changeset 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
files .hgignore dwt/DWT.d dwt/DWTError.d dwt/DWTException.d dwt/accessibility/ACC.d dwt/accessibility/Accessible.d dwt/accessibility/AccessibleAdapter.d dwt/accessibility/AccessibleControlAdapter.d dwt/accessibility/AccessibleControlEvent.d dwt/accessibility/AccessibleControlListener.d dwt/accessibility/AccessibleEvent.d dwt/accessibility/AccessibleListener.d dwt/accessibility/AccessibleTextAdapter.d dwt/accessibility/AccessibleTextEvent.d dwt/accessibility/AccessibleTextListener.d dwt/browser/AppFileLocProvider.d dwt/browser/Browser.d dwt/browser/CloseWindowListener.d dwt/browser/Download.d dwt/browser/DownloadFactory.d dwt/browser/DownloadFactory_1_8.d dwt/browser/Download_1_8.d dwt/browser/FilePicker.d dwt/browser/FilePickerFactory.d dwt/browser/FilePickerFactory_1_8.d dwt/browser/FilePicker_1_8.d dwt/browser/HelperAppLauncherDialog.d dwt/browser/HelperAppLauncherDialogFactory.d dwt/browser/InputStream.d dwt/browser/LocationAdapter.d dwt/browser/LocationEvent.d dwt/browser/LocationListener.d dwt/browser/Mozilla.d dwt/browser/MozillaDelegate.d dwt/browser/OpenWindowListener.d dwt/browser/ProgressAdapter.d dwt/browser/ProgressEvent.d dwt/browser/ProgressListener.d dwt/browser/PromptDialog.d dwt/browser/PromptService2.d dwt/browser/PromptService2Factory.d dwt/browser/Safari.d dwt/browser/SimpleEnumerator.d dwt/browser/StatusTextEvent.d dwt/browser/StatusTextListener.d dwt/browser/TitleEvent.d dwt/browser/TitleListener.d dwt/browser/VisibilityWindowAdapter.d dwt/browser/VisibilityWindowListener.d dwt/browser/WebBrowser.d dwt/browser/WindowCreator2.d dwt/browser/WindowEvent.d dwt/custom/AnimatedProgress.d dwt/custom/BidiSegmentEvent.d dwt/custom/BidiSegmentListener.d dwt/custom/Bullet.d dwt/custom/BusyIndicator.d dwt/custom/CBanner.d dwt/custom/CBannerLayout.d dwt/custom/CCombo.d dwt/custom/CLabel.d dwt/custom/CLayoutData.d dwt/custom/CTabFolder.d dwt/custom/CTabFolder2Adapter.d dwt/custom/CTabFolder2Listener.d dwt/custom/CTabFolderAdapter.d dwt/custom/CTabFolderEvent.d dwt/custom/CTabFolderLayout.d dwt/custom/CTabFolderListener.d dwt/custom/CTabItem.d dwt/custom/ControlEditor.d dwt/custom/DefaultContent.d dwt/custom/ExtendedModifyEvent.d dwt/custom/ExtendedModifyListener.d dwt/custom/LineBackgroundEvent.d dwt/custom/LineBackgroundListener.d dwt/custom/LineStyleEvent.d dwt/custom/LineStyleListener.d dwt/custom/MovementEvent.d dwt/custom/MovementListener.d dwt/custom/PaintObjectEvent.d dwt/custom/PaintObjectListener.d dwt/custom/PopupList.d dwt/custom/ST.d dwt/custom/SashForm.d dwt/custom/SashFormData.d dwt/custom/SashFormLayout.d dwt/custom/ScrolledComposite.d dwt/custom/ScrolledCompositeLayout.d dwt/custom/StackLayout.d dwt/custom/StyleRange.d dwt/custom/StyledText.d dwt/custom/StyledTextContent.d dwt/custom/StyledTextDropTargetEffect.d dwt/custom/StyledTextEvent.d dwt/custom/StyledTextListener.d dwt/custom/StyledTextPrintOptions.d dwt/custom/StyledTextRenderer.d dwt/custom/TableCursor.d dwt/custom/TableEditor.d dwt/custom/TableTree.d dwt/custom/TableTreeEditor.d dwt/custom/TableTreeItem.d dwt/custom/TextChangeListener.d dwt/custom/TextChangedEvent.d dwt/custom/TextChangingEvent.d dwt/custom/TreeEditor.d dwt/custom/VerifyKeyListener.d dwt/custom/ViewForm.d dwt/custom/ViewFormLayout.d dwt/dnd/ByteArrayTransfer.d dwt/dnd/Clipboard.d dwt/dnd/DND.d dwt/dnd/DNDEvent.d dwt/dnd/DNDListener.d dwt/dnd/DragSource.d dwt/dnd/DragSourceAdapter.d dwt/dnd/DragSourceEffect.d dwt/dnd/DragSourceEvent.d dwt/dnd/DragSourceListener.d dwt/dnd/DropTarget.d dwt/dnd/DropTargetAdapter.d dwt/dnd/DropTargetEffect.d dwt/dnd/DropTargetEvent.d dwt/dnd/DropTargetListener.d dwt/dnd/FileTransfer.d dwt/dnd/HTMLTransfer.d dwt/dnd/ImageTransfer.d dwt/dnd/RTFTransfer.d dwt/dnd/TableDragSourceEffect.d dwt/dnd/TableDropTargetEffect.d dwt/dnd/TextTransfer.d dwt/dnd/Transfer.d dwt/dnd/TransferData.d dwt/dnd/TreeDragSourceEffect.d dwt/dnd/TreeDropTargetEffect.d dwt/dnd/URLTransfer.d dwt/dwthelper/BufferedInputStream.d dwt/dwthelper/BufferedOutputStream.d dwt/dwthelper/ByteArrayInputStream.d dwt/dwthelper/ByteArrayOutputStream.d dwt/dwthelper/File.d dwt/dwthelper/FileInputStream.d dwt/dwthelper/FileOutputStream.d dwt/dwthelper/InflaterInputStream.d dwt/dwthelper/InputStream.d dwt/dwthelper/OutputStream.d dwt/dwthelper/ResourceBundle.d dwt/dwthelper/Runnable.d dwt/dwthelper/System.d dwt/dwthelper/WeakHashMap.d dwt/dwthelper/WeakRef.d dwt/dwthelper/XmlTranscode.d dwt/dwthelper/utils.d dwt/effects/Effect.d dwt/events/ArmEvent.d dwt/events/ArmListener.d dwt/events/ControlAdapter.d dwt/events/ControlEvent.d dwt/events/ControlListener.d dwt/events/DisposeEvent.d dwt/events/DisposeListener.d dwt/events/DragDetectEvent.d dwt/events/DragDetectListener.d dwt/events/ExpandAdapter.d dwt/events/ExpandEvent.d dwt/events/ExpandListener.d dwt/events/FocusAdapter.d dwt/events/FocusEvent.d dwt/events/FocusListener.d dwt/events/HelpEvent.d dwt/events/HelpListener.d dwt/events/KeyAdapter.d dwt/events/KeyEvent.d dwt/events/KeyListener.d dwt/events/MenuAdapter.d dwt/events/MenuDetectEvent.d dwt/events/MenuDetectListener.d dwt/events/MenuEvent.d dwt/events/MenuListener.d dwt/events/ModifyEvent.d dwt/events/ModifyListener.d dwt/events/MouseAdapter.d dwt/events/MouseEvent.d dwt/events/MouseListener.d dwt/events/MouseMoveListener.d dwt/events/MouseTrackAdapter.d dwt/events/MouseTrackListener.d dwt/events/MouseWheelListener.d dwt/events/PaintEvent.d dwt/events/PaintListener.d dwt/events/SelectionAdapter.d dwt/events/SelectionEvent.d dwt/events/SelectionListener.d dwt/events/ShellAdapter.d dwt/events/ShellEvent.d dwt/events/ShellListener.d dwt/events/TraverseEvent.d dwt/events/TraverseListener.d dwt/events/TreeAdapter.d dwt/events/TreeEvent.d dwt/events/TreeListener.d dwt/events/TypedEvent.d dwt/events/VerifyEvent.d dwt/events/VerifyListener.d dwt/graphics/Color.d dwt/graphics/Cursor.d dwt/graphics/Device.d dwt/graphics/DeviceData.d dwt/graphics/Drawable.d dwt/graphics/Font.d dwt/graphics/FontData.d dwt/graphics/FontMetrics.d dwt/graphics/GC.d dwt/graphics/GCData.d dwt/graphics/GlyphMetrics.d dwt/graphics/Image.d dwt/graphics/ImageData.d dwt/graphics/ImageDataLoader.d dwt/graphics/ImageLoader.d dwt/graphics/ImageLoaderEvent.d dwt/graphics/ImageLoaderListener.d dwt/graphics/LineAttributes.d dwt/graphics/PaletteData.d dwt/graphics/Path.d dwt/graphics/PathData.d dwt/graphics/Pattern.d dwt/graphics/Point.d dwt/graphics/RGB.d dwt/graphics/Rectangle.d dwt/graphics/Region.d dwt/graphics/Resource.d dwt/graphics/TextLayout.d dwt/graphics/TextStyle.d dwt/graphics/Transform.d dwt/internal/BidiUtil.d dwt/internal/C.d dwt/internal/Callback.d dwt/internal/CloneableCompatibility.d dwt/internal/Compatibility.d dwt/internal/DWTEventListener.d dwt/internal/DWTEventObject.d dwt/internal/LONG.d dwt/internal/Library.d dwt/internal/Lock.d dwt/internal/Platform.d dwt/internal/SerializableCompatibility.d dwt/internal/c/callback.d dwt/internal/c/carboncore/MacTypes.d dwt/internal/c/qd/Quickdraw.d dwt/internal/c/qd/QuickdrawTypes.d dwt/internal/c/qd/bindings.d dwt/internal/c/swt.d dwt/internal/cocoa/CFNumberFormatter.d dwt/internal/cocoa/CFPropertyList.d dwt/internal/cocoa/CFRunLoopRef.d dwt/internal/cocoa/CGBase.d dwt/internal/cocoa/CGColorSpace.d dwt/internal/cocoa/CGEventTypes.d dwt/internal/cocoa/CGFloat.d dwt/internal/cocoa/CGPoint.d dwt/internal/cocoa/CGRect.d dwt/internal/cocoa/CGSize.d dwt/internal/cocoa/CIColor.d dwt/internal/cocoa/CIImage.d dwt/internal/cocoa/DOMDocument.d dwt/internal/cocoa/DOMEvent.d dwt/internal/cocoa/DOMKeyboardEvent.d dwt/internal/cocoa/DOMMouseEvent.d dwt/internal/cocoa/DOMWheelEvent.d dwt/internal/cocoa/IconRef.d dwt/internal/cocoa/MacGenerator.d dwt/internal/cocoa/NSATSTypesetter.d dwt/internal/cocoa/NSActionCell.d dwt/internal/cocoa/NSAffineTransform.d dwt/internal/cocoa/NSAffineTransformStruct.d dwt/internal/cocoa/NSAlert.d dwt/internal/cocoa/NSAnimation.d dwt/internal/cocoa/NSAnimationContext.d dwt/internal/cocoa/NSAppleEventDescriptor.d dwt/internal/cocoa/NSAppleEventManager.d dwt/internal/cocoa/NSAppleScript.d dwt/internal/cocoa/NSApplication.d dwt/internal/cocoa/NSArchiver.d dwt/internal/cocoa/NSArray.d dwt/internal/cocoa/NSArrayController.d dwt/internal/cocoa/NSAssertionHandler.d dwt/internal/cocoa/NSAttributeType.d dwt/internal/cocoa/NSAttributedString.d dwt/internal/cocoa/NSAutoreleasePool.d dwt/internal/cocoa/NSBezierPath.d dwt/internal/cocoa/NSBitmapImageRep.d dwt/internal/cocoa/NSBox.d dwt/internal/cocoa/NSBrowser.d dwt/internal/cocoa/NSBrowserCell.d dwt/internal/cocoa/NSBundle.d dwt/internal/cocoa/NSButton.d dwt/internal/cocoa/NSButtonCell.d dwt/internal/cocoa/NSCIImageRep.d dwt/internal/cocoa/NSCachedImageRep.d dwt/internal/cocoa/NSCachedURLResponse.d dwt/internal/cocoa/NSCalendar.d dwt/internal/cocoa/NSCalendarDate.d dwt/internal/cocoa/NSCell.d dwt/internal/cocoa/NSCharacterSet.d dwt/internal/cocoa/NSClassDescription.d dwt/internal/cocoa/NSClipView.d dwt/internal/cocoa/NSCloneCommand.d dwt/internal/cocoa/NSCloseCommand.d dwt/internal/cocoa/NSCoder.d dwt/internal/cocoa/NSCollectionView.d dwt/internal/cocoa/NSCollectionViewItem.d dwt/internal/cocoa/NSColor.d dwt/internal/cocoa/NSColorList.d dwt/internal/cocoa/NSColorPanel.d dwt/internal/cocoa/NSColorPicker.d dwt/internal/cocoa/NSColorSpace.d dwt/internal/cocoa/NSColorWell.d dwt/internal/cocoa/NSComboBox.d dwt/internal/cocoa/NSComboBoxCell.d dwt/internal/cocoa/NSComparisonPredicate.d dwt/internal/cocoa/NSComparisonResult.d dwt/internal/cocoa/NSCompoundPredicate.d dwt/internal/cocoa/NSCondition.d dwt/internal/cocoa/NSConditionLock.d dwt/internal/cocoa/NSConnection.d dwt/internal/cocoa/NSControl.d dwt/internal/cocoa/NSController.d dwt/internal/cocoa/NSCountedSet.d dwt/internal/cocoa/NSCreateCommand.d dwt/internal/cocoa/NSCursor.d dwt/internal/cocoa/NSCustomImageRep.d dwt/internal/cocoa/NSData.d dwt/internal/cocoa/NSDate.d dwt/internal/cocoa/NSDateComponents.d dwt/internal/cocoa/NSDateFormatter.d dwt/internal/cocoa/NSDatePicker.d dwt/internal/cocoa/NSDatePickerCell.d dwt/internal/cocoa/NSDecimal.d dwt/internal/cocoa/NSDecimalNumber.d dwt/internal/cocoa/NSDecimalNumberHandler.d dwt/internal/cocoa/NSDeleteCommand.d dwt/internal/cocoa/NSDictionary.d dwt/internal/cocoa/NSDictionaryController.d dwt/internal/cocoa/NSDirectoryEnumerator.d dwt/internal/cocoa/NSDistantObject.d dwt/internal/cocoa/NSDistantObjectRequest.d dwt/internal/cocoa/NSDistributedLock.d dwt/internal/cocoa/NSDistributedNotificationCenter.d dwt/internal/cocoa/NSDockTile.d dwt/internal/cocoa/NSDocument.d dwt/internal/cocoa/NSDocumentController.d dwt/internal/cocoa/NSDragOperation.d dwt/internal/cocoa/NSDrawer.d dwt/internal/cocoa/NSEPSImageRep.d dwt/internal/cocoa/NSEnumerator.d dwt/internal/cocoa/NSError.d dwt/internal/cocoa/NSEvent.d dwt/internal/cocoa/NSException.d dwt/internal/cocoa/NSExpression.d dwt/internal/cocoa/NSFileHandle.d dwt/internal/cocoa/NSFileManager.d dwt/internal/cocoa/NSFileWrapper.d dwt/internal/cocoa/NSFocusRingType.d dwt/internal/cocoa/NSFont.d dwt/internal/cocoa/NSFontDescriptor.d dwt/internal/cocoa/NSFontManager.d dwt/internal/cocoa/NSFontPanel.d dwt/internal/cocoa/NSForm.d dwt/internal/cocoa/NSFormCell.d dwt/internal/cocoa/NSFormatter.d dwt/internal/cocoa/NSGarbageCollector.d dwt/internal/cocoa/NSGlyphGenerator.d dwt/internal/cocoa/NSGlyphInfo.d dwt/internal/cocoa/NSGradient.d dwt/internal/cocoa/NSGraphicsContext.d dwt/internal/cocoa/NSHTTPCookie.d dwt/internal/cocoa/NSHTTPCookieStorage.d dwt/internal/cocoa/NSHTTPURLResponse.d dwt/internal/cocoa/NSHashEnumerator.d dwt/internal/cocoa/NSHashTable.d dwt/internal/cocoa/NSHashTableCallBacks.d dwt/internal/cocoa/NSHelpManager.d dwt/internal/cocoa/NSHost.d dwt/internal/cocoa/NSImage.d dwt/internal/cocoa/NSImageCell.d dwt/internal/cocoa/NSImageRep.d dwt/internal/cocoa/NSImageView.d dwt/internal/cocoa/NSIndexPath.d dwt/internal/cocoa/NSIndexSet.d dwt/internal/cocoa/NSIndexSpecifier.d dwt/internal/cocoa/NSInputManager.d dwt/internal/cocoa/NSInputServer.d dwt/internal/cocoa/NSInputStream.d dwt/internal/cocoa/NSInteger.d dwt/internal/cocoa/NSInterfaceStyle.d dwt/internal/cocoa/NSInvocation.d dwt/internal/cocoa/NSInvocationOperation.d dwt/internal/cocoa/NSKeyValueObserving.d dwt/internal/cocoa/NSKeyedArchiver.d dwt/internal/cocoa/NSKeyedUnarchiver.d dwt/internal/cocoa/NSLayoutManager.d dwt/internal/cocoa/NSLevelIndicator.d dwt/internal/cocoa/NSLevelIndicatorCell.d dwt/internal/cocoa/NSLocale.d dwt/internal/cocoa/NSLock.d dwt/internal/cocoa/NSLogicalTest.d dwt/internal/cocoa/NSMachBootstrapServer.d dwt/internal/cocoa/NSMachPort.d dwt/internal/cocoa/NSMapEnumerator.d dwt/internal/cocoa/NSMapTable.d dwt/internal/cocoa/NSMapTableKeyCallBacks.d dwt/internal/cocoa/NSMapTableValueCallBacks.d dwt/internal/cocoa/NSMatrix.d dwt/internal/cocoa/NSMenu.d dwt/internal/cocoa/NSMenuItem.d dwt/internal/cocoa/NSMenuItemCell.d dwt/internal/cocoa/NSMenuView.d dwt/internal/cocoa/NSMessagePortNameServer.d dwt/internal/cocoa/NSMetadataItem.d dwt/internal/cocoa/NSMetadataQuery.d dwt/internal/cocoa/NSMetadataQueryAttributeValueTuple.d dwt/internal/cocoa/NSMetadataQueryResultGroup.d dwt/internal/cocoa/NSMethodSignature.d dwt/internal/cocoa/NSMoveCommand.d dwt/internal/cocoa/NSMovie.d dwt/internal/cocoa/NSMovieView.d dwt/internal/cocoa/NSMutableArray.d dwt/internal/cocoa/NSMutableAttributedString.d dwt/internal/cocoa/NSMutableCharacterSet.d dwt/internal/cocoa/NSMutableData.d dwt/internal/cocoa/NSMutableDictionary.d dwt/internal/cocoa/NSMutableIndexSet.d dwt/internal/cocoa/NSMutableParagraphStyle.d dwt/internal/cocoa/NSMutableSet.d dwt/internal/cocoa/NSMutableString.d dwt/internal/cocoa/NSMutableURLRequest.d dwt/internal/cocoa/NSNameSpecifier.d dwt/internal/cocoa/NSNetService.d dwt/internal/cocoa/NSNetServiceBrowser.d dwt/internal/cocoa/NSNib.d dwt/internal/cocoa/NSNibConnector.d dwt/internal/cocoa/NSNibControlConnector.d dwt/internal/cocoa/NSNibOutletConnector.d dwt/internal/cocoa/NSNotification.d dwt/internal/cocoa/NSNotificationCenter.d dwt/internal/cocoa/NSNotificationQueue.d dwt/internal/cocoa/NSNull.d dwt/internal/cocoa/NSNumber.d dwt/internal/cocoa/NSNumberFormatter.d dwt/internal/cocoa/NSObject.d dwt/internal/cocoa/NSObjectController.d dwt/internal/cocoa/NSOpenGLContext.d dwt/internal/cocoa/NSOpenGLPixelBuffer.d dwt/internal/cocoa/NSOpenGLPixelFormat.d dwt/internal/cocoa/NSOpenGLView.d dwt/internal/cocoa/NSOpenPanel.d dwt/internal/cocoa/NSOperation.d dwt/internal/cocoa/NSOperationQueue.d dwt/internal/cocoa/NSOutlineView.d dwt/internal/cocoa/NSOutputStream.d dwt/internal/cocoa/NSPDFImageRep.d dwt/internal/cocoa/NSPICTImageRep.d dwt/internal/cocoa/NSPageLayout.d dwt/internal/cocoa/NSPanel.d dwt/internal/cocoa/NSParagraphStyle.d dwt/internal/cocoa/NSPasteboard.d dwt/internal/cocoa/NSPathCell.d dwt/internal/cocoa/NSPathComponentCell.d dwt/internal/cocoa/NSPathControl.d dwt/internal/cocoa/NSPersistentDocument.d dwt/internal/cocoa/NSPipe.d dwt/internal/cocoa/NSPoint.d dwt/internal/cocoa/NSPointerArray.d dwt/internal/cocoa/NSPointerFunctions.d dwt/internal/cocoa/NSPopUpButton.d dwt/internal/cocoa/NSPopUpButtonCell.d dwt/internal/cocoa/NSPort.d dwt/internal/cocoa/NSPortCoder.d dwt/internal/cocoa/NSPortMessage.d dwt/internal/cocoa/NSPortNameServer.d dwt/internal/cocoa/NSPositionalSpecifier.d dwt/internal/cocoa/NSPredicate.d dwt/internal/cocoa/NSPredicateEditor.d dwt/internal/cocoa/NSPredicateEditorRowTemplate.d dwt/internal/cocoa/NSPrintInfo.d dwt/internal/cocoa/NSPrintOperation.d dwt/internal/cocoa/NSPrintPanel.d dwt/internal/cocoa/NSPrinter.d dwt/internal/cocoa/NSProcessInfo.d dwt/internal/cocoa/NSProgressIndicator.d dwt/internal/cocoa/NSPropertyListFormat.d dwt/internal/cocoa/NSPropertyListSerialization.d dwt/internal/cocoa/NSProtocolChecker.d dwt/internal/cocoa/NSProxy.d dwt/internal/cocoa/NSQuickDrawView.d dwt/internal/cocoa/NSQuitCommand.d dwt/internal/cocoa/NSRange.d dwt/internal/cocoa/NSRangeSpecifier.d dwt/internal/cocoa/NSRect.d dwt/internal/cocoa/NSRecursiveLock.d dwt/internal/cocoa/NSRelativeSpecifier.d dwt/internal/cocoa/NSResponder.d dwt/internal/cocoa/NSRuleEditor.d dwt/internal/cocoa/NSRulerMarker.d dwt/internal/cocoa/NSRulerView.d dwt/internal/cocoa/NSRunLoop.d dwt/internal/cocoa/NSSavePanel.d dwt/internal/cocoa/NSScanner.d dwt/internal/cocoa/NSScreen.d dwt/internal/cocoa/NSScriptClassDescription.d dwt/internal/cocoa/NSScriptCoercionHandler.d dwt/internal/cocoa/NSScriptCommand.d dwt/internal/cocoa/NSScriptCommandDescription.d dwt/internal/cocoa/NSScriptExecutionContext.d dwt/internal/cocoa/NSScriptObjectSpecifier.d dwt/internal/cocoa/NSScriptSuiteRegistry.d dwt/internal/cocoa/NSScriptWhoseTest.d dwt/internal/cocoa/NSScrollView.d dwt/internal/cocoa/NSScroller.d dwt/internal/cocoa/NSSearchField.d dwt/internal/cocoa/NSSearchFieldCell.d dwt/internal/cocoa/NSSecureTextField.d dwt/internal/cocoa/NSSecureTextFieldCell.d dwt/internal/cocoa/NSSegmentedCell.d dwt/internal/cocoa/NSSegmentedControl.d dwt/internal/cocoa/NSSet.d dwt/internal/cocoa/NSSetCommand.d dwt/internal/cocoa/NSShadow.d dwt/internal/cocoa/NSSize.d dwt/internal/cocoa/NSSlider.d dwt/internal/cocoa/NSSliderCell.d dwt/internal/cocoa/NSSocketPort.d dwt/internal/cocoa/NSSocketPortNameServer.d dwt/internal/cocoa/NSSortDescriptor.d dwt/internal/cocoa/NSSound.d dwt/internal/cocoa/NSSpecifierTest.d dwt/internal/cocoa/NSSpeechRecognizer.d dwt/internal/cocoa/NSSpeechSynthesizer.d dwt/internal/cocoa/NSSpellChecker.d dwt/internal/cocoa/NSSpellServer.d dwt/internal/cocoa/NSSplitView.d dwt/internal/cocoa/NSStatusBar.d dwt/internal/cocoa/NSStatusItem.d dwt/internal/cocoa/NSStepper.d dwt/internal/cocoa/NSStepperCell.d dwt/internal/cocoa/NSStream.d dwt/internal/cocoa/NSString.d dwt/internal/cocoa/NSSwappedDouble.d dwt/internal/cocoa/NSSwappedFloat.d dwt/internal/cocoa/NSTabView.d dwt/internal/cocoa/NSTabViewItem.d dwt/internal/cocoa/NSTableColumn.d dwt/internal/cocoa/NSTableHeaderCell.d dwt/internal/cocoa/NSTableHeaderView.d dwt/internal/cocoa/NSTableView.d dwt/internal/cocoa/NSTask.d dwt/internal/cocoa/NSText.d dwt/internal/cocoa/NSTextAttachment.d dwt/internal/cocoa/NSTextBlock.d dwt/internal/cocoa/NSTextContainer.d dwt/internal/cocoa/NSTextField.d dwt/internal/cocoa/NSTextFieldCell.d dwt/internal/cocoa/NSTextList.d dwt/internal/cocoa/NSTextStorage.d dwt/internal/cocoa/NSTextTab.d dwt/internal/cocoa/NSTextTable.d dwt/internal/cocoa/NSTextTableBlock.d dwt/internal/cocoa/NSTextView.d dwt/internal/cocoa/NSThread.d dwt/internal/cocoa/NSTimeInterval.d dwt/internal/cocoa/NSTimeZone.d dwt/internal/cocoa/NSTimer.d dwt/internal/cocoa/NSTokenField.d dwt/internal/cocoa/NSTokenFieldCell.d dwt/internal/cocoa/NSToolbar.d dwt/internal/cocoa/NSToolbarItem.d dwt/internal/cocoa/NSToolbarItemGroup.d dwt/internal/cocoa/NSTrackingArea.d dwt/internal/cocoa/NSTreeController.d dwt/internal/cocoa/NSTreeNode.d dwt/internal/cocoa/NSTypesetter.d dwt/internal/cocoa/NSURL.d dwt/internal/cocoa/NSURLAuthenticationChallenge.d dwt/internal/cocoa/NSURLCache.d dwt/internal/cocoa/NSURLConnection.d dwt/internal/cocoa/NSURLCredential.d dwt/internal/cocoa/NSURLCredentialStorage.d dwt/internal/cocoa/NSURLDownload.d dwt/internal/cocoa/NSURLHandle.d dwt/internal/cocoa/NSURLProtectionSpace.d dwt/internal/cocoa/NSURLProtocol.d dwt/internal/cocoa/NSURLRequest.d dwt/internal/cocoa/NSURLResponse.d dwt/internal/cocoa/NSUnarchiver.d dwt/internal/cocoa/NSUndoManager.d dwt/internal/cocoa/NSUniqueIDSpecifier.d dwt/internal/cocoa/NSUserDefaults.d dwt/internal/cocoa/NSUserDefaultsController.d dwt/internal/cocoa/NSValue.d dwt/internal/cocoa/NSValueTransformer.d dwt/internal/cocoa/NSView.d dwt/internal/cocoa/NSViewAnimation.d dwt/internal/cocoa/NSViewController.d dwt/internal/cocoa/NSWhoseSpecifier.d dwt/internal/cocoa/NSWindow.d dwt/internal/cocoa/NSWindowController.d dwt/internal/cocoa/NSWorkspace.d dwt/internal/cocoa/NSXMLDTD.d dwt/internal/cocoa/NSXMLDTDNode.d dwt/internal/cocoa/NSXMLDocument.d dwt/internal/cocoa/NSXMLElement.d dwt/internal/cocoa/NSXMLNode.d dwt/internal/cocoa/NSXMLParser.d dwt/internal/cocoa/NSZone.d dwt/internal/cocoa/OS.d dwt/internal/cocoa/SWTApplicationDelegate.d dwt/internal/cocoa/SWTBox.d dwt/internal/cocoa/SWTButton.d dwt/internal/cocoa/SWTComboBox.d dwt/internal/cocoa/SWTDatePicker.d dwt/internal/cocoa/SWTImageView.d dwt/internal/cocoa/SWTMenu.d dwt/internal/cocoa/SWTMenuItem.d dwt/internal/cocoa/SWTOutlineView.d dwt/internal/cocoa/SWTPanelDelegate.d dwt/internal/cocoa/SWTPopUpButton.d dwt/internal/cocoa/SWTProgressIndicator.d dwt/internal/cocoa/SWTScrollView.d dwt/internal/cocoa/SWTScroller.d dwt/internal/cocoa/SWTSlider.d dwt/internal/cocoa/SWTStepper.d dwt/internal/cocoa/SWTTabView.d dwt/internal/cocoa/SWTTableView.d dwt/internal/cocoa/SWTTextField.d dwt/internal/cocoa/SWTTextView.d dwt/internal/cocoa/SWTTreeItem.d dwt/internal/cocoa/SWTView.d dwt/internal/cocoa/SWTWebViewDelegate.d dwt/internal/cocoa/SWTWindow.d dwt/internal/cocoa/SWTWindowDelegate.d dwt/internal/cocoa/WebDataSource.d dwt/internal/cocoa/WebDocumentRepresentation.d dwt/internal/cocoa/WebFrame.d dwt/internal/cocoa/WebFrameView.d dwt/internal/cocoa/WebOpenPanelResultListener.d dwt/internal/cocoa/WebPolicyDecisionListener.d dwt/internal/cocoa/WebPreferences.d dwt/internal/cocoa/WebView.d dwt/internal/cocoa/gl.d dwt/internal/cocoa/id.d dwt/internal/cocoa/objc_super.d dwt/internal/image/FileFormat.d dwt/internal/image/GIFFileFormat.d dwt/internal/image/JPEGAppn.d dwt/internal/image/JPEGArithmeticConditioningTable.d dwt/internal/image/JPEGComment.d dwt/internal/image/JPEGDecoder.d dwt/internal/image/JPEGEndOfImage.d dwt/internal/image/JPEGFileFormat.d dwt/internal/image/JPEGFixedSizeSegment.d dwt/internal/image/JPEGFrameHeader.d dwt/internal/image/JPEGHuffmanTable.d dwt/internal/image/JPEGQuantizationTable.d dwt/internal/image/JPEGRestartInterval.d dwt/internal/image/JPEGScanHeader.d dwt/internal/image/JPEGSegment.d dwt/internal/image/JPEGStartOfImage.d dwt/internal/image/JPEGVariableSizeSegment.d dwt/internal/image/LEDataInputStream.d dwt/internal/image/LEDataOutputStream.d dwt/internal/image/LZWCodec.d dwt/internal/image/LZWNode.d dwt/internal/image/OS2BMPFileFormat.d dwt/internal/image/PNGFileFormat.d dwt/internal/image/PngChunk.d dwt/internal/image/PngChunkReader.d dwt/internal/image/PngDecodingDataStream.d dwt/internal/image/PngDeflater.d dwt/internal/image/PngEncoder.d dwt/internal/image/PngFileReadState.d dwt/internal/image/PngHuffmanTable.d dwt/internal/image/PngHuffmanTables.d dwt/internal/image/PngIdatChunk.d dwt/internal/image/PngIendChunk.d dwt/internal/image/PngIhdrChunk.d dwt/internal/image/PngInputStream.d dwt/internal/image/PngLzBlockReader.d dwt/internal/image/PngPlteChunk.d dwt/internal/image/PngTrnsChunk.d dwt/internal/image/TIFFDirectory.d dwt/internal/image/TIFFFileFormat.d dwt/internal/image/TIFFModifiedHuffmanCodec.d dwt/internal/image/TIFFRandomFileAccess.d dwt/internal/image/WinBMPFileFormat.d dwt/internal/image/WinICOFileFormat.d dwt/internal/objc/appkit/AppKit.d dwt/internal/objc/appkit/NSAccessibility.d dwt/internal/objc/appkit/NSAttributedString.d dwt/internal/objc/appkit/NSGraphics.d dwt/internal/objc/appkit/NSScreen.d dwt/internal/objc/appkit/bindings.d dwt/internal/objc/bindings.d dwt/internal/objc/cocoa/Cocoa.d dwt/internal/objc/foundation/Foundation.d dwt/internal/objc/foundation/NSHFSFileTypes.d dwt/internal/objc/foundation/NSRunLoop.d dwt/internal/objc/foundation/bindings.d dwt/internal/objc/runtime.d dwt/internal/theme/ButtonDrawData.d dwt/internal/theme/ComboDrawData.d dwt/internal/theme/DrawData.d dwt/internal/theme/ExpanderDrawData.d dwt/internal/theme/GroupDrawData.d dwt/internal/theme/ProgressBarDrawData.d dwt/internal/theme/RangeDrawData.d dwt/internal/theme/ScaleDrawData.d dwt/internal/theme/ScrollBarDrawData.d dwt/internal/theme/TabFolderDrawData.d dwt/internal/theme/TabItemDrawData.d dwt/internal/theme/Theme.d dwt/internal/theme/ToolBarDrawData.d dwt/internal/theme/ToolItemDrawData.d dwt/layout/FillData.d dwt/layout/FillLayout.d dwt/layout/FormAttachment.d dwt/layout/FormData.d dwt/layout/FormLayout.d dwt/layout/GridData.d dwt/layout/GridLayout.d dwt/layout/RowData.d dwt/layout/RowLayout.d dwt/opengl/GLCanvas.d dwt/opengl/GLData.d dwt/printing/PrintDialog.d dwt/printing/Printer.d dwt/printing/PrinterData.d dwt/program/Program.d dwt/widgets/Button.d dwt/widgets/Canvas.d dwt/widgets/Caret.d dwt/widgets/ColorDialog.d dwt/widgets/Combo.d dwt/widgets/Composite.d dwt/widgets/Control.d dwt/widgets/CoolBar.d dwt/widgets/CoolItem.d dwt/widgets/DateTime.d dwt/widgets/Decorations.d dwt/widgets/Dialog.d dwt/widgets/DirectoryDialog.d dwt/widgets/Display.d dwt/widgets/Event.d dwt/widgets/EventTable.d dwt/widgets/ExpandBar.d dwt/widgets/ExpandItem.d dwt/widgets/FileDialog.d dwt/widgets/FontDialog.d dwt/widgets/Group.d dwt/widgets/IME.d dwt/widgets/Item.d dwt/widgets/Label.d dwt/widgets/Layout.d dwt/widgets/Link.d dwt/widgets/List.d dwt/widgets/Listener.d dwt/widgets/Menu.d dwt/widgets/MenuItem.d dwt/widgets/MessageBox.d dwt/widgets/Monitor.d dwt/widgets/ProgressBar.d dwt/widgets/RunnableLock.d dwt/widgets/Sash.d dwt/widgets/Scale.d dwt/widgets/ScrollBar.d dwt/widgets/Scrollable.d dwt/widgets/Shell.d dwt/widgets/Slider.d dwt/widgets/Spinner.d dwt/widgets/Synchronizer.d dwt/widgets/TabFolder.d dwt/widgets/TabItem.d dwt/widgets/Table.d dwt/widgets/TableColumn.d dwt/widgets/TableItem.d dwt/widgets/Text.d dwt/widgets/ToolBar.d dwt/widgets/ToolItem.d dwt/widgets/ToolTip.d dwt/widgets/Tracker.d dwt/widgets/Tray.d dwt/widgets/TrayItem.d dwt/widgets/Tree.d dwt/widgets/TreeColumn.d dwt/widgets/TreeItem.d dwt/widgets/TypedListener.d dwt/widgets/Widget.d
diffstat 797 files changed, 208812 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,3 @@
+syntax: glob
+*.DS_Store
+*.o
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/DWT.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,3893 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.DWT;
+
+import tango.core.Exception;
+
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.dwthelper.utils;
+import dwt.internal.Platform;
+import dwt.internal.Compatibility;
+import dwt.internal.Library;
+
+/**
+ * This class provides access to a small number of DWT system-wide
+ * methods, and in addition defines the public constants provided
+ * by DWT.
+ * <p>
+ * 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.
+ * </p><p>
+ * 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 <em>HINT</em>s. The set of widgets which support a particular
+ * <em>HINT</em> may change from release to release, although we typically
+ * will not withdraw support for a <em>HINT</em> once it is made available.
+ * </p>
+ */
+
+/* NOTE:
+ *   Good javadoc coding style is to put the values of static final 
+ *   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 <em>not</em> 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).
+     * <p>
+     * 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.
+     * </p>
+     * 
+     * @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;
+
+    /**
+     * The IME composition event type (value is 43).  
+     * <p>
+     * The IME composition event is sent to allow
+     * custom text editors to implement in-line
+     * editing of international text. 
+     * </p> 
+     * 
+     * The detail field indicates the action to be taken:
+     * <p><ul>
+     * <li>{@link DWT#COMPOSITION_CHANGED}</li>
+     * <li>{@link DWT#COMPOSITION_OFFSET}</li>
+     * <li>{@link DWT#COMPOSITION_SELECTION}</li>
+     * </ul></p>
+     * 
+     * @see dwt.widgets.Widget#addListener
+     * @see dwt.widgets.Display#addFilter
+     * @see dwt.widgets.Event
+     * 
+     * @since 3.4
+     */
+    public static const int ImeComposition = 43;
+
+    /* Event Details */
+
+    /**
+     * The IME composition event detail that indicates
+     * a change in the IME composition. The text field
+     * of the event is the new composition text. 
+     * The start and end indicate the offsets where the
+     * composition text should be inserted.
+     * The styles and ranges are stored in the IME 
+     * object (value is 1).
+     * 
+     * @see DWT#ImeComposition
+     * 
+     * @since 3.4
+     */
+    public static const int COMPOSITION_CHANGED = 1;
+
+    /**
+     * The IME composition event detail that indicates
+     * that the IME needs the offset for a given location.
+     * The x and y fields of the event are used by the 
+     * application to determine the offset.
+     * 
+     * The index field of the event should be set to the 
+     * text offset at that location. The count field should 
+     * be set to indicate whether the location is closer to
+     * the leading edge (0) or the trailing edge (1) (value is 2).
+     * 
+     * @see DWT#ImeComposition
+     * @see dwt.graphics.TextLayout#getOffset(int, int, int[])
+     * 
+     * @since 3.4
+     */
+    public static const int COMPOSITION_OFFSET = 2;
+
+    /**
+     * The IME composition event detail that indicates
+     * that IME needs the selected text and its start
+     * and end offsets (value is 3).
+     * 
+     * @see DWT#ImeComposition
+     * 
+     * @since 3.4
+     */
+    public static const int COMPOSITION_SELECTION = 3;
+
+    /**
+     * 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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Menu</code></li>
+     * </ul></p>
+     */
+    public static const int BAR = 1 << 1;
+
+    /**
+     * Style constant for drop down menu/list behavior (value is 1&lt;&lt;2).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Menu</code></li>
+     * <li><code>ToolItem</code></li>
+     * <li><code>CoolItem</code></li>
+     * <li><code>Combo</code></li>
+     * </ul></p>
+     */
+    public static const int DROP_DOWN = 1 << 2;
+
+    /**
+     * Style constant for pop up menu behavior (value is 1&lt;&lt;3).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Menu</code></li>
+     * </ul></p>
+     */
+    public static const int POP_UP = 1 << 3;
+
+    /**
+     * Style constant for line separator behavior (value is 1&lt;&lt;1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Label</code></li>
+     * <li><code>MenuItem</code></li>
+     * <li><code>ToolItem</code></li>
+     * </ul></p>
+     */
+    public static const int SEPARATOR = 1 << 1;
+
+    /**
+     * Style constant for toggle button behavior (value is 1&lt;&lt;1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * </ul></p>
+     */
+    public static const int TOGGLE = 1 << 1;
+
+    /**
+     * Style constant for arrow button behavior (value is 1&lt;&lt;2).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * </ul></p>
+     */
+    public static const int ARROW = 1 << 2;
+
+    /**
+     * Style constant for push button behavior (value is 1&lt;&lt;3).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * <li><code>MenuItem</code></li>
+     * <li><code>ToolItem</code></li>
+     * </ul></p>
+     */
+    public static const int PUSH = 1 << 3;
+
+    /**
+     * Style constant for radio button behavior (value is 1&lt;&lt;4).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * <li><code>MenuItem</code></li>
+     * <li><code>ToolItem</code></li>
+     * </ul></p>
+     */
+    public static const int RADIO = 1 << 4;
+
+    /**
+     * Style constant for check box behavior (value is 1&lt;&lt;5).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * <li><code>MenuItem</code></li>
+     * <li><code>ToolItem</code></li>
+     * <li><code>Table</code></li>
+     * <li><code>Tree</code></li>
+     * </ul></p>
+     */
+    public static const int CHECK = 1 << 5;
+
+    /**
+     * Style constant for cascade behavior (value is 1&lt;&lt;6).
+     * <p><b>Used By:</b><ul>
+     * <li><code>MenuItem</code></li>
+     * </ul></p>
+     */
+    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&lt;&lt;1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Text</code></li>
+     * <li><code>List</code></li>
+     * <li><code>FileDialog</code></li>
+     * </ul></p>
+     */
+    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&lt;&lt;2).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Text</code></li>
+     * <li><code>List</code></li>
+     * <li><code>Table</code></li>
+     * <li><code>Tree</code></li>
+     * </ul></p>
+     */
+    public static const int SINGLE = 1 << 2;
+
+    /**
+     * Style constant for read-only behavior (value is 1&lt;&lt;3).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Combo</code></li>
+     * <li><code>Text</code></li>
+     * </ul></p>
+     */
+    public static const int READ_ONLY = 1 << 3;
+
+    /**
+     * Style constant for automatic line wrap behavior (value is 1&lt;&lt;6).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Label</code></li>
+     * <li><code>Text</code></li>
+     * <li><code>ToolBar</code></li>
+     * <li><code>Spinner</code></li>
+     * </ul></p>
+     */
+    public static const int WRAP = 1 << 6;
+
+    /**
+     * Style constant for search behavior (value is 1&lt;&lt;7).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Text</code></li>
+     * </ul></p>
+     * 
+     * @since 3.3
+     */
+    public static const int SEARCH = 1 << 7;
+
+    /**
+     * Style constant for simple (not drop down) behavior (value is 1&lt;&lt;6).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Combo</code></li>
+     * </ul></p>
+     */
+    public static const int SIMPLE = 1 << 6;
+
+    /**
+     * Style constant for password behavior (value is 1&lt;&lt;22).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Text</code></li>
+     * </ul></p>
+     * 
+     * @since 3.0
+     */
+    public static const int PASSWORD = 1 << 22;
+
+    /**
+     * Style constant for shadow in behavior (value is 1&lt;&lt;2).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Label</code></li>
+     * <li><code>Group</code></li>
+     * </ul></p>
+     */
+    public static const int SHADOW_IN = 1 << 2;
+
+    /**
+     * Style constant for shadow out behavior (value is 1&lt;&lt;3).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Label</code></li>
+     * <li><code>Group</code></li>
+     * <li><code>ToolBar</code></li>
+     * </ul></p>
+     */
+    public static const int SHADOW_OUT = 1 << 3;
+
+    /**
+     * Style constant for shadow etched in behavior (value is 1&lt;&lt;4).
+     * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Group</code></li>
+     * </ul></p>
+     */
+    public static const int SHADOW_ETCHED_IN = 1 << 4;
+
+    /**
+     * Style constant for shadow etched out behavior (value is 1&lt;&lt;6).
+     * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Group</code></li>
+     * </ul></p>
+     */
+    public static const int SHADOW_ETCHED_OUT = 1 << 6;
+
+    /**
+     * Style constant for no shadow behavior (value is 1&lt;&lt;5).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Label</code></li>
+     * <li><code>Group</code></li>
+     * </ul></p>
+     */
+    public static const int SHADOW_NONE = 1 << 5;
+
+    /**
+     * Style constant for progress bar behavior (value is 1&lt;&lt;1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>ProgressBar</code></li>
+     * </ul></p>
+     */
+    public static const int INDETERMINATE = 1 << 1;
+
+    /**
+     * Style constant for tool window behavior (value is 1&lt;&lt;2).
+     * <p>
+     * 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.
+     * <br>Note that this is a <em>HINT</em>.
+     * </p><p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int TOOL = 1 << 2;
+
+    /**
+     * Style constant to ensure no trimmings are used (value is 1&lt;&lt;3).
+     * <br>Note that this overrides all other trim styles.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int NO_TRIM = 1 << 3;
+
+    /**
+     * Style constant for resize box trim (value is 1&lt;&lt;4).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * <li><code>Tracker</code></li>
+     * </ul></p>
+     */
+    public static const int RESIZE = 1 << 4;
+
+    /**
+     * Style constant for title area trim (value is 1&lt;&lt;5).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int TITLE = 1 << 5;
+
+    /**
+     * Style constant for close box trim (value is 1&lt;&lt;6,
+     * since we do not distinguish between CLOSE style and MENU style).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int CLOSE = 1 << 6;
+
+    /**
+     * Style constant for shell menu trim (value is 1&lt;&lt;6,
+     * since we do not distinguish between CLOSE style and MENU style).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int MENU = CLOSE;
+
+    /**
+     * Style constant for minimize box trim (value is 1&lt;&lt;7).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int MIN = 1 << 7;
+
+    /**
+     * Style constant for maximize box trim (value is 1&lt;&lt;10).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Decorations</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int MAX = 1 << 10;
+
+    /**
+     * Style constant for horizontal scrollbar behavior (value is 1&lt;&lt;8).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Scrollable</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int H_SCROLL = 1 << 8;
+
+    /**
+     * Style constant for vertical scrollbar behavior (value is 1&lt;&lt;9).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Scrollable</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int V_SCROLL = 1 << 9;
+
+    /**
+     * Style constant for no scrollbar behavior (value is 1&lt;&lt;4).
+     * <p>
+     * When neither H_SCROLL or V_SCROLL are specified, controls
+     * are free to create the default scroll bars for the control.
+     * Using NO_SCROLL overrides the default and forces the control
+     * to have no scroll bars.
+     * 
+     * <b>Used By:</b><ul>
+     * <li><code>Tree</code></li>
+     * <li><code>Table</code></li>
+     * </ul></p>
+     *
+     * @since 3.4
+     */
+    public static const int NO_SCROLL = 1 << 4;
+
+    /**
+     * Style constant for bordered behavior (value is 1&lt;&lt;11).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code> and subclasses</li>
+     * </ul></p>
+     */
+    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&lt;&lt;12).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code> and subclasses</li>
+     * </ul></p>
+     */
+    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&lt;&lt;13).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code> and subclasses</li>
+     * </ul></p>
+     */
+    public static const int CLIP_SIBLINGS = 1 << 13;
+
+    /**
+     * Style constant for always on top behavior (value is 1&lt;&lt;14).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Shell</code> and subclasses</li>
+     * </ul></p>
+     */
+    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).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Shell</code></li>
+     * </ul></p>
+     */
+    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).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Shell</code></li>
+     * </ul></p>
+     */
+    public static const int DIALOG_TRIM = TITLE | CLOSE | BORDER;
+
+    /**
+     * Style constant for modeless behavior (value is 0).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Dialog</code></li>
+     * <li><code>Shell</code></li>
+     * </ul></p>
+     */
+    public static const int MODELESS = 0;
+
+    /**
+     * Style constant for primary modal behavior (value is 1&lt;&lt;15).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Dialog</code></li>
+     * <li><code>Shell</code></li>
+     * </ul></p>
+     */
+    public static const int PRIMARY_MODAL = 1 << 15;
+
+    /**
+     * Style constant for application modal behavior (value is 1&lt;&lt;16).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Dialog</code></li>
+     * <li><code>Shell</code></li>
+     * </ul></p>
+     */
+    public static const int APPLICATION_MODAL = 1 << 16;
+
+    /**
+     * Style constant for system modal behavior (value is 1&lt;&lt;17).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Dialog</code></li>
+     * <li><code>Shell</code></li>
+     * </ul></p>
+     */
+    public static const int SYSTEM_MODAL = 1 << 17;
+
+    /**
+     * Style constant for selection hiding behavior when the widget loses focus (value is 1&lt;&lt;15).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Table</code></li>
+     * </ul></p>
+     */
+    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&lt;&lt;16).
+     * <br>Note that for some widgets this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Table</code></li>
+     * <li><code>Tree</code></li>
+     * <li><code>StyledText</code></li>
+     * <li><code>TextLayout</code></li> 
+     * </ul></p>
+     */
+    public static const int FULL_SELECTION = 1 << 16;
+
+    /**
+     * Style constant for flat appearance. (value is 1&lt;&lt;23).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * <li><code>ToolBar</code></li>
+     * </ul></p>
+     */
+    public static const int FLAT = 1 << 23;
+
+    /**
+     * Style constant for smooth appearance. (value is 1&lt;&lt;16).
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>ProgressBar</code></li>
+     * <li><code>Sash</code></li>
+     * </ul></p>
+     */
+    public static const int SMOOTH = 1 << 16;
+
+    /**
+     * Style constant for no background behavior (value is 1&lt;&lt;18).
+     * <p>
+     * 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.
+     * </p><p><b>Used By:</b><ul>
+     * <li><code>Composite</code></li>
+     * </ul></p>
+     */
+    public static const int NO_BACKGROUND = 1 << 18;
+
+    /**
+     * Style constant for no focus from the mouse behavior (value is 1&lt;&lt;19).
+     * <p>
+     * Normally, when the user clicks on a control, focus is assigned to that
+     * control, providing the control has no children.  Some controls, such as
+     * tool bars and sashes, don't normally take focus when the mouse is clicked
+     * or accept focus when assigned from within the program.  This style allows
+     * Composites to implement "no focus" mouse behavior.
+     * 
+     * <br>Note that this is a <em>HINT</em>.
+     * </p>
+     * <p><b>Used By:</b><ul>
+     * <li><code>Composite</code></li>
+     * </ul></p>
+     */
+    public static const int NO_FOCUS = 1 << 19;
+
+    /**
+     * Style constant for no redraw on resize behavior (value is 1&lt;&lt;20).
+     * <p>
+     * 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.
+     * 
+     * <br>Note that this is a <em>HINT</em>.
+     * </p><p><b>Used By:</b><ul>
+     * <li><code>Composite</code></li>
+     * </ul></p>
+     */
+    public static const int NO_REDRAW_RESIZE = 1 << 20;
+
+    /**
+     * Style constant for no paint event merging behavior (value is 1&lt;&lt;21).
+     * 
+     * <br>Note that this is a <em>HINT</em>.
+     * <p><b>Used By:</b><ul>
+     * <li><code>Composite</code></li>
+     * </ul></p>
+     */
+    public static const int NO_MERGE_PAINTS = 1 << 21;
+
+    /**
+     * Style constant for preventing child radio group behavior (value is 1&lt;&lt;22).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Composite</code></li>
+     * </ul></p>
+     */
+    public static const int NO_RADIO_GROUP = 1 << 22;
+
+    /**
+     * Style constant for left to right orientation (value is 1&lt;&lt;25).
+     * <p>
+     * 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.
+     * <br>Note that this is a <em>HINT</em>.
+     * </p>
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code></li>
+     * <li><code>Menu</code></li>
+     * <li><code>GC</code></li> 
+     * </ul></p>
+     * 
+     * @since 2.1.2
+     */
+    public static const int LEFT_TO_RIGHT = 1 << 25;
+
+    /**
+     * Style constant for right to left orientation (value is 1&lt;&lt;26).
+     * <p>
+     * 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.
+     * <br>Note that this is a <em>HINT</em>.
+     * </p>
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code></li>
+     * <li><code>Menu</code></li>
+     * <li><code>GC</code></li> 
+     * </ul></p>
+     * 
+     * @since 2.1.2
+     */
+    public static const int RIGHT_TO_LEFT = 1 << 26;
+
+    /**
+     * Style constant to indicate coordinate mirroring (value is 1&lt;&lt;27).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code></li>
+     * <li><code>Menu</code></li>
+     * </ul></p>
+     * 
+     * @since 2.1.2
+     */
+    public static const int MIRRORED = 1 << 27;
+
+    /**
+     * Style constant to allow embedding (value is 1&lt;&lt;24).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Composite</code></li>
+     * </ul></p>
+     * 
+     * @since 3.0
+     */
+    public static const int EMBEDDED = 1 << 24;
+
+    /**
+     * Style constant to allow virtual data (value is 1&lt;&lt;28).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Table</code></li>
+     * <li><code>Tree</code></li>
+     * </ul></p>
+     * 
+     * @since 3.0
+     */
+    public static const int VIRTUAL = 1 << 28;
+
+    /**
+     * Style constant to indicate double buffering (value is 1&lt;&lt;29).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code></li>
+     * </ul></p>
+     * 
+     * @since 3.1
+     */
+    public static const int DOUBLE_BUFFERED = 1 << 29;
+
+    /**
+     * Style constant for transparent behavior (value is 1&lt;&lt;30).
+     * <p>
+     * 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 widgets that are obscured
+     * will draw through.
+     * </p><p><b>Used By:</b><ul>
+     * <li><code>Composite</code></li>
+     * </ul></p>
+     *
+     * @since 3.4
+     * 
+     * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED
+     */
+    public static const int TRANSPARENT = 1 << 30;
+
+    /**
+     * Style constant for align up behavior (value is 1&lt;&lt;7,
+     * since align UP and align TOP are considered the same).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code> with <code>ARROW</code> style</li>
+     * <li><code>Tracker</code></li>
+     * <li><code>Table</code></li>
+     * <li><code>Tree</code></li>
+     * </ul></p>
+     */
+    public static const int UP = 1 << 7;
+
+    /**
+     * Style constant to indicate single underline (value is 0).
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextStyle</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int UNDERLINE_SINGLE = 0;
+
+    /**
+     * Style constant to indicate double underline (value is 1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextStyle</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int UNDERLINE_DOUBLE = 1;
+
+    /**
+     * Style constant to indicate error underline (value is 2).
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextStyle</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int UNDERLINE_ERROR = 2;
+
+    /**
+     * Style constant to indicate squiggle underline (value is 3).
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextStyle</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int UNDERLINE_SQUIGGLE = 3;
+
+    /**
+     * Style constant to indicate solid border (value is 1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextStyle</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int BORDER_SOLID = 1;
+
+    /**
+     * Style constant to indicate dashed border (value is 2).
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextStyle</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int BORDER_DASH = 2;
+
+    /**
+     * Style constant to indicate dotted border (value is 4).
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextStyle</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int BORDER_DOT = 4;
+
+    /**
+     * Style constant for align top behavior (value is 1&lt;&lt;7,
+     * since align UP and align TOP are considered the same).
+     * <p><b>Used By:</b><ul>
+     * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+     * </ul></p>
+     */
+    public static const int TOP = UP;
+
+    /**
+     * Style constant for align down behavior (value is 1&lt;&lt;10,
+     * since align DOWN and align BOTTOM are considered the same).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code> with <code>ARROW</code> style</li>
+     * <li><code>Tracker</code></li>
+     * <li><code>Table</code></li>
+     * <li><code>Tree</code></li>
+     * </ul></p>
+     */
+    public static const int DOWN = 1 << 10;
+
+    /**
+     * Style constant for align bottom behavior (value is 1&lt;&lt;10,
+     * since align DOWN and align BOTTOM are considered the same).
+     * <p><b>Used By:</b><ul>
+     * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+     * </ul></p>
+     */
+    public static const int BOTTOM = DOWN;
+
+    /**
+     * Style constant for leading alignment (value is 1&lt;&lt;14).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * <li><code>Label</code></li>
+     * <li><code>TableColumn</code></li>
+     * <li><code>Tracker</code></li>
+     * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+     * </ul></p>
+     * 
+     * @since 2.1.2
+     */
+    public static const int LEAD = 1 << 14;
+
+    /**
+     * Style constant for align left behavior (value is 1&lt;&lt;14).
+     * This is a synonym for LEAD (value is 1&lt;&lt;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&lt;&lt;17).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * <li><code>Label</code></li>
+     * <li><code>TableColumn</code></li>
+     * <li><code>Tracker</code></li>
+     * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+     * </ul></p>
+     * 
+     * @since 2.1.2
+     */
+    public static const int TRAIL = 1 << 17;
+
+    /**
+     * Style constant for align right behavior (value is 1&lt;&lt;17).
+     * This is a synonym for TRAIL (value is 1&lt;&lt;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&lt;&lt;24).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Button</code></li>
+     * <li><code>Label</code></li>
+     * <li><code>TableColumn</code></li>
+     * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+     * </ul></p>
+     */
+    public static const int CENTER = 1 << 24;
+
+    /**
+     * Style constant for horizontal alignment or orientation behavior (value is 1&lt;&lt;8).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Label</code></li>
+     * <li><code>ProgressBar</code></li>
+     * <li><code>Sash</code></li>
+     * <li><code>Scale</code></li>
+     * <li><code>ScrollBar</code></li>
+     * <li><code>Slider</code></li>
+     * <li><code>ToolBar</code></li>
+     * <li><code>FillLayout</code> type</li>
+     * <li><code>RowLayout</code> type</li>
+     * </ul></p>
+     */
+    public static const int HORIZONTAL = 1 << 8;
+
+    /**
+     * Style constant for vertical alignment or orientation behavior (value is 1&lt;&lt;9).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Label</code></li>
+     * <li><code>ProgressBar</code></li>
+     * <li><code>Sash</code></li>
+     * <li><code>Scale</code></li>
+     * <li><code>ScrollBar</code></li>
+     * <li><code>Slider</code></li>
+     * <li><code>ToolBar</code></li>
+     * <li><code>CoolBar</code></li>
+     * <li><code>FillLayout</code> type</li>
+     * <li><code>RowLayout</code> type</li>
+     * </ul></p>
+     */
+    public static const int VERTICAL = 1 << 9;
+
+    /**
+     * Style constant for date display (value is 1&lt;&lt;5).
+     * <p><b>Used By:</b><ul>
+     * <li><code>DateTime</code></li>
+     * </ul></p>
+     * 
+     * @since 3.3
+     */
+    public static const int DATE = 1 << 5;
+
+    /**
+     * Style constant for time display (value is 1&lt;&lt;7).
+     * <p><b>Used By:</b><ul>
+     * <li><code>DateTime</code></li>
+     * </ul></p>
+     * 
+     * @since 3.3
+     */
+    public static const int TIME = 1 << 7;
+
+    /**
+     * Style constant for calendar display (value is 1&lt;&lt;10).
+     * <p><b>Used By:</b><ul>
+     * <li><code>DateTime</code></li>
+     * </ul></p>
+     * 
+     * @since 3.3
+     */
+    public static const int CALENDAR = 1 << 10;
+
+    /**
+     * Style constant for short date/time format (value is 1&lt;&lt;15).
+     * <p>
+     * A short date displays the month and year.
+     * A short time displays hours and minutes.
+     * <br>Note that this is a <em>HINT</em>.
+     * </p>
+     * <p><b>Used By:</b><ul>
+     * <li><code>DateTime</code></li>
+     * </ul></p>
+     * 
+     * @since 3.3
+     */
+    public static const int SHORT = 1 << 15;
+
+    /**
+     * Style constant for medium date/time format (value is 1&lt;&lt;16).
+     * <p>
+     * A medium date displays the day, month and year.
+     * A medium time displays hours, minutes, and seconds.
+     * <br>Note that this is a <em>HINT</em>.
+     * </p>
+     * <p><b>Used By:</b><ul>
+     * <li><code>DateTime</code></li>
+     * </ul></p>
+     * 
+     * @since 3.3
+     */
+    public static const int MEDIUM = 1 << 16;
+
+    /**
+     * Style constant for long date/time format (value is 1&lt;&lt;28).
+     * <p>
+     * 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.
+     * <br>Note that this is a <em>HINT</em>.
+     * </p>
+     * <p><b>Used By:</b><ul>
+     * <li><code>DateTime</code></li>
+     * </ul></p>
+     * 
+     * @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&lt;&lt;15).
+     * <p>
+     * <p><b>Used By:</b><ul>
+     * <li><code>Browser</code></li>
+     * </ul></p>
+     * 
+     * @since 3.3
+     */
+    public static const int MOZILLA = 1 << 15;
+
+    /**
+     * Style constant for balloon behavior (value is 1&lt;&lt;12).
+     * <p><b>Used By:</b><ul>
+     * <li><code>ToolTip</code></li>
+     * </ul></p>
+     *
+     * @since 3.2
+     */
+    public static const int BALLOON = 1 << 12;
+
+    /**
+     * Style constant for vertical alignment or orientation behavior (value is 1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>GridLayout</code> type</li>
+     * </ul></p>
+     */
+    public static const int BEGINNING = 1;
+
+    /**
+     * Style constant for vertical alignment or orientation behavior (value is 4).
+     * <p><b>Used By:</b><ul>
+     * <li><code>GridLayout</code> type</li>
+     * </ul></p>
+     */
+    public static const int FILL = 4;
+
+    /**
+     * Input Method Editor style constant for double byte
+     * input behavior (value is 1&lt;&lt;1).
+     */
+    public static const int DBCS = 1 << 1;
+
+    /**
+     * Input Method Editor style constant for alpha
+     * input behavior (value is 1&lt;&lt;2).
+     */
+    public static const int ALPHA = 1 << 2;
+
+    /**
+     * Input Method Editor style constant for native
+     * input behavior (value is 1&lt;&lt;3).
+     */
+    public static const int NATIVE = 1 << 3;
+
+    /**
+     * Input Method Editor style constant for phonetic
+     * input behavior (value is 1&lt;&lt;4).
+     */
+    public static const int PHONETIC = 1 << 4;
+
+    /**
+     * Input Method Editor style constant for romanicized
+     * input behavior (value is 1&lt;&lt;5).
+     */
+    public static const int ROMAN = 1 << 5;
+
+    /**
+     * ASCII character convenience constant for the backspace character
+     * (value is the <code>char</code> '\b').
+     */
+    public static final char BS = '\b';
+
+    /**
+     * ASCII character convenience constant for the carriage return character
+     * (value is the <code>char</code> '\r').
+     */
+    public static final char CR = '\r';
+
+    /**
+     * ASCII character convenience constant for the delete character
+     * (value is the <code>char</code> with value 127).
+     */
+    public static final char DEL = 0x7F;
+
+    /**
+     * ASCII character convenience constant for the escape character
+     * (value is the <code>char</code> with value 27).
+     */
+    public static final char ESC = 0x1B;
+
+    /**
+     * ASCII character convenience constant for the line feed character
+     * (value is the <code>char</code> '\n').
+     */
+    public static final char LF = '\n';
+
+    /**
+     * ASCII character convenience constant for the tab character
+     * (value is the <code>char</code> '\t').
+     * 
+     * @since 2.1
+     */
+    public static final 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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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.
+     * 
+     * <code>(stateMask & DWT.MODIFIER_MASK) !is 0</code>.
+     * 
+     * @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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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.
+     * 
+     * <code>(stateMask & DWT.BUTTON_MASK) !is 0</code>.
+     * 
+     * @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).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code></li>
+     * </ul></p>
+     * 
+     * @since 3.1
+     */
+    public static const int SCROLL_LINE = 1;
+
+    /**
+     * Constants to indicate page scrolling (value is 2).
+     * <p><b>Used By:</b><ul>
+     * <li><code>Control</code></li>
+     * </ul></p>
+     * 
+     * @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:
+     * 
+     * <code>((DWT.MOD1 | DWT.MOD2 | 'T') & DWT.KEYCODE_BIT) !is 0</code>.
+     * 
+     * The following expression is true:
+     * 
+     * <code>((DWT.MOD3 | DWT.F2) & DWT.KEYCODE_BIT) !is 0</code>.
+     * 
+     * (value is (1&lt;&lt;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 <code>KEYCODE_BIT</code>
+     * 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&lt;&lt;24)+1).
+     */
+    public static const int ARROW_UP = KEYCODE_BIT + 1;
+
+    /**
+     * Keyboard event constant representing the DOWN ARROW key
+     * (value is (1&lt;&lt;24)+2).
+     */
+    public static const int ARROW_DOWN = KEYCODE_BIT + 2;
+
+    /**
+     * Keyboard event constant representing the LEFT ARROW key
+     * (value is (1&lt;&lt;24)+3).
+     */
+    public static const int ARROW_LEFT = KEYCODE_BIT + 3;
+
+    /**
+     * Keyboard event constant representing the RIGHT ARROW key
+     * (value is (1&lt;&lt;24)+4).
+     */
+    public static const int ARROW_RIGHT = KEYCODE_BIT + 4;
+
+    /**
+     * Keyboard event constant representing the PAGE UP key
+     * (value is (1&lt;&lt;24)+5).
+     */
+    public static const int PAGE_UP = KEYCODE_BIT + 5;
+
+    /**
+     * Keyboard event constant representing the PAGE DOWN key
+     * (value is (1&lt;&lt;24)+6).
+     */
+    public static const int PAGE_DOWN = KEYCODE_BIT + 6;
+
+    /**
+     * Keyboard event constant representing the HOME key
+     * (value is (1&lt;&lt;24)+7).
+     */
+    public static const int HOME = KEYCODE_BIT + 7;
+
+    /**
+     * Keyboard event constant representing the END key
+     * (value is (1&lt;&lt;24)+8).
+     */
+    public static const int END = KEYCODE_BIT + 8;
+
+    /**
+     * Keyboard event constant representing the INSERT key
+     * (value is (1&lt;&lt;24)+9).
+     */
+    public static const int INSERT = KEYCODE_BIT + 9;
+
+    /**
+     * Keyboard event constant representing the F1 key
+     * (value is (1&lt;&lt;24)+10).
+     */
+    public static const int F1 = KEYCODE_BIT + 10;
+
+    /**
+     * Keyboard event constant representing the F2 key
+     * (value is (1&lt;&lt;24)+11).
+     */
+    public static const int F2 = KEYCODE_BIT + 11;
+
+    /**
+     * Keyboard event constant representing the F3 key
+     * (value is (1&lt;&lt;24)+12).
+     */
+    public static const int F3 = KEYCODE_BIT + 12;
+
+    /**
+     * Keyboard event constant representing the F4 key
+     * (value is (1&lt;&lt;24)+13).
+     */
+    public static const int F4 = KEYCODE_BIT + 13;
+
+    /**
+     * Keyboard event constant representing the F5 key
+     * (value is (1&lt;&lt;24)+14).
+     */
+    public static const int F5 = KEYCODE_BIT + 14;
+
+    /**
+     * Keyboard event constant representing the F6 key
+     * (value is (1&lt;&lt;24)+15).
+     */
+    public static const int F6 = KEYCODE_BIT + 15;
+
+    /**
+     * Keyboard event constant representing the F7 key
+     * (value is (1&lt;&lt;24)+16).
+     */
+    public static const int F7 = KEYCODE_BIT + 16;
+
+    /**
+     * Keyboard event constant representing the F8 key
+     * (value is (1&lt;&lt;24)+17).
+     */
+    public static const int F8 = KEYCODE_BIT + 17;
+
+    /**
+     * Keyboard event constant representing the F9 key
+     * (value is (1&lt;&lt;24)+18).
+     */
+    public static const int F9 = KEYCODE_BIT + 18;
+
+    /**
+     * Keyboard event constant representing the F10 key
+     * (value is (1&lt;&lt;24)+19).
+     */
+    public static const int F10 = KEYCODE_BIT + 19;
+
+    /**
+     * Keyboard event constant representing the F11 key
+     * (value is (1&lt;&lt;24)+20).
+     */
+    public static const int F11 = KEYCODE_BIT + 20;
+
+    /**
+     * Keyboard event constant representing the F12 key
+     * (value is (1&lt;&lt;24)+21).
+     */
+    public static const int F12 = KEYCODE_BIT + 21;
+
+    /**
+     * Keyboard event constant representing the F13 key
+     * (value is (1&lt;&lt;24)+22).
+     * 
+     * @since 3.0
+     */
+    public static const int F13 = KEYCODE_BIT + 22;
+
+    /**
+     * Keyboard event constant representing the F14 key
+     * (value is (1&lt;&lt;24)+23).
+     * 
+     * @since 3.0
+     */
+    public static const int F14 = KEYCODE_BIT + 23;
+
+    /**
+     * Keyboard event constant representing the F15 key
+     * (value is (1&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;24)+80).
+     * 
+     * @since 3.0
+     */
+    public static const int KEYPAD_CR = KEYCODE_BIT + 80;
+
+    /**
+     * Keyboard event constant representing the help
+     * key (value is (1&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;24)+84).
+     * 
+     * @since 3.0
+     */
+    public static const int SCROLL_LOCK = KEYCODE_BIT + 84;
+
+    /**
+     * Keyboard event constant representing the pause
+     * key (value is (1&lt;&lt;24)+85).
+     * 
+     * @since 3.0
+     */
+    public static const int PAUSE = KEYCODE_BIT + 85;
+
+    /**
+     * Keyboard event constant representing the break
+     * key (value is (1&lt;&lt;24)+86).
+     * 
+     * @since 3.0
+     */
+    public static const int BREAK = KEYCODE_BIT + 86;
+
+    /**
+     * Keyboard event constant representing the print screen
+     * key (value is (1&lt;&lt;24)+87).
+     * 
+     * @since 3.0
+     */
+    public static const int PRINT_SCREEN = KEYCODE_BIT + 87;
+
+    /**
+     * The <code>MessageBox</code> style constant for error icon
+     * behavior (value is 1).
+     */
+    public static const int ICON_ERROR = 1;
+
+    /**
+     * The <code>MessageBox</code> style constant for information icon
+     * behavior (value is 1&lt;&lt;1).
+     */
+    public static const int ICON_INFORMATION = 1 << 1;
+
+    /**
+     * The <code>MessageBox</code> style constant for question icon
+     * behavior (value is 1&lt;&lt;2).
+     */
+    public static const int ICON_QUESTION = 1 << 2;
+
+    /**
+     * The <code>MessageBox</code> style constant for warning icon
+     * behavior (value is 1&lt;&lt;3).
+     */
+    public static const int ICON_WARNING = 1 << 3;
+
+    /**
+     * The <code>MessageBox</code> style constant for "working" icon
+     * behavior (value is 1&lt;&lt;4).
+     */
+    public static const int ICON_WORKING = 1 << 4;
+
+    /**
+     * The <code>MessageBox</code> style constant for an OK button;
+     * valid combinations are OK, OK|CANCEL
+     * (value is 1&lt;&lt;5).
+     */
+    public static const int OK = 1 << 5;
+
+    /**
+     * The <code>MessageBox</code> style constant for YES button;
+     * valid combinations are YES|NO, YES|NO|CANCEL
+     * (value is 1&lt;&lt;6).
+     */
+    public static const int YES = 1 << 6;
+
+    /**
+     * The <code>MessageBox</code> style constant for NO button;
+     * valid combinations are YES|NO, YES|NO|CANCEL
+     * (value is 1&lt;&lt;7).
+     */
+    public static const int NO = 1 << 7;
+
+    /**
+     * The <code>MessageBox</code> style constant for a CANCEL button;
+     * valid combinations are OK|CANCEL, YES|NO|CANCEL, RETRY|CANCEL
+     * (value is 1&lt;&lt;8).  This style constant is also used with 
+     * <code>Text</code> in combination with SEARCH.
+     * 
+     * <p><b>Used By:</b><ul>
+     * <li><code>MessageBox</code></li>
+     * <li><code>Text</code></li>
+     * </ul></p>
+     */
+    public static const int CANCEL = 1 << 8;
+
+    /**
+     * The <code>MessageBox</code> style constant for an ABORT button;
+     * the only valid combination is ABORT|RETRY|IGNORE
+     * (value is 1&lt;&lt;9).
+     */
+    public static const int ABORT = 1 << 9;
+
+    /**
+     * The <code>MessageBox</code> style constant for a RETRY button;
+     *  valid combinations are ABORT|RETRY|IGNORE, RETRY|CANCEL
+     * (value is 1&lt;&lt;10).
+     */
+    public static const int RETRY = 1 << 10;
+
+    /**
+     * The <code>MessageBox</code> style constant for an IGNORE button;
+     * the only valid combination is ABORT|RETRY|IGNORE
+     * (value is 1&lt;&lt;11).
+     */
+    public static const int IGNORE = 1 << 11;
+
+    /**
+     * The <code>FileDialog</code> style constant for open file dialog behavior
+     * (value is 1&lt;&lt;12).
+     */
+    public static const int OPEN = 1 << 12;
+
+    /**
+     * The <code>FileDialog</code> style constant for save file dialog behavior
+     * (value is 1&lt;&lt;13).
+     */
+    public static const int SAVE = 1 << 13;
+
+    /**
+     * The <code>Composite</code> 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 <code>Composite</code> 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 <code>Composite</code> 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&lt;&lt;0).
+     */
+    public static const int DRAW_TRANSPARENT = 1 << 0;
+
+    /**
+     * Draw constant indicating whether the String drawing operation
+     * should handle line-delimiters (value is 1&lt;&lt;1).
+     */
+    public static const int DRAW_DELIMITER = 1 << 1;
+
+    /**
+     * Draw constant indicating whether the String drawing operation
+     * should expand TAB characters (value is 1&lt;&lt;2).
+     */
+    public static const int DRAW_TAB = 1 << 2;
+
+    /**
+     * Draw constant indicating whether the String drawing operation
+     * should handle mnemonics (value is 1&lt;&lt;3).
+     */
+    public static const int DRAW_MNEMONIC = 1 << 3;
+
+    /**
+     * Selection constant indicating that a line delimiter should be 
+     * drawn (value is 1&lt;&lt;17).
+     * 
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextLayout</code></li>
+     * </ul></p>
+     *
+     * @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&lt;&lt;20).
+     * 
+     * <p><b>Used By:</b><ul>
+     * <li><code>TextLayout</code></li>
+     * </ul></p>
+     * 
+     * @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
+     * <code>checkSubclass()</code> method
+     * (value is 43).
+     * 
+     * For additional information see the comment in 
+     * <code>Widget.checkSubclass()</code>.
+     *
+     * @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 <code>Image</code> 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 <code>Image</code> 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 <code>Image</code> 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;
+
+    /**
+     * Constant to indicate an error state (value is 1).
+     * <p><b>Used By:</b><ul>
+     * <li><code>ProgressBar</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int ERROR = 1;
+
+    /**
+     * Constant to a indicate a paused state (value is 4).
+     * <p><b>Used By:</b><ul>
+     * <li><code>ProgressBar</code></li>
+     * </ul></p>
+     * 
+     * @since 3.4
+     */
+    public static const int PAUSED = 1 << 2;
+
+    /**
+     * The font style constant indicating a normal weight, non-italic font
+     * (value is 0). This constant is also used with <code>ProgressBar</code>
+     * to indicate a normal state.
+     * <p><b>Used By:</b><ul>
+     * <li><code>ProgressBar</code></li>
+     * </ul></p>
+     */
+    public static const int NORMAL = 0;
+
+    /**
+     * The font style constant indicating a bold weight font
+     * (value is 1&lt;&lt;0).
+     */
+    public static const int BOLD = 1 << 0;
+
+    /**
+     * The font style constant indicating an italic font
+     * (value is 1&lt;&lt;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&lt;&lt;0).
+     */
+    public static const int TRANSPARENCY_ALPHA = 1 << 0;
+
+    /**
+     * Image transparency constant indicating that the image
+     * contains a transparency mask (value is 1&lt;&lt;1).
+     */
+    public static const int TRANSPARENCY_MASK = 1 << 1;
+
+    /**
+     * Image transparency constant indicating that the image
+     * contains a transparent pixel (value is 1&lt;&lt;2).
+     */
+    public static const int TRANSPARENCY_PIXEL = 1 << 2;
+
+    /**
+     * The character movement type (value is 1&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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&lt;&lt;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 String 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:
+            break;
+        }
+        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 <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+     * </ul>
+     */
+    public static String getMessage (String key) {
+        return Compatibility.getMessage(key);
+    }
+
+    /**
+     * Returns the DWT platform name.
+     * Examples: "win32", "motif", "gtk", "photon", "carbon"
+     *
+     * @return the DWT platform name
+     */
+    public static String getPlatform () {
+        return Platform.PLATFORM;
+    }
+
+    /**
+     * Returns the DWT version number as an integer.
+     * Example: "DWT051" is 51
+     *
+     * @return the DWT version number
+     */
+    public static int getVersion () {
+        return Library.DWT_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 <code>throwable</code> argument should be either null, or the
+     * throwable which caused DWT to throw an exception.
+     * <p>
+     * In DWT, errors are reported by throwing one of three exceptions:
+     * <dl>
+     * <dd>java.lang.IllegalArgumentException</dd>
+     * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+     * <dd>dwt.DWTException (: java.lang.RuntimeException)</dd>
+     * <dt>thrown whenever a recoverable error happens internally in DWT</dt>
+     * <dd>dwt.DWTError (: java.lang.Error)</dd>
+     * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in DWT</dt>
+     * </dl>
+     * This method provides the logic which maps between error codes
+     * and one of the above exceptions.
+     * </p>
+     *
+     * @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, Exception throwable) {
+        error(code, throwable, null);
+    }
+
+    /**
+     * Throws an appropriate exception based on the passed in error code.
+     * The <code>throwable</code> argument should be either null, or the
+     * throwable which caused DWT to throw an exception.
+     * <p>
+     * In DWT, errors are reported by throwing one of three exceptions:
+     * <dl>
+     * <dd>java.lang.IllegalArgumentException</dd>
+     * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+     * <dd>dwt.DWTException (: java.lang.RuntimeException)</dd>
+     * <dt>thrown whenever a recoverable error happens internally in DWT</dt>
+     * <dd>dwt.DWTError (: java.lang.Error)</dd>
+     * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in DWT</dt>
+     * </dl>
+     * This method provides the logic which maps between error codes
+     * and one of the above exceptions.
+     * </p>
+     *
+     * @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, Exception throwable, String detail) {
+
+        /*
+         * This code prevents the creation of "chains" of DWTErrors and
+         * DWTExceptions which in turn contain other DWTErrors and 
+         * DWTExceptions 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 (cast(DWTError) throwable)
+                throw cast(DWTError) throwable;
+
+            if (cast(DWTException) throwable)
+                throw cast(DWTException) throwable;
+        }
+
+        String message = findErrorText(code);
+        if (detail !is 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: {
+                DWTException 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: {
+                DWTError error = new DWTError(code, message);
+                error.throwable = throwable;
+                throw error;
+            }
+
+            default:
+            break;
+        }
+
+        /* Unknown/Undefined Error */
+        DWTError error = new DWTError(code, message);
+        error.throwable = throwable;
+        throw error;
+    }
+
+    static this () {
+        /*
+         * 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.
+         */
+        String platform = getPlatform();
+        if ("carbon".opEquals(platform)) { //$NON-NLS-1$
+            MOD1 = COMMAND;
+            MOD2 = SHIFT;
+            MOD3 = ALT;
+            MOD4 = CONTROL;
+        }
+        else {
+            MOD1 = CONTROL;
+            MOD2 = SHIFT;
+            MOD3 = ALT;
+            MOD4 = 0;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/DWTError.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.DWTError;
+
+import tango.core.Exception;
+
+import dwt.internal.Library;
+import dwt.DWT;
+
+import dwt.dwthelper.utils;
+
+/**
+ * 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 <code>throwable</code> field which holds the underlying
+ * throwable that caused the problem (if this information is
+ * available (i.e. it may be null)).
+ * <p>
+ * DWTErrors 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). DWTErrors should not occur in typical
+ * programs, although "high reliability" applications should
+ * still catch them.
+ * </p><p>
+ * 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.
+ * </p>
+ *
+ * @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 Exception throwable (Exception e) {
+        this.next = e;
+        return this.next;
+    }
+
+    public Exception throwable () {
+        return this.next;
+    }
+
+    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 <code>null</code>
+     * 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 <code>null</code> 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, String message) {
+        super(message);
+        this.code = code;
+    }
+
+    /**
+     * Returns the underlying throwable that caused the problem,
+     * or null if this information is not available.
+     * <p>
+     * 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.
+     * </p>
+     * @return the underlying throwable
+     * 
+     * @since 3.1
+     */
+    public Exception getCause () {
+        return throwable;
+    }
+
+    /**
+     *  Returns the String describing this DWTError object.
+     *  <p>
+     *  It is combined with the message String of the Throwable
+     *  which caused this DWTError (if this information is available).
+     *  </p>
+     *  @return the error message String of this DWTError object
+     */
+    public String getMessage () {
+        if (throwable is null)
+            return super.getMessage();
+        return super.getMessage() + " (" + throwable.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * Outputs a printable representation of this error's
+     * stack trace on the standard error stream.
+     * <p>
+     * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
+     * are not provided in order to maintain compatibility with CLDC.
+     * </p>
+     */
+    public void printStackTrace () {
+        super.printStackTrace();
+        if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0) && throwable !is null) {
+            System.err.println("*** Stack trace of contained error ***"); //$NON-NLS-1$
+            throwable.printStackTrace();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/DWTException.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.DWTError;
+
+import dwt.DWTError;
+import dwt.DWT;
+
+import dwt.internal.Library;
+
+import dwt.dwthelper.utils;
+
+/**
+ * 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 <code>throwable</code> field which holds the underlying
+ * exception that caused the problem (if this information is
+ * available (i.e. it may be null)).
+ * <p>
+ * DWTExceptions 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).
+ * </p>
+ *
+ * @see DWTError
+ */
+
+public class DWTException : Exception {
+    /**
+     * 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 Exception throwable (Exception e) {
+        this.next = e;
+        return this.next;
+    }
+
+    public Exception throwable () {
+        return this.next;
+    }
+
+    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 <code>null</code>
+     * 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 <code>null</code> 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, String message) {
+        super(message);
+        this.code = code;
+    }
+
+    /**
+     * Returns the underlying throwable that caused the problem,
+     * or null if this information is not available.
+     * <p>
+     * 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.
+     * </p>
+     * @return the underlying throwable
+     * 
+     * @since 3.1
+     */
+    public Exception getCause () {
+        return throwable;
+    }
+
+    /**
+     *  Returns the String describing this DWTException object.
+     *  <p>
+     *  It is combined with the message String of the Throwable
+     *  which caused this DWTException (if this information is available).
+     *  </p>
+     *  @return the error message String of this DWTException object
+     */
+    public String getMessage () {
+        if (throwable is null)
+            return super.getMessage();
+        return super.getMessage() + " (" + throwable.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+    }
+
+    /**
+     * Outputs a printable representation of this exception's
+     * stack trace on the standard error stream.
+     * <p>
+     * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
+     * are not provided in order to maintain compatibility with CLDC.
+     * </p>
+     */
+    public void printStackTrace () {
+        super.printStackTrace();
+        if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0) && throwable !is null) {
+            System.err.println("*** Stack trace of contained exception ***"); //$NON-NLS-1$
+            throwable.printStackTrace();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/ACC.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.ACC;
+
+/**
+ * Class ACC contains all the constants used in defining an
+ * Accessible object.
+ * 
+ * @since 2.0
+ */
+public class ACC {
+    public static const int STATE_NORMAL = 0x00000000;
+    public static const int STATE_SELECTED = 0x00000002;
+    public static const int STATE_SELECTABLE = 0x00200000;
+    public static const int STATE_MULTISELECTABLE = 0x1000000;
+    public static const int STATE_FOCUSED = 0x00000004;
+    public static const int STATE_FOCUSABLE = 0x00100000;
+    public static const int STATE_PRESSED = 0x8;
+    public static const int STATE_CHECKED = 0x10;
+    public static const int STATE_EXPANDED = 0x200;
+    public static const int STATE_COLLAPSED = 0x400;
+    public static const int STATE_HOTTRACKED = 0x80;
+    public static const int STATE_BUSY = 0x800;
+    public static const int STATE_READONLY = 0x40;
+    public static const int STATE_INVISIBLE = 0x8000;
+    public static const int STATE_OFFSCREEN = 0x10000;
+    public static const int STATE_SIZEABLE = 0x20000;
+    public static const int STATE_LINKED = 0x400000;
+
+    public static const int ROLE_CLIENT_AREA = 0xa;
+    public static const int ROLE_WINDOW = 0x9;
+    public static const int ROLE_MENUBAR = 0x2;
+    public static const int ROLE_MENU = 0xb;
+    public static const int ROLE_MENUITEM = 0xc;
+    public static const int ROLE_SEPARATOR = 0x15;
+    public static const int ROLE_TOOLTIP = 0xd;
+    public static const int ROLE_SCROLLBAR = 0x3;
+    public static const int ROLE_DIALOG = 0x12;
+    public static const int ROLE_LABEL = 0x29;
+    public static const int ROLE_PUSHBUTTON = 0x2b;
+    public static const int ROLE_CHECKBUTTON = 0x2c;
+    public static const int ROLE_RADIOBUTTON = 0x2d;
+    public static const int ROLE_COMBOBOX = 0x2e;
+    public static const int ROLE_TEXT = 0x2a;
+    public static const int ROLE_TOOLBAR = 0x16;
+    public static const int ROLE_LIST = 0x21;
+    public static const int ROLE_LISTITEM = 0x22;
+    public static const int ROLE_TABLE = 0x18;
+    public static const int ROLE_TABLECELL = 0x1d;
+    public static const int ROLE_TABLECOLUMNHEADER = 0x19;
+    /** @deprecated use ROLE_TABLECOLUMNHEADER */
+    public static const int ROLE_TABLECOLUMN = ROLE_TABLECOLUMNHEADER;
+    public static const int ROLE_TABLEROWHEADER = 0x1a;
+    public static const int ROLE_TREE = 0x23;
+    public static const int ROLE_TREEITEM = 0x24;
+    public static const int ROLE_TABFOLDER = 0x3c;
+    public static const int ROLE_TABITEM = 0x25;
+    public static const int ROLE_PROGRESSBAR = 0x30;
+    public static const int ROLE_SLIDER = 0x33;
+    public static const int ROLE_LINK = 0x1e;
+
+    public static const int CHILDID_SELF = -1;
+    public static const int CHILDID_NONE = -2;
+    public static const int CHILDID_MULTIPLE = -3;
+
+    public static const int TEXT_INSERT = 0;
+    public static const int TEXT_DELETE = 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/Accessible.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,310 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.Accessible;
+
+import dwt.dwthelper.utils;
+import dwt.DWTException;
+import dwt.widgets.Control;
+
+import dwt.accessibility.AccessibleListener;
+import dwt.accessibility.AccessibleControlListener;
+import dwt.accessibility.AccessibleTextListener;
+
+/**
+ * Instances of this class provide a bridge between application
+ * code and assistive technology clients. Many platforms provide
+ * default accessible behavior for most widgets, and this class
+ * allows that default behavior to be overridden. Applications
+ * can get the default Accessible object for a control by sending
+ * it <code>getAccessible</code>, and then add an accessible listener
+ * to override simple items like the name and help string, or they
+ * can add an accessible control listener to override complex items.
+ * As a rule of thumb, an application would only want to use the
+ * accessible control listener to implement accessibility for a
+ * custom control.
+ * 
+ * @see Control#getAccessible
+ * @see AccessibleListener
+ * @see AccessibleEvent
+ * @see AccessibleControlListener
+ * @see AccessibleControlEvent
+ * 
+ * @since 2.0
+ */
+public class Accessible {
+    Control control;
+
+    this (Control control) {
+        this.control = control;
+    }
+
+    /**
+     * Adds the listener to the collection of listeners who will
+     * be notified when an accessible client asks for certain strings,
+     * such as name, description, help, or keyboard shortcut. The
+     * listener is notified by sending it one of the messages defined
+     * in the <code>AccessibleListener</code> interface.
+     *
+     * @param listener the listener that should be notified when the receiver
+     * is asked for a name, description, help, or keyboard shortcut string
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @see AccessibleListener
+     * @see #removeAccessibleListener
+     */
+    public void addAccessibleListener (AccessibleListener listener) {
+    }
+
+    /**
+     * Removes the listener from the collection of listeners who will
+     * be notified when an accessible client asks for certain strings,
+     * such as name, description, help, or keyboard shortcut.
+     *
+     * @param listener the listener that should no longer be notified when the receiver
+     * is asked for a name, description, help, or keyboard shortcut string
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @see AccessibleListener
+     * @see #addAccessibleListener
+     */
+    public void removeAccessibleListener (AccessibleListener listener) {
+    }
+
+    /**
+     * Adds the listener to the collection of listeners who will
+     * be notified when an accessible client asks for custom control
+     * specific information. The listener is notified by sending it
+     * one of the messages defined in the <code>AccessibleControlListener</code>
+     * interface.
+     *
+     * @param listener the listener that should be notified when the receiver
+     * is asked for custom control specific information
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @see AccessibleControlListener
+     * @see #removeAccessibleControlListener
+     */
+    public void addAccessibleControlListener (AccessibleControlListener listener) {
+    }
+
+    /**
+     * Removes the listener from the collection of listeners who will
+     * be notified when an accessible client asks for custom control
+     * specific information.
+     *
+     * @param listener the listener that should no longer be notified when the receiver
+     * is asked for custom control specific information
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @see AccessibleControlListener
+     * @see #addAccessibleControlListener
+     */
+    public void removeAccessibleControlListener (AccessibleControlListener listener) {
+    }
+
+    /**
+     * Adds the listener to the collection of listeners who will
+     * be notified when an accessible client asks for custom text control
+     * specific information. The listener is notified by sending it
+     * one of the messages defined in the <code>AccessibleTextListener</code>
+     * interface.
+     *
+     * @param listener the listener that should be notified when the receiver
+     * is asked for custom text control specific information
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @see AccessibleTextListener
+     * @see #removeAccessibleTextListener
+     * 
+     * @since 3.0
+     */
+    public void addAccessibleTextListener (AccessibleTextListener listener) {
+    }
+
+    /**
+     * Removes the listener from the collection of listeners who will
+     * be notified when an accessible client asks for custom text control
+     * specific information.
+     *
+     * @param listener the listener that should no longer be notified when the receiver
+     * is asked for custom text control specific information
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @see AccessibleTextListener
+     * @see #addAccessibleTextListener
+     * 
+     * @since 3.0
+     */
+    public void removeAccessibleTextListener (AccessibleTextListener listener) {
+    }
+
+    /**
+     * Returns the control for this Accessible object. 
+     *
+     * @return the receiver's control
+     * @since 3.0
+     */
+    public Control getControl () {
+        return control;
+    }
+
+    /**
+     * Sends a message to accessible clients that the child selection
+     * within a custom container control has changed.
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void selectionChanged () {
+    }
+
+    /**
+     * Sends a message to accessible clients that the text
+     * caret has moved within a custom control.
+     *
+     * @param index the new caret index within the control
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void textCaretMoved (int index) {
+    }
+
+    /**
+     * Sends a message to accessible clients that the text
+     * within a custom control has changed.
+     *
+     * @param type the type of change, one of <code>ACC.NOTIFY_TEXT_INSERT</code>
+     * or <code>ACC.NOTIFY_TEXT_DELETE</code>
+     * @param startIndex the text index within the control where the insertion or deletion begins
+     * @param length the non-negative length in characters of the insertion or deletion
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     * 
+     * @see ACC#TEXT_INSERT
+     * @see ACC#TEXT_DELETE
+     * 
+     * @since 3.0
+     */
+    public void textChanged (int type, int startIndex, int length) {
+    }
+
+    /**
+     * Sends a message to accessible clients that the text
+     * selection has changed within a custom control.
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void textSelectionChanged () {
+    }
+
+    /**
+     * Sends a message to accessible clients indicating that the focus
+     * has changed within a custom control.
+     *
+     * @param childID an identifier specifying a child of the control
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+     * </ul>
+     */
+    public void setFocus (int childID) {
+    }
+
+    /**
+     * Invokes platform specific functionality to dispose an accessible object.
+     * <p>
+     * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+     * API for <code>Accessible</code>. It is marked public only so that it
+     * can be shared within the packages provided by DWT. It is not
+     * available on all platforms, and should never be called from
+     * application code.
+     * </p>
+     */
+    public void internal_dispose_Accessible () {
+    }
+
+    /**
+     * Invokes platform specific functionality to handle a window message.
+     * <p>
+     * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+     * API for <code>Accessible</code>. It is marked public only so that it
+     * can be shared within the packages provided by DWT. It is not
+     * available on all platforms, and should never be called from
+     * application code.
+     * </p>
+     */
+    public int internal_WM_GETOBJECT (int wParam, int lParam) {
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleAdapter;
+
+import dwt.dwthelper.utils;
+import dwt.accessibility.AccessibleListener;
+import dwt.accessibility.AccessibleEvent;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p>
+ *
+ * @see AccessibleListener
+ * @see AccessibleEvent
+ * 
+ * @since 2.0
+ */
+public abstract class AccessibleAdapter : AccessibleListener {
+
+    /**
+     * Sent when an accessibility client requests the name
+     * of the control, or the name of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the name of the control or specified child in the
+     * <code>result</code> field of the event object. Returning
+     * an empty String tells the client that the control or child
+     * does not have a name, and returning null tells the client
+     * to use the platform name.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested name String, or null</li>
+     * </ul>
+     */
+    public void getName (AccessibleEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the help String
+     * of the control, or the help String of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * The information in this property should be similar to the help
+     * provided by toolTipText. It describes what the control or child
+     * does or how to use it, as opposed to getDescription, which
+     * describes appearance.
+     * </p><p>
+     * Return the help String of the control or specified child in
+     * the <code>result</code> field of the event object. Returning
+     * an empty String tells the client that the control or child
+     * does not have a help String, and returning null tells the
+     * client to use the platform help String.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested help String, or null</li>
+     * </ul>
+     */
+    public void getHelp (AccessibleEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the keyboard shortcut
+     * of the control, or the keyboard shortcut of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * A keyboard shortcut can either be a mnemonic, or an accelerator.
+     * As a general rule, if the control or child can receive keyboard focus,
+     * then you should expose its mnemonic, and if it cannot receive keyboard
+     * focus, then you should expose its accelerator.
+     * </p><p>
+     * Return the keyboard shortcut String of the control or specified child
+     * in the <code>result</code> field of the event object. Returning an
+     * empty String tells the client that the control or child does not
+     * have a keyboard shortcut String, and returning null tells the client
+     * to use the platform keyboard shortcut String.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested keyboard shortcut String (example: "ALT+N"), or null</li>
+     * </ul>
+     */
+    public void getKeyboardShortcut (AccessibleEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests a description
+     * of the control, or a description of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * This is a textual description of the control or child's visual
+     * appearance, which is typically only necessary if it cannot be
+     * determined from other properties such as role.
+     * </p><p>
+     * Return the description of the control or specified child in
+     * the <code>result</code> field of the event object. Returning
+     * an empty String tells the client that the control or child
+     * does not have a description, and returning null tells the
+     * client to use the platform description.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested description String, or null</li>
+     * </ul>
+     */
+    public void getDescription (AccessibleEvent e) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleControlAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,257 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleControlAdapter;
+
+import dwt.dwthelper.utils;
+import dwt.accessibility.AccessibleControlListener;
+import dwt.accessibility.AccessibleControlEvent;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleControlListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleControlEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * When returning a child identifier to a client, you may use CHILDID_NONE
+ * to indicate that no child or control has the required information.
+ * </p><p>
+ * Note: This adapter is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleControlListener
+ * @see AccessibleControlEvent
+ * 
+ * @since 2.0
+ */
+public abstract class AccessibleControlAdapter : AccessibleControlListener {
+
+    /**
+     * Sent when an accessibility client requests the identifier
+     * of the control child at the specified display coordinates.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the identifier of the child at display point (x, y)
+     * in the <code>childID</code> field of the event object.
+     * Return CHILDID_SELF if point (x, y) is in the control itself
+     * and not in any child. Return CHILDID_NONE if point (x, y)
+     * is not contained in either the control or any of its children.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>x, y [IN] - the specified point in display coordinates</li>
+     *    <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
+     *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+     * </ul>
+     */
+    public void getChildAtPoint (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the location
+     * of the control, or the location of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return a rectangle describing the location of the specified
+     * control or child in the <code>x, y, width, and height</code>
+     * fields of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
+     * </ul>
+     */
+    public void getLocation (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the accessible object
+     * for a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return an <code>Accessible</code> for the specified control or
+     * child in the <code>accessible</code> field of the event object.
+     * Return null if the specified child does not have its own
+     * <code>Accessible</code>.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying a child of the control</li>
+     *    <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
+     * </ul>
+     */
+    public void getChild (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the number of
+     * children in the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the number of child items in the <code>detail</code>
+     * field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>detail [OUT] - the number of child items in this control</li>
+     * </ul>
+     */
+    public void getChildCount (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the default action
+     * of the control, or the default action of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * This String is typically a verb describing what the user does to it.
+     * For example, a Push Button's default action is "Press", a Check Button's
+     * is "Check" or "UnCheck", and List items have the default action "Double Click".
+     * </p><p>
+     * Return a String describing the default action of the specified
+     * control or child in the <code>result</code> field of the event object.
+     * Returning null tells the client to use the platform default action String.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested default action String, or null</li>
+     * </ul>
+     */
+    public void getDefaultAction (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the identity of
+     * the child or control that has keyboard focus.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the identifier of the child that has focus in the
+     * <code>childID</code> field of the event object.
+     * Return CHILDID_SELF if the control itself has keyboard focus.
+     * Return CHILDID_NONE if neither the control nor any of its children has focus.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
+     *    <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
+     * </ul>
+     */
+    public void getFocus (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the role
+     * of the control, or the role of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return a role constant (constant defined in ACC beginning with ROLE_)
+     * that describes the role of the specified control or child in the
+     * <code>detail</code> field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>detail [OUT] - a role constant describing the role of the control or child</li>
+     * </ul>
+     */
+    public void getRole (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the identity of
+     * the child or control that is currently selected.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the identifier of the selected child in the
+     * <code>childID</code> field of the event object.
+     * Return CHILDID_SELF if the control itself is selected.
+     * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
+     * Return CHILDID_NONE if neither the control nor any of its children are selected.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
+     *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+     * </ul>
+     */
+    public void getSelection (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the state
+     * of the control, or the state of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return a state mask (mask bit constants defined in ACC beginning with STATE_)
+     * that describes the current state of the specified control or child in the
+     * <code>detail</code> field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>detail [OUT] - a state mask describing the current state of the control or child</li>
+     * </ul>
+     */
+    public void getState (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the value
+     * of the control, or the value of a child of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Many controls do not return a value. Examples of controls
+     * that do are: Combo returns the text String, Text returns
+     * its contents, ProgressBar returns a String representing a
+     * percentage, and Tree items return a String representing
+     * their level in the tree.
+     * </p><p>
+     * Return a String describing the value of the specified control
+     * or child in the <code>result</code> field of the event object.
+     * Returning null tells the client to use the platform value String.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested value String, or null</li>
+     * </ul>
+     */
+    public void getValue (AccessibleControlEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the children of the control.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the children as an array of childIDs in the <code>children</code>
+     * field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>children [Typical OUT] - an array of childIDs</li>
+     *    <li>accessible [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
+     * </ul>
+     */
+    public void getChildren (AccessibleControlEvent e) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleControlEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleControlEvent;
+
+import dwt.accessibility.Accessible;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for detailed information about the implementation
+ * of the control instance. Typically, only implementors
+ * of custom controls need to listen for this event.
+ * <p>
+ * Note: The meaning of each field depends on the
+ * message that was sent.
+ * </p>
+ *
+ * @see AccessibleControlListener
+ * @see AccessibleControlAdapter
+ * 
+ * @since 2.0
+ */
+public class AccessibleControlEvent : DWTEventObject {
+    public int childID; // IN/OUT
+    public Accessible accessible; // OUT
+    public int x, y; // IN/OUT
+    public int width, height; // OUT
+    public int detail; // IN/OUT
+    public String result; // OUT
+    public Object children[]; // [OUT]
+
+    static final long serialVersionUID = 3257281444169529141L;
+
+    /**
+     * Constructs a new instance of this class.
+     *
+     * @param source the object that fired the event
+     */
+    public this (Object source) {
+        super(source);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        return "AccessibleControlEvent {childID=" + childID + //$NON-NLS-1$
+        " accessible=" + accessible + //$NON-NLS-1$
+        " x=" + x + //$NON-NLS-1$
+        " y=" + y + //$NON-NLS-1$
+        " width=" + width + //$NON-NLS-1$
+        " height=" + height + //$NON-NLS-1$
+        " detail=" + detail + //$NON-NLS-1$
+        " result=" + result + //$NON-NLS-1$
+        "}"; //$NON-NLS-1$
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleControlListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleControlListener;
+
+import dwt.accessibility.AccessibleControlEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleControlListener</code> method and removed
+ * using the <code>removeAccessibleControlListener</code> method.
+ * When a client requests information the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p><p>
+ * Note: This interface is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleControlAdapter
+ * @see AccessibleControlEvent
+ * 
+ * @since 2.0
+ */
+public interface AccessibleControlListener : DWTEventListener {
+
+    /**
+     * Sent when an accessibility client requests the identifier
+     * of the control child at the specified display coordinates.
+     * <p>
+     * Return the identifier of the child at display point (x, y)
+     * in the <code>childID</code> field of the event object.
+     * Return CHILDID_SELF if point (x, y) is in the control itself
+     * and not in any child. Return CHILDID_NONE if point (x, y)
+     * is not contained in either the control or any of its children.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>x, y [IN] - the specified point in display coordinates</li>
+     *    <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
+     *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+     * </ul>
+     */
+    public void getChildAtPoint (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the location
+     * of the control, or the location of a child of the control.
+     * <p>
+     * Return a rectangle describing the location of the specified
+     * control or child in the <code>x, y, width, and height</code>
+     * fields of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
+     * </ul>
+     */
+    public void getLocation (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the accessible object
+     * for a child of the control.
+     * <p>
+     * Return an <code>Accessible</code> for the specified control or
+     * child in the <code>accessible</code> field of the event object.
+     * Return null if the specified child does not have its own
+     * <code>Accessible</code>.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying a child of the control</li>
+     *    <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
+     * </ul>
+     */
+    public void getChild (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the number of
+     * children in the control.
+     * <p>
+     * Return the number of child items in the <code>detail</code>
+     * field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>detail [OUT] - the number of child items in this control</li>
+     * </ul>
+     */
+    public void getChildCount (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the default action
+     * of the control, or the default action of a child of the control.
+     * <p>
+     * This String is typically a verb describing what the user does to it.
+     * For example, a Push Button's default action is "Press", a Check Button's
+     * is "Check" or "UnCheck", and List items have the default action "Double Click".
+     * </p><p>
+     * Return a String describing the default action of the specified
+     * control or child in the <code>result</code> field of the event object.
+     * Returning null tells the client to use the platform default action String.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested default action String, or null</li>
+     * </ul>
+     */
+    public void getDefaultAction (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the identity of
+     * the child or control that has keyboard focus.
+     * <p>
+     * Return the identifier of the child that has focus in the
+     * <code>childID</code> field of the event object.
+     * Return CHILDID_SELF if the control itself has keyboard focus.
+     * Return CHILDID_NONE if neither the control nor any of its children has focus.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
+     *    <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
+     * </ul>
+     */
+    public void getFocus (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the role
+     * of the control, or the role of a child of the control.
+     * <p>
+     * Return a role constant (constant defined in ACC beginning with ROLE_)
+     * that describes the role of the specified control or child in the
+     * <code>detail</code> field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>detail [OUT] - a role constant describing the role of the control or child</li>
+     * </ul>
+     */
+    public void getRole (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the identity of
+     * the child or control that is currently selected.
+     * <p>
+     * Return the identifier of the selected child in the
+     * <code>childID</code> field of the event object.
+     * Return CHILDID_SELF if the control itself is selected.
+     * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
+     * Return CHILDID_NONE if neither the control nor any of its children are selected.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
+     *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+     * </ul>
+     */
+    public void getSelection (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the state
+     * of the control, or the state of a child of the control.
+     * <p>
+     * Return a state mask (mask bit constants defined in ACC beginning with STATE_)
+     * that describes the current state of the specified control or child in the
+     * <code>detail</code> field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>detail [OUT] - a state mask describing the current state of the control or child</li>
+     * </ul>
+     */
+    public void getState (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the value
+     * of the control, or the value of a child of the control.
+     * <p>
+     * Many controls do not return a value. Examples of controls
+     * that do are: Combo returns the text String, Text returns
+     * its contents, ProgressBar returns a String representing a
+     * percentage, and Tree items return a String representing
+     * their level in the tree.
+     * </p><p>
+     * Return a String describing the value of the specified control
+     * or child in the <code>result</code> field of the event object.
+     * Returning null tells the client to use the platform value String.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested value String, or null</li>
+     * </ul>
+     */
+    public void getValue (AccessibleControlEvent e);
+
+    /**
+     * Sent when an accessibility client requests the children of the control.
+     * <p>
+     * Return the children as an array of childIDs in the <code>children</code>
+     * field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>children [Typical OUT] - an array of childIDs</li>
+     *    <li>children [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
+     * </ul>
+     */
+    public void getChildren (AccessibleControlEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleEvent;
+
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for information about the control instance.
+ * <p>
+ * Note: The meaning of the result field depends
+ * on the message that was sent.
+ * </p>
+ *
+ * @see AccessibleListener
+ * @see AccessibleAdapter
+ * 
+ * @since 2.0
+ */
+public class AccessibleEvent : DWTEventObject {
+    /**
+     * The value of this field is set by an accessibility client
+     * before the accessible listener method is called.
+     * ChildID can be CHILDID_SELF, representing the control itself,
+     * or a 0-based integer representing a specific child of the control.
+     */
+    public int childID;
+
+    /**
+     * The value of this field must be set in the accessible listener
+     * method before returning.
+     * What to set it to depends on the listener method called, and
+     * the childID specified by the client.
+     */
+    public String result;
+
+    static final long serialVersionUID = 3257567304224026934L;
+
+    /**
+     * Constructs a new instance of this class.
+     *
+     * @param source the object that fired the event
+     */
+    public this (Object source) {
+        super(source);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        return "AccessibleEvent {childID=" + childID + " result=" + result + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleListener;
+
+import dwt.accessibility.AccessibleEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleListener</code> method and removed
+ * using the <code>removeAccessibleListener</code> method.
+ * When a client requests information, the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p>
+ *
+ * @see AccessibleAdapter
+ * @see AccessibleEvent
+ * 
+ * @since 2.0
+ */
+public interface AccessibleListener : DWTEventListener {
+
+    /**
+     * Sent when an accessibility client requests the name
+     * of the control, or the name of a child of the control.
+     * <p>
+     * Return the name of the control or specified child in the
+     * <code>result</code> field of the event object. Returning
+     * an empty string tells the client that the control or child
+     * does not have a name, and returning null tells the client
+     * to use the platform name.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested name string, or null</li>
+     * </ul>
+     */
+    public void getName (AccessibleEvent e);
+
+    /**
+     * Sent when an accessibility client requests the help string
+     * of the control, or the help string of a child of the control.
+     * <p>
+     * The information in this property should be similar to the help
+     * provided by toolTipText. It describes what the control or child
+     * does or how to use it, as opposed to getDescription, which
+     * describes appearance.
+     * </p><p>
+     * Return the help string of the control or specified child in
+     * the <code>result</code> field of the event object. Returning
+     * an empty string tells the client that the control or child
+     * does not have a help string, and returning null tells the
+     * client to use the platform help string.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested help string, or null</li>
+     * </ul>
+     */
+    public void getHelp (AccessibleEvent e);
+
+    /**
+     * Sent when an accessibility client requests the keyboard shortcut
+     * of the control, or the keyboard shortcut of a child of the control.
+     * <p>
+     * A keyboard shortcut can either be a mnemonic, or an accelerator.
+     * As a general rule, if the control or child can receive keyboard focus,
+     * then you should expose its mnemonic, and if it cannot receive keyboard
+     * focus, then you should expose its accelerator.
+     * </p><p>
+     * Return the keyboard shortcut string of the control or specified child
+     * in the <code>result</code> field of the event object. Returning an
+     * empty string tells the client that the control or child does not
+     * have a keyboard shortcut string, and returning null tells the client
+     * to use the platform keyboard shortcut string.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
+     * </ul>
+     */
+    public void getKeyboardShortcut (AccessibleEvent e);
+
+    /**
+     * Sent when an accessibility client requests a description
+     * of the control, or a description of a child of the control.
+     * <p>
+     * This is a textual description of the control or child's visual
+     * appearance, which is typically only necessary if it cannot be
+     * determined from other properties such as role.
+     * </p><p>
+     * Return the description of the control or specified child in
+     * the <code>result</code> field of the event object. Returning
+     * an empty string tells the client that the control or child
+     * does not have a description, and returning null tells the
+     * client to use the platform description.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+     *    <li>result [OUT] - the requested description string, or null</li>
+     * </ul>
+     */
+    public void getDescription (AccessibleEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleTextAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleTextAdapter;
+
+import dwt.accessibility.AccessibleTextListener;
+import dwt.accessibility.AccessibleTextEvent;
+import dwt.dwthelper.utils;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleTextListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleTextEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * When returning a child identifier to a client, you may use CHILDID_NONE
+ * to indicate that no child or control has the required information.
+ * </p><p>
+ * Note: This adapter is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleTextListener
+ * @see AccessibleTextEvent
+ * 
+ * @since 3.0
+ */
+public abstract class AccessibleTextAdapter : AccessibleTextListener {
+
+    /**
+     * Sent when an accessibility client requests the current character offset
+     * of the text caret.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the caret offset in the <code>offset</code>
+     * field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying a child of the control</li>
+     *    <li>offset [OUT] - the current offset of the text caret</li>
+     * </ul>
+     */
+    public void getCaretOffset (AccessibleTextEvent e) {
+    }
+
+    /**
+     * Sent when an accessibility client requests the range of the current
+     * text selection.
+     * The default behavior is to do nothing.
+     * <p>
+     * Return the selection start offset and non-negative length in the
+     * <code>offset</code> and <code>length</code> fields of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying a child of the control</li>
+     *    <li>offset [OUT] - the offset of the current text selection</li>
+     *    <li>length [OUT] - the length of the current text selection</li>
+     * </ul>
+     */
+    public void getSelectionRange (AccessibleTextEvent e) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleTextEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleTextEvent;
+
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for detailed information about the implementation
+ * of the control instance. Typically, only implementors
+ * of custom controls need to listen for this event.
+ * <p>
+ * Note: The meaning of each field depends on the
+ * message that was sent.
+ * </p>
+ *
+ * @see AccessibleTextListener
+ * @see AccessibleTextAdapter
+ * 
+ * @since 3.0
+ */
+public class AccessibleTextEvent : DWTEventObject {
+    public int childID; // IN
+    public int offset, length; // OUT
+
+    static final long serialVersionUID = 3977019530868308275L;
+
+    /**
+     * Constructs a new instance of this class.
+     *
+     * @param source the object that fired the event
+     */
+    public this (Object source) {
+        super(source);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        return "AccessibleTextEvent {childID=" ~ childID + //$NON-NLS-1$
+        " offset=" + offset + //$NON-NLS-1$
+        " length=" + length + //$NON-NLS-1$
+        "}"; //$NON-NLS-1$
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/accessibility/AccessibleTextListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.accessibility.AccessibleTextListener;
+
+import dwt.accessibility.AccessibleTextEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleTextListener</code> method and removed
+ * using the <code>removeAccessibleTextListener</code> method.
+ * When a client requests information the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p><p>
+ * Note: This interface is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleTextAdapter
+ * @see AccessibleTextEvent
+ * 
+ * @since 3.0
+ */
+public interface AccessibleTextListener : DWTEventListener {
+
+    /**
+     * Sent when an accessibility client requests the current character offset
+     * of the text caret.
+     * <p>
+     * Return the caret offset in the <code>offset</code>
+     * field of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying a child of the control</li>
+     *    <li>offset [OUT] - the current offset of the text caret</li>
+     * </ul>
+     */
+    public void getCaretOffset (AccessibleTextEvent e);
+
+    /**
+     * Sent when an accessibility client requests the range of the current
+     * text selection.
+     * <p>
+     * Return the selection start offset and non-negative length in the
+     * <code>offset</code> and <code>length</code> fields of the event object.
+     * </p>
+     *
+     * @param e an event object containing the following fields:<ul>
+     *    <li>childID [IN] - an identifier specifying a child of the control</li>
+     *    <li>offset [OUT] - the offset of the current text selection</li>
+     *    <li>length [OUT] - the length of the current text selection</li>
+     * </ul>
+     */
+    public void getSelectionRange (AccessibleTextEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/AppFileLocProvider.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.AppFileLocProvider;
+
+import dwt.dwthelper.utils;
+
+import java.util.Vector;
+
+import dwt.internal.C;
+import dwt.internal.Compatibility;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsEmbedString;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIDirectoryServiceProvider;
+import dwt.internal.mozilla.nsIDirectoryServiceProvider2;
+import dwt.internal.mozilla.nsIFile;
+import dwt.internal.mozilla.nsILocalFile;
+import dwt.internal.mozilla.nsISupports;
+
+class AppFileLocProvider {
+    XPCOMObject supports;
+    XPCOMObject directoryServiceProvider;
+    XPCOMObject directoryServiceProvider2;  
+    int refCount = 0;
+    String mozillaPath, profilePath;
+    String[] pluginDirs;
+    bool isXULRunner;
+    
+    static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$
+    static final String CHROME_DIR = "chrome"; //$NON-NLS-1$
+    static final String COMPONENTS_DIR = "components"; //$NON-NLS-1$
+    static final String HISTORY_FILE = "history.dat"; //$NON-NLS-1$
+    static final String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$
+    static final String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$
+    static final String PLUGINS_DIR = "plugins"; //$NON-NLS-1$
+    static final String USER_PLUGINS_DIR = ".mozilla" + SEPARATOR_OS + "plugins"; //$NON-NLS-1$ //$NON-NLS-2$
+    static final String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$
+    
+AppFileLocProvider (String path) {
+    mozillaPath = path + SEPARATOR_OS;
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    directoryServiceProvider = new XPCOMObject (new int[] {2, 0, 0, 3}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return getFile (args[0], args[1], args[2]);}
+    };
+        
+    directoryServiceProvider2 = new XPCOMObject (new int[] {2, 0, 0, 3, 2}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return getFile (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return getFiles (args[0], args[1]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (directoryServiceProvider !is null) {
+        directoryServiceProvider.dispose ();
+        directoryServiceProvider = null;    
+    }
+    if (directoryServiceProvider2 !is null) {
+        directoryServiceProvider2.dispose ();
+        directoryServiceProvider2 = null;   
+    }   
+}
+
+int /*long*/ getAddress () {
+    return directoryServiceProvider.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIDirectoryServiceProvider.NS_IDIRECTORYSERVICEPROVIDER_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {directoryServiceProvider.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIDirectoryServiceProvider2.NS_IDIRECTORYSERVICEPROVIDER2_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {directoryServiceProvider2.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+void setProfilePath (String path) {
+    profilePath = path;
+    if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$
+        int /*long*/[] result = new int /*long*/[1];
+        nsEmbedString pathString = new nsEmbedString (path);
+        int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+        pathString.dispose ();
+
+        nsILocalFile file = new nsILocalFile (result [0]);
+        rc = file.Create (nsILocalFile.DIRECTORY_TYPE, 0700);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        file.Release ();
+    }
+}
+
+/* nsIDirectoryServiceProvider2 */
+
+int getFiles (int /*long*/ prop, int /*long*/ _retval) {
+    int size = XPCOM.strlen (prop);
+    byte[] bytes = new byte[size];
+    XPCOM.memmove (bytes, prop, size);
+    String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes));
+    String[] propertyValues = null;
+
+    if (propertyName.equals (XPCOM.NS_APP_PLUGINS_DIR_LIST)) {
+        if (pluginDirs is null) {
+            int index = 0;
+            /* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */
+            int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_PLUGIN_PATH, true));
+            if (ptr !is 0) {
+                int length = C.strlen (ptr);
+                byte[] buffer = new byte[length];
+                C.memmove (buffer, ptr, length);
+                String value = new String (MozillaDelegate.mbcsToWcs (null, buffer));
+                if (value.length () > 0) {
+                    String separator = System.getProperty ("path.separator"); // $NON-NLS-1$
+                    Vector segments = new Vector ();
+                    int start, end = -1;
+                    do {
+                        start = end + 1;
+                        end = value.indexOf (separator, start);
+                        String segment;
+                        if (end is -1) {
+                            segment = value.substring (start);
+                        } else {
+                            segment = value.substring (start, end);
+                        }
+                        if (segment.length () > 0) segments.addElement (segment);
+                    } while (end !is -1);
+                    int segmentsSize = segments.size ();
+                    pluginDirs = new String [segmentsSize + 2];
+                    for (index = 0; index < segmentsSize; index++) {
+                        pluginDirs[index] = (String)segments.elementAt (index);
+                    }
+                }
+            }
+            if (pluginDirs is null) {
+                pluginDirs = new String[2];
+            }
+
+            /* set the next value to the GRE path + "plugins" */
+            pluginDirs[index++] = mozillaPath + PLUGINS_DIR;
+
+            /* set the next value to the home directory + "/.mozilla/plugins" */
+            pluginDirs[index++] = System.getProperty("user.home") + SEPARATOR_OS + USER_PLUGINS_DIR;
+        }
+        propertyValues = pluginDirs;
+    }
+
+    XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    if (propertyValues !is null) {
+        int /*long*/[] result = new int /*long*/[1];
+        nsISupports[] files = new nsISupports [propertyValues.length];
+        int index = 0;
+        for (int i = 0; i < propertyValues.length; i++) {
+            nsEmbedString pathString = new nsEmbedString (propertyValues[i]);
+            int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+            if (rc !is XPCOM.NS_ERROR_FILE_UNRECOGNIZED_PATH) {
+                /* value appears to be a valid pathname */
+                if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+                if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+
+                nsILocalFile localFile = new nsILocalFile (result[0]);
+                result[0] = 0;
+                rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); 
+                if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+                if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+                localFile.Release ();
+
+                nsIFile file = new nsIFile (result[0]);
+                files[index++] = file;
+            }
+            pathString.dispose ();
+            result[0] = 0;
+        }
+
+        if (index < propertyValues.length) {
+            /* there were some invalid values so remove the trailing empty array slots */
+            nsISupports[] temp = new nsISupports [index];
+            System.arraycopy (files, 0, temp, 0, index);
+            files = temp;
+        }
+
+        SimpleEnumerator enumerator = new SimpleEnumerator (files);
+        enumerator.AddRef ();
+        XPCOM.memmove (_retval, new int /*long*/[] {enumerator.getAddress ()}, C.PTR_SIZEOF);
+        return XPCOM.NS_OK;
+    }
+
+    return XPCOM.NS_ERROR_FAILURE;
+}   
+    
+/* nsIDirectoryServiceProvider implementation */
+
+int getFile(int /*long*/ prop, int /*long*/ persistent, int /*long*/ _retval) {
+    int size = XPCOM.strlen (prop);
+    byte[] bytes = new byte[size];
+    XPCOM.memmove (bytes, prop, size);
+    String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes));
+    String propertyValue = null;
+
+    if (propertyName.equals (XPCOM.NS_APP_HISTORY_50_FILE)) {
+        propertyValue = profilePath + HISTORY_FILE;
+    } else if (propertyName.equals (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) {
+        propertyValue = profilePath + MIMETYPES_FILE;
+    } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_FILE)) {
+        propertyValue = profilePath + PREFERENCES_FILE;
+    } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_DIR)) {
+        propertyValue = profilePath;
+    } else if (propertyName.equals (XPCOM.NS_APP_USER_CHROME_DIR)) {
+        propertyValue = profilePath + CHROME_DIR;
+    } else if (propertyName.equals (XPCOM.NS_APP_USER_PROFILE_50_DIR)) {
+        propertyValue = profilePath;
+    } else if (propertyName.equals (XPCOM.NS_APP_LOCALSTORE_50_FILE)) {
+        propertyValue = profilePath + LOCALSTORE_FILE;
+    } else if (propertyName.equals (XPCOM.NS_APP_CACHE_PARENT_DIR)) {
+        propertyValue = profilePath;
+    } else if (propertyName.equals (XPCOM.NS_OS_HOME_DIR)) {
+        propertyValue = System.getProperty("user.home");    //$NON-NLS-1$
+    } else if (propertyName.equals (XPCOM.NS_OS_TEMP_DIR)) {
+        propertyValue = System.getProperty("java.io.tmpdir");   //$NON-NLS-1$
+    } else if (propertyName.equals (XPCOM.NS_GRE_DIR)) {
+        propertyValue = mozillaPath;
+    } else if (propertyName.equals (XPCOM.NS_GRE_COMPONENT_DIR)) {
+        propertyValue = mozillaPath + COMPONENTS_DIR;
+    } else if (propertyName.equals (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) {
+        propertyValue = mozillaPath;
+    } else if (propertyName.equals (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) {
+        propertyValue = mozillaPath;
+    } else if (propertyName.equals (XPCOM.NS_XPCOM_COMPONENT_DIR)) {
+        propertyValue = mozillaPath + COMPONENTS_DIR;
+    } else if (propertyName.equals (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) {
+        propertyValue = mozillaPath;
+    } else if (propertyName.equals (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) {
+        /*
+        * Answering a value for this property causes problems in Mozilla versions
+        * < 1.7.  Unfortunately this property is queried early enough in the
+        * Browser creation process that the Mozilla version being used is not
+        * yet determined.  However it is known if XULRunner is being used or not.
+        * 
+        * For now answer a value for this property iff XULRunner is the GRE.
+        * If the range of Mozilla versions supported by the Browser is changed
+        * in the future to be >= 1.7 then this value can always be answered.  
+        */
+        if (isXULRunner) propertyValue = profilePath;
+    }
+
+    XPCOM.memmove (persistent, new int[] {1}, 4); /* PRBool */
+    XPCOM.memmove (_retval, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    if (propertyValue !is null && propertyValue.length () > 0) {
+        int /*long*/[] result = new int /*long*/[1];
+        nsEmbedString pathString = new nsEmbedString (propertyValue);
+        int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+        pathString.dispose ();
+        
+        nsILocalFile localFile = new nsILocalFile (result [0]);
+        result[0] = 0;
+        rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); 
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+        XPCOM.memmove (_retval, new int /*long*/[] {result[0]}, C.PTR_SIZEOF);
+        localFile.Release ();
+        return XPCOM.NS_OK;
+    }
+
+    return XPCOM.NS_ERROR_FAILURE;
+}       
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/Browser.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,826 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.Browser;
+
+import tango.core.Thread;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.widgets.Composite;
+import dwt.widgets.Display;
+import dwt.widgets.Widget;
+
+import dwt.browser.LocationListener;
+import dwt.browser.WebBrowser;
+import dwt.browser.CloseWindowListener;
+import dwt.browser.OpenWindowListener;
+import dwt.browser.ProgressListener;
+import dwt.browser.StatusTextListener;
+import dwt.browser.TitleListener;
+import dwt.browser.VisibilityWindowListener;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Instances of this class implement the browser user interface
+ * metaphor.  It allows the user to visualize and navigate through
+ * HTML documents.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>MOZILLA</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>CloseWindowListener, LocationListener, OpenWindowListener, ProgressListener, StatusTextListener, TitleListener, VisibilityWindowListener</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @since 3.0
+ */
+
+public class Browser : Composite {
+    WebBrowser webBrowser;
+    int userStyle;
+
+    static final String PACKAGE_PREFIX = "dwt.browser."; //$NON-NLS-1$
+    static final String NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * and a style value describing its behavior and appearance.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a widget which will be the parent of the new instance (cannot be null)
+     * @param style the style of widget to construct
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     * @exception DWTError <ul>
+     *    <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li>
+     * </ul>
+     * 
+     * @see Widget#getStyle
+     * 
+     * @since 3.0
+     */
+    public this (Composite parent, int style) {
+        super(checkParent(parent), checkStyle(style));
+        userStyle = style;
+
+        String platform = DWT.getPlatform();
+        Display display = parent.getDisplay();
+        if ("gtk".opEquals(platform))
+            display.setData(NO_INPUT_METHOD, null); //$NON-NLS-1$
+        String className = null;
+        if ((style & DWT.MOZILLA) !is 0) {
+            className = "dwt.browser.Mozilla"; //$NON-NLS-1$
+        }
+        else {
+            if ("win32".opEquals(platform) || "wpf".opEquals(platform)) { //$NON-NLS-1$ $NON-NLS-2$
+                className = "dwt.browser.IE"; //$NON-NLS-1$
+            }
+            else if ("motif".opEquals(platform)) { //$NON-NLS-1$
+                className = "dwt.browser.Mozilla"; //$NON-NLS-1$
+            }
+            else if ("gtk".opEquals(platform)) { //$NON-NLS-1$
+                className = "dwt.browser.Mozilla"; //$NON-NLS-1$
+            }
+            else if ("carbon".opEquals(platform) || "cocoa".opEquals(platform)) { //$NON-NLS-1$
+                className = "dwt.browser.Safari"; //$NON-NLS-1$
+            }
+            else if ("photon".opEquals(platform)) { //$NON-NLS-1$
+                className = "dwt.browser.Voyager"; //$NON-NLS-1$
+            }
+            else {
+                dispose();
+                DWT.error(DWT.ERROR_NO_HANDLES);
+            }
+        }
+
+        try {
+            Class clazz = Class.forName(className);
+            webBrowser = cast(WebBrowser) clazz.newInstance();
+        }
+        catch (ClassNotFoundException e) {
+        } catch (IllegalAccessException e) {
+        } catch (InstantiationException e) {
+        }
+        if (webBrowser is null) {
+            dispose();
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        }
+
+        webBrowser.setBrowser(this);
+        webBrowser.create(parent, style);
+    }
+
+    static Composite checkParent (Composite parent) {
+        String platform = DWT.getPlatform();
+        if (!"gtk".opEquals(platform))
+            return parent; //$NON-NLS-1$
+
+        /*
+         * Note.  Mozilla provides all IM support needed for text input in web pages.
+         * If DWT creates another input method context for the widget it will cause
+         * indeterminate results to happen (hangs and crashes). The fix is to prevent 
+         * DWT from creating an input method context for the  Browser widget.
+         */
+        if (parent !is null && !parent.isDisposed()) {
+            Display display = parent.getDisplay();
+            if (display !is null) {
+                if (display.getThread() is Thread.currentThread()) {
+                    display.setData(NO_INPUT_METHOD, "true"); //$NON-NLS-1$
+                }
+            }
+        }
+        return parent;
+    }
+
+    static int checkStyle (int style) {
+        String platform = DWT.getPlatform();
+        if ((style & DWT.MOZILLA) !is 0) {
+            if ("carbon".opEquals(platform))
+                return style | DWT.EMBEDDED; //$NON-NLS-1$
+            if ("motif".opEquals(platform))
+                return style | DWT.EMBEDDED; //$NON-NLS-1$
+            return style;
+        }
+
+        if ("win32".opEquals(platform)) { //$NON-NLS-1$
+            /*
+             * For IE on win32 the border is supplied by the embedded browser, so remove
+             * the style so that the parent Composite will not draw a second border.
+             */
+            return style & ~DWT.BORDER;
+        }
+        else if ("motif".opEquals(platform)) { //$NON-NLS-1$
+            return style | DWT.EMBEDDED;
+        }
+        return style;
+    }
+
+    /**
+     * Clears all session cookies from all current Browser instances.
+     * 
+     * @since 3.2
+     */
+    public static void clearSessions () {
+        WebBrowser.clearSessions();
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will be
+     * notified when the window hosting the receiver should be closed.
+     * <p>
+     * This notification occurs when a javascript command such as
+     * <code>window.close</code> gets executed by a <code>Browser</code>.
+     * </p>
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void addCloseWindowListener (CloseWindowListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.addCloseWindowListener(listener);
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will be
+     * notified when the current location has changed or is about to change.
+     * <p>
+     * This notification typically occurs when the application navigates
+     * to a new location with {@link #setUrl(String)} or when the user
+     * activates a hyperlink.
+     * </p>
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void addLocationListener (LocationListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.addLocationListener(listener);
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will be
+     * notified when a new window needs to be created.
+     * <p>
+     * This notification occurs when a javascript command such as
+     * <code>window.open</code> gets executed by a <code>Browser</code>.
+     * </p>
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void addOpenWindowListener (OpenWindowListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.addOpenWindowListener(listener);
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will be
+     * notified when a progress is made during the loading of the current 
+     * URL or when the loading of the current URL has been completed.
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void addProgressListener (ProgressListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.addProgressListener(listener);
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will be
+     * notified when the status text is changed.
+     * <p>
+     * The status text is typically displayed in the status bar of
+     * a browser application.
+     * </p>
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void addStatusTextListener (StatusTextListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.addStatusTextListener(listener);
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will be
+     * notified when the title of the current document is available
+     * or has changed.
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void addTitleListener (TitleListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.addTitleListener(listener);
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will be
+     * notified when a window hosting the receiver needs to be displayed
+     * or hidden.
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void addVisibilityWindowListener (VisibilityWindowListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.addVisibilityWindowListener(listener);
+    }
+
+    /**
+     * Navigate to the previous session history item.
+     *
+     * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @see #forward
+     * 
+     * @since 3.0
+     */
+    public bool back () {
+        checkWidget();
+        return webBrowser.back();
+    }
+
+    protected void checkSubclass () {
+        String name = getClass().getName();
+        int index = name.lastIndexOf('.');
+        if (!name.substring(0, index + 1).opEquals(PACKAGE_PREFIX)) {
+            DWT.error(DWT.ERROR_INVALID_SUBCLASS);
+        }
+    }
+
+    /**
+     * Execute the specified script.
+     *
+     * <p>
+     * Execute a script containing javascript commands in the context of the current document. 
+     * 
+     * @param script the script with javascript commands
+     *  
+     * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the script is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.1
+     */
+    public bool execute (String script) {
+        checkWidget();
+        if (script is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        return webBrowser.execute(script);
+    }
+
+    /**
+     * Navigate to the next session history item.
+     *
+     * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @see #back
+     * 
+     * @since 3.0
+     */
+    public bool forward () {
+        checkWidget();
+        return webBrowser.forward();
+    }
+
+    public int getStyle () {
+        /*
+         * If DWT.BORDER was specified at creation time then getStyle() should answer
+         * it even though it is removed for IE on win32 in checkStyle().
+         */
+        return super.getStyle() | (userStyle & DWT.BORDER);
+    }
+
+    /**
+     * Returns a String with HTML that represents the content of the current page.
+     *
+     * @return HTML representing the current page or an empty <code>String</code>
+     * if this is empty
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.4
+     */
+    public String getText () {
+        checkWidget();
+        return webBrowser.getText();
+    }
+
+    /**
+     * Returns the current URL.
+     *
+     * @return the current URL or an empty <code>String</code> if there is no current URL
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @see #setUrl
+     * 
+     * @since 3.0
+     */
+    public String getUrl () {
+        checkWidget();
+        return webBrowser.getUrl();
+    }
+
+    /**
+     * Returns the JavaXPCOM <code>nsIWebBrowser</code> for the receiver, or <code>null</code>
+     * if it is not available.  In order for an <code>nsIWebBrowser</code> to be returned all
+     * of the following must be true: <ul>
+     *    <li>the receiver's style must be <code>DWT.MOZILLA</code></li>
+     *    <li>the classes from JavaXPCOM &gt;= 1.8.1.2 must be resolvable at runtime</li>
+     *    <li>the version of the underlying XULRunner must be &gt;= 1.8.1.2</li>
+     * </ul> 
+     *
+     * @return the receiver's JavaXPCOM <code>nsIWebBrowser</code> or <code>null</code>
+     * 
+     * @since 3.3
+     */
+    public Object getWebBrowser () {
+        checkWidget();
+        return webBrowser.getWebBrowser();
+    }
+
+    /**
+     * Returns <code>true</code> if the receiver can navigate to the 
+     * previous session history item, and <code>false</code> otherwise.
+     *
+     * @return the receiver's back command enabled state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @see #back
+     */
+    public bool isBackEnabled () {
+        checkWidget();
+        return webBrowser.isBackEnabled();
+    }
+
+    public bool isFocusControl () {
+        checkWidget();
+        if (webBrowser.isFocusControl())
+            return true;
+        return super.isFocusControl();
+    }
+
+    /**
+     * Returns <code>true</code> if the receiver can navigate to the 
+     * next session history item, and <code>false</code> otherwise.
+     *
+     * @return the receiver's forward command enabled state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @see #forward
+     */
+    public bool isForwardEnabled () {
+        checkWidget();
+        return webBrowser.isForwardEnabled();
+    }
+
+    /**
+     * Refresh the current page.
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void refresh () {
+        checkWidget();
+        webBrowser.refresh();
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when the window hosting the receiver should be closed.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void removeCloseWindowListener (CloseWindowListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.removeCloseWindowListener(listener);
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when the current location is changed or about to be changed.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void removeLocationListener (LocationListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.removeLocationListener(listener);
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when a new window needs to be created.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void removeOpenWindowListener (OpenWindowListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.removeOpenWindowListener(listener);
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when a progress is made during the loading of the current 
+     * URL or when the loading of the current URL has been completed.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void removeProgressListener (ProgressListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.removeProgressListener(listener);
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when the status text is changed.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void removeStatusTextListener (StatusTextListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.removeStatusTextListener(listener);
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when the title of the current document is available
+     * or has changed.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void removeTitleListener (TitleListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.removeTitleListener(listener);
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when a window hosting the receiver needs to be displayed
+     * or hidden.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void removeVisibilityWindowListener (VisibilityWindowListener listener) {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        webBrowser.removeVisibilityWindowListener(listener);
+    }
+
+    /**
+     * Renders HTML.
+     * 
+     * <p>
+     * The html parameter is Unicode encoded since it is a java <code>String</code>.
+     * As a result, the HTML meta tag charset should not be set. The charset is implied
+     * by the <code>String</code> itself.
+     * 
+     * @param html the HTML content to be rendered
+     *
+     * @return true if the operation was successful and false otherwise.
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the html is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *  
+     * @see #setUrl
+     * 
+     * @since 3.0
+     */
+    public bool setText (String html) {
+        checkWidget();
+        if (html is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        return webBrowser.setText(html);
+    }
+
+    /**
+     * Loads a URL.
+     * 
+     * @param url the URL to be loaded
+     *
+     * @return true if the operation was successful and false otherwise.
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the url is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *  
+     * @see #getUrl
+     * 
+     * @since 3.0
+     */
+    public bool setUrl (String url) {
+        checkWidget();
+        if (url is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        return webBrowser.setUrl(url);
+    }
+
+    /**
+     * Stop any loading and rendering activity.
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void stop () {
+        checkWidget();
+        webBrowser.stop();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/CloseWindowListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.CloseWindowListener;
+
+import dwt.browser.WindowEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link WindowEvent} notification when a {@link Browser} is 
+ * about to be closed and when its host window should be closed
+ * by the application.
+ * 
+ * @see Browser#addCloseWindowListener(CloseWindowListener)
+ * @see Browser#removeCloseWindowListener(CloseWindowListener)
+ * @see OpenWindowListener
+ * @see VisibilityWindowListener
+ * 
+ * @since 3.0
+ */
+public interface CloseWindowListener : DWTEventListener {
+
+    /**
+     * This method is called when the window hosting a {@link Browser} should be closed.
+     * Application would typically close the {@link dwt.widgets.Shell} that
+     * hosts the <code>Browser</code>. The <code>Browser</code> is disposed after this
+     * notification.
+     *
+     * <p>The following fields in the <code>WindowEvent</code> apply:
+     * <ul>
+     * <li>(in) widget the <code>Browser</code> that is going to be disposed
+     * </ul></p>
+     *
+     * @param event the <code>WindowEvent</code> that specifies the <code>Browser</code>
+     * that is going to be disposed
+     * 
+     * @see dwt.widgets.Shell#close()
+     * 
+     * @since 3.0
+     */
+    public void close (WindowEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/Download.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,386 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.Download;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.C;
+import dwt.internal.Compatibility;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIDownload;
+import dwt.internal.mozilla.nsIHelperAppLauncher;
+import dwt.internal.mozilla.nsILocalFile;
+import dwt.internal.mozilla.nsIProgressDialog;
+import dwt.internal.mozilla.nsISupports;
+import dwt.internal.mozilla.nsIURI;
+import dwt.internal.mozilla.nsIWebProgressListener;
+import dwt.layout.GridData;
+import dwt.layout.GridLayout;
+import dwt.widgets.Button;
+import dwt.widgets.Event;
+import dwt.widgets.Label;
+import dwt.widgets.Listener;
+import dwt.widgets.Shell;
+
+class Download {
+    XPCOMObject supports;
+    XPCOMObject download;
+    XPCOMObject progressDialog;
+    XPCOMObject webProgressListener;
+    nsIHelperAppLauncher helperAppLauncher;
+    int refCount = 0;
+
+    Shell shell;
+    Label status;
+    Button cancel;
+    
+Download () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    download = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);}
+        public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);}
+        public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);}
+        public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);}
+    };
+    
+    progressDialog = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);}
+        public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);}
+        public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);}
+        public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);}
+        public int /*long*/ method16 (int /*long*/[] args) {return Open (args[0]);}
+        public int /*long*/ method17 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);}
+        public int /*long*/ method18 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);}
+        public int /*long*/ method19 (int /*long*/[] args) {return GetDialog (args[0]);}
+        public int /*long*/ method20 (int /*long*/[] args) {return SetDialog (args[0]);}
+    };
+    
+    webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (download !is null) {
+        download.dispose ();
+        download = null;    
+    }
+    if (progressDialog !is null) {
+        progressDialog.dispose ();
+        progressDialog = null;
+    }
+    if (webProgressListener !is null) {
+        webProgressListener.dispose ();
+        webProgressListener = null;
+    }
+}
+
+int /*long*/ getAddress () {
+    return progressDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIDownload.NS_IDOWNLOAD_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIProgressDialog.NS_IPROGRESSDIALOG_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+/* nsIDownload */
+
+/* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */
+int Init (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aPersist) {
+    nsIURI source = new nsIURI (aSource);
+    int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+    int rc = source.GetHost (aSpec);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    int length = XPCOM.nsEmbedCString_Length (aSpec);
+    int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+    byte[] dest = new byte[length];
+    XPCOM.memmove (dest, buffer, length);
+    XPCOM.nsEmbedCString_delete (aSpec);
+    String url = new String (dest);
+
+    /*
+    * As of mozilla 1.7 the second argument of the nsIDownload interface's 
+    * Init function changed from nsILocalFile to nsIURI.  Detect which of
+    * these interfaces the second argument implements and act accordingly.  
+    */
+    String filename = null;
+    nsISupports supports = new nsISupports (aTarget);
+    int /*long*/[] result = new int /*long*/[1];
+    rc = supports.QueryInterface (nsIURI.NS_IURI_IID, result);
+    if (rc is 0) {  /* >= 1.7 */
+        nsIURI target = new nsIURI (result[0]);
+        result[0] = 0;
+        int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
+        rc = target.GetPath (aPath);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        length = XPCOM.nsEmbedCString_Length (aPath);
+        buffer = XPCOM.nsEmbedCString_get (aPath);
+        dest = new byte[length];
+        XPCOM.memmove (dest, buffer, length);
+        XPCOM.nsEmbedCString_delete (aPath);
+        filename = new String (dest);
+        int separator = filename.lastIndexOf (System.getProperty ("file.separator"));   //$NON-NLS-1$
+        filename = filename.substring (separator + 1);
+        target.Release ();
+    } else {    /* < 1.7 */
+        nsILocalFile target = new nsILocalFile (aTarget);
+        int /*long*/ aNativeTarget = XPCOM.nsEmbedCString_new ();
+        rc = target.GetNativeLeafName (aNativeTarget);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        length = XPCOM.nsEmbedCString_Length (aNativeTarget);
+        buffer = XPCOM.nsEmbedCString_get (aNativeTarget);
+        dest = new byte[length];
+        XPCOM.memmove (dest, buffer, length);
+        XPCOM.nsEmbedCString_delete (aNativeTarget);
+        filename = new String (dest);
+    }
+
+    Listener listener = new Listener () {
+        public void handleEvent (Event event) {
+            if (event.widget is cancel) {
+                shell.close ();
+            }
+            if (helperAppLauncher !is null) {
+                helperAppLauncher.Cancel ();
+                helperAppLauncher.Release ();
+            }
+            shell = null;
+            helperAppLauncher = null;
+        }
+    };
+    shell = new Shell (DWT.DIALOG_TRIM);
+    String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
+    shell.setText (msg);
+    GridLayout gridLayout = new GridLayout ();
+    gridLayout.marginHeight = 15;
+    gridLayout.marginWidth = 15;
+    gridLayout.verticalSpacing = 20;
+    shell.setLayout(gridLayout);
+    msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
+    new Label (shell, DWT.SIMPLE).setText (msg);
+    status = new Label (shell, DWT.SIMPLE);
+    msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$
+    status.setText (msg);
+    GridData data = new GridData ();
+    data.grabExcessHorizontalSpace = true;
+    data.grabExcessVerticalSpace = true;
+    status.setLayoutData (data);
+
+    cancel = new Button (shell, DWT.PUSH);
+    cancel.setText (DWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$
+    data = new GridData ();
+    data.horizontalAlignment = GridData.CENTER;
+    cancel.setLayoutData (data);
+    cancel.addListener (DWT.Selection, listener);
+    shell.addListener (DWT.Close, listener);
+    shell.pack ();
+    shell.open ();
+    return XPCOM.NS_OK;
+}
+
+int GetSource (int /*long*/ aSource) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetTarget (int /*long*/ aTarget) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetPersist (int /*long*/ aPersist) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetPercentComplete (int /*long*/ aPercentComplete) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDisplayName (int /*long*/ aDisplayName) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDisplayName (int /*long*/ aDisplayName) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetStartTime (int /*long*/ aStartTime) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetMIMEInfo (int /*long*/ aMIMEInfo) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetListener (int /*long*/ aListener) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetListener (int /*long*/ aListener) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetObserver (int /*long*/ aObserver) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetObserver (int /*long*/ aObserver) {
+    if (aObserver !is 0) {
+        nsISupports supports = new nsISupports (aObserver);
+        int /*long*/[] result = new int /*long*/[1];
+        int rc = supports.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+        helperAppLauncher = new nsIHelperAppLauncher (result[0]);
+    }
+    return XPCOM.NS_OK;
+}
+
+/* nsIProgressDialog */
+int Open (int /*long*/ aParent) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetCancelDownloadOnClose (int /*long*/ aCancelDownloadOnClose) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetCancelDownloadOnClose (int aCancelDownloadOnClose) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDialog (int /*long*/ aDialog) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDialog (int /*long*/ aDialog) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIWebProgressListener */
+
+int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) {
+    if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) {
+        if (helperAppLauncher !is null) helperAppLauncher.Release ();
+        helperAppLauncher = null;
+        if (shell !is null && !shell.isDisposed ()) shell.dispose ();
+        shell = null;
+    }
+    return XPCOM.NS_OK;
+}
+
+int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) {
+    int currentKBytes = aCurTotalProgress / 1024;
+    int totalKBytes = aMaxTotalProgress / 1024;
+    if (shell !is null && !shell.isDisposed ()) {
+        Object[] arguments = {new Integer (currentKBytes), new Integer (totalKBytes)};
+        String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$
+        status.setText (statusMsg);
+        shell.layout (true);
+        shell.getDisplay ().update ();
+    }
+    return XPCOM.NS_OK;
+}
+
+int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) {
+    return XPCOM.NS_OK;
+}
+
+int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) {
+    return XPCOM.NS_OK;
+}
+
+int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) {
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/DownloadFactory.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.DownloadFactory;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIFactory;
+import dwt.internal.mozilla.nsISupports;
+
+class DownloadFactory {
+    XPCOMObject supports;
+    XPCOMObject factory;
+    int refCount = 0;
+
+DownloadFactory () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (factory !is null) {
+        factory.dispose ();
+        factory = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+    
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+    Download download = new Download ();
+    download.AddRef ();
+    XPCOM.memmove (result, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/DownloadFactory_1_8.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.DownloadFactory_1_8;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIFactory;
+import dwt.internal.mozilla.nsISupports;
+
+class DownloadFactory_1_8 {
+    XPCOMObject supports;
+    XPCOMObject factory;
+    int refCount = 0;
+
+DownloadFactory_1_8 () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (factory !is null) {
+        factory.dispose ();
+        factory = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+    Download_1_8 download = new Download_1_8 ();
+    download.AddRef ();
+    XPCOM.memmove (result, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/Download_1_8.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,407 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.Download_1_8;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.C;
+import dwt.internal.Compatibility;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsICancelable;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIDownload_1_8;
+import dwt.internal.mozilla.nsIProgressDialog_1_8;
+import dwt.internal.mozilla.nsISupports;
+import dwt.internal.mozilla.nsIURI;
+import dwt.internal.mozilla.nsIWebProgressListener;
+import dwt.layout.GridData;
+import dwt.layout.GridLayout;
+import dwt.widgets.Button;
+import dwt.widgets.Event;
+import dwt.widgets.Label;
+import dwt.widgets.Listener;
+import dwt.widgets.Shell;
+
+class Download_1_8 {
+    XPCOMObject supports;
+    XPCOMObject download;
+    XPCOMObject progressDialog;
+    XPCOMObject webProgressListener;
+    nsICancelable cancelable;
+    int refCount = 0;
+
+    Shell shell;
+    Label status;
+    Button cancel;
+
+    static final bool is32 = C.PTR_SIZEOF is 4;
+
+Download_1_8 () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+
+    download = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+        public int /*long*/ method8 (int /*long*/[] args) {
+            if (args.length is 10) {
+                return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
+            } else {
+                return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]);
+            }
+        }
+        public int /*long*/ method9 (int /*long*/[] args) {
+            if (args.length is 8) {
+                return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+            } else {
+                return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+            }
+        }
+        public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);}
+        public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);}
+        public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);}
+        public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);}
+        public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);}
+        public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+        public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);}
+        public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+    };
+
+    progressDialog = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+        public int /*long*/ method8 (int /*long*/[] args) {
+            if (args.length is 10) {
+                return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
+            } else {
+                return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]);
+            }
+        }
+        public int /*long*/ method9 (int /*long*/[] args) {
+            if (args.length is 8) {
+                return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+            } else {
+                return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+            }
+        }
+        public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);}
+        public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);}
+        public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);}
+        public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);}
+        public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);}
+        public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+        public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);}
+        public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+        public int /*long*/ method20 (int /*long*/[] args) {return Open (args[0]);}
+        public int /*long*/ method21 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);}
+        public int /*long*/ method22 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);}
+        public int /*long*/ method23 (int /*long*/[] args) {return GetObserver (args[0]);}
+        public int /*long*/ method24 (int /*long*/[] args) {return SetObserver (args[0]);}
+        public int /*long*/ method25 (int /*long*/[] args) {return GetDialog (args[0]);}
+        public int /*long*/ method26 (int /*long*/[] args) {return SetDialog (args[0]);}
+    };
+
+    webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+    };
+}
+
+void disposeCOMInterfaces() {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (download !is null) {
+        download.dispose ();
+        download = null;    
+    }
+    if (progressDialog !is null) {
+        progressDialog.dispose ();
+        progressDialog = null;  
+    }
+    if (webProgressListener !is null) {
+        webProgressListener.dispose ();
+        webProgressListener = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return progressDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIDownload_1_8.NS_IDOWNLOAD_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIProgressDialog_1_8.NS_IPROGRESSDIALOG_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF);
+        AddRef();
+        return XPCOM.NS_OK;
+    }
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+/* nsIDownload */
+
+/* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */
+int Init_32 (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aTempFile, int /*long*/ aCancelable) {
+    long startTime = (startTime2 << 32) + startTime1;
+    return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable);
+}
+
+int Init (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, long startTime, int /*long*/ aTempFile, int /*long*/ aCancelable) {
+    cancelable = new nsICancelable (aCancelable);
+    nsIURI source = new nsIURI (aSource);
+    int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+    int rc = source.GetHost (aSpec);
+    if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
+    int length = XPCOM.nsEmbedCString_Length (aSpec);
+    int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+    byte[] dest = new byte[length];
+    XPCOM.memmove (dest, buffer, length);
+    XPCOM.nsEmbedCString_delete (aSpec);
+    String url = new String (dest);
+
+    nsIURI target = new nsIURI (aTarget);
+    int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
+    rc = target.GetPath (aPath);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    length = XPCOM.nsEmbedCString_Length (aPath);
+    buffer = XPCOM.nsEmbedCString_get (aPath);
+    dest = new byte[length];
+    XPCOM.memmove (dest, buffer, length);
+    XPCOM.nsEmbedCString_delete (aPath);
+    String filename = new String (dest);
+    int separator = filename.lastIndexOf (System.getProperty ("file.separator"));   //$NON-NLS-1$
+    filename = filename.substring (separator + 1);
+
+    Listener listener = new Listener() {
+        public void handleEvent (Event event) {
+            if (event.widget is cancel) {
+                shell.close ();
+            }
+            if (cancelable !is null) {
+                int rc = cancelable.Cancel (XPCOM.NS_BINDING_ABORTED);
+                if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+            }
+            shell = null;
+            cancelable = null;
+        }
+    };
+    shell = new Shell (DWT.DIALOG_TRIM);
+    String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
+    shell.setText (msg);
+    GridLayout gridLayout = new GridLayout ();
+    gridLayout.marginHeight = 15;
+    gridLayout.marginWidth = 15;
+    gridLayout.verticalSpacing = 20;
+    shell.setLayout (gridLayout);
+    msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
+    new Label (shell, DWT.SIMPLE).setText (msg);
+    status = new Label (shell, DWT.SIMPLE);
+    msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$
+    status.setText (msg);
+    GridData data = new GridData ();
+    data.grabExcessHorizontalSpace = true;
+    data.grabExcessVerticalSpace = true;
+    status.setLayoutData (data);
+    
+    cancel = new Button (shell, DWT.PUSH);
+    cancel.setText (DWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$
+    data = new GridData ();
+    data.horizontalAlignment = GridData.CENTER;
+    cancel.setLayoutData (data);
+    cancel.addListener (DWT.Selection, listener);
+    shell.addListener (DWT.Close, listener);
+    shell.pack ();
+    shell.open ();
+    return XPCOM.NS_OK;
+}
+
+int GetAmountTransferred (int /*long*/ arg0) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetCancelable (int /*long*/ arg0) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDisplayName (int /*long*/ aDisplayName) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetMIMEInfo (int /*long*/ aMIMEInfo) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetPercentComplete (int /*long*/ aPercentComplete) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetSize (int /*long*/ arg0) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetSource (int /*long*/ aSource) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetStartTime (int /*long*/ aStartTime) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetTarget (int /*long*/ aTarget) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetTargetFile (int /*long*/ arg0) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIProgressDialog */
+int GetCancelDownloadOnClose (int /*long*/ aCancelDownloadOnClose) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDialog (int /*long*/ aDialog) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetObserver (int /*long*/ aObserver) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int Open (int /*long*/ aParent) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetCancelDownloadOnClose (int aCancelDownloadOnClose) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDialog (int /*long*/ aDialog) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetObserver (int /*long*/ aObserver) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIWebProgressListener */
+
+int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) {
+    return XPCOM.NS_OK;
+}
+
+int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) {
+    return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
+}
+
+/* Note. The last 4 args in the original interface are defined as PRInt64. These each translate into two java ints. */
+int OnProgressChange64_32 (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress1, int /*long*/ aCurSelfProgress2, int /*long*/ aMaxSelfProgress1, int /*long*/ aMaxSelfProgress2, int /*long*/ aCurTotalProgress1, int /*long*/ aCurTotalProgress2, int /*long*/ aMaxTotalProgress1, int /*long*/ aMaxTotalProgress2) {
+    long aCurSelfProgress = (aCurSelfProgress2 << 32) + aCurSelfProgress1;
+    long aMaxSelfProgress = (aMaxSelfProgress2 << 32) + aMaxSelfProgress1;
+    long aCurTotalProgress = (aCurTotalProgress2 << 32) + aCurTotalProgress1;
+    long aMaxTotalProgress = (aMaxTotalProgress2 << 32) + aMaxTotalProgress1;
+    return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
+}
+
+int OnProgressChange64 (int /*long*/ aWebProgress, int /*long*/ aRequest, long aCurSelfProgress, long aMaxSelfProgress, long aCurTotalProgress, long aMaxTotalProgress) {
+    long currentKBytes = aCurTotalProgress / 1024;
+    long totalKBytes = aMaxTotalProgress / 1024;
+    if (shell !is null && !shell.isDisposed ()) {
+        Object[] arguments = {new Long (currentKBytes), new Long (totalKBytes)};
+        String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$
+        status.setText (statusMsg);
+        shell.layout (true);
+        shell.getDisplay ().update ();
+    }
+    return XPCOM.NS_OK;
+}
+
+int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) {
+    return XPCOM.NS_OK;
+}
+
+int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) {
+    if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) {
+        cancelable = null;
+        if (shell !is null && !shell.isDisposed ()) shell.dispose ();
+        shell = null;
+    }
+    return XPCOM.NS_OK;
+}   
+
+int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) {
+    return XPCOM.NS_OK;
+}       
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/FilePicker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.FilePicker;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsEmbedString;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIFilePicker;
+import dwt.internal.mozilla.nsIFilePicker_1_8;
+import dwt.internal.mozilla.nsILocalFile;
+import dwt.internal.mozilla.nsISupports;
+import dwt.widgets.DirectoryDialog;
+import dwt.widgets.Display;
+import dwt.widgets.FileDialog;
+import dwt.widgets.Shell;
+
+class FilePicker {
+    XPCOMObject supports;
+    XPCOMObject filePicker;
+
+    int refCount = 0;
+    short mode;
+    int /*long*/ parentHandle;
+    String[] files, masks;
+    String defaultFilename, directory, title;
+
+    static final String SEPARATOR = System.getProperty ("file.separator"); //$NON-NLS-1$
+
+FilePicker () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+
+    filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], (short)args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters ((int)/*64*/args[0]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex ((int)/*64*/args[0]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);}
+        public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);}
+        public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);}
+        public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);}
+        public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);}
+        public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (filePicker !is null) {
+        filePicker.dispose ();
+        filePicker = null;  
+    }
+}
+
+int /*long*/ getAddress () {
+    return filePicker.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIFilePicker.NS_IFILEPICKER_IID)) {
+        XPCOM.memmove(ppvObject, new int /*long*/[] {filePicker.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIFilePicker_1_8.NS_IFILEPICKER_IID)) {
+        XPCOM.memmove(ppvObject, new int /*long*/[] {filePicker.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+/*
+ * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type.  This method
+ * answers a java string based on the type of string that is appropriate for the Mozilla
+ * version being used.
+ */
+String parseAString (int /*long*/ string) {
+    return null;
+}
+
+/* nsIFilePicker */
+
+int Init (int /*long*/ parent, int /*long*/ title, short mode) {
+    parentHandle = parent;
+    this.mode = mode;
+    this.title = parseAString (title);
+    return XPCOM.NS_OK;
+}
+
+int Show (int /*long*/ _retval) {
+    if (mode is nsIFilePicker.modeGetFolder) {
+        /* picking a directory */
+        int result = showDirectoryPicker ();
+        XPCOM.memmove (_retval, new short[] {(short)result}, 2); /* PRInt16 */
+        return XPCOM.NS_OK;
+    }
+
+    /* picking a file */
+    int style = mode is nsIFilePicker.modeSave ? DWT.SAVE : DWT.OPEN;
+    if (mode is nsIFilePicker.modeOpenMultiple) style |= DWT.MULTI;
+    Display display = Display.getCurrent ();
+    Shell parent = null; // TODO compute parent
+    if (parent is null) {
+        parent = new Shell (display);
+    }
+    FileDialog dialog = new FileDialog (parent, style);
+    if (title !is null) dialog.setText (title);
+    if (directory !is null) dialog.setFilterPath (directory);
+    if (masks !is null) dialog.setFilterExtensions (masks);
+    if (defaultFilename !is null) dialog.setFileName (defaultFilename);
+    String filename = dialog.open ();
+    files = dialog.getFileNames ();
+    directory = dialog.getFilterPath ();
+    title = defaultFilename = null;
+    masks = null;
+    int result = filename is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; 
+    XPCOM.memmove (_retval, new short[] {(short)result}, 2); /* PRInt16 */
+    return XPCOM.NS_OK;
+}
+
+int showDirectoryPicker () {
+    Display display = Display.getCurrent ();
+    Shell parent = null; // TODO compute parent
+    if (parent is null) {
+        parent = new Shell (display);
+    }
+    DirectoryDialog dialog = new DirectoryDialog (parent, DWT.NONE);
+    if (title !is null) dialog.setText (title);
+    if (directory !is null) dialog.setFilterPath (directory);
+    directory = dialog.open ();
+    title = defaultFilename = null;
+    files = masks = null;
+    return directory is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK;
+}
+
+int GetFiles (int /*long*/ aFiles) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetFileURL (int /*long*/ aFileURL) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetFile (int /*long*/ aFile) {
+    String filename = "";   //$NON-NLS-1$
+    if (directory !is null) filename += directory + SEPARATOR;
+    if (files !is null && files.length > 0) filename += files[0];
+    nsEmbedString path = new nsEmbedString (filename);
+    int /*long*/[] file = new int /*long*/[1];
+    int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, file);
+    path.dispose ();
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (file[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+    XPCOM.memmove (aFile, file, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int SetDisplayDirectory (int /*long*/ aDisplayDirectory) {
+    if (aDisplayDirectory is 0) return XPCOM.NS_OK;
+    nsILocalFile file = new nsILocalFile (aDisplayDirectory);
+    int /*long*/ pathname = XPCOM.nsEmbedCString_new ();
+    file.GetNativePath (pathname);
+    int length = XPCOM.nsEmbedCString_Length (pathname);
+    int /*long*/ buffer = XPCOM.nsEmbedCString_get (pathname);
+    byte[] bytes = new byte[length];
+    XPCOM.memmove (bytes, buffer, length);
+    XPCOM.nsEmbedCString_delete (pathname);
+    char[] chars = MozillaDelegate.mbcsToWcs (null, bytes);
+    directory = new String (chars);
+    return XPCOM.NS_OK;
+}
+
+int GetDisplayDirectory (int /*long*/ aDisplayDirectory) {
+    String directoryName = directory !is null ? directory : "";  //$NON-NLS-1$
+    nsEmbedString path = new nsEmbedString (directoryName);
+    int /*long*/[] file = new int /*long*/[1];
+    int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, file);
+    path.dispose ();
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (file[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+    XPCOM.memmove (aDisplayDirectory, file, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int SetFilterIndex (int aFilterIndex) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetFilterIndex (int /*long*/ aFilterIndex) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDefaultExtension (int /*long*/ aDefaultExtension) {
+    /* note that the type of argument 1 changed as of Mozilla 1.8 */
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDefaultExtension (int /*long*/ aDefaultExtension) {
+    /* note that the type of argument 1 changed as of Mozilla 1.8 */
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDefaultString (int /*long*/ aDefaultString) {
+    defaultFilename = parseAString (aDefaultString);
+    return XPCOM.NS_OK;
+}
+
+int GetDefaultString (int /*long*/ aDefaultString) {
+    /* note that the type of argument 1 changed as of Mozilla 1.8 */
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int AppendFilter (int /*long*/ title, int /*long*/ filter) {
+    /* note that the type of arguments 1 and 2 changed as of Mozilla 1.8 */
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int AppendFilters (int filterMask) {
+    String[] addFilters = null;
+    switch (filterMask) {
+        case nsIFilePicker.filterAll:
+        case nsIFilePicker.filterApps:
+            masks = null;           /* this is equivalent to no filter */
+            break;
+        case nsIFilePicker.filterHTML:
+            addFilters = new String[] {"*.htm;*.html"}; //$NON-NLS-1$
+            break;
+        case nsIFilePicker.filterImages:
+            addFilters = new String[] {"*.gif;*.jpeg;*.jpg;*.png"}; //$NON-NLS-1$
+            break;
+        case nsIFilePicker.filterText:
+            addFilters = new String[] {"*.txt"};    //$NON-NLS-1$
+            break;
+        case nsIFilePicker.filterXML:
+            addFilters = new String[] {"*.xml"};    //$NON-NLS-1$
+            break;
+        case nsIFilePicker.filterXUL:
+            addFilters = new String[] {"*.xul"};    //$NON-NLS-1$
+            break;
+    }
+    if (masks is null) {
+        masks = addFilters;
+    } else {
+        if (addFilters !is null) {
+            String[] newFilters = new String[masks.length + addFilters.length];
+            System.arraycopy (masks, 0, newFilters, 0, masks.length);
+            System.arraycopy (addFilters, 0, newFilters, masks.length, addFilters.length);
+            masks = newFilters;
+        }
+    }
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/FilePickerFactory.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.FilePickerFactory;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIFactory;
+import dwt.internal.mozilla.nsISupports;
+
+class FilePickerFactory {
+    XPCOMObject supports;
+    XPCOMObject factory;
+    int refCount = 0;
+
+FilePickerFactory () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (factory !is null) {
+        factory.dispose ();
+        factory = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+    
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+    FilePicker picker = new FilePicker ();
+    picker.AddRef ();
+    XPCOM.memmove (result, new int /*long*/[] {picker.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/FilePickerFactory_1_8.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.FilePickerFactory_1_8;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+
+class FilePickerFactory_1_8 extends FilePickerFactory {
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+    };
+}
+
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+    FilePicker_1_8 picker = new FilePicker_1_8 ();
+    picker.AddRef ();
+    XPCOM.memmove (result, new int /*long*/[] {picker.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/FilePicker_1_8.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.FilePicker_1_8;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+
+class FilePicker_1_8 extends FilePicker {
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+
+    filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], (short)args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters ((int)/*64*/args[0]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex ((int)/*64*/args[0]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);}
+        public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);}
+        public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);}
+        public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);}
+        public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);}
+        public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);}
+    };
+}
+
+/*
+ * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type.  This method
+ * answers a java string based on the type of string that is appropriate for the Mozilla
+ * version being used.
+ */
+String parseAString (int /*long*/ string) {
+    if (string is 0) return null;
+    int length = XPCOM.nsEmbedString_Length (string);
+    int /*long*/ buffer = XPCOM.nsEmbedString_get (string);
+    char[] chars = new char[length];
+    XPCOM.memmove (chars, buffer, length * 2);
+    return new String (chars);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/HelperAppLauncherDialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.HelperAppLauncherDialog;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsEmbedString;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIHelperAppLauncher;
+import dwt.internal.mozilla.nsIHelperAppLauncherDialog;
+import dwt.internal.mozilla.nsIHelperAppLauncher_1_8;
+import dwt.internal.mozilla.nsIHelperAppLauncher_1_9;
+import dwt.internal.mozilla.nsISupports;
+import dwt.widgets.FileDialog;
+import dwt.widgets.Shell;
+
+class HelperAppLauncherDialog {
+    XPCOMObject supports;
+    XPCOMObject helperAppLauncherDialog;
+    int refCount = 0;
+
+HelperAppLauncherDialog () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    helperAppLauncherDialog = new XPCOMObject (new int[] {2, 0, 0, 3, 5}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Show (args[0], args[1], (int)/*64*/args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return PromptForSaveToFile (args[0], args[1], args[2], args[3], args[4]);}
+    };      
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (helperAppLauncherDialog !is null) {
+        helperAppLauncherDialog.dispose ();
+        helperAppLauncherDialog = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return helperAppLauncherDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIHelperAppLauncherDialog.NS_IHELPERAPPLAUNCHERDIALOG_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    /*
+    * Note.  This instance lives as long as the download it is binded to.
+    * Its reference count is expected to go down to 0 when the download
+    * has completed or when it has been cancelled. E.g. when the user
+    * cancels the File Dialog, cancels or closes the Download Dialog
+    * and when the Download Dialog goes away after the download is completed.
+    */
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+/* nsIHelperAppLauncherDialog */
+
+int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) {
+    /*
+    * The interface for nsIHelperAppLauncher changed in GRE versions 1.8 and 1.9.  Query for
+    * each of these interfaces in turn until one is found.
+    */
+    nsISupports supports = new nsISupports (aLauncher);
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = supports.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result);
+    if (rc is 0) {
+        nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher);
+        rc = helperAppLauncher.SaveToDisk (0, 0);
+        helperAppLauncher.Release ();
+        return rc;
+    }
+
+    result[0] = 0;
+    rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result);
+    if (rc is 0) {
+        nsIHelperAppLauncher_1_8 helperAppLauncher = new nsIHelperAppLauncher_1_8 (aLauncher);
+        rc = helperAppLauncher.SaveToDisk (0, 0);
+        helperAppLauncher.Release ();
+        return rc;
+    }
+
+    nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher (aLauncher);  /* < 1.8 */
+    return helperAppLauncher.SaveToDisk (0, 0);
+}
+
+int PromptForSaveToFile (int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4) {
+    int /*long*/ aDefaultFile, aSuggestedFileExtension, _retval;
+    bool hasLauncher = false;
+
+    /*
+    * The interface for nsIHelperAppLauncherDialog changed as of mozilla 1.5 when an
+    * extra argument was added to the PromptForSaveToFile method (this resulted in all
+    * subsequent arguments shifting right).  The workaround is to provide an XPCOMObject 
+    * that fits the newer API, and to use the first argument's type to infer whether
+    * the old or new nsIHelperAppLauncherDialog interface is being used (and by extension
+    * the ordering of the arguments).  In mozilla >= 1.5 the first argument is an
+    * nsIHelperAppLauncher. 
+    */
+    /*
+     * The interface for nsIHelperAppLauncher changed as of mozilla 1.8, so the first
+     * argument must be queried for both the old and new nsIHelperAppLauncher interfaces. 
+     */
+    bool using_1_8 = false, using_1_9 = false;
+    nsISupports support = new nsISupports (arg0);
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = support.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result);
+    if (rc is 0) {
+        using_1_8 = true;
+        hasLauncher = true;
+        new nsISupports (result[0]).Release ();
+    } else {
+        result[0] = 0;
+        rc = support.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result);
+        if (rc is 0) {
+            using_1_9 = true;
+            hasLauncher = true;
+            new nsISupports (result[0]).Release ();
+        } else {
+            result[0] = 0;
+            rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result);
+            if (rc is 0) {
+                hasLauncher = true;
+                new nsISupports (result[0]).Release ();
+            }
+        }
+    }
+    result[0] = 0;
+
+    if (hasLauncher) {  /* >= 1.5 */
+        aDefaultFile = arg2;
+        aSuggestedFileExtension = arg3;
+        _retval = arg4;
+    } else {            /* 1.4 */
+        aDefaultFile = arg1;
+        aSuggestedFileExtension = arg2;
+        _retval = arg3;
+    }
+
+    int length = XPCOM.strlen_PRUnichar (aDefaultFile);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, aDefaultFile, length * 2);
+    String defaultFile = new String (dest);
+
+    length = XPCOM.strlen_PRUnichar (aSuggestedFileExtension);
+    dest = new char[length];
+    XPCOM.memmove (dest, aSuggestedFileExtension, length * 2);
+    String suggestedFileExtension = new String (dest);
+
+    Shell shell = new Shell ();
+    FileDialog fileDialog = new FileDialog (shell, DWT.SAVE);
+    fileDialog.setFileName (defaultFile);
+    fileDialog.setFilterExtensions (new String[] {suggestedFileExtension});
+    String name = fileDialog.open ();
+    shell.close ();
+    if (name is null) {
+        if (hasLauncher) {
+            if (using_1_8) {
+                nsIHelperAppLauncher_1_8 launcher = new nsIHelperAppLauncher_1_8 (arg0);
+                rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED);
+            } else if (using_1_9) {
+                nsIHelperAppLauncher_1_9 launcher = new nsIHelperAppLauncher_1_9 (arg0);
+                rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED);
+            } else {
+                nsIHelperAppLauncher launcher = new nsIHelperAppLauncher (arg0);
+                rc = launcher.Cancel ();
+            }
+            if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+            return XPCOM.NS_OK;
+        }
+        return XPCOM.NS_ERROR_FAILURE;
+    }
+    nsEmbedString path = new nsEmbedString (name);
+    rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, result);
+    path.dispose ();
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+    /* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */
+    XPCOM.memmove (_retval, result, C.PTR_SIZEOF);  
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/HelperAppLauncherDialogFactory.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.HelperAppLauncherDialogFactory;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIFactory;
+import dwt.internal.mozilla.nsISupports;
+
+class HelperAppLauncherDialogFactory {
+    XPCOMObject supports;
+    XPCOMObject factory;
+    int refCount = 0;
+
+HelperAppLauncherDialogFactory () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (factory !is null) {
+        factory.dispose ();
+        factory = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+    
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+    HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog ();
+    helperAppLauncherDialog.AddRef ();
+    XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/InputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.InputStream;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIInputStream;
+import dwt.internal.mozilla.nsISupports;
+
+class InputStream {
+    XPCOMObject inputStream;
+    int refCount = 0;
+
+    byte[] buffer;
+    int index = 0;
+    
+InputStream (byte[] buffer) {
+    this.buffer = buffer;
+    index = 0;
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    inputStream = new XPCOMObject (new int[] {2, 0, 0, 0, 1, 3, 4, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Close ();}
+        public int /*long*/ method4 (int /*long*/[] args) {return Available (args[0]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return Read (args[0], (int)/*64*/args[1], args[2]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return ReadSegments (args[0], args[1], (int)/*64*/args[2], args[3]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return IsNonBlocking (args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (inputStream !is null) {
+        inputStream.dispose ();
+        inputStream = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return inputStream.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {inputStream.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIInputStream.NS_IINPUTSTREAM_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {inputStream.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }   
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+    
+/* nsIInputStream implementation */
+
+int Close () {
+    buffer = null;
+    index = 0;
+    return XPCOM.NS_OK;
+}
+
+int Available (int /*long*/ _retval) {
+    int available = buffer is null ? 0 : buffer.length - index;
+    XPCOM.memmove (_retval, new int[] {available}, 4);
+    return XPCOM.NS_OK;
+}
+
+int Read(int /*long*/ aBuf, int aCount, int /*long*/ _retval) {
+    int max = Math.min (aCount, buffer is null ? 0 : buffer.length - index);
+    if (max > 0) {
+        byte[] src = new byte[max];
+        System.arraycopy (buffer, index, src, 0, max);
+        XPCOM.memmove (aBuf, src, max);
+        index += max;
+    }
+    XPCOM.memmove(_retval, new int[] {max}, 4);
+    return XPCOM.NS_OK;
+}
+
+int ReadSegments (int /*long*/ aWriter, int /*long*/ aClosure, int aCount, int /*long*/ _retval) {
+    int max = Math.min (aCount, buffer is null ? 0 : buffer.length - index);
+    int cnt = max;
+    while (cnt > 0) {
+        int[] aWriteCount = new int[1];
+        int /*long*/ rc = XPCOM.Call (aWriter, getAddress (), aClosure, buffer, index, cnt, aWriteCount);
+        if (rc !is XPCOM.NS_OK) break;
+        index += aWriteCount[0];
+        cnt -= aWriteCount[0];
+    }
+    XPCOM.memmove (_retval, new int[] {max - cnt}, 4);
+    return XPCOM.NS_OK;
+}
+
+int IsNonBlocking (int /*long*/ _retval) {
+    /* blocking */
+    XPCOM.memmove (_retval, new int[] {0}, 4);
+    return XPCOM.NS_OK;
+}       
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/LocationAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.LocationAdapter;
+
+import dwt.browser.LocationListener;
+import dwt.browser.LocationEvent;
+import dwt.dwthelper.utils;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the {@link LocationListener} interface.
+ * <p>
+ * Classes that wish to deal with {@link LocationEvent}'s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ * 
+ * @since 3.0
+ */
+public abstract class LocationAdapter : LocationListener {
+
+    public void changing (LocationEvent event) {
+    }
+
+    public void changed (LocationEvent event) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/LocationEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.LocationEvent;
+
+import dwt.events.TypedEvent;
+import dwt.widgets.Widget;
+
+import dwt.dwthelper.string;
+
+/**
+ * A <code>LocationEvent</code> is sent by a {@link Browser} to
+ * {@link LocationListener}'s when the <code>Browser</code>
+ * navigates to a different URL. This notification typically 
+ * occurs when the application navigates to a new location with 
+ * {@link Browser#setUrl(String)} or when the user activates a
+ * hyperlink.
+ * 
+ * @since 3.0
+ */
+public class LocationEvent : TypedEvent {
+    /** current location */
+    public String location;
+
+    /**
+     * A flag indicating whether the location opens in the top frame
+     * or not.
+     */
+    public bool top;
+
+    /**
+     * A flag indicating whether the location loading should be allowed.
+     * Setting this field to <code>false</code> will cancel the operation.
+     */
+    public bool doit;
+
+    static final long serialVersionUID = 3906644198244299574L;
+
+    this (Widget w) {
+        super(w);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        String String = super.toString();
+        return String.substring(0, String.length() - 1) // remove trailing '}'
+        + " location=" + location + " top=" + top + " doit=" + doit + "}";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/LocationListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.LocationListener;
+
+import dwt.browser.LocationEvent;
+import dwt.internal.DWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link LocationEvent} notification when a {@link Browser}
+ * navigates to a different URL.
+ * 
+ * @see Browser#addLocationListener(LocationListener)
+ * @see Browser#removeLocationListener(LocationListener)
+ * 
+ * @since 3.0
+ */
+public interface LocationListener : DWTEventListener {
+
+    /**
+     * This method is called when the current location is about to be changed.
+     * <p>
+     *
+     * <p>The following fields in the <code>LocationEvent</code> apply:
+     * <ul>
+     * <li>(in) location the location to be loaded
+     * <li>(in) widget the <code>Browser</code> whose location is changing
+     * <li>(in/out) doit can be set to <code>false</code> to prevent the location
+     * from being loaded 
+     * </ul>
+     * 
+     * @param event the <code>LocationEvent</code> that specifies the location
+     * to be loaded by a <code>Browser</code>
+     * 
+     * @since 3.0
+     */
+    public void changing (LocationEvent event);
+
+    /**
+     * This method is called when the current location is changed.
+     * <p>
+     *
+     * <p>The following fields in the <code>LocationEvent</code> apply:
+     * <ul>
+     * <li>(in) location the current location
+     * <li>(in) top <code>true</code> if the location opens in the top frame or
+     * <code>false</code> otherwise
+     * <li>(in) widget the <code>Browser</code> whose location has changed
+     * </ul>
+     * 
+     * @param event the <code>LocationEvent</code> that specifies  the new
+     * location of a <code>Browser</code>
+     * 
+     * @since 3.0
+     */
+    public void changed (LocationEvent event);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/Mozilla.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,3254 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.Mozilla;
+
+import dwt.dwthelper.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Vector;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.graphics.Device;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.C;
+import dwt.internal.Compatibility;
+import dwt.internal.LONG;
+import dwt.internal.Library;
+import dwt.internal.mozilla.GREVersionRange;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMInit;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsEmbedString;
+import dwt.internal.mozilla.nsIAppShell;
+import dwt.internal.mozilla.nsIBaseWindow;
+import dwt.internal.mozilla.nsICategoryManager;
+import dwt.internal.mozilla.nsIComponentManager;
+import dwt.internal.mozilla.nsIComponentRegistrar;
+import dwt.internal.mozilla.nsIContextMenuListener;
+import dwt.internal.mozilla.nsICookie;
+import dwt.internal.mozilla.nsICookieManager;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIDOMEvent;
+import dwt.internal.mozilla.nsIDOMEventTarget;
+import dwt.internal.mozilla.nsIDOMKeyEvent;
+import dwt.internal.mozilla.nsIDOMMouseEvent;
+import dwt.internal.mozilla.nsIDOMSerializer;
+import dwt.internal.mozilla.nsIDOMSerializer_1_7;
+import dwt.internal.mozilla.nsIDOMWindow;
+import dwt.internal.mozilla.nsIDOMWindowCollection;
+import dwt.internal.mozilla.nsIDirectoryService;
+import dwt.internal.mozilla.nsIDocShell;
+import dwt.internal.mozilla.nsIDocShell_1_8;
+import dwt.internal.mozilla.nsIDocShell_1_9;
+import dwt.internal.mozilla.nsIEmbeddingSiteWindow;
+import dwt.internal.mozilla.nsIFile;
+import dwt.internal.mozilla.nsIIOService;
+import dwt.internal.mozilla.nsIInterfaceRequestor;
+import dwt.internal.mozilla.nsIJSContextStack;
+import dwt.internal.mozilla.nsILocalFile;
+import dwt.internal.mozilla.nsIObserverService;
+import dwt.internal.mozilla.nsIPrefBranch;
+import dwt.internal.mozilla.nsIPrefLocalizedString;
+import dwt.internal.mozilla.nsIPrefService;
+import dwt.internal.mozilla.nsIProperties;
+import dwt.internal.mozilla.nsIServiceManager;
+import dwt.internal.mozilla.nsISimpleEnumerator;
+import dwt.internal.mozilla.nsISupports;
+import dwt.internal.mozilla.nsISupportsWeakReference;
+import dwt.internal.mozilla.nsITooltipListener;
+import dwt.internal.mozilla.nsIURI;
+import dwt.internal.mozilla.nsIURIContentListener;
+import dwt.internal.mozilla.nsIWeakReference;
+import dwt.internal.mozilla.nsIWebBrowser;
+import dwt.internal.mozilla.nsIWebBrowserChrome;
+import dwt.internal.mozilla.nsIWebBrowserChromeFocus;
+import dwt.internal.mozilla.nsIWebBrowserFocus;
+import dwt.internal.mozilla.nsIWebNavigation;
+import dwt.internal.mozilla.nsIWebNavigationInfo;
+import dwt.internal.mozilla.nsIWebProgress;
+import dwt.internal.mozilla.nsIWebProgressListener;
+import dwt.internal.mozilla.nsIWindowWatcher;
+import dwt.layout.FillLayout;
+import dwt.widgets.Composite;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Label;
+import dwt.widgets.Listener;
+import dwt.widgets.Menu;
+import dwt.widgets.Shell;
+
+class Mozilla extends WebBrowser {
+    int /*long*/ embedHandle;
+    nsIWebBrowser webBrowser;
+    Object webBrowserObject;
+    MozillaDelegate delegate;
+
+    /* Interfaces for this Mozilla embedding notification */
+    XPCOMObject supports;
+    XPCOMObject weakReference;
+    XPCOMObject webProgressListener;
+    XPCOMObject webBrowserChrome;
+    XPCOMObject webBrowserChromeFocus;
+    XPCOMObject embeddingSiteWindow;
+    XPCOMObject interfaceRequestor;
+    XPCOMObject supportsWeakReference;
+    XPCOMObject contextMenuListener;    
+    XPCOMObject uriContentListener;
+    XPCOMObject tooltipListener;
+    XPCOMObject domEventListener;
+    int chromeFlags = nsIWebBrowserChrome.CHROME_DEFAULT;
+    int refCount, lastKeyCode, lastCharCode;
+    int /*long*/ request;
+    Point location, size;
+    bool visible, isChild, ignoreDispose, awaitingNavigate;
+    Shell tip = null;
+    Listener listener;
+    Vector unhookedDOMWindows = new Vector ();
+
+    static nsIAppShell AppShell;
+    static AppFileLocProvider LocationProvider;
+    static WindowCreator2 WindowCreator;
+    static int BrowserCount;
+    static bool Initialized, IsPre_1_8, PerformedVersionCheck, XPCOMWasGlued, XPCOMInitWasGlued;
+
+    /* XULRunner detect constants */
+    static final String GRERANGE_LOWER = "1.8.1.2"; //$NON-NLS-1$
+    static final String GRERANGE_LOWER_FALLBACK = "1.8"; //$NON-NLS-1$
+    static final bool LowerRangeInclusive = true;
+    static final String GRERANGE_UPPER = "1.9.*"; //$NON-NLS-1$
+    static final bool UpperRangeInclusive = true;
+
+    static final int MAX_PORT = 65535;
+    static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$
+    static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
+    static final String DISPOSE_LISTENER_HOOKED = "dwt.browser.Mozilla.disposeListenerHooked"; //$NON-NLS-1$
+    static final String PREFIX_JAVASCRIPT = "javascript:"; //$NON-NLS-1$
+    static final String PREFERENCE_CHARSET = "intl.charset.default"; //$NON-NLS-1$
+    static final String PREFERENCE_DISABLEOPENDURINGLOAD = "dom.disable_open_during_load"; //$NON-NLS-1$
+    static final String PREFERENCE_DISABLEWINDOWSTATUSCHANGE = "dom.disable_window_status_change"; //$NON-NLS-1$
+    static final String PREFERENCE_LANGUAGES = "intl.accept_languages"; //$NON-NLS-1$
+    static final String PREFERENCE_PROXYHOST_FTP = "network.proxy.ftp"; //$NON-NLS-1$
+    static final String PREFERENCE_PROXYPORT_FTP = "network.proxy.ftp_port"; //$NON-NLS-1$
+    static final String PREFERENCE_PROXYHOST_HTTP = "network.proxy.http"; //$NON-NLS-1$
+    static final String PREFERENCE_PROXYPORT_HTTP = "network.proxy.http_port"; //$NON-NLS-1$
+    static final String PREFERENCE_PROXYHOST_SSL = "network.proxy.ssl"; //$NON-NLS-1$
+    static final String PREFERENCE_PROXYPORT_SSL = "network.proxy.ssl_port"; //$NON-NLS-1$
+    static final String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$
+    static final String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$
+    static final String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$
+    static final String PROFILE_DIR = SEPARATOR_OS + "eclipse" + SEPARATOR_OS; //$NON-NLS-1$
+    static final String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$
+    static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$
+    static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$
+    static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$
+    static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$
+    static final String STARTUP = "startup"; //$NON-NLS-1$
+    static final String TOKENIZER_LOCALE = ","; //$NON-NLS-1$
+    static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$
+    static final String XULRUNNER_PATH = "dwt.browser.XULRunnerPath"; //$NON-NLS-1$
+
+    // TEMPORARY CODE
+    static final String GRE_INITIALIZED = "dwt.browser.XULRunnerInitialized"; //$NON-NLS-1$
+
+    static {
+        MozillaClearSessions = new Runnable () {
+            public void run () {
+                if (!Initialized) return;
+                int /*long*/[] result = new int /*long*/[1];
+                int rc = XPCOM.NS_GetServiceManager (result);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+                nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+                result[0] = 0;
+                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_COOKIEMANAGER_CONTRACTID, true);
+                rc = serviceManager.GetServiceByContractID (aContractID, nsICookieManager.NS_ICOOKIEMANAGER_IID, result);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+                serviceManager.Release ();
+
+                nsICookieManager manager = new nsICookieManager (result[0]);
+                result[0] = 0;
+                rc = manager.GetEnumerator (result);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                manager.Release ();
+
+                nsISimpleEnumerator enumerator = new nsISimpleEnumerator (result[0]);
+                int[] moreElements = new int[1]; /* PRBool */
+                rc = enumerator.HasMoreElements (moreElements);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                while (moreElements[0] !is 0) {
+                    result[0] = 0;
+                    rc = enumerator.GetNext (result);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+                    nsICookie cookie = new nsICookie (result[0]);
+                    long[] expires = new long[1];
+                    rc = cookie.GetExpires (expires);
+                    if (expires[0] is 0) {
+                        /* indicates a session cookie */
+                        int /*long*/ domain = XPCOM.nsEmbedCString_new ();
+                        int /*long*/ name = XPCOM.nsEmbedCString_new ();
+                        int /*long*/ path = XPCOM.nsEmbedCString_new ();
+                        cookie.GetHost (domain);
+                        cookie.GetName (name);
+                        cookie.GetPath (path);
+                        rc = manager.Remove (domain, name, path, 0);
+                        XPCOM.nsEmbedCString_delete (domain);
+                        XPCOM.nsEmbedCString_delete (name);
+                        XPCOM.nsEmbedCString_delete (path);
+                        if (rc !is XPCOM.NS_OK) error (rc);
+                    }
+                    cookie.Release ();
+                    rc = enumerator.HasMoreElements (moreElements);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+                }
+                enumerator.Release ();
+            }
+        };
+    }
+
+public void create (Composite parent, int style) {
+    delegate = new MozillaDelegate (browser);
+    Display display = parent.getDisplay ();
+
+    int /*long*/[] result = new int /*long*/[1];
+    if (!Initialized) {
+        bool initLoaded = false;
+        bool IsXULRunner = false;
+
+        String greInitialized = System.getProperty (GRE_INITIALIZED); 
+        if ("true".equals (greInitialized)) { //$NON-NLS-1$
+            /* 
+             * Another browser has already initialized xulrunner in this process,
+             * so just bind to it instead of trying to initialize a new one.
+             */
+            Initialized = true;
+        }
+
+        String mozillaPath = System.getProperty (XULRUNNER_PATH);
+        /*
+        * Browser clients that ship XULRunner in a plug-in must have an opportunity 
+        * to set the dwt.browser.XULRunnerPath system property to point
+        * at their XULRunner before the first Mozilla-based Browser is created.  To
+        * facilitate this, reflection is used to reference non-existent class
+        * dwt.browser.XULRunnerInitializer the first time a Mozilla-
+        * based Browser is created.   A client wishing to use this hook can do so
+        * by creating a fragment of dwt that implements this class and
+        * sets the system property in its static initializer.
+        */
+        if (mozillaPath is null) {
+            try {
+                Class.forName ("dwt.browser.XULRunnerInitializer"); //$NON-NLS-1$
+                mozillaPath = System.getProperty (XULRUNNER_PATH);
+            } catch (ClassNotFoundException e) {
+                /* no fragment is providing this class, which is the typical case */
+            }
+        }
+
+        if (mozillaPath is null) {
+            try {
+                String libName = delegate.getSWTInitLibraryName ();
+                Library.loadLibrary (libName);
+                initLoaded = true;
+            } catch (UnsatisfiedLinkError e) {
+                /* 
+                * If this library failed to load then do not attempt to detect a
+                * xulrunner to use.  The Browser may still be usable if MOZILLA_FIVE_HOME
+                * points at a GRE. 
+                */
+            }
+        } else {
+            mozillaPath += SEPARATOR_OS + delegate.getLibraryName ();
+            IsXULRunner = true;
+        }
+
+        if (initLoaded) {
+            /* attempt to discover a XULRunner to use as the GRE */
+            GREVersionRange range = new GREVersionRange ();
+            byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true);
+            int /*long*/ lower = C.malloc (bytes.length);
+            C.memmove (lower, bytes, bytes.length);
+            range.lower = lower;
+            range.lowerInclusive = LowerRangeInclusive;
+
+            bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true);
+            int /*long*/ upper = C.malloc (bytes.length);
+            C.memmove (upper, bytes, bytes.length);
+            range.upper = upper;
+            range.upperInclusive = UpperRangeInclusive;
+
+            int length = XPCOMInit.PATH_MAX;
+            int /*long*/ greBuffer = C.malloc (length);
+            int /*long*/ propertiesPtr = C.malloc (2 * C.PTR_SIZEOF);
+            int rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length);
+
+            /*
+             * A XULRunner was not found that supports wrapping of XPCOM handles as JavaXPCOM objects.
+             * Drop the lower version bound and try to detect an earlier XULRunner installation.
+             */
+            if (rc !is XPCOM.NS_OK) {
+                C.free (lower);
+                bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true);
+                lower = C.malloc (bytes.length);
+                C.memmove (lower, bytes, bytes.length);
+                range.lower = lower;
+                rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length);
+            }
+
+            C.free (lower);
+            C.free (upper);
+            C.free (propertiesPtr);
+            if (rc is XPCOM.NS_OK) {
+                /* indicates that a XULRunner was found */
+                length = C.strlen (greBuffer);
+                bytes = new byte[length];
+                C.memmove (bytes, greBuffer, length);
+                mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, bytes));
+                IsXULRunner = mozillaPath.length () > 0;
+
+                /*
+                 * Test whether the detected XULRunner can be used as the GRE before loading swt's
+                 * XULRunner library.  If it cannot be used then fall back to attempting to use
+                 * the GRE pointed to by MOZILLA_FIVE_HOME.
+                 * 
+                 * One case where this will fail is attempting to use a 64-bit xulrunner while swt
+                 * is running in 32-bit mode, or vice versa.
+                 */
+                if (IsXULRunner) {
+                    byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
+                    rc = XPCOMInit.XPCOMGlueStartup (path);
+                    if (rc !is XPCOM.NS_OK) {
+                        IsXULRunner = false;    /* failed */
+                        mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
+                        if (Device.DEBUG) System.out.println ("cannot use detected XULRunner: " + mozillaPath); //$NON-NLS-1$
+                    } else {
+                        XPCOMInitWasGlued = true;
+                    }
+                }
+            }
+            C.free (greBuffer);
+        }
+
+        if (IsXULRunner) {
+            if (Device.DEBUG) System.out.println ("XULRunner path: " + mozillaPath); //$NON-NLS-1$
+            try {
+                Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$
+            } catch (UnsatisfiedLinkError e) {
+                DWT.error (DWT.ERROR_NO_HANDLES, e);
+            }
+            byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
+            int rc = XPCOM.XPCOMGlueStartup (path);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            XPCOMWasGlued = true;
+
+            /*
+             * Remove the trailing xpcom lib name from mozillaPath because the
+             * Mozilla.initialize and NS_InitXPCOM2 invocations require a directory name only.
+             */ 
+            mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
+        } else {
+            if ((style & DWT.MOZILLA) !is 0) {
+                browser.dispose ();
+                String errorString = (mozillaPath !is null && mozillaPath.length () > 0) ?
+                    " [Failed to use detected XULRunner: " + mozillaPath + "]" :
+                    " [Could not detect registered XULRunner to use]";  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                DWT.error (DWT.ERROR_NO_HANDLES, null, errorString);
+            }
+
+            /* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */
+            int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_FIVE_HOME, true));
+            if (ptr !is 0) {
+                int length = C.strlen (ptr);
+                byte[] buffer = new byte[length];
+                C.memmove (buffer, ptr, length);
+                mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, buffer));
+            } else {
+                browser.dispose ();
+                DWT.error (DWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$
+            }
+            if (Device.DEBUG) System.out.println ("Mozilla path: " + mozillaPath); //$NON-NLS-1$
+
+            /*
+            * Note.  Embedding a Mozilla GTK1.2 causes a crash.  The workaround
+            * is to check the version of GTK used by Mozilla by looking for
+            * the libwidget_gtk.so library used by Mozilla GTK1.2. Mozilla GTK2
+            * uses the libwidget_gtk2.so library.   
+            */
+            if (Compatibility.fileExists (mozillaPath, "components/libwidget_gtk.so")) { //$NON-NLS-1$
+                browser.dispose ();
+                DWT.error (DWT.ERROR_NO_HANDLES, null, " [Mozilla GTK2 required (GTK1.2 detected)]"); //$NON-NLS-1$                         
+            }
+
+            try {
+                Library.loadLibrary ("swt-mozilla"); //$NON-NLS-1$
+            } catch (UnsatisfiedLinkError e) {
+                try {
+                    /* 
+                     * The initial loadLibrary attempt may have failed as a result of the user's
+                     * system not having libstdc++.so.6 installed, so try to load the alternate
+                     * swt mozilla library that depends on libswtc++.so.5 instead.
+                     */
+                    Library.loadLibrary ("swt-mozilla-gcc3"); //$NON-NLS-1$
+                } catch (UnsatisfiedLinkError ex) {
+                    browser.dispose ();
+                    /*
+                     * Print the error from the first failed attempt since at this point it's
+                     * known that the failure was not due to the libstdc++.so.6 dependency.
+                     */
+                    DWT.error (DWT.ERROR_NO_HANDLES, e, " [MOZILLA_FIVE_HOME='" + mozillaPath + "']"); //$NON-NLS-1$ //$NON-NLS-2$
+                }
+            }
+        }
+
+        if (!Initialized) {
+            int /*long*/[] retVal = new int /*long*/[1];
+            nsEmbedString pathString = new nsEmbedString (mozillaPath);
+            int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, retVal);
+            pathString.dispose ();
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            if (retVal[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_ERROR_NULL_POINTER);
+            }
+
+            LocationProvider = new AppFileLocProvider (mozillaPath);
+            LocationProvider.AddRef ();
+
+            nsIFile localFile = new nsILocalFile (retVal[0]);
+            rc = XPCOM.NS_InitXPCOM2 (0, localFile.getAddress(), LocationProvider.getAddress ());
+            localFile.Release ();
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                DWT.error (DWT.ERROR_NO_HANDLES, null, " [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding " + mozillaPath + " error " + rc + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            }
+            System.setProperty (GRE_INITIALIZED, "true"); //$NON-NLS-1$
+            if (IsXULRunner) {
+                System.setProperty (XULRUNNER_PATH, mozillaPath);
+            }
+        }
+
+        /* If JavaXPCOM is detected then attempt to initialize it with the XULRunner being used */
+        if (IsXULRunner) {
+            try {
+                Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$
+                Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$
+                Object mozilla = method.invoke (null, new Object[0]);
+                method = clazz.getMethod ("getComponentManager", new Class[0]); //$NON-NLS-1$
+                try {
+                    method.invoke (mozilla, new Object[0]);
+                } catch (InvocationTargetException e) {
+                    /* indicates that JavaXPCOM has not been initialized yet */
+                    Class fileClass = Class.forName ("java.io.File"); //$NON-NLS-1$
+                    method = clazz.getMethod ("initialize", new Class[] {fileClass}); //$NON-NLS-1$
+                    Constructor constructor = fileClass.getDeclaredConstructor (new Class[] {String.class});
+                    Object argument = constructor.newInstance (new Object[] {mozillaPath});
+                    method.invoke (mozilla, new Object[] {argument});
+                }
+            } catch (ClassNotFoundException e) {
+                /* JavaXPCOM is not on the classpath */
+            } catch (NoSuchMethodException e) {
+                /* the JavaXPCOM on the classpath does not implement initialize() */
+            } catch (IllegalArgumentException e) {
+            } catch (IllegalAccessException e) {
+            } catch (InvocationTargetException e) {
+            } catch (InstantiationException e) {
+            }
+        }
+
+        int rc = XPCOM.NS_GetComponentManager (result);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        if (result[0] is 0) {
+            browser.dispose ();
+            error (XPCOM.NS_NOINTERFACE);
+        }
+        
+        nsIComponentManager componentManager = new nsIComponentManager (result[0]);
+        result[0] = 0;
+        if (delegate.needsSpinup ()) {
+            /* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */
+            rc = componentManager.CreateInstance (XPCOM.NS_APPSHELL_CID, 0, nsIAppShell.NS_IAPPSHELL_IID, result);
+            if (rc !is XPCOM.NS_ERROR_NO_INTERFACE) {
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+                if (result[0] is 0) {
+                    browser.dispose ();
+                    error (XPCOM.NS_NOINTERFACE);
+                }
+    
+                AppShell = new nsIAppShell (result[0]);
+                rc = AppShell.Create (0, null);
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+                rc = AppShell.Spinup ();
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+            }
+            result[0] = 0;
+        }
+
+        WindowCreator = new WindowCreator2 ();
+        WindowCreator.AddRef ();
+        
+        rc = XPCOM.NS_GetServiceManager (result);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        if (result[0] is 0) {
+            browser.dispose ();
+            error (XPCOM.NS_NOINTERFACE);
+        }
+        
+        nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+        result[0] = 0;      
+        byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
+        rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        if (result[0] is 0) {
+            browser.dispose ();
+            error (XPCOM.NS_NOINTERFACE);       
+        }
+
+        nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
+        result[0] = 0;
+        rc = windowWatcher.SetWindowCreator (WindowCreator.getAddress());
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        windowWatcher.Release ();
+
+        /* compute the profile directory and set it on the AppFileLocProvider */
+        if (LocationProvider !is null) {
+            byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DIRECTORYSERVICE_CONTRACTID, true);
+            rc = serviceManager.GetServiceByContractID (buffer, nsIDirectoryService.NS_IDIRECTORYSERVICE_IID, result);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+
+            nsIDirectoryService directoryService = new nsIDirectoryService (result[0]);
+            result[0] = 0;
+            rc = directoryService.QueryInterface (nsIProperties.NS_IPROPERTIES_IID, result);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+            directoryService.Release ();
+
+            nsIProperties properties = new nsIProperties (result[0]);
+            result[0] = 0;
+            buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_APP_APPLICATION_REGISTRY_DIR, true);
+            rc = properties.Get (buffer, nsIFile.NS_IFILE_IID, result);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+            properties.Release ();
+
+            nsIFile profileDir = new nsIFile (result[0]);
+            result[0] = 0;
+            int /*long*/ path = XPCOM.nsEmbedCString_new ();
+            rc = profileDir.GetNativePath (path);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            int length = XPCOM.nsEmbedCString_Length (path);
+            int /*long*/ ptr = XPCOM.nsEmbedCString_get (path);
+            buffer = new byte [length];
+            XPCOM.memmove (buffer, ptr, length);
+            String profilePath = new String (MozillaDelegate.mbcsToWcs (null, buffer)) + PROFILE_DIR;
+            LocationProvider.setProfilePath (profilePath);
+            LocationProvider.isXULRunner = IsXULRunner;
+            XPCOM.nsEmbedCString_delete (path);
+            profileDir.Release ();
+
+            /* notify observers of a new profile directory being used */
+            buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true);
+            rc = serviceManager.GetServiceByContractID (buffer, nsIObserverService.NS_IOBSERVERSERVICE_IID, result);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+
+            nsIObserverService observerService = new nsIObserverService (result[0]);
+            result[0] = 0;
+            buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_DO_CHANGE, true);
+            length = STARTUP.length ();
+            char[] chars = new char [length + 1];
+            STARTUP.getChars (0, length, chars, 0);
+            rc = observerService.NotifyObservers (0, buffer, chars);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_AFTER_CHANGE, true);
+            rc = observerService.NotifyObservers (0, buffer, chars);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            observerService.Release ();
+        }
+
+        /*
+         * As a result of using a common profile the user cannot change their locale
+         * and charset.  The fix for this is to set mozilla's locale and charset
+         * preference values according to the user's current locale and charset.
+         */
+        aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true);
+        rc = serviceManager.GetServiceByContractID (aContractID, nsIPrefService.NS_IPREFSERVICE_IID, result);
+        serviceManager.Release ();
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        if (result[0] is 0) {
+            browser.dispose ();
+            error (XPCOM.NS_NOINTERFACE);
+        }
+
+        nsIPrefService prefService = new nsIPrefService (result[0]);
+        result[0] = 0;
+        byte[] buffer = new byte[1];
+        rc = prefService.GetBranch (buffer, result);    /* empty buffer denotes root preference level */
+        prefService.Release ();
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        if (result[0] is 0) {
+            browser.dispose ();
+            error (XPCOM.NS_NOINTERFACE);
+        }
+
+        nsIPrefBranch prefBranch = new nsIPrefBranch (result[0]);
+        result[0] = 0;
+
+        /* get Mozilla's current locale preference value */
+        String prefLocales = null;
+        nsIPrefLocalizedString localizedString = null;
+        buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_LANGUAGES, true);
+        rc = prefBranch.GetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+        /* 
+         * Feature of Debian.  For some reason attempting to query for the current locale
+         * preference fails on Debian.  The workaround for this is to assume a value of
+         * "en-us,en" since this is typically the default value when mozilla is used without
+         * a profile.
+         */
+        if (rc !is XPCOM.NS_OK) {
+            prefLocales = "en-us,en" + TOKENIZER_LOCALE;    //$NON-NLS-1$
+        } else {
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+            localizedString = new nsIPrefLocalizedString (result[0]);
+            result[0] = 0;
+            rc = localizedString.ToString (result);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+            int length = XPCOM.strlen_PRUnichar (result[0]);
+            char[] dest = new char[length];
+            XPCOM.memmove (dest, result[0], length * 2);
+            prefLocales = new String (dest) + TOKENIZER_LOCALE;
+        }
+        result[0] = 0;
+
+        /*
+         * construct the new locale preference value by prepending the
+         * user's current locale and language to the original value 
+         */
+        Locale locale = Locale.getDefault ();
+        String language = locale.getLanguage ();
+        String country = locale.getCountry ();
+        StringBuffer stringBuffer = new StringBuffer (language);
+        stringBuffer.append (SEPARATOR_LOCALE);
+        stringBuffer.append (country.toLowerCase ());
+        stringBuffer.append (TOKENIZER_LOCALE);
+        stringBuffer.append (language);
+        stringBuffer.append (TOKENIZER_LOCALE);
+        String newLocales = stringBuffer.toString ();
+
+        int start, end = -1;
+        do {
+            start = end + 1;
+            end = prefLocales.indexOf (TOKENIZER_LOCALE, start);
+            String token;
+            if (end is -1) {
+                token = prefLocales.substring (start);
+            } else {
+                token = prefLocales.substring (start, end);
+            }
+            if (token.length () > 0) {
+                token = (token + TOKENIZER_LOCALE).trim ();
+                /* ensure that duplicate locale values are not added */
+                if (newLocales.indexOf (token) is -1) {
+                    stringBuffer.append (token);
+                }
+            }
+        } while (end !is -1);
+        newLocales = stringBuffer.toString ();
+        if (!newLocales.equals (prefLocales)) {
+            /* write the new locale value */
+            newLocales = newLocales.substring (0, newLocales.length () - TOKENIZER_LOCALE.length ()); /* remove trailing tokenizer */
+            int length = newLocales.length ();
+            char[] charBuffer = new char[length + 1];
+            newLocales.getChars (0, length, charBuffer, 0);
+            if (localizedString is null) {
+                byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
+                rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+                if (result[0] is 0) {
+                    browser.dispose ();
+                    error (XPCOM.NS_NOINTERFACE);
+                }
+                localizedString = new nsIPrefLocalizedString (result[0]);
+                result[0] = 0;
+            }
+            localizedString.SetDataWithLength (length, charBuffer);
+            rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress());
+        }
+        if (localizedString !is null) {
+            localizedString.Release ();
+            localizedString = null;
+        }
+
+        /* get Mozilla's current charset preference value */
+        String prefCharset = null;
+        buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_CHARSET, true);
+        rc = prefBranch.GetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+        /* 
+         * Feature of Debian.  For some reason attempting to query for the current charset
+         * preference fails on Debian.  The workaround for this is to assume a value of
+         * "ISO-8859-1" since this is typically the default value when mozilla is used
+         * without a profile.
+         */
+        if (rc !is XPCOM.NS_OK) {
+            prefCharset = "ISO-8859-1"; //$NON_NLS-1$
+        } else {
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+            localizedString = new nsIPrefLocalizedString (result[0]);
+            result[0] = 0;
+            rc = localizedString.ToString (result);
+            if (rc !is XPCOM.NS_OK) {
+                browser.dispose ();
+                error (rc);
+            }
+            if (result[0] is 0) {
+                browser.dispose ();
+                error (XPCOM.NS_NOINTERFACE);
+            }
+            int length = XPCOM.strlen_PRUnichar (result[0]);
+            char[] dest = new char[length];
+            XPCOM.memmove (dest, result[0], length * 2);
+            prefCharset = new String (dest);
+        }
+        result[0] = 0;
+
+        String newCharset = System.getProperty ("file.encoding");   // $NON-NLS-1$
+        if (!newCharset.equals (prefCharset)) {
+            /* write the new charset value */
+            int length = newCharset.length ();
+            char[] charBuffer = new char[length + 1];
+            newCharset.getChars (0, length, charBuffer, 0);
+            if (localizedString is null) {
+                byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
+                rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+                if (result[0] is 0) {
+                    browser.dispose ();
+                    error (XPCOM.NS_NOINTERFACE);
+                }
+                localizedString = new nsIPrefLocalizedString (result[0]);
+                result[0] = 0;
+            }
+            localizedString.SetDataWithLength (length, charBuffer);
+            rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+        }
+        if (localizedString !is null) localizedString.Release ();
+
+        /*
+        * Check for proxy values set as documented java properties and update mozilla's
+        * preferences with these values if needed.
+        */
+        String proxyHost = System.getProperty (PROPERTY_PROXYHOST);
+        String proxyPortString = System.getProperty (PROPERTY_PROXYPORT);
+
+        int port = -1;
+        if (proxyPortString !is null) {
+            try {
+                int value = Integer.valueOf (proxyPortString).intValue ();
+                if (0 <= value && value <= MAX_PORT) port = value;
+            } catch (NumberFormatException e) {
+                /* do nothing, java property has non-integer value */
+            }
+        }
+
+        if (proxyHost !is null) {
+            byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
+            rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+            localizedString = new nsIPrefLocalizedString (result[0]);
+            result[0] = 0;
+            int length = proxyHost.length ();
+            char[] charBuffer = new char[length + 1];
+            proxyHost.getChars (0, length, charBuffer, 0);
+            rc = localizedString.SetDataWithLength (length, charBuffer);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_FTP, true);
+            rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+            if (rc !is XPCOM.NS_OK) error (rc);
+            buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_HTTP, true);
+            rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+            if (rc !is XPCOM.NS_OK) error (rc);
+            buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_SSL, true);
+            rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+            if (rc !is XPCOM.NS_OK) error (rc);
+            localizedString.Release ();
+        }
+
+        if (port !is -1) {
+            buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_FTP, true);
+            rc = prefBranch.SetIntPref (buffer, port);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_HTTP, true);
+            rc = prefBranch.SetIntPref (buffer, port);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_SSL, true);
+            rc = prefBranch.SetIntPref (buffer, port);
+            if (rc !is XPCOM.NS_OK) error (rc);
+        }
+
+        if (proxyHost !is null || port !is -1) {
+            buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYTYPE, true);
+            rc = prefBranch.SetIntPref (buffer, 1);
+            if (rc !is XPCOM.NS_OK) error (rc);
+        }
+
+        /*
+        * Ensure that windows that are shown during page loads are not blocked.  Firefox may
+        * try to block these by default since such windows are often unwelcome, but this
+        * assumption should not be made in the Browser's context.  Since the Browser client
+        * is responsible for creating the new Browser and Shell in an OpenWindowListener,
+        * they should decide whether the new window is unwelcome or not and act accordingly. 
+        */
+        buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEOPENDURINGLOAD, true);
+        rc = prefBranch.SetBoolPref (buffer, 0);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+
+        /* Ensure that the status text can be set through means like javascript */ 
+        buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEWINDOWSTATUSCHANGE, true);
+        rc = prefBranch.SetBoolPref (buffer, 0);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+
+        prefBranch.Release ();
+
+        PromptService2Factory factory = new PromptService2Factory ();
+        factory.AddRef ();
+
+        rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        if (result[0] is 0) {
+            browser.dispose ();
+            error (XPCOM.NS_NOINTERFACE);
+        }
+        
+        nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
+        result[0] = 0;
+        aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PROMPTSERVICE_CONTRACTID, true); 
+        byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Prompt Service", true); //$NON-NLS-1$
+        rc = componentRegistrar.RegisterFactory (XPCOM.NS_PROMPTSERVICE_CID, aClassName, aContractID, factory.getAddress ());
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        factory.Release ();
+        
+        HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
+        dialogFactory.AddRef ();
+        aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
+        aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$
+        rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress ());
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        dialogFactory.Release ();
+
+        /*
+        * This Download factory will be used if the GRE version is < 1.8.
+        * If the GRE version is 1.8.x then the Download factory that is registered later for
+        *   contract "Transfer" will be used.
+        * If the GRE version is >= 1.9 then no Download factory is registered because this
+        *   functionality is provided by the GRE.
+        */
+        DownloadFactory downloadFactory = new DownloadFactory ();
+        downloadFactory.AddRef ();
+        aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOWNLOAD_CONTRACTID, true);
+        aClassName = MozillaDelegate.wcsToMbcs (null, "Download", true); //$NON-NLS-1$
+        rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory.getAddress ());
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        downloadFactory.Release ();
+
+        FilePickerFactory pickerFactory = IsXULRunner ? new FilePickerFactory_1_8 () : new FilePickerFactory ();
+        pickerFactory.AddRef ();
+        aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_FILEPICKER_CONTRACTID, true);
+        aClassName = MozillaDelegate.wcsToMbcs (null, "FilePicker", true); //$NON-NLS-1$
+        rc = componentRegistrar.RegisterFactory (XPCOM.NS_FILEPICKER_CID, aClassName, aContractID, pickerFactory.getAddress ());
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc);
+        }
+        pickerFactory.Release ();
+
+        componentRegistrar.Release ();
+        componentManager.Release ();
+
+        Initialized = true;
+    }
+
+    if (display.getData (DISPOSE_LISTENER_HOOKED) is null) {
+        display.setData (DISPOSE_LISTENER_HOOKED, DISPOSE_LISTENER_HOOKED);
+        display.addListener (DWT.Dispose, new Listener () {
+            public void handleEvent (Event event) {
+                if (BrowserCount > 0) return; /* another display is still active */
+
+                int /*long*/[] result = new int /*long*/[1];
+                int rc = XPCOM.NS_GetServiceManager (result);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+                nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+                result[0] = 0;      
+                byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true);
+                rc = serviceManager.GetServiceByContractID (buffer, nsIObserverService.NS_IOBSERVERSERVICE_IID, result);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+                nsIObserverService observerService = new nsIObserverService (result[0]);
+                result[0] = 0;
+                buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_BEFORE_CHANGE, true);
+                int length = SHUTDOWN_PERSIST.length ();
+                char[] chars = new char [length + 1];
+                SHUTDOWN_PERSIST.getChars (0, length, chars, 0);
+                rc = observerService.NotifyObservers (0, buffer, chars);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                observerService.Release ();
+
+                if (LocationProvider !is null) {
+                    String prefsLocation = LocationProvider.profilePath + AppFileLocProvider.PREFERENCES_FILE;
+                    nsEmbedString pathString = new nsEmbedString (prefsLocation);
+                    rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+                    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+                    if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+                    pathString.dispose ();
+
+                    nsILocalFile localFile = new nsILocalFile (result [0]);
+                    result[0] = 0;
+                    rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); 
+                    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+                    if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+                    localFile.Release ();
+
+                    nsIFile prefFile = new nsIFile (result[0]);
+                    result[0] = 0;
+
+                    buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true);
+                    rc = serviceManager.GetServiceByContractID (buffer, nsIPrefService.NS_IPREFSERVICE_IID, result);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+                    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+                    nsIPrefService prefService = new nsIPrefService (result[0]);
+                    result[0] = 0;
+                    rc = prefService.SavePrefFile(prefFile.getAddress ());
+                    prefService.Release ();
+                    prefFile.Release ();
+                }
+                serviceManager.Release ();
+
+                if (XPCOMWasGlued) {
+                    XPCOM.XPCOMGlueShutdown ();
+                    XPCOMWasGlued = false;
+                }
+                if (XPCOMInitWasGlued) {
+                    XPCOMInit.XPCOMGlueShutdown ();
+                    XPCOMInitWasGlued = false;
+                }
+                Initialized = false;
+            }
+        });
+    }
+
+    BrowserCount++;
+    int rc = XPCOM.NS_GetComponentManager (result);
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (rc);
+    }
+    if (result[0] is 0) {
+        browser.dispose ();
+        error (XPCOM.NS_NOINTERFACE);
+    }
+    
+    nsIComponentManager componentManager = new nsIComponentManager (result[0]);
+    result[0] = 0;
+    nsID NS_IWEBBROWSER_CID = new nsID ("F1EAC761-87E9-11d3-AF80-00A024FFC08C"); //$NON-NLS-1$
+    rc = componentManager.CreateInstance (NS_IWEBBROWSER_CID, 0, nsIWebBrowser.NS_IWEBBROWSER_IID, result);
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (rc);
+    }
+    if (result[0] is 0) {
+        browser.dispose ();
+        error (XPCOM.NS_NOINTERFACE);   
+    }
+    
+    webBrowser = new nsIWebBrowser (result[0]);
+    result[0] = 0;
+
+    createCOMInterfaces ();
+    AddRef ();
+
+    rc = webBrowser.SetContainerWindow (webBrowserChrome.getAddress());
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (rc);
+    }
+            
+    rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (rc);
+    }
+    if (result[0] is 0) {
+        browser.dispose ();
+        error (XPCOM.NS_ERROR_NO_INTERFACE);
+    }
+    
+    nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+    result[0] = 0;
+    Rectangle rect = browser.getClientArea ();
+    if (rect.isEmpty ()) {
+        rect.width = 1;
+        rect.height = 1;
+    }
+
+    embedHandle = delegate.getHandle ();
+
+    rc = baseWindow.InitWindow (embedHandle, 0, 0, 0, rect.width, rect.height);
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (XPCOM.NS_ERROR_FAILURE);
+    }
+    rc = baseWindow.Create ();
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (XPCOM.NS_ERROR_FAILURE);
+    }
+    rc = baseWindow.SetVisibility (1);
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (XPCOM.NS_ERROR_FAILURE);
+    }
+    baseWindow.Release ();
+
+    if (!PerformedVersionCheck) {
+        PerformedVersionCheck = true;
+
+        /*
+        * Check for the availability of the pre-1.8 implementation of nsIDocShell
+        * to determine if the GRE's version is < 1.8.
+        */
+        rc = webBrowser.QueryInterface (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (XPCOM.NS_ERROR_FAILURE);
+        }
+        if (result[0] is 0) {
+            browser.dispose ();
+            error (XPCOM.NS_ERROR_NO_INTERFACE);
+        }
+        nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]);
+        result[0] = 0;
+
+        rc = interfaceRequestor.GetInterface (nsIDocShell.NS_IDOCSHELL_IID, result);
+        if (rc is XPCOM.NS_OK && result[0] !is 0) {
+            IsPre_1_8 = true;
+            new nsISupports (result[0]).Release ();
+        }
+        result[0] = 0;
+
+        /*
+        * A Download factory for contract "Transfer" must be registered iff the GRE's version is 1.8.x.
+        *   Check for the availability of the 1.8 implementation of nsIDocShell to determine if the
+        *   GRE's version is 1.8.x.
+        * If the GRE version is < 1.8 then the previously-registered Download factory for contract
+        *   "Download" will be used.
+        * If the GRE version is >= 1.9 then no Download factory is registered because this
+        *   functionality is provided by the GRE.
+        */
+        if (!IsPre_1_8) {
+            rc = interfaceRequestor.GetInterface (nsIDocShell_1_8.NS_IDOCSHELL_IID, result);
+            if (rc is XPCOM.NS_OK && result[0] !is 0) { /* 1.8 */
+                new nsISupports (result[0]).Release ();
+                result[0] = 0;
+                rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result);
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+                if (result[0] is 0) {
+                    browser.dispose ();
+                    error (XPCOM.NS_NOINTERFACE);
+                }
+
+                nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
+                DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 ();
+                downloadFactory_1_8.AddRef ();
+                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true);
+                byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$
+                rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory_1_8.getAddress ());
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+                downloadFactory_1_8.Release ();
+                componentRegistrar.Release ();
+            } else { /* >= 1.9 */
+                /*
+                 * Bug in XULRunner 1.9.  Mozilla no longer clears its background before initial content has
+                 * been set.  As a result embedders appear broken if they do not immediately navigate to a url.
+                 * The workaround for this is to navigate to about:blank immediately so that the background is
+                 * cleared, but do not fire any corresponding events or allow Browser API calls to reveal this.
+                 * Once the client does a proper navigate with either setUrl() or setText() then resume as
+                 * normal.  The Mozilla bug for this is https://bugzilla.mozilla.org/show_bug.cgi?id=415789.
+                 */
+                awaitingNavigate = true;
+                rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+                if (rc !is XPCOM.NS_OK) {
+                    browser.dispose ();
+                    error (rc);
+                }
+                if (result[0] is 0) {
+                    browser.dispose ();
+                    error (XPCOM.NS_ERROR_NO_INTERFACE);
+                }
+                nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+                char[] uri = new char[ABOUT_BLANK.length () + 1];
+                ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0);
+                rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
+                webNavigation.Release ();
+            }
+        }
+        result[0] = 0;
+        interfaceRequestor.Release ();
+    }
+    componentManager.Release ();
+
+    rc = webBrowser.AddWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (rc);
+    }
+
+    rc = webBrowser.SetParentURIContentListener (uriContentListener.getAddress ());
+    if (rc !is XPCOM.NS_OK) {
+        browser.dispose ();
+        error (rc);
+    }
+
+    delegate.init ();
+
+    listener = new Listener () {
+        public void handleEvent (Event event) {
+            switch (event.type) {
+                case DWT.Dispose: {
+                    /* make this handler run after other dispose listeners */
+                    if (ignoreDispose) {
+                        ignoreDispose = false;
+                        break;
+                    }
+                    ignoreDispose = true;
+                    browser.notifyListeners (event.type, event);
+                    event.type = DWT.NONE;
+                    onDispose (event.display);
+                    break;
+                }
+                case DWT.Resize: onResize (); break;
+                case DWT.FocusIn: Activate (); break;
+                case DWT.Activate: Activate (); break;
+                case DWT.Deactivate: {
+                    Display display = event.display;
+                    if (Mozilla.this.browser is display.getFocusControl ()) Deactivate ();
+                    break;
+                }
+                case DWT.Show: {
+                    /*
+                    * Feature in GTK Mozilla.  Mozilla does not show up when
+                    * its container (a GTK fixed handle) is made visible
+                    * after having been hidden.  The workaround is to reset
+                    * its size after the container has been made visible. 
+                    */
+                    Display display = event.display;
+                    display.asyncExec(new Runnable () {
+                        public void run() {
+                            if (browser.isDisposed ()) return;
+                            onResize ();
+                        }
+                    });
+                    break;
+                }
+            }
+        }
+    };  
+    int[] folderEvents = new int[] {
+        DWT.Dispose,
+        DWT.Resize,  
+        DWT.FocusIn,
+        DWT.Activate,
+        DWT.Deactivate,
+        DWT.Show,
+        DWT.KeyDown     // needed to make browser traversable
+    };
+    for (int i = 0; i < folderEvents.length; i++) {
+        browser.addListener (folderEvents[i], listener);
+    }
+}
+
+public bool back () {
+    if (awaitingNavigate) return false;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);          
+    rc = webNavigation.GoBack ();   
+    webNavigation.Release ();
+    return rc is XPCOM.NS_OK;
+}
+
+void createCOMInterfaces () {
+    // Create each of the interfaces that this object implements
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    weakReference = new XPCOMObject (new int[] {2, 0, 0, 2}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return QueryReferent (args[0], args[1]);}
+    };
+
+    webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+    };
+    
+    webBrowserChrome = new XPCOMObject (new int[] {2, 0, 0, 2, 1, 1, 1, 1, 0, 2, 0, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return SetStatus ((int)/*64*/args[0], args[1]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return GetWebBrowser (args[0]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return SetWebBrowser (args[0]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return GetChromeFlags (args[0]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return SetChromeFlags ((int)/*64*/args[0]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return DestroyBrowserWindow ();}
+        public int /*long*/ method9 (int /*long*/[] args) {return SizeBrowserTo ((int)/*64*/args[0], (int)/*64*/args[1]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return ShowAsModal ();}
+        public int /*long*/ method11 (int /*long*/[] args) {return IsWindowModal (args[0]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return ExitModalEventLoop ((int)/*64*/args[0]);}
+    };
+    
+    webBrowserChromeFocus = new XPCOMObject (new int[] {2, 0, 0, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return FocusNextElement ();}
+        public int /*long*/ method4 (int /*long*/[] args) {return FocusPrevElement ();}
+    };
+        
+    embeddingSiteWindow = new XPCOMObject (new int[] {2, 0, 0, 5, 5, 0, 1, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return SetDimensions ((int)/*64*/args[0], (int)/*64*/args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return GetDimensions ((int)/*64*/args[0], args[1], args[2], args[3], args[4]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return SetFocus ();}
+        public int /*long*/ method6 (int /*long*/[] args) {return GetVisibility (args[0]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return SetVisibility ((int)/*64*/args[0]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return GetTitle (args[0]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return SetTitle (args[0]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return GetSiteWindow (args[0]);}
+    };
+    
+    interfaceRequestor = new XPCOMObject (new int[] {2, 0, 0, 2} ){
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return GetInterface (args[0], args[1]);}
+    };
+        
+    supportsWeakReference = new XPCOMObject (new int[] {2, 0, 0, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return GetWeakReference (args[0]);}
+    };
+    
+    contextMenuListener = new XPCOMObject (new int[] {2, 0, 0, 3}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnShowContextMenu ((int)/*64*/args[0], args[1], args[2]);}
+    };
+    
+    uriContentListener = new XPCOMObject (new int[] {2, 0, 0, 2, 5, 3, 4, 1, 1, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnStartURIOpen (args[0], args[1]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return DoContent (args[0], (int)/*64*/args[1], args[2], args[3], args[4]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return IsPreferred (args[0], args[1], args[2]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return CanHandleContent (args[0], (int)/*64*/args[1], args[2], args[3]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return GetLoadCookie (args[0]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return SetLoadCookie (args[0]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return GetParentContentListener (args[0]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return SetParentContentListener (args[0]);}     
+    };
+    
+    tooltipListener = new XPCOMObject (new int[] {2, 0, 0, 3, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return OnShowTooltip ((int)/*64*/args[0], (int)/*64*/args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return OnHideTooltip ();}        
+    };
+
+    domEventListener = new XPCOMObject (new int[] {2, 0, 0, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return HandleEvent (args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (weakReference !is null) {
+        weakReference.dispose ();
+        weakReference = null;   
+    }
+    if (webProgressListener !is null) {
+        webProgressListener.dispose ();
+        webProgressListener = null;
+    }
+    if (webBrowserChrome !is null) {
+        webBrowserChrome.dispose ();
+        webBrowserChrome = null;
+    }
+    if (webBrowserChromeFocus !is null) {
+        webBrowserChromeFocus.dispose ();
+        webBrowserChromeFocus = null;
+    }
+    if (embeddingSiteWindow !is null) {
+        embeddingSiteWindow.dispose ();
+        embeddingSiteWindow = null;
+    }
+    if (interfaceRequestor !is null) {
+        interfaceRequestor.dispose ();
+        interfaceRequestor = null;
+    }       
+    if (supportsWeakReference !is null) {
+        supportsWeakReference.dispose ();
+        supportsWeakReference = null;
+    }   
+    if (contextMenuListener !is null) {
+        contextMenuListener.dispose ();
+        contextMenuListener = null;
+    }
+    if (uriContentListener !is null) {
+        uriContentListener.dispose ();
+        uriContentListener = null;
+    }
+    if (tooltipListener !is null) {
+        tooltipListener.dispose ();
+        tooltipListener = null;
+    }
+    if (domEventListener !is null) {
+        domEventListener.dispose ();
+        domEventListener = null;
+    }
+}
+
+public bool execute (String script) {
+    if (awaitingNavigate) return false;
+
+    String url = PREFIX_JAVASCRIPT + script + ";void(0);";  //$NON-NLS-1$
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    char[] arg = url.toCharArray (); 
+    char[] c = new char[arg.length+1];
+    System.arraycopy (arg, 0, c, 0, arg.length);
+    rc = webNavigation.LoadURI (c, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
+    webNavigation.Release ();
+    return rc is XPCOM.NS_OK;
+}
+
+static Browser findBrowser (int /*long*/ handle) {
+    return MozillaDelegate.findBrowser (handle);
+}
+
+public bool forward () {
+    if (awaitingNavigate) return false;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    rc = webNavigation.GoForward ();
+    webNavigation.Release ();
+
+    return rc is XPCOM.NS_OK;
+}
+
+public String getText () {
+    if (awaitingNavigate) return ""; //$NON-NLS-1$
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.GetContentDOMWindow (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+    nsIDOMWindow window = new nsIDOMWindow (result[0]);
+    result[0] = 0;
+    rc = window.GetDocument (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+    window.Release ();
+
+    int /*long*/ document = result[0];
+    result[0] = 0;
+    rc = XPCOM.NS_GetComponentManager (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+    nsIComponentManager componentManager = new nsIComponentManager (result[0]);
+    result[0] = 0;
+    byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOMSERIALIZER_CONTRACTID, true);
+    char[] chars = null;
+
+    rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer_1_7.NS_IDOMSERIALIZER_IID, result);
+    if (rc is XPCOM.NS_OK) {    /* mozilla >= 1.7 */
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+        nsIDOMSerializer_1_7 serializer = new nsIDOMSerializer_1_7 (result[0]);
+        result[0] = 0;
+        int /*long*/ string = XPCOM.nsEmbedString_new ();
+        rc = serializer.SerializeToString (document, string);
+        serializer.Release ();
+
+        int length = XPCOM.nsEmbedString_Length (string);
+        int /*long*/ buffer = XPCOM.nsEmbedString_get (string);
+        chars = new char[length];
+        XPCOM.memmove (chars, buffer, length * 2);
+        XPCOM.nsEmbedString_delete (string);
+    } else {    /* mozilla < 1.7 */
+        rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer.NS_IDOMSERIALIZER_IID, result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+        nsIDOMSerializer serializer = new nsIDOMSerializer (result[0]);
+        result[0] = 0;
+        rc = serializer.SerializeToString (document, result);
+        serializer.Release ();
+
+        int length = XPCOM.strlen_PRUnichar (result[0]);
+        chars = new char[length];
+        XPCOM.memmove (chars, result[0], length * 2);
+    }
+
+    componentManager.Release ();
+    new nsISupports (document).Release ();
+    return new String (chars);
+}
+
+public String getUrl () {
+    if (awaitingNavigate) return ""; //$NON-NLS-1$
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    int /*long*/[] aCurrentURI = new int /*long*/[1];
+    rc = webNavigation.GetCurrentURI (aCurrentURI);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    webNavigation.Release ();
+
+    byte[] dest = null;
+    if (aCurrentURI[0] !is 0) {
+        nsIURI uri = new nsIURI (aCurrentURI[0]);
+        int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+        rc = uri.GetSpec (aSpec);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        int length = XPCOM.nsEmbedCString_Length (aSpec);
+        int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+        dest = new byte[length];
+        XPCOM.memmove (dest, buffer, length);
+        XPCOM.nsEmbedCString_delete (aSpec);
+        uri.Release ();
+    }
+    if (dest is null) return ""; //$NON-NLS-1$
+
+    String location = new String (dest);
+    /*
+     * If the URI indicates that the page is being rendered from memory
+     * (via setText()) then set it to about:blank to be consistent with IE.
+     */
+    if (location.equals (URI_FROMMEMORY)) location = ABOUT_BLANK;
+    return location;
+}
+
+public Object getWebBrowser () {
+    if ((browser.getStyle () & DWT.MOZILLA) is 0) return null;
+    if (webBrowserObject !is null) return webBrowserObject;
+
+    try {
+        Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$
+        Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$
+        Object mozilla = method.invoke (null, new Object[0]);
+        method = clazz.getMethod ("wrapXPCOMObject", new Class[] {Long.TYPE, String.class}); //$NON-NLS-1$
+        webBrowserObject = method.invoke (mozilla, new Object[] {new Long (webBrowser.getAddress ()), nsIWebBrowser.NS_IWEBBROWSER_IID_STR});
+        /*
+         * The following AddRef() is needed to offset the automatic Release() that
+         * will be performed by JavaXPCOM when webBrowserObject is finalized.
+         */
+        webBrowser.AddRef ();
+        return webBrowserObject;
+    } catch (ClassNotFoundException e) {
+    } catch (NoSuchMethodException e) {
+    } catch (IllegalArgumentException e) {
+    } catch (IllegalAccessException e) {
+    } catch (InvocationTargetException e) {
+    }
+    return null;
+}
+
+public bool isBackEnabled () {
+    if (awaitingNavigate) return false;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    int[] aCanGoBack = new int[1]; /* PRBool */
+    rc = webNavigation.GetCanGoBack (aCanGoBack);   
+    webNavigation.Release ();
+    return aCanGoBack[0] !is 0;
+}
+
+public bool isForwardEnabled () {
+    if (awaitingNavigate) return false;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    int[] aCanGoForward = new int[1]; /* PRBool */
+    rc = webNavigation.GetCanGoForward (aCanGoForward);
+    webNavigation.Release ();
+    return aCanGoForward[0] !is 0;
+}
+
+static String error (int code) {
+    throw new DWTError ("XPCOM error " + code); //$NON-NLS-1$
+}
+
+void onDispose (Display display) {
+    int rc = webBrowser.RemoveWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
+    if (rc !is XPCOM.NS_OK) error (rc);
+
+    rc = webBrowser.SetParentURIContentListener (0);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    
+    unhookDOMListeners ();
+    if (listener !is null) {
+        int[] folderEvents = new int[] {
+            DWT.Dispose,
+            DWT.Resize,  
+            DWT.FocusIn,
+            DWT.Activate,
+            DWT.Deactivate,
+            DWT.Show,
+            DWT.KeyDown,
+        };
+        for (int i = 0; i < folderEvents.length; i++) {
+            browser.removeListener (folderEvents[i], listener);
+        }
+        listener = null;
+    }
+
+    int /*long*/[] result = new int /*long*/[1];
+    rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+    nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+    rc = baseWindow.Destroy ();
+    if (rc !is XPCOM.NS_OK) error (rc);
+    baseWindow.Release ();
+
+    Release ();
+    webBrowser.Release ();
+    webBrowser = null;
+    webBrowserObject = null;
+
+    if (tip !is null && !tip.isDisposed ()) tip.dispose ();
+    tip = null;
+    location = size = null;
+
+    Enumeration elements = unhookedDOMWindows.elements ();
+    while (elements.hasMoreElements ()) {
+        LONG ptrObject = (LONG)elements.nextElement ();
+        new nsISupports (ptrObject.value).Release ();
+    }
+    unhookedDOMWindows = null;
+
+    delegate.onDispose (embedHandle);
+    delegate = null;
+
+    embedHandle = 0;
+    BrowserCount--;
+}
+
+void Activate () {
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus (result[0]);
+    rc = webBrowserFocus.Activate ();
+    if (rc !is XPCOM.NS_OK) error (rc);
+    webBrowserFocus.Release ();
+}
+    
+void Deactivate () {
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus (result[0]);
+    rc = webBrowserFocus.Deactivate ();
+    if (rc !is XPCOM.NS_OK) error (rc);
+    webBrowserFocus.Release ();
+}
+
+void onResize () {
+    Rectangle rect = browser.getClientArea ();
+    int width = Math.max (1, rect.width);
+    int height = Math.max (1, rect.height);
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+    delegate.setSize (embedHandle, width, height);
+    nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+    rc = baseWindow.SetPositionAndSize (0, 0, width, height, 1);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    baseWindow.Release ();
+}
+
+public void refresh () {
+    if (awaitingNavigate) return;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error(rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);          
+    rc = webNavigation.Reload (nsIWebNavigation.LOAD_FLAGS_NONE);
+    webNavigation.Release ();
+    if (rc is XPCOM.NS_OK) return;
+    /*
+    * Feature in Mozilla.  Reload returns an error code NS_ERROR_INVALID_POINTER
+    * when it is called immediately after a request to load a new document using
+    * LoadURI.  The workaround is to ignore this error code.
+    *
+    * Feature in Mozilla.  Attempting to reload a file that no longer exists
+    * returns an error code of NS_ERROR_FILE_NOT_FOUND.  This is equivalent to
+    * attempting to load a non-existent local url, which is not a Browser error,
+    * so this error code should be ignored. 
+    */
+    if (rc !is XPCOM.NS_ERROR_INVALID_POINTER && rc !is XPCOM.NS_ERROR_FILE_NOT_FOUND) error (rc);
+}
+
+public bool setText (String html) {
+    /*
+    *  Feature in Mozilla.  The focus memory of Mozilla must be 
+    *  properly managed through the nsIWebBrowserFocus interface.
+    *  In particular, nsIWebBrowserFocus.deactivate must be called
+    *  when the focus moves from the browser (or one of its children
+    *  managed by Mozilla to another widget.  We currently do not
+    *  get notified when a widget takes focus away from the Browser.
+    *  As a result, deactivate is not properly called. This causes
+    *  Mozilla to retake focus the next time a document is loaded.
+    *  This breaks the case where the HTML loaded in the Browser 
+    *  varies while the user enters characters in a text widget. The text
+    *  widget loses focus every time new content is loaded.
+    *  The current workaround is to call deactivate everytime if 
+    *  the browser currently does not have focus. A better workaround
+    *  would be to have a way to call deactivate when the Browser
+    *  or one of its children loses focus.
+    */
+    if (browser !is browser.getDisplay ().getFocusControl ()) Deactivate ();
+    
+    /* convert the String containing HTML to an array of bytes with UTF-8 data */
+    byte[] data = null;
+    try {
+        data = html.getBytes ("UTF-8"); //$NON-NLS-1$
+    } catch (UnsupportedEncodingException e) {
+        return false;
+    }
+
+    awaitingNavigate = false;
+
+    byte[] contentTypeBuffer = MozillaDelegate.wcsToMbcs (null, "text/html", true); // $NON-NLS-1$
+    int /*long*/ aContentType = XPCOM.nsEmbedCString_new (contentTypeBuffer, contentTypeBuffer.length);
+    byte[] contentCharsetBuffer = MozillaDelegate.wcsToMbcs (null, "UTF-8", true);  //$NON-NLS-1$
+    int /*long*/ aContentCharset = XPCOM.nsEmbedCString_new (contentCharsetBuffer, contentCharsetBuffer.length);
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = XPCOM.NS_GetServiceManager (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+    nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+    result[0] = 0;
+    rc = serviceManager.GetService (XPCOM.NS_IOSERVICE_CID, nsIIOService.NS_IIOSERVICE_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+    serviceManager.Release ();
+
+    nsIIOService ioService = new nsIIOService (result[0]);
+    result[0] = 0;
+    /*
+    * Note.  Mozilla ignores LINK tags used to load CSS stylesheets
+    * when the URI protocol for the nsInputStreamChannel
+    * is about:blank.  The fix is to specify the file protocol.
+    */
+    byte[] aString = MozillaDelegate.wcsToMbcs (null, URI_FROMMEMORY, false);
+    int /*long*/ aSpec = XPCOM.nsEmbedCString_new (aString, aString.length);
+    rc = ioService.NewURI (aSpec, null, 0, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+    XPCOM.nsEmbedCString_delete (aSpec);
+    ioService.Release ();
+
+    nsIURI uri = new nsIURI (result[0]);
+    result[0] = 0;
+
+    rc = webBrowser.QueryInterface (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]);
+    result[0] = 0;
+
+    /*
+    * Feature in Mozilla. LoadStream invokes the nsIInputStream argument
+    * through a different thread.  The callback mechanism must attach 
+    * a non java thread to the JVM otherwise the nsIInputStream Read and
+    * Close methods never get called.
+    */
+    InputStream inputStream = new InputStream (data);
+    inputStream.AddRef ();
+
+    rc = interfaceRequestor.GetInterface (nsIDocShell_1_9.NS_IDOCSHELL_IID, result);
+    if (rc is XPCOM.NS_OK) {
+        if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+        nsIDocShell_1_9 docShell = new nsIDocShell_1_9 (result[0]);
+        rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType,  aContentCharset, 0);
+        docShell.Release ();
+    } else {
+        result[0] = 0;
+        rc = interfaceRequestor.GetInterface (nsIDocShell_1_8.NS_IDOCSHELL_IID, result);
+        if (rc is XPCOM.NS_OK) {    
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+            nsIDocShell_1_8 docShell = new nsIDocShell_1_8 (result[0]);
+            rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType,  aContentCharset, 0);
+            docShell.Release ();
+        } else {
+            result[0] = 0;
+            rc = interfaceRequestor.GetInterface (nsIDocShell.NS_IDOCSHELL_IID, result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+            nsIDocShell docShell = new nsIDocShell (result[0]);
+            rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType,  aContentCharset, 0);
+            docShell.Release ();
+        }
+    }
+    if (rc !is XPCOM.NS_OK) error (rc);
+    result[0] = 0;
+
+    inputStream.Release ();
+    interfaceRequestor.Release ();
+    uri.Release ();
+    XPCOM.nsEmbedCString_delete (aContentCharset);
+    XPCOM.nsEmbedCString_delete (aContentType);
+    return true;
+}
+
+public bool setUrl (String url) {
+    awaitingNavigate = false;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    char[] uri = new char[url.length () + 1];
+    url.getChars (0, url.length (), uri, 0);
+    rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
+    webNavigation.Release ();
+    return rc is XPCOM.NS_OK;
+}
+
+public void stop () {
+    if (awaitingNavigate) return;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);      
+    rc = webNavigation.Stop (nsIWebNavigation.STOP_ALL);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    webNavigation.Release ();
+}
+
+void hookDOMListeners (nsIDOMEventTarget target, bool isTop) {
+    nsEmbedString string = new nsEmbedString (XPCOM.DOMEVENT_FOCUS);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_UNLOAD);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDOWN);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEUP);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEMOVE);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEWHEEL);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDRAG);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+
+    /*
+    * Only hook mouseover and mouseout if the target is a top-level frame, so that mouse moves
+    * between frames will not generate events.
+    */
+    if (isTop && delegate.hookEnterExit ()) {
+        string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOVER);
+        target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+        string.dispose ();
+        string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOUT);
+        target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+        string.dispose ();
+    }
+
+    string = new nsEmbedString (XPCOM.DOMEVENT_KEYDOWN);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_KEYPRESS);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_KEYUP);
+    target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+}
+
+void unhookDOMListeners () {
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.GetContentDOMWindow (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+    nsIDOMWindow window = new nsIDOMWindow (result[0]);
+    result[0] = 0;
+    rc = window.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+    nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+    result[0] = 0;
+    unhookDOMListeners (target);
+    target.Release ();
+
+    /* Listeners must be unhooked in pages contained in frames */
+    rc = window.GetFrames (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    nsIDOMWindowCollection frames = new nsIDOMWindowCollection (result[0]);
+    result[0] = 0;
+    int[] frameCount = new int[1];
+    rc = frames.GetLength (frameCount); /* PRUint32 */
+    if (rc !is XPCOM.NS_OK) error (rc);
+    int count = frameCount[0];
+
+    if (count > 0) {
+        for (int i = 0; i < count; i++) {
+            rc = frames.Item (i, result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+            nsIDOMWindow frame = new nsIDOMWindow (result[0]);
+            result[0] = 0;
+            rc = frame.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+            target = new nsIDOMEventTarget (result[0]);
+            result[0] = 0;
+            unhookDOMListeners (target);
+            target.Release ();
+            frame.Release ();
+        }
+    }
+    frames.Release ();
+    window.Release ();
+}
+
+void unhookDOMListeners (nsIDOMEventTarget target) {
+    nsEmbedString string = new nsEmbedString (XPCOM.DOMEVENT_FOCUS);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_UNLOAD);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDOWN);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEUP);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEMOVE);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEWHEEL);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDRAG);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOVER);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOUT);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_KEYDOWN);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_KEYPRESS);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+    string = new nsEmbedString (XPCOM.DOMEVENT_KEYUP);
+    target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+    string.dispose ();
+}
+
+/* nsISupports */
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWeakReference.NS_IWEAKREFERENCE_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWebBrowserChrome.NS_IWEBBROWSERCHROME_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChrome.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWebBrowserChromeFocus.NS_IWEBBROWSERCHROMEFOCUS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChromeFocus.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {embeddingSiteWindow.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {interfaceRequestor.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsISupportsWeakReference.NS_ISUPPORTSWEAKREFERENCE_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supportsWeakReference.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIContextMenuListener.NS_ICONTEXTMENULISTENER_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {contextMenuListener.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIURIContentListener.NS_IURICONTENTLISTENER_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {uriContentListener.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsITooltipListener.NS_ITOOLTIPLISTENER_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {tooltipListener.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+/* nsIWeakReference */  
+    
+int QueryReferent (int /*long*/ riid, int /*long*/ ppvObject) {
+    return QueryInterface (riid, ppvObject);
+}
+
+/* nsIInterfaceRequestor */
+
+int GetInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    if (guid.Equals (nsIDOMWindow.NS_IDOMWINDOW_IID)) {
+        int /*long*/[] aContentDOMWindow = new int /*long*/[1];
+        int rc = webBrowser.GetContentDOMWindow (aContentDOMWindow);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (aContentDOMWindow[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+        XPCOM.memmove (ppvObject, aContentDOMWindow, C.PTR_SIZEOF);
+        return rc;
+    }
+    return QueryInterface (riid, ppvObject);
+}
+
+int GetWeakReference (int /*long*/ ppvObject) {
+    XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF);
+    AddRef ();
+    return XPCOM.NS_OK;
+}
+
+/* nsIWebProgressListener */
+
+int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) {
+    if ((aStateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) is 0) return XPCOM.NS_OK;
+    if ((aStateFlags & nsIWebProgressListener.STATE_START) !is 0) {
+        if (request is 0) request = aRequest;
+
+        if (!awaitingNavigate) {
+            /*
+             * Add the page's nsIDOMWindow to the collection of windows that will
+             * have DOM listeners added to them later on in the page loading
+             * process.  These listeners cannot be added yet because the
+             * nsIDOMWindow is not ready to take them at this stage.
+             */
+            int /*long*/[] result = new int /*long*/[1];
+            nsIWebProgress progress = new nsIWebProgress (aWebProgress);
+            int rc = progress.GetDOMWindow (result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+            unhookedDOMWindows.addElement (new LONG (result[0]));
+        }
+    } else if ((aStateFlags & nsIWebProgressListener.STATE_REDIRECTING) !is 0) {
+        if (request is aRequest) request = 0;
+    } else if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) {
+        /*
+        * If this page's nsIDOMWindow handle is still in unhookedDOMWindows then
+        * add its DOM listeners now.  It's possible for this to happen since
+        * there is no guarantee that a STATE_TRANSFERRING state change will be
+        * received for every window in a page, which is when these listeners
+        * are typically added.
+        */
+        int /*long*/[] result = new int /*long*/[1];
+        nsIWebProgress progress = new nsIWebProgress (aWebProgress);
+        int rc = progress.GetDOMWindow (result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+        nsIDOMWindow domWindow = new nsIDOMWindow (result[0]);
+
+        LONG ptrObject = new LONG (result[0]);
+        result[0] = 0;
+        int index = unhookedDOMWindows.indexOf (ptrObject);
+        if (index !is -1) {
+            rc = webBrowser.GetContentDOMWindow (result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+            bool isTop = result[0] is domWindow.getAddress ();
+            new nsISupports (result[0]).Release ();
+            result[0] = 0;
+
+            rc = domWindow.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+            nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+            result[0] = 0;
+            hookDOMListeners (target, isTop);
+            target.Release ();
+
+            /*
+            * Remove and unreference the nsIDOMWindow from the collection of windows
+            * that are waiting to have DOM listeners hooked on them. 
+            */
+            unhookedDOMWindows.remove (ptrObject);
+            new nsISupports (ptrObject.value).Release ();
+        }
+        domWindow.Release ();
+
+        /*
+        * Feature in Mozilla.  When a request is redirected (STATE_REDIRECTING),
+        * it never reaches the state STATE_STOP and it is replaced with a new request.
+        * The new request is received when it is in the state STATE_STOP.
+        * To handle this case,  the variable request is set to 0 when the corresponding
+        * request is redirected. The following request received with the state STATE_STOP
+        * - the new request resulting from the redirection - is used to send
+        * the ProgressListener.completed event.
+        */
+        if (request is aRequest || request is 0) {
+            request = 0;
+            if (!awaitingNavigate) {
+                StatusTextEvent event = new StatusTextEvent (browser);
+                event.display = browser.getDisplay ();
+                event.widget = browser;
+                event.text = ""; //$NON-NLS-1$
+                for (int i = 0; i < statusTextListeners.length; i++) {
+                    statusTextListeners[i].changed (event);
+                }
+                ProgressEvent event2 = new ProgressEvent (browser);
+                event2.display = browser.getDisplay ();
+                event2.widget = browser;
+                for (int i = 0; i < progressListeners.length; i++) {
+                    progressListeners[i].completed (event2);
+                }
+            }
+        }
+    } else if ((aStateFlags & nsIWebProgressListener.STATE_TRANSFERRING) !is 0) {
+        /*
+        * Hook DOM listeners to the page's nsIDOMWindow here because this is
+        * the earliest opportunity to do so.    
+        */
+        int /*long*/[] result = new int /*long*/[1];
+        nsIWebProgress progress = new nsIWebProgress (aWebProgress);
+        int rc = progress.GetDOMWindow (result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+        nsIDOMWindow domWindow = new nsIDOMWindow (result[0]);
+
+        LONG ptrObject = new LONG (result[0]);
+        result[0] = 0;
+        int index = unhookedDOMWindows.indexOf (ptrObject);
+        if (index !is -1) {
+            rc = webBrowser.GetContentDOMWindow (result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+            bool isTop = result[0] is domWindow.getAddress ();
+            new nsISupports (result[0]).Release ();
+            result[0] = 0;
+
+            rc = domWindow.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+            nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+            result[0] = 0;
+            hookDOMListeners (target, isTop);
+            target.Release ();
+
+            /*
+            * Remove and unreference the nsIDOMWindow from the collection of windows
+            * that are waiting to have DOM listeners hooked on them. 
+            */
+            unhookedDOMWindows.remove (ptrObject);
+            new nsISupports (ptrObject.value).Release ();
+        }
+        domWindow.Release ();
+    }
+    return XPCOM.NS_OK;
+}
+
+int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) {
+    if (awaitingNavigate || progressListeners.length is 0) return XPCOM.NS_OK;
+    ProgressEvent event = new ProgressEvent (browser);
+    event.display = browser.getDisplay ();
+    event.widget = browser;
+    event.current = aCurTotalProgress;
+    event.total = aMaxTotalProgress;
+    for (int i = 0; i < progressListeners.length; i++) {
+        progressListeners[i].changed (event);
+    }
+    return XPCOM.NS_OK;
+}
+
+int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) {
+    /*
+    * Feature in Mozilla.  When a page is loaded via setText before a previous
+    * setText page load has completed, the expected OnStateChange STATE_STOP for the
+    * original setText never arrives because it gets replaced by the OnStateChange
+    * STATE_STOP for the new request.  This results in the request field never being
+    * cleared because the original request's OnStateChange STATE_STOP is still expected
+    * (but never arrives).  To handle this case, the request field is updated to the new
+    * overriding request since its OnStateChange STATE_STOP will be received next.
+    */
+    if (request !is 0 && request !is aRequest) request = aRequest;
+
+    if (awaitingNavigate || locationListeners.length is 0) return XPCOM.NS_OK;
+
+    nsIWebProgress webProgress = new nsIWebProgress (aWebProgress);
+    int /*long*/[] aDOMWindow = new int /*long*/[1];
+    int rc = webProgress.GetDOMWindow (aDOMWindow);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (aDOMWindow[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIDOMWindow domWindow = new nsIDOMWindow (aDOMWindow[0]);
+    int /*long*/[] aTop = new int /*long*/[1];
+    rc = domWindow.GetTop (aTop);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (aTop[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    domWindow.Release ();
+    
+    nsIDOMWindow topWindow = new nsIDOMWindow (aTop[0]);
+    topWindow.Release ();
+    
+    nsIURI location = new nsIURI (aLocation);
+    int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+    location.GetSpec (aSpec);
+    int length = XPCOM.nsEmbedCString_Length (aSpec);
+    int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+    byte[] dest = new byte[length];
+    XPCOM.memmove (dest, buffer, length);
+    XPCOM.nsEmbedCString_delete (aSpec);
+    String url = new String (dest);
+
+    /*
+     * As of Mozilla 1.8, the first time that a page is displayed, regardless of
+     * whether it's via Browser.setURL() or Browser.setText(), the GRE navigates
+     * to about:blank and fires the corresponding navigation events.  Do not send
+     * this event on to the user since it is not expected.
+     */
+    if (!IsPre_1_8 && aRequest is 0 && url.startsWith (ABOUT_BLANK)) return XPCOM.NS_OK;
+
+    LocationEvent event = new LocationEvent (browser);
+    event.display = browser.getDisplay ();
+    event.widget = browser;
+    event.location = url;
+    /*
+     * If the URI indicates that the page is being rendered from memory
+     * (via setText()) then set it to about:blank to be consistent with IE.
+     */
+    if (event.location.equals (URI_FROMMEMORY)) event.location = ABOUT_BLANK;
+    event.top = aTop[0] is aDOMWindow[0];
+    for (int i = 0; i < locationListeners.length; i++) {
+        locationListeners[i].changed (event);
+    }
+    return XPCOM.NS_OK;
+}
+
+int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) {
+    if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK;
+    StatusTextEvent event = new StatusTextEvent (browser);
+    event.display = browser.getDisplay ();
+    event.widget = browser;
+    int length = XPCOM.strlen_PRUnichar (aMessage);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, aMessage, length * 2);
+    event.text = new String (dest);
+    for (int i = 0; i < statusTextListeners.length; i++) {
+        statusTextListeners[i].changed (event);
+    }
+    return XPCOM.NS_OK;
+}       
+
+int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) {
+    return XPCOM.NS_OK;
+}
+
+/* nsIWebBrowserChrome */
+
+int SetStatus (int statusType, int /*long*/ status) {
+    if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK;
+    StatusTextEvent event = new StatusTextEvent (browser);
+    event.display = browser.getDisplay ();
+    event.widget = browser;
+    int length = XPCOM.strlen_PRUnichar (status);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, status, length * 2);
+    String string = new String (dest);
+    event.text = string;
+    for (int i = 0; i < statusTextListeners.length; i++) {
+        statusTextListeners[i].changed (event);
+    }
+    return XPCOM.NS_OK;
+}
+
+int GetWebBrowser (int /*long*/ aWebBrowser) {
+    int /*long*/[] ret = new int /*long*/[1];   
+    if (webBrowser !is null) {
+        webBrowser.AddRef ();
+        ret[0] = webBrowser.getAddress ();  
+    }
+    XPCOM.memmove (aWebBrowser, ret, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int SetWebBrowser (int /*long*/ aWebBrowser) {
+    if (webBrowser !is null) webBrowser.Release ();
+    webBrowser = aWebBrowser !is 0 ? new nsIWebBrowser (aWebBrowser) : null;                 
+    return XPCOM.NS_OK;
+}
+   
+int GetChromeFlags (int /*long*/ aChromeFlags) {
+    int[] ret = new int[1];
+    ret[0] = chromeFlags;
+    XPCOM.memmove (aChromeFlags, ret, 4); /* PRUint32 */
+    return XPCOM.NS_OK;
+}
+
+int SetChromeFlags (int aChromeFlags) {
+    chromeFlags = aChromeFlags;
+    return XPCOM.NS_OK;
+}
+
+int DestroyBrowserWindow () {
+    WindowEvent newEvent = new WindowEvent (browser);
+    newEvent.display = browser.getDisplay ();
+    newEvent.widget = browser;
+    for (int i = 0; i < closeWindowListeners.length; i++) {
+        closeWindowListeners[i].close (newEvent);
+    }
+    /*
+    * Note on Mozilla.  The DestroyBrowserWindow notification cannot be cancelled.
+    * The browser widget cannot be used after this notification has been received.
+    * The application is advised to close the window hosting the browser widget.
+    * The browser widget must be disposed in all cases.
+    */
+    browser.dispose ();
+    return XPCOM.NS_OK;
+}
+    
+int SizeBrowserTo (int aCX, int aCY) {
+    size = new Point (aCX, aCY);
+    bool isChrome = (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) !is 0;
+    if (isChrome) {
+        Shell shell = browser.getShell ();
+        shell.setSize (shell.computeSize (size.x, size.y));
+    }
+    return XPCOM.NS_OK;
+}
+
+int ShowAsModal () {
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = XPCOM.NS_GetServiceManager (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+    nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+    result[0] = 0;
+    byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_CONTEXTSTACK_CONTRACTID, true);
+    rc = serviceManager.GetServiceByContractID (aContractID, nsIJSContextStack.NS_IJSCONTEXTSTACK_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+    serviceManager.Release ();
+
+    nsIJSContextStack stack = new nsIJSContextStack (result[0]);
+    result[0] = 0;
+    rc = stack.Push (0);
+    if (rc !is XPCOM.NS_OK) error (rc);
+
+    Shell shell = browser.getShell ();
+    Display display = browser.getDisplay ();
+    while (!shell.isDisposed ()) {
+        if (!display.readAndDispatch ()) display.sleep ();
+    }
+
+    rc = stack.Pop (result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    stack.Release ();
+    return XPCOM.NS_OK;
+}
+
+int IsWindowModal (int /*long*/ retval) {
+    int result = (chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) !is 0 ? 1 : 0;
+    XPCOM.memmove (retval, new int[] {result}, 4); /* PRBool */
+    return XPCOM.NS_OK;
+}
+   
+int ExitModalEventLoop (int aStatus) {
+    return XPCOM.NS_OK;
+}
+
+/* nsIEmbeddingSiteWindow */ 
+
+int SetDimensions (int flags, int x, int y, int cx, int cy) {
+    if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) !is 0) {
+        location = new Point (x, y);
+        browser.getShell ().setLocation (x, y);
+    }
+    if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_INNER) !is 0) {
+        browser.setSize (cx, cy);
+    }
+    if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_OUTER) !is 0) {
+        browser.getShell ().setSize (cx, cy);
+    }
+    return XPCOM.NS_OK;
+}
+
+int GetDimensions (int flags, int /*long*/ x, int /*long*/ y, int /*long*/ cx, int /*long*/ cy) {
+    if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) !is 0) {
+        Point location = browser.getShell ().getLocation ();
+        if (x !is 0) C.memmove (x, new int[] {location.x}, 4); /* PRInt32 */
+        if (y !is 0) C.memmove (y, new int[] {location.y}, 4); /* PRInt32 */
+    }
+    if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_INNER) !is 0) {
+        Point size = browser.getSize ();
+        if (cx !is 0) C.memmove (cx, new int[] {size.x}, 4); /* PRInt32 */
+        if (cy !is 0) C.memmove (cy, new int[] {size.y}, 4); /* PRInt32 */
+    }
+    if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_OUTER) !is 0) {
+        Point size = browser.getShell().getSize ();
+        if (cx !is 0) C.memmove (cx, new int[] {size.x}, 4); /* PRInt32 */
+        if (cy !is 0) C.memmove (cy, new int[] {size.y}, 4); /* PRInt32 */
+    }
+    return XPCOM.NS_OK;
+}
+
+int SetFocus () {
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+    
+    nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+    rc = baseWindow.SetFocus ();
+    if (rc !is XPCOM.NS_OK) error (rc);
+    baseWindow.Release ();
+
+    /*
+    * Note. Mozilla notifies here that one of the children took
+    * focus. This could or should be used to fire an DWT.FOCUS_IN
+    * event on Browser focus listeners.
+    */
+    return XPCOM.NS_OK;         
+}   
+
+int GetVisibility (int /*long*/ aVisibility) {
+    bool visible = browser.isVisible () && !browser.getShell ().getMinimized ();
+    XPCOM.memmove (aVisibility, new int[] {visible ? 1 : 0}, 4); /* PRBool */
+    return XPCOM.NS_OK;
+}
+
+int SetVisibility (int aVisibility) {
+    if (isChild) {
+        WindowEvent event = new WindowEvent (browser);
+        event.display = browser.getDisplay ();
+        event.widget = browser;
+        if (aVisibility !is 0) {
+            /*
+            * Bug in Mozilla.  When the JavaScript window.open is executed, Mozilla
+            * fires multiple SetVisibility 1 notifications.  The workaround is
+            * to ignore subsequent notifications. 
+            */
+            if (!visible) {
+                visible = true;
+                event.location = location;
+                event.size = size;
+                event.addressBar = (chromeFlags & nsIWebBrowserChrome.CHROME_LOCATIONBAR) !is 0;
+                event.menuBar = (chromeFlags & nsIWebBrowserChrome.CHROME_MENUBAR) !is 0;
+                event.statusBar = (chromeFlags & nsIWebBrowserChrome.CHROME_STATUSBAR) !is 0;
+                event.toolBar = (chromeFlags & nsIWebBrowserChrome.CHROME_TOOLBAR) !is 0;
+                for (int i = 0; i < visibilityWindowListeners.length; i++) {
+                    visibilityWindowListeners[i].show (event);
+                }
+                location = null;
+                size = null;
+            }
+        } else {
+            visible = false;
+            for (int i = 0; i < visibilityWindowListeners.length; i++) {
+                visibilityWindowListeners[i].hide (event);
+            }
+        }
+    } else {
+        visible = aVisibility !is 0;
+    }
+    return XPCOM.NS_OK;         
+}
+
+int GetTitle (int /*long*/ aTitle) {
+    return XPCOM.NS_OK;         
+}
+ 
+int SetTitle (int /*long*/ aTitle) {
+    if (awaitingNavigate || titleListeners.length is 0) return XPCOM.NS_OK;
+    TitleEvent event = new TitleEvent (browser);
+    event.display = browser.getDisplay ();
+    event.widget = browser;
+    /*
+    * To be consistent with other platforms the title event should
+    * contain the page's url if the page does not contain a <title>
+    * tag. 
+    */
+    int length = XPCOM.strlen_PRUnichar (aTitle);
+    if (length > 0) {
+        char[] dest = new char[length];
+        XPCOM.memmove (dest, aTitle, length * 2);
+        event.title = new String (dest);
+    } else {
+        event.title = getUrl ();
+    }
+    for (int i = 0; i < titleListeners.length; i++) {
+        titleListeners[i].changed (event);
+    }
+    return XPCOM.NS_OK;         
+}
+
+int GetSiteWindow (int /*long*/ aSiteWindow) {
+    /*
+    * Note.  The handle is expected to be an HWND on Windows and
+    * a GtkWidget* on GTK.  This callback is invoked on Windows
+    * when the javascript window.print is invoked and the print
+    * dialog comes up. If no handle is returned, the print dialog
+    * does not come up on this platform.  
+    */
+    XPCOM.memmove (aSiteWindow, new int /*long*/[] {embedHandle}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;         
+}  
+ 
+/* nsIWebBrowserChromeFocus */
+
+int FocusNextElement () {
+    /*
+    * Bug in Mozilla embedding API.  Mozilla takes back the focus after sending
+    * this event.  This prevents tabbing out of Mozilla. This behaviour can be reproduced
+    * with the Mozilla application TestGtkEmbed.  The workaround is to
+    * send the traversal notification after this callback returns.
+    */
+    browser.getDisplay ().asyncExec (new Runnable () {
+        public void run () {
+            if (browser.isDisposed ()) return;
+            browser.traverse (DWT.TRAVERSE_TAB_NEXT);
+        }
+    });
+    return XPCOM.NS_OK;  
+}
+
+int FocusPrevElement () {
+    /*
+    * Bug in Mozilla embedding API.  Mozilla takes back the focus after sending
+    * this event.  This prevents tabbing out of Mozilla. This behaviour can be reproduced
+    * with the Mozilla application TestGtkEmbed.  The workaround is to
+    * send the traversal notification after this callback returns.
+    */
+    browser.getDisplay ().asyncExec (new Runnable () {
+        public void run () {
+            if (browser.isDisposed ()) return;
+            browser.traverse (DWT.TRAVERSE_TAB_PREVIOUS);
+        }
+    });
+    return XPCOM.NS_OK;         
+}
+
+/* nsIContextMenuListener */
+
+int OnShowContextMenu (int aContextFlags, int /*long*/ aEvent, int /*long*/ aNode) {
+    if (awaitingNavigate) return XPCOM.NS_OK;
+
+    nsIDOMEvent domEvent = new nsIDOMEvent (aEvent);
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = domEvent.QueryInterface (nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+    nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent (result[0]);
+    int[] aScreenX = new int[1], aScreenY = new int[1];
+    rc = domMouseEvent.GetScreenX (aScreenX);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    rc = domMouseEvent.GetScreenY (aScreenY);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    domMouseEvent.Release ();
+    
+    Event event = new Event ();
+    event.x = aScreenX[0];
+    event.y = aScreenY[0];
+    browser.notifyListeners (DWT.MenuDetect, event);
+    if (!event.doit || browser.isDisposed ()) return XPCOM.NS_OK;
+    Menu menu = browser.getMenu ();
+    if (menu !is null && !menu.isDisposed ()) {
+        if (aScreenX[0] !is event.x || aScreenY[0] !is event.y) {
+            menu.setLocation (event.x, event.y);
+        }
+        menu.setVisible (true);
+    }
+    return XPCOM.NS_OK;         
+}
+
+/* nsIURIContentListener */
+
+int OnStartURIOpen (int /*long*/ aURI, int /*long*/ retval) {
+    if (awaitingNavigate || locationListeners.length is 0) {
+        XPCOM.memmove (retval, new int[] {0}, 4); /* PRBool */
+        return XPCOM.NS_OK;
+    }
+    nsIURI location = new nsIURI (aURI);
+    int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+    location.GetSpec (aSpec);
+    int length = XPCOM.nsEmbedCString_Length (aSpec);
+    int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+    buffer = XPCOM.nsEmbedCString_get (aSpec);
+    byte[] dest = new byte[length];
+    XPCOM.memmove (dest, buffer, length);
+    XPCOM.nsEmbedCString_delete (aSpec);
+    String value = new String (dest);
+    bool doit = true;
+    if (request is 0) {
+        /* 
+         * listeners should not be notified of internal transitions like "javascipt:..."
+         * because this is an implementation side-effect, not a true navigate
+         */
+        if (!value.startsWith (PREFIX_JAVASCRIPT)) {
+            LocationEvent event = new LocationEvent (browser);
+            event.display = browser.getDisplay();
+            event.widget = browser;
+            event.location = value;
+            /*
+             * If the URI indicates that the page is being rendered from memory
+             * (via setText()) then set it to about:blank to be consistent with IE.
+             */
+            if (event.location.equals (URI_FROMMEMORY)) event.location = ABOUT_BLANK;
+            event.doit = doit;
+            for (int i = 0; i < locationListeners.length; i++) {
+                locationListeners[i].changing (event);
+            }
+            doit = event.doit && !browser.isDisposed();
+        }
+    }
+    XPCOM.memmove (retval, new int[] {doit ? 0 : 1}, 4); /* PRBool */
+    return XPCOM.NS_OK;
+}
+
+int DoContent (int /*long*/ aContentType, int aIsContentPreferred, int /*long*/ aRequest, int /*long*/ aContentHandler, int /*long*/ retval) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int IsPreferred (int /*long*/ aContentType, int /*long*/ aDesiredContentType, int /*long*/ retval) {
+    bool preferred = false;
+    int size = XPCOM.strlen (aContentType);
+    if (size > 0) {
+        byte[] typeBytes = new byte[size + 1];
+        XPCOM.memmove (typeBytes, aContentType, size);
+        String contentType = new String (typeBytes, 0, size);
+
+        /* do not attempt to handle known problematic content types */
+        if (!contentType.equals (XPCOM.CONTENT_MAYBETEXT) && !contentType.equals (XPCOM.CONTENT_MULTIPART)) {
+            /* determine whether browser can handle the content type */
+            int /*long*/[] result = new int /*long*/[1];
+            int rc = XPCOM.NS_GetServiceManager (result);
+            if (rc !is XPCOM.NS_OK) error (rc);
+            if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+            nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+            result[0] = 0;
+
+            /* First try to use the nsIWebNavigationInfo if it's available (>= mozilla 1.8) */
+            byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WEBNAVIGATIONINFO_CONTRACTID, true);
+            rc = serviceManager.GetServiceByContractID (aContractID, nsIWebNavigationInfo.NS_IWEBNAVIGATIONINFO_IID, result);
+            if (rc is 0) {
+                byte[] bytes = MozillaDelegate.wcsToMbcs (null, contentType, true);
+                int /*long*/ typePtr = XPCOM.nsEmbedCString_new (bytes, bytes.length);
+                nsIWebNavigationInfo info = new nsIWebNavigationInfo (result[0]);
+                result[0] = 0;
+                int[] isSupportedResult = new int[1]; /* PRUint32 */
+                rc = info.IsTypeSupported (typePtr, 0, isSupportedResult);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                info.Release ();
+                XPCOM.nsEmbedCString_delete (typePtr);
+                preferred = isSupportedResult[0] !is 0;
+            } else {
+                /* nsIWebNavigationInfo is not available, so do the type lookup */
+                result[0] = 0;
+                rc = serviceManager.GetService (XPCOM.NS_CATEGORYMANAGER_CID, nsICategoryManager.NS_ICATEGORYMANAGER_IID, result);
+                if (rc !is XPCOM.NS_OK) error (rc);
+                if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+                nsICategoryManager categoryManager = new nsICategoryManager (result[0]);
+                result[0] = 0;
+                byte[] categoryBytes = MozillaDelegate.wcsToMbcs (null, "Gecko-Content-Viewers", true); //$NON-NLS-1$
+                rc = categoryManager.GetCategoryEntry (categoryBytes, typeBytes, result);
+                categoryManager.Release ();
+                /* if no viewer for the content type is registered then rc is XPCOM.NS_ERROR_NOT_AVAILABLE */
+                preferred = rc is XPCOM.NS_OK;
+            }
+            serviceManager.Release ();
+        }
+    }
+
+    XPCOM.memmove(retval, new int[] {preferred ? 1 : 0}, 4); /* PRBool */
+    if (preferred) {
+        XPCOM.memmove (aDesiredContentType, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    }
+    return XPCOM.NS_OK;
+}
+
+int CanHandleContent (int /*long*/ aContentType, int aIsContentPreferred, int /*long*/ aDesiredContentType, int /*long*/ retval) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetLoadCookie (int /*long*/ aLoadCookie) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetLoadCookie (int /*long*/ aLoadCookie) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetParentContentListener (int /*long*/ aParentContentListener) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+    
+int SetParentContentListener (int /*long*/ aParentContentListener) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsITooltipListener */
+
+int OnShowTooltip (int aXCoords, int aYCoords, int /*long*/ aTipText) {
+    if (awaitingNavigate) return XPCOM.NS_OK;
+
+    int length = XPCOM.strlen_PRUnichar (aTipText);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, aTipText, length * 2);
+    String text = new String (dest);
+    if (tip !is null && !tip.isDisposed ()) tip.dispose ();
+    Display display = browser.getDisplay ();
+    Shell parent = browser.getShell ();
+    tip = new Shell (parent, DWT.ON_TOP);
+    tip.setLayout (new FillLayout());
+    Label label = new Label (tip, DWT.CENTER);
+    label.setForeground (display.getSystemColor (DWT.COLOR_INFO_FOREGROUND));
+    label.setBackground (display.getSystemColor (DWT.COLOR_INFO_BACKGROUND));
+    label.setText (text);
+    /*
+    * Bug in Mozilla embedded API.  Tooltip coordinates are wrong for 
+    * elements inside an inline frame (IFrame tag).  The workaround is 
+    * to position the tooltip based on the mouse cursor location.
+    */
+    Point point = display.getCursorLocation ();
+    /* Assuming cursor is 21x21 because this is the size of
+     * the arrow cursor on Windows
+     */ 
+    point.y += 21;
+    tip.setLocation (point);
+    tip.pack ();
+    tip.setVisible (true);
+    return XPCOM.NS_OK;
+}
+
+int OnHideTooltip () {
+    if (tip !is null && !tip.isDisposed ()) tip.dispose ();
+    tip = null;
+    return XPCOM.NS_OK;
+}
+
+/* nsIDOMEventListener */
+
+int HandleEvent (int /*long*/ event) {
+    nsIDOMEvent domEvent = new nsIDOMEvent (event);
+
+    int /*long*/ type = XPCOM.nsEmbedString_new ();
+    int rc = domEvent.GetType (type);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    int length = XPCOM.nsEmbedString_Length (type);
+    int /*long*/ buffer = XPCOM.nsEmbedString_get (type);
+    char[] chars = new char[length];
+    XPCOM.memmove (chars, buffer, length * 2);
+    String typeString = new String (chars);
+    XPCOM.nsEmbedString_delete (type);
+
+    if (XPCOM.DOMEVENT_UNLOAD.equals (typeString)) {
+        int /*long*/[] result = new int /*long*/[1];
+        rc = domEvent.GetCurrentTarget (result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+
+        nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+        unhookDOMListeners (target);
+        target.Release ();
+        return XPCOM.NS_OK;
+    }
+
+    if (XPCOM.DOMEVENT_FOCUS.equals (typeString)) {
+        delegate.handleFocus ();
+        return XPCOM.NS_OK;
+    }
+
+    if (XPCOM.DOMEVENT_KEYDOWN.equals (typeString)) {
+        int /*long*/[] result = new int /*long*/[1];
+        rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+        nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]);
+        result[0] = 0;
+
+        int[] aKeyCode = new int[1]; /* PRUint32 */
+        rc = domKeyEvent.GetKeyCode (aKeyCode);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        int keyCode = translateKey (aKeyCode[0]);
+
+        /*
+        * if keyCode is lastKeyCode then either a repeating key like Shift
+        * is being held or a key for which key events are not sent has been
+        * pressed.  In both of these cases a KeyDown should not be sent.
+        */
+        if (keyCode !is lastKeyCode) {
+            lastKeyCode = keyCode;
+            switch (keyCode) {
+                case DWT.SHIFT:
+                case DWT.CONTROL:
+                case DWT.ALT:
+                case DWT.CAPS_LOCK:
+                case DWT.NUM_LOCK:
+                case DWT.SCROLL_LOCK:
+                case DWT.COMMAND: {
+                    /* keypress events will not be received for these keys, so send KeyDowns for them now */
+                    int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+                    rc = domKeyEvent.GetAltKey (aAltKey);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+                    rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+                    rc = domKeyEvent.GetShiftKey (aShiftKey);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+                    rc = domKeyEvent.GetMetaKey (aMetaKey);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+
+                    Event keyEvent = new Event ();
+                    keyEvent.widget = browser;
+                    keyEvent.type = DWT.KeyDown;
+                    keyEvent.keyCode = keyCode;
+                    keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0);
+                    keyEvent.stateMask &= ~keyCode;     /* remove current keydown if it's a state key */
+                    browser.notifyListeners (keyEvent.type, keyEvent);
+                    if (!keyEvent.doit || browser.isDisposed ()) {
+                        domEvent.PreventDefault ();
+                    }
+                    break;
+                }
+                default: {
+                    /* 
+                    * If the keydown has Meta (but not Meta+Ctrl) as a modifier then send a KeyDown event for it here
+                    * because a corresponding keypress event will not be received for it from the DOM.  If the keydown
+                    * does not have Meta as a modifier, or has Meta+Ctrl as a modifier, then then do nothing here
+                    * because its KeyDown event will be sent from the keypress listener.
+                    */
+                    int[] aMetaKey = new int[1]; /* PRBool */
+                    rc = domKeyEvent.GetMetaKey (aMetaKey);
+                    if (rc !is XPCOM.NS_OK) error (rc);
+                    if (aMetaKey[0] !is 0) {
+                        int[] aCtrlKey = new int[1]; /* PRBool */
+                        rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+                        if (rc !is XPCOM.NS_OK) error (rc);
+                        if (aCtrlKey[0] is 0) {
+                            int[] aAltKey = new int[1], aShiftKey = new int[1]; /* PRBool */
+                            rc = domKeyEvent.GetAltKey (aAltKey);
+                            if (rc !is XPCOM.NS_OK) error (rc);
+                            rc = domKeyEvent.GetShiftKey (aShiftKey);
+                            if (rc !is XPCOM.NS_OK) error (rc);
+
+                            Event keyEvent = new Event ();
+                            keyEvent.widget = browser;
+                            keyEvent.type = DWT.KeyDown;
+                            keyEvent.keyCode = lastKeyCode;
+                            keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0? DWT.CTRL : 0) | (aShiftKey[0] !is 0? DWT.SHIFT : 0) | (aMetaKey[0] !is 0? DWT.COMMAND : 0);
+                            browser.notifyListeners (keyEvent.type, keyEvent);
+                            if (!keyEvent.doit || browser.isDisposed ()) {
+                                domEvent.PreventDefault ();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        domKeyEvent.Release ();
+        return XPCOM.NS_OK;
+    }
+
+    if (XPCOM.DOMEVENT_KEYPRESS.equals (typeString)) {
+        /*
+        * if keydown could not determine a keycode for this key then it's a
+        * key for which key events are not sent (eg.- the Windows key)
+        */
+        if (lastKeyCode is 0) return XPCOM.NS_OK;
+
+        /*
+        * On linux only, unexpected keypress events are received for some
+        * modifier keys.  The workaround is to ignore these events since
+        * KeyDown events are sent for these keys in the keydown listener.  
+        */
+        switch (lastKeyCode) {
+            case DWT.CAPS_LOCK:
+            case DWT.NUM_LOCK:
+            case DWT.SCROLL_LOCK: return XPCOM.NS_OK;
+        }
+
+        int /*long*/[] result = new int /*long*/[1];
+        rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+        nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]);
+        result[0] = 0;
+
+        int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+        rc = domKeyEvent.GetAltKey (aAltKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        rc = domKeyEvent.GetShiftKey (aShiftKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        rc = domKeyEvent.GetMetaKey (aMetaKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        domKeyEvent.Release ();
+
+        int[] aCharCode = new int[1]; /* PRUint32 */
+        rc = domKeyEvent.GetCharCode (aCharCode);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        lastCharCode = aCharCode[0];
+        if (lastCharCode is 0) {
+            switch (lastKeyCode) {
+                case DWT.TAB: lastCharCode = DWT.TAB; break;
+                case DWT.CR: lastCharCode = DWT.CR; break;
+                case DWT.BS: lastCharCode = DWT.BS; break;
+                case DWT.ESC: lastCharCode = DWT.ESC; break;
+                case DWT.DEL: lastCharCode = DWT.DEL; break;
+            }
+        }
+        if (aCtrlKey[0] !is 0 && (0 <= lastCharCode && lastCharCode <= 0x7F)) {
+            if ('a'  <= lastCharCode && lastCharCode <= 'z') lastCharCode -= 'a' - 'A';
+            if (64 <= lastCharCode && lastCharCode <= 95) lastCharCode -= 64;
+        }
+
+        Event keyEvent = new Event ();
+        keyEvent.widget = browser;
+        keyEvent.type = DWT.KeyDown;
+        keyEvent.keyCode = lastKeyCode;
+        keyEvent.character = (char)lastCharCode;
+        keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0);
+        browser.notifyListeners (keyEvent.type, keyEvent);
+        if (!keyEvent.doit || browser.isDisposed ()) {
+            domEvent.PreventDefault ();
+        }
+        return XPCOM.NS_OK;
+    }
+
+    if (XPCOM.DOMEVENT_KEYUP.equals (typeString)) {
+        int /*long*/[] result = new int /*long*/[1];
+        rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+        nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]);
+        result[0] = 0;
+
+        int[] aKeyCode = new int[1]; /* PRUint32 */
+        rc = domKeyEvent.GetKeyCode (aKeyCode);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        int keyCode = translateKey (aKeyCode[0]);
+        if (keyCode is 0) {
+            /* indicates a key for which key events are not sent */
+            domKeyEvent.Release ();
+            return XPCOM.NS_OK;
+        }
+        if (keyCode !is lastKeyCode) {
+            /* keyup does not correspond to the last keydown */
+            lastKeyCode = keyCode;
+            lastCharCode = 0;
+        }
+
+        int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+        rc = domKeyEvent.GetAltKey (aAltKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        rc = domKeyEvent.GetShiftKey (aShiftKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        rc = domKeyEvent.GetMetaKey (aMetaKey);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        domKeyEvent.Release ();
+
+        Event keyEvent = new Event ();
+        keyEvent.widget = browser;
+        keyEvent.type = DWT.KeyUp;
+        keyEvent.keyCode = lastKeyCode;
+        keyEvent.character = (char)lastCharCode;
+        keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0);
+        switch (lastKeyCode) {
+            case DWT.SHIFT:
+            case DWT.CONTROL:
+            case DWT.ALT:
+            case DWT.COMMAND: {
+                keyEvent.stateMask |= lastKeyCode;
+            }
+        }
+        browser.notifyListeners (keyEvent.type, keyEvent);
+        if (!keyEvent.doit || browser.isDisposed ()) {
+            domEvent.PreventDefault ();
+        }
+        lastKeyCode = lastCharCode = 0;
+        return XPCOM.NS_OK;
+    }
+
+    /* mouse event */
+
+    int /*long*/[] result = new int /*long*/[1];
+    rc = domEvent.QueryInterface (nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID, result);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    if (result[0] is 0) error (XPCOM.NS_NOINTERFACE);
+    nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent (result[0]);
+    result[0] = 0;
+
+    /*
+     * MouseOver and MouseOut events are fired any time the mouse enters or exits
+     * any element within the Browser.  To ensure that DWT events are only
+     * fired for mouse movements into or out of the Browser, do not fire an
+     * event if the element being exited (on MouseOver) or entered (on MouseExit)
+     * is within the Browser.
+     */
+    if (XPCOM.DOMEVENT_MOUSEOVER.equals (typeString) || XPCOM.DOMEVENT_MOUSEOUT.equals (typeString)) {
+        rc = domMouseEvent.GetRelatedTarget (result);
+        if (rc !is XPCOM.NS_OK) error (rc);
+        if (result[0] !is 0) {
+            domMouseEvent.Release ();
+            return XPCOM.NS_OK;
+        }
+    }
+
+    int[] aClientX = new int[1], aClientY = new int[1], aDetail = new int[1]; /* PRInt32 */
+    rc = domMouseEvent.GetClientX (aClientX);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    rc = domMouseEvent.GetClientY (aClientY);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    rc = domMouseEvent.GetDetail (aDetail);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    short[] aButton = new short[1]; /* PRUint16 */
+    rc = domMouseEvent.GetButton (aButton);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+    rc = domMouseEvent.GetAltKey (aAltKey);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    rc = domMouseEvent.GetCtrlKey (aCtrlKey);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    rc = domMouseEvent.GetShiftKey (aShiftKey);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    rc = domMouseEvent.GetMetaKey (aMetaKey);
+    if (rc !is XPCOM.NS_OK) error (rc);
+    domMouseEvent.Release ();
+
+    Event mouseEvent = new Event ();
+    mouseEvent.widget = browser;
+    mouseEvent.x = aClientX[0]; mouseEvent.y = aClientY[0];
+    mouseEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0);
+
+    if (XPCOM.DOMEVENT_MOUSEDOWN.equals (typeString)) {
+        delegate.handleMouseDown ();
+        mouseEvent.type = DWT.MouseDown;
+        mouseEvent.button = aButton[0] + 1;
+        mouseEvent.count = aDetail[0];
+    } else if (XPCOM.DOMEVENT_MOUSEUP.equals (typeString)) {
+        /*
+         * Bug on OSX.  For some reason multiple mouseup events come from the DOM
+         * when button 3 is released on OSX.  The first of these events has a count
+         * detail and the others do not.  The workaround is to not fire received
+         * button 3 mouseup events that do not have a count since mouse events
+         * without a click count are not valid.
+         */
+        int button = aButton[0] + 1;
+        int count = aDetail[0];
+        if (count is 0 && button is 3) return XPCOM.NS_OK;
+        mouseEvent.type = DWT.MouseUp;
+        mouseEvent.button = button;
+        mouseEvent.count = count;
+    } else if (XPCOM.DOMEVENT_MOUSEMOVE.equals (typeString)) {
+        mouseEvent.type = DWT.MouseMove;
+    } else if (XPCOM.DOMEVENT_MOUSEWHEEL.equals (typeString)) {
+        mouseEvent.type = DWT.MouseWheel;
+        mouseEvent.count = -aDetail[0];
+    } else if (XPCOM.DOMEVENT_MOUSEOVER.equals (typeString)) {
+        mouseEvent.type = DWT.MouseEnter;
+    } else if (XPCOM.DOMEVENT_MOUSEOUT.equals (typeString)) {
+        mouseEvent.type = DWT.MouseExit;
+    } else if (XPCOM.DOMEVENT_MOUSEDRAG.equals (typeString)) {
+        mouseEvent.type = DWT.DragDetect;
+        mouseEvent.button = aButton[0] + 1;
+        switch (mouseEvent.button) {
+            case 1: mouseEvent.stateMask |= DWT.BUTTON1; break;
+            case 2: mouseEvent.stateMask |= DWT.BUTTON2; break;
+            case 3: mouseEvent.stateMask |= DWT.BUTTON3; break;
+            case 4: mouseEvent.stateMask |= DWT.BUTTON4; break;
+            case 5: mouseEvent.stateMask |= DWT.BUTTON5; break;
+        }
+    }
+
+    browser.notifyListeners (mouseEvent.type, mouseEvent);
+    if (browser.isDisposed ()) return XPCOM.NS_OK;
+    if (aDetail[0] is 2 && XPCOM.DOMEVENT_MOUSEDOWN.equals (typeString)) {
+        mouseEvent = new Event ();
+        mouseEvent.widget = browser;
+        mouseEvent.x = aClientX[0]; mouseEvent.y = aClientY[0];
+        mouseEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0);
+        mouseEvent.type = DWT.MouseDoubleClick;
+        mouseEvent.button = aButton[0] + 1;
+        mouseEvent.count = aDetail[0];
+        browser.notifyListeners (mouseEvent.type, mouseEvent);  
+    }
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/MozillaDelegate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.MozillaDelegate;
+
+import dwt.DWT;
+import dwt.browser.Browser;
+import dwt.dwthelper.string;
+import dwt.dwthelper.utils;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+
+class MozillaDelegate {
+    Browser browser;
+    Listener listener;
+    bool hasFocus;
+
+    this (Browser browser) {
+        super();
+        this.browser = browser;
+    }
+
+    static Browser findBrowser (int handle) {
+        Display display = Display.getCurrent();
+        return cast(Browser) display.findWidget(handle);
+    }
+
+    static char[] mbcsToWcs (String codePage, byte[] buffer) {
+        //  int encoding = OS.CFStringGetSystemEncoding ();
+        //  int cfString = OS.CFStringCreateWithBytes (OS.kCFAllocatorDefault, buffer, buffer.length, encoding, false);
+        //  char[] chars = null;
+        //  if (cfString !is 0) {
+        //      int length = OS.CFStringGetLength (cfString);
+        //      chars = new char [length];
+        //      if (length !is 0) {
+        //          CFRange range = new CFRange ();
+        //          range.length = length;
+        //          OS.CFStringGetCharacters (cfString, range, chars);
+        //      }
+        //      OS.CFRelease (cfString);
+        //  }
+        //  return chars;
+
+        //return new String(buffer).toCharArray(); commented by Jacob Carlborg
+        return cast(char[]) buffer.dup; // FIXME
+    }
+
+    static byte[] wcsToMbcs (String codePage, String str, bool terminate) {
+        //  char[] chars = new char [String.length()];
+        //  String.getChars (0, chars.length, chars, 0);
+        //  int cfString = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length);
+        //  byte[] buffer = null;
+        //  if (cfString !is 0) {
+        //      CFRange range = new CFRange ();
+        //      range.length = chars.length;
+        //      int encoding = OS.CFStringGetSystemEncoding ();
+        //      int[] size = new int[1];
+        //      int numChars = OS.CFStringGetBytes (cfString, range, encoding, (byte)'?', true, null, 0, size);
+        //      buffer = new byte [size[0] + (terminate ? 1 : 0)];
+        //      if (numChars !is 0) {
+        //          numChars = OS.CFStringGetBytes (cfString, range, encoding, (byte)'?', true, buffer, size[0], size);
+        //      }
+        //      OS.CFRelease (cfString);
+        //  }
+        //  return buffer;
+        if (terminate)
+            str ~= "\0";
+
+        //return str.getBytes(); commented by Jacob Carlborg
+        return cast(byte[]) str.dup; // FIXME
+    }
+
+    int getHandle () {
+        return browser.view.id;
+    }
+
+    String getLibraryName () {
+        return "libxpcom.dylib"; //$NON-NLS-1$
+    }
+
+    String getDWTInitLibraryName () {
+        return "swt-xulrunner"; //$NON-NLS-1$
+    }
+
+    void handleFocus () {
+        if (hasFocus)
+            return;
+        hasFocus = true;
+        (cast(Mozilla) browser.webBrowser).Activate();
+        browser.setFocus();
+        listener = new class Listener {
+            public void handleEvent (Event event) {
+                if (event.widget == browser)
+                    return;
+
+                (cast(Mozilla) browser.webBrowser).Deactivate();
+                hasFocus = false;
+                browser.getDisplay().removeFilter(DWT.FocusIn, this);
+                browser.getShell().removeListener(DWT.Deactivate, this);
+                listener = null;
+            }
+
+        };
+        browser.getDisplay().addFilter(DWT.FocusIn, listener);
+        browser.getShell().addListener(DWT.Deactivate, listener);
+    }
+
+    void handleMouseDown () {
+    }
+
+    bool hookEnterExit () {
+        return true;
+    }
+
+    void init () {
+    }
+
+    bool needsSpinup () {
+        return false;
+    }
+
+    void onDispose (int embedHandle) {
+        if (listener !is null) {
+            browser.getDisplay().removeFilter(DWT.FocusIn, listener);
+            browser.getShell().removeListener(DWT.Deactivate, listener);
+            listener = null;
+        }
+        browser = null;
+    }
+
+    void setSize (int embedHandle, int width, int height) {
+        // TODO
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/OpenWindowListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.OpenWindowListener;
+
+import dwt.browser.WindowEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/** 
+ * This listener interface may be implemented in order to receive
+ * a {@link WindowEvent} notification when a new {@link Browser}
+ * needs to be provided by the application.
+ * 
+ * @see Browser#addOpenWindowListener(OpenWindowListener)
+ * @see Browser#removeOpenWindowListener(OpenWindowListener)
+ * @see CloseWindowListener
+ * @see VisibilityWindowListener
+ * 
+ * @since 3.0
+ */
+public interface OpenWindowListener : DWTEventListener {
+
+    /**
+     * This method is called when a new window needs to be created.
+     * <p>
+     * A particular <code>Browser</code> can be passed to the event.browser
+     * field to host the content of a new window.
+     * <p>
+     * A standalone system browser is used to host the new window
+     * if the event.required field value is false and if the event.browser 
+     * field is left <code>null</code>. The event.required field
+     * is true on platforms that don't support a standalone system browser for
+     * new window requests. 
+     * <p>
+     * The navigation is cancelled if the event.required field is set to
+     * true and the event.browser field is left <code>null</code>.
+     * <p>
+     * <p>The following fields in the <code>WindowEvent</code> apply:
+     * <ul>
+     * <li>(in/out) required true if the platform requires the user to provide a
+     * <code>Browser</code> to handle the new window or false otherwise.
+     * <li>(out) browser the new <code>Browser</code> that will host the 
+     * content of the new window.
+     * <li>(in) widget the <code>Browser</code> that is requesting to open a 
+     * new window
+     * </ul>
+     * 
+     * @param event the <code>WindowEvent</code> that needs to be passed a new
+     * <code>Browser</code> to handle the new window request
+     * 
+     * @since 3.0
+     */
+    public void open (WindowEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/ProgressAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.ProgressAdapter;
+
+import dwt.browser.ProgressListener;
+import dwt.browser.ProgressEvent;
+import dwt.dwthelper.utils;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the {@link ProgressListener} interface.
+ * <p>
+ * Classes that wish to deal with {@link ProgressEvent}'s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ * 
+ * @since 3.0
+ */
+public abstract class ProgressAdapter : ProgressListener {
+
+    public void changed (ProgressEvent event) {
+    }
+
+    public void completed (ProgressEvent event) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/ProgressEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.ProgressEvent;
+
+import dwt.dwthelper.string;
+import dwt.dwthelper.utils;
+import dwt.events.TypedEvent;
+import dwt.widgets.Widget;
+
+/**
+ * A <code>ProgressEvent</code> is sent by a {@link Browser} to
+ * {@link ProgressListener}'s when a progress is made during the
+ * loading of the current URL or when the loading of the current
+ * URL has been completed.
+ * 
+ * @since 3.0
+ */
+public class ProgressEvent : TypedEvent {
+    /** current value */
+    public int current;
+
+    /** total value */
+    public int total;
+
+    static const long serialVersionUID = 3977018427045393972L;
+
+    this (Widget w) {
+        super(w);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        String str = super.toString();
+        return str.substring(0, String.length() - 1) // remove trailing '}'
+        + " current=" + current + " total=" + total + "}";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/ProgressListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.ProgressListener;
+
+import dwt.browser.ProgressEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link ProgressEvent} notification when a {@link Browser}
+ * makes a progress in loading the current URL or when the
+ * current URL has been loaded.
+ * 
+ * @see Browser#addProgressListener(ProgressListener)
+ * @see Browser#removeProgressListener(ProgressListener)
+ * @see Browser#getUrl()
+ * 
+ * @since 3.0
+ */
+public interface ProgressListener : DWTEventListener {
+
+    /**
+     * This method is called when a progress is made during the loading of the 
+     * current location.
+     * <p>
+     *
+     * <p>The following fields in the <code>ProgressEvent</code> apply:
+     * <ul>
+     * <li>(in) current the progress for the location currently being loaded
+     * <li>(in) total the maximum progress for the location currently being loaded
+     * <li>(in) widget the <code>Browser</code> whose current URL is being loaded
+     * </ul>
+     * 
+     * @param event the <code>ProgressEvent</code> related to the loading of the
+     * current location of a <code>Browser</code>
+     * 
+     * @since 3.0
+     */
+    public void changed (ProgressEvent event);
+
+    /**
+     * This method is called when the current location has been completely loaded.
+     * <p>
+     *
+     * <p>The following fields in the <code>ProgressEvent</code> apply:
+     * <ul>
+     * <li>(in) widget the <code>Browser</code> whose current URL has been loaded
+     * </ul>
+     * 
+     * @param event the <code>ProgressEvent</code> related to the <code>Browser</code>
+     * that has loaded its current URL.
+     * 
+     * @since 3.0
+     */
+    public void completed (ProgressEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/PromptDialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.PromptDialog;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.layout.GridData;
+import dwt.layout.GridLayout;
+import dwt.widgets.Button;
+import dwt.widgets.Composite;
+import dwt.widgets.Dialog;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Label;
+import dwt.widgets.Listener;
+import dwt.widgets.Monitor;
+import dwt.widgets.Shell;
+import dwt.widgets.Text;
+import dwt.widgets.Widget;
+
+class PromptDialog extends Dialog {
+    
+    PromptDialog(Shell parent, int style) {
+        super(parent, style);
+    }
+    
+    PromptDialog(Shell parent) {
+        this(parent, 0);
+    }
+    
+    void alertCheck(String title, String text, String check, final int[] checkValue) {
+        Shell parent = getParent();
+        final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL);
+        if (title !is null) shell.setText(title);
+        GridLayout gridLayout = new GridLayout();
+        shell.setLayout(gridLayout);
+        Label label = new Label(shell, DWT.WRAP);
+        label.setText(text);
+        GridData data = new GridData();
+        Monitor monitor = parent.getMonitor();
+        int maxWidth = monitor.getBounds().width * 2 / 3;
+        int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x;
+        data.widthHint = Math.min(width, maxWidth);
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        label.setLayoutData (data);
+
+        final Button checkButton = check !is null ? new Button(shell, DWT.CHECK) : null;
+        if (checkButton !is null) {
+            checkButton.setText(check);
+            checkButton.setSelection(checkValue[0] !is 0);
+            data = new GridData ();
+            data.horizontalAlignment = GridData.BEGINNING;
+            checkButton.setLayoutData (data);
+        }
+        Button okButton = new Button(shell, DWT.PUSH);
+        okButton.setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$
+        data = new GridData ();
+        data.horizontalAlignment = GridData.CENTER;
+        okButton.setLayoutData (data);
+        okButton.addListener(DWT.Selection, new Listener() {
+            public void handleEvent(Event event) {
+                if (checkButton !is null) checkValue[0] = checkButton.getSelection() ? 1 : 0;
+                shell.close();
+            }
+        });
+
+        shell.pack();
+        shell.open();
+        Display display = parent.getDisplay();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch()) display.sleep();
+        }
+    }
+
+    void confirmEx(String title, String text, String check, String button0, String button1, String button2, int defaultIndex, final int[] checkValue, final int[] result) {
+        Shell parent = getParent();
+        final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL);
+        shell.setText(title);
+        GridLayout gridLayout = new GridLayout();
+        shell.setLayout(gridLayout);
+        Label label = new Label(shell, DWT.WRAP);
+        label.setText(text);
+        GridData data = new GridData();
+        Monitor monitor = parent.getMonitor();
+        int maxWidth = monitor.getBounds().width * 2 / 3;
+        int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x;
+        data.widthHint = Math.min(width, maxWidth);
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        label.setLayoutData (data);
+
+        final Button[] buttons = new Button[4];
+        Listener listener = new Listener() {
+            public void handleEvent(Event event) {
+                if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0;
+                Widget widget = event.widget;
+                for (int i = 1; i < buttons.length; i++) {
+                    if (widget is buttons[i]) {
+                        result[0] = i - 1;
+                        break;
+                    }
+                }
+                shell.close();
+            }   
+        };
+        if (check !is null) {
+            buttons[0] = new Button(shell, DWT.CHECK);
+            buttons[0].setText(check);
+            buttons[0].setSelection(checkValue[0] !is 0);
+            data = new GridData ();
+            data.horizontalAlignment = GridData.BEGINNING;
+            buttons[0].setLayoutData (data);
+        }
+        Composite composite = new Composite(shell, DWT.NONE);
+        data = new GridData();
+        data.horizontalAlignment = GridData.CENTER;
+        composite.setLayoutData (data);
+        GridLayout layout = new GridLayout();
+        layout.makeColumnsEqualWidth = true;
+        composite.setLayout(layout);
+        int buttonCount = 0;
+        if (button0 !is null) {
+            buttons[1] = new Button(composite, DWT.PUSH);
+            buttons[1].setText(button0);
+            buttons[1].addListener(DWT.Selection, listener);
+            buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+            buttonCount++;
+        }
+        if (button1 !is null) {
+            buttons[2] = new Button(composite, DWT.PUSH);
+            buttons[2].setText(button1);
+            buttons[2].addListener(DWT.Selection, listener);
+            buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+            buttonCount++;
+        }
+        if (button2 !is null) {
+            buttons[3] = new Button(composite, DWT.PUSH);
+            buttons[3].setText(button2);
+            buttons[3].addListener(DWT.Selection, listener);
+            buttons[3].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+            buttonCount++;
+        }
+        layout.numColumns = buttonCount;
+        Button defaultButton = buttons [defaultIndex + 1];
+        if (defaultButton !is null) shell.setDefaultButton (defaultButton);
+
+        shell.pack();
+        shell.open();
+        Display display = parent.getDisplay();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch()) display.sleep();
+        }
+    }
+    
+    void prompt(String title, String text, String check, final String[] value, final int[] checkValue, final int[] result) {
+        Shell parent = getParent();
+        final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL);
+        if (title !is null) shell.setText(title);
+        GridLayout gridLayout = new GridLayout();
+        shell.setLayout(gridLayout);
+        Label label = new Label(shell, DWT.WRAP);
+        label.setText(text);
+        GridData data = new GridData();
+        Monitor monitor = parent.getMonitor();
+        int maxWidth = monitor.getBounds().width * 2 / 3;
+        int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x;
+        data.widthHint = Math.min(width, maxWidth);
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        label.setLayoutData (data);
+                
+        final Text valueText = new Text(shell, DWT.BORDER);
+        if (value[0] !is null) valueText.setText(value[0]);
+        data = new GridData();
+        width = valueText.computeSize(DWT.DEFAULT, DWT.DEFAULT).x;
+        if (width > maxWidth) data.widthHint = maxWidth;
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        valueText.setLayoutData(data);
+
+        final Button[] buttons = new Button[3];
+        Listener listener = new Listener() {
+            public void handleEvent(Event event) {
+                if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0;
+                value[0] = valueText.getText();
+                result[0] = event.widget is buttons[1] ? 1 : 0;
+                shell.close();
+            }   
+        };
+        if (check !is null) {
+            buttons[0] = new Button(shell, DWT.CHECK);
+            buttons[0].setText(check);
+            buttons[0].setSelection(checkValue[0] !is 0);
+            data = new GridData ();
+            data.horizontalAlignment = GridData.BEGINNING;
+            buttons[0].setLayoutData (data);
+        }
+        Composite composite = new Composite(shell, DWT.NONE);
+        data = new GridData();
+        data.horizontalAlignment = GridData.CENTER;
+        composite.setLayoutData (data);
+        composite.setLayout(new GridLayout(2, true));
+        buttons[1] = new Button(composite, DWT.PUSH);
+        buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$
+        buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        buttons[1].addListener(DWT.Selection, listener);
+        buttons[2] = new Button(composite, DWT.PUSH);
+        buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$
+        buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        buttons[2].addListener(DWT.Selection, listener);
+
+        shell.pack();
+        shell.open();
+        Display display = parent.getDisplay();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch()) display.sleep();
+        }   
+    }
+
+    void promptUsernameAndPassword(String title, String text, String check, final String[] user, final String[] pass, final int[] checkValue, final int[] result) {
+        Shell parent = getParent();
+        final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL);
+        shell.setText(title);
+        GridLayout gridLayout = new GridLayout();
+        shell.setLayout(gridLayout);
+        Label label = new Label(shell, DWT.WRAP);
+        label.setText(text);
+        GridData data = new GridData();
+        Monitor monitor = parent.getMonitor();
+        int maxWidth = monitor.getBounds().width * 2 / 3;
+        int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x;
+        data.widthHint = Math.min(width, maxWidth);
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        label.setLayoutData (data);
+        
+        Label userLabel = new Label(shell, DWT.NONE);
+        userLabel.setText(DWT.getMessage("SWT_Username")); //$NON-NLS-1$
+        
+        final Text userText = new Text(shell, DWT.BORDER);
+        if (user[0] !is null) userText.setText(user[0]);
+        data = new GridData();
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        userText.setLayoutData(data);
+        
+        Label passwordLabel = new Label(shell, DWT.NONE);
+        passwordLabel.setText(DWT.getMessage("SWT_Password")); //$NON-NLS-1$
+        
+        final Text passwordText = new Text(shell, DWT.PASSWORD | DWT.BORDER);
+        if (pass[0] !is null) passwordText.setText(pass[0]);
+        data = new GridData();
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        passwordText.setLayoutData(data);
+
+        final Button[] buttons = new Button[3];
+        Listener listener = new Listener() {
+            public void handleEvent(Event event) {
+                if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0;
+                user[0] = userText.getText();
+                pass[0] = passwordText.getText();
+                result[0] = event.widget is buttons[1] ? 1 : 0;
+                shell.close();
+            }   
+        };
+        if (check !is null) {
+            buttons[0] = new Button(shell, DWT.CHECK);
+            buttons[0].setText(check);
+            buttons[0].setSelection(checkValue[0] !is 0);
+            data = new GridData ();
+            data.horizontalAlignment = GridData.BEGINNING;
+            buttons[0].setLayoutData (data);
+        }
+        Composite composite = new Composite(shell, DWT.NONE);
+        data = new GridData();
+        data.horizontalAlignment = GridData.CENTER;
+        composite.setLayoutData (data);
+        composite.setLayout(new GridLayout(2, true));
+        buttons[1] = new Button(composite, DWT.PUSH);
+        buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$
+        buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        buttons[1].addListener(DWT.Selection, listener);
+        buttons[2] = new Button(composite, DWT.PUSH);
+        buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$
+        buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        buttons[2].addListener(DWT.Selection, listener);
+
+        shell.setDefaultButton(buttons[1]);
+        shell.pack();
+        shell.open();
+        Display display = parent.getDisplay();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch()) display.sleep();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/PromptService2.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,649 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 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
+ *******************************************************************************/
+module dwt.browser.PromptService2;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.C;
+import dwt.internal.Compatibility;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsEmbedString;
+import dwt.internal.mozilla.nsIAuthInformation;
+import dwt.internal.mozilla.nsIChannel;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIDOMWindow;
+import dwt.internal.mozilla.nsIEmbeddingSiteWindow;
+import dwt.internal.mozilla.nsIMemory;
+import dwt.internal.mozilla.nsIPromptService;
+import dwt.internal.mozilla.nsIPromptService2;
+import dwt.internal.mozilla.nsIServiceManager;
+import dwt.internal.mozilla.nsISupports;
+import dwt.internal.mozilla.nsIURI;
+import dwt.internal.mozilla.nsIWebBrowserChrome;
+import dwt.internal.mozilla.nsIWindowWatcher;
+import dwt.widgets.MessageBox;
+import dwt.widgets.Shell;
+
+class PromptService2 {
+    XPCOMObject supports;
+    XPCOMObject promptService;
+    XPCOMObject promptService2;
+    int refCount = 0;
+
+PromptService2 () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    promptService = new XPCOMObject (new int[] {2, 0, 0, 3, 5, 4, 6, 10, 7, 8, 7, 7}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Alert (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return AlertCheck (args[0], args[1], args[2], args[3], args[4]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return Confirm (args[0], args[1], args[2], args[3]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return ConfirmCheck (args[0], args[1], args[2], args[3], args[4], args[5]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return ConfirmEx (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7], args[8], args[9]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return Prompt (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return PromptUsernameAndPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return PromptPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return Select (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6]);}
+    };
+    
+    promptService2 = new XPCOMObject (new int[] {2, 0, 0, 3, 5, 4, 6, 10, 7, 8, 7, 7, 7, 9}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return Alert (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return AlertCheck (args[0], args[1], args[2], args[3], args[4]);}
+        public int /*long*/ method5 (int /*long*/[] args) {return Confirm (args[0], args[1], args[2], args[3]);}
+        public int /*long*/ method6 (int /*long*/[] args) {return ConfirmCheck (args[0], args[1], args[2], args[3], args[4], args[5]);}
+        public int /*long*/ method7 (int /*long*/[] args) {return ConfirmEx (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7], args[8], args[9]);}
+        public int /*long*/ method8 (int /*long*/[] args) {return Prompt (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method9 (int /*long*/[] args) {return PromptUsernameAndPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
+        public int /*long*/ method10 (int /*long*/[] args) {return PromptPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method11 (int /*long*/[] args) {return Select (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method12 (int /*long*/[] args) {return PromptAuth (args[0], args[1], (int)/*64*/args[2], args[3], args[4], args[5], args[6]);}
+        public int /*long*/ method13 (int /*long*/[] args) {return AsyncPromptAuth (args[0], args[1], args[2], args[3], (int)/*64*/args[4], args[5], args[6], args[7], args[8]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (promptService !is null) {
+        promptService.dispose ();
+        promptService = null;   
+    }
+    if (promptService2 !is null) {
+        promptService2.dispose ();
+        promptService2 = null;  
+    }
+}
+
+int /*long*/ getAddress () {
+    return promptService2.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIPromptService.NS_IPROMPTSERVICE_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {promptService.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIPromptService2.NS_IPROMPTSERVICE2_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {promptService2.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+Browser getBrowser (int /*long*/ aDOMWindow) {
+    if (aDOMWindow is 0) return null;
+
+    int /*long*/[] result = new int /*long*/[1];
+    int rc = XPCOM.NS_GetServiceManager (result);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+    
+    nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+    result[0] = 0;
+    byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
+    rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
+    if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
+    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
+    serviceManager.Release ();
+    
+    nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
+    result[0] = 0;
+    /* the chrome will only be answered for the top-level nsIDOMWindow */
+    nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
+    rc = window.GetTop (result);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+    aDOMWindow = result[0];
+    result[0] = 0;
+    rc = windowWatcher.GetChromeForWindow (aDOMWindow, result);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
+    windowWatcher.Release ();   
+    
+    nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
+    result[0] = 0;
+    rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID, result);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
+    webBrowserChrome.Release ();
+    
+    nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
+    result[0] = 0;
+    rc = embeddingSiteWindow.GetSiteWindow (result);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+    if (result[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);       
+    embeddingSiteWindow.Release ();
+    
+    return Mozilla.findBrowser (result[0]); 
+}
+
+String getLabel (int buttonFlag, int index, int /*long*/ buttonTitle) {
+    String label = null;
+    int flag = (buttonFlag & (0xff * index)) / index;
+    switch (flag) {
+        case nsIPromptService.BUTTON_TITLE_CANCEL : label = DWT.getMessage ("SWT_Cancel"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_NO : label = DWT.getMessage ("SWT_No"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_OK : label = DWT.getMessage ("SWT_OK"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_SAVE : label = DWT.getMessage ("SWT_Save"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_YES : label = DWT.getMessage ("SWT_Yes"); break; //$NON-NLS-1$
+        case nsIPromptService.BUTTON_TITLE_IS_STRING : {
+            int length = XPCOM.strlen_PRUnichar (buttonTitle);
+            char[] dest = new char[length];
+            XPCOM.memmove (dest, buttonTitle, length * 2);
+            label = new String (dest);
+        }
+    }
+    return label;
+}
+
+/* nsIPromptService */
+
+int Alert (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText) {
+    Browser browser = getBrowser (aParent);
+    
+    int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, aDialogTitle, length * 2);
+    String titleLabel = new String (dest);
+
+    length = XPCOM.strlen_PRUnichar (aText);
+    dest = new char[length];
+    XPCOM.memmove (dest, aText, length * 2);
+    String textLabel = new String (dest);
+
+    Shell shell = browser is null ? new Shell () : browser.getShell (); 
+    MessageBox messageBox = new MessageBox (shell, DWT.OK | DWT.ICON_WARNING);
+    messageBox.setText (titleLabel);
+    messageBox.setMessage (textLabel);
+    messageBox.open ();
+    return XPCOM.NS_OK;
+}
+
+int AlertCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState) {
+    Browser browser = getBrowser (aParent);
+    
+    int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, aDialogTitle, length * 2);
+    String titleLabel = new String (dest);
+
+    length = XPCOM.strlen_PRUnichar (aText);
+    dest = new char[length];
+    XPCOM.memmove (dest, aText, length * 2);
+    String textLabel = new String (dest);
+
+    length = XPCOM.strlen_PRUnichar (aCheckMsg);
+    dest = new char[length];
+    XPCOM.memmove (dest, aCheckMsg, length * 2);
+    String checkLabel = new String (dest);
+
+    Shell shell = browser is null ? new Shell () : browser.getShell ();
+    PromptDialog dialog = new PromptDialog (shell);
+    int[] check = new int[1];
+    if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */
+    dialog.alertCheck (titleLabel, textLabel, checkLabel, check);
+    if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */
+    return XPCOM.NS_OK;
+}
+
+int AsyncPromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int /*long*/ aCallback, int /*long*/ aContext, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkValue, int /*long*/ _retval) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int Confirm (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ _retval) {
+    Browser browser = getBrowser (aParent);
+    
+    int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, aDialogTitle, length * 2);
+    String titleLabel = new String (dest);
+
+    length = XPCOM.strlen_PRUnichar (aText);
+    dest = new char[length];
+    XPCOM.memmove (dest, aText, length * 2);
+    String textLabel = new String (dest);
+
+    Shell shell = browser is null ? new Shell () : browser.getShell ();
+    MessageBox messageBox = new MessageBox (shell, DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION);
+    messageBox.setText (titleLabel);
+    messageBox.setMessage (textLabel);
+    int id = messageBox.open ();
+    int[] result = {id is DWT.OK ? 1 : 0};
+    XPCOM.memmove (_retval, result, 4);
+    return XPCOM.NS_OK;
+}
+
+int ConfirmCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int ConfirmEx (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aButtonFlags, int /*long*/ aButton0Title, int /*long*/ aButton1Title, int /*long*/ aButton2Title, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+    Browser browser = getBrowser (aParent);
+    
+    int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+    char[] dest = new char[length];
+    XPCOM.memmove (dest, aDialogTitle, length * 2);
+    String titleLabel = new String (dest);
+
+    length = XPCOM.strlen_PRUnichar (aText);
+    dest = new char[length];
+    XPCOM.memmove (dest, aText, length * 2);
+    String textLabel = new String (dest);
+    
+    String checkLabel = null;
+    if (aCheckMsg !is 0) {
+        length = XPCOM.strlen_PRUnichar (aCheckMsg);
+        dest = new char[length];
+        XPCOM.memmove (dest, aCheckMsg, length * 2);
+        checkLabel = new String (dest);
+    }
+    
+    String button0Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title);
+    String button1Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title);
+    String button2Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title);
+    
+    int defaultIndex = 0;
+    if ((aButtonFlags & nsIPromptService.BUTTON_POS_1_DEFAULT) !is 0) {
+        defaultIndex = 1;
+    } else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) !is 0) {
+        defaultIndex = 2;
+    }
+    
+    Shell shell = browser is null ? new Shell () : browser.getShell ();
+    PromptDialog dialog = new PromptDialog (shell);
+    int[] check = new int[1], result = new int[1];
+    if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4);
+    dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, check, result);
+    if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4);
+    XPCOM.memmove (_retval, result, 4);
+    return XPCOM.NS_OK;
+}
+
+int Prompt (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aValue, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+    Browser browser = getBrowser (aParent);
+    String titleLabel = null, textLabel, checkLabel = null;
+    String[] valueLabel = new String[1];
+    char[] dest;
+    int length;
+    if (aDialogTitle !is 0) {
+        length = XPCOM.strlen_PRUnichar (aDialogTitle);
+        dest = new char[length];
+        XPCOM.memmove (dest, aDialogTitle, length * 2);
+        titleLabel = new String (dest);
+    }
+    
+    length = XPCOM.strlen_PRUnichar (aText);
+    dest = new char[length];
+    XPCOM.memmove (dest, aText, length * 2);
+    textLabel = new String (dest);
+    
+    int /*long*/[] valueAddr = new int /*long*/[1];
+    XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF);
+    if (valueAddr[0] !is 0) {
+        length = XPCOM.strlen_PRUnichar (valueAddr[0]);
+        dest = new char[length];
+        XPCOM.memmove (dest, valueAddr[0], length * 2);
+        valueLabel[0] = new String (dest);      
+    }
+    
+    if (aCheckMsg !is 0) {
+        length = XPCOM.strlen_PRUnichar (aCheckMsg);
+        if (length > 0) {
+            dest = new char[length];
+            XPCOM.memmove (dest, aCheckMsg, length * 2);
+            checkLabel = new String (dest);
+        }
+    }
+
+    Shell shell = browser is null ? new Shell () : browser.getShell ();
+    PromptDialog dialog = new PromptDialog (shell);
+    int[] check = new int[1], result = new int[1];
+    if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4);
+    dialog.prompt (titleLabel, textLabel, checkLabel, valueLabel, check, result);
+
+    XPCOM.memmove (_retval, result, 4);
+    if (result[0] is 1) {
+        /* 
+        * User selected OK. User name and password are returned as PRUnichar values. Any default
+        * value that we override must be freed using the nsIMemory service.
+        */
+        int cnt, size;
+        int /*long*/ ptr;
+        char[] buffer;
+        int /*long*/[] result2 = new int /*long*/[1];
+        if (valueLabel[0] !is null) {
+            cnt = valueLabel[0].length ();
+            buffer = new char[cnt + 1];
+            valueLabel[0].getChars (0, cnt, buffer, 0);
+            size = buffer.length * 2;
+            ptr = C.malloc (size);
+            XPCOM.memmove (ptr, buffer, size);
+            XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+
+            if (valueAddr[0] !is 0) {
+                int rc = XPCOM.NS_GetServiceManager (result2);
+                if (rc !is XPCOM.NS_OK) DWT.error (rc);
+                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);
+            
+                nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+                result2[0] = 0;
+                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+                rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+                if (rc !is XPCOM.NS_OK) DWT.error (rc);
+                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);      
+                serviceManager.Release ();
+                
+                nsIMemory memory = new nsIMemory (result2[0]);
+                result2[0] = 0;
+                memory.Free (valueAddr[0]);
+                memory.Release ();
+            }
+        }
+    }
+    if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4);
+    return XPCOM.NS_OK;
+}
+
+int PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkboxValue, int /*long*/ _retval) {
+    Browser browser = getBrowser (aParent);
+    String checkLabel = null;
+    int[] checkValue = new int[1];
+    String[] userLabel = new String[1], passLabel = new String[1];
+
+    String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
+
+    if (checkboxLabel !is 0 && checkboxValue !is 0) {
+        int length = XPCOM.strlen_PRUnichar (checkboxLabel);
+        char[] dest = new char[length];
+        XPCOM.memmove (dest, checkboxLabel, length * 2);
+        checkLabel = new String (dest);
+        XPCOM.memmove (checkValue, checkboxValue, 4); /* PRBool */
+    }
+
+    /* get initial username and password values */
+
+    nsIAuthInformation auth = new nsIAuthInformation (authInfo);
+
+    int /*long*/ ptr = XPCOM.nsEmbedString_new ();
+    int rc = auth.GetUsername (ptr);
+    if (rc !is XPCOM.NS_OK) DWT.error (rc);
+    int length = XPCOM.nsEmbedString_Length (ptr);
+    int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr);
+    char[] chars = new char[length];
+    XPCOM.memmove (chars, buffer, length * 2);
+    userLabel[0] = new String (chars);
+    XPCOM.nsEmbedString_delete (ptr);
+
+    ptr = XPCOM.nsEmbedString_new ();
+    rc = auth.GetPassword (ptr);
+    if (rc !is XPCOM.NS_OK) DWT.error (rc);
+    length = XPCOM.nsEmbedString_Length (ptr);
+    buffer = XPCOM.nsEmbedString_get (ptr);
+    chars = new char[length];
+    XPCOM.memmove (chars, buffer, length * 2);
+    passLabel[0] = new String (chars);
+    XPCOM.nsEmbedString_delete (ptr);
+
+    /* compute the message text */
+
+    ptr = XPCOM.nsEmbedString_new ();
+    rc = auth.GetRealm (ptr);
+    if (rc !is XPCOM.NS_OK) DWT.error (rc);
+    length = XPCOM.nsEmbedString_Length (ptr);
+    buffer = XPCOM.nsEmbedString_get (ptr);
+    chars = new char[length];
+    XPCOM.memmove (chars, buffer, length * 2);
+    String realm = new String (chars);
+    XPCOM.nsEmbedString_delete (ptr);
+
+    nsIChannel channel = new nsIChannel (aChannel);
+    int /*long*/[] uri = new int /*long*/[1];
+    rc = channel.GetURI (uri);
+    if (rc !is XPCOM.NS_OK) DWT.error (rc);
+    if (uri[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+
+    nsIURI nsURI = new nsIURI (uri[0]);
+    int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+    rc = nsURI.GetHost (aSpec);
+    if (rc !is XPCOM.NS_OK) DWT.error (rc);
+    length = XPCOM.nsEmbedCString_Length (aSpec);
+    buffer = XPCOM.nsEmbedCString_get (aSpec);
+    byte[] bytes = new byte[length];
+    XPCOM.memmove (bytes, buffer, length);
+    XPCOM.nsEmbedCString_delete (aSpec);
+    String host = new String (bytes);
+    nsURI.Release ();
+
+    String message;
+    if (realm.length () > 0 && host.length () > 0) {
+        message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
+    } else {
+        message = ""; //$NON-NLS-1$
+    }
+
+    /* open the prompter */
+    Shell shell = browser is null ? new Shell () : browser.getShell ();
+    PromptDialog dialog = new PromptDialog (shell);
+    int[] result = new int[1];
+    dialog.promptUsernameAndPassword (title, message, checkLabel, userLabel, passLabel, checkValue, result);
+
+    XPCOM.memmove (_retval, result, 4); /* PRBool */
+    if (result[0] is 1) {   /* User selected OK */
+        nsEmbedString string = new nsEmbedString (userLabel[0]);
+        rc = auth.SetUsername(string.getAddress ());
+        if (rc !is XPCOM.NS_OK) DWT.error (rc);
+        string.dispose ();
+        
+        string = new nsEmbedString (passLabel[0]);
+        rc = auth.SetPassword(string.getAddress ());
+        if (rc !is XPCOM.NS_OK) DWT.error (rc);
+        string.dispose ();
+    }
+
+    if (checkboxValue !is 0) XPCOM.memmove (checkboxValue, checkValue, 4); /* PRBool */
+    return XPCOM.NS_OK;
+}
+
+int PromptUsernameAndPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aUsername, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+    Browser browser = getBrowser (aParent);
+    String titleLabel, textLabel, checkLabel = null;
+    String[] userLabel = new String[1], passLabel = new String[1];
+    char[] dest;
+    int length;
+    if (aDialogTitle !is 0) {
+        length = XPCOM.strlen_PRUnichar (aDialogTitle);
+        dest = new char[length];
+        XPCOM.memmove (dest, aDialogTitle, length * 2);
+        titleLabel = new String (dest);
+    } else {
+        titleLabel = DWT.getMessage ("SWT_Authentication_Required");    //$NON-NLS-1$
+    }
+    
+    length = XPCOM.strlen_PRUnichar (aText);
+    dest = new char[length];
+    XPCOM.memmove (dest, aText, length * 2);
+    textLabel = new String (dest);
+    
+    int /*long*/[] userAddr = new int /*long*/[1];
+    XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF);
+    if (userAddr[0] !is 0) {
+        length = XPCOM.strlen_PRUnichar (userAddr[0]);
+        dest = new char[length];
+        XPCOM.memmove (dest, userAddr[0], length * 2);
+        userLabel[0] = new String (dest);       
+    }
+    
+    int /*long*/[] passAddr = new int /*long*/[1];
+    XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF);
+    if (passAddr[0] !is 0) {
+        length = XPCOM.strlen_PRUnichar (passAddr[0]);
+        dest = new char[length];
+        XPCOM.memmove (dest, passAddr[0], length * 2);
+        passLabel[0] = new String (dest);       
+    }
+    
+    if (aCheckMsg !is 0) {
+        length = XPCOM.strlen_PRUnichar (aCheckMsg);
+        if (length > 0) {
+            dest = new char[length];
+            XPCOM.memmove (dest, aCheckMsg, length * 2);
+            checkLabel = new String (dest);
+        }
+    }
+
+    Shell shell = browser is null ? new Shell () : browser.getShell ();
+    PromptDialog dialog = new PromptDialog (shell);
+    int[] check = new int[1], result = new int[1];
+    if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4);    /* PRBool */
+    dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result);
+
+    XPCOM.memmove (_retval, result, 4); /* PRBool */
+    if (result[0] is 1) {
+        /* 
+        * User selected OK. User name and password are returned as PRUnichar values. Any default
+        * value that we override must be freed using the nsIMemory service.
+        */
+        int cnt, size;
+        int /*long*/ ptr;
+        char[] buffer;
+        int /*long*/[] result2 = new int /*long*/[1];
+        if (userLabel[0] !is null) {
+            cnt = userLabel[0].length ();
+            buffer = new char[cnt + 1];
+            userLabel[0].getChars (0, cnt, buffer, 0);
+            size = buffer.length * 2;
+            ptr = C.malloc (size);
+            XPCOM.memmove (ptr, buffer, size);
+            XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+
+            if (userAddr[0] !is 0) {
+                int rc = XPCOM.NS_GetServiceManager (result2);
+                if (rc !is XPCOM.NS_OK) DWT.error (rc);
+                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);
+            
+                nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+                result2[0] = 0;
+                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+                rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+                if (rc !is XPCOM.NS_OK) DWT.error (rc);
+                if (result[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);       
+                serviceManager.Release ();
+                
+                nsIMemory memory = new nsIMemory (result2[0]);
+                result2[0] = 0;
+                memory.Free (userAddr[0]);
+                memory.Release ();
+            }
+        }
+        if (passLabel[0] !is null) {
+            cnt = passLabel[0].length ();
+            buffer = new char[cnt + 1];
+            passLabel[0].getChars (0, cnt, buffer, 0);
+            size = buffer.length * 2;
+            ptr = C.malloc (size);
+            XPCOM.memmove (ptr, buffer, size);
+            XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+            
+            if (passAddr[0] !is 0) {
+                int rc = XPCOM.NS_GetServiceManager (result2);
+                if (rc !is XPCOM.NS_OK) DWT.error (rc);
+                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);
+
+                nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+                result2[0] = 0;
+                byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+                rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+                if (rc !is XPCOM.NS_OK) DWT.error (rc);
+                if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE);      
+                serviceManager.Release ();
+
+                nsIMemory memory = new nsIMemory (result2[0]);
+                result2[0] = 0;
+                memory.Free (passAddr[0]);
+                memory.Release ();
+            }
+        }
+    }
+    if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */
+    return XPCOM.NS_OK;
+}
+
+int PromptPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int Select (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aCount, int /*long*/ aSelectList, int /*long*/ aOutSelection, int /*long*/ _retval) {
+    return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/PromptService2Factory.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 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
+ *******************************************************************************/
+module dwt.browser.PromptService2Factory;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsIFactory;
+import dwt.internal.mozilla.nsISupports;
+
+class PromptService2Factory {
+    XPCOMObject supports;
+    XPCOMObject factory;
+    int refCount = 0;
+
+PromptService2Factory () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+    
+    factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (factory !is null) {
+        factory.dispose ();
+        factory = null; 
+    }
+}
+
+int /*long*/ getAddress () {
+    return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+    
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+    PromptService2 promptService = new PromptService2 ();
+    promptService.AddRef ();
+    XPCOM.memmove (result, new int /*long*/[] {promptService.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+    return XPCOM.NS_OK;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/Safari.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1566 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.Safari;
+
+import dwt.DWT;
+import dwt.browser.LocationEvent;
+import dwt.browser.ProgressEvent;
+import dwt.browser.ProgressListener;
+import dwt.browser.StatusTextEvent;
+import dwt.browser.TitleEvent;
+import dwt.browser.TitleListener;
+import dwt.browser.WebBrowser;
+import dwt.dwthelper.utils;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.Callback;
+import dwt.internal.cocoa.DOMDocument;
+import dwt.internal.cocoa.DOMEvent;
+import dwt.internal.cocoa.DOMKeyboardEvent;
+import dwt.internal.cocoa.DOMMouseEvent;
+import dwt.internal.cocoa.DOMWheelEvent;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSHTTPCookie;
+import dwt.internal.cocoa.NSHTTPCookieStorage;
+import dwt.internal.cocoa.NSNotificationCenter;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSPrintInfo;
+import dwt.internal.cocoa.NSPrintOperation;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSURLDownload;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.DWTWebViewDelegate;
+import dwt.internal.cocoa.WebDataSource;
+import dwt.internal.cocoa.WebDocumentRepresentation;
+import dwt.internal.cocoa.WebFrame;
+import dwt.internal.cocoa.WebFrameView;
+import dwt.internal.cocoa.WebOpenPanelResultListener;
+import dwt.internal.cocoa.WebPolicyDecisionListener;
+import dwt.internal.cocoa.WebPreferences;
+import dwt.internal.cocoa.WebView;
+import dwt.internal.cocoa.id;
+
+import dwt.widgets.Composite;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.FileDialog;
+import dwt.widgets.Listener;
+import dwt.widgets.Menu;
+import dwt.widgets.MessageBox;
+import dwt.widgets.Shell;
+
+import Math = tango.math.Math;
+
+import dwt.dwthelper.Runnable;
+
+class Safari : WebBrowser
+{
+    WebView webView;
+    DWTWebViewDelegate delegatee;
+    int jniRef;
+    bool changingLocation;
+    String lastHoveredLinkURL;
+    String html;
+    int identifier;
+    int resourceCount;
+    String url = "";
+    Point location;
+    Point size;
+    bool statusBar = true, toolBar = true, ignoreDispose;
+    int lastMouseMoveX, lastMouseMoveY;
+    //TEMPORARY CODE
+    //  bool doit;
+
+    static bool Initialized;
+    static Callback Callback2, Callback3, Callback4, Callback5, Callback6, Callback7;
+
+    static const int MIN_SIZE = 16;
+    static const int MAX_PROGRESS = 100;
+    static const String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$
+    static const String AGENT_STRING = "Safari/unknown"; //$NON-NLS-1$
+    static const String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$
+    static const String PROTOCOL_FILE = "file:"; //$NON-NLS-1$
+    static const String PROTOCOL_HTTP = "http:"; //$NON-NLS-1$
+    static const String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
+    static const String SAFARI_EVENTS_FIX_KEY = "dwt.internal.safariEventsFix"; //$NON-NLS-1$
+
+    /* event Strings */
+    static const String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$
+    static const String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$
+    static const String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$
+    static const String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$
+    static const String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$
+    static const String DOMEVENT_MOUSEWHEEL = "mousewheel"; //$NON-NLS-1$
+
+    static this ()
+    {
+        NativeClearSessions = new class Runnable
+        {
+            public void run ()
+            {
+                NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage();
+                NSArray cookies = storage.cookies();
+                int count = cookies.count();
+                
+                for (int i = 0; i < count; i++)
+                {
+                    NSHTTPCookie cookie = new NSHTTPCookie(cookies.objectAtIndex(i));
+                    if (cookie.isSessionOnly())
+                    {
+                        storage.deleteCookie(cookie);
+                    }
+                }
+            }
+        };
+    }
+
+    public void create (Composite parent, int style)
+    {
+
+        String className = "DWTWebViewDelegate";
+        if (OS.objc_lookUpClass(className) == 0)
+        {
+            ClassInfo safaryClass = this.classinfo;
+            Callback2 = new Callback(safaryClass, "browserProc", 2);
+            int proc2 = Callback2.getAddress();
+            if (proc2 is 0)
+                DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+            Callback3 = new Callback(safaryClass, "browserProc", 3);
+            int proc3 = Callback3.getAddress();
+            if (proc3 is 0)
+                DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+            Callback4 = new Callback(safaryClass, "browserProc", 4);
+            int proc4 = Callback4.getAddress();
+            if (proc4 is 0)
+                DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+            Callback5 = new Callback(safaryClass, "browserProc", 5);
+            int proc5 = Callback5.getAddress();
+            if (proc5 is 0)
+                DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+            Callback6 = new Callback(safaryClass, "browserProc", 6);
+            int proc6 = Callback6.getAddress();
+            if (proc6 is 0)
+                DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+            Callback7 = new Callback(safaryClass, "browserProc", 7);
+            int proc7 = Callback7.getAddress();
+            if (proc7 is 0)
+                DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+
+            int cls = OS.objc_allocateClassPair(OS.class_WebView, className, 0);
+            OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte) (Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+            OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+            OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+            OS.class_addMethod(cls, OS.sel_webView_1didChangeLocationWithinPageForFrame_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1didFailProvisionalLoadWithError_1forFrame_1, proc5, "@:@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1didFinishLoadForFrame_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1didReceiveTitle_1forFrame_1, proc5, "@:@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1didStartProvisionalLoadForFrame_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1didCommitLoadForFrame_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1resource_1didFinishLoadingFromDataSource_1, proc5, "@:@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1resource_1didFailLoadingWithError_1fromDataSource_1, proc6, "@:@@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1identifierForInitialRequest_1fromDataSource_1, proc5, "@:@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1resource_1willSendRequest_1redirectResponse_1fromDataSource_1, proc7, "@:@@@@@");
+            OS.class_addMethod(cls, OS.sel_handleNotification_1, proc3, "@:@");
+            OS.class_addMethod(cls, OS.sel_webView_1createWebViewWithRequest_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webViewShow_1, proc3, "@:@");
+            OS.class_addMethod(cls, OS.sel_webView_1setFrame_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webViewClose_1, proc3, "@:@");
+            OS.class_addMethod(cls, OS.sel_webView_1contextMenuItemsForElement_1defaultMenuItems_1, proc5, "@:@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1setStatusBarVisible_1, proc4, "@:@B");
+            OS.class_addMethod(cls, OS.sel_webView_1setResizable_1, proc4, "@:@B");
+            OS.class_addMethod(cls, OS.sel_webView_1setToolbarsVisible_1, proc4, "@:@B");
+            OS.class_addMethod(cls, OS.sel_webView_1setStatusText_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webViewFocus_1, proc3, "@:@");
+            OS.class_addMethod(cls, OS.sel_webViewUnfocus_1, proc3, "@:@");
+            OS.class_addMethod(cls, OS.sel_webView_1runJavaScriptAlertPanelWithMessage_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1runJavaScriptConfirmPanelWithMessage_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1runOpenPanelForFileButtonWithResultListener_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1mouseDidMoveOverElement_1modifierFlags_1, proc5, "@:@@I");
+            OS.class_addMethod(cls, OS.sel_webView_1printFrameView_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_webView_1decidePolicyForMIMEType_1request_1frame_1decisionListener_1, proc7, "@:@@@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1decidePolicyForNavigationAction_1request_1frame_1decisionListener_1, proc7, "@:@@@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1decidePolicyForNewWindowAction_1request_1newFrameName_1decisionListener_1, proc7, "@:@@@@@");
+            OS.class_addMethod(cls, OS.sel_webView_1unableToImplementPolicyWithError_1frame_1, proc5, "@:@@@");
+            OS.class_addMethod(cls, OS.sel_download_1decideDestinationWithSuggestedFilename_1, proc4, "@:@@");
+            OS.class_addMethod(cls, OS.sel_handleEvent_1, proc3, "@:@");
+            OS.objc_registerClassPair(cls);
+        }
+
+        /*
+         * Override the default event mechanism to not send key events so
+         * that the browser can send them by listening to the DOM instead.
+         */
+        browser.setData(SAFARI_EVENTS_FIX_KEY);
+
+        WebView webView = cast(WebView) (new WebView()).alloc();
+        if (webView is null)
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        webView.initWithFrame(browser.view.frame(), null, null);
+        webView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable);
+        jniRef = OS.NewGlobalRef(this);
+        if (jniRef is 0)
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        const DWTWebViewDelegate delegatee = cast(DWTWebViewDelegate) (new DWTWebViewDelegate()).alloc().init();
+        delegatee.setTag(jniRef);
+        this.delegatee = delegatee;
+        this.webView = webView;
+        browser.view.addSubview_(webView);
+
+        const NSNotificationCenter notificationCenter = NSNotificationCenter.defaultCenter();
+
+        Listener listener = new class (notificationCenter) Listener
+        {
+            NSNotificationCenter notificationCenter;
+            
+            this (NSNotificationCenter notificationCenter)
+            {
+                this.notificationCenter = notificationCenter;
+            }
+            
+            public void handleEvent (Event e)
+            {
+                switch (e.type)
+                {
+                    case DWT.Dispose:
+                    {
+                        /* make this handler run after other dispose listeners */
+                        if (ignoreDispose)
+                        {
+                            ignoreDispose = false;
+                            break;
+                        }
+                        ignoreDispose = true;
+                        browser.notifyListeners(e.type, e);
+                        e.type = DWT.NONE;
+
+                        webView.setFrameLoadDelegate(null);
+                        webView.setResourceLoadDelegate(null);
+                        webView.setUIDelegate(null);
+                        webView.setPolicyDelegate(null);
+                        webView.setDownloadDelegate(null);
+                        notificationCenter.removeObserver(delegatee);
+
+                        webView.release();
+                        webView = null;
+                        delegatee.release();
+                        delegatee = null;
+                        OS.DeleteGlobalRef(jniRef);
+                        jniRef = 0;
+                        html = null;
+                        lastHoveredLinkURL = null;
+                        break;
+                    }
+                }
+            }
+        };
+        browser.addListener(DWT.Dispose, listener);
+
+        webView.setFrameLoadDelegate(delegatee);
+        webView.setResourceLoadDelegate(delegatee);
+        webView.setUIDelegate(delegatee);
+        notificationCenter.addObserver(delegatee, OS.sel_handleNotification_1, null, webView);
+        webView.setPolicyDelegate(delegatee);
+        webView.setDownloadDelegate(delegatee);
+        webView.setApplicationNameForUserAgent(NSString.StringWith(AGENT_STRING));
+
+        if (!Initialized)
+        {
+            Initialized = true;
+            /* disable applets */
+            WebPreferences.standardPreferences().setJavaEnabled(false);
+        }
+    }
+
+    public bool back ()
+    {
+        html = null;
+        return webView.goBack();
+    }
+
+    static int browserProc (int delegatee, int sel)
+    {
+        if (sel is OS.sel_tag)
+        {
+            int[] tag = new int[1];
+            OS.object_getInstanceVariable(delegatee, "tag", tag);
+            return tag[0];
+        }
+        return 0;
+    }
+
+    static int browserProc (int id, int sel, int arg0)
+    {
+        if (sel is OS.sel_setTag_1)
+        {
+            OS.object_setInstanceVariable(id, "tag", arg0);
+            return 0;
+        }
+        int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+        if (jniRef is 0 || jniRef is -1)
+            return 0;
+        Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
+        if (widget is null)
+            return 0;
+        if (sel is OS.sel_handleNotification_1)
+        {
+            widget.handleNotification(arg0);
+        }
+        else if (sel is OS.sel_webViewShow_1)
+        {
+            widget.webViewShow(arg0);
+        }
+        else if (sel is OS.sel_webViewClose_1)
+        {
+            widget.webViewClose(arg0);
+        }
+        else if (sel is OS.sel_webViewFocus_1)
+        {
+            widget.webViewFocus(arg0);
+        }
+        else if (sel is OS.sel_webViewUnfocus_1)
+        {
+            widget.webViewUnfocus(arg0);
+        }
+        else if (sel is OS.sel_handleEvent_1)
+        {
+            widget.handleEvent(arg0);
+        }
+        return 0;
+    }
+
+    static int browserProc (int id, int sel, int arg0, int arg1)
+    {
+        if (sel is OS.sel_setTag_1)
+        {
+            OS.object_setInstanceVariable(id, "tag", arg0);
+            return 0;
+        }
+        int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+        if (jniRef is 0 || jniRef is -1)
+            return 0;
+        Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
+        if (widget is null)
+            return 0;
+        if (sel is OS.sel_webView_1didChangeLocationWithinPageForFrame_1)
+        {
+            widget.webView_didChangeLocationWithinPageForFrame(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1didFinishLoadForFrame_1)
+        {
+            widget.webView_didFinishLoadForFrame(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1didStartProvisionalLoadForFrame_1)
+        {
+            widget.webView_didStartProvisionalLoadForFrame(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1didCommitLoadForFrame_1)
+        {
+            widget.webView_didCommitLoadForFrame(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1setFrame_1)
+        {
+            widget.webView_setFrame(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1createWebViewWithRequest_1)
+        {
+            return widget.webView_createWebViewWithRequest(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1setStatusBarVisible_1)
+        {
+            widget.webView_setStatusBarVisible(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1setResizable_1)
+        {
+            widget.webView_setResizable(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1setStatusText_1)
+        {
+            widget.webView_setStatusText(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1setToolbarsVisible_1)
+        {
+            widget.webView_setToolbarsVisible(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1runJavaScriptAlertPanelWithMessage_1)
+        {
+            widget.webView_runJavaScriptAlertPanelWithMessage(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1runJavaScriptConfirmPanelWithMessage_1)
+        {
+            return widget.webView_runJavaScriptConfirmPanelWithMessage(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1runOpenPanelForFileButtonWithResultListener_1)
+        {
+            widget.webView_runOpenPanelForFileButtonWithResultListener(arg0, arg1);
+        }
+        else if (sel is OS.sel_download_1decideDestinationWithSuggestedFilename_1)
+        {
+            widget.download_decideDestinationWithSuggestedFilename(arg0, arg1);
+        }
+        else if (sel is OS.sel_webView_1printFrameView_1)
+        {
+            widget.webView_printFrameView(arg0, arg1);
+        }
+        return 0;
+    }
+
+    static int browserProc (int id, int sel, int arg0, int arg1, int arg2)
+    {
+        int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+        if (jniRef is 0 || jniRef is -1)
+            return 0;
+        Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
+        if (widget is null)
+            return 0;
+        if (sel is OS.sel_webView_1didFailProvisionalLoadWithError_1forFrame_1)
+        {
+            widget.webView_didFailProvisionalLoadWithError_forFrame(arg0, arg1, arg2);
+        }
+        else if (sel is OS.sel_webView_1didReceiveTitle_1forFrame_1)
+        {
+            widget.webView_didReceiveTitle_forFrame(arg0, arg1, arg2);
+        }
+        else if (sel is OS.sel_webView_1resource_1didFinishLoadingFromDataSource_1)
+        {
+            widget.webView_resource_didFinishLoadingFromDataSource(arg0, arg1, arg2);
+        }
+        else if (sel is OS.sel_webView_1identifierForInitialRequest_1fromDataSource_1)
+        {
+            return widget.webView_identifierForInitialRequest_fromDataSource(arg0, arg1, arg2);
+        }
+        else if (sel is OS.sel_webView_1contextMenuItemsForElement_1defaultMenuItems_1)
+        {
+            return widget.webView_contextMenuItemsForElement_defaultMenuItems(arg0, arg1, arg2);
+        }
+        else if (sel is OS.sel_webView_1mouseDidMoveOverElement_1modifierFlags_1)
+        {
+            widget.webView_mouseDidMoveOverElement_modifierFlags(arg0, arg1, arg2);
+        }
+        else if (sel is OS.sel_webView_1unableToImplementPolicyWithError_1frame_1)
+        {
+            widget.webView_unableToImplementPolicyWithError_frame(arg0, arg1, arg2);
+        }
+        return 0;
+    }
+
+    static int browserProc (int id, int sel, int arg0, int arg1, int arg2, int arg3)
+    {
+        int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+        if (jniRef is 0 || jniRef is -1)
+            return 0;
+        Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
+        if (widget is null)
+            return 0;
+        if (sel is OS.sel_webView_1resource_1didFailLoadingWithError_1fromDataSource_1)
+        {
+            widget.webView_resource_didFailLoadingWithError_fromDataSource(arg0, arg1, arg2, arg3);
+        }
+        return 0;
+    }
+
+    static int browserProc (int id, int sel, int arg0, int arg1, int arg2, int arg3, int arg4)
+    {
+        int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+        if (jniRef is 0 || jniRef is -1)
+            return 0;
+        Safari widget = cast(Safari) OS.JNIGetObject(jniRef);
+        if (widget is null)
+            return 0;
+        if (sel is OS.sel_webView_1resource_1willSendRequest_1redirectResponse_1fromDataSource_1)
+        {
+            return widget.webView_resource_willSendRequest_redirectResponse_fromDataSource(arg0, arg1, arg2, arg3, arg4);
+        }
+        else if (sel is OS.sel_webView_1decidePolicyForMIMEType_1request_1frame_1decisionListener_1)
+        {
+            widget.webView_decidePolicyForMIMEType_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4);
+        }
+        else if (sel is OS.sel_webView_1decidePolicyForNavigationAction_1request_1frame_1decisionListener_1)
+        {
+            widget.webView_decidePolicyForNavigationAction_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4);
+        }
+        else if (sel is OS.sel_webView_1decidePolicyForNewWindowAction_1request_1newFrameName_1decisionListener_1)
+        {
+            widget.webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(arg0, arg1, arg2, arg3, arg4);
+        }
+        return 0;
+    }
+
+    public bool execute (String script)
+    {
+        return webView.StringByEvaluatingJavaScriptFromString(NSString.StringWith(script)) !is null;
+    }
+
+    public bool forward ()
+    {
+        html = null;
+        return webView.goForward();
+    }
+
+    public String getText ()
+    {
+        WebFrame mainFrame = webView.mainFrame();
+        WebDataSource dataSource = mainFrame.dataSource();
+        if (dataSource is null)
+            return ""; //$NON-NLS-1$
+        WebDocumentRepresentation representation = dataSource.representation();
+        if (representation is null)
+            return ""; //$NON-NLS-1$
+        NSString source = representation.documentSource();
+        if (source is null)
+            return ""; //$NON-NLS-1$
+        char[] buffer = new char[source.length()];
+        source.getCharacters_(buffer);
+        return new String(buffer);
+    }
+
+    public String getUrl ()
+    {
+        return url;
+    }
+
+    public bool isBackEnabled ()
+    {
+        return webView.canGoBack();
+    }
+
+    public bool isForwardEnabled ()
+    {
+        return webView.canGoForward();
+    }
+
+    public void refresh ()
+    {
+        webView.reload(null);
+    }
+
+    public bool setText (String html)
+    {
+        /*
+         * Bug in Safari.  The web view segment faults in some circumstances
+         * when the text changes during the location changing callback.  The
+         * fix is to defer the work until the callback is done. 
+         */
+        if (changingLocation)
+        {
+            this.html = html;
+        }
+        else
+        {
+            _setText(html);
+        }
+        return true;
+    }
+
+    void _setText (String html)
+    {
+        NSString String = NSString.StringWith(html);
+        NSString URLString = NSString.StringWith(URI_FROMMEMORY);
+        NSURL URL = NSURL.static_URLWithString_(URLString);
+        WebFrame mainFrame = webView.mainFrame();
+        mainFrame.loadHTMLString(String, URL);
+    }
+
+    public bool setUrl (String url)
+    {
+        html = null;
+
+        NSURL inURL;
+        if (url.startsWith(PROTOCOL_FILE))
+        {
+            url = url.substring(PROTOCOL_FILE.length());
+        }
+        bool isHttpURL = url.indexOf('/') !is 0;
+        if (isHttpURL)
+        {
+            if (url.indexOf(':') is -1)
+            {
+                url = PROTOCOL_HTTP + "//" + url; //$NON-NLS-1$
+            }
+            inURL = NSURL.static_URLWithString_(NSString.StringWith(url.toString()));
+        }
+        else
+        {
+            inURL = NSURL.static_fileURLWithPath_(NSString.StringWith(url.toString()));
+        }
+        if (inURL is null)
+            return false;
+
+        NSURLRequest request = NSURLRequest.static_requestWithURL_(inURL);
+        WebFrame mainFrame = webView.mainFrame();
+        mainFrame.loadRequest(request);
+        return true;
+    }
+
+    public void stop ()
+    {
+        html = null;
+        webView.stopLoading(null);
+    }
+
+    /* WebFrameLoadDelegate */
+
+    void webView_didChangeLocationWithinPageForFrame (int sender, int frameID)
+    {
+        WebFrame frame = new WebFrame(frameID);
+        WebDataSource dataSource = frame.dataSource();
+        NSURLRequest request = dataSource.request();
+        NSURL url = request.URL();
+        NSString s = url.absoluteString();
+        int length = s.length();
+        if (length is 0)
+            return;
+        char[] buffer = new char[length];
+        s.getCharacters_(buffer);
+        String url2 = new String(buffer);
+        /*
+         * If the URI indicates that the page is being rendered from memory
+         * (via setText()) then set it to about:blank to be consistent with IE.
+         */
+        if (url2.opEquals(URI_FROMMEMORY))
+            url2 = ABOUT_BLANK;
+
+        const Display display = browser.getDisplay();
+        bool top = frameID is webView.mainFrame().id;
+        if (top)
+        {
+            StatusTextEvent statusText = new StatusTextEvent(browser);
+            statusText.display = display;
+            statusText.widget = browser;
+            statusText.text = url2;
+            for (int i = 0; i < statusTextListeners.length; i++)
+            {
+                statusTextListeners[i].changed(statusText);
+            }
+        }
+
+        LocationEvent location = new LocationEvent(browser);
+        location.display = display;
+        location.widget = browser;
+        location.location = url2;
+        location.top = top;
+        for (int i = 0; i < locationListeners.length; i++)
+        {
+            locationListeners[i].changed(location);
+        }
+    }
+
+    void webView_didFailProvisionalLoadWithError_forFrame (int sender, int error, int frame)
+    {
+        if (frame is webView.mainFrame().id)
+        {
+            /*
+             * Feature on Safari.  The identifier is used here as a marker for the events 
+             * related to the top frame and the URL changes related to that top frame as 
+             * they should appear on the location bar of a browser.  It is expected to reset
+             * the identifier to 0 when the event didFinishLoadingFromDataSource related to 
+             * the identifierForInitialRequest event is received.  However, Safari fires
+             * the didFinishLoadingFromDataSource event before the entire content of the
+             * top frame is loaded.  It is possible to receive multiple willSendRequest 
+             * events in this interval, causing the Browser widget to send unwanted
+             * Location.changing events.  For this reason, the identifier is reset to 0
+             * when the top frame has either finished loading (didFinishLoadForFrame
+             * event) or failed (didFailProvisionalLoadWithError).
+             */
+            identifier = 0;
+        }
+    }
+
+    void webView_didFinishLoadForFrame (int sender, int frameID)
+    {
+        hookDOMMouseListeners(frameID);
+        if (frameID is webView.mainFrame().id)
+        {
+            hookDOMKeyListeners(frameID);
+
+            const Display display = browser.getDisplay();
+            /*
+             * To be consistent with other platforms a title event should be fired when a
+             * page has completed loading.  A page with a <title> tag will do this
+             * automatically when the didReceiveTitle callback is received.  However a page
+             * without a <title> tag will not do this by default, so fire the event
+             * here with the page's url as the title.
+             */
+            WebFrame frame = new WebFrame(frameID);
+            WebDataSource dataSource = frame.dataSource();
+            if (dataSource !is null)
+            {
+                NSString title = dataSource.pageTitle();
+                if (title is null)
+                {   /* page has no title */
+                    const TitleEvent newEvent = new TitleEvent(browser);
+                    newEvent.display = display;
+                    newEvent.widget = browser;
+                    newEvent.title = url;
+                    for (int i = 0; i < titleListeners.length; i++)
+                    {
+                        const TitleListener listener = titleListeners[i];
+                        /*
+                         * Note on WebKit.  Running the event loop from a Browser
+                         * delegatee callback breaks the WebKit (stop loading or
+                         * crash).  The workaround is to invoke Display.asyncExec()
+                         * so that the Browser does not crash if this is attempted.
+                         */
+                        display.asyncExec(new class (display, listener) Runnable
+                        {
+                            Display display;
+                            TitleListener listener;
+                            
+                            this (Display display, TitleListener listener)
+                            {
+                                this.display = display;
+                                this.listener = listener;
+                            }
+                            
+                            public void run ()
+                            {
+                                if (!display.isDisposed() && !browser.isDisposed())
+                                {
+                                    listener.changed(newEvent);
+                                }
+                            }
+                        });
+                    }
+                }
+            }
+            const ProgressEvent progress = new ProgressEvent(browser);
+            progress.display = display;
+            progress.widget = browser;
+            progress.current = MAX_PROGRESS;
+            progress.total = MAX_PROGRESS;
+            for (int i = 0; i < progressListeners.length; i++)
+            {
+                const ProgressListener listener = progressListeners[i];
+                /*
+                 * Note on WebKit.  Running the event loop from a Browser
+                 * delegatee callback breaks the WebKit (stop loading or
+                 * crash).  The ProgressBar widget currently touches the
+                 * event loop every time the method setSelection is called.  
+                 * The workaround is to invoke Display.asyncExec() so that
+                 * the Browser does not crash when the user updates the 
+                 * selection of the ProgressBar.
+                 */
+                display.asyncExec(new class (display, listener) Runnable
+                {
+                    Display display;
+                    ProgressListener listener;
+                    
+                    this (Display display, ProgressListener listener)
+                    {
+                        this.display = display;
+                        this.listener = listener;
+                    }
+                    
+                    public void run ()
+                    {
+                        if (!display.isDisposed() && !browser.isDisposed())
+                        {
+                            listener.completed(progress);
+                        }
+                    }
+                });
+            }
+            /*
+             * Feature on Safari.  The identifier is used here as a marker for the events 
+             * related to the top frame and the URL changes related to that top frame as 
+             * they should appear on the location bar of a browser.  It is expected to reset
+             * the identifier to 0 when the event didFinishLoadingFromDataSource related to 
+             * the identifierForInitialRequest event is received.  However, Safari fires
+             * the didFinishLoadingFromDataSource event before the entire content of the
+             * top frame is loaded.  It is possible to receive multiple willSendRequest 
+             * events in this interval, causing the Browser widget to send unwanted
+             * Location.changing events.  For this reason, the identifier is reset to 0
+             * when the top frame has either finished loading (didFinishLoadForFrame
+             * event) or failed (didFailProvisionalLoadWithError).
+             */
+            identifier = 0;
+        }
+    }
+
+    void hookDOMKeyListeners (int frameID)
+    {
+        WebFrame frame = new WebFrame(frameID);
+        DOMDocument document = frame.DOMDocument();
+
+        NSString type = NSString.StringWith(DOMEVENT_KEYDOWN);
+        document.addEventListener_listener_useCapture(type, delegatee, false);
+
+        type = NSString.StringWith(DOMEVENT_KEYUP);
+        document.addEventListener_listener_useCapture(type, delegatee, false);
+    }
+
+    void hookDOMMouseListeners (int frameID)
+    {
+        WebFrame frame = new WebFrame(frameID);
+        DOMDocument document = frame.DOMDocument();
+
+        NSString type = NSString.StringWith(DOMEVENT_MOUSEDOWN);
+        document.addEventListener_listener_useCapture(type, delegatee, false);
+
+        type = NSString.StringWith(DOMEVENT_MOUSEUP);
+        document.addEventListener_listener_useCapture(type, delegatee, false);
+
+        type = NSString.StringWith(DOMEVENT_MOUSEMOVE);
+        document.addEventListener_listener_useCapture(type, delegatee, false);
+
+        type = NSString.StringWith(DOMEVENT_MOUSEWHEEL);
+        document.addEventListener_listener_useCapture(type, delegatee, false);
+    }
+
+    void webView_didReceiveTitle_forFrame (int sender, int titleID, int frameID)
+    {
+        if (frameID is webView.mainFrame().id)
+        {
+            NSString title = new NSString(titleID);
+            char[] buffer = new char[title.length()];
+            title.getCharacters_(buffer);
+            String newTitle = new String(buffer);
+            TitleEvent newEvent = new TitleEvent(browser);
+            newEvent.display = browser.getDisplay();
+            newEvent.widget = browser;
+            newEvent.title = newTitle;
+            for (int i = 0; i < titleListeners.length; i++)
+            {
+                titleListeners[i].changed(newEvent);
+            }
+        }
+    }
+
+    void webView_didStartProvisionalLoadForFrame (int sender, int frameID)
+    {
+    /* 
+     * This code is intentionally commented.  WebFrameLoadDelegate:didStartProvisionalLoadForFrame is
+     * called before WebResourceLoadDelegate:willSendRequest and
+     * WebFrameLoadDelegate:didCommitLoadForFrame.  The resource count is reset when didCommitLoadForFrame
+     * is received for the top frame.
+     */
+    //  if (frameID is webView.mainFrame().id) {
+    //      /* reset resource status variables */
+    //      resourceCount= 0;
+    //  }
+    }
+
+    void webView_didCommitLoadForFrame (int sender, int frameID)
+    {
+        WebFrame frame = new WebFrame(frameID);
+        WebDataSource dataSource = frame.dataSource();
+        NSURLRequest request = dataSource.request();
+        NSURL url = request.URL();
+        NSString s = url.absoluteString();
+        int length = s.length();
+        if (length is 0)
+            return;
+        char[] buffer = new char[length];
+        s.getCharacters_(buffer);
+        String url2 = new String(buffer);
+        /*
+         * If the URI indicates that the page is being rendered from memory
+         * (via setText()) then set it to about:blank to be consistent with IE.
+         */
+        if (url2.opEquals(URI_FROMMEMORY))
+            url2 = ABOUT_BLANK;
+
+        const Display display = browser.getDisplay();
+        bool top = frameID is webView.mainFrame().id;
+        if (top)
+        {
+            /* reset resource status variables */
+            resourceCount = 0;
+            this.url = url2;
+
+            const ProgressEvent progress = new ProgressEvent(browser);
+            progress.display = display;
+            progress.widget = browser;
+            progress.current = 1;
+            progress.total = MAX_PROGRESS;
+            for (int i = 0; i < progressListeners.length; i++)
+            {
+                const ProgressListener listener = progressListeners[i];
+                /*
+                 * Note on WebKit.  Running the event loop from a Browser
+                 * delegatee callback breaks the WebKit (stop loading or
+                 * crash).  The widget ProgressBar currently touches the
+                 * event loop every time the method setSelection is called.  
+                 * The workaround is to invoke Display.asyncexec so that
+                 * the Browser does not crash when the user updates the 
+                 * selection of the ProgressBar.
+                 */
+                display.asyncExec(new class (display, listener) Runnable
+                {
+                    Display display;
+                    ProgressListener listener;
+                    
+                    this (Display display, ProgressListener listener)
+                    {
+                        this.display = display;
+                        this.listener = listener;
+                    }
+                    
+                    public void run ()
+                    {
+                        if (!display.isDisposed() && !browser.isDisposed())
+                            listener.changed(progress);
+                    }
+                });
+            }
+
+            StatusTextEvent statusText = new StatusTextEvent(browser);
+            statusText.display = display;
+            statusText.widget = browser;
+            statusText.text = url2;
+            for (int i = 0; i < statusTextListeners.length; i++)
+            {
+                statusTextListeners[i].changed(statusText);
+            }
+        }
+        LocationEvent location = new LocationEvent(browser);
+        location.display = display;
+        location.widget = browser;
+        location.location = url2;
+        location.top = top;
+        for (int i = 0; i < locationListeners.length; i++)
+        {
+            locationListeners[i].changed(location);
+        }
+    }
+
+    /* WebResourceLoadDelegate */
+
+    void webView_resource_didFinishLoadingFromDataSource (int sender, int identifier, int dataSource)
+    {
+    /*
+     * Feature on Safari.  The identifier is used here as a marker for the events 
+     * related to the top frame and the URL changes related to that top frame as 
+     * they should appear on the location bar of a browser.  It is expected to reset
+     * the identifier to 0 when the event didFinishLoadingFromDataSource related to 
+     * the identifierForInitialRequest event is received.  However, Safari fires
+     * the didFinishLoadingFromDataSource event before the entire content of the
+     * top frame is loaded.  It is possible to receive multiple willSendRequest 
+     * events in this interval, causing the Browser widget to send unwanted
+     * Location.changing events.  For this reason, the identifier is reset to 0
+     * when the top frame has either finished loading (didFinishLoadForFrame
+     * event) or failed (didFailProvisionalLoadWithError).
+     */
+    // this code is intentionally commented
+    //if (this.identifier is identifier) this.identifier = 0;
+    }
+
+    void webView_resource_didFailLoadingWithError_fromDataSource (int sender, int identifier, int error, int dataSource)
+    {
+    /*
+     * Feature on Safari.  The identifier is used here as a marker for the events 
+     * related to the top frame and the URL changes related to that top frame as 
+     * they should appear on the location bar of a browser.  It is expected to reset
+     * the identifier to 0 when the event didFinishLoadingFromDataSource related to 
+     * the identifierForInitialRequest event is received.  However, Safari fires
+     * the didFinishLoadingFromDataSource event before the entire content of the
+     * top frame is loaded.  It is possible to receive multiple willSendRequest 
+     * events in this interval, causing the Browser widget to send unwanted
+     * Location.changing events.  For this reason, the identifier is reset to 0
+     * when the top frame has either finished loading (didFinishLoadForFrame
+     * event) or failed (didFailProvisionalLoadWithError).
+     */
+    // this code is intentionally commented
+    //if (this.identifier is identifier) this.identifier = 0;
+    }
+
+    int webView_identifierForInitialRequest_fromDataSource (int sender, int request, int dataSourceID)
+    {
+        const Display display = browser.getDisplay();
+        const ProgressEvent progress = new ProgressEvent(browser);
+        progress.display = display;
+        progress.widget = browser;
+        progress.current = resourceCount;
+        progress.total = Math.max(resourceCount, MAX_PROGRESS);
+        for (int i = 0; i < progressListeners.length; i++)
+        {
+            const ProgressListener listener = progressListeners[i];
+            /*
+             * Note on WebKit.  Running the event loop from a Browser
+             * delegatee callback breaks the WebKit (stop loading or
+             * crash).  The widget ProgressBar currently touches the
+             * event loop every time the method setSelection is called.  
+             * The workaround is to invoke Display.asyncexec so that
+             * the Browser does not crash when the user updates the 
+             * selection of the ProgressBar.
+             */
+            display.asyncExec(new class (display, listener) Runnable
+            {
+                Display display;
+                ProgressListener listener;
+                
+                this (Display display, ProgressListener listener)
+                {
+                    this.display = display;
+                    this.listener = listener;
+                }
+                
+                public void run ()
+                {
+                    if (!display.isDisposed() && !browser.isDisposed())
+                        listener.changed(progress);
+                }
+            });
+        }
+
+        NSNumber identifier = NSNumber.numberWithInt(resourceCount++);
+        if (this.identifier is 0)
+        {
+            WebDataSource dataSource = new WebDataSource(dataSourceID);
+            WebFrame frame = dataSource.webFrame();
+            if (frame.id is webView.mainFrame().id)
+                this.identifier = identifier.id;
+        }
+        return identifier.id;
+
+    }
+
+    int webView_resource_willSendRequest_redirectResponse_fromDataSource (int sender, int identifier, int request, int redirectResponse,
+            int dataSource)
+    {
+        return request;
+    }
+
+    /* handleNotification */
+
+    void handleNotification (int notification)
+    {
+    }
+
+    /* UIDelegate */
+    int webView_createWebViewWithRequest (int sender, int request)
+    {
+        WindowEvent newEvent = new WindowEvent(browser);
+        newEvent.display = browser.getDisplay();
+        newEvent.widget = browser;
+        newEvent.required = true;
+        if (openWindowListeners !is null)
+        {
+            for (int i = 0; i < openWindowListeners.length; i++)
+            {
+                openWindowListeners[i].open(newEvent);
+            }
+        }
+        Browser browser = null;
+        if (newEvent.browser !is null && cast(Safari) newEvent.browser.webBrowser)
+        {
+            browser = newEvent.browser;
+        }
+        if (browser !is null && !browser.isDisposed())
+        {
+            if (request !is 0)
+            {
+                WebFrame mainFrame = webView.mainFrame();
+                mainFrame.loadRequest(new NSURLRequest(request));
+            }
+        }
+        return webView.id;
+    }
+
+    void webViewShow (int sender)
+    {
+        /*
+         * Feature on WebKit.  The Safari WebKit expects the application
+         * to create a new Window using the Objective C Cocoa API in response
+         * to UIDelegate.createWebViewWithRequest. The application is then
+         * expected to use Objective C Cocoa API to make this window visible
+         * when receiving the UIDelegate.webViewShow message.  For some reason,
+         * a window created with the Carbon API hosting the new browser instance
+         * does not redraw until it has been resized.  The fix is to increase the
+         * size of the Shell and restore it to its initial size.
+         */
+        Shell parent = browser.getShell();
+        Point pt = parent.getSize();
+        parent.setSize(pt.x + 1, pt.y);
+        parent.setSize(pt.x, pt.y);
+        WindowEvent newEvent = new WindowEvent(browser);
+        newEvent.display = browser.getDisplay();
+        newEvent.widget = browser;
+        if (location !is null)
+            newEvent.location = location;
+        if (size !is null)
+            newEvent.size = size;
+        /*
+         * Feature in Safari.  Safari's tool bar contains
+         * the address bar.  The address bar is displayed
+         * if the tool bar is displayed. There is no separate
+         * notification for the address bar.
+         * Feature in Safari.  The menu bar is always
+         * displayed. There is no notification to hide
+         * the menu bar.
+         */
+        newEvent.addressBar = toolBar;
+        newEvent.menuBar = true;
+        newEvent.statusBar = statusBar;
+        newEvent.toolBar = toolBar;
+        for (int i = 0; i < visibilityWindowListeners.length; i++)
+        {
+            visibilityWindowListeners[i].show(newEvent);
+        }
+        location = null;
+        size = null;
+    }
+
+    void webView_setFrame (int sender, int frame)
+    {
+        float[] dest = new float[4];
+        OS.memmove(dest, frame, 16);
+        /* convert to DWT system coordinates */
+        Rectangle bounds = browser.getDisplay().getBounds();
+        location = new Point(cast(int) dest[0], bounds.height - cast(int) dest[1] - cast(int) dest[3]);
+        size = new Point(cast(int) dest[2], cast(int) dest[3]);
+    }
+
+    void webViewFocus (int sender)
+    {
+    }
+
+    void webViewUnfocus (int sender)
+    {
+    }
+
+    void webView_runJavaScriptAlertPanelWithMessage (int sender, int messageID)
+    {
+        NSString message = new NSString(messageID);
+        char[] buffer = new char[message.length()];
+        message.getCharacters_(buffer);
+        String text = new String(buffer);
+
+        MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.ICON_WARNING);
+        messageBox.setText("Javascript"); //$NON-NLS-1$
+        messageBox.setMessage(text);
+        messageBox.open();
+    }
+
+    int webView_runJavaScriptConfirmPanelWithMessage (int sender, int messageID)
+    {
+        NSString message = new NSString(messageID);
+        char[] buffer = new char[message.length()];
+        message.getCharacters_(buffer);
+        String text = new String(buffer);
+
+        MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION);
+        messageBox.setText("Javascript"); //$NON-NLS-1$
+        messageBox.setMessage(text);
+        return messageBox.open() is DWT.OK ? 1 : 0;
+    }
+
+    void webView_runOpenPanelForFileButtonWithResultListener (int sender, int resultListenerID)
+    {
+        FileDialog dialog = new FileDialog(browser.getShell(), DWT.NONE);
+        String result = dialog.open();
+        WebOpenPanelResultListener resultListener = new WebOpenPanelResultListener(resultListenerID);
+        if (result is null)
+        {
+            resultListener.cancel();
+            return;
+        }
+        resultListener.chooseFilename(NSString.StringWith(result));
+    }
+
+    void webViewClose (int sender)
+    {
+        Shell parent = browser.getShell();
+        WindowEvent newEvent = new WindowEvent(browser);
+        newEvent.display = browser.getDisplay();
+        newEvent.widget = browser;
+        for (int i = 0; i < closeWindowListeners.length; i++)
+        {
+            closeWindowListeners[i].close(newEvent);
+        }
+        browser.dispose();
+        if (parent.isDisposed())
+            return;
+        /*
+         * Feature on WebKit.  The Safari WebKit expects the application
+         * to create a new Window using the Objective C Cocoa API in response
+         * to UIDelegate.createWebViewWithRequest. The application is then
+         * expected to use Objective C Cocoa API to make this window visible
+         * when receiving the UIDelegate.webViewShow message.  For some reason,
+         * a window created with the Carbon API hosting the new browser instance
+         * does not redraw until it has been resized.  The fix is to increase the
+         * size of the Shell and restore it to its initial size.
+         */
+        Point pt = parent.getSize();
+        parent.setSize(pt.x + 1, pt.y);
+        parent.setSize(pt.x, pt.y);
+    }
+
+    int webView_contextMenuItemsForElement_defaultMenuItems (int sender, int element, int defaultMenuItems)
+    {
+        Point pt = browser.getDisplay().getCursorLocation();
+        Event event = new Event();
+        event.x = pt.x;
+        event.y = pt.y;
+        browser.notifyListeners(DWT.MenuDetect, event);
+        Menu menu = browser.getMenu();
+        if (!event.doit)
+            return 0;
+        if (menu !is null && !menu.isDisposed())
+        {
+            if (event.x !is pt.x || event.y !is pt.y)
+            {
+                menu.setLocation(event.x, event.y);
+            }
+            menu.setVisible(true);
+            return 0;
+        }
+        return defaultMenuItems;
+    }
+
+    void webView_setStatusBarVisible (int sender, int visible)
+    {
+        /* Note.  Webkit only emits the notification when the status bar should be hidden. */
+        statusBar = visible !is 0;
+    }
+
+    void webView_setStatusText (int sender, int textID)
+    {
+        NSString text = new NSString(textID);
+        int length = text.length();
+        if (length is 0)
+            return;
+        char[] buffer = new char[length];
+        text.getCharacters_(buffer);
+
+        StatusTextEvent statusText = new StatusTextEvent(browser);
+        statusText.display = browser.getDisplay();
+        statusText.widget = browser;
+        statusText.text = new String(buffer);
+        for (int i = 0; i < statusTextListeners.length; i++)
+        {
+            statusTextListeners[i].changed(statusText);
+        }
+    }
+
+    void webView_setResizable (int sender, int visible)
+    {
+    }
+
+    void webView_setToolbarsVisible (int sender, int visible)
+    {
+        /* Note.  Webkit only emits the notification when the tool bar should be hidden. */
+        toolBar = visible !is 0;
+    }
+
+    void webView_mouseDidMoveOverElement_modifierFlags (int sender, int elementInformationID, int modifierFlags)
+    {
+        if (elementInformationID is 0)
+            return;
+
+        NSString key = NSString.StringWith(WebElementLinkURLKey);
+        NSDictionary elementInformation = new NSDictionary(elementInformationID);
+        id value = elementInformation.valueForKey(key);
+        if (value is null)
+        {
+            /* not currently over a link */
+            if (lastHoveredLinkURL is null)
+                return;
+            lastHoveredLinkURL = null;
+            StatusTextEvent statusText = new StatusTextEvent(browser);
+            statusText.display = browser.getDisplay();
+            statusText.widget = browser;
+            statusText.text = ""; //$NON-NLS-1$
+            for (int i = 0; i < statusTextListeners.length; i++)
+            {
+                statusTextListeners[i].changed(statusText);
+            }
+            return;
+        }
+
+        NSString url = (new NSURL(value.id)).absoluteString();
+        int length = url.length();
+        String urlString;
+        if (length is 0)
+        {
+            urlString = ""; //$NON-NLS-1$
+        }
+        else
+        {
+            char[] buffer = new char[length];
+            url.getCharacters_(buffer);
+            urlString = new String(buffer);
+        }
+        if (urlString.opEquals(lastHoveredLinkURL))
+            return;
+
+        lastHoveredLinkURL = urlString;
+        StatusTextEvent statusText = new StatusTextEvent(browser);
+        statusText.display = browser.getDisplay();
+        statusText.widget = browser;
+        statusText.text = urlString;
+        for (int i = 0; i < statusTextListeners.length; i++)
+        {
+            statusTextListeners[i].changed(statusText);
+        }
+    }
+
+    void webView_printFrameView (int sender, int frameViewID)
+    {
+        WebFrameView view = new WebFrameView(frameViewID);
+        bool viewPrint = view.documentViewShouldHandlePrint();
+        if (viewPrint)
+        {
+            view.printDocumentView();
+            return;
+        }
+        NSPrintInfo info = NSPrintInfo.sharedPrintInfo();
+        NSPrintOperation operation = view.printOperationWithPrintInfo(info);
+        if (operation !is null)
+            operation.runOperation();
+    }
+
+    /* PolicyDelegate */
+
+    void webView_decidePolicyForMIMEType_request_frame_decisionListener (int sender, int type, int request, int frame, int listenerID)
+    {
+        bool canShow = WebView.canShowMIMEType(new NSString(type));
+        WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
+        if (canShow)
+        {
+            listener.use();
+        }
+        else
+        {
+            listener.download();
+        }
+    }
+
+    void webView_decidePolicyForNavigationAction_request_frame_decisionListener (int sender, int actionInformation, int request, int frame,
+            int listenerID)
+    {
+        NSURL url = (new NSURLRequest(request)).URL();
+        WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
+        if (url is null)
+        {
+            /* indicates that a URL with an invalid format was specified */
+            listener.ignore();
+            return;
+        }
+        NSString s = url.absoluteString();
+        char[] buffer = new char[s.length()];
+        s.getCharacters_(buffer);
+        String url2 = new String(buffer);
+        /*
+         * If the URI indicates that the page is being rendered from memory
+         * (via setText()) then set it to about:blank to be consistent with IE.
+         */
+        if (url2.opEquals(URI_FROMMEMORY))
+            url2 = ABOUT_BLANK;
+
+        LocationEvent newEvent = new LocationEvent(browser);
+        newEvent.display = browser.getDisplay();
+        newEvent.widget = browser;
+        newEvent.location = url2;
+        newEvent.doit = true;
+        if (locationListeners !is null)
+        {
+            changingLocation = true;
+            for (int i = 0; i < locationListeners.length; i++)
+            {
+                locationListeners[i].changing(newEvent);
+            }
+            changingLocation = false;
+        }
+        if (newEvent.doit)
+        {
+            listener.use();
+        }
+        else
+        {
+            listener.ignore();
+        }
+        if (html !is null && !browser.isDisposed())
+        {
+            String html = this.html;
+            this.html = null;
+            _setText(html);
+        }
+    }
+
+    void webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener (int sender, int actionInformation, int request, int frameName,
+            int listenerID)
+    {
+        WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID);
+        listener.use();
+    }
+
+    void webView_unableToImplementPolicyWithError_frame (int sender, int error, int frame)
+    {
+    }
+
+    /* WebDownload */
+
+    void download_decideDestinationWithSuggestedFilename (int downloadId, int filename)
+    {
+        NSString String = new NSString(filename);
+        char[] buffer = new char[String.length()];
+        String.getCharacters_(buffer);
+        String name = new String(buffer);
+        FileDialog dialog = new FileDialog(browser.getShell(), DWT.SAVE);
+        dialog.setText(DWT.getMessage("DWT_FileDownload")); //$NON-NLS-1$
+        dialog.setFileName(name);
+        String path = dialog.open();
+        NSURLDownload download = new NSURLDownload(downloadId);
+        if (path is null)
+        {
+            /* cancel pressed */
+            download.cancel();
+            return;
+        }
+        download.setDestination(NSString.StringWith(path), true);
+    }
+
+    /* DOMEventListener */
+
+    void handleEvent (int evtId)
+    {
+        DOMEvent evt = new DOMEvent(evtId);
+        NSString String = evt.type();
+        char[] buffer = new char[String.length()];
+        String.getCharacters_(buffer);
+        String type = new String(buffer);
+
+        if (DOMEVENT_KEYDOWN.opEquals(type) || DOMEVENT_KEYUP.opEquals(type))
+        {
+            DOMKeyboardEvent event = new DOMKeyboardEvent(evtId);
+
+            bool ctrl = event.ctrlKey();
+            bool shift = event.shiftKey();
+            bool alt = event.altKey();
+            bool meta = event.metaKey();
+            int keyCode = event.keyCode();
+            int charCode = event.charCode();
+
+            Event keyEvent = new Event();
+            keyEvent.widget = browser;
+            if (DOMEVENT_KEYDOWN.opEquals(type))
+            {
+                keyEvent.type = DWT.KeyDown;
+            }
+            else
+            {
+                keyEvent.type = DWT.KeyUp;
+            }
+            keyEvent.keyCode = translateKey(keyCode);
+            keyEvent.character = cast(char) charCode;
+            keyEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+            browser.notifyListeners(keyEvent.type, keyEvent);
+            if (!keyEvent.doit)
+            {
+                event.preventDefault();
+            }
+            return;
+        }
+
+        if (DOMEVENT_MOUSEWHEEL.opEquals(type))
+        {
+            DOMWheelEvent event = new DOMWheelEvent(evtId);
+            int clientX = event.clientX();
+            int clientY = event.clientY();
+            int delta = event.wheelDelta();
+            bool ctrl = event.ctrlKey();
+            bool shift = event.shiftKey();
+            bool alt = event.altKey();
+            bool meta = event.metaKey();
+            Event mouseEvent = new Event();
+            mouseEvent.type = DWT.MouseWheel;
+            mouseEvent.widget = browser;
+            mouseEvent.x = clientX;
+            mouseEvent.y = clientY;
+            mouseEvent.count = delta / 120;
+            mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+            browser.notifyListeners(mouseEvent.type, mouseEvent);
+            return;
+        }
+
+        /* mouse event */
+
+        DOMMouseEvent event = new DOMMouseEvent(evtId);
+
+        int clientX = event.clientX();
+        int clientY = event.clientY();
+        int detail = event.detail();
+        int button = event.button();
+        bool ctrl = event.ctrlKey();
+        bool shift = event.shiftKey();
+        bool alt = event.altKey();
+        bool meta = event.metaKey();
+
+        Event mouseEvent = new Event();
+        mouseEvent.widget = browser;
+        mouseEvent.x = clientX;
+        mouseEvent.y = clientY;
+        mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+        if (DOMEVENT_MOUSEDOWN.opEquals(type))
+        {
+            mouseEvent.type = DWT.MouseDown;
+            mouseEvent.button = button + 1;
+            mouseEvent.count = detail;
+        }
+        else if (DOMEVENT_MOUSEUP.opEquals(type))
+        {
+            mouseEvent.type = DWT.MouseUp;
+            mouseEvent.button = button + 1;
+            mouseEvent.count = detail;
+            switch (mouseEvent.button)
+            {
+                case 1:
+                    mouseEvent.stateMask |= DWT.BUTTON1;
+                break;
+                case 2:
+                    mouseEvent.stateMask |= DWT.BUTTON2;
+                break;
+                case 3:
+                    mouseEvent.stateMask |= DWT.BUTTON3;
+                break;
+                case 4:
+                    mouseEvent.stateMask |= DWT.BUTTON4;
+                break;
+                case 5:
+                    mouseEvent.stateMask |= DWT.BUTTON5;
+                break;
+            }
+        }
+        else if (DOMEVENT_MOUSEMOVE.opEquals(type))
+        {
+            /*
+             * Bug in Safari.  Spurious and redundant mousemove events are received in
+             * various contexts, including following every MouseUp.  The workaround is
+             * to not fire MouseMove events whose x and y values match the last MouseMove  
+             */
+            if (mouseEvent.x is lastMouseMoveX && mouseEvent.y is lastMouseMoveY)
+                return;
+            mouseEvent.type = DWT.MouseMove;
+            lastMouseMoveX = mouseEvent.x;
+            lastMouseMoveY = mouseEvent.y;
+        }
+
+        browser.notifyListeners(mouseEvent.type, mouseEvent);
+        if (detail is 2 && DOMEVENT_MOUSEDOWN.opEquals(type))
+        {
+            mouseEvent = new Event();
+            mouseEvent.widget = browser;
+            mouseEvent.x = clientX;
+            mouseEvent.y = clientY;
+            mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0);
+            mouseEvent.type = DWT.MouseDoubleClick;
+            mouseEvent.button = button + 1;
+            mouseEvent.count = detail;
+            browser.notifyListeners(mouseEvent.type, mouseEvent);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/SimpleEnumerator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.SimpleEnumerator;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.C;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsISimpleEnumerator;
+import dwt.internal.mozilla.nsISupports;
+
+class SimpleEnumerator {
+    XPCOMObject supports;
+    XPCOMObject simpleEnumerator;
+    int refCount = 0;
+    nsISupports[] values;
+    int index = 0;
+
+SimpleEnumerator (nsISupports[] values) {
+    this.values = values;
+    for (int i = 0; i < values.length; i++) {
+        values[i].AddRef ();
+    }
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+
+    simpleEnumerator = new XPCOMObject (new int[] {2, 0, 0, 1, 1}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return HasMoreElements (args[0]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return GetNext (args[0]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (simpleEnumerator !is null) {
+        simpleEnumerator.dispose ();
+        simpleEnumerator = null;    
+    }
+    if (values !is null) {
+        for (int i = 0; i < values.length; i++) {
+            values[i].Release ();
+        }
+        values = null;
+    }
+}
+
+int /*long*/ getAddress () {
+    return simpleEnumerator.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsISimpleEnumerator.NS_ISIMPLEENUMERATOR_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {simpleEnumerator.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+
+int HasMoreElements (int /*long*/ _retval) {
+    bool more = values !is null && index < values.length;
+    XPCOM.memmove (_retval, new int[] {more ? 1 : 0}, 4); /*PRBool */
+    return XPCOM.NS_OK;
+}   
+    
+int GetNext (int /*long*/ _retval) {
+    if (values is null || index is values.length) return XPCOM.NS_ERROR_UNEXPECTED;
+    nsISupports value = values[index++];
+    value.AddRef ();
+    XPCOM.memmove (_retval, new int /*long*/[] {value.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}       
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/StatusTextEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.StatusTextEvent;
+
+import dwt.dwthelper.string;
+import dwt.dwthelper.utils;
+import dwt.events.TypedEvent;
+import dwt.widgets.Widget;
+
+/**
+ * A <code>StatusTextEvent</code> is sent by a {@link Browser} to
+ * {@link StatusTextListener}'s when the status text is changed.
+ * The status text is typically displayed in the status bar of
+ * a browser application.
+ * 
+ * @since 3.0
+ */
+public class StatusTextEvent : TypedEvent {
+    /** status text */
+    public String text;
+
+    static const long serialVersionUID = 3258407348371600439L;
+
+    this (Widget w) {
+        super(w);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        String String = super.toString();
+        return String.substring(0, String.length() - 1) // remove trailing '}'
+        + " text=" + text + "}";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/StatusTextListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.StatusTextListener;
+
+import dwt.browser.StatusTextEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link StatusTextEvent} notification when the status text for
+ * a {@link Browser} is changed.
+ * 
+ * @see Browser#addStatusTextListener(StatusTextListener)
+ * @see Browser#removeStatusTextListener(StatusTextListener)
+ * 
+ * @since 3.0
+ */
+public interface StatusTextListener : DWTEventListener {
+
+    /**
+     * This method is called when the status text is changed. The
+     * status text is typically displayed in the status bar of a browser 
+     * application. 
+     * <p>
+     *
+     * <p>The following fields in the <code>StatusTextEvent</code> apply:
+     * <ul>
+     * <li>(in) text the modified status text
+     * <li>(in) widget the <code>Browser</code> whose status text is changed
+     * </ul>
+     * 
+     * @param event the <code>StatusTextEvent</code> that contains the updated
+     * status description of a <code>Browser</code>
+     * 
+     * @since 3.0
+     */
+    public void changed (StatusTextEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/TitleEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.TitleEvent;
+
+import dwt.dwthelper.utils;
+import dwt.dwthelper.string;
+import dwt.events.TypedEvent;
+import dwt.widgets.Widget;
+
+/**
+ * A <code>TitleEvent</code> is sent by a {@link Browser} to
+ * {@link TitleListener}'s when the title of the current document
+ * is available or when it is modified.
+ * 
+ * @since 3.0
+ */
+public class TitleEvent : TypedEvent {
+    /** the title of the current document */
+    public String title;
+
+    static const long serialVersionUID = 4121132532906340919L;
+
+    this (Widget w) {
+        super(w);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        String str = super.toString();
+        return str.substring(0, String.length() - 1) // remove trailing '}'
+        + " title=" + title + "}";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/TitleListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.TitleListener;
+
+import dwt.browser.TitleEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link TitleEvent} notification when the title of the document
+ * displayed in a {@link Browser} is known or has been changed.
+ * 
+ * @see Browser#addTitleListener(TitleListener)
+ * @see Browser#removeTitleListener(TitleListener)
+ * 
+ * @since 3.0
+ */
+public interface TitleListener : DWTEventListener {
+
+    /**
+     * This method is called when the title of the current document
+     * is available or has changed.
+     * <p>
+     *
+     * <p>The following fields in the <code>TitleEvent</code> apply:
+     * <ul>
+     * <li>(in) title the title of the current document
+     * <li>(in) widget the <code>Browser</code> whose current document's
+     * title is known or modified
+     * </ul>
+     * 
+     * @param event the <code>TitleEvent</code> that contains the title
+     * of the document currently displayed in a <code>Browser</code>
+     * 
+     * @since 3.0
+     */
+    public void changed (TitleEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/VisibilityWindowAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.VisibilityWindowAdapter;
+
+import dwt.browser.VisibilityWindowListener;
+import dwt.browser.WindowEvent;
+import dwt.dwthelper.utils;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the {@link VisibilityWindowListener} interface.
+ * <p>
+ * Classes that wish to deal with {@link WindowEvent}'s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ * 
+ * @since 3.0
+ */
+public abstract class VisibilityWindowAdapter : VisibilityWindowListener {
+
+    public void hide (WindowEvent event) {
+    }
+
+    public void show (WindowEvent event) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/VisibilityWindowListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.VisibilityWindowListener;
+
+import dwt.browser.WindowEvent;
+import dwt.dwthelper.utils;
+import dwt.internal.DWTEventListener;
+
+/** 
+ * This listener interface may be implemented in order to receive
+ * a {@link WindowEvent} notification when a window hosting a
+ * {@link Browser} needs to be displayed or hidden.
+ * 
+ * @see Browser#addVisibilityWindowListener(VisibilityWindowListener)
+ * @see Browser#removeVisibilityWindowListener(VisibilityWindowListener)
+ * @see OpenWindowListener
+ * @see CloseWindowListener
+ * 
+ * @since 3.0
+ */
+public interface VisibilityWindowListener : DWTEventListener {
+
+    /**
+     * This method is called when the window hosting a <code>Browser</code> 
+     * is requested to be hidden. Application would typically hide the
+     * {@link dwt.widgets.Shell} that hosts the <code>Browser</code>.
+     * <p>
+     *
+     * <p>The following fields in the <code>WindowEvent</code> apply:
+     * <ul>
+     * <li>(in) widget the <code>Browser</code> that needs to be hidden
+     * </ul>
+     *
+     * @param event the <code>WindowEvent</code> that specifies the
+     * <code>Browser</code> that needs to be hidden
+     * 
+     * @see dwt.widgets.Shell#setVisible(bool)
+     * 
+     * @since 3.0
+     */
+    public void hide (WindowEvent event);
+
+    /**
+     * This method is called when the window hosting a <code>Browser</code>
+     * is requested to be displayed. Application would typically set the 
+     * location and the size of the {@link dwt.widgets.Shell} 
+     * that hosts the <code>Browser</code>, if a particular location and size
+     * are specified. The application would then open that <code>Shell</code>.
+     * <p>
+     *
+     * <p>The following fields in the <code>WindowEvent</code> apply:
+     * <ul>
+     * <li>(in) widget the <code>Browser</code> to display
+     * <li>(in) location the requested location for the <code>Shell</code> 
+     * hosting the browser. It is <code>null</code> if no location is set. 
+     * <li>(in) size the requested size for the <code>Browser</code>.
+     * The client area of the <code>Shell</code> hosting the
+     * <code>Browser</code> should be large enough to accommodate that size.
+     * It is <code>null</code> if no size is set.
+     * <li>(in) addressBar <code>true</code> if the <code>Shell</code> 
+     * hosting the <code>Browser</code> should display an address bar or
+     * <code>false</code> otherwise
+     * <li>(in) menuBar <code>true</code> if the <code>Shell</code> 
+     * hosting the <code>Browser</code> should display a menu bar or
+     * <code>false</code> otherwise
+     * <li>(in) statusBar <code>true</code> if the <code>Shell</code> 
+     * hosting the <code>Browser</code> should display a status bar or
+     * <code>false</code> otherwise
+     * <li>(in) toolBar <code>true</code> if the <code>Shell</code> 
+     * hosting the <code>Browser</code> should display a tool bar or
+     * <code>false</code> otherwise
+     * </ul>
+     *
+     * @param event the <code>WindowEvent</code> that specifies the
+     * <code>Browser</code> that needs to be displayed
+     * 
+     * @see dwt.widgets.Control#setLocation(dwt.graphics.Point)
+     * @see dwt.widgets.Control#setSize(dwt.graphics.Point)
+     * @see dwt.widgets.Shell#open()
+     * 
+     * @since 3.0
+     */
+    public void show (WindowEvent event);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/WebBrowser.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,432 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.WebBrowser;
+
+import dwt.DWT;
+import dwt.browser.Browser;
+import dwt.browser.CloseWindowListener;
+import dwt.browser.LocationListener;
+import dwt.browser.OpenWindowListener;
+import dwt.browser.ProgressListener;
+import dwt.browser.StatusTextListener;
+import dwt.browser.TitleListener;
+import dwt.browser.VisibilityWindowListener;
+import dwt.dwthelper.utils;
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.System;
+import dwt.widgets.Composite;
+
+abstract class WebBrowser {
+    Browser browser;
+    CloseWindowListener[] closeWindowListeners = new CloseWindowListener[0];
+    LocationListener[] locationListeners = new LocationListener[0];
+    OpenWindowListener[] openWindowListeners = new OpenWindowListener[0];
+    ProgressListener[] progressListeners = new ProgressListener[0];
+    StatusTextListener[] statusTextListeners = new StatusTextListener[0];
+    TitleListener[] titleListeners = new TitleListener[0];
+    VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0];
+
+    static Runnable MozillaClearSessions;
+    static Runnable NativeClearSessions;
+
+    /* Key Mappings */
+    static const int[][] KeyTable = [
+        /* Keyboard and Mouse Masks */
+        [18, DWT.ALT],
+        [16, DWT.SHIFT],
+        [17, DWT.CONTROL],
+        [224, DWT.COMMAND],
+
+        /* Literal Keys */
+        [65, 'a'],
+        [66, 'b'],
+        [67, 'c'],
+        [68, 'd'],
+        [69, 'e'],
+        [70, 'f'],
+        [71, 'g'],
+        [72, 'h'],
+        [73, 'i'],
+        [74, 'j'],
+        [75, 'k'],
+        [76, 'l'],
+        [77, 'm'],
+        [78, 'n'],
+        [79, 'o'],
+        [80, 'p'],
+        [81, 'q'],
+        [82, 'r'],
+        [83, 's'],
+        [84, 't'],
+        [85, 'u'],
+        [86, 'v'],
+        [87, 'w'],
+        [88, 'x'],
+        [89, 'y'],
+        [90, 'z'],
+        [48, '0'],
+        [49, '1'],
+        [50, '2'],
+        [51, '3'],
+        [52, '4'],
+        [53, '5'],
+        [54, '6'],
+        [55, '7'],
+        [56, '8'],
+        [57, '9'],
+        [32, ' '],
+        [59, ';'],
+        [61, '='],
+        [188, ','],
+        [190, '.'],
+        [191, '/'],
+        [219, '['],
+        [221, ']'],
+        [222, '\''],
+        [192, '`'],
+        [220, '\\'],
+        [108, '|'],
+
+        /* Non-Numeric Keypad Keys */
+        [37, DWT.ARROW_LEFT],
+        [39, DWT.ARROW_RIGHT],
+        [38, DWT.ARROW_UP],
+        [40, DWT.ARROW_DOWN],
+        [45, DWT.INSERT],
+        [36, DWT.HOME],
+        [35, DWT.END],
+        [46, DWT.DEL],
+        [33, DWT.PAGE_UP],
+        [34, DWT.PAGE_DOWN],
+
+        /* Virtual and Ascii Keys */
+        [8, DWT.BS],
+        [13, DWT.CR],
+        [9, DWT.TAB],
+        [27, DWT.ESC],
+        [12, DWT.DEL],
+
+        /* Functions Keys */
+        [112, DWT.F1],
+        [113, DWT.F2],
+        [114, DWT.F3],
+        [115, DWT.F4],
+        [116, DWT.F5],
+        [117, DWT.F6],
+        [118, DWT.F7],
+        [119, DWT.F8],
+        [120, DWT.F9],
+        [121, DWT.F10],
+        [122, DWT.F11],
+        [123, DWT.F12],
+        [124, DWT.F13],
+        [125, DWT.F14],
+        [126, DWT.F15],
+        [127, 0],
+        [128, 0],
+        [129, 0],
+        [130, 0],
+        [131, 0],
+        [132, 0],
+        [133, 0],
+        [134, 0],
+        [135, 0],
+
+        /* Numeric Keypad Keys */
+        [96, DWT.KEYPAD_0],
+        [97, DWT.KEYPAD_1],
+        [98, DWT.KEYPAD_2],
+        [99, DWT.KEYPAD_3],
+        [100, DWT.KEYPAD_4],
+        [101, DWT.KEYPAD_5],
+        [102, DWT.KEYPAD_6],
+        [103, DWT.KEYPAD_7],
+        [104, DWT.KEYPAD_8],
+        [105, DWT.KEYPAD_9],
+        [14, DWT.KEYPAD_CR],
+        [107, DWT.KEYPAD_ADD],
+        [109, DWT.KEYPAD_SUBTRACT],
+        [106, DWT.KEYPAD_MULTIPLY],
+        [111, DWT.KEYPAD_DIVIDE],
+        [110, DWT.KEYPAD_DECIMAL],
+
+        /* Other keys */
+        [20, DWT.CAPS_LOCK],
+        [144, DWT.NUM_LOCK],
+        [145, DWT.SCROLL_LOCK],
+        [44, DWT.PRINT_SCREEN],
+        [6, DWT.HELP],
+        [19, DWT.PAUSE],
+        [3, DWT.BREAK],
+
+        /* Safari-specific */
+        [186, ';'],
+        [187, '='],
+        [189, '-']
+    , ];
+
+    public void addCloseWindowListener (CloseWindowListener listener) {
+        CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length + 1];
+        System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, closeWindowListeners.length);
+        closeWindowListeners = newCloseWindowListeners;
+        closeWindowListeners[closeWindowListeners.length - 1] = listener;
+    }
+
+    public void addLocationListener (LocationListener listener) {
+        LocationListener[] newLocationListeners = new LocationListener[locationListeners.length + 1];
+        System.arraycopy(locationListeners, 0, newLocationListeners, 0, locationListeners.length);
+        locationListeners = newLocationListeners;
+        locationListeners[locationListeners.length - 1] = listener;
+    }
+
+    public void addOpenWindowListener (OpenWindowListener listener) {
+        OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length + 1];
+        System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, openWindowListeners.length);
+        openWindowListeners = newOpenWindowListeners;
+        openWindowListeners[openWindowListeners.length - 1] = listener;
+    }
+
+    public void addProgressListener (ProgressListener listener) {
+        ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length + 1];
+        System.arraycopy(progressListeners, 0, newProgressListeners, 0, progressListeners.length);
+        progressListeners = newProgressListeners;
+        progressListeners[progressListeners.length - 1] = listener;
+    }
+
+    public void addStatusTextListener (StatusTextListener listener) {
+        StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length + 1];
+        System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, statusTextListeners.length);
+        statusTextListeners = newStatusTextListeners;
+        statusTextListeners[statusTextListeners.length - 1] = listener;
+    }
+
+    public void addTitleListener (TitleListener listener) {
+        TitleListener[] newTitleListeners = new TitleListener[titleListeners.length + 1];
+        System.arraycopy(titleListeners, 0, newTitleListeners, 0, titleListeners.length);
+        titleListeners = newTitleListeners;
+        titleListeners[titleListeners.length - 1] = listener;
+    }
+
+    public void addVisibilityWindowListener (VisibilityWindowListener listener) {
+        VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length + 1];
+        System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, visibilityWindowListeners.length);
+        visibilityWindowListeners = newVisibilityWindowListeners;
+        visibilityWindowListeners[visibilityWindowListeners.length - 1] = listener;
+    }
+
+    public abstract bool back ();
+
+    public static void clearSessions () {
+        if (NativeClearSessions !is null)
+            NativeClearSessions.run();
+        if (MozillaClearSessions !is null)
+            MozillaClearSessions.run();
+    }
+
+    public abstract void create (Composite parent, int style);
+
+    public abstract bool execute (String script);
+
+    public abstract bool forward ();
+
+    public abstract String getText ();
+
+    public abstract String getUrl ();
+
+    public Object getWebBrowser () {
+        return null;
+    }
+
+    public abstract bool isBackEnabled ();
+
+    public bool isFocusControl () {
+        return false;
+    }
+
+    public abstract bool isForwardEnabled ();
+
+    public abstract void refresh ();
+
+    public void removeCloseWindowListener (CloseWindowListener listener) {
+        if (closeWindowListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < closeWindowListeners.length; i++) {
+            if (listener is closeWindowListeners[i]) {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (closeWindowListeners.length is 1) {
+            closeWindowListeners = new CloseWindowListener[0];
+            return;
+        }
+        CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length - 1];
+        System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, index);
+        System.arraycopy(closeWindowListeners, index + 1, newCloseWindowListeners, index, closeWindowListeners.length - index - 1);
+        closeWindowListeners = newCloseWindowListeners;
+    }
+
+    public void removeLocationListener (LocationListener listener) {
+        if (locationListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < locationListeners.length; i++) {
+            if (listener is locationListeners[i]) {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (locationListeners.length is 1) {
+            locationListeners = new LocationListener[0];
+            return;
+        }
+        LocationListener[] newLocationListeners = new LocationListener[locationListeners.length - 1];
+        System.arraycopy(locationListeners, 0, newLocationListeners, 0, index);
+        System.arraycopy(locationListeners, index + 1, newLocationListeners, index, locationListeners.length - index - 1);
+        locationListeners = newLocationListeners;
+    }
+
+    public void removeOpenWindowListener (OpenWindowListener listener) {
+        if (openWindowListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < openWindowListeners.length; i++) {
+            if (listener is openWindowListeners[i]) {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (openWindowListeners.length is 1) {
+            openWindowListeners = new OpenWindowListener[0];
+            return;
+        }
+        OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length - 1];
+        System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, index);
+        System.arraycopy(openWindowListeners, index + 1, newOpenWindowListeners, index, openWindowListeners.length - index - 1);
+        openWindowListeners = newOpenWindowListeners;
+    }
+
+    public void removeProgressListener (ProgressListener listener) {
+        if (progressListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < progressListeners.length; i++) {
+            if (listener is progressListeners[i]) {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (progressListeners.length is 1) {
+            progressListeners = new ProgressListener[0];
+            return;
+        }
+        ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length - 1];
+        System.arraycopy(progressListeners, 0, newProgressListeners, 0, index);
+        System.arraycopy(progressListeners, index + 1, newProgressListeners, index, progressListeners.length - index - 1);
+        progressListeners = newProgressListeners;
+    }
+
+    public void removeStatusTextListener (StatusTextListener listener) {
+        if (statusTextListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < statusTextListeners.length; i++) {
+            if (listener is statusTextListeners[i]) {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (statusTextListeners.length is 1) {
+            statusTextListeners = new StatusTextListener[0];
+            return;
+        }
+        StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length - 1];
+        System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, index);
+        System.arraycopy(statusTextListeners, index + 1, newStatusTextListeners, index, statusTextListeners.length - index - 1);
+        statusTextListeners = newStatusTextListeners;
+    }
+
+    public void removeTitleListener (TitleListener listener) {
+        if (titleListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < titleListeners.length; i++) {
+            if (listener is titleListeners[i]) {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (titleListeners.length is 1) {
+            titleListeners = new TitleListener[0];
+            return;
+        }
+        TitleListener[] newTitleListeners = new TitleListener[titleListeners.length - 1];
+        System.arraycopy(titleListeners, 0, newTitleListeners, 0, index);
+        System.arraycopy(titleListeners, index + 1, newTitleListeners, index, titleListeners.length - index - 1);
+        titleListeners = newTitleListeners;
+    }
+
+    public void removeVisibilityWindowListener (VisibilityWindowListener listener) {
+        if (visibilityWindowListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < visibilityWindowListeners.length; i++) {
+            if (listener is visibilityWindowListeners[i]) {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (visibilityWindowListeners.length is 1) {
+            visibilityWindowListeners = new VisibilityWindowListener[0];
+            return;
+        }
+        VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length - 1];
+        System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, index);
+        System.arraycopy(visibilityWindowListeners, index + 1, newVisibilityWindowListeners, index, visibilityWindowListeners.length - index - 1);
+        visibilityWindowListeners = newVisibilityWindowListeners;
+    }
+
+    public void setBrowser (Browser browser) {
+        this.browser = browser;
+    }
+
+    public abstract bool setText (String html);
+
+    public abstract bool setUrl (String url);
+
+    public abstract void stop ();
+
+    int translateKey (int key) {
+        for (int i = 0; i < KeyTable.length; i++) {
+            if (KeyTable[i][0] is key)
+                return KeyTable[i][1];
+        }
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/WindowCreator2.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ *******************************************************************************/
+module dwt.browser.WindowCreator2;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.internal.C;
+import dwt.internal.Platform;
+import dwt.internal.mozilla.XPCOM;
+import dwt.internal.mozilla.XPCOMObject;
+import dwt.internal.mozilla.nsIBaseWindow;
+import dwt.internal.mozilla.nsID;
+import dwt.internal.mozilla.nsISupports;
+import dwt.internal.mozilla.nsIURI;
+import dwt.internal.mozilla.nsIWebBrowser;
+import dwt.internal.mozilla.nsIWebBrowserChrome;
+import dwt.internal.mozilla.nsIWindowCreator;
+import dwt.internal.mozilla.nsIWindowCreator2;
+import dwt.layout.FillLayout;
+import dwt.widgets.Shell;
+
+class WindowCreator2 {
+    XPCOMObject supports;
+    XPCOMObject windowCreator;
+    XPCOMObject windowCreator2;
+    int refCount = 0;
+
+WindowCreator2 () {
+    createCOMInterfaces ();
+}
+
+int AddRef () {
+    refCount++;
+    return refCount;
+}
+
+void createCOMInterfaces () {
+    /* Create each of the interfaces that this object implements */
+    supports = new XPCOMObject (new int[] {2, 0, 0}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+    };
+
+    windowCreator = new XPCOMObject (new int[] {2, 0, 0, 3}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
+    };
+
+    windowCreator2 = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) {
+        public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+        public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+        public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+        public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
+        public int /*long*/ method4 (int /*long*/[] args) {return CreateChromeWindow2 (args[0], (int)/*64*/args[1], (int)/*64*/args[2], args[3], args[4], args[5]);}
+    };
+}
+
+void disposeCOMInterfaces () {
+    if (supports !is null) {
+        supports.dispose ();
+        supports = null;
+    }   
+    if (windowCreator !is null) {
+        windowCreator.dispose ();
+        windowCreator = null;   
+    }
+
+    if (windowCreator2 !is null) {
+        windowCreator2.dispose ();
+        windowCreator2 = null;  
+    }
+}
+
+int /*long*/ getAddress () {
+    return windowCreator.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+    if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+    nsID guid = new nsID ();
+    XPCOM.memmove (guid, riid, nsID.sizeof);
+    
+    if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWindowCreator.NS_IWINDOWCREATOR_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+    if (guid.Equals (nsIWindowCreator2.NS_IWINDOWCREATOR2_IID)) {
+        XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator2.getAddress ()}, C.PTR_SIZEOF);
+        AddRef ();
+        return XPCOM.NS_OK;
+    }
+
+    XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+    return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+            
+int Release () {
+    refCount--;
+    if (refCount is 0) disposeCOMInterfaces ();
+    return refCount;
+}
+    
+/* nsIWindowCreator */
+
+int CreateChromeWindow (int /*long*/ parent, int chromeFlags, int /*long*/ _retval) {
+    return CreateChromeWindow2 (parent, chromeFlags, 0, 0, 0, _retval);
+}
+
+/* nsIWindowCreator2 */
+
+int CreateChromeWindow2 (int /*long*/ parent, int chromeFlags, int contextFlags, int /*long*/ uri, int /*long*/ cancel, int /*long*/ _retval) {
+    if (parent is 0 && (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) is 0) {
+        return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+    }
+    Browser src = null; 
+    if (parent !is 0) {
+        nsIWebBrowserChrome browserChromeParent = new nsIWebBrowserChrome (parent);
+        int /*long*/[] aWebBrowser = new int /*long*/[1];
+        int rc = browserChromeParent.GetWebBrowser (aWebBrowser);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (aWebBrowser[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+        nsIWebBrowser webBrowser = new nsIWebBrowser (aWebBrowser[0]);
+        int /*long*/[] result = new int /*long*/[1];
+        rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+        webBrowser.Release ();
+
+        nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+        result[0] = 0;
+        int /*long*/[] aParentNativeWindow = new int /*long*/[1];
+        rc = baseWindow.GetParentNativeWindow (aParentNativeWindow);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (aParentNativeWindow[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+        baseWindow.Release ();
+
+        src = Mozilla.findBrowser (aParentNativeWindow[0]);
+    }
+    final Browser browser;
+    bool doit = true;
+    if ((chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) !is 0) {
+        /*
+        * Mozilla will request a new Browser in a modal window in order to emulate a native
+        * dialog that is not available to it (eg.- a print dialog on Linux).  For this
+        * reason modal requests are handled here so that the user is not exposed to them.
+        */
+        int style = DWT.DIALOG_TRIM;
+        if ((chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) !is 0) style |= DWT.APPLICATION_MODAL; 
+        final Shell shell = src is null ?
+            new Shell (style) :
+            new Shell (src.getShell(), style);
+        shell.setLayout (new FillLayout ());
+        browser = new Browser (shell, src is null ? DWT.MOZILLA : src.getStyle () & DWT.MOZILLA);
+        browser.addVisibilityWindowListener (new VisibilityWindowListener () {
+            public void hide (WindowEvent event) {
+            }
+            public void show (WindowEvent event) {
+                if (event.location !is null) shell.setLocation (event.location);
+                if (event.size !is null) {
+                    Point size = event.size;
+                    shell.setSize (shell.computeSize (size.x, size.y));
+                }
+                shell.open ();
+            }
+        });
+        browser.addCloseWindowListener (new CloseWindowListener () {
+            public void close (WindowEvent event) {
+                shell.close ();
+            }
+        });
+        if (uri !is 0) {
+            nsIURI location = new nsIURI (uri);
+            int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+            if (location.GetSpec (aSpec) is XPCOM.NS_OK) {
+                int length = XPCOM.nsEmbedCString_Length (aSpec);
+                if (length > 0) {
+                    int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+                    byte[] dest = new byte[length];
+                    XPCOM.memmove (dest, buffer, length);
+                    browser.setUrl (new String (dest));
+                }
+            }
+            XPCOM.nsEmbedCString_delete (aSpec);
+        }
+    } else {
+        WindowEvent event = new WindowEvent (src);
+        event.display = src.getDisplay ();
+        event.widget = src;
+        event.required = true;
+        for (int i = 0; i < src.webBrowser.openWindowListeners.length; i++) {
+            src.webBrowser.openWindowListeners[i].open (event);
+        }
+        browser = event.browser;
+
+        /* Ensure that the Browser provided by the client is valid for use */ 
+        doit = browser !is null && !browser.isDisposed ();
+        if (doit) {
+            String platform = Platform.PLATFORM;
+            bool isMozillaNativePlatform = platform.equals ("gtk") || platform.equals ("motif"); //$NON-NLS-1$ //$NON-NLS-2$
+            doit = isMozillaNativePlatform || (browser.getStyle () & DWT.MOZILLA) !is 0;
+        }
+    }
+    if (doit) {
+        Mozilla mozilla = (Mozilla)browser.webBrowser;
+        mozilla.isChild = true;
+        int /*long*/ chromePtr = mozilla.webBrowserChrome.getAddress ();
+        nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (chromePtr);
+        webBrowserChrome.SetChromeFlags (chromeFlags);
+        webBrowserChrome.AddRef ();
+        XPCOM.memmove (_retval, new int /*long*/[] {chromePtr}, C.PTR_SIZEOF);
+    } else {
+        if (cancel !is 0) {
+            C.memmove (cancel, new int[] {1}, 4);   /* PRBool */
+        }
+    }
+    return doit ? XPCOM.NS_OK : XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/browser/WindowEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.browser.WindowEvent;
+
+import dwt.browser.Browser;
+import dwt.dwthelper.utils;
+import dwt.events.TypedEvent;
+import dwt.graphics.Point;
+import dwt.widgets.Widget;
+
+/**
+ * A <code>WindowEvent</code> is sent by a {@link Browser} when
+ * a new window needs to be created or when an existing window needs to be
+ * closed. This notification occurs when a javascript command such as
+ * <code>window.open</code> or <code>window.close</code> gets executed by
+ * a <code>Browser</code>.
+ *
+ * <p>
+ * The following example shows how <code>WindowEvent</code>'s are typically
+ * handled.
+ * 
+ * <code><pre>
+ *  public static void main(String[] args) {
+ *      Display display = new Display();
+ *      Shell shell = new Shell(display);
+ *      shell.setText("Main Window");
+ *      shell.setLayout(new FillLayout());
+ *      Browser browser = new Browser(shell, DWT.NONE);
+ *      initialize(display, browser);
+ *      shell.open();
+ *      browser.setUrl("http://www.eclipse.org");
+ *      while (!shell.isDisposed()) {
+ *          if (!display.readAndDispatch())
+ *              display.sleep();
+ *      }
+ *      display.dispose();
+ *  }
+ *
+ *  static void initialize(final Display display, Browser browser) {
+ *      browser.addOpenWindowListener(new OpenWindowListener() {
+ *          public void open(WindowEvent event) {
+ *              // Certain platforms can provide a default full browser.
+ *              // simply return in that case if the application prefers
+ *              // the default full browser to the embedded one set below.
+ *              if (!event.required) return;
+ *
+ *              // Embed the new window
+ *              Shell shell = new Shell(display);
+ *              shell.setText("New Window");
+ *              shell.setLayout(new FillLayout());
+ *              Browser browser = new Browser(shell, DWT.NONE);
+ *              initialize(display, browser);
+ *              event.browser = browser;
+ *          }
+ *      });
+ *      browser.addVisibilityWindowListener(new VisibilityWindowListener() {
+ *          public void hide(WindowEvent event) {
+ *              Browser browser = (Browser)event.widget;
+ *              Shell shell = browser.getShell();
+ *              shell.setVisible(false);
+ *          }
+ *          public void show(WindowEvent event) {
+ *              Browser browser = (Browser)event.widget;
+ *              Shell shell = browser.getShell();
+ *              if (event.location !is null) shell.setLocation(event.location);
+ *              if (event.size !is null) {
+ *                  Point size = event.size;
+ *                  shell.setSize(shell.computeSize(size.x, size.y));
+ *              }
+ *              if (event.addressBar || event.menuBar || event.statusBar || event.toolBar) {
+ *                  // Create widgets for the address bar, menu bar, status bar and/or tool bar
+ *                  // leave enough space in the Shell to accommodate a Browser of the size
+ *                  // given by event.size
+ *              }
+ *              shell.open();
+ *          }
+ *      });
+ *      browser.addCloseWindowListener(new CloseWindowListener() {
+ *          public void close(WindowEvent event) {
+ *              Browser browser = (Browser)event.widget;
+ *              Shell shell = browser.getShell();
+ *              shell.close();
+ *          }
+ *      });
+ *  }
+ * </pre></code>
+ * 
+ * The following notifications are emitted when the user selects a hyperlink that targets a new window
+ * or as the result of a javascript that executes window.open. 
+ * 
+ * <p>Main Browser
+ * <ul>
+ *    <li>User selects a link that opens in a new window or javascript requests a new window</li>
+ *    <li>OpenWindowListener.open() notified</li>
+ *    <ul>
+ *          <li>Application creates a new Shell and a second Browser inside that Shell</li>
+ *          <li>Application registers WindowListener's on that second Browser, such as VisibilityWindowListener</li>
+ *          <li>Application returns the second Browser as the host for the new window content</li>
+ *    </ul>
+ * </ul>
+ * 
+ * <p>Second Browser
+ * <ul>
+ *    <li>VisibilityWindowListener.show() notified</li>
+ *    <ul>
+ *          <li>Application sets navigation tool bar, status bar, menu bar and Shell size
+ *          <li>Application makes the Shell hosting the second Browser visible
+ *          <li>User now sees the new window
+ *    </ul> 
+ * </ul>
+ * 
+ * @see CloseWindowListener
+ * @see OpenWindowListener
+ * @see VisibilityWindowListener
+ * 
+ * @since 3.0
+ */
+public class WindowEvent : TypedEvent {
+
+    /** 
+     * Specifies whether the platform requires the user to provide a
+     * <code>Browser</code> to handle the new window.
+     * 
+     * @since 3.1
+     */
+    public bool required;
+
+    /** 
+     * <code>Browser</code> provided by the application.
+     */
+    public Browser browser;
+
+    /** 
+     * Requested location for the <code>Shell</code> hosting the <code>Browser</code>.
+     * It is <code>null</code> if no location has been requested.
+     */
+    public Point location;
+
+    /** 
+     * Requested <code>Browser</code> size. The client area of the <code>Shell</code> 
+     * hosting the <code>Browser</code> should be large enough to accommodate that size. 
+     * It is <code>null</code> if no size has been requested.
+     */
+    public Point size;
+
+    /**
+     * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+     * display an address bar.
+     * 
+     * @since 3.1
+     */
+    public bool addressBar;
+
+    /**
+     * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+     * display a menu bar.
+     * 
+     * @since 3.1
+     */
+    public bool menuBar;
+
+    /**
+     * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+     * display a status bar.
+     * 
+     * @since 3.1
+     */
+    public bool statusBar;
+
+    /**
+     * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+     * display a tool bar.
+     * 
+     * @since 3.1
+     */
+    public bool toolBar;
+
+    static final long serialVersionUID = 3617851997387174969L;
+
+    this (Widget w) {
+        super(w);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        String str = super.toString();
+        return str.substring(0, str.length() - 1) // remove trailing '}'
+        + " required=" + required + " browser=" + browser + " location=" + location + " size=" + size + " addressBar=" + addressBar + " menuBar=" + menuBar + " statusBar=" + statusBar + " toolBar=" + toolBar + "}";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/AnimatedProgress.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.AnimatedProgress;
+
+import dwt.DWT;
+import dwt.events.ControlAdapter;
+import dwt.events.ControlEvent;
+import dwt.events.DisposeEvent;
+import dwt.events.DisposeListener;
+import dwt.events.PaintEvent;
+import dwt.events.PaintListener;
+import dwt.graphics.Color;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.widgets.Canvas;
+import dwt.widgets.Composite;
+
+/**
+ * A control for showing progress feedback for a long running operation.
+ *
+ * @deprecated As of Eclipse 2.1, use ProgressBar with the style DWT.INDETERMINATE
+ * 
+ * <dl>
+ * <dt><b>Styles:</b><dd>VERTICAL, HORIZONTAL, BORDER
+ * </dl>
+ */
+public class AnimatedProgress : Canvas
+{
+
+    static const int SLEEP = 70;
+    static const int DEFAULT_WIDTH = 160;
+    static const int DEFAULT_HEIGHT = 18;
+    bool active = false;
+    bool showStripes = false;
+    int value;
+    int orientation = DWT.HORIZONTAL;
+    bool showBorder = false;
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * and a style value describing its behavior and appearance.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a widget which will be the parent of the new instance (cannot be null)
+     * @param style the style of widget to construct
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     *
+     * @see DWT#VERTICAL
+     * @see DWT#HORIZONTAL
+     * @see DWT#BORDER
+     * @see #getStyle()
+     */
+    public this (Composite parent, int style)
+    {
+        super(parent, checkStyle(style));
+
+        if ((style & DWT.VERTICAL) !is 0)
+        {
+            orientation = DWT.VERTICAL;
+        }
+        showBorder = (style & DWT.BORDER) !is 0;
+
+        addControlListener(new class ControlAdapter
+        {
+            public void controlResized (ControlEvent e)
+            {
+                redraw();
+            }
+        });
+        addPaintListener(new class PaintListener
+        {
+            public void paintControl (PaintEvent e)
+            {
+                paint(e);
+            }
+        });
+        addDisposeListener(new class DisposeListener
+        {
+            public void widgetDisposed (DisposeEvent e)
+            {
+                stop();
+            }
+        });
+    }
+
+    private static int checkStyle (int style)
+    {
+        int mask = DWT.NONE;
+        return style & mask;
+    }
+
+    /**
+     * Stop the animation if it is not already stopped and 
+     * reset the presentation to a blank appearance.
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public synchronized void clear ()
+    {
+        checkWidget();
+        if (active)
+            stop();
+        showStripes = false;
+        redraw();
+    }
+
+    public Point computeSize (int wHint, int hHint, bool changed)
+    {
+        checkWidget();
+        Point size = null;
+        if (orientation is DWT.HORIZONTAL)
+        {
+            size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+        }
+        else
+        {
+            size = new Point(DEFAULT_HEIGHT, DEFAULT_WIDTH);
+        }
+        if (wHint !is DWT.DEFAULT)
+            size.x = wHint;
+        if (hHint !is DWT.DEFAULT)
+            size.y = hHint;
+
+        return size;
+    }
+
+    private void drawBevelRect (GC gc, int x, int y, int w, int h,
+            Color topleft, Color bottomright)
+    {
+        gc.setForeground(topleft);
+        gc.drawLine(x, y, x + w - 1, y);
+        gc.drawLine(x, y, x, y + h - 1);
+
+        gc.setForeground(bottomright);
+        gc.drawLine(x + w, y, x + w, y + h);
+        gc.drawLine(x, y + h, x + w, y + h);
+    }
+
+    void paint (PaintEvent event)
+    {
+        GC gc = event.gc;
+        Display disp = getDisplay();
+
+        Rectangle rect = getClientArea();
+        gc.fillRectangle(rect);
+        if (showBorder)
+        {
+            drawBevelRect(gc, rect.x, rect.y, rect.width - 1, rect.height - 1,
+                    disp.getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW),
+                    disp.getSystemColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+        }
+
+        paintStripes(gc);
+    }
+
+    void paintStripes (GC gc)
+    {
+
+        if (!showStripes)
+            return;
+
+        Rectangle rect = getClientArea();
+        // Subtracted border painted by paint.
+        rect = new Rectangle(rect.x + 2, rect.y + 2, rect.width - 4,
+                rect.height - 4);
+
+        gc.setLineWidth(2);
+        gc.setClipping(rect);
+        Color color = getDisplay().getSystemColor(DWT.COLOR_LIST_SELECTION);
+        gc.setBackground(color);
+        gc.fillRectangle(rect);
+        gc.setForeground(this.getBackground());
+        int step = 12;
+        int foregroundValue = value is 0 ? step - 2 : value - 2;
+        if (orientation is DWT.HORIZONTAL)
+        {
+            int y = rect.y - 1;
+            int w = rect.width;
+            int h = rect.height + 2;
+            for (int i = 0; i < w; i += step)
+            {
+                int x = i + foregroundValue;
+                gc.drawLine(x, y, x, h);
+            }
+        }
+        else
+        {
+            int x = rect.x - 1;
+            int w = rect.width + 2;
+            int h = rect.height;
+
+            for (int i = 0; i < h; i += step)
+            {
+                int y = i + foregroundValue;
+                gc.drawLine(x, y, w, y);
+            }
+        }
+
+        if (active)
+        {
+            value = (value + 2) % step;
+        }
+    }
+
+    /**
+     * Start the animation.
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public synchronized void start ()
+    {
+        checkWidget();
+        if (active)
+            return;
+
+        active = true;
+        showStripes = true;
+
+        const Display display = getDisplay();
+        const Runnable[] timer = new Runnable[1];
+        timer[0] = new class (display) Runnable
+        {
+            Display display;
+
+            this (Display display)
+            {
+                this.display = display;
+            }
+
+            public void run ()
+            {
+                if (!active)
+                    return;
+                GC gc = new GC(this);
+                paintStripes(gc);
+                gc.dispose();
+                display.timerExec(SLEEP, timer[0]);
+            }
+        };
+        display.timerExec(SLEEP, timer[0]);
+    }
+
+    /**
+     * Stop the animation.   Freeze the presentation at its current appearance.
+     */
+    public synchronized void stop ()
+    {
+        //checkWidget();
+        active = false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/BidiSegmentEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.BidiSegmentEvent;
+
+import dwt.custom.StyledTextEvent;
+import dwt.events.TypedEvent;
+
+import dwt.dwthelper.string;
+
+/**
+ * This event is sent to BidiSegmentListeners when a line is to
+ * be measured or rendered in a bidi locale.  The segments field is 
+ * used to specify text ranges in the line that should be treated as 
+ * separate segments for bidi reordering.  Each segment will be reordered 
+ * and rendered separately.
+ * <p>
+ * The elements in the segments field specify the start offset of 
+ * a segment relative to the start of the line. They must follow
+ * the following rules:
+ * <ul>
+ * <li>first element must be 0
+ * <li>elements must be in ascending order and must not have duplicates
+ * <li>elements must not exceed the line length
+ * </ul>
+ * In addition, the last element may be set to the end of the line 
+ * but this is not required.
+ *
+ * The segments field may be left null if the entire line should 
+ * be reordered as is.
+ * </p>
+ * A BidiSegmentListener may be used when adjacent segments of 
+ * right-to-left text should not be reordered relative to each other. 
+ * For example, within a Java editor, you may wish multiple 
+ * right-to-left String literals to be reordered differently than the
+ * bidi algorithm specifies.  
+ *
+ * Example:
+ * <pre>
+ *  stored line = "R1R2R3" + "R4R5R6"
+ *      R1 to R6 are right-to-left characters. The quotation marks
+ *      are part of the line text. The line is 13 characters long.
+ * 
+ *  segments = null: 
+ *      entire line will be reordered and thus the two R2L segments 
+ *      swapped (as per the bidi algorithm). 
+ *      visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
+ * 
+ *  segments = [0, 5, 8]    
+ *      "R1R2R3" will be reordered, followed by [blank]+[blank] and 
+ *      "R4R5R6". 
+ *      visual line = "R3R2R1" + "R6R5R4"
+ * </pre>
+ */
+public class BidiSegmentEvent : TypedEvent {
+
+    /** 
+     * line start offset 
+     */
+    public int lineOffset;
+
+    /** 
+     * line text 
+     */
+    public String lineText;
+
+    /** 
+     * bidi segments, see above 
+     */
+    public int[] segments;
+
+    static final long serialVersionUID = 3257846571587547957L;
+
+    this (StyledTextEvent e) {
+        super(e);
+        lineOffset = e.detail;
+        lineText = e.text;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/BidiSegmentListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.BidiSegmentListener;
+
+import dwt.custom.BidiSegmentEvent;
+import dwt.internal.DWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * BidiSegmentEvents.
+ * @see BidiSegmentEvent
+ */
+public interface BidiSegmentListener : DWTEventListener {
+
+    /**
+     * This method is called when a line needs to be reordered for 
+     * measuring or rendering in a bidi locale. 
+     * <p>
+     * The following event fields are used:<ul>
+     * <li>event.lineOffset line start offset (input)</li>
+     * <li>event.lineText line text (input)</li>
+     * <li>event.segments text segments that should be reordered 
+     *  separately. (output)</li> 
+     * </ul>
+     *
+     * @param event the given event
+     *  separately. (output)
+     * @see BidiSegmentEvent
+     */
+    public void lineGetSegments (BidiSegmentEvent event);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/Bullet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.Bullet;
+
+import dwt.DWT;
+import dwt.custom.StyleRange;
+
+import dwt.dwthelper.string;
+import dwt.dwthelper.System;
+
+/**
+ * Instances of this class represent bullets in the <code>StyledText</code>.
+ * <p>
+ * The toHash() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see StyledText#setLineBullet(int, int, Bullet)
+ * 
+ * @since 3.2
+ */
+public class Bullet {
+    public int type;
+    public StyleRange style;
+    public String text;
+    int[] linesIndices;
+    int count;
+
+    /** 
+     * Create a new bullet the specified style, the type is set to ST.BULLET_DOT. 
+     * The style must have a glyph metrics set.
+     *
+     * @param style the style 
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT when the style or the glyph metrics are null</li>
+     * </ul> 
+     */
+    public this (StyleRange style) {
+        this(DWT.BULLET_DOT, style);
+    }
+
+    /** 
+     * Create a new bullet the specified style and type. 
+     * The style must have a glyph metrics set.
+     *
+     * @param style the style 
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT when the style or the glyph metrics are null</li>
+     * </ul> 
+     */
+    public this (int type, StyleRange style) {
+        if (style is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        if (style.metrics is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        this.type = type;
+        this.style = style;
+    }
+
+    void addIndices (int startLine, int lineCount) {
+        if (linesIndices is null) {
+            linesIndices = new int[lineCount];
+            count = lineCount;
+            for (int i = 0; i < lineCount; i++)
+                linesIndices[i] = startLine + i;
+        }
+        else {
+            int modifyStart = 0;
+            while (modifyStart < count) {
+                if (startLine <= linesIndices[modifyStart])
+                    break;
+                modifyStart++;
+            }
+            int modifyEnd = modifyStart;
+            while (modifyEnd < count) {
+                if (startLine + lineCount <= linesIndices[modifyEnd])
+                    break;
+                modifyEnd++;
+            }
+            int newSize = modifyStart + lineCount + count - modifyEnd;
+            if (newSize > linesIndices.length) {
+                int[] newLinesIndices = new int[newSize];
+                System.arraycopy(linesIndices, 0, newLinesIndices, 0, count);
+                linesIndices = newLinesIndices;
+            }
+            System.arraycopy(linesIndices, modifyEnd, linesIndices, modifyStart + lineCount, count - modifyEnd);
+            for (int i = 0; i < lineCount; i++)
+                linesIndices[modifyStart + i] = startLine + i;
+            count = newSize;
+        }
+    }
+
+    int indexOf (int lineIndex) {
+        for (int i = 0; i < count; i++) {
+            if (linesIndices[i] is lineIndex)
+                return i;
+        }
+        return -1;
+    }
+
+    public hash_t toHash () {
+        return style.toHash() ^ type;
+    }
+
+    int[] removeIndices (int startLine, int replaceLineCount, int newLineCount, bool update) {
+        if (count is 0)
+            return null;
+        if (startLine > linesIndices[count - 1])
+            return null;
+        int endLine = startLine + replaceLineCount;
+        int delta = newLineCount - replaceLineCount;
+        for (int i = 0; i < count; i++) {
+            int index = linesIndices[i];
+            if (startLine <= index) {
+                int j = i;
+                while (j < count) {
+                    if (linesIndices[j] >= endLine)
+                        break;
+                    j++;
+                }
+                if (update) {
+                    for (int k = j; k < count; k++)
+                        linesIndices[k] += delta;
+                }
+                int[] redrawLines = new int[count - j];
+                System.arraycopy(linesIndices, j, redrawLines, 0, count - j);
+                System.arraycopy(linesIndices, j, linesIndices, i, count - j);
+                count -= (j - i);
+                return redrawLines;
+            }
+        }
+        for (int i = 0; i < count; i++)
+            linesIndices[i] += delta;
+        return null;
+    }
+
+    int size () {
+        return count;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/BusyIndicator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.BusyIndicator;
+
+import dwt.DWT;
+import dwt.graphics.Cursor;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.string;
+import dwt.dwthelper.utils : Integer;
+
+/**
+ * Support for showing a Busy Cursor during a long running process.
+ */
+public class BusyIndicator {
+
+    static int nextBusyId = 1;
+    static final String BUSYID_NAME = "DWT BusyIndicator"; //$NON-NLS-1$
+    static final String BUSY_CURSOR = "DWT BusyIndicator Cursor"; //$NON-NLS-1$
+
+    /**
+     * Runs the given <code>Runnable</code> while providing
+     * busy feedback using this busy indicator.
+     * 
+     * @param display the display on which the busy feedback should be
+     *        displayed.  If the display is null, the Display for the current
+     *        thread will be used.  If there is no Display for the current thread,
+     *        the runnable code will be executed and no busy feedback will be displayed.
+     * @param runnable the runnable for which busy feedback is to be shown.
+     *        Must not be null.
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+     * </ul>
+     */
+
+    public static void showWhile (Display display, Runnable runnable) {
+        if (runnable is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        if (display is null) {
+            display = Display.getCurrent();
+            if (display is null) {
+                runnable.run();
+                return;
+            }
+        }
+
+        Integer busyId = new Integer(nextBusyId);
+        nextBusyId++;
+        Cursor cursor = display.getSystemCursor(DWT.CURSOR_WAIT);
+        Shell[] shells = display.getShells();
+        for (int i = 0; i < shells.length; i++) {
+            Integer id = cast(Integer) shells[i].getData(BUSYID_NAME);
+            if (id is null) {
+                shells[i].setCursor(cursor);
+                shells[i].setData(BUSYID_NAME, busyId);
+            }
+        }
+
+        try {
+            runnable.run();
+        }
+        finally {
+            shells = display.getShells();
+            for (int i = 0; i < shells.length; i++) {
+                Integer id = cast(Integer) shells[i].getData(BUSYID_NAME);
+                if (id is busyId) {
+                    shells[i].setCursor(null);
+                    shells[i].setData(BUSYID_NAME, null);
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CBanner.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,587 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CBanner;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Color;
+import dwt.graphics.Cursor;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Event;
+import dwt.widgets.Layout;
+import dwt.widgets.Listener;
+
+/**
+ * Instances of this class implement a Composite that lays out its
+ * children and allows programmatic control of the layout. It draws
+ * a separator between the left and right children which can be dragged
+ * to resize the right control.
+ * CBanner is used in the workbench to layout the toolbar area and
+ * perspective switching toolbar.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(None)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @since 3.0
+ */
+
+public class CBanner : Composite {
+
+    Control left;
+    Control right;
+    Control bottom;
+
+    bool simple = true;
+
+    int[] curve = new int[0];
+    int curveStart = 0;
+    Rectangle curveRect = new Rectangle(0, 0, 0, 0);
+    int curve_width = 5;
+    int curve_indent = -2;
+
+    int rightWidth = DWT.DEFAULT;
+    int rightMinWidth = 0;
+    int rightMinHeight = 0;
+    Cursor resizeCursor;
+    bool dragging = false;
+    int rightDragDisplacement = 0;
+
+    static const int OFFSCREEN = -200;
+    static const int BORDER_BOTTOM = 2;
+    static const int BORDER_TOP = 3;
+    static const int BORDER_STRIPE = 1;
+    static const int CURVE_TAIL = 200;
+    static const int BEZIER_RIGHT = 30;
+    static const int BEZIER_LEFT = 30;
+    static const int MIN_LEFT = 10;
+    static int BORDER1 = DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW;
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * and a style value describing its behavior and appearance.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a widget which will be the parent of the new instance (cannot be null)
+     * @param style the style of widget to construct
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     *
+     */
+    public this (Composite parent, int style) {
+        super(parent, checkStyle(style));
+        super.setLayout(new CBannerLayout());
+        resizeCursor = new Cursor(getDisplay(), DWT.CURSOR_SIZEWE);
+
+        Listener listener = new class Listener {
+            public void handleEvent (Event e) {
+                switch (e.type) {
+                    case DWT.Dispose:
+                        onDispose();
+                    break;
+                    case DWT.MouseDown:
+                        onMouseDown(e.x, e.y);
+                    break;
+                    case DWT.MouseExit:
+                        onMouseExit();
+                    break;
+                    case DWT.MouseMove:
+                        onMouseMove(e.x, e.y);
+                    break;
+                    case DWT.MouseUp:
+                        onMouseUp();
+                    break;
+                    case DWT.Paint:
+                        onPaint(e.gc);
+                    break;
+                    case DWT.Resize:
+                        onResize();
+                    break;
+                }
+            }
+        };
+        int[] events = new int[][DWT.Dispose , DWT.MouseDown , DWT.MouseExit , DWT.MouseMove , DWT.MouseUp , DWT.Paint , DWT.Resize];
+        for (int i = 0; i < events.length; i++) {
+            addListener(events[i], listener);
+        }
+    }
+
+    static int[] bezier (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int count) {
+        // The parametric equations for a Bezier curve for x[t] and y[t] where  0 <= t <=1 are:
+        // x[t] = x0+3(x1-x0)t+3(x0+x2-2x1)t^2+(x3-x0+3x1-3x2)t^3
+        // y[t] = y0+3(y1-y0)t+3(y0+y2-2y1)t^2+(y3-y0+3y1-3y2)t^3
+        double a0 = x0;
+        double a1 = 3 * (x1 - x0);
+        double a2 = 3 * (x0 + x2 - 2 * x1);
+        double a3 = x3 - x0 + 3 * x1 - 3 * x2;
+        double b0 = y0;
+        double b1 = 3 * (y1 - y0);
+        double b2 = 3 * (y0 + y2 - 2 * y1);
+        double b3 = y3 - y0 + 3 * y1 - 3 * y2;
+
+        int[] polygon = new int[2 * count + 2];
+        for (int i = 0; i <= count; i++) {
+            double t = cast(double) i / cast(double) count;
+            polygon[2 * i] = cast(int) (a0 + a1 * t + a2 * t * t + a3 * t * t * t);
+            polygon[2 * i + 1] = cast(int) (b0 + b1 * t + b2 * t * t + b3 * t * t * t);
+        }
+        return polygon;
+    }
+
+    static int checkStyle (int style) {
+        return DWT.NONE;
+    }
+
+    /**
+     * Returns the Control that appears on the bottom side of the banner.
+     * 
+     * @return the control that appears on the bottom side of the banner or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public Control getBottom () {
+        checkWidget();
+        return bottom;
+    }
+
+    public Rectangle getClientArea () {
+        return new Rectangle(0, 0, 0, 0);
+    }
+
+    /**
+     * Returns the Control that appears on the left side of the banner.
+     * 
+     * @return the control that appears on the left side of the banner or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public Control getLeft () {
+        checkWidget();
+        return left;
+    }
+
+    /**
+     * Returns the Control that appears on the right side of the banner.
+     * 
+     * @return the control that appears on the right side of the banner or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public Control getRight () {
+        checkWidget();
+        return right;
+    }
+
+    /**
+     * Returns the minimum size of the control that appears on the right of the banner.
+     * 
+     * @return the minimum size of the control that appears on the right of the banner
+     * 
+     * @since 3.1
+     */
+    public Point getRightMinimumSize () {
+        checkWidget();
+        return new Point(rightMinWidth, rightMinHeight);
+    }
+
+    /**
+     * Returns the width of the control that appears on the right of the banner.
+     * 
+     * @return the width of the control that appears on the right of the banner
+     * 
+     * @since 3.0
+     */
+    public int getRightWidth () {
+        checkWidget();
+        if (right is null)
+            return 0;
+        if (rightWidth is DWT.DEFAULT) {
+            Point size = right.computeSize(DWT.DEFAULT, DWT.DEFAULT, false);
+            return size.x;
+        }
+        return rightWidth;
+    }
+
+    /**
+     * Returns <code>true</code> if the CBanner is rendered
+     * with a simple, traditional shape.
+     * 
+     * @return <code>true</code> if the CBanner is rendered with a simple shape
+     * 
+     * @since 3.0
+     */
+    public bool getSimple () {
+        checkWidget();
+        return simple;
+    }
+
+    void onDispose () {
+        if (resizeCursor !is null)
+            resizeCursor.dispose();
+        resizeCursor = null;
+        left = null;
+        right = null;
+        bottom = null;
+    }
+
+    void onMouseDown (int x, int y) {
+        if (curveRect.contains(x, y)) {
+            dragging = true;
+            rightDragDisplacement = curveStart - x + curve_width - curve_indent;
+        }
+    }
+
+    void onMouseExit () {
+        if (!dragging)
+            setCursor(null);
+    }
+
+    void onMouseMove (int x, int y) {
+        if (dragging) {
+            Point size = getSize();
+            if (!(0 < x && x < size.x))
+                return;
+            rightWidth = Math.max(0, size.x - x - rightDragDisplacement);
+            if (rightMinWidth is DWT.DEFAULT) {
+                Point minSize = right.computeSize(rightMinWidth, rightMinHeight);
+                rightWidth = Math.max(minSize.x, rightWidth);
+            }
+            else {
+                rightWidth = Math.max(rightMinWidth, rightWidth);
+            }
+            layout(false);
+            return;
+        }
+        if (curveRect.contains(x, y)) {
+            setCursor(resizeCursor);
+        }
+        else {
+            setCursor(null);
+        }
+    }
+
+    void onMouseUp () {
+        dragging = false;
+    }
+
+    void onPaint (GC gc) {
+        //   Useful for debugging paint problems
+        //  {
+        //  Point size = getSize(); 
+        //  gc.setBackground(getDisplay().getSystemColor(DWT.COLOR_GREEN));
+        //  gc.fillRectangle(-10, -10, size.x+20, size.y+20);
+        //  }
+        if (left is null && right is null)
+            return;
+        Point size = getSize();
+        Color border1 = getDisplay().getSystemColor(BORDER1);
+        if (bottom !is null) {
+            int y = bottom.getBounds().y - BORDER_STRIPE - 1;
+            gc.setForeground(border1);
+            gc.drawLine(0, y, size.x, y);
+        }
+        if (left is null || right is null)
+            return;
+        int[] line1 = new int[curve.length + 6];
+        int index = 0;
+        int x = curveStart;
+        line1[index++] = x + 1;
+        line1[index++] = size.y - BORDER_STRIPE;
+        for (int i = 0; i < curve.length / 2; i++) {
+            line1[index++] = x + curve[2 * i];
+            line1[index++] = curve[2 * i + 1];
+        }
+        line1[index++] = x + curve_width;
+        line1[index++] = 0;
+        line1[index++] = size.x;
+        line1[index++] = 0;
+
+        Color background = getBackground();
+
+        if (getDisplay().getDepth() >= 15) {
+            // Anti- aliasing
+            int[] line2 = new int[line1.length];
+            index = 0;
+            for (int i = 0; i < line1.length / 2; i++) {
+                line2[index] = line1[index++] - 1;
+                line2[index] = line1[index++];
+            }
+            int[] line3 = new int[line1.length];
+            index = 0;
+            for (int i = 0; i < line1.length / 2; i++) {
+                line3[index] = line1[index++] + 1;
+                line3[index] = line1[index++];
+            }
+            RGB from = border1.getRGB();
+            RGB to = background.getRGB();
+            int red = from.red + 3 * (to.red - from.red) / 4;
+            int green = from.green + 3 * (to.green - from.green) / 4;
+            int blue = from.blue + 3 * (to.blue - from.blue) / 4;
+            Color color = new Color(getDisplay(), red, green, blue);
+            gc.setForeground(color);
+            gc.drawPolyline(line2);
+            gc.drawPolyline(line3);
+            color.dispose();
+
+            // draw tail fading to background
+            int x1 = Math.max(0, curveStart - CURVE_TAIL);
+            gc.setForeground(background);
+            gc.setBackground(border1);
+            gc.fillGradientRectangle(x1, size.y - BORDER_STRIPE, curveStart - x1 + 1, 1, false);
+        }
+        else {
+            // draw solid tail
+            int x1 = Math.max(0, curveStart - CURVE_TAIL);
+            gc.setForeground(border1);
+            gc.drawLine(x1, size.y - BORDER_STRIPE, curveStart + 1, size.y - BORDER_STRIPE);
+        }
+
+        // draw border
+        gc.setForeground(border1);
+        gc.drawPolyline(line1);
+    }
+
+    void onResize () {
+        updateCurve(getSize().y);
+    }
+
+    /**
+     * Set the control that appears on the bottom side of the banner.
+     * The bottom control is optional.  Setting the bottom control to null will remove it from 
+     * the banner - however, the creator of the control must dispose of the control.
+     * 
+     * @param control the control to be displayed on the bottom or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the bottom control was not created as a child of the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setBottom (Control control) {
+        checkWidget();
+        if (control !is null && control.getParent() !is this) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        if (bottom !is null && !bottom.isDisposed()) {
+            Point size = bottom.getSize();
+            bottom.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+        }
+        bottom = control;
+        layout(false);
+    }
+
+    /**
+     * Sets the layout which is associated with the receiver to be
+     * the argument which may be null.
+     * <p>
+     * Note: No Layout can be set on this Control because it already
+     * manages the size and position of its children.
+     * </p>
+     *
+     * @param layout the receiver's new layout or null
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setLayout (Layout layout) {
+        checkWidget();
+        return;
+    }
+
+    /**
+     * Set the control that appears on the left side of the banner.
+     * The left control is optional.  Setting the left control to null will remove it from 
+     * the banner - however, the creator of the control must dispose of the control.
+     * 
+     * @param control the control to be displayed on the left or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the left control was not created as a child of the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setLeft (Control control) {
+        checkWidget();
+        if (control !is null && control.getParent() !is this) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        if (left !is null && !left.isDisposed()) {
+            Point size = left.getSize();
+            left.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+        }
+        left = control;
+        layout(false);
+    }
+
+    /**
+     * Set the control that appears on the right side of the banner.
+     * The right control is optional.  Setting the right control to null will remove it from 
+     * the banner - however, the creator of the control must dispose of the control.
+     * 
+     * @param control the control to be displayed on the right or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the right control was not created as a child of the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setRight (Control control) {
+        checkWidget();
+        if (control !is null && control.getParent() !is this) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        if (right !is null && !right.isDisposed()) {
+            Point size = right.getSize();
+            right.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+        }
+        right = control;
+        layout(false);
+    }
+
+    /**
+     * Set the minimum height of the control that appears on the right side of the banner.
+     * 
+     * @param size the minimum size of the control on the right
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the size is null or the values of size are less than DWT.DEFAULT</li>
+     * </ul>
+     * 
+     * @since 3.1
+     */
+    public void setRightMinimumSize (Point size) {
+        checkWidget();
+        if (size is null || size.x < DWT.DEFAULT || size.y < DWT.DEFAULT)
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        rightMinWidth = size.x;
+        rightMinHeight = size.y;
+        layout(false);
+    }
+
+    /**
+     * Set the width of the control that appears on the right side of the banner.
+     * 
+     * @param width the width of the control on the right
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if width is less than DWT.DEFAULT</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setRightWidth (int width) {
+        checkWidget();
+        if (width < DWT.DEFAULT)
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        rightWidth = width;
+        layout(false);
+    }
+
+    /**
+     * Sets the shape that the CBanner will use to render itself.  
+     * 
+     * @param simple <code>true</code> if the CBanner should render itself in a simple, traditional style
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void setSimple (bool simple) {
+        checkWidget();
+        if (this.simple !is simple) {
+            this.simple = simple;
+            if (simple) {
+                curve_width = 5;
+                curve_indent = -2;
+            }
+            else {
+                curve_width = 50;
+                curve_indent = 5;
+            }
+            updateCurve(getSize().y);
+            layout(false);
+            redraw();
+        }
+    }
+
+    void updateCurve (int height) {
+        int h = height - BORDER_STRIPE;
+        if (simple) {
+            curve = new int[][0 , h , 1 , h , 2 , h - 1 , 3 , h - 2 , 3 , 2 , 4 , 1 , 5 , 0];
+        }
+        else {
+            curve = bezier(0, h + 1, BEZIER_LEFT, h + 1, curve_width - BEZIER_RIGHT, 0, curve_width, 0, curve_width);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CBannerLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CBannerLayout;
+
+import Math = tango.math.Math;
+
+import dwt.DWT;
+import dwt.custom.CBanner;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Layout;
+import dwt.widgets.Scrollable;
+
+/**
+ * This class provides the layout for CBanner
+ * 
+ * @see CBanner
+ */
+class CBannerLayout : Layout {
+
+    protected Point computeSize (Composite composite, int wHint, int hHint, bool flushCache) {
+        CBanner banner = cast(CBanner) composite;
+        Control left = banner.left;
+        Control right = banner.right;
+        Control bottom = banner.bottom;
+        bool showCurve = left !is null && right !is null;
+        int height = hHint;
+        int width = wHint;
+
+        // Calculate component sizes
+        Point bottomSize = new Point(0, 0);
+        if (bottom !is null) {
+            int trim = computeTrim(bottom);
+            int w = wHint is DWT.DEFAULT ? DWT.DEFAULT : Math.max(0, width - trim);
+            bottomSize = computeChildSize(bottom, w, DWT.DEFAULT, flushCache);
+        }
+        Point rightSize = new Point(0, 0);
+        if (right !is null) {
+            int trim = computeTrim(right);
+            int w = DWT.DEFAULT;
+            if (banner.rightWidth !is DWT.DEFAULT) {
+                w = banner.rightWidth - trim;
+                if (left !is null) {
+                    w = Math.min(w, width - banner.curve_width + 2 * banner.curve_indent - CBanner.MIN_LEFT - trim);
+                }
+                w = Math.max(0, w);
+            }
+            rightSize = computeChildSize(right, w, DWT.DEFAULT, flushCache);
+            if (wHint !is DWT.DEFAULT) {
+                width -= rightSize.x + banner.curve_width - 2 * banner.curve_indent;
+            }
+        }
+        Point leftSize = new Point(0, 0);
+        if (left !is null) {
+            int trim = computeTrim(left);
+            int w = wHint is DWT.DEFAULT ? DWT.DEFAULT : Math.max(0, width - trim);
+            leftSize = computeChildSize(left, w, DWT.DEFAULT, flushCache);
+        }
+
+        // Add up sizes
+        width = leftSize.x + rightSize.x;
+        height = bottomSize.y;
+        if (bottom !is null && (left !is null || right !is null)) {
+            height += CBanner.BORDER_STRIPE + 2;
+        }
+        if (left !is null) {
+            if (right is null) {
+                height += leftSize.y;
+            }
+            else {
+                height += Math.max(leftSize.y, banner.rightMinHeight is DWT.DEFAULT ? rightSize.y : banner.rightMinHeight);
+            }
+        }
+        else {
+            height += rightSize.y;
+        }
+        if (showCurve) {
+            width += banner.curve_width - 2 * banner.curve_indent;
+            height += CBanner.BORDER_TOP + CBanner.BORDER_BOTTOM + 2 * CBanner.BORDER_STRIPE;
+        }
+
+        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) {
+        Object data = control.getLayoutData();
+        if (data is null || !(cast(CLayoutData) data)) {
+            data = new CLayoutData();
+            control.setLayoutData(data);
+        }
+        return (cast(CLayoutData) data).computeSize(control, wHint, hHint, flushCache);
+    }
+
+    int computeTrim (Control c) {
+        if (cast(Scrollable) c) {
+            Rectangle rect = (cast(Scrollable) c).computeTrim(0, 0, 0, 0);
+            return rect.width;
+        }
+        return c.getBorderWidth() * 2;
+    }
+
+    protected bool flushCache (Control control) {
+        Object data = control.getLayoutData();
+        if (data !is null && cast(CLayoutData) data)
+            (cast(CLayoutData) data).flushCache();
+        return true;
+    }
+
+    protected void layout (Composite composite, bool flushCache) {
+        CBanner banner = cast(CBanner) composite;
+        Control left = banner.left;
+        Control right = banner.right;
+        Control bottom = banner.bottom;
+
+        Point size = banner.getSize();
+        bool showCurve = left !is null && right !is null;
+        int width = size.x - 2 * banner.getBorderWidth();
+        int height = size.y - 2 * banner.getBorderWidth();
+
+        Point bottomSize = new Point(0, 0);
+        if (bottom !is null) {
+            int trim = computeTrim(bottom);
+            int w = Math.max(0, width - trim);
+            bottomSize = computeChildSize(bottom, w, DWT.DEFAULT, flushCache);
+            height -= bottomSize.y + CBanner.BORDER_STRIPE + 2;
+        }
+        if (showCurve)
+            height -= CBanner.BORDER_TOP + CBanner.BORDER_BOTTOM + 2 * CBanner.BORDER_STRIPE;
+        height = Math.max(0, height);
+        Point rightSize = new Point(0, 0);
+        if (right !is null) {
+            int trim = computeTrim(right);
+            int w = DWT.DEFAULT;
+            if (banner.rightWidth !is DWT.DEFAULT) {
+                w = banner.rightWidth - trim;
+                if (left !is null) {
+                    w = Math.min(w, width - banner.curve_width + 2 * banner.curve_indent - CBanner.MIN_LEFT - trim);
+                }
+                w = Math.max(0, w);
+            }
+            rightSize = computeChildSize(right, w, DWT.DEFAULT, flushCache);
+            width = width - (rightSize.x - banner.curve_indent + banner.curve_width - banner.curve_indent);
+        }
+        Point leftSize = new Point(0, 0);
+        if (left !is null) {
+            int trim = computeTrim(left);
+            int w = Math.max(0, width - trim);
+            leftSize = computeChildSize(left, w, DWT.DEFAULT, flushCache);
+        }
+
+        int x = 0;
+        int y = 0;
+        int oldStart = banner.curveStart;
+        Rectangle leftRect = null;
+        Rectangle rightRect = null;
+        Rectangle bottomRect = null;
+        if (bottom !is null) {
+            bottomRect = new Rectangle(x, y + size.y - bottomSize.y, bottomSize.x, bottomSize.y);
+        }
+        if (showCurve)
+            y += CBanner.BORDER_TOP + CBanner.BORDER_STRIPE;
+        if (left !is null) {
+            leftRect = new Rectangle(x, y, leftSize.x, leftSize.y);
+            banner.curveStart = x + leftSize.x - banner.curve_indent;
+            x += leftSize.x - banner.curve_indent + banner.curve_width - banner.curve_indent;
+        }
+        if (right !is null) {
+            if (left !is null) {
+                rightSize.y = Math.max(leftSize.y, banner.rightMinHeight is DWT.DEFAULT ? rightSize.y : banner.rightMinHeight);
+            }
+            rightRect = new Rectangle(x, y, rightSize.x, rightSize.y);
+        }
+        if (banner.curveStart < oldStart) {
+            banner.redraw(banner.curveStart - CBanner.CURVE_TAIL, 0, oldStart + banner.curve_width - banner.curveStart + CBanner.CURVE_TAIL + 5,
+                    size.y, false);
+        }
+        if (banner.curveStart > oldStart) {
+            banner.redraw(oldStart - CBanner.CURVE_TAIL, 0, banner.curveStart + banner.curve_width - oldStart + CBanner.CURVE_TAIL + 5, size.y, false);
+        }
+        /*
+         * The paint events must be flushed in order to make the curve draw smoothly
+         * while the user drags the divider.
+         * On Windows, it is necessary to flush the paints before the children are 
+         * resized because otherwise the children (particularly toolbars) will flash.
+         */
+        banner.update();
+        banner.curveRect = new Rectangle(banner.curveStart, 0, banner.curve_width, size.y);
+        if (bottomRect !is null)
+            bottom.setBounds(bottomRect);
+        if (rightRect !is null)
+            right.setBounds(rightRect);
+        if (leftRect !is null)
+            left.setBounds(leftRect);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CCombo.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,2174 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CCombo;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.accessibility.ACC;
+import dwt.accessibility.AccessibleAdapter;
+import dwt.accessibility.AccessibleControlAdapter;
+import dwt.accessibility.AccessibleControlEvent;
+import dwt.accessibility.AccessibleEvent;
+import dwt.accessibility.AccessibleTextAdapter;
+import dwt.accessibility.AccessibleTextEvent;
+import dwt.events.ModifyListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.events.VerifyListener;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Button;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Label;
+import dwt.widgets.Layout;
+import dwt.widgets.List;
+import dwt.widgets.Listener;
+import dwt.widgets.Menu;
+import dwt.widgets.Shell;
+import dwt.widgets.Text;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Widget;
+
+import dwt.dwthelper.utils;
+
+/**
+ * The CCombo class represents a selectable user interface object
+ * that combines a text field and a list and issues notification
+ * when an item is selected from the list.
+ * <p>
+ * CCombo was written to work around certain limitations in the native
+ * combo box. Specifically, on win32, the height of a CCombo can be set;
+ * attempts to set the height of a Combo are ignored. CCombo can be used
+ * anywhere that having the increased flexibility is more important than
+ * getting native L&F, but the decision should not be taken lightly. 
+ * There is no is no strict requirement that CCombo look or behave
+ * the same as the native combo box.
+ * </p>
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER, READ_ONLY, FLAT</dd>
+ * <dt><b>Events:</b>
+ * <dd>DefaultSelection, Modify, Selection, Verify</dd>
+ * </dl>
+ */
+public final class CCombo : Composite
+{
+
+    Text text;
+    List list;
+    int visibleItemCount = 5;
+    Shell popup;
+    Button arrow;
+    bool hasFocus;
+    Listener listener, filter;
+    Color foreground, background;
+    Font font;
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * and a style value describing its behavior and appearance.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a widget which will be the parent of the new instance (cannot be null)
+     * @param style the style of widget to construct
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     *
+     * @see DWT#BORDER
+     * @see DWT#READ_ONLY
+     * @see DWT#FLAT
+     * @see Widget#getStyle()
+     */
+    public this (Composite parent, int style)
+    {
+        super(parent, style = checkStyle(style));
+
+        int textStyle = DWT.SINGLE;
+        if ((style & DWT.READ_ONLY) !is 0)
+            textStyle |= DWT.READ_ONLY;
+        if ((style & DWT.FLAT) !is 0)
+            textStyle |= DWT.FLAT;
+        text = new Text(this, textStyle);
+        int arrowStyle = DWT.ARROW | DWT.DOWN;
+        if ((style & DWT.FLAT) !is 0)
+            arrowStyle |= DWT.FLAT;
+        arrow = new Button(this, arrowStyle);
+
+        listener = new class Listener
+        {
+            public void handleEvent (Event event)
+            {
+                if (popup is event.widget)
+                {
+                    popupEvent(event);
+                    return;
+                }
+                if (text is event.widget)
+                {
+                    textEvent(event);
+                    return;
+                }
+                if (list is event.widget)
+                {
+                    listEvent(event);
+                    return;
+                }
+                if (arrow is event.widget)
+                {
+                    arrowEvent(event);
+                    return;
+                }
+                if (this is event.widget)
+                {
+                    comboEvent(event);
+                    return;
+                }
+                if (getShell() is event.widget)
+                {
+                    getDisplay().asyncExec(new class Runnable
+                    {
+                        public void run ()
+                        {
+                            if (isDisposed())
+                                return;
+                            handleFocus(DWT.FocusOut);
+                        }
+                    });
+                }
+            }
+        };
+        filter = new class Listener
+        {
+            public void handleEvent (Event event)
+            {
+                Shell shell = (cast(Control) event.widget).getShell();
+                if (shell is this.getShell())
+                {
+                    handleFocus(DWT.FocusOut);
+                }
+            }
+        };
+
+        int[] comboEvents = [DWT.Dispose, DWT.FocusIn, DWT.Move, DWT.Resize];
+        for (int i = 0; i < comboEvents.length; i++)
+            this.addListener(comboEvents[i], listener);
+
+        int[] textEvents = [DWT.DefaultSelection, DWT.KeyDown, DWT.KeyUp,
+                DWT.MenuDetect, DWT.Modify, DWT.MouseDown, DWT.MouseUp,
+                DWT.MouseDoubleClick, DWT.MouseWheel, DWT.Traverse,
+                DWT.FocusIn, DWT.Verify];
+        for (int i = 0; i < textEvents.length; i++)
+            text.addListener(textEvents[i], listener);
+
+        int[] arrowEvents = [DWT.MouseDown, DWT.MouseUp, DWT.Selection,
+                DWT.FocusIn];
+        for (int i = 0; i < arrowEvents.length; i++)
+            arrow.addListener(arrowEvents[i], listener);
+
+        createPopup(null, -1);
+        initAccessible();
+    }
+
+    static int checkStyle (int style)
+    {
+        int
+                mask = DWT.BORDER | DWT.READ_ONLY | DWT.FLAT | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+        return DWT.NO_FOCUS | (style & mask);
+    }
+
+    /**
+     * Adds the argument to the end of the receiver's list.
+     *
+     * @param String the new item
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the String is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see #add(String,int)
+     */
+    public void add (String str)
+    {
+        checkWidget();
+        if (str is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        list.add(str);
+    }
+
+    /**
+     * Adds the argument to the receiver's list at the given
+     * zero-relative index.
+     * <p>
+     * Note: To add an item at the end of the list, use the
+     * result of calling <code>getItemCount()</code> as the
+     * index or use <code>add(String)</code>.
+     * </p>
+     *
+     * @param String the new item
+     * @param index the index for the item
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the String is null</li>
+     *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see #add(String)
+     */
+    public void add (String str, int index)
+    {
+        checkWidget();
+        if (str is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        list.add(str, index);
+    }
+
+    /**
+     * Adds the listener to the collection of listeners who will
+     * be notified when the receiver's text is modified, by sending
+     * it one of the messages defined in the <code>ModifyListener</code>
+     * interface.
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see ModifyListener
+     * @see #removeModifyListener
+     */
+    public void addModifyListener (ModifyListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        TypedListener typedListener = new TypedListener(listener);
+        addListener(DWT.Modify, typedListener);
+    }
+
+    /**
+     * Adds the listener to the collection of listeners who will
+     * be notified when the user changes the receiver's selection, by sending
+     * it one of the messages defined in the <code>SelectionListener</code>
+     * interface.
+     * <p>
+     * <code>widgetSelected</code> is called when the combo's list selection changes.
+     * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+     * </p>
+     *
+     * @param listener the listener which should be notified when the user changes the receiver's selection
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see SelectionListener
+     * @see #removeSelectionListener
+     * @see SelectionEvent
+     */
+    public void addSelectionListener (SelectionListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        TypedListener typedListener = new TypedListener(listener);
+        addListener(DWT.Selection, typedListener);
+        addListener(DWT.DefaultSelection, typedListener);
+    }
+
+    /**
+     * Adds the listener to the collection of listeners who will
+     * be notified when the receiver's text is verified, by sending
+     * it one of the messages defined in the <code>VerifyListener</code>
+     * interface.
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see VerifyListener
+     * @see #removeVerifyListener
+     * 
+     * @since 3.3
+     */
+    public void addVerifyListener (VerifyListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        TypedListener typedListener = new TypedListener(listener);
+        addListener(DWT.Verify, typedListener);
+    }
+
+    void arrowEvent (Event event)
+    {
+        switch (event.type)
+        {
+            case DWT.FocusIn:
+            {
+                handleFocus(DWT.FocusIn);
+                break;
+            }
+            case DWT.MouseDown:
+            {
+                Event mouseEvent = new Event();
+                mouseEvent.button = event.button;
+                mouseEvent.count = event.count;
+                mouseEvent.stateMask = event.stateMask;
+                mouseEvent.time = event.time;
+                mouseEvent.x = event.x;
+                mouseEvent.y = event.y;
+                notifyListeners(DWT.MouseDown, mouseEvent);
+                event.doit = mouseEvent.doit;
+                break;
+            }
+            case DWT.MouseUp:
+            {
+                Event mouseEvent = new Event();
+                mouseEvent.button = event.button;
+                mouseEvent.count = event.count;
+                mouseEvent.stateMask = event.stateMask;
+                mouseEvent.time = event.time;
+                mouseEvent.x = event.x;
+                mouseEvent.y = event.y;
+                notifyListeners(DWT.MouseUp, mouseEvent);
+                event.doit = mouseEvent.doit;
+                break;
+            }
+            case DWT.Selection:
+            {
+                text.setFocus();
+                dropDown(!isDropped());
+                break;
+            }
+
+            default:
+            break;
+        }
+    }
+
+    /**
+     * Sets the selection in the receiver's text field to an empty
+     * selection starting just before the first character. If the
+     * text field is editable, this has the effect of placing the
+     * i-beam at the start of the text.
+     * <p>
+     * Note: To clear the selected items in the receiver's list, 
+     * use <code>deselectAll()</code>.
+     * </p>
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see #deselectAll
+     */
+    public void clearSelection ()
+    {
+        checkWidget();
+        text.clearSelection();
+        list.deselectAll();
+    }
+
+    void comboEvent (Event event)
+    {
+        switch (event.type)
+        {
+            case DWT.Dispose:
+                if (popup !is null && !popup.isDisposed())
+                {
+                    list.removeListener(DWT.Dispose, listener);
+                    popup.dispose();
+                }
+                Shell shell = getShell();
+                shell.removeListener(DWT.Deactivate, listener);
+                Display display = getDisplay();
+                display.removeFilter(DWT.FocusIn, filter);
+                popup = null;
+                text = null;
+                list = null;
+                arrow = null;
+            break;
+            case DWT.FocusIn:
+                Control focusControl = getDisplay().getFocusControl();
+                if (focusControl is arrow || focusControl is list)
+                    return;
+                if (isDropped())
+                {
+                    list.setFocus();
+                }
+                else
+                {
+                    text.setFocus();
+                }
+            break;
+            case DWT.Move:
+                dropDown(false);
+            break;
+            case DWT.Resize:
+                internalLayout(false);
+            break;
+
+            default:
+            break;
+        }
+    }
+
+    public Point computeSize (int wHint, int hHint, bool changed)
+    {
+        checkWidget();
+        int width = 0, height = 0;
+        String[] items = list.getItems();
+        GC gc = new GC(text);
+        int spacer = gc.StringExtent(" ").x; //$NON-NLS-1$
+        int textWidth = gc.StringExtent(text.getText()).x;
+        for (int i = 0; i < items.length; i++)
+        {
+            textWidth = Math.max(gc.StringExtent(items[i]).x, textWidth);
+        }
+        gc.dispose();
+        Point textSize = text.computeSize(DWT.DEFAULT, DWT.DEFAULT, changed);
+        Point arrowSize = arrow.computeSize(DWT.DEFAULT, DWT.DEFAULT, changed);
+        Point listSize = list.computeSize(DWT.DEFAULT, DWT.DEFAULT, changed);
+        int borderWidth = getBorderWidth();
+
+        height = Math.max(textSize.y, arrowSize.y);
+        width = Math.max(
+                textWidth + 2 * spacer + arrowSize.x + 2 * borderWidth,
+                listSize.x);
+        if (wHint !is DWT.DEFAULT)
+            width = wHint;
+        if (hHint !is DWT.DEFAULT)
+            height = hHint;
+        return new Point(width + 2 * borderWidth, height + 2 * borderWidth);
+    }
+
+    /**
+     * Copies the selected text.
+     * <p>
+     * The current selection is copied to the clipboard.
+     * </p>
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.3
+     */
+    public void copy ()
+    {
+        checkWidget();
+        text.copy();
+    }
+
+    void createPopup (String[] items, int selectionIndex)
+    {
+        // create shell and list
+        popup = new Shell(getShell(), DWT.NO_TRIM | DWT.ON_TOP);
+        int style = getStyle();
+        int listStyle = DWT.SINGLE | DWT.V_SCROLL;
+        if ((style & DWT.FLAT) !is 0)
+            listStyle |= DWT.FLAT;
+        if ((style & DWT.RIGHT_TO_LEFT) !is 0)
+            listStyle |= DWT.RIGHT_TO_LEFT;
+        if ((style & DWT.LEFT_TO_RIGHT) !is 0)
+            listStyle |= DWT.LEFT_TO_RIGHT;
+        list = new List(popup, listStyle);
+        if (font !is null)
+            list.setFont(font);
+        if (foreground !is null)
+            list.setForeground(foreground);
+        if (background !is null)
+            list.setBackground(background);
+
+        int[] popupEvents = [DWT.Close, DWT.Paint, DWT.Deactivate];
+        for (int i = 0; i < popupEvents.length; i++)
+            popup.addListener(popupEvents[i], listener);
+        int[] listEvents = [DWT.MouseUp, DWT.Selection, DWT.Traverse,
+                DWT.KeyDown, DWT.KeyUp, DWT.FocusIn, DWT.Dispose];
+        for (int i = 0; i < listEvents.length; i++)
+            list.addListener(listEvents[i], listener);
+
+        if (items !is null)
+            list.setItems(items);
+        if (selectionIndex !is -1)
+            list.setSelection(selectionIndex);
+    }
+
+    /**
+     * Cuts the selected text.
+     * <p>
+     * The current selection is first copied to the
+     * clipboard and then deleted from the widget.
+     * </p>
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.3
+     */
+    public void cut ()
+    {
+        checkWidget();
+        text.cut();
+    }
+
+    /**
+     * Deselects the item at the given zero-relative index in the receiver's 
+     * list.  If the item at the index was already deselected, it remains
+     * deselected. Indices that are out of range are ignored.
+     *
+     * @param index the index of the item to deselect
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void deselect (int index)
+    {
+        checkWidget();
+        if (0 <= index && index < list.getItemCount() && index is list.getSelectionIndex() && text.getText().opEquals(
+                list.getItem(index)))
+        {
+            text.setText(""); //$NON-NLS-1$
+            list.deselect(index);
+        }
+    }
+
+    /**
+     * Deselects all selected items in the receiver's list.
+     * <p>
+     * Note: To clear the selection in the receiver's text field,
+     * use <code>clearSelection()</code>.
+     * </p>
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see #clearSelection
+     */
+    public void deselectAll ()
+    {
+        checkWidget();
+        text.setText(""); //$NON-NLS-1$
+        list.deselectAll();
+    }
+
+    void dropDown (bool drop)
+    {
+        if (drop is isDropped())
+            return;
+        if (!drop)
+        {
+            popup.setVisible(false);
+            if (!isDisposed() && isFocusControl())
+            {
+                text.setFocus();
+            }
+            return;
+        }
+
+        if (getShell() !is popup.getParent())
+        {
+            String[] items = list.getItems();
+            int selectionIndex = list.getSelectionIndex();
+            list.removeListener(DWT.Dispose, listener);
+            popup.dispose();
+            popup = null;
+            list = null;
+            createPopup(items, selectionIndex);
+        }
+
+        Point size = getSize();
+        int itemCount = list.getItemCount();
+        itemCount = (itemCount is 0) ? visibleItemCount : Math.min(
+                visibleItemCount, itemCount);
+        int itemHeight = list.getItemHeight() * itemCount;
+        Point listSize = list.computeSize(DWT.DEFAULT, itemHeight, false);
+        list.setBounds(1, 1, Math.max(size.x - 2, listSize.x), listSize.y);
+
+        int index = list.getSelectionIndex();
+        if (index !is -1)
+            list.setTopIndex(index);
+        Display display = getDisplay();
+        Rectangle listRect = list.getBounds();
+        Rectangle parentRect = display.map(getParent(), null, getBounds());
+        Point comboSize = getSize();
+        Rectangle displayRect = getMonitor().getClientArea();
+        int width = Math.max(comboSize.x, listRect.width + 2);
+        int height = listRect.height + 2;
+        int x = parentRect.x;
+        int y = parentRect.y + comboSize.y;
+        if (y + height > displayRect.y + displayRect.height)
+            y = parentRect.y - height;
+        if (x + width > displayRect.x + displayRect.width)
+            x = displayRect.x + displayRect.width - listRect.width;
+        popup.setBounds(x, y, width, height);
+        popup.setVisible(true);
+        if (isFocusControl())
+            list.setFocus();
+    }
+
+    /*
+     * Return the lowercase of the first non-'&' character following
+     * an '&' character in the given String. If there are no '&'
+     * characters in the given String, return '\0'.
+     */
+    char _findMnemonic (String str)
+    {
+        if (str is null)
+            return '\0';
+        int index = 0;
+        int length = str.length();
+        do
+        {
+            while (index < length && str.charAt(index) !is '&')
+                index++;
+            if (++index >= length)
+                return '\0';
+            if (str.charAt(index) !is '&')
+                return CharacterToLower(string.charAt(index));
+            index++;
+        } while (index < length);
+        return '\0';
+    }
+
+    /* 
+     * Return the Label immediately preceding the receiver in the z-order, 
+     * or null if none. 
+     */
+    Label getAssociatedLabel ()
+    {
+        Control[] siblings = getParent().getChildren();
+        for (int i = 0; i < siblings.length; i++)
+        {
+            if (siblings[i] is this)
+            {
+                if (i > 0 && cast(Label) (siblings[i - 1]))
+                {
+                    return cast(Label) (siblings[i - 1]);
+                }
+            }
+        }
+        return null;
+    }
+
+    public Control[] getChildren ()
+    {
+        checkWidget();
+        return new Control[0];
+    }
+
+    /**
+     * Gets the editable state.
+     *
+     * @return whether or not the receiver is editable
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public bool getEditable ()
+    {
+        checkWidget();
+        return text.getEditable();
+    }
+
+    /**
+     * Returns the item at the given, zero-relative index in the
+     * receiver's list. Throws an exception if the index is out
+     * of range.
+     *
+     * @param index the index of the item to return
+     * @return the item at the given index
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public String getItem (int index)
+    {
+        checkWidget();
+        return list.getItem(index);
+    }
+
+    /**
+     * Returns the number of items contained in the receiver's list.
+     *
+     * @return the number of items
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public int getItemCount ()
+    {
+        checkWidget();
+        return list.getItemCount();
+    }
+
+    /**
+     * Returns the height of the area which would be used to
+     * display <em>one</em> of the items in the receiver's list.
+     *
+     * @return the height of one item
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public int getItemHeight ()
+    {
+        checkWidget();
+        return list.getItemHeight();
+    }
+
+    /**
+     * Returns an array of <code>String</code>s which are the items
+     * in the receiver's list. 
+     * <p>
+     * Note: This is not the actual structure used by the receiver
+     * to maintain its list of items, so modifying the array will
+     * not affect the receiver. 
+     * </p>
+     *
+     * @return the items in the receiver's list
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public String[] getItems ()
+    {
+        checkWidget();
+        return list.getItems();
+    }
+
+    /**
+     * Returns <code>true</code> if the receiver's list is visible,
+     * and <code>false</code> otherwise.
+     * <p>
+     * If one of the receiver's ancestors is not visible or some
+     * other condition makes the receiver not visible, this method
+     * may still indicate that it is considered visible even though
+     * it may not actually be showing.
+     * </p>
+     *
+     * @return the receiver's list's visibility state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.4
+     */
+    public bool getListVisible ()
+    {
+        checkWidget();
+        return isDropped();
+    }
+
+    public Menu getMenu ()
+    {
+        return text.getMenu();
+    }
+
+    /**
+     * Returns a <code>Point</code> whose x coordinate is the start
+     * of the selection in the receiver's text field, and whose y
+     * coordinate is the end of the selection. The returned values
+     * are zero-relative. An "empty" selection as indicated by
+     * the the x and y coordinates having the same value.
+     *
+     * @return a point representing the selection start and end
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public Point getSelection ()
+    {
+        checkWidget();
+        return text.getSelection();
+    }
+
+    /**
+     * Returns the zero-relative index of the item which is currently
+     * selected in the receiver's list, or -1 if no item is selected.
+     *
+     * @return the index of the selected item
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public int getSelectionIndex ()
+    {
+        checkWidget();
+        return list.getSelectionIndex();
+    }
+
+    public int getStyle ()
+    {
+        int style = super.getStyle();
+        style &= ~DWT.READ_ONLY;
+        if (!text.getEditable())
+            style |= DWT.READ_ONLY;
+        return style;
+    }
+
+    /**
+     * Returns a String containing a copy of the contents of the
+     * receiver's text field.
+     *
+     * @return the receiver's text
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public String getText ()
+    {
+        checkWidget();
+        return text.getText();
+    }
+
+    /**
+     * Returns the height of the receivers's text field.
+     *
+     * @return the text height
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public int getTextHeight ()
+    {
+        checkWidget();
+        return text.getLineHeight();
+    }
+
+    /**
+     * Returns the maximum number of characters that the receiver's
+     * text field is capable of holding. If this has not been changed
+     * by <code>setTextLimit()</code>, it will be the constant
+     * <code>Combo.LIMIT</code>.
+     * 
+     * @return the text limit
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public int getTextLimit ()
+    {
+        checkWidget();
+        return text.getTextLimit();
+    }
+
+    /**
+     * Gets the number of items that are visible in the drop
+     * down portion of the receiver's list.
+     *
+     * @return the number of items that are visible
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public int getVisibleItemCount ()
+    {
+        checkWidget();
+        return visibleItemCount;
+    }
+
+    void handleFocus (int type)
+    {
+        if (isDisposed())
+            return;
+        switch (type)
+        {
+            case DWT.FocusIn:
+            {
+                if (hasFocus)
+                    return;
+                if (getEditable())
+                    text.selectAll();
+                hasFocus = true;
+                Shell shell = getShell();
+                shell.removeListener(DWT.Deactivate, listener);
+                shell.addListener(DWT.Deactivate, listener);
+                Display display = getDisplay();
+                display.removeFilter(DWT.FocusIn, filter);
+                display.addFilter(DWT.FocusIn, filter);
+                Event e = new Event();
+                notifyListeners(DWT.FocusIn, e);
+                break;
+            }
+            case DWT.FocusOut:
+            {
+                if (!hasFocus)
+                    return;
+                Control focusControl = getDisplay().getFocusControl();
+                if (focusControl is arrow || focusControl is list || focusControl is text)
+                    return;
+                hasFocus = false;
+                Shell shell = getShell();
+                shell.removeListener(DWT.Deactivate, listener);
+                Display display = getDisplay();
+                display.removeFilter(DWT.FocusIn, filter);
+                Event e = new Event();
+                notifyListeners(DWT.FocusOut, e);
+                break;
+            }
+
+            default:
+            break;
+        }
+    }
+
+    /**
+     * Searches the receiver's list starting at the first item
+     * (index 0) until an item is found that is equal to the 
+     * argument, and returns the index of that item. If no item
+     * is found, returns -1.
+     *
+     * @param String the search item
+     * @return the index of the item
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the String is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public int indexOf (String String)
+    {
+        checkWidget();
+        if (String is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        return list.indexOf(String);
+    }
+
+    /**
+     * Searches the receiver's list starting at the given, 
+     * zero-relative index until an item is found that is equal
+     * to the argument, and returns the index of that item. If
+     * no item is found or the starting index is out of range,
+     * returns -1.
+     *
+     * @param String the search item
+     * @param start the zero-relative index at which to begin the search
+     * @return the index of the item
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the String is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public int indexOf (String String, int start)
+    {
+        checkWidget();
+        if (String is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        return list.indexOf(String, start);
+    }
+
+    void initAccessible ()
+    {
+        AccessibleAdapter accessibleAdapter = new class AccessibleAdapter
+        {
+            public void getName (AccessibleEvent e)
+            {
+                String name = null;
+                Label label = getAssociatedLabel();
+                if (label !is null)
+                {
+                    name = stripMnemonic(label.getText());
+                }
+                e.result = name;
+            }
+
+            public void getKeyboardShortcut (AccessibleEvent e)
+            {
+                String shortcut = null;
+                Label label = getAssociatedLabel();
+                if (label !is null)
+                {
+                    String text = label.getText();
+                    if (text !is null)
+                    {
+                        char mnemonic = _findMnemonic(text);
+                        if (mnemonic !is '\0')
+                        {
+                            shortcut = "Alt+" + mnemonic; //$NON-NLS-1$
+            }
+        }
+    }
+    e.result = shortcut;
+}
+
+public void getHelp (AccessibleEvent e)
+{
+    e.result = getToolTipText();
+}
+}       ;
+        getAccessible().addAccessibleListener(accessibleAdapter);
+        text.getAccessible().addAccessibleListener(accessibleAdapter);
+        list.getAccessible().addAccessibleListener(accessibleAdapter);
+
+        arrow.getAccessible().addAccessibleListener(
+                new class AccessibleAdapter
+                {
+                    public void getName (AccessibleEvent e)
+                    {
+                        e.result = isDropped() ? DWT.getMessage("DWT_Close") : DWT.getMessage(
+                                "DWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+                    }
+
+                    public void getKeyboardShortcut (AccessibleEvent e)
+                    {
+                        e.result = "Alt+Down Arrow"; //$NON-NLS-1$
+                    }
+
+                    public void getHelp (AccessibleEvent e)
+                    {
+                        e.result = getToolTipText();
+                    }
+                });
+
+        getAccessible().addAccessibleTextListener(new class
+                AccessibleTextAdapter
+        {
+            public void getCaretOffset (AccessibleTextEvent e)
+            {
+                e.offset = text.getCaretPosition();
+            }
+
+            public void getSelectionRange (AccessibleTextEvent e)
+            {
+                Point sel = text.getSelection();
+                e.offset = sel.x;
+                e.length = sel.y - sel.x;
+            }
+        });
+
+        getAccessible().addAccessibleControlListener(new class
+                AccessibleControlAdapter
+        {
+            public void getChildAtPoint (AccessibleControlEvent e)
+            {
+                Point testPoint = toControl(e.x, e.y);
+                if (getBounds().contains(testPoint))
+                {
+                    e.childID = ACC.CHILDID_SELF;
+                }
+            }
+
+            public void getLocation (AccessibleControlEvent e)
+            {
+                Rectangle location = getBounds();
+                Point pt = getParent().toDisplay(location.x, location.y);
+                e.x = pt.x;
+                e.y = pt.y;
+                e.width = location.width;
+                e.height = location.height;
+            }
+
+            public void getChildCount (AccessibleControlEvent e)
+            {
+                e.detail = 0;
+            }
+
+            public void getRole (AccessibleControlEvent e)
+            {
+                e.detail = ACC.ROLE_COMBOBOX;
+            }
+
+            public void getState (AccessibleControlEvent e)
+            {
+                e.detail = ACC.STATE_NORMAL;
+            }
+
+            public void getValue (AccessibleControlEvent e)
+            {
+                e.result = getText();
+            }
+        });
+
+        text.getAccessible().addAccessibleControlListener(new class
+                AccessibleControlAdapter
+        {
+            public void getRole (AccessibleControlEvent e)
+            {
+                e.detail = text.getEditable() ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
+            }
+        });
+
+        arrow.getAccessible().addAccessibleControlListener(
+                new class AccessibleControlAdapter
+                {
+                    public void getDefaultAction (AccessibleControlEvent e)
+                    {
+                        e.result = isDropped() ? DWT.getMessage("DWT_Close") : DWT.getMessage(
+                                "DWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+                    }
+                });
+    }
+
+    bool isDropped ()
+    {
+        return popup.getVisible();
+    }
+
+    public bool isFocusControl ()
+    {
+        checkWidget();
+        if (text.isFocusControl() || arrow.isFocusControl() || list.isFocusControl() || popup.isFocusControl())
+        {
+            return true;
+        }
+        return super.isFocusControl();
+    }
+
+    void internalLayout (bool changed)
+    {
+        if (isDropped())
+            dropDown(false);
+        Rectangle rect = getClientArea();
+        int width = rect.width;
+        int height = rect.height;
+        Point arrowSize = arrow.computeSize(DWT.DEFAULT, height, changed);
+        text.setBounds(0, 0, width - arrowSize.x, height);
+        arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
+    }
+
+    void listEvent (Event event)
+    {
+        switch (event.type)
+        {
+            case DWT.Dispose:
+                if (getShell() !is popup.getParent())
+                {
+                    String[] items = list.getItems();
+                    int selectionIndex = list.getSelectionIndex();
+                    popup = null;
+                    list = null;
+                    createPopup(items, selectionIndex);
+                }
+            break;
+            case DWT.FocusIn:
+            {
+                handleFocus(DWT.FocusIn);
+                break;
+            }
+            case DWT.MouseUp:
+            {
+                if (event.button !is 1)
+                    return;
+                dropDown(false);
+                break;
+            }
+            case DWT.Selection:
+            {
+                int index = list.getSelectionIndex();
+                if (index is -1)
+                    return;
+                text.setText(list.getItem(index));
+                text.selectAll();
+                list.setSelection(index);
+                Event e = new Event();
+                e.time = event.time;
+                e.stateMask = event.stateMask;
+                e.doit = event.doit;
+                notifyListeners(DWT.Selection, e);
+                event.doit = e.doit;
+                break;
+            }
+            case DWT.Traverse:
+            {
+                switch (event.detail)
+                {
+                    case DWT.TRAVERSE_RETURN:
+                    case DWT.TRAVERSE_ESCAPE:
+                    case DWT.TRAVERSE_ARROW_PREVIOUS:
+                    case DWT.TRAVERSE_ARROW_NEXT:
+                        event.doit = false;
+                    break;
+                    case DWT.TRAVERSE_TAB_NEXT:
+                    case DWT.TRAVERSE_TAB_PREVIOUS:
+                        event.doit = text.traverse(event.detail);
+                        event.detail = DWT.TRAVERSE_NONE;
+                        if (event.doit)
+                            dropDown(false);
+                        return;
+                }
+                Event e = new Event();
+                e.time = event.time;
+                e.detail = event.detail;
+                e.doit = event.doit;
+                e.character = event.character;
+                e.keyCode = event.keyCode;
+                notifyListeners(DWT.Traverse, e);
+                event.doit = e.doit;
+                event.detail = e.detail;
+                break;
+            }
+            case DWT.KeyUp:
+            {
+                Event e = new Event();
+                e.time = event.time;
+                e.character = event.character;
+                e.keyCode = event.keyCode;
+                e.stateMask = event.stateMask;
+                notifyListeners(DWT.KeyUp, e);
+                break;
+            }
+            case DWT.KeyDown:
+            {
+                if (event.character is DWT.ESC)
+                {
+                    // Escape key cancels popup list
+                    dropDown(false);
+                }
+                if ((event.stateMask & DWT.ALT) !is 0 && (event.keyCode is DWT.ARROW_UP || event.keyCode is DWT.ARROW_DOWN))
+                {
+                    dropDown(false);
+                }
+                if (event.character is DWT.CR)
+                {
+                    // Enter causes default selection
+                    dropDown(false);
+                    Event e = new Event();
+                    e.time = event.time;
+                    e.stateMask = event.stateMask;
+                    notifyListeners(DWT.DefaultSelection, e);
+                }
+                // At this point the widget may have been disposed.
+                // If so, do not continue.
+                if (isDisposed())
+                    break;
+                Event e = new Event();
+                e.time = event.time;
+                e.character = event.character;
+                e.keyCode = event.keyCode;
+                e.stateMask = event.stateMask;
+                notifyListeners(DWT.KeyDown, e);
+                break;
+
+            }
+
+            default:
+            break;
+        }
+    }
+
+    /**
+     * Pastes text from clipboard.
+     * <p>
+     * The selected text is deleted from the widget
+     * and new text inserted from the clipboard.
+     * </p>
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.3
+     */
+    public void paste ()
+    {
+        checkWidget();
+        text.paste();
+    }
+
+    void popupEvent (Event event)
+    {
+        switch (event.type)
+        {
+            case DWT.Paint:
+                // draw black rectangle around list
+                Rectangle listRect = list.getBounds();
+                Color black = getDisplay().getSystemColor(DWT.COLOR_BLACK);
+                event.gc.setForeground(black);
+                event.gc.drawRectangle(0, 0, listRect.width + 1,
+                        listRect.height + 1);
+            break;
+            case DWT.Close:
+                event.doit = false;
+                dropDown(false);
+            break;
+            case DWT.Deactivate:
+                /*
+                 * Bug in GTK. When the arrow button is pressed the popup control receives a
+                 * deactivate event and then the arrow button receives a selection event. If 
+                 * we hide the popup in the deactivate event, the selection event will show 
+                 * it again. To prevent the popup from showing again, we will let the selection 
+                 * event of the arrow button hide the popup.
+                 * In Windows, hiding the popup during the deactivate causes the deactivate 
+                 * to be called twice and the selection event to be disappear.
+                 */
+                if (!"carbon".opEquals(DWT.getPlatform()))
+                {
+                    Point point = arrow.toControl(
+                            getDisplay().getCursorLocation());
+                    Point size = arrow.getSize();
+                    Rectangle rect = new Rectangle(0, 0, size.x, size.y);
+                    if (!rect.contains(point))
+                        dropDown(false);
+                }
+                else
+                {
+                    dropDown(false);
+                }
+            break;
+
+            default:
+            break;
+        }
+    }
+
+    public void redraw ()
+    {
+        super.redraw();
+        text.redraw();
+        arrow.redraw();
+        if (popup.isVisible())
+            list.redraw();
+    }
+
+    public void redraw (int x, int y, int width, int height, bool all)
+    {
+        super.redraw(x, y, width, height, true);
+    }
+
+    /**
+     * Removes the item from the receiver's list at the given
+     * zero-relative index.
+     *
+     * @param index the index for the item
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void remove (int index)
+    {
+        checkWidget();
+        list.remove(index);
+    }
+
+    /**
+     * Removes the items from the receiver's list which are
+     * between the given zero-relative start and end 
+     * indices (inclusive).
+     *
+     * @param start the start of the range
+     * @param end the end of the range
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void remove (int start, int end)
+    {
+        checkWidget();
+        list.remove(start, end);
+    }
+
+    /**
+     * Searches the receiver's list starting at the first item
+     * until an item is found that is equal to the argument, 
+     * and removes that item from the list.
+     *
+     * @param String the item to remove
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the String is null</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the String is not found in the list</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void remove (String String)
+    {
+        checkWidget();
+        if (String is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        list.remove(String);
+    }
+
+    /**
+     * Removes all of the items from the receiver's list and clear the
+     * contents of receiver's text field.
+     * <p>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void removeAll ()
+    {
+        checkWidget();
+        text.setText(""); //$NON-NLS-1$
+        list.removeAll();
+    }
+
+    /**
+     * Removes the listener from the collection of listeners who will
+     * be notified when the receiver's text is modified.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see ModifyListener
+     * @see #addModifyListener
+     */
+    public void removeModifyListener (ModifyListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        removeListener(DWT.Modify, listener);
+    }
+
+    /**
+     * Removes the listener from the collection of listeners who will
+     * be notified when the user changes the receiver's selection.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see SelectionListener
+     * @see #addSelectionListener
+     */
+    public void removeSelectionListener (SelectionListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        removeListener(DWT.Selection, listener);
+        removeListener(DWT.DefaultSelection, listener);
+    }
+
+    /**
+     * Removes the listener from the collection of listeners who will
+     * be notified when the control is verified.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see VerifyListener
+     * @see #addVerifyListener
+     * 
+     * @since 3.3
+     */
+    public void removeVerifyListener (VerifyListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        removeListener(DWT.Verify, listener);
+    }
+
+    /**
+     * Selects the item at the given zero-relative index in the receiver's 
+     * list.  If the item at the index was already selected, it remains
+     * selected. Indices that are out of range are ignored.
+     *
+     * @param index the index of the item to select
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void select (int index)
+    {
+        checkWidget();
+        if (index is -1)
+        {
+            list.deselectAll();
+            text.setText(""); //$NON-NLS-1$
+            return;
+        }
+        if (0 <= index && index < list.getItemCount())
+        {
+            if (index !is getSelectionIndex())
+            {
+                text.setText(list.getItem(index));
+                text.selectAll();
+                list.select(index);
+                list.showSelection();
+            }
+        }
+    }
+
+    public void setBackground (Color color)
+    {
+        super.setBackground(color);
+        background = color;
+        if (text !is null)
+            text.setBackground(color);
+        if (list !is null)
+            list.setBackground(color);
+        if (arrow !is null)
+            arrow.setBackground(color);
+    }
+
+    /**
+     * Sets the editable state.
+     *
+     * @param editable the new editable state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setEditable (bool editable)
+    {
+        checkWidget();
+        text.setEditable(editable);
+    }
+
+    public void setEnabled (bool enabled)
+    {
+        super.setEnabled(enabled);
+        if (popup !is null)
+            popup.setVisible(false);
+        if (text !is null)
+            text.setEnabled(enabled);
+        if (arrow !is null)
+            arrow.setEnabled(enabled);
+    }
+
+    public bool setFocus ()
+    {
+        checkWidget();
+        if (!isEnabled() || !isVisible())
+            return false;
+        if (isFocusControl())
+            return true;
+        return text.setFocus();
+    }
+
+    public void setFont (Font font)
+    {
+        super.setFont(font);
+        this.font = font;
+        text.setFont(font);
+        list.setFont(font);
+        internalLayout(true);
+    }
+
+    public void setForeground (Color color)
+    {
+        super.setForeground(color);
+        foreground = color;
+        if (text !is null)
+            text.setForeground(color);
+        if (list !is null)
+            list.setForeground(color);
+        if (arrow !is null)
+            arrow.setForeground(color);
+    }
+
+    /**
+     * Sets the text of the item in the receiver's list at the given
+     * zero-relative index to the String argument. This is equivalent
+     * to <code>remove</code>'ing the old item at the index, and then
+     * <code>add</code>'ing the new item at that index.
+     *
+     * @param index the index for the item
+     * @param String the new text for the item
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+     *    <li>ERROR_NULL_ARGUMENT - if the String is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setItem (int index, String String)
+    {
+        checkWidget();
+        list.setItem(index, String);
+    }
+
+    /**
+     * Sets the receiver's list to be the given array of items.
+     *
+     * @param items the array of items
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setItems (String[] items)
+    {
+        checkWidget();
+        list.setItems(items);
+        if (!text.getEditable())
+            text.setText(""); //$NON-NLS-1$
+    }
+
+    /**
+     * Sets the layout which is associated with the receiver to be
+     * the argument which may be null.
+     * <p>
+     * Note: No Layout can be set on this Control because it already
+     * manages the size and position of its children.
+     * </p>
+     *
+     * @param layout the receiver's new layout or null
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setLayout (Layout layout)
+    {
+        checkWidget();
+        return;
+    }
+
+    /**
+     * Marks the receiver's list as visible if the argument is <code>true</code>,
+     * and marks it invisible otherwise.
+     * <p>
+     * If one of the receiver's ancestors is not visible or some
+     * other condition makes the receiver not visible, marking
+     * it visible may not actually cause it to be displayed.
+     * </p>
+     *
+     * @param visible the new visibility state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.4
+     */
+    public void setListVisible (bool visible)
+    {
+        checkWidget();
+        dropDown(visible);
+    }
+
+    public void setMenu (Menu menu)
+    {
+        text.setMenu(menu);
+    }
+
+    /**
+     * Sets the selection in the receiver's text field to the
+     * range specified by the argument whose x coordinate is the
+     * start of the selection and whose y coordinate is the end
+     * of the selection. 
+     *
+     * @param selection a point representing the new selection start and end
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setSelection (Point selection)
+    {
+        checkWidget();
+        if (selection is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        text.setSelection(selection.x, selection.y);
+    }
+
+    /**
+     * Sets the contents of the receiver's text field to the
+     * given String.
+     * <p>
+     * Note: The text field in a <code>Combo</code> is typically
+     * only capable of displaying a single line of text. Thus,
+     * setting the text to a String containing line breaks or
+     * other special characters will probably cause it to 
+     * display incorrectly.
+     * </p>
+     *
+     * @param String the new text
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the String is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setText (String String)
+    {
+        checkWidget();
+        if (String is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        int index = list.indexOf(String);
+        if (index is -1)
+        {
+            list.deselectAll();
+            text.setText(String);
+            return;
+        }
+        text.setText(String);
+        text.selectAll();
+        list.setSelection(index);
+        list.showSelection();
+    }
+
+    /**
+     * Sets the maximum number of characters that the receiver's
+     * text field is capable of holding to be the argument.
+     *
+     * @param limit new text limit
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setTextLimit (int limit)
+    {
+        checkWidget();
+        text.setTextLimit(limit);
+    }
+
+    public void setToolTipText (String String)
+    {
+        checkWidget();
+        super.setToolTipText(String);
+        arrow.setToolTipText(String);
+        text.setToolTipText(String);
+    }
+
+    public void setVisible (bool visible)
+    {
+        super.setVisible(visible);
+        /* 
+         * At this point the widget may have been disposed in a FocusOut event.
+         * If so then do not continue.
+         */
+        if (isDisposed())
+            return;
+        if (!visible)
+            popup.setVisible(false);
+    }
+
+    /**
+     * Sets the number of items that are visible in the drop
+     * down portion of the receiver's list.
+     *
+     * @param count the new number of items to be visible
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setVisibleItemCount (int count)
+    {
+        checkWidget();
+        if (count < 0)
+            return;
+        visibleItemCount = count;
+    }
+
+    String stripMnemonic (String String)
+    {
+        int index = 0;
+        int length = String.length();
+        do
+        {
+            while ((index < length) && (String.charAt(index) !is '&'))
+                index++;
+            if (++index >= length)
+                return String;
+            if (String.charAt(index) !is '&')
+            {
+                return String.substring(0, index - 1) + String.substring(index,
+                        length);
+            }
+            index++;
+        } while (index < length);
+        return String;
+    }
+
+    void textEvent (Event event)
+    {
+        switch (event.type)
+        {
+            case DWT.FocusIn:
+            {
+                handleFocus(DWT.FocusIn);
+                break;
+            }
+            case DWT.DefaultSelection:
+            {
+                dropDown(false);
+                Event e = new Event();
+                e.time = event.time;
+                e.stateMask = event.stateMask;
+                notifyListeners(DWT.DefaultSelection, e);
+                break;
+            }
+            case DWT.KeyDown:
+            {
+                Event keyEvent = new Event();
+                keyEvent.time = event.time;
+                keyEvent.character = event.character;
+                keyEvent.keyCode = event.keyCode;
+                keyEvent.stateMask = event.stateMask;
+                notifyListeners(DWT.KeyDown, keyEvent);
+                if (isDisposed())
+                    break;
+                event.doit = keyEvent.doit;
+                if (!event.doit)
+                    break;
+                if (event.keyCode is DWT.ARROW_UP || event.keyCode is DWT.ARROW_DOWN)
+                {
+                    event.doit = false;
+                    if ((event.stateMask & DWT.ALT) !is 0)
+                    {
+                        bool dropped = isDropped();
+                        text.selectAll();
+                        if (!dropped)
+                            setFocus();
+                        dropDown(!dropped);
+                        break;
+                    }
+
+                    int oldIndex = getSelectionIndex();
+                    if (event.keyCode is DWT.ARROW_UP)
+                    {
+                        select(Math.max(oldIndex - 1, 0));
+                    }
+                    else
+                    {
+                        select(Math.min(oldIndex + 1, getItemCount() - 1));
+                    }
+                    if (oldIndex !is getSelectionIndex())
+                    {
+                        Event e = new Event();
+                        e.time = event.time;
+                        e.stateMask = event.stateMask;
+                        notifyListeners(DWT.Selection, e);
+                    }
+                    if (isDisposed())
+                        break;
+                }
+
+                // Further work : Need to add support for incremental search in 
+                // pop up list as characters typed in text widget
+                break;
+            }
+            case DWT.KeyUp:
+            {
+                Event e = new Event();
+                e.time = event.time;
+                e.character = event.character;
+                e.keyCode = event.keyCode;
+                e.stateMask = event.stateMask;
+                notifyListeners(DWT.KeyUp, e);
+                event.doit = e.doit;
+                break;
+            }
+            case DWT.MenuDetect:
+            {
+                Event e = new Event();
+                e.time = event.time;
+                notifyListeners(DWT.MenuDetect, e);
+                break;
+            }
+            case DWT.Modify:
+            {
+                list.deselectAll();
+                Event e = new Event();
+                e.time = event.time;
+                notifyListeners(DWT.Modify, e);
+                break;
+            }
+            case DWT.MouseDown:
+            {
+                Event mouseEvent = new Event();
+                mouseEvent.button = event.button;
+                mouseEvent.count = event.count;
+                mouseEvent.stateMask = event.stateMask;
+                mouseEvent.time = event.time;
+                mouseEvent.x = event.x;
+                mouseEvent.y = event.y;
+                notifyListeners(DWT.MouseDown, mouseEvent);
+                if (isDisposed())
+                    break;
+                event.doit = mouseEvent.doit;
+                if (!event.doit)
+                    break;
+                if (event.button !is 1)
+                    return;
+                if (text.getEditable())
+                    return;
+                bool dropped = isDropped();
+                text.selectAll();
+                if (!dropped)
+                    setFocus();
+                dropDown(!dropped);
+                break;
+            }
+            case DWT.MouseUp:
+            {
+                Event mouseEvent = new Event();
+                mouseEvent.button = event.button;
+                mouseEvent.count = event.count;
+                mouseEvent.stateMask = event.stateMask;
+                mouseEvent.time = event.time;
+                mouseEvent.x = event.x;
+                mouseEvent.y = event.y;
+                notifyListeners(DWT.MouseUp, mouseEvent);
+                if (isDisposed())
+                    break;
+                event.doit = mouseEvent.doit;
+                if (!event.doit)
+                    break;
+                if (event.button !is 1)
+                    return;
+                if (text.getEditable())
+                    return;
+                text.selectAll();
+                break;
+            }
+            case DWT.MouseDoubleClick:
+            {
+                Event mouseEvent = new Event();
+                mouseEvent.button = event.button;
+                mouseEvent.count = event.count;
+                mouseEvent.stateMask = event.stateMask;
+                mouseEvent.time = event.time;
+                mouseEvent.x = event.x;
+                mouseEvent.y = event.y;
+                notifyListeners(DWT.MouseDoubleClick, mouseEvent);
+                break;
+            }
+            case DWT.MouseWheel:
+            {
+                Event keyEvent = new Event();
+                keyEvent.time = event.time;
+                keyEvent.keyCode = event.count > 0 ? DWT.ARROW_UP : DWT.ARROW_DOWN;
+                keyEvent.stateMask = event.stateMask;
+                notifyListeners(DWT.KeyDown, keyEvent);
+                if (isDisposed())
+                    break;
+                event.doit = keyEvent.doit;
+                if (!event.doit)
+                    break;
+                if (event.count !is 0)
+                {
+                    event.doit = false;
+                    int oldIndex = getSelectionIndex();
+                    if (event.count > 0)
+                    {
+                        select(Math.max(oldIndex - 1, 0));
+                    }
+                    else
+                    {
+                        select(Math.min(oldIndex + 1, getItemCount() - 1));
+                    }
+                    if (oldIndex !is getSelectionIndex())
+                    {
+                        Event e = new Event();
+                        e.time = event.time;
+                        e.stateMask = event.stateMask;
+                        notifyListeners(DWT.Selection, e);
+                    }
+                    if (isDisposed())
+                        break;
+                }
+                break;
+            }
+            case DWT.Traverse:
+            {
+                switch (event.detail)
+                {
+                    case DWT.TRAVERSE_ARROW_PREVIOUS:
+                    case DWT.TRAVERSE_ARROW_NEXT:
+                        // The enter causes default selection and
+                        // the arrow keys are used to manipulate the list contents so
+                        // do not use them for traversal.
+                        event.doit = false;
+                    break;
+                    case DWT.TRAVERSE_TAB_PREVIOUS:
+                        event.doit = traverse(DWT.TRAVERSE_TAB_PREVIOUS);
+                        event.detail = DWT.TRAVERSE_NONE;
+                        return;
+                }
+                Event e = new Event();
+                e.time = event.time;
+                e.detail = event.detail;
+                e.doit = event.doit;
+                e.character = event.character;
+                e.keyCode = event.keyCode;
+                notifyListeners(DWT.Traverse, e);
+                event.doit = e.doit;
+                event.detail = e.detail;
+                break;
+            }
+            case DWT.Verify:
+            {
+                Event e = new Event();
+                e.text = event.text;
+                e.start = event.start;
+                e.end = event.end;
+                e.character = event.character;
+                e.keyCode = event.keyCode;
+                e.stateMask = event.stateMask;
+                notifyListeners(DWT.Verify, e);
+                event.doit = e.doit;
+                break;
+            }
+
+            default:
+            break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CLabel.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1040 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CLabel;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.accessibility.ACC;
+import dwt.accessibility.Accessible;
+import dwt.accessibility.AccessibleAdapter;
+import dwt.accessibility.AccessibleControlAdapter;
+import dwt.accessibility.AccessibleControlEvent;
+import dwt.accessibility.AccessibleEvent;
+import dwt.events.DisposeEvent;
+import dwt.events.DisposeListener;
+import dwt.events.PaintEvent;
+import dwt.events.PaintListener;
+import dwt.events.TraverseEvent;
+import dwt.events.TraverseListener;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.graphics.TextLayout;
+import dwt.widgets.Canvas;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Display;
+
+import dwt.dwthelper.utils;
+
+/**
+ * A Label which supports aligned text and/or an image and different border styles.
+ * <p>
+ * If there is not enough space a CLabel uses the following strategy to fit the 
+ * information into the available space:
+ * <pre>
+ *      ignores the indent in left align mode
+ *      ignores the image and the gap
+ *      shortens the text by replacing the center portion of the label with an ellipsis
+ *      shortens the text by removing the center portion of the label
+ * </pre>
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>LEFT, RIGHT, CENTER, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b>
+ * <dd></dd>
+ * </dl>
+ * 
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class CLabel : Canvas
+{
+
+    /** Gap between icon and text */
+    private static const int GAP = 5;
+    /** Left and right margins */
+    private static const int INDENT = 3;
+    /** a String inserted in the middle of text that has been shortened */
+    private static const String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"
+    /** the alignnment. Either CENTER, RIGHT, LEFT. Default is LEFT*/
+    private int alignn = DWT.LEFT;
+    private int hIndent = INDENT;
+    private int vIndent = INDENT;
+    /** the current text */
+    private String text;
+    /** the current icon */
+    private Image image;
+    // The tooltip is used for two purposes - the application can set
+    // a tooltip or the tooltip can be used to display the full text when the
+    // the text has been truncated due to the label being too short.
+    // The appToolTip stores the tooltip set by the application.  Control.tooltiptext 
+    // contains whatever tooltip is currently being displayed.
+    private String appToolTipText;
+
+    private Image backgroundImage;
+    private Color[] gradientColors;
+    private int[] gradientPercents;
+    private bool gradientVertical;
+    private Color background;
+
+    private static int
+            DRAW_FLAGS = DWT.DRAW_MNEMONIC | DWT.DRAW_TAB | DWT.DRAW_TRANSPARENT | DWT.DRAW_DELIMITER;
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * and a style value describing its behavior and appearance.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a widget which will be the parent of the new instance (cannot be null)
+     * @param style the style of widget to construct
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     *
+     * @see DWT#LEFT
+     * @see DWT#RIGHT
+     * @see DWT#CENTER
+     * @see DWT#SHADOW_IN
+     * @see DWT#SHADOW_OUT
+     * @see DWT#SHADOW_NONE
+     * @see #getStyle()
+     */
+    public this (Composite parent, int style)
+    {
+        super(parent, checkStyle(style));
+        if ((style & (DWT.CENTER | DWT.RIGHT)) is 0)
+            style |= DWT.LEFT;
+        if ((style & DWT.CENTER) !is 0)
+            alignn = DWT.CENTER;
+        if ((style & DWT.RIGHT) !is 0)
+            alignn = DWT.RIGHT;
+        if ((style & DWT.LEFT) !is 0)
+            alignn = DWT.LEFT;
+
+        addPaintListener(new class PaintListener
+        {
+            public void paintControl (PaintEvent event)
+            {
+                onPaint(event);
+            }
+        });
+
+        addDisposeListener(new class DisposeListener
+        {
+            public void widgetDisposed (DisposeEvent event)
+            {
+                onDispose(event);
+            }
+        });
+
+        addTraverseListener(new class TraverseListener
+        {
+            public void keyTraversed (TraverseEvent event)
+            {
+                if (event.detail is DWT.TRAVERSE_MNEMONIC)
+                {
+                    onMnemonic(event);
+                }
+            }
+        });
+
+        initAccessible();
+
+    }
+
+    /**
+     * Check the style bits to ensure that no invalid styles are applied.
+     */
+    private static int checkStyle (int style)
+    {
+        if ((style & DWT.BORDER) !is 0)
+            style |= DWT.SHADOW_IN;
+        int
+                mask = DWT.SHADOW_IN | DWT.SHADOW_OUT | DWT.SHADOW_NONE | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+        style = style & mask;
+        return style |= DWT.NO_FOCUS | DWT.DOUBLE_BUFFERED;
+    }
+
+    //protected void checkSubclass () {
+    //  String name = getClass().getName ();
+    //  String validName = CLabel.class.getName();
+    //  if (!validName.opEquals(name)) {
+    //      DWT.error (DWT.ERROR_INVALID_SUBCLASS);
+    //  }
+    //}
+
+    public Point computeSize (int wHint, int hHint, bool changed)
+    {
+        checkWidget();
+        Point e = getTotalSize(image, text);
+        if (wHint is DWT.DEFAULT)
+        {
+            e.x += 2 * hIndent;
+        }
+        else
+        {
+            e.x = wHint;
+        }
+        if (hHint is DWT.DEFAULT)
+        {
+            e.y += 2 * vIndent;
+        }
+        else
+        {
+            e.y = hHint;
+        }
+        return e;
+    }
+
+    /**
+     * Draw a rectangle in the given colors.
+     */
+    private void drawBevelRect (GC gc, int x, int y, int w, int h,
+            Color topleft, Color bottomright)
+    {
+        gc.setForeground(bottomright);
+        gc.drawLine(x + w, y, x + w, y + h);
+        gc.drawLine(x, y + h, x + w, y + h);
+
+        gc.setForeground(topleft);
+        gc.drawLine(x, y, x + w - 1, y);
+        gc.drawLine(x, y, x, y + h - 1);
+    }
+
+    /*
+     * Return the lowercase of the first non-'&' character following
+     * an '&' character in the given String. If there are no '&'
+     * characters in the given String, return '\0'.
+     */
+    char _findMnemonic (String str)
+    {
+        if (str is null)
+            return '\0';
+        int index = 0;
+        int length = str.length();
+        do
+        {
+            while (index < length && str.charAt(index) !is '&')
+                index++;
+            if (++index >= length)
+                return '\0';
+            if (str.charAt(index) !is '&')
+                return CharacterToLower(str.charAt(index));
+            index++;
+        } while (index < length);
+        return '\0';
+    }
+
+    /**
+     * Returns the alignnment.
+     * The alignnment style (LEFT, CENTER or RIGHT) is returned.
+     * 
+     * @return DWT.LEFT, DWT.RIGHT or DWT.CENTER
+     */
+    public int getAlignment ()
+    {
+        //checkWidget();
+        return alignn;
+    }
+
+    /**
+     * Return the CLabel's image or <code>null</code>.
+     * 
+     * @return the image of the label or null
+     */
+    public Image getImage ()
+    {
+        //checkWidget();
+        return image;
+    }
+
+    /**
+     * Compute the minimum size.
+     */
+    private Point getTotalSize (Image image, String text)
+    {
+        Point size = new Point(0, 0);
+
+        if (image !is null)
+        {
+            Rectangle r = image.getBounds();
+            size.x += r.width;
+            size.y += r.height;
+        }
+
+        GC gc = new GC(this);
+        if (text !is null && text.length() > 0)
+        {
+            Point e = gc.textExtent(text, DRAW_FLAGS);
+            size.x += e.x;
+            size.y = Math.max(size.y, e.y);
+            if (image !is null)
+                size.x += GAP;
+        }
+        else
+        {
+            size.y = Math.max(size.y, gc.getFontMetrics().getHeight());
+        }
+        gc.dispose();
+
+        return size;
+    }
+
+    public int getStyle ()
+    {
+        int style = super.getStyle();
+        switch (alignn)
+        {
+            case DWT.RIGHT:
+                style |= DWT.RIGHT;
+            break;
+            case DWT.CENTER:
+                style |= DWT.CENTER;
+            break;
+            case DWT.LEFT:
+                style |= DWT.LEFT;
+            break;
+        }
+        return style;
+    }
+
+    /**
+     * Return the Label's text.
+     * 
+     * @return the text of the label or null
+     */
+    public String getText ()
+    {
+        //checkWidget();
+        return text;
+    }
+
+    public String getToolTipText ()
+    {
+        checkWidget();
+        return appToolTipText;
+    }
+
+    private void initAccessible ()
+    {
+        Accessible accessible = getAccessible();
+        accessible.addAccessibleListener(new class AccessibleAdapter
+        {
+            public void getName (AccessibleEvent e)
+            {
+                e.result = getText();
+            }
+
+            public void getHelp (AccessibleEvent e)
+            {
+                e.result = getToolTipText();
+            }
+
+            public void getKeyboardShortcut (AccessibleEvent e)
+            {
+                char mnemonic = _findMnemonic(this.text);
+                if (mnemonic !is '\0')
+                {
+                    e.result = "Alt+" + mnemonic; //$NON-NLS-1$
+            }
+        }
+    }   );
+
+        accessible.addAccessibleControlListener(new class
+                AccessibleControlAdapter
+        {
+            public void getChildAtPoint (AccessibleControlEvent e)
+            {
+                e.childID = ACC.CHILDID_SELF;
+            }
+
+            public void getLocation (AccessibleControlEvent e)
+            {
+                Rectangle rect = getDisplay().map(getParent(), null,
+                        getBounds());
+                e.x = rect.x;
+                e.y = rect.y;
+                e.width = rect.width;
+                e.height = rect.height;
+            }
+
+            public void getChildCount (AccessibleControlEvent e)
+            {
+                e.detail = 0;
+            }
+
+            public void getRole (AccessibleControlEvent e)
+            {
+                e.detail = ACC.ROLE_LABEL;
+            }
+
+            public void getState (AccessibleControlEvent e)
+            {
+                e.detail = ACC.STATE_READONLY;
+            }
+        });
+    }
+
+    void onDispose (DisposeEvent event)
+    {
+        gradientColors = null;
+        gradientPercents = null;
+        backgroundImage = null;
+        text = null;
+        image = null;
+        appToolTipText = null;
+    }
+
+    void onMnemonic (TraverseEvent event)
+    {
+        char mnemonic = _findMnemonic(text);
+        if (mnemonic is '\0')
+            return;
+        if (CharacterToLower(event.character) !is mnemonic)
+            return;
+        Composite control = this.getParent();
+        while (control !is null)
+        {
+            Control[] children = control.getChildren();
+            int index = 0;
+            while (index < children.length)
+            {
+                if (children[index] is this)
+                    break;
+                index++;
+            }
+            index++;
+            if (index < children.length)
+            {
+                if (children[index].setFocus())
+                {
+                    event.doit = true;
+                    event.detail = DWT.TRAVERSE_NONE;
+                }
+            }
+            control = control.getParent();
+        }
+    }
+
+    void onPaint (PaintEvent event)
+    {
+        Rectangle rect = getClientArea();
+        if (rect.width is 0 || rect.height is 0)
+            return;
+
+        bool shortenText = false;
+        String t = text;
+        Image img = image;
+        int availableWidth = Math.max(0, rect.width - 2 * hIndent);
+        Point extent = getTotalSize(img, t);
+        if (extent.x > availableWidth)
+        {
+            img = null;
+            extent = getTotalSize(img, t);
+            if (extent.x > availableWidth)
+            {
+                shortenText = true;
+            }
+        }
+
+        GC gc = event.gc;
+        String[] lines = text is null ? null : splitString(text);
+
+        // shorten the text
+        if (shortenText)
+        {
+            extent.x = 0;
+            for (int i = 0; i < lines.length; i++)
+            {
+                Point e = gc.textExtent(lines[i], DRAW_FLAGS);
+                if (e.x > availableWidth)
+                {
+                    lines[i] = shortenText(gc, lines[i], availableWidth);
+                    extent.x = Math.max(extent.x,
+                            getTotalSize(null, lines[i]).x);
+                }
+                else
+                {
+                    extent.x = Math.max(extent.x, e.x);
+                }
+            }
+            if (appToolTipText is null)
+            {
+                super.setToolTipText(text);
+            }
+        }
+        else
+        {
+            super.setToolTipText(appToolTipText);
+        }
+
+        // determine horizontal position
+        int x = rect.x + hIndent;
+        if (alignn is DWT.CENTER)
+        {
+            x = (rect.width - extent.x) / 2;
+        }
+        if (alignn is DWT.RIGHT)
+        {
+            x = rect.width - hIndent - extent.x;
+        }
+
+        // draw a background image behind the text
+        try
+        {
+            if (backgroundImage !is null)
+            {
+                // draw a background image behind the text
+                Rectangle imageRect = backgroundImage.getBounds();
+                // tile image to fill space
+                gc.setBackground(getBackground());
+                gc.fillRectangle(rect);
+                int xPos = 0;
+                while (xPos < rect.width)
+                {
+                    int yPos = 0;
+                    while (yPos < rect.height)
+                    {
+                        gc.drawImage(backgroundImage, xPos, yPos);
+                        yPos += imageRect.height;
+                    }
+                    xPos += imageRect.width;
+                }
+            }
+            else if (gradientColors !is null)
+            {
+                // draw a gradient behind the text
+                const Color oldBackground = gc.getBackground();
+                if (gradientColors.length is 1)
+                {
+                    if (gradientColors[0] !is null)
+                        gc.setBackground(gradientColors[0]);
+                    gc.fillRectangle(0, 0, rect.width, rect.height);
+                }
+                else
+                {
+                    const Color oldForeground = gc.getForeground();
+                    Color lastColor = gradientColors[0];
+                    if (lastColor is null)
+                        lastColor = oldBackground;
+                    int pos = 0;
+                    for (int i = 0; i < gradientPercents.length; ++i)
+                    {
+                        gc.setForeground(lastColor);
+                        lastColor = gradientColors[i + 1];
+                        if (lastColor is null)
+                            lastColor = oldBackground;
+                        gc.setBackground(lastColor);
+                        if (gradientVertical)
+                        {
+                            const int
+                                    gradientHeight = (gradientPercents[i] * rect.height / 100) - pos;
+                            gc.fillGradientRectangle(0, pos, rect.width,
+                                    gradientHeight, true);
+                            pos += gradientHeight;
+                        }
+                        else
+                        {
+                            const int
+                                    gradientWidth = (gradientPercents[i] * rect.width / 100) - pos;
+                            gc.fillGradientRectangle(pos, 0, gradientWidth,
+                                    rect.height, false);
+                            pos += gradientWidth;
+                        }
+                    }
+                    if (gradientVertical && pos < rect.height)
+                    {
+                        gc.setBackground(getBackground());
+                        gc.fillRectangle(0, pos, rect.width, rect.height - pos);
+                    }
+                    if (!gradientVertical && pos < rect.width)
+                    {
+                        gc.setBackground(getBackground());
+                        gc.fillRectangle(pos, 0, rect.width - pos, rect.height);
+                    }
+                    gc.setForeground(oldForeground);
+                }
+                gc.setBackground(oldBackground);
+            }
+            else
+            {
+                if (background !is null || (getStyle() & DWT.DOUBLE_BUFFERED) is 0)
+                {
+                    gc.setBackground(getBackground());
+                    gc.fillRectangle(rect);
+                }
+            }
+        }
+        catch (DWTException e)
+        {
+            if ((getStyle() & DWT.DOUBLE_BUFFERED) is 0)
+            {
+                gc.setBackground(getBackground());
+                gc.fillRectangle(rect);
+            }
+        }
+
+        // draw border
+        int style = getStyle();
+        if ((style & DWT.SHADOW_IN) !is 0 || (style & DWT.SHADOW_OUT) !is 0)
+        {
+            paintBorder(gc, rect);
+        }
+
+        // draw the image
+        if (img !is null)
+        {
+            Rectangle imageRect = img.getBounds();
+            gc.drawImage(img, 0, 0, imageRect.width, imageRect.height, x,
+                    (rect.height - imageRect.height) / 2, imageRect.width,
+                    imageRect.height);
+            x += imageRect.width + GAP;
+            extent.x -= imageRect.width + GAP;
+        }
+        // draw the text
+        if (lines !is null)
+        {
+            int lineHeight = gc.getFontMetrics().getHeight();
+            int textHeight = lines.length * lineHeight;
+            int lineY = Math.max(vIndent,
+                    rect.y + (rect.height - textHeight) / 2);
+            gc.setForeground(getForeground());
+            for (int i = 0; i < lines.length; i++)
+            {
+                int lineX = x;
+                if (lines.length > 1)
+                {
+                    if (alignn is DWT.CENTER)
+                    {
+                        int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
+                        lineX = x + Math.max(0, (extent.x - lineWidth) / 2);
+                    }
+                    if (alignn is DWT.RIGHT)
+                    {
+                        int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
+                        lineX = Math.max(x,
+                                rect.x + rect.width - hIndent - lineWidth);
+                    }
+                }
+                gc.drawText(lines[i], lineX, lineY, DRAW_FLAGS);
+                lineY += lineHeight;
+            }
+        }
+    }
+
+    /**
+     * Paint the Label's border.
+     */
+    private void paintBorder (GC gc, Rectangle r)
+    {
+        Display disp = getDisplay();
+
+        Color c1 = null;
+        Color c2 = null;
+
+        int style = getStyle();
+        if ((style & DWT.SHADOW_IN) !is 0)
+        {
+            c1 = disp.getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW);
+            c2 = disp.getSystemColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+        }
+        if ((style & DWT.SHADOW_OUT) !is 0)
+        {
+            c1 = disp.getSystemColor(DWT.COLOR_WIDGET_LIGHT_SHADOW);
+            c2 = disp.getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW);
+        }
+
+        if (c1 !is null && c2 !is null)
+        {
+            gc.setLineWidth(1);
+            drawBevelRect(gc, r.x, r.y, r.width - 1, r.height - 1, c1, c2);
+        }
+    }
+
+    /**
+     * Set the alignnment of the CLabel.
+     * Use the values LEFT, CENTER and RIGHT to alignn image and text within the available space.
+     * 
+     * @param alignn the alignnment style of LEFT, RIGHT or CENTER
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the value of alignn is not one of DWT.LEFT, DWT.RIGHT or DWT.CENTER</li>
+     * </ul>
+     */
+    public void setAlignment (int alignn)
+    {
+        checkWidget();
+        if (alignn !is DWT.LEFT && alignn !is DWT.RIGHT && alignn !is DWT.CENTER)
+        {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        if (this.alignn !is alignn)
+        {
+            this.alignn = alignn;
+            redraw();
+        }
+    }
+
+    public void setBackground (Color color)
+    {
+        super.setBackground(color);
+        // Are these settings the same as before?
+        if (backgroundImage is null && gradientColors is null && gradientPercents is null)
+        {
+            if (color is null)
+            {
+                if (background is null)
+                    return;
+            }
+            else
+            {
+                if (color.opEquals(background))
+                    return;
+            }
+        }
+        background = color;
+        backgroundImage = null;
+        gradientColors = null;
+        gradientPercents = null;
+        redraw();
+    }
+
+    /**
+     * Specify a gradient of colours to be drawn in the background of the CLabel.
+     * <p>For example, to draw a gradient that varies from dark blue to blue and then to
+     * white and stays white for the right half of the label, use the following call 
+     * to setBackground:</p>
+     * <pre>
+     *  clabel.setBackground(new Color[]{display.getSystemColor(DWT.COLOR_DARK_BLUE), 
+     *                                 display.getSystemColor(DWT.COLOR_BLUE),
+     *                                 display.getSystemColor(DWT.COLOR_WHITE), 
+     *                                 display.getSystemColor(DWT.COLOR_WHITE)},
+     *                     new int[] {25, 50, 100});
+     * </pre>
+     *
+     * @param colors an array of Color that specifies the colors to appear in the gradient 
+     *               in order of appearance from left to right;  The value <code>null</code> 
+     *               clears the background gradient; the value <code>null</code> can be used 
+     *               inside the array of Color to specify the background color.
+     * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+     *                 of the widget at which the color should change; the size of the percents 
+     *                 array must be one less than the size of the colors array.
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent</li>
+     * </ul>
+     */
+    public void setBackground (Color[] colors, int[] percents)
+    {
+        setBackground(colors, percents, false);
+    }
+
+    /**
+     * Specify a gradient of colours to be drawn in the background of the CLabel.
+     * <p>For example, to draw a gradient that varies from dark blue to white in the vertical,
+     * direction use the following call 
+     * to setBackground:</p>
+     * <pre>
+     *  clabel.setBackground(new Color[]{display.getSystemColor(DWT.COLOR_DARK_BLUE), 
+     *                                 display.getSystemColor(DWT.COLOR_WHITE)},
+     *                       new int[] {100}, true);
+     * </pre>
+     *
+     * @param colors an array of Color that specifies the colors to appear in the gradient 
+     *               in order of appearance from left/top to right/bottom;  The value <code>null</code> 
+     *               clears the background gradient; the value <code>null</code> can be used 
+     *               inside the array of Color to specify the background color.
+     * @param percents an array of integers between 0 and 100 specifying the percent of the width/height 
+     *                 of the widget at which the color should change; the size of the percents 
+     *                 array must be one less than the size of the colors array.
+     * @param vertical indicate the direction of the gradient.  True is vertical and false is horizontal.
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setBackground (Color[] colors, int[] percents, bool vertical)
+    {
+        checkWidget();
+        if (colors !is null)
+        {
+            if (percents is null || percents.length !is colors.length - 1)
+            {
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            }
+            if (getDisplay().getDepth() < 15)
+            {
+                // Don't use gradients on low color displays
+                colors = new Color[][colors[colors.length - 1]];
+                percents = new int[][];
+            }
+            for (int i = 0; i < percents.length; i++)
+            {
+                if (percents[i] < 0 || percents[i] > 100)
+                {
+                    DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+                }
+                if (i > 0 && percents[i] < percents[i - 1])
+                {
+                    DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+                }
+            }
+        }
+
+        // Are these settings the same as before?
+        const Color background = getBackground();
+        if (backgroundImage is null)
+        {
+            if ((gradientColors !is null) && (colors !is null) && (gradientColors.length is colors.length))
+            {
+                bool same = false;
+                for (int i = 0; i < gradientColors.length; i++)
+                {
+                    same = (gradientColors[i] is colors[i]) || ((gradientColors[i] is null) && (colors[i] is background)) || ((gradientColors[i] is background) && (colors[i] is null));
+                    if (!same)
+                        break;
+                }
+                if (same)
+                {
+                    for (int i = 0; i < gradientPercents.length; i++)
+                    {
+                        same = gradientPercents[i] is percents[i];
+                        if (!same)
+                            break;
+                    }
+                }
+                if (same && this.gradientVertical is vertical)
+                    return;
+            }
+        }
+        else
+        {
+            backgroundImage = null;
+        }
+        // Store the new settings
+        if (colors is null)
+        {
+            gradientColors = null;
+            gradientPercents = null;
+            gradientVertical = false;
+        }
+        else
+        {
+            gradientColors = new Color[colors.length];
+            for (int i = 0; i < colors.length; ++i)
+                gradientColors[i] = (colors[i] !is null) ? colors[i] : background;
+            gradientPercents = new int[percents.length];
+            for (int i = 0; i < percents.length; ++i)
+                gradientPercents[i] = percents[i];
+            gradientVertical = vertical;
+        }
+        // Refresh with the new settings
+        redraw();
+    }
+
+    /**
+     * Set the image to be drawn in the background of the label.
+     * 
+     * @param image the image to be drawn in the background
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setBackground (Image image)
+    {
+        checkWidget();
+        if (image is backgroundImage)
+            return;
+        if (image !is null)
+        {
+            gradientColors = null;
+            gradientPercents = null;
+        }
+        backgroundImage = image;
+        redraw();
+
+    }
+
+    public void setFont (Font font)
+    {
+        super.setFont(font);
+        redraw();
+    }
+
+    /**
+     * Set the label's Image.
+     * The value <code>null</code> clears it.
+     * 
+     * @param image the image to be displayed in the label or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setImage (Image image)
+    {
+        checkWidget();
+        if (image !is this.image)
+        {
+            this.image = image;
+            redraw();
+        }
+    }
+
+    /**
+     * Set the label's text.
+     * The value <code>null</code> clears it.
+     * 
+     * @param text the text to be displayed in the label or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setText (String text)
+    {
+        checkWidget();
+        if (text is null)
+            text = ""; //$NON-NLS-1$
+        if (!text.opEquals(this.text))
+        {
+            this.text = text;
+            redraw();
+        }
+    }
+
+    public void setToolTipText (String String)
+    {
+        super.setToolTipText(String);
+        appToolTipText = super.getToolTipText();
+    }
+
+    /**
+     * Shorten the given text <code>t</code> so that its length doesn't exceed
+     * the given width. The default implementation replaces characters in the
+     * center of the original String with an ellipsis ("...").
+     * Override if you need a different strategy.
+     * 
+     * @param gc the gc to use for text measurement
+     * @param t the text to shorten
+     * @param width the width to shorten the text to, in pixels
+     * @return the shortened text
+     */
+    protected String shortenText (GC gc, String t, int width)
+    {
+        if (t is null)
+            return null;
+        int w = gc.textExtent(ELLIPSIS, DRAW_FLAGS).x;
+        if (width <= w)
+            return t;
+        int l = t.length();
+        int max = l / 2;
+        int min = 0;
+        int mid = (max + min) / 2 - 1;
+        if (mid <= 0)
+            return t;
+        TextLayout layout = new TextLayout(getDisplay());
+        layout.setText(t);
+        mid = validateOffset(layout, mid);
+        while (min < mid && mid < max)
+        {
+            String s1 = t.substring(0, mid);
+            String s2 = t.substring(validateOffset(layout, l - mid), l);
+            int l1 = gc.textExtent(s1, DRAW_FLAGS).x;
+            int l2 = gc.textExtent(s2, DRAW_FLAGS).x;
+            if (l1 + w + l2 > width)
+            {
+                max = mid;
+                mid = validateOffset(layout, (max + min) / 2);
+            }
+            else if (l1 + w + l2 < width)
+            {
+                min = mid;
+                mid = validateOffset(layout, (max + min) / 2);
+            }
+            else
+            {
+                min = max;
+            }
+        }
+        String
+                result = mid is 0 ? t : t.substring(0, mid) + ELLIPSIS + t.substring(
+                        validateOffset(layout, l - mid), l);
+        layout.dispose();
+        return result;
+    }
+
+    int validateOffset (TextLayout layout, int offset)
+    {
+        int nextOffset = layout.getNextOffset(offset, DWT.MOVEMENT_CLUSTER);
+        if (nextOffset !is offset)
+            return layout.getPreviousOffset(nextOffset, DWT.MOVEMENT_CLUSTER);
+        return offset;
+    }
+
+    private String[] splitString (String text)
+    {
+        String[] lines = new String[1];
+        int start = 0, pos;
+        do
+        {
+            pos = text.indexOf('\n', start);
+            if (pos is -1)
+            {
+                lines[lines.length - 1] = text.substring(start);
+            }
+            else
+            {
+                bool crlf = (pos > 0) && (text.charAt(pos - 1) is '\r');
+                lines[lines.length - 1] = text.substring(start,
+                        pos - (crlf ? 1 : 0));
+                start = pos + 1;
+                String[] newLines = new String[lines.length + 1];
+                System.arraycopy(lines, 0, newLines, 0, lines.length);
+                lines = newLines;
+            }
+        } while (pos !is -1);
+        return lines;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CLayoutData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CLayoutData;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.widgets.Control;
+
+class CLayoutData {
+
+    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;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabFolder.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,5094 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CTabFolder;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.accessibility.ACC;
+import dwt.accessibility.Accessible;
+import dwt.accessibility.AccessibleAdapter;
+import dwt.accessibility.AccessibleControlAdapter;
+import dwt.accessibility.AccessibleControlEvent;
+import dwt.accessibility.AccessibleEvent;
+import dwt.custom.CTabFolderListener;
+import dwt.custom.CTabFolder2Listener;
+import dwt.custom.CTabItem;
+import dwt.events.SelectionAdapter;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.FontData;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+import dwt.graphics.Rectangle;
+import dwt.graphics.Region;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Layout;
+import dwt.widgets.Listener;
+import dwt.widgets.Menu;
+import dwt.widgets.MenuItem;
+import dwt.widgets.TypedListener;
+
+/**
+ * 
+ * Instances of this class implement the notebook user interface
+ * metaphor.  It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CTabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>CTabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CLOSE, TOP, BOTTOM, FLAT, BORDER, SINGLE, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * <dd>"CTabFolder2"</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles TOP and BOTTOM 
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class CTabFolder : Composite
+{
+
+    /**
+     * marginWidth specifies the number of pixels of horizontal margin
+     * that will be placed along the left and right edges of the form.
+     *
+     * 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 form.
+     *
+     * The default value is 0.
+     */
+    public int marginHeight = 0;
+
+    /**
+     * A multiple of the tab height that specifies the minimum width to which a tab 
+     * will be compressed before scrolling arrows are used to navigate the tabs.
+     * 
+     * NOTE This field is badly named and can not be fixed for backwards compatibility.
+     * It should not be capitalized.
+     * 
+     * @deprecated This field is no longer used.  See setMinimumCharacters(int)
+     */
+    public int MIN_TAB_WIDTH = 4;
+
+    /**
+     * Color of innermost line of drop shadow border.
+     * 
+     * NOTE This field is badly named and can not be fixed for backwards compatibility.
+     * It should be capitalized.
+     * 
+     * @deprecated drop shadow border is no longer drawn in 3.0
+     */
+    public static RGB borderInsideRGB = new RGB(132, 130, 132);
+    /**
+     * Color of middle line of drop shadow border.
+     * 
+     * NOTE This field is badly named and can not be fixed for backwards compatibility.
+     * It should be capitalized.
+     * 
+     * @deprecated drop shadow border is no longer drawn in 3.0
+     */
+    public static RGB borderMiddleRGB = new RGB(143, 141, 138);
+    /**
+     * Color of outermost line of drop shadow border.
+     * 
+     * NOTE This field is badly named and can not be fixed for backwards compatibility.
+     * It should be capitalized.
+     * 
+     * @deprecated drop shadow border is no longer drawn in 3.0
+     */
+    public static RGB borderOutsideRGB = new RGB(171, 168, 165);
+
+    /* sizing, positioning */
+    int xClient, yClient;
+    bool onBottom = false;
+    bool single = false;
+    bool simple = true;
+    int fixedTabHeight = DWT.DEFAULT;
+    int tabHeight;
+    int minChars = 20;
+
+    /* item management */
+    CTabItem items[] = new CTabItem[0];
+    int firstIndex = -1; // index of the left most visible tab.
+    int selectedIndex = -1;
+    int[] priority = new int[0];
+    bool mru = false;
+    Listener listener;
+
+    /* External Listener management */
+    CTabFolder2Listener[] folderListeners = new CTabFolder2Listener[0];
+    // support for deprecated listener mechanism
+    CTabFolderListener[] tabListeners = new CTabFolderListener[0];
+
+    /* Selected item appearance */
+    Image selectionBgImage;
+    Color[] selectionGradientColors;
+    int[] selectionGradientPercents;
+    bool selectionGradientVertical;
+    Color selectionForeground;
+    Color selectionBackground; //selection fade end
+    Color selectionFadeStart;
+
+    Color selectionHighlightGradientBegin = null; //null is no highlight
+    //Although we are given new colours all the time to show different states (active, etc),
+    //some of which may have a highlight and some not, we'd like to retain the highlight colours
+    //as a cache so that we can reuse them if we're again told to show the highlight.
+    //We are relying on the fact that only one tab state usually gets a highlight, so only
+    //a single cache is required. If that happens to not be true, cache simply becomes less effective,
+    //but we don't leak colours.
+    Color[] selectionHighlightGradientColorsCache = null; //null is a legal value, check on access
+
+    /* Unselected item appearance */
+    Image bgImage;
+    Color[] gradientColors;
+    int[] gradientPercents;
+    bool gradientVertical;
+    bool showUnselectedImage = true;
+
+    static Color borderColor;
+
+    // close, min/max and chevron buttons
+    bool showClose = false;
+    bool showUnselectedClose = true;
+
+    Rectangle chevronRect = new Rectangle(0, 0, 0, 0);
+    int chevronImageState = NORMAL;
+    bool showChevron = false;
+    Menu showMenu;
+
+    bool showMin = false;
+    Rectangle minRect = new Rectangle(0, 0, 0, 0);
+    bool minimized = false;
+    int minImageState = NORMAL;
+
+    bool showMax = false;
+    Rectangle maxRect = new Rectangle(0, 0, 0, 0);
+    bool maximized = false;
+    int maxImageState = NORMAL;
+
+    Control topRight;
+    Rectangle topRightRect = new Rectangle(0, 0, 0, 0);
+    int topRightAlignment = DWT.RIGHT;
+
+    // borders and shapes
+    int borderLeft = 0;
+    int borderRight = 0;
+    int borderTop = 0;
+    int borderBottom = 0;
+
+    int highlight_margin = 0;
+    int highlight_header = 0;
+
+    int[] curve;
+    int[] topCurveHighlightStart;
+    int[] topCurveHighlightEnd;
+    int curveWidth = 0;
+    int curveIndent = 0;
+
+    // when disposing CTabFolder, don't try to layout the items or 
+    // change the selection as each child is destroyed.
+    bool inDispose = false;
+
+    // keep track of size changes in order to redraw only affected area
+    // on Resize
+    Point oldSize;
+    Font oldFont;
+
+    //   internal constants
+    static const int DEFAULT_WIDTH = 64;
+    static const int DEFAULT_HEIGHT = 64;
+    static const int BUTTON_SIZE = 18;
+
+    static const int[]
+            TOP_LEFT_CORNER = new int[][0 , 6 , 1 , 5 , 1 , 4 , 4 , 1 , 5 , 1 , 6 , 0];
+
+    //  TOP_LEFT_CORNER_HILITE is laid out in reverse (ie. top to bottom)
+    //  so can fade in same direction as right swoop curve
+    static const int[]
+            TOP_LEFT_CORNER_HILITE = new int[][5 , 2 , 4 , 2 , 3 , 3 , 2 , 4 , 2 , 5 , 1 , 6];
+
+    static const int[]
+            TOP_RIGHT_CORNER = new int[][-6 , 0 , -5 , 1 , -4 , 1 , -1 , 4 , -1 , 5 , 0 , 6];
+    static const int[]
+            BOTTOM_LEFT_CORNER = new int[][0 , -6 , 1 , -5 , 1 , -4 , 4 , -1 , 5 , -1 , 6 , 0];
+    static const int[]
+            BOTTOM_RIGHT_CORNER = new int[][-6 , 0 , -5 , -1 , -4 , -1 , -1 , -4 , -1 , -5 , 0 , -6];
+
+    static const int[]
+            SIMPLE_TOP_LEFT_CORNER = new int[][0 , 2 , 1 , 1 , 2 , 0];
+    static const int[]
+            SIMPLE_TOP_RIGHT_CORNER = new int[][-2 , 0 , -1 , 1 , 0 , 2];
+    static const int[]
+            SIMPLE_BOTTOM_LEFT_CORNER = new int[][0 , -2 , 1 , -1 , 2 , 0];
+    static const int[]
+            SIMPLE_BOTTOM_RIGHT_CORNER = new int[][-2 , 0 , -1 , -1 , 0 , -2];
+    static const int[] SIMPLE_UNSELECTED_INNER_CORNER = new int[][0 , 0];
+
+    static const int[]
+            TOP_LEFT_CORNER_BORDERLESS = new int[][0 , 6 , 1 , 5 , 1 , 4 , 4 , 1 , 5 , 1 , 6 , 0];
+    static const int[]
+            TOP_RIGHT_CORNER_BORDERLESS = new int[][-7 , 0 , -6 , 1 , -5 , 1 , -2 , 4 , -2 , 5 , -1 , 6];
+    static const int[]
+            BOTTOM_LEFT_CORNER_BORDERLESS = new int[][0 , -6 , 1 , -6 , 1 , -5 , 2 , -4 , 4 , -2 , 5 , -1 , 6 , -1 , 6 , 0];
+    static const int[]
+            BOTTOM_RIGHT_CORNER_BORDERLESS = new int[][-7 , 0 , -7 , -1 , -6 , -1 , -5 , -2 , -3 , -4 , -2 , -5 , -2 , -6 , -1 , -6];
+
+    static const int[]
+            SIMPLE_TOP_LEFT_CORNER_BORDERLESS = new int[][0 , 2 , 1 , 1 , 2 , 0];
+    static const int[]
+            SIMPLE_TOP_RIGHT_CORNER_BORDERLESS = new int[][-3 , 0 , -2 , 1 , -1 , 2];
+    static const int[]
+            SIMPLE_BOTTOM_LEFT_CORNER_BORDERLESS = new int[][0 , -3 , 1 , -2 , 2 , -1 , 3 , 0];
+    static const int[]
+            SIMPLE_BOTTOM_RIGHT_CORNER_BORDERLESS = new int[][-4 , 0 , -3 , -1 , -2 , -2 , -1 , -3];
+
+    static const int SELECTION_FOREGROUND = DWT.COLOR_LIST_FOREGROUND;
+    static const int SELECTION_BACKGROUND = DWT.COLOR_LIST_BACKGROUND;
+    static const int BORDER1_COLOR = DWT.COLOR_WIDGET_NORMAL_SHADOW;
+    static const int FOREGROUND = DWT.COLOR_WIDGET_FOREGROUND;
+    static const int BACKGROUND = DWT.COLOR_WIDGET_BACKGROUND;
+    static const int BUTTON_BORDER = DWT.COLOR_WIDGET_DARK_SHADOW;
+    static const int BUTTON_FILL = DWT.COLOR_LIST_BACKGROUND;
+
+    static const int NONE = 0;
+    static const int NORMAL = 1;
+    static const int HOT = 2;
+    static const int SELECTED = 3;
+    static const RGB CLOSE_FILL = new RGB(252, 160, 160);
+
+    static const int CHEVRON_CHILD_ID = 0;
+    static const int MINIMIZE_CHILD_ID = 1;
+    static const int MAXIMIZE_CHILD_ID = 2;
+    static const int EXTRA_CHILD_ID_COUNT = 3;
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * and a style value describing its behavior and appearance.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a widget which will be the parent of the new instance (cannot be null)
+     * @param style the style of widget to construct
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     *
+     * @see DWT#TOP
+     * @see DWT#BOTTOM
+     * @see DWT#FLAT
+     * @see DWT#BORDER
+     * @see DWT#SINGLE
+     * @see DWT#MULTI
+     * @see #getStyle()
+     */
+    public this (Composite parent, int style)
+    {
+        super(parent, checkStyle(parent, style));
+        super.setLayout(new CTabFolderLayout());
+        int style2 = super.getStyle();
+        oldFont = getFont();
+        onBottom = (style2 & DWT.BOTTOM) !is 0;
+        showClose = (style2 & DWT.CLOSE) !is 0;
+        //  showMin = (style2 & DWT.MIN) !is 0; - conflicts with DWT.TOP
+        //  showMax = (style2 & DWT.MAX) !is 0; - conflicts with DWT.BOTTOM
+        single = (style2 & DWT.SINGLE) !is 0;
+        borderLeft = borderRight = (style & DWT.BORDER) !is 0 ? 1 : 0;
+        borderTop = onBottom ? borderLeft : 0;
+        borderBottom = onBottom ? 0 : borderLeft;
+        highlight_header = (style & DWT.FLAT) !is 0 ? 1 : 3;
+        highlight_margin = (style & DWT.FLAT) !is 0 ? 0 : 2;
+        //set up default colors
+        Display display = getDisplay();
+        selectionForeground = display.getSystemColor(SELECTION_FOREGROUND);
+        selectionBackground = display.getSystemColor(SELECTION_BACKGROUND);
+        borderColor = display.getSystemColor(BORDER1_COLOR);
+        updateTabHeight(false);
+
+        initAccessible();
+
+        // Add all listeners
+        listener = new class Listener
+        {
+            public void handleEvent (Event event)
+            {
+                switch (event.type)
+                {
+                    case DWT.Dispose:
+                        onDispose(event);
+                    break;
+                    case DWT.DragDetect:
+                        onDragDetect(event);
+                    break;
+                    case DWT.FocusIn:
+                        onFocus(event);
+                    break;
+                    case DWT.FocusOut:
+                        onFocus(event);
+                    break;
+                    case DWT.KeyDown:
+                        onKeyDown(event);
+                    break;
+                    case DWT.MouseDoubleClick:
+                        onMouseDoubleClick(event);
+                    break;
+                    case DWT.MouseDown:
+                        onMouse(event);
+                    break;
+                    case DWT.MouseEnter:
+                        onMouse(event);
+                    break;
+                    case DWT.MouseExit:
+                        onMouse(event);
+                    break;
+                    case DWT.MouseMove:
+                        onMouse(event);
+                    break;
+                    case DWT.MouseUp:
+                        onMouse(event);
+                    break;
+                    case DWT.Paint:
+                        onPaint(event);
+                    break;
+                    case DWT.Resize:
+                        onResize();
+                    break;
+                    case DWT.Traverse:
+                        onTraverse(event);
+                    break;
+                }
+            }
+        };
+
+        int[]
+                folderEvents = new int[][DWT.Dispose , DWT.DragDetect , DWT.FocusIn , DWT.FocusOut , DWT.KeyDown , DWT.MouseDoubleClick , DWT.MouseDown , DWT.MouseEnter , DWT.MouseExit , DWT.MouseMove , DWT.MouseUp , DWT.Paint , DWT.Resize , DWT.Traverse];
+        for (int i = 0; i < folderEvents.length; i++)
+        {
+            addListener(folderEvents[i], listener);
+        }
+    }
+
+    static int checkStyle (Composite parent, int style)
+    {
+        int
+                mask = DWT.CLOSE | DWT.TOP | DWT.BOTTOM | DWT.FLAT | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT | DWT.SINGLE | DWT.MULTI;
+        style = style & mask;
+        // TOP and BOTTOM are mutually exclusive.
+        // TOP is the default
+        if ((style & DWT.TOP) !is 0)
+            style = style & ~DWT.BOTTOM;
+        // SINGLE and MULTI are mutually exclusive.
+        // MULTI is the default
+        if ((style & DWT.MULTI) !is 0)
+            style = style & ~DWT.SINGLE;
+        // reduce the flash by not redrawing the entire area on a Resize event
+        style |= DWT.NO_REDRAW_RESIZE;
+        //TEMPORARY CODE
+        /*
+         * The default background on carbon and some GTK themes is not a solid color 
+         * but a texture.  To show the correct default background, we must allow
+         * the operating system to draw it and therefore, we can not use the 
+         * NO_BACKGROUND style.  The NO_BACKGROUND style is not required on platforms
+         * that use double buffering which is true in both of these cases.
+         */
+        String platform = DWT.getPlatform();
+        if ("carbon".opEquals(platform) || "gtk".opEquals(platform))
+            return style; //$NON-NLS-1$ //$NON-NLS-2$
+
+        //TEMPORARY CODE
+        /*
+         * In Right To Left orientation on Windows, all GC calls that use a brush are drawing 
+         * offset by one pixel.  This results in some parts of the CTabFolder not drawing correctly.
+         * To alleviate some of the appearance problems, allow the OS to draw the background.
+         * This does not draw correctly but the result is less obviously wrong.
+         */
+        if ((style & DWT.RIGHT_TO_LEFT) !is 0)
+            return style;
+        if ((parent.getStyle() & DWT.MIRRORED) !is 0 && (style & DWT.LEFT_TO_RIGHT) is 0)
+            return style;
+
+        return style | DWT.NO_BACKGROUND;
+    }
+
+    static void fillRegion (GC gc, Region region)
+    {
+        // NOTE: region passed in to this function will be modified
+        Region clipping = new Region();
+        gc.getClipping(clipping);
+        region.intersect(clipping);
+        gc.setClipping(region);
+        gc.fillRectangle(region.getBounds());
+        gc.setClipping(clipping);
+        clipping.dispose();
+    }
+
+    /**
+     * 
+     * Adds the listener to the collection of listeners who will
+     * be notified when a tab item is closed, minimized, maximized,
+     * restored, or to show the list of items that are not 
+     * currently visible.
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @see CTabFolder2Listener
+     * @see #removeCTabFolder2Listener(CTabFolder2Listener)
+     * 
+     * @since 3.0
+     */
+    public void addCTabFolder2Listener (CTabFolder2Listener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        // add to array
+        CTabFolder2Listener[]
+                newListeners = new CTabFolder2Listener[folderListeners.length + 1];
+        System.arraycopy(folderListeners, 0, newListeners, 0,
+                folderListeners.length);
+        folderListeners = newListeners;
+        folderListeners[folderListeners.length - 1] = listener;
+    }
+
+    /**
+     * Adds the listener to the collection of listeners who will
+     * be notified when a tab item is closed.
+     *
+     * @param listener the listener which should be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     *
+     * @see CTabFolderListener
+     * @see #removeCTabFolderListener(CTabFolderListener)
+     * 
+     * @deprecated use addCTabFolder2Listener(CTabFolder2Listener)
+     */
+    public void addCTabFolderListener (CTabFolderListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        // add to array
+        CTabFolderListener[]
+                newTabListeners = new CTabFolderListener[tabListeners.length + 1];
+        System.arraycopy(tabListeners, 0, newTabListeners, 0,
+                tabListeners.length);
+        tabListeners = newTabListeners;
+        tabListeners[tabListeners.length - 1] = listener;
+        // display close button to be backwards compatible
+        if (!showClose)
+        {
+            showClose = true;
+            updateItems();
+            redraw();
+        }
+    }
+
+    /**  
+     * Adds the listener to the collection of listeners who will
+     * be notified when the user changes the receiver's selection, by sending
+     * it one of the messages defined in the <code>SelectionListener</code>
+     * interface.
+     * <p>
+     * <code>widgetSelected</code> is called when the user changes the selected tab.
+     * <code>widgetDefaultSelected</code> is not called.
+     * </p>
+     *
+     * @param listener the listener which should be notified when the user changes the receiver's selection
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see SelectionListener
+     * @see #removeSelectionListener
+     * @see SelectionEvent
+     */
+    public void addSelectionListener (SelectionListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+        {
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        }
+        TypedListener typedListener = new TypedListener(listener);
+        addListener(DWT.Selection, typedListener);
+        addListener(DWT.DefaultSelection, typedListener);
+    }
+
+    void antialias (int[] shape, RGB lineRGB, RGB innerRGB, RGB outerRGB, GC gc)
+    {
+        // Don't perform anti-aliasing on Mac and WPF because the platform
+        // already does it.  The simple style also does not require anti-aliasing.
+        if (simple || "carbon".opEquals(DWT.getPlatform()) || "wpf".opEquals(
+                DWT.getPlatform()))
+            return; //$NON-NLS-1$
+        // Don't perform anti-aliasing on low resolution displays
+        if (getDisplay().getDepth() < 15)
+            return;
+        if (outerRGB !is null)
+        {
+            int index = 0;
+            bool left = true;
+            int oldY = onBottom ? 0 : getSize().y;
+            int[] outer = new int[shape.length];
+            for (int i = 0; i < shape.length / 2; i++)
+            {
+                if (left && (index + 3 < shape.length))
+                {
+                    left = onBottom ? oldY <= shape[index + 3] : oldY >= shape[index + 3];
+                    oldY = shape[index + 1];
+                }
+                outer[index] = shape[index++] + (left ? -1 : +1);
+                outer[index] = shape[index++];
+            }
+            RGB from = lineRGB;
+            RGB to = outerRGB;
+            int red = from.red + 2 * (to.red - from.red) / 3;
+            int green = from.green + 2 * (to.green - from.green) / 3;
+            int blue = from.blue + 2 * (to.blue - from.blue) / 3;
+            Color color = new Color(getDisplay(), red, green, blue);
+            gc.setForeground(color);
+            gc.drawPolyline(outer);
+            color.dispose();
+        }
+        if (innerRGB !is null)
+        {
+            int[] inner = new int[shape.length];
+            int index = 0;
+            bool left = true;
+            int oldY = onBottom ? 0 : getSize().y;
+            for (int i = 0; i < shape.length / 2; i++)
+            {
+                if (left && (index + 3 < shape.length))
+                {
+                    left = onBottom ? oldY <= shape[index + 3] : oldY >= shape[index + 3];
+                    oldY = shape[index + 1];
+                }
+                inner[index] = shape[index++] + (left ? +1 : -1);
+                inner[index] = shape[index++];
+            }
+            RGB from = lineRGB;
+            RGB to = innerRGB;
+            int red = from.red + 2 * (to.red - from.red) / 3;
+            int green = from.green + 2 * (to.green - from.green) / 3;
+            int blue = from.blue + 2 * (to.blue - from.blue) / 3;
+            Color color = new Color(getDisplay(), red, green, blue);
+            gc.setForeground(color);
+            gc.drawPolyline(inner);
+            color.dispose();
+        }
+    }
+
+    public Rectangle computeTrim (int x, int y, int width, int height)
+    {
+        checkWidget();
+        int trimX = x - marginWidth - highlight_margin - borderLeft;
+        int
+                trimWidth = width + borderLeft + borderRight + 2 * marginWidth + 2 * highlight_margin;
+        if (minimized)
+        {
+            int
+                    trimY = onBottom ? y - borderTop : y - highlight_header - tabHeight - borderTop;
+            int
+                    trimHeight = borderTop + borderBottom + tabHeight + highlight_header;
+            return new Rectangle(trimX, trimY, trimWidth, trimHeight);
+        }
+        else
+        {
+            int
+                    trimY = onBottom ? y - marginHeight - highlight_margin - borderTop : y - marginHeight - highlight_header - tabHeight - borderTop;
+            int
+                    trimHeight = height + borderTop + borderBottom + 2 * marginHeight + tabHeight + highlight_header + highlight_margin;
+            return new Rectangle(trimX, trimY, trimWidth, trimHeight);
+        }
+    }
+
+    void createItem (CTabItem item, int index)
+    {
+        if (0 > index || index > getItemCount())
+            DWT.error(DWT.ERROR_INVALID_RANGE);
+        item.parent = this;
+        CTabItem[] newItems = new CTabItem[items.length + 1];
+        System.arraycopy(items, 0, newItems, 0, index);
+        newItems[index] = item;
+        System.arraycopy(items, index, newItems, index + 1,
+                items.length - index);
+        items = newItems;
+        if (selectedIndex >= index)
+            selectedIndex++;
+        int[] newPriority = new int[priority.length + 1];
+        int next = 0, priorityIndex = priority.length;
+        for (int i = 0; i < priority.length; i++)
+        {
+            if (!mru && priority[i] is index)
+            {
+                priorityIndex = next++;
+            }
+            newPriority[next++] = priority[i] >= index ? priority[i] + 1 : priority[i];
+        }
+        newPriority[priorityIndex] = index;
+        priority = newPriority;
+
+        if (items.length is 1)
+        {
+            if (!updateTabHeight(false))
+                updateItems();
+            redraw();
+        }
+        else
+        {
+            updateItems();
+            redrawTabs();
+        }
+    }
+
+    void destroyItem (CTabItem item)
+    {
+        if (inDispose)
+            return;
+        int index = indexOf(item);
+        if (index is -1)
+            return;
+
+        if (items.length is 1)
+        {
+            items = new CTabItem[0];
+            priority = new int[0];
+            firstIndex = -1;
+            selectedIndex = -1;
+
+            Control control = item.getControl();
+            if (control !is null && !control.isDisposed())
+            {
+                control.setVisible(false);
+            }
+            setToolTipText(null);
+            setButtonBounds();
+            redraw();
+            return;
+        }
+
+        CTabItem[] newItems = new CTabItem[items.length - 1];
+        System.arraycopy(items, 0, newItems, 0, index);
+        System.arraycopy(items, index + 1, newItems, index,
+                items.length - index - 1);
+        items = newItems;
+
+        int[] newPriority = new int[priority.length - 1];
+        int next = 0;
+        for (int i = 0; i < priority.length; i++)
+        {
+            if (priority[i] is index)
+                continue;
+            newPriority[next++] = priority[i] > index ? priority[i] - 1 : priority[i];
+        }
+        priority = newPriority;
+
+        // move the selection if this item is selected
+        if (selectedIndex is index)
+        {
+            Control control = item.getControl();
+            selectedIndex = -1;
+            int nextSelection = mru ? priority[0] : Math.max(0, index - 1);
+            setSelection(nextSelection, true);
+            if (control !is null && !control.isDisposed())
+            {
+                control.setVisible(false);
+            }
+        }
+        else if (selectedIndex > index)
+        {
+            selectedIndex--;
+        }
+
+        updateItems();
+        redrawTabs();
+    }
+
+    void drawBackground (GC gc, int[] shape, bool selected)
+    {
+        Color
+                defaultBackground = selected ? selectionBackground : getBackground();
+        Image image = selected ? selectionBgImage : bgImage;
+        Color[] colors = selected ? selectionGradientColors : gradientColors;
+        int[]
+                percents = selected ? selectionGradientPercents : gradientPercents;
+        bool vertical = selected ? selectionGradientVertical : gradientVertical;
+        Point size = getSize();
+        int width = size.x;
+        int height = tabHeight + highlight_header;
+        int x = 0;
+        if (borderLeft > 0)
+        {
+            x += 1;
+            width -= 2;
+        }
+        int y = onBottom ? size.y - borderBottom - height : borderTop;
+        drawBackground(gc, shape, x, y, width, height, defaultBackground,
+                image, colors, percents, vertical);
+    }
+
+    void drawBackground (GC gc, int[] shape, int x, int y, int width,
+            int height, Color defaultBackground, Image image, Color[] colors,
+            int[] percents, bool vertical)
+    {
+        Region clipping = new Region();
+        gc.getClipping(clipping);
+        Region region = new Region();
+        region.add(shape);
+        region.intersect(clipping);
+        gc.setClipping(region);
+
+        if (image !is null)
+        {
+            // draw the background image in shape
+            gc.setBackground(defaultBackground);
+            gc.fillRectangle(x, y, width, height);
+            Rectangle imageRect = image.getBounds();
+            gc.drawImage(image, imageRect.x, imageRect.y, imageRect.width,
+                    imageRect.height, x, y, width, height);
+        }
+        else if (colors !is null)
+        {
+            // draw gradient
+            if (colors.length is 1)
+            {
+                Color
+                        background = colors[0] !is null ? colors[0] : defaultBackground;
+                gc.setBackground(background);
+                gc.fillRectangle(x, y, width, height);
+            }
+            else
+            {
+                if (vertical)
+                {
+                    if (onBottom)
+                    {
+                        int pos = 0;
+                        if (percents[percents.length - 1] < 100)
+                        {
+                            pos = percents[percents.length - 1] * height / 100;
+                            gc.setBackground(defaultBackground);
+                            gc.fillRectangle(x, y, width, pos);
+                        }
+                        Color lastColor = colors[colors.length - 1];
+                        if (lastColor is null)
+                            lastColor = defaultBackground;
+                        for (int i = percents.length - 1; i >= 0; i--)
+                        {
+                            gc.setForeground(lastColor);
+                            lastColor = colors[i];
+                            if (lastColor is null)
+                                lastColor = defaultBackground;
+                            gc.setBackground(lastColor);
+                            int gradientHeight = percents[i] * height / 100;
+                            gc.fillGradientRectangle(x, y + pos, width,
+                                    gradientHeight, true);
+                            pos += gradientHeight;
+                        }
+                    }
+                    else
+                    {
+                        Color lastColor = colors[0];
+                        if (lastColor is null)
+                            lastColor = defaultBackground;
+                        int pos = 0;
+                        for (int i = 0; i < percents.length; i++)
+                        {
+                            gc.setForeground(lastColor);
+                            lastColor = colors[i + 1];
+                            if (lastColor is null)
+                                lastColor = defaultBackground;
+                            gc.setBackground(lastColor);
+                            int gradientHeight = percents[i] * height / 100;
+                            gc.fillGradientRectangle(x, y + pos, width,
+                                    gradientHeight, true);
+                            pos += gradientHeight;
+                        }
+                        if (pos < height)
+                        {
+                            gc.setBackground(defaultBackground);
+                            gc.fillRectangle(x, pos, width, height - pos + 1);
+                        }
+                    }
+                }
+                else
+                {   //horizontal gradient
+                    y = 0;
+                    height = getSize().y;
+                    Color lastColor = colors[0];
+                    if (lastColor is null)
+                        lastColor = defaultBackground;
+                    int pos = 0;
+                    for (int i = 0; i < percents.length; ++i)
+                    {
+                        gc.setForeground(lastColor);
+                        lastColor = colors[i + 1];
+                        if (lastColor is null)
+                            lastColor = defaultBackground;
+                        gc.setBackground(lastColor);
+                        int gradientWidth = (percents[i] * width / 100) - pos;
+                        gc.fillGradientRectangle(x + pos, y, gradientWidth,
+                                height, false);
+                        pos += gradientWidth;
+                    }
+                    if (pos < width)
+                    {
+                        gc.setBackground(defaultBackground);
+                        gc.fillRectangle(x + pos, y, width - pos, height);
+                    }
+                }
+            }
+        }
+        else
+        {
+            // draw a solid background using default background in shape
+            if ((getStyle() & DWT.NO_BACKGROUND) !is 0 || !defaultBackground.opEquals(
+                    getBackground()))
+            {
+                gc.setBackground(defaultBackground);
+                gc.fillRectangle(x, y, width, height);
+            }
+        }
+        gc.setClipping(clipping);
+        clipping.dispose();
+        region.dispose();
+    }
+
+    void drawBody (Event event)
+    {
+        GC gc = event.gc;
+        Point size = getSize();
+
+        // fill in body
+        if (!minimized)
+        {
+            int
+                    width = size.x - borderLeft - borderRight - 2 * highlight_margin;
+            int
+                    height = size.y - borderTop - borderBottom - tabHeight - highlight_header - highlight_margin;
+            // Draw highlight margin
+            if (highlight_margin > 0)
+            {
+                int[] shape = null;
+                if (onBottom)
+                {
+                    int x1 = borderLeft;
+                    int y1 = borderTop;
+                    int x2 = size.x - borderRight;
+                    int
+                            y2 = size.y - borderBottom - tabHeight - highlight_header;
+                    shape = new int[][x1 , y1 , x2 , y1 , x2 , y2 , x2 - highlight_margin , y2 , x2 - highlight_margin , y1 + highlight_margin , x1 + highlight_margin , y1 + highlight_margin , x1 + highlight_margin , y2 , x1 , y2];
+                }
+                else
+                {
+                    int x1 = borderLeft;
+                    int y1 = borderTop + tabHeight + highlight_header;
+                    int x2 = size.x - borderRight;
+                    int y2 = size.y - borderBottom;
+                    shape = new int[][x1 , y1 , x1 + highlight_margin , y1 , x1 + highlight_margin , y2 - highlight_margin , x2 - highlight_margin , y2 - highlight_margin , x2 - highlight_margin , y1 , x2 , y1 , x2 , y2 , x1 , y2];
+                }
+                // If horizontal gradient, show gradient across the whole area
+                if (selectedIndex !is -1 && selectionGradientColors !is null && selectionGradientColors.length > 1 && !selectionGradientVertical)
+                {
+                    drawBackground(gc, shape, true);
+                }
+                else if (selectedIndex is -1 && gradientColors !is null && gradientColors.length > 1 && !gradientVertical)
+                {
+                    drawBackground(gc, shape, false);
+                }
+                else
+                {
+                    gc.setBackground(
+                            selectedIndex is -1 ? getBackground() : selectionBackground);
+                    gc.fillPolygon(shape);
+                }
+            }
+            //Draw client area
+            if ((getStyle() & DWT.NO_BACKGROUND) !is 0)
+            {
+                gc.setBackground(getBackground());
+                gc.fillRectangle(xClient - marginWidth, yClient - marginHeight,
+                        width, height);
+            }
+        }
+        else
+        {
+            if ((getStyle() & DWT.NO_BACKGROUND) !is 0)
+            {
+                int
+                        height = borderTop + tabHeight + highlight_header + borderBottom;
+                if (size.y > height)
+                {
+                    gc.setBackground(getParent().getBackground());
+                    gc.fillRectangle(0, height, size.x, size.y - height);
+                }
+            }
+        }
+
+        //draw 1 pixel border around outside
+        if (borderLeft > 0)
+        {
+            gc.setForeground(borderColor);
+            int x1 = borderLeft - 1;
+            int x2 = size.x - borderRight;
+            int y1 = onBottom ? borderTop - 1 : borderTop + tabHeight;
+            int
+                    y2 = onBottom ? size.y - tabHeight - borderBottom - 1 : size.y - borderBottom;
+            gc.drawLine(x1, y1, x1, y2); // left
+            gc.drawLine(x2, y1, x2, y2); // right
+            if (onBottom)
+            {
+                gc.drawLine(x1, y1, x2, y1); // top
+            }
+            else
+            {
+                gc.drawLine(x1, y2, x2, y2); // bottom
+            }
+        }
+    }
+
+    void drawChevron (GC gc)
+    {
+        if (chevronRect.width is 0 || chevronRect.height is 0)
+            return;
+        // draw chevron (10x7)
+        Display display = getDisplay();
+        Point dpi = display.getDPI();
+        int fontHeight = 72 * 10 / dpi.y;
+        FontData fd = getFont().getFontData()[0];
+        fd.setHeight(fontHeight);
+        Font f = new Font(display, fd);
+        int fHeight = f.getFontData()[0].getHeight() * dpi.y / 72;
+        int indent = Math.max(2, (chevronRect.height - fHeight - 4) / 2);
+        int x = chevronRect.x + 2;
+        int y = chevronRect.y + indent;
+        int count;
+        if (single)
+        {
+            count = selectedIndex is -1 ? items.length : items.length - 1;
+        }
+        else
+        {
+            int showCount = 0;
+            while (showCount < priority.length && items[priority[showCount]].showing)
+            {
+                showCount++;
+            }
+            count = items.length - showCount;
+        }
+        String chevronString = count > 99 ? "99+" : String.valueOf(count); //$NON-NLS-1$
+        switch (chevronImageState)
+        {
+            case NORMAL:
+            {
+                Color
+                        chevronBorder = single ? getSelectionForeground() : getForeground();
+                gc.setForeground(chevronBorder);
+                gc.setFont(f);
+                gc.drawLine(x, y, x + 2, y + 2);
+                gc.drawLine(x + 2, y + 2, x, y + 4);
+                gc.drawLine(x + 1, y, x + 3, y + 2);
+                gc.drawLine(x + 3, y + 2, x + 1, y + 4);
+                gc.drawLine(x + 4, y, x + 6, y + 2);
+                gc.drawLine(x + 6, y + 2, x + 5, y + 4);
+                gc.drawLine(x + 5, y, x + 7, y + 2);
+                gc.drawLine(x + 7, y + 2, x + 4, y + 4);
+                gc.drawString(chevronString, x + 7, y + 3, true);
+                break;
+            }
+            case HOT:
+            {
+                gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+                gc.setBackground(display.getSystemColor(BUTTON_FILL));
+                gc.setFont(f);
+                gc.fillRoundRectangle(chevronRect.x, chevronRect.y,
+                        chevronRect.width, chevronRect.height, 6, 6);
+                gc.drawRoundRectangle(chevronRect.x, chevronRect.y,
+                        chevronRect.width - 1, chevronRect.height - 1, 6, 6);
+                gc.drawLine(x, y, x + 2, y + 2);
+                gc.drawLine(x + 2, y + 2, x, y + 4);
+                gc.drawLine(x + 1, y, x + 3, y + 2);
+                gc.drawLine(x + 3, y + 2, x + 1, y + 4);
+                gc.drawLine(x + 4, y, x + 6, y + 2);
+                gc.drawLine(x + 6, y + 2, x + 5, y + 4);
+                gc.drawLine(x + 5, y, x + 7, y + 2);
+                gc.drawLine(x + 7, y + 2, x + 4, y + 4);
+                gc.drawString(chevronString, x + 7, y + 3, true);
+                break;
+            }
+            case SELECTED:
+            {
+                gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+                gc.setBackground(display.getSystemColor(BUTTON_FILL));
+                gc.setFont(f);
+                gc.fillRoundRectangle(chevronRect.x, chevronRect.y,
+                        chevronRect.width, chevronRect.height, 6, 6);
+                gc.drawRoundRectangle(chevronRect.x, chevronRect.y,
+                        chevronRect.width - 1, chevronRect.height - 1, 6, 6);
+                gc.drawLine(x + 1, y + 1, x + 3, y + 3);
+                gc.drawLine(x + 3, y + 3, x + 1, y + 5);
+                gc.drawLine(x + 2, y + 1, x + 4, y + 3);
+                gc.drawLine(x + 4, y + 3, x + 2, y + 5);
+                gc.drawLine(x + 5, y + 1, x + 7, y + 3);
+                gc.drawLine(x + 7, y + 3, x + 6, y + 5);
+                gc.drawLine(x + 6, y + 1, x + 8, y + 3);
+                gc.drawLine(x + 8, y + 3, x + 5, y + 5);
+                gc.drawString(chevronString, x + 8, y + 4, true);
+                break;
+            }
+        }
+        f.dispose();
+    }
+
+    void drawMaximize (GC gc)
+    {
+        if (maxRect.width is 0 || maxRect.height is 0)
+            return;
+        Display display = getDisplay();
+        // 5x4 or 7x9
+        int x = maxRect.x + (CTabFolder.BUTTON_SIZE - 10) / 2;
+        int y = maxRect.y + 3;
+
+        gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+        gc.setBackground(display.getSystemColor(BUTTON_FILL));
+
+        switch (maxImageState)
+        {
+            case NORMAL:
+            {
+                if (!maximized)
+                {
+                    gc.fillRectangle(x, y, 9, 9);
+                    gc.drawRectangle(x, y, 9, 9);
+                    gc.drawLine(x + 1, y + 2, x + 8, y + 2);
+                }
+                else
+                {
+                    gc.fillRectangle(x, y + 3, 5, 4);
+                    gc.fillRectangle(x + 2, y, 5, 4);
+                    gc.drawRectangle(x, y + 3, 5, 4);
+                    gc.drawRectangle(x + 2, y, 5, 4);
+                    gc.drawLine(x + 3, y + 1, x + 6, y + 1);
+                    gc.drawLine(x + 1, y + 4, x + 4, y + 4);
+                }
+                break;
+            }
+            case HOT:
+            {
+                gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width,
+                        maxRect.height, 6, 6);
+                gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1,
+                        maxRect.height - 1, 6, 6);
+                if (!maximized)
+                {
+                    gc.fillRectangle(x, y, 9, 9);
+                    gc.drawRectangle(x, y, 9, 9);
+                    gc.drawLine(x + 1, y + 2, x + 8, y + 2);
+                }
+                else
+                {
+                    gc.fillRectangle(x, y + 3, 5, 4);
+                    gc.fillRectangle(x + 2, y, 5, 4);
+                    gc.drawRectangle(x, y + 3, 5, 4);
+                    gc.drawRectangle(x + 2, y, 5, 4);
+                    gc.drawLine(x + 3, y + 1, x + 6, y + 1);
+                    gc.drawLine(x + 1, y + 4, x + 4, y + 4);
+                }
+                break;
+            }
+            case SELECTED:
+            {
+                gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width,
+                        maxRect.height, 6, 6);
+                gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1,
+                        maxRect.height - 1, 6, 6);
+                if (!maximized)
+                {
+                    gc.fillRectangle(x + 1, y + 1, 9, 9);
+                    gc.drawRectangle(x + 1, y + 1, 9, 9);
+                    gc.drawLine(x + 2, y + 3, x + 9, y + 3);
+                }
+                else
+                {
+                    gc.fillRectangle(x + 1, y + 4, 5, 4);
+                    gc.fillRectangle(x + 3, y + 1, 5, 4);
+                    gc.drawRectangle(x + 1, y + 4, 5, 4);
+                    gc.drawRectangle(x + 3, y + 1, 5, 4);
+                    gc.drawLine(x + 4, y + 2, x + 7, y + 2);
+                    gc.drawLine(x + 2, y + 5, x + 5, y + 5);
+                }
+                break;
+            }
+        }
+    }
+
+    void drawMinimize (GC gc)
+    {
+        if (minRect.width is 0 || minRect.height is 0)
+            return;
+        Display display = getDisplay();
+        // 5x4 or 9x3
+        int x = minRect.x + (BUTTON_SIZE - 10) / 2;
+        int y = minRect.y + 3;
+
+        gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+        gc.setBackground(display.getSystemColor(BUTTON_FILL));
+
+        switch (minImageState)
+        {
+            case NORMAL:
+            {
+                if (!minimized)
+                {
+                    gc.fillRectangle(x, y, 9, 3);
+                    gc.drawRectangle(x, y, 9, 3);
+                }
+                else
+                {
+                    gc.fillRectangle(x, y + 3, 5, 4);
+                    gc.fillRectangle(x + 2, y, 5, 4);
+                    gc.drawRectangle(x, y + 3, 5, 4);
+                    gc.drawRectangle(x + 2, y, 5, 4);
+                    gc.drawLine(x + 3, y + 1, x + 6, y + 1);
+                    gc.drawLine(x + 1, y + 4, x + 4, y + 4);
+                }
+                break;
+            }
+            case HOT:
+            {
+                gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width,
+                        minRect.height, 6, 6);
+                gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1,
+                        minRect.height - 1, 6, 6);
+                if (!minimized)
+                {
+                    gc.fillRectangle(x, y, 9, 3);
+                    gc.drawRectangle(x, y, 9, 3);
+                }
+                else
+                {
+                    gc.fillRectangle(x, y + 3, 5, 4);
+                    gc.fillRectangle(x + 2, y, 5, 4);
+                    gc.drawRectangle(x, y + 3, 5, 4);
+                    gc.drawRectangle(x + 2, y, 5, 4);
+                    gc.drawLine(x + 3, y + 1, x + 6, y + 1);
+                    gc.drawLine(x + 1, y + 4, x + 4, y + 4);
+                }
+                break;
+            }
+            case SELECTED:
+            {
+                gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width,
+                        minRect.height, 6, 6);
+                gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1,
+                        minRect.height - 1, 6, 6);
+                if (!minimized)
+                {
+                    gc.fillRectangle(x + 1, y + 1, 9, 3);
+                    gc.drawRectangle(x + 1, y + 1, 9, 3);
+                }
+                else
+                {
+                    gc.fillRectangle(x + 1, y + 4, 5, 4);
+                    gc.fillRectangle(x + 3, y + 1, 5, 4);
+                    gc.drawRectangle(x + 1, y + 4, 5, 4);
+                    gc.drawRectangle(x + 3, y + 1, 5, 4);
+                    gc.drawLine(x + 4, y + 2, x + 7, y + 2);
+                    gc.drawLine(x + 2, y + 5, x + 5, y + 5);
+                }
+                break;
+            }
+        }
+    }
+
+    void drawTabArea (Event event)
+    {
+        GC gc = event.gc;
+        Point size = getSize();
+        int[] shape = null;
+
+        if (tabHeight is 0)
+        {
+            int style = getStyle();
+            if ((style & DWT.FLAT) !is 0 && (style & DWT.BORDER) is 0)
+                return;
+            int x1 = borderLeft - 1;
+            int x2 = size.x - borderRight;
+            int
+                    y1 = onBottom ? size.y - borderBottom - highlight_header - 1 : borderTop + highlight_header;
+            int y2 = onBottom ? size.y - borderBottom : borderTop;
+            if (borderLeft > 0 && onBottom)
+                y2 -= 1;
+
+            shape = new int[][x1 , y1 , x1 , y2 , x2 , y2 , x2 , y1];
+
+            // If horizontal gradient, show gradient across the whole area
+            if (selectedIndex !is -1 && selectionGradientColors !is null && selectionGradientColors.length > 1 && !selectionGradientVertical)
+            {
+                drawBackground(gc, shape, true);
+            }
+            else if (selectedIndex is -1 && gradientColors !is null && gradientColors.length > 1 && !gradientVertical)
+            {
+                drawBackground(gc, shape, false);
+            }
+            else
+            {
+                gc.setBackground(
+                        selectedIndex is -1 ? getBackground() : selectionBackground);
+                gc.fillPolygon(shape);
+            }
+
+            //draw 1 pixel border
+            if (borderLeft > 0)
+            {
+                gc.setForeground(borderColor);
+                gc.drawPolyline(shape);
+            }
+            return;
+        }
+
+        int x = Math.max(0, borderLeft - 1);
+        int y = onBottom ? size.y - borderBottom - tabHeight : borderTop;
+        int width = size.x - borderLeft - borderRight + 1;
+        int height = tabHeight - 1;
+
+        // Draw Tab Header
+        if (onBottom)
+        {
+            int[] left, right;
+            if ((getStyle() & DWT.BORDER) !is 0)
+            {
+                left = simple ? SIMPLE_BOTTOM_LEFT_CORNER : BOTTOM_LEFT_CORNER;
+                right = simple ? SIMPLE_BOTTOM_RIGHT_CORNER : BOTTOM_RIGHT_CORNER;
+            }
+            else
+            {
+                left = simple ? SIMPLE_BOTTOM_LEFT_CORNER_BORDERLESS : BOTTOM_LEFT_CORNER_BORDERLESS;
+                right = simple ? SIMPLE_BOTTOM_RIGHT_CORNER_BORDERLESS : BOTTOM_RIGHT_CORNER_BORDERLESS;
+            }
+            shape = new int[left.length + right.length + 4];
+            int index = 0;
+            shape[index++] = x;
+            shape[index++] = y - highlight_header;
+            for (int i = 0; i < left.length / 2; i++)
+            {
+                shape[index++] = x + left[2 * i];
+                shape[index++] = y + height + left[2 * i + 1];
+                if (borderLeft is 0)
+                    shape[index - 1] += 1;
+            }
+            for (int i = 0; i < right.length / 2; i++)
+            {
+                shape[index++] = x + width + right[2 * i];
+                shape[index++] = y + height + right[2 * i + 1];
+                if (borderLeft is 0)
+                    shape[index - 1] += 1;
+            }
+            shape[index++] = x + width;
+            shape[index++] = y - highlight_header;
+        }
+        else
+        {
+            int[] left, right;
+            if ((getStyle() & DWT.BORDER) !is 0)
+            {
+                left = simple ? SIMPLE_TOP_LEFT_CORNER : TOP_LEFT_CORNER;
+                right = simple ? SIMPLE_TOP_RIGHT_CORNER : TOP_RIGHT_CORNER;
+            }
+            else
+            {
+                left = simple ? SIMPLE_TOP_LEFT_CORNER_BORDERLESS : TOP_LEFT_CORNER_BORDERLESS;
+                right = simple ? SIMPLE_TOP_RIGHT_CORNER_BORDERLESS : TOP_RIGHT_CORNER_BORDERLESS;
+            }
+            shape = new int[left.length + right.length + 4];
+            int index = 0;
+            shape[index++] = x;
+            shape[index++] = y + height + highlight_header + 1;
+            for (int i = 0; i < left.length / 2; i++)
+            {
+                shape[index++] = x + left[2 * i];
+                shape[index++] = y + left[2 * i + 1];
+            }
+            for (int i = 0; i < right.length / 2; i++)
+            {
+                shape[index++] = x + width + right[2 * i];
+                shape[index++] = y + right[2 * i + 1];
+            }
+            shape[index++] = x + width;
+            shape[index++] = y + height + highlight_header + 1;
+        }
+        // Fill in background
+        bool bkSelected = single && selectedIndex !is -1;
+        drawBackground(gc, shape, bkSelected);
+        // Fill in parent background for non-rectangular shape
+        Region r = new Region();
+        r.add(new Rectangle(x, y, width + 1, height + 1));
+        r.subtract(shape);
+        gc.setBackground(getParent().getBackground());
+        fillRegion(gc, r);
+        r.dispose();
+
+        // Draw the unselected tabs.
+        if (!single)
+        {
+            for (int i = 0; i < items.length; i++)
+            {
+                if (i !is selectedIndex && event.getBounds().intersects(
+                        items[i].getBounds()))
+                {
+                    items[i].onPaint(gc, false);
+                }
+            }
+        }
+
+        // Draw selected tab
+        if (selectedIndex !is -1)
+        {
+            CTabItem item = items[selectedIndex];
+            item.onPaint(gc, true);
+        }
+        else
+        {
+            // if no selected tab - draw line across bottom of all tabs
+            int x1 = borderLeft;
+            int
+                    y1 = (onBottom) ? size.y - borderBottom - tabHeight - 1 : borderTop + tabHeight;
+            int x2 = size.x - borderRight;
+            gc.setForeground(borderColor);
+            gc.drawLine(x1, y1, x2, y1);
+        }
+
+        // Draw Buttons
+        drawChevron(gc);
+        drawMinimize(gc);
+        drawMaximize(gc);
+
+        // Draw border line
+        if (borderLeft > 0)
+        {
+            RGB outside = getParent().getBackground().getRGB();
+            antialias(shape, borderColor.getRGB(), null, outside, gc);
+            gc.setForeground(borderColor);
+            gc.drawPolyline(shape);
+        }
+    }
+
+    /**
+     * Returns <code>true</code> if the receiver's border is visible.
+     *
+     * @return the receiver's border visibility state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public bool getBorderVisible ()
+    {
+        checkWidget();
+        return borderLeft is 1;
+    }
+
+    public Rectangle getClientArea ()
+    {
+        checkWidget();
+        if (minimized)
+            return new Rectangle(xClient, yClient, 0, 0);
+        Point size = getSize();
+        int
+                width = size.x - borderLeft - borderRight - 2 * marginWidth - 2 * highlight_margin;
+        int
+                height = size.y - borderTop - borderBottom - 2 * marginHeight - highlight_margin - highlight_header;
+        height -= tabHeight;
+        return new Rectangle(xClient, yClient, width, height);
+    }
+
+    /**
+     * Return the tab that is located at the specified index.
+     * 
+     * @param index the index of the tab item
+     * @return the item at the specified index
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_RANGE - if the index is out of range</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     */
+    public CTabItem getItem (int index)
+    {
+        //checkWidget();
+        if (index < 0 || index >= items.length)
+            DWT.error(DWT.ERROR_INVALID_RANGE);
+        return items[index];
+    }
+
+    /**
+     * Gets the item at a point in the widget.
+     *
+     * @param pt the point in coordinates relative to the CTabFolder
+     * @return the item at a point or null
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public CTabItem getItem (Point pt)
+    {
+        //checkWidget();
+        if (items.length is 0)
+            return null;
+        Point size = getSize();
+        if (size.x <= borderLeft + borderRight)
+            return null;
+        if (showChevron && chevronRect.contains(pt))
+            return null;
+        for (int i = 0; i < priority.length; i++)
+        {
+            CTabItem item = items[priority[i]];
+            Rectangle rect = item.getBounds();
+            if (rect.contains(pt))
+                return item;
+        }
+        return null;
+    }
+
+    /**
+     * Return the number of tabs in the folder.
+     * 
+     * @return the number of tabs in the folder
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public int getItemCount ()
+    {
+        //checkWidget();
+        return items.length;
+    }
+
+    /**
+     * Return the tab items.
+     * 
+     * @return the tab items
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public CTabItem[] getItems ()
+    {
+        //checkWidget();
+        CTabItem[] tabItems = new CTabItem[items.length];
+        System.arraycopy(items, 0, tabItems, 0, items.length);
+        return tabItems;
+    }
+
+    /*
+     * Return the lowercase of the first non-'&' character following
+     * an '&' character in the given String. If there are no '&'
+     * characters in the given String, return '\0'.
+     */
+    char _findMnemonic (String String)
+    {
+        if (String is null)
+            return '\0';
+        int index = 0;
+        int length = String.length();
+        do
+        {
+            while (index < length && String.charAt(index) !is '&')
+                index++;
+            if (++index >= length)
+                return '\0';
+            if (String.charAt(index) !is '&')
+                return Character.toLowerCase(String.charAt(index));
+            index++;
+        } while (index < length);
+        return '\0';
+    }
+
+    String stripMnemonic (String String)
+    {
+        int index = 0;
+        int length = String.length();
+        do
+        {
+            while ((index < length) && (String.charAt(index) !is '&'))
+                index++;
+            if (++index >= length)
+                return String;
+            if (String.charAt(index) !is '&')
+            {
+                return String.substring(0, index - 1) + String.substring(index,
+                        length);
+            }
+            index++;
+        } while (index < length);
+        return String;
+    }
+
+    /**
+     * Returns <code>true</code> if the receiver is minimized.
+     *
+     * @return the receiver's minimized state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public bool getMinimized ()
+    {
+        checkWidget();
+        return minimized;
+    }
+
+    /**
+     * Returns <code>true</code> if the minimize button
+     * is visible.
+     *
+     * @return the visibility of the minimized button
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public bool getMinimizeVisible ()
+    {
+        checkWidget();
+        return showMin;
+    }
+
+    /** 
+     * Returns the number of characters that will
+     * appear in a fully compressed tab.
+     * 
+     * @return number of characters that will appear in a fully compressed tab
+     * 
+     * @since 3.0
+     */
+    public int getMinimumCharacters ()
+    {
+        checkWidget();
+        return minChars;
+    }
+
+    /**
+     * Returns <code>true</code> if the receiver is maximized.
+     * <p>
+     *
+     * @return the receiver's maximized state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public bool getMaximized ()
+    {
+        checkWidget();
+        return maximized;
+    }
+
+    /**
+     * Returns <code>true</code> if the maximize button
+     * is visible.
+     *
+     * @return the visibility of the maximized button
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public bool getMaximizeVisible ()
+    {
+        checkWidget();
+        return showMax;
+    }
+
+    /**
+     * Returns <code>true</code> if the receiver displays most
+     * recently used tabs and <code>false</code> otherwise.
+     * <p>
+     * When there is not enough horizontal space to show all the tabs,
+     * by default, tabs are shown sequentially from left to right in 
+     * order of their index.  When the MRU visibility is turned on,
+     * the tabs that are visible will be the tabs most recently selected.
+     * Tabs will still maintain their left to right order based on index 
+     * but only the most recently selected tabs are visible.
+     * <p>
+     * For example, consider a CTabFolder that contains "Tab 1", "Tab 2",
+     * "Tab 3" and "Tab 4" (in order by index).  The user selects
+     * "Tab 1" and then "Tab 3".  If the CTabFolder is now
+     * compressed so that only two tabs are visible, by default, 
+     * "Tab 2" and "Tab 3" will be shown ("Tab 3" since it is currently 
+     * selected and "Tab 2" because it is the previous item in index order).
+     * If MRU visibility is enabled, the two visible tabs will be "Tab 1"
+     * and "Tab 3" (in that order from left to right).</p>
+     *
+     * @return the receiver's header's visibility state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.1
+     */
+    public bool getMRUVisible ()
+    {
+        checkWidget();
+        return mru;
+    }
+
+    int getRightItemEdge ()
+    {
+        int x = getSize().x - borderRight - 3;
+        if (showMin)
+            x -= BUTTON_SIZE;
+        if (showMax)
+            x -= BUTTON_SIZE;
+        if (showChevron)
+            x -= 3 * BUTTON_SIZE / 2;
+        if (topRight !is null && topRightAlignment !is DWT.FILL)
+        {
+            Point rightSize = topRight.computeSize(DWT.DEFAULT, DWT.DEFAULT);
+            x -= rightSize.x + 3;
+        }
+        return Math.max(0, x);
+    }
+
+    /**
+     * Return the selected tab item, or null if there is no selection.
+     * 
+     * @return the selected tab item, or null if none has been selected
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public CTabItem getSelection ()
+    {
+        //checkWidget();
+        if (selectedIndex is -1)
+            return null;
+        return items[selectedIndex];
+    }
+
+    /**
+     * Returns the receiver's selection background color.
+     *
+     * @return the selection background color of the receiver
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public Color getSelectionBackground ()
+    {
+        checkWidget();
+        return selectionBackground;
+    }
+
+    /**
+     * Returns the receiver's selection foreground color.
+     *
+     * @return the selection foreground color of the receiver
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public Color getSelectionForeground ()
+    {
+        checkWidget();
+        return selectionForeground;
+    }
+
+    /**
+     * Return the index of the selected tab item, or -1 if there
+     * is no selection.
+     * 
+     * @return the index of the selected tab item or -1
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public int getSelectionIndex ()
+    {
+        //checkWidget();
+        return selectedIndex;
+    }
+
+    /**
+     * Returns <code>true</code> if the CTabFolder is rendered
+     * with a simple, traditional shape.
+     * 
+     * @return <code>true</code> if the CTabFolder is rendered with a simple shape
+     * 
+     * @since 3.0
+     */
+    public bool getSimple ()
+    {
+        checkWidget();
+        return simple;
+    }
+
+    /**
+     * Returns <code>true</code> if the CTabFolder only displays the selected tab
+     * and <code>false</code> if the CTabFolder displays multiple tabs.
+     * 
+     * @return <code>true</code> if the CTabFolder only displays the selected tab and <code>false</code> if the CTabFolder displays multiple tabs
+     * 
+     * @since 3.0
+     */
+    public bool getSingle ()
+    {
+        checkWidget();
+        return single;
+    }
+
+    public int getStyle ()
+    {
+        int style = super.getStyle();
+        style &= ~(DWT.TOP | DWT.BOTTOM);
+        style |= onBottom ? DWT.BOTTOM : DWT.TOP;
+        style &= ~(DWT.SINGLE | DWT.MULTI);
+        style |= single ? DWT.SINGLE : DWT.MULTI;
+        if (borderLeft !is 0)
+            style |= DWT.BORDER;
+        style &= ~DWT.CLOSE;
+        if (showClose)
+            style |= DWT.CLOSE;
+        return style;
+    }
+
+    /**
+     * Returns the height of the tab
+     * 
+     * @return the height of the tab
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public int getTabHeight ()
+    {
+        checkWidget();
+        if (fixedTabHeight !is DWT.DEFAULT)
+            return fixedTabHeight;
+        return tabHeight - 1; // -1 for line drawn across top of tab
+    }
+
+    /**
+     * Returns the position of the tab.  Possible values are DWT.TOP or DWT.BOTTOM.
+     * 
+     * @return the position of the tab
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public int getTabPosition ()
+    {
+        checkWidget();
+        return onBottom ? DWT.BOTTOM : DWT.TOP;
+    }
+
+    /**
+     * Returns the control in the top right corner of the tab folder. 
+     * Typically this is a close button or a composite with a menu and close button.
+     *
+     * @return the control in the top right corner of the tab folder or null
+     * 
+     * @exception  DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     *
+     * @since 2.1
+     */
+    public Control getTopRight ()
+    {
+        checkWidget();
+        return topRight;
+    }
+
+    /**
+     * Returns <code>true</code> if the close button appears 
+     * when the user hovers over an unselected tabs.
+     * 
+     * @return <code>true</code> if the close button appears on unselected tabs
+     * 
+     * @since 3.0
+     */
+    public bool getUnselectedCloseVisible ()
+    {
+        checkWidget();
+        return showUnselectedClose;
+    }
+
+    /**
+     * Returns <code>true</code> if an image appears 
+     * in unselected tabs.
+     * 
+     * @return <code>true</code> if an image appears in unselected tabs
+     * 
+     * @since 3.0
+     */
+    public bool getUnselectedImageVisible ()
+    {
+        checkWidget();
+        return showUnselectedImage;
+    }
+
+    /**
+     * Return the index of the specified tab or -1 if the tab is not 
+     * in the receiver.
+     * 
+     * @param item the tab item for which the index is required
+     * 
+     * @return the index of the specified tab item or -1
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     */
+    public int indexOf (CTabItem item)
+    {
+        checkWidget();
+        if (item is null)
+        {
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        }
+        for (int i = 0; i < items.length; i++)
+        {
+            if (items[i] is item)
+                return i;
+        }
+        return -1;
+    }
+
+    void initAccessible ()
+    {
+        const Accessible accessible = getAccessible();
+        accessible.addAccessibleListener(new class AccessibleAdapter
+        {
+            public void getName (AccessibleEvent e)
+            {
+                String name = null;
+                int childID = e.childID;
+                if (childID >= 0 && childID < items.length)
+                {
+                    name = stripMnemonic(items[childID].getText());
+                }
+                else if (childID is items.length + CHEVRON_CHILD_ID)
+                {
+                    name = DWT.getMessage("DWT_ShowList"); //$NON-NLS-1$
+            }
+            else if (childID is items.length + MINIMIZE_CHILD_ID)
+            {
+                name = minimized ? DWT.getMessage("DWT_Restore") : DWT.getMessage(
+                        "DWT_Minimize"); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+            else if (childID is items.length + MAXIMIZE_CHILD_ID)
+            {
+                name = maximized ? DWT.getMessage("DWT_Restore") : DWT.getMessage(
+                        "DWT_Maximize"); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+            e.result = name;
+        }
+
+        public void getHelp (AccessibleEvent e)
+        {
+            String help = null;
+            int childID = e.childID;
+            if (childID is ACC.CHILDID_SELF)
+            {
+                help = getToolTipText();
+            }
+            else if (childID >= 0 && childID < items.length)
+            {
+                help = items[childID].getToolTipText();
+            }
+            e.result = help;
+        }
+
+        public void getKeyboardShortcut (AccessibleEvent e)
+        {
+            String shortcut = null;
+            int childID = e.childID;
+            if (childID >= 0 && childID < items.length)
+            {
+                String text = items[childID].getText();
+                if (text !is null)
+                {
+                    char mnemonic = _findMnemonic(text);
+                    if (mnemonic !is '\0')
+                    {
+                        shortcut = "Alt+" + mnemonic; //$NON-NLS-1$
+                    }
+                }
+            }
+            e.result = shortcut;
+        }
+    }   );
+
+        accessible.addAccessibleControlListener(
+                new class AccessibleControlAdapter
+                {
+                    public void getChildAtPoint (AccessibleControlEvent e)
+                    {
+                        Point testPoint = toControl(e.x, e.y);
+                        int childID = ACC.CHILDID_NONE;
+                        for (int i = 0; i < items.length; i++)
+                        {
+                            if (items[i].getBounds().contains(testPoint))
+                            {
+                                childID = i;
+                                break;
+                            }
+                        }
+                        if (childID is ACC.CHILDID_NONE)
+                        {
+                            if (showChevron && chevronRect.contains(testPoint))
+                            {
+                                childID = items.length + CHEVRON_CHILD_ID;
+                            }
+                            else if (showMin && minRect.contains(testPoint))
+                            {
+                                childID = items.length + MINIMIZE_CHILD_ID;
+                            }
+                            else if (showMax && maxRect.contains(testPoint))
+                            {
+                                childID = items.length + MAXIMIZE_CHILD_ID;
+                            }
+                            else
+                            {
+                                Rectangle location = getBounds();
+                                location.height = location.height - getClientArea().height;
+                                if (location.contains(testPoint))
+                                {
+                                    childID = ACC.CHILDID_SELF;
+                                }
+                            }
+                        }
+                        e.childID = childID;
+                    }
+
+                    public void getLocation (AccessibleControlEvent e)
+                    {
+                        Rectangle location = null;
+                        Point pt = null;
+                        int childID = e.childID;
+                        if (childID is ACC.CHILDID_SELF)
+                        {
+                            location = getBounds();
+                            pt = getParent().toDisplay(location.x, location.y);
+                        }
+                        else
+                        {
+                            if (childID >= 0 && childID < items.length && items[childID].isShowing())
+                            {
+                                location = items[childID].getBounds();
+                            }
+                            else if (showChevron && childID is items.length + CHEVRON_CHILD_ID)
+                            {
+                                location = chevronRect;
+                            }
+                            else if (showMin && childID is items.length + MINIMIZE_CHILD_ID)
+                            {
+                                location = minRect;
+                            }
+                            else if (showMax && childID is items.length + MAXIMIZE_CHILD_ID)
+                            {
+                                location = maxRect;
+                            }
+                            if (location !is null)
+                            {
+                                pt = toDisplay(location.x, location.y);
+                            }
+                        }
+                        if (location !is null && pt !is null)
+                        {
+                            e.x = pt.x;
+                            e.y = pt.y;
+                            e.width = location.width;
+                            e.height = location.height;
+                        }
+                    }
+
+                    public void getChildCount (AccessibleControlEvent e)
+                    {
+                        e.detail = items.length + EXTRA_CHILD_ID_COUNT;
+                    }
+
+                    public void getDefaultAction (AccessibleControlEvent e)
+                    {
+                        String action = null;
+                        int childID = e.childID;
+                        if (childID >= 0 && childID < items.length)
+                        {
+                            action = DWT.getMessage("DWT_Switch"); //$NON-NLS-1$
+                        }
+                        if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT)
+                        {
+                            action = DWT.getMessage("DWT_Press"); //$NON-NLS-1$
+                        }
+                        e.result = action;
+                    }
+
+                    public void getFocus (AccessibleControlEvent e)
+                    {
+                        int childID = ACC.CHILDID_NONE;
+                        if (isFocusControl())
+                        {
+                            if (selectedIndex is -1)
+                            {
+                                childID = ACC.CHILDID_SELF;
+                            }
+                            else
+                            {
+                                childID = selectedIndex;
+                            }
+                        }
+                        e.childID = childID;
+                    }
+
+                    public void getRole (AccessibleControlEvent e)
+                    {
+                        int role = 0;
+                        int childID = e.childID;
+                        if (childID is ACC.CHILDID_SELF)
+                        {
+                            role = ACC.ROLE_TABFOLDER;
+                        }
+                        else if (childID >= 0 && childID < items.length)
+                        {
+                            role = ACC.ROLE_TABITEM;
+                        }
+                        else if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT)
+                        {
+                            role = ACC.ROLE_PUSHBUTTON;
+                        }
+                        e.detail = role;
+                    }
+
+                    public void getSelection (AccessibleControlEvent e)
+                    {
+                        e.childID = (selectedIndex is -1) ? ACC.CHILDID_NONE : selectedIndex;
+                    }
+
+                    public void getState (AccessibleControlEvent e)
+                    {
+                        int state = 0;
+                        int childID = e.childID;
+                        if (childID is ACC.CHILDID_SELF)
+                        {
+                            state = ACC.STATE_NORMAL;
+                        }
+                        else if (childID >= 0 && childID < items.length)
+                        {
+                            state = ACC.STATE_SELECTABLE;
+                            if (isFocusControl())
+                            {
+                                state |= ACC.STATE_FOCUSABLE;
+                            }
+                            if (selectedIndex is childID)
+                            {
+                                state |= ACC.STATE_SELECTED;
+                                if (isFocusControl())
+                                {
+                                    state |= ACC.STATE_FOCUSED;
+                                }
+                            }
+                        }
+                        else if (childID is items.length + CHEVRON_CHILD_ID)
+                        {
+                            state = showChevron ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;
+                        }
+                        else if (childID is items.length + MINIMIZE_CHILD_ID)
+                        {
+                            state = showMin ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;
+                        }
+                        else if (childID is items.length + MAXIMIZE_CHILD_ID)
+                        {
+                            state = showMax ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;
+                        }
+                        e.detail = state;
+                    }
+
+                    public void getChildren (AccessibleControlEvent e)
+                    {
+                        int childIdCount = items.length + EXTRA_CHILD_ID_COUNT;
+                        Object[] children = new Object[childIdCount];
+                        for (int i = 0; i < childIdCount; i++)
+                        {
+                            children[i] = new Integer(i);
+                        }
+                        e.children = children;
+                    }
+                });
+
+        addListener(DWT.Selection, new class(accessible) Listener
+        {
+
+            Accessible accessible;
+
+            this (Accessible accessible)
+            {
+                this.accessible = accessible;
+            }
+
+            public void handleEvent (Event event)
+            {
+                if (isFocusControl())
+                {
+                    if (selectedIndex is -1)
+                    {
+                        accessible.setFocus(ACC.CHILDID_SELF);
+                    }
+                    else
+                    {
+                        accessible.setFocus(selectedIndex);
+                    }
+                }
+            }
+        });
+
+        addListener(DWT.FocusIn, new class(accessible) Listener
+        {
+
+            Accessible accessible;
+
+            this (Accessible accessible)
+            {
+                this.accessible = accessible;
+            }
+
+            public void handleEvent (Event event)
+            {
+                if (selectedIndex is -1)
+                {
+                    accessible.setFocus(ACC.CHILDID_SELF);
+                }
+                else
+                {
+                    accessible.setFocus(selectedIndex);
+                }
+            }
+        });
+    }
+
+    void onKeyDown (Event event)
+    {
+        switch (event.keyCode)
+        {
+            case DWT.ARROW_LEFT:
+            case DWT.ARROW_RIGHT:
+                int count = items.length;
+                if (count is 0)
+                    return;
+                if (selectedIndex is -1)
+                    return;
+                int
+                        leadKey = (getStyle() & DWT.RIGHT_TO_LEFT) !is 0 ? DWT.ARROW_RIGHT : DWT.ARROW_LEFT;
+                int offset = event.keyCode is leadKey ? -1 : 1;
+                int index;
+                if (!mru)
+                {
+                    index = selectedIndex + offset;
+                }
+                else
+                {
+                    int[] visible = new int[items.length];
+                    int idx = 0;
+                    int current = -1;
+                    for (int i = 0; i < items.length; i++)
+                    {
+                        if (items[i].showing)
+                        {
+                            if (i is selectedIndex)
+                                current = idx;
+                            visible[idx++] = i;
+                        }
+                    }
+                    if (current + offset >= 0 && current + offset < idx)
+                    {
+                        index = visible[current + offset];
+                    }
+                    else
+                    {
+                        if (showChevron)
+                        {
+                            CTabFolderEvent e = new CTabFolderEvent(this);
+                            e.widget = this;
+                            e.time = event.time;
+                            e.x = chevronRect.x;
+                            e.y = chevronRect.y;
+                            e.width = chevronRect.width;
+                            e.height = chevronRect.height;
+                            e.doit = true;
+                            for (int i = 0; i < folderListeners.length; i++)
+                            {
+                                folderListeners[i].showList(e);
+                            }
+                            if (e.doit && !isDisposed())
+                            {
+                                showList(chevronRect);
+                            }
+                        }
+                        return;
+                    }
+                }
+                if (index < 0 || index >= count)
+                    return;
+                setSelection(index, true);
+                forceFocus();
+        }
+    }
+
+    void onDispose (Event event)
+    {
+        removeListener(DWT.Dispose, listener);
+        notifyListeners(DWT.Dispose, event);
+        event.type = DWT.None;
+        /*
+         * Usually when an item is disposed, destroyItem will change the size of the items array, 
+         * reset the bounds of all the tabs and manage the widget associated with the tab.
+         * Since the whole folder is being disposed, this is not necessary.  For speed
+         * the inDispose flag is used to skip over this part of the item dispose.
+         */
+        inDispose = true;
+
+        if (showMenu !is null && !showMenu.isDisposed())
+        {
+            showMenu.dispose();
+            showMenu = null;
+        }
+        int length = items.length;
+        for (int i = 0; i < length; i++)
+        {
+            if (items[i] !is null)
+            {
+                items[i].dispose();
+            }
+        }
+
+        selectionGradientColors = null;
+        selectionGradientPercents = null;
+        selectionBgImage = null;
+
+        selectionBackground = null;
+        selectionForeground = null;
+        disposeSelectionHighlightGradientColors();
+    }
+
+    void onDragDetect (Event event)
+    {
+        bool consume = false;
+        if (chevronRect.contains(event.x, event.y) || minRect.contains(event.x,
+                event.y) || maxRect.contains(event.x, event.y))
+        {
+            consume = true;
+        }
+        else
+        {
+            for (int i = 0; i < items.length; i++)
+            {
+                if (items[i].closeRect.contains(event.x, event.y))
+                {
+                    consume = true;
+                    break;
+                }
+            }
+        }
+        if (consume)
+        {
+            event.type = DWT.None;
+        }
+    }
+
+    void onFocus (Event event)
+    {
+        checkWidget();
+        if (selectedIndex >= 0)
+        {
+            redraw();
+        }
+        else
+        {
+            setSelection(0, true);
+        }
+    }
+
+    bool onMnemonic (Event event)
+    {
+        char key = event.character;
+        for (int i = 0; i < items.length; i++)
+        {
+            if (items[i] !is null)
+            {
+                char mnemonic = _findMnemonic(items[i].getText());
+                if (mnemonic !is '\0')
+                {
+                    if (Character.toLowerCase(key) is mnemonic)
+                    {
+                        setSelection(i, true);
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    void onMouseDoubleClick (Event event)
+    {
+        if (event.button !is 1 || (event.stateMask & DWT.BUTTON2) !is 0 || (event.stateMask & DWT.BUTTON3) !is 0)
+            return;
+        Event e = new Event();
+        e.item = getItem(new Point(event.x, event.y));
+        if (e.item !is null)
+        {
+            notifyListeners(DWT.DefaultSelection, e);
+        }
+    }
+
+    void onMouse (Event event)
+    {
+        int x = event.x, y = event.y;
+        switch (event.type)
+        {
+            case DWT.MouseEnter:
+            {
+                setToolTipText(null);
+                break;
+            }
+            case DWT.MouseExit:
+            {
+                if (minImageState !is NORMAL)
+                {
+                    minImageState = NORMAL;
+                    redraw(minRect.x, minRect.y, minRect.width, minRect.height,
+                            false);
+                }
+                if (maxImageState !is NORMAL)
+                {
+                    maxImageState = NORMAL;
+                    redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height,
+                            false);
+                }
+                if (chevronImageState !is NORMAL)
+                {
+                    chevronImageState = NORMAL;
+                    redraw(chevronRect.x, chevronRect.y, chevronRect.width,
+                            chevronRect.height, false);
+                }
+                for (int i = 0; i < items.length; i++)
+                {
+                    CTabItem item = items[i];
+                    if (i !is selectedIndex && item.closeImageState !is NONE)
+                    {
+                        item.closeImageState = NONE;
+                        redraw(item.closeRect.x, item.closeRect.y,
+                                item.closeRect.width, item.closeRect.height,
+                                false);
+                    }
+                    if (i is selectedIndex && item.closeImageState !is NORMAL)
+                    {
+                        item.closeImageState = NORMAL;
+                        redraw(item.closeRect.x, item.closeRect.y,
+                                item.closeRect.width, item.closeRect.height,
+                                false);
+                    }
+                }
+                break;
+            }
+            case DWT.MouseDown:
+            {
+                if (minRect.contains(x, y))
+                {
+                    if (event.button !is 1)
+                        return;
+                    minImageState = SELECTED;
+                    redraw(minRect.x, minRect.y, minRect.width, minRect.height,
+                            false);
+                    update();
+                    return;
+                }
+                if (maxRect.contains(x, y))
+                {
+                    if (event.button !is 1)
+                        return;
+                    maxImageState = SELECTED;
+                    redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height,
+                            false);
+                    update();
+                    return;
+                }
+                if (chevronRect.contains(x, y))
+                {
+                    if (event.button !is 1)
+                        return;
+                    if (chevronImageState !is HOT)
+                    {
+                        chevronImageState = HOT;
+                    }
+                    else
+                    {
+                        chevronImageState = SELECTED;
+                    }
+                    redraw(chevronRect.x, chevronRect.y, chevronRect.width,
+                            chevronRect.height, false);
+                    update();
+                    return;
+                }
+                CTabItem item = null;
+                if (single)
+                {
+                    if (selectedIndex !is -1)
+                    {
+                        Rectangle bounds = items[selectedIndex].getBounds();
+                        if (bounds.contains(x, y))
+                        {
+                            item = items[selectedIndex];
+                        }
+                    }
+                }
+                else
+                {
+                    for (int i = 0; i < items.length; i++)
+                    {
+                        Rectangle bounds = items[i].getBounds();
+                        if (bounds.contains(x, y))
+                        {
+                            item = items[i];
+                        }
+                    }
+                }
+                if (item !is null)
+                {
+                    if (item.closeRect.contains(x, y))
+                    {
+                        if (event.button !is 1)
+                            return;
+                        item.closeImageState = SELECTED;
+                        redraw(item.closeRect.x, item.closeRect.y,
+                                item.closeRect.width, item.closeRect.height,
+                                false);
+                        update();
+                        return;
+                    }
+                    int index = indexOf(item);
+                    if (item.showing)
+                    {
+                        setSelection(index, true);
+                    }
+                    return;
+                }
+                break;
+            }
+            case DWT.MouseMove:
+            {
+                _setToolTipText(event.x, event.y);
+                bool close = false, minimize = false, maximize = false,
+                        chevron = false;
+                if (minRect.contains(x, y))
+                {
+                    minimize = true;
+                    if (minImageState !is SELECTED && minImageState !is HOT)
+                    {
+                        minImageState = HOT;
+                        redraw(minRect.x, minRect.y, minRect.width,
+                                minRect.height, false);
+                    }
+                }
+                if (maxRect.contains(x, y))
+                {
+                    maximize = true;
+                    if (maxImageState !is SELECTED && maxImageState !is HOT)
+                    {
+                        maxImageState = HOT;
+                        redraw(maxRect.x, maxRect.y, maxRect.width,
+                                maxRect.height, false);
+                    }
+                }
+                if (chevronRect.contains(x, y))
+                {
+                    chevron = true;
+                    if (chevronImageState !is SELECTED && chevronImageState !is HOT)
+                    {
+                        chevronImageState = HOT;
+                        redraw(chevronRect.x, chevronRect.y, chevronRect.width,
+                                chevronRect.height, false);
+                    }
+                }
+                if (minImageState !is NORMAL && !minimize)
+                {
+                    minImageState = NORMAL;
+                    redraw(minRect.x, minRect.y, minRect.width, minRect.height,
+                            false);
+                }
+                if (maxImageState !is NORMAL && !maximize)
+                {
+                    maxImageState = NORMAL;
+                    redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height,
+                            false);
+                }
+                if (chevronImageState !is NORMAL && !chevron)
+                {
+                    chevronImageState = NORMAL;
+                    redraw(chevronRect.x, chevronRect.y, chevronRect.width,
+                            chevronRect.height, false);
+                }
+                for (int i = 0; i < items.length; i++)
+                {
+                    CTabItem item = items[i];
+                    close = false;
+                    if (item.getBounds().contains(x, y))
+                    {
+                        close = true;
+                        if (item.closeRect.contains(x, y))
+                        {
+                            if (item.closeImageState !is SELECTED && item.closeImageState !is HOT)
+                            {
+                                item.closeImageState = HOT;
+                                redraw(item.closeRect.x, item.closeRect.y,
+                                        item.closeRect.width,
+                                        item.closeRect.height, false);
+                            }
+                        }
+                        else
+                        {
+                            if (item.closeImageState !is NORMAL)
+                            {
+                                item.closeImageState = NORMAL;
+                                redraw(item.closeRect.x, item.closeRect.y,
+                                        item.closeRect.width,
+                                        item.closeRect.height, false);
+                            }
+                        }
+                    }
+                    if (i !is selectedIndex && item.closeImageState !is NONE && !close)
+                    {
+                        item.closeImageState = NONE;
+                        redraw(item.closeRect.x, item.closeRect.y,
+                                item.closeRect.width, item.closeRect.height,
+                                false);
+                    }
+                    if (i is selectedIndex && item.closeImageState !is NORMAL && !close)
+                    {
+                        item.closeImageState = NORMAL;
+                        redraw(item.closeRect.x, item.closeRect.y,
+                                item.closeRect.width, item.closeRect.height,
+                                false);
+                    }
+                }
+                break;
+            }
+            case DWT.MouseUp:
+            {
+                if (event.button !is 1)
+                    return;
+                if (chevronRect.contains(x, y))
+                {
+                    bool selected = chevronImageState is SELECTED;
+                    if (!selected)
+                        return;
+                    CTabFolderEvent e = new CTabFolderEvent(this);
+                    e.widget = this;
+                    e.time = event.time;
+                    e.x = chevronRect.x;
+                    e.y = chevronRect.y;
+                    e.width = chevronRect.width;
+                    e.height = chevronRect.height;
+                    e.doit = true;
+                    for (int i = 0; i < folderListeners.length; i++)
+                    {
+                        folderListeners[i].showList(e);
+                    }
+                    if (e.doit && !isDisposed())
+                    {
+                        showList(chevronRect);
+                    }
+                    return;
+                }
+                if (minRect.contains(x, y))
+                {
+                    bool selected = minImageState is SELECTED;
+                    minImageState = HOT;
+                    redraw(minRect.x, minRect.y, minRect.width, minRect.height,
+                            false);
+                    if (!selected)
+                        return;
+                    CTabFolderEvent e = new CTabFolderEvent(this);
+                    e.widget = this;
+                    e.time = event.time;
+                    for (int i = 0; i < folderListeners.length; i++)
+                    {
+                        if (minimized)
+                        {
+                            folderListeners[i].restore(e);
+                        }
+                        else
+                        {
+                            folderListeners[i].minimize(e);
+                        }
+                    }
+                    return;
+                }
+                if (maxRect.contains(x, y))
+                {
+                    bool selected = maxImageState is SELECTED;
+                    maxImageState = HOT;
+                    redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height,
+                            false);
+                    if (!selected)
+                        return;
+                    CTabFolderEvent e = new CTabFolderEvent(this);
+                    e.widget = this;
+                    e.time = event.time;
+                    for (int i = 0; i < folderListeners.length; i++)
+                    {
+                        if (maximized)
+                        {
+                            folderListeners[i].restore(e);
+                        }
+                        else
+                        {
+                            folderListeners[i].maximize(e);
+                        }
+                    }
+                    return;
+                }
+                CTabItem item = null;
+                if (single)
+                {
+                    if (selectedIndex !is -1)
+                    {
+                        Rectangle bounds = items[selectedIndex].getBounds();
+                        if (bounds.contains(x, y))
+                        {
+                            item = items[selectedIndex];
+                        }
+                    }
+                }
+                else
+                {
+                    for (int i = 0; i < items.length; i++)
+                    {
+                        Rectangle bounds = items[i].getBounds();
+                        if (bounds.contains(x, y))
+                        {
+                            item = items[i];
+                        }
+                    }
+                }
+                if (item !is null)
+                {
+                    if (item.closeRect.contains(x, y))
+                    {
+                        bool selected = item.closeImageState is SELECTED;
+                        item.closeImageState = HOT;
+                        redraw(item.closeRect.x, item.closeRect.y,
+                                item.closeRect.width, item.closeRect.height,
+                                false);
+                        if (!selected)
+                            return;
+                        CTabFolderEvent e = new CTabFolderEvent(this);
+                        e.widget = this;
+                        e.time = event.time;
+                        e.item = item;
+                        e.doit = true;
+                        for (int j = 0; j < folderListeners.length; j++)
+                        {
+                            CTabFolder2Listener listener = folderListeners[j];
+                            listener.close(e);
+                        }
+                        for (int j = 0; j < tabListeners.length; j++)
+                        {
+                            CTabFolderListener listener = tabListeners[j];
+                            listener.itemClosed(e);
+                        }
+                        if (e.doit)
+                            item.dispose();
+                        if (!isDisposed() && item.isDisposed())
+                        {
+                            Display display = getDisplay();
+                            Point pt = display.getCursorLocation();
+                            pt = display.map(null, this, pt.x, pt.y);
+                            CTabItem nextItem = getItem(pt);
+                            if (nextItem !is null)
+                            {
+                                if (nextItem.closeRect.contains(pt))
+                                {
+                                    if (nextItem.closeImageState !is SELECTED && nextItem.closeImageState !is HOT)
+                                    {
+                                        nextItem.closeImageState = HOT;
+                                        redraw(nextItem.closeRect.x,
+                                                nextItem.closeRect.y,
+                                                nextItem.closeRect.width,
+                                                nextItem.closeRect.height,
+                                                false);
+                                    }
+                                }
+                                else
+                                {
+                                    if (nextItem.closeImageState !is NORMAL)
+                                    {
+                                        nextItem.closeImageState = NORMAL;
+                                        redraw(nextItem.closeRect.x,
+                                                nextItem.closeRect.y,
+                                                nextItem.closeRect.width,
+                                                nextItem.closeRect.height,
+                                                false);
+                                    }
+                                }
+                            }
+                        }
+                        return;
+                    }
+                }
+            }
+        }
+    }
+
+    bool onPageTraversal (Event event)
+    {
+        int count = items.length;
+        if (count is 0)
+            return false;
+        int index = selectedIndex;
+        if (index is -1)
+        {
+            index = 0;
+        }
+        else
+        {
+            int offset = (event.detail is DWT.TRAVERSE_PAGE_NEXT) ? 1 : -1;
+            if (!mru)
+            {
+                index = (selectedIndex + offset + count) % count;
+            }
+            else
+            {
+                int[] visible = new int[items.length];
+                int idx = 0;
+                int current = -1;
+                for (int i = 0; i < items.length; i++)
+                {
+                    if (items[i].showing)
+                    {
+                        if (i is selectedIndex)
+                            current = idx;
+                        visible[idx++] = i;
+                    }
+                }
+                if (current + offset >= 0 && current + offset < idx)
+                {
+                    index = visible[current + offset];
+                }
+                else
+                {
+                    if (showChevron)
+                    {
+                        CTabFolderEvent e = new CTabFolderEvent(this);
+                        e.widget = this;
+                        e.time = event.time;
+                        e.x = chevronRect.x;
+                        e.y = chevronRect.y;
+                        e.width = chevronRect.width;
+                        e.height = chevronRect.height;
+                        e.doit = true;
+                        for (int i = 0; i < folderListeners.length; i++)
+                        {
+                            folderListeners[i].showList(e);
+                        }
+                        if (e.doit && !isDisposed())
+                        {
+                            showList(chevronRect);
+                        }
+                    }
+                    return true;
+                }
+            }
+        }
+        setSelection(index, true);
+        return true;
+    }
+
+    void onPaint (Event event)
+    {
+        if (inDispose)
+            return;
+        Font font = getFont();
+        if (oldFont is null || !oldFont.opEquals(font))
+        {
+            // handle case where  default font changes
+            oldFont = font;
+            if (!updateTabHeight(false))
+            {
+                updateItems();
+                redraw();
+                return;
+            }
+        }
+
+        GC gc = event.gc;
+        Font gcFont = gc.getFont();
+        Color gcBackground = gc.getBackground();
+        Color gcForeground = gc.getForeground();
+
+        // Useful for debugging paint problems
+        //{
+        //Point size = getSize();   
+        //gc.setBackground(getDisplay().getSystemColor(DWT.COLOR_GREEN));
+        //gc.fillRectangle(-10, -10, size.x + 20, size.y+20);
+        //}
+
+        drawBody(event);
+
+        gc.setFont(gcFont);
+        gc.setForeground(gcForeground);
+        gc.setBackground(gcBackground);
+
+        drawTabArea(event);
+
+        gc.setFont(gcFont);
+        gc.setForeground(gcForeground);
+        gc.setBackground(gcBackground);
+    }
+
+    void onResize ()
+    {
+        if (updateItems())
+            redrawTabs();
+
+        Point size = getSize();
+        if (oldSize is null)
+        {
+            redraw();
+        }
+        else
+        {
+            if (onBottom && size.y !is oldSize.y)
+            {
+                redraw();
+            }
+            else
+            {
+                int x1 = Math.min(size.x, oldSize.x);
+                if (size.x !is oldSize.x)
+                    x1 -= borderRight + highlight_margin + 2;
+                if (!simple)
+                    x1 -= 5; // rounded top right corner
+                int y1 = Math.min(size.y, oldSize.y);
+                if (size.y !is oldSize.y)
+                    y1 -= borderBottom + highlight_margin;
+                int x2 = Math.max(size.x, oldSize.x);
+                int y2 = Math.max(size.y, oldSize.y);
+                redraw(0, y1, x2, y2 - y1, false);
+                redraw(x1, 0, x2 - x1, y2, false);
+            }
+        }
+        oldSize = size;
+    }
+
+    void onTraverse (Event event)
+    {
+        switch (event.detail)
+        {
+            case DWT.TRAVERSE_ESCAPE:
+            case DWT.TRAVERSE_RETURN:
+            case DWT.TRAVERSE_TAB_NEXT:
+            case DWT.TRAVERSE_TAB_PREVIOUS:
+                Control focusControl = getDisplay().getFocusControl();
+                if (focusControl is this)
+                    event.doit = true;
+            break;
+            case DWT.TRAVERSE_MNEMONIC:
+                event.doit = onMnemonic(event);
+                if (event.doit)
+                    event.detail = DWT.TRAVERSE_NONE;
+            break;
+            case DWT.TRAVERSE_PAGE_NEXT:
+            case DWT.TRAVERSE_PAGE_PREVIOUS:
+                event.doit = onPageTraversal(event);
+                event.detail = DWT.TRAVERSE_NONE;
+            break;
+        }
+    }
+
+    void redrawTabs ()
+    {
+        Point size = getSize();
+        if (onBottom)
+        {
+            redraw(0, size.y - borderBottom - tabHeight - highlight_header - 1,
+                    size.x, borderBottom + tabHeight + highlight_header + 1,
+                    false);
+        }
+        else
+        {
+            redraw(0, 0, size.x, borderTop + tabHeight + highlight_header + 1,
+                    false);
+        }
+    }
+
+    /**  
+     * Removes the listener.
+     *
+     * @param listener the listener
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @see #addCTabFolder2Listener(CTabFolder2Listener)
+     * 
+     * @since 3.0
+     */
+    public void removeCTabFolder2Listener (CTabFolder2Listener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        if (folderListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < folderListeners.length; i++)
+        {
+            if (listener is folderListeners[i])
+            {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (folderListeners.length is 1)
+        {
+            folderListeners = new CTabFolder2Listener[0];
+            return;
+        }
+        CTabFolder2Listener[]
+                newTabListeners = new CTabFolder2Listener[folderListeners.length - 1];
+        System.arraycopy(folderListeners, 0, newTabListeners, 0, index);
+        System.arraycopy(folderListeners, index + 1, newTabListeners, index,
+                folderListeners.length - index - 1);
+        folderListeners = newTabListeners;
+    }
+
+    /**  
+     * Removes the listener.
+     *
+     * @param listener the listener
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     * 
+     * @deprecated see removeCTabFolderCloseListener(CTabFolderListener)
+     */
+    public void removeCTabFolderListener (CTabFolderListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        if (tabListeners.length is 0)
+            return;
+        int index = -1;
+        for (int i = 0; i < tabListeners.length; i++)
+        {
+            if (listener is tabListeners[i])
+            {
+                index = i;
+                break;
+            }
+        }
+        if (index is -1)
+            return;
+        if (tabListeners.length is 1)
+        {
+            tabListeners = new CTabFolderListener[0];
+            return;
+        }
+        CTabFolderListener[]
+                newTabListeners = new CTabFolderListener[tabListeners.length - 1];
+        System.arraycopy(tabListeners, 0, newTabListeners, 0, index);
+        System.arraycopy(tabListeners, index + 1, newTabListeners, index,
+                tabListeners.length - index - 1);
+        tabListeners = newTabListeners;
+    }
+
+    /**  
+     * Removes the listener from the collection of listeners who will
+     * be notified when the user changes the receiver's selection.
+     *
+     * @param listener the listener which should no longer be notified
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see SelectionListener
+     * @see #addSelectionListener
+     */
+    public void removeSelectionListener (SelectionListener listener)
+    {
+        checkWidget();
+        if (listener is null)
+        {
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        }
+        removeListener(DWT.Selection, listener);
+        removeListener(DWT.DefaultSelection, listener);
+    }
+
+    public void setBackground (Color color)
+    {
+        super.setBackground(color);
+        redraw();
+    }
+
+    /**
+     * Specify a gradient of colours to be drawn in the background of the unselected tabs.
+     * For example to draw a gradient that varies from dark blue to blue and then to
+     * white, use the following call to setBackground:
+     * <pre>
+     *  cfolder.setBackground(new Color[]{display.getSystemColor(DWT.COLOR_DARK_BLUE), 
+     *                                 display.getSystemColor(DWT.COLOR_BLUE),
+     *                                 display.getSystemColor(DWT.COLOR_WHITE), 
+     *                                 display.getSystemColor(DWT.COLOR_WHITE)},
+     *                     new int[] {25, 50, 100});
+     * </pre>
+     *
+     * @param colors an array of Color that specifies the colors to appear in the gradient 
+     *               in order of appearance left to right.  The value <code>null</code> clears the
+     *               background gradient. The value <code>null</code> can be used inside the array of 
+     *               Color to specify the background color.
+     * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+     *                 of the widget at which the color should change.  The size of the percents array must be one 
+     *                 less than the size of the colors array.
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     *
+     * @since 3.0
+     */
+    void setBackground (Color[] colors, int[] percents)
+    {
+        setBackground(colors, percents, false);
+    }
+
+    /**
+     * Specify a gradient of colours to be drawn in the background of the unselected tab.
+     * For example to draw a vertical gradient that varies from dark blue to blue and then to
+     * white, use the following call to setBackground:
+     * <pre>
+     *  cfolder.setBackground(new Color[]{display.getSystemColor(DWT.COLOR_DARK_BLUE), 
+     *                                 display.getSystemColor(DWT.COLOR_BLUE),
+     *                                 display.getSystemColor(DWT.COLOR_WHITE), 
+     *                                 display.getSystemColor(DWT.COLOR_WHITE)},
+     *                        new int[] {25, 50, 100}, true);
+     * </pre>
+     *
+     * @param colors an array of Color that specifies the colors to appear in the gradient 
+     *               in order of appearance left to right.  The value <code>null</code> clears the
+     *               background gradient. The value <code>null</code> can be used inside the array of 
+     *               Color to specify the background color.
+     * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+     *                 of the widget at which the color should change.  The size of the percents array must be one 
+     *                 less than the size of the colors array.
+     * 
+     * @param vertical indicate the direction of the gradient.  True is vertical and false is horizontal. 
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     *
+     * @since 3.0
+     */
+    void setBackground (Color[] colors, int[] percents, bool vertical)
+    {
+        checkWidget();
+        if (colors !is null)
+        {
+            if (percents is null || percents.length !is colors.length - 1)
+            {
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            }
+            for (int i = 0; i < percents.length; i++)
+            {
+                if (percents[i] < 0 || percents[i] > 100)
+                {
+                    DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+                }
+                if (i > 0 && percents[i] < percents[i - 1])
+                {
+                    DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+                }
+            }
+            if (getDisplay().getDepth() < 15)
+            {
+                // Don't use gradients on low color displays
+                colors = new Color[][colors[colors.length - 1]];
+                percents = new int[][];
+            }
+        }
+
+        // Are these settings the same as before?
+        if (bgImage is null)
+        {
+            if ((gradientColors !is null) && (colors !is null) && (gradientColors.length is colors.length))
+            {
+                bool same = false;
+                for (int i = 0; i < gradientColors.length; i++)
+                {
+                    if (gradientColors[i] is null)
+                    {
+                        same = colors[i] is null;
+                    }
+                    else
+                    {
+                        same = gradientColors[i].opEquals(colors[i]);
+                    }
+                    if (!same)
+                        break;
+                }
+                if (same)
+                {
+                    for (int i = 0; i < gradientPercents.length; i++)
+                    {
+                        same = gradientPercents[i] is percents[i];
+                        if (!same)
+                            break;
+                    }
+                }
+                if (same && this.gradientVertical is vertical)
+                    return;
+            }
+        }
+        else
+        {
+            bgImage = null;
+        }
+        // Store the new settings
+        if (colors is null)
+        {
+            gradientColors = null;
+            gradientPercents = null;
+            gradientVertical = false;
+            setBackground(cast(Color) null);
+        }
+        else
+        {
+            gradientColors = new Color[colors.length];
+            for (int i = 0; i < colors.length; ++i)
+            {
+                gradientColors[i] = colors[i];
+            }
+            gradientPercents = new int[percents.length];
+            for (int i = 0; i < percents.length; ++i)
+            {
+                gradientPercents[i] = percents[i];
+            }
+            gradientVertical = vertical;
+            setBackground(gradientColors[gradientColors.length - 1]);
+        }
+
+        // Refresh with the new settings
+        redraw();
+    }
+
+    /**
+     * Set the image to be drawn in the background of the unselected tab.  Image
+     * is stretched or compressed to cover entire unselected tab area.
+     * 
+     * @param image the image to be drawn in the background
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    void setBackground (Image image)
+    {
+        checkWidget();
+        if (image is bgImage)
+            return;
+        if (image !is null)
+        {
+            gradientColors = null;
+            gradientPercents = null;
+        }
+        bgImage = image;
+        redraw();
+    }
+
+    /**
+     * Toggle the visibility of the border
+     * 
+     * @param show true if the border should be displayed
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setBorderVisible (bool show)
+    {
+        checkWidget();
+        if ((borderLeft is 1) is show)
+            return;
+        borderLeft = borderRight = show ? 1 : 0;
+        borderTop = onBottom ? borderLeft : 0;
+        borderBottom = onBottom ? 0 : borderLeft;
+        Rectangle rectBefore = getClientArea();
+        updateItems();
+        Rectangle rectAfter = getClientArea();
+        if (!rectBefore.opEquals(rectAfter))
+        {
+            notifyListeners(DWT.Resize, new Event());
+        }
+        redraw();
+    }
+
+    void setButtonBounds ()
+    {
+        Point size = getSize();
+        int oldX, oldY, oldWidth, oldHeight;
+        // max button
+        oldX = maxRect.x;
+        oldY = maxRect.y;
+        oldWidth = maxRect.width;
+        oldHeight = maxRect.height;
+        maxRect.x = maxRect.y = maxRect.width = maxRect.height = 0;
+        if (showMax)
+        {
+            maxRect.x = size.x - borderRight - BUTTON_SIZE - 3;
+            if (borderRight > 0)
+                maxRect.x += 1;
+            maxRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE) / 2 : borderTop + (tabHeight - BUTTON_SIZE) / 2;
+            maxRect.width = BUTTON_SIZE;
+            maxRect.height = BUTTON_SIZE;
+        }
+        if (oldX !is maxRect.x || oldWidth !is maxRect.width || oldY !is maxRect.y || oldHeight !is maxRect.height)
+        {
+            int left = Math.min(oldX, maxRect.x);
+            int right = Math.max(oldX + oldWidth, maxRect.x + maxRect.width);
+            int
+                    top = onBottom ? size.y - borderBottom - tabHeight : borderTop + 1;
+            redraw(left, top, right - left, tabHeight, false);
+        }
+
+        // min button
+        oldX = minRect.x;
+        oldY = minRect.y;
+        oldWidth = minRect.width;
+        oldHeight = minRect.height;
+        minRect.x = minRect.y = minRect.width = minRect.height = 0;
+        if (showMin)
+        {
+            minRect.x = size.x - borderRight - maxRect.width - BUTTON_SIZE - 3;
+            if (borderRight > 0)
+                minRect.x += 1;
+            minRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE) / 2 : borderTop + (tabHeight - BUTTON_SIZE) / 2;
+            minRect.width = BUTTON_SIZE;
+            minRect.height = BUTTON_SIZE;
+        }
+        if (oldX !is minRect.x || oldWidth !is minRect.width || oldY !is minRect.y || oldHeight !is minRect.height)
+        {
+            int left = Math.min(oldX, minRect.x);
+            int right = Math.max(oldX + oldWidth, minRect.x + minRect.width);
+            int
+                    top = onBottom ? size.y - borderBottom - tabHeight : borderTop + 1;
+            redraw(left, top, right - left, tabHeight, false);
+        }
+
+        // top right control
+        oldX = topRightRect.x;
+        oldY = topRightRect.y;
+        oldWidth = topRightRect.width;
+        oldHeight = topRightRect.height;
+        topRightRect.x = topRightRect.y = topRightRect.width = topRightRect.height = 0;
+        if (topRight !is null)
+        {
+            switch (topRightAlignment)
+            {
+                case DWT.FILL:
+                {
+                    int
+                            rightEdge = size.x - borderRight - 3 - maxRect.width - minRect.width;
+                    if (!simple && borderRight > 0 && !showMax && !showMin)
+                        rightEdge -= 2;
+                    if (single)
+                    {
+                        if (items.length is 0 || selectedIndex is -1)
+                        {
+                            topRightRect.x = borderLeft + 3;
+                            topRightRect.width = rightEdge - topRightRect.x;
+                        }
+                        else
+                        {
+                            // fill size is 0 if item compressed
+                            CTabItem item = items[selectedIndex];
+                            if (item.x + item.width + 7 + 3 * BUTTON_SIZE / 2 >= rightEdge)
+                                break;
+                            topRightRect.x = item.x + item.width + 7 + 3 * BUTTON_SIZE / 2;
+                            topRightRect.width = rightEdge - topRightRect.x;
+                        }
+                    }
+                    else
+                    {
+                        // fill size is 0 if chevron showing
+                        if (showChevron)
+                            break;
+                        if (items.length is 0)
+                        {
+                            topRightRect.x = borderLeft + 3;
+                        }
+                        else
+                        {
+                            CTabItem item = items[items.length - 1];
+                            topRightRect.x = item.x + item.width;
+                            if (!simple && items.length - 1 is selectedIndex)
+                                topRightRect.x += curveWidth - curveIndent;
+                        }
+                        topRightRect.width = Math.max(0,
+                                rightEdge - topRightRect.x);
+                    }
+                    topRightRect.y = onBottom ? size.y - borderBottom - tabHeight : borderTop + 1;
+                    topRightRect.height = tabHeight - 1;
+                    break;
+                }
+                case DWT.RIGHT:
+                {
+                    Point topRightSize = topRight.computeSize(DWT.DEFAULT,
+                            tabHeight, false);
+                    int
+                            rightEdge = size.x - borderRight - 3 - maxRect.width - minRect.width;
+                    if (!simple && borderRight > 0 && !showMax && !showMin)
+                        rightEdge -= 2;
+                    topRightRect.x = rightEdge - topRightSize.x;
+                    topRightRect.width = topRightSize.x;
+                    topRightRect.y = onBottom ? size.y - borderBottom - tabHeight : borderTop + 1;
+                    topRightRect.height = tabHeight - 1;
+                }
+            }
+            topRight.setBounds(topRightRect);
+        }
+        if (oldX !is topRightRect.x || oldWidth !is topRightRect.width || oldY !is topRightRect.y || oldHeight !is topRightRect.height)
+        {
+            int left = Math.min(oldX, topRightRect.x);
+            int right = Math.max(oldX + oldWidth,
+                    topRightRect.x + topRightRect.width);
+            int
+                    top = onBottom ? size.y - borderBottom - tabHeight : borderTop + 1;
+            redraw(left, top, right - left, tabHeight, false);
+        }
+
+        // chevron button
+        oldX = chevronRect.x;
+        oldY = chevronRect.y;
+        oldWidth = chevronRect.width;
+        oldHeight = chevronRect.height;
+        chevronRect.x = chevronRect.y = chevronRect.height = chevronRect.width = 0;
+        if (single)
+        {
+            if (selectedIndex is -1 || items.length > 1)
+            {
+                chevronRect.width = 3 * BUTTON_SIZE / 2;
+                chevronRect.height = BUTTON_SIZE;
+                chevronRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - chevronRect.height) / 2 : borderTop + (tabHeight - chevronRect.height) / 2;
+                if (selectedIndex is -1)
+                {
+                    chevronRect.x = size.x - borderRight - 3 - minRect.width - maxRect.width - topRightRect.width - chevronRect.width;
+                }
+                else
+                {
+                    CTabItem item = items[selectedIndex];
+                    int
+                            w = size.x - borderRight - 3 - minRect.width - maxRect.width - chevronRect.width;
+                    if (topRightRect.width > 0)
+                        w -= topRightRect.width + 3;
+                    chevronRect.x = Math.min(item.x + item.width + 3, w);
+                }
+                if (borderRight > 0)
+                    chevronRect.x += 1;
+            }
+        }
+        else
+        {
+            if (showChevron)
+            {
+                chevronRect.width = 3 * BUTTON_SIZE / 2;
+                chevronRect.height = BUTTON_SIZE;
+                int i = 0, lastIndex = -1;
+                while (i < priority.length && items[priority[i]].showing)
+                {
+                    lastIndex = Math.max(lastIndex, priority[i++]);
+                }
+                if (lastIndex is -1)
+                    lastIndex = firstIndex;
+                CTabItem lastItem = items[lastIndex];
+                int w = lastItem.x + lastItem.width + 3;
+                if (!simple && lastIndex is selectedIndex)
+                    w += curveWidth - 2 * curveIndent;
+                chevronRect.x = Math.min(w, getRightItemEdge());
+                chevronRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - chevronRect.height) / 2 : borderTop + (tabHeight - chevronRect.height) / 2;
+            }
+        }
+        if (oldX !is chevronRect.x || oldWidth !is chevronRect.width || oldY !is chevronRect.y || oldHeight !is chevronRect.height)
+        {
+            int left = Math.min(oldX, chevronRect.x);
+            int right = Math.max(oldX + oldWidth,
+                    chevronRect.x + chevronRect.width);
+            int
+                    top = onBottom ? size.y - borderBottom - tabHeight : borderTop + 1;
+            redraw(left, top, right - left, tabHeight, false);
+        }
+    }
+
+    public void setFont (Font font)
+    {
+        checkWidget();
+        if (font !is null && font.opEquals(getFont()))
+            return;
+        super.setFont(font);
+        oldFont = getFont();
+        if (!updateTabHeight(false))
+        {
+            updateItems();
+            redraw();
+        }
+    }
+
+    public void setForeground (Color color)
+    {
+        super.setForeground(color);
+        redraw();
+    }
+
+    /**
+     * Display an insert marker before or after the specified tab item. 
+     * 
+     * A value of null will clear the mark.
+     * 
+     * @param item the item with which the mark is associated or null
+     * 
+     * @param after true if the mark should be displayed after the specified item
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setInsertMark (CTabItem item, bool after)
+    {
+        checkWidget();
+    }
+
+    /**
+     * Display an insert marker before or after the specified tab item.
+     * 
+     * A value of -1 will clear the mark.
+     * 
+     * @param index the index of the item with which the mark is associated or null
+     * 
+     * @param after true if the mark should be displayed after the specified item
+     * 
+     * @exception IllegalArgumentException<ul>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setInsertMark (int index, bool after)
+    {
+        checkWidget();
+        if (index < -1 || index >= getItemCount())
+        {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+
+    bool setItemLocation ()
+    {
+        bool changed = false;
+        if (items.length is 0)
+            return false;
+        Point size = getSize();
+        int y = onBottom ? Math.max(borderBottom,
+                size.y - borderBottom - tabHeight) : borderTop;
+        if (single)
+        {
+            int defaultX = getDisplay().getBounds().width + 10; // off screen
+            for (int i = 0; i < items.length; i++)
+            {
+                CTabItem item = items[i];
+                if (i is selectedIndex)
+                {
+                    firstIndex = selectedIndex;
+                    int oldX = item.x, oldY = item.y;
+                    item.x = borderLeft;
+                    item.y = y;
+                    item.showing = true;
+                    if (showClose || item.showClose)
+                    {
+                        item.closeRect.x = borderLeft + CTabItem.LEFT_MARGIN;
+                        item.closeRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE) / 2 : borderTop + (tabHeight - BUTTON_SIZE) / 2;
+                    }
+                    if (item.x !is oldX || item.y !is oldY)
+                        changed = true;
+                }
+                else
+                {
+                    item.x = defaultX;
+                    item.showing = false;
+                }
+            }
+        }
+        else
+        {
+            int rightItemEdge = getRightItemEdge();
+            int maxWidth = rightItemEdge - borderLeft;
+            int width = 0;
+            for (int i = 0; i < priority.length; i++)
+            {
+                CTabItem item = items[priority[i]];
+                width += item.width;
+                item.showing = i is 0 ? true : item.width > 0 && width <= maxWidth;
+                if (!simple && priority[i] is selectedIndex)
+                    width += curveWidth - 2 * curveIndent;
+            }
+            int x = 0;
+            int defaultX = getDisplay().getBounds().width + 10; // off screen
+            firstIndex = items.length - 1;
+            for (int i = 0; i < items.length; i++)
+            {
+                CTabItem item = items[i];
+                if (!item.showing)
+                {
+                    if (item.x !is defaultX)
+                        changed = true;
+                    item.x = defaultX;
+                }
+                else
+                {
+                    firstIndex = Math.min(firstIndex, i);
+                    if (item.x !is x || item.y !is y)
+                        changed = true;
+                    item.x = x;
+                    item.y = y;
+                    if (i is selectedIndex)
+                    {
+                        int edge = Math.min(item.x + item.width, rightItemEdge);
+                        item.closeRect.x = edge - CTabItem.RIGHT_MARGIN - BUTTON_SIZE;
+                    }
+                    else
+                    {
+                        item.closeRect.x = item.x + item.width - CTabItem.RIGHT_MARGIN - BUTTON_SIZE;
+                    }
+                    item.closeRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE) / 2 : borderTop + (tabHeight - BUTTON_SIZE) / 2;
+                    x = x + item.width;
+                    if (!simple && i is selectedIndex)
+                        x += curveWidth - 2 * curveIndent;
+                }
+            }
+        }
+        return changed;
+    }
+
+    bool setItemSize ()
+    {
+        bool changed = false;
+        if (isDisposed())
+            return changed;
+        Point size = getSize();
+        if (size.x <= 0 || size.y <= 0)
+            return changed;
+        xClient = borderLeft + marginWidth + highlight_margin;
+        if (onBottom)
+        {
+            yClient = borderTop + highlight_margin + marginHeight;
+        }
+        else
+        {
+            yClient = borderTop + tabHeight + highlight_header + marginHeight;
+        }
+        showChevron = false;
+        if (single)
+        {
+            showChevron = true;
+            if (selectedIndex !is -1)
+            {
+                CTabItem tab = items[selectedIndex];
+                GC gc = new GC(this);
+                int width = tab.preferredWidth(gc, true, false);
+                gc.dispose();
+                width = Math.min(width, getRightItemEdge() - borderLeft);
+                if (tab.height !is tabHeight || tab.width !is width)
+                {
+                    changed = true;
+                    tab.shortenedText = null;
+                    tab.shortenedTextWidth = 0;
+                    tab.height = tabHeight;
+                    tab.width = width;
+                    tab.closeRect.width = tab.closeRect.height = 0;
+                    if (showClose || tab.showClose)
+                    {
+                        tab.closeRect.width = BUTTON_SIZE;
+                        tab.closeRect.height = BUTTON_SIZE;
+                    }
+                }
+            }
+            return changed;
+        }
+
+        if (items.length is 0)
+            return changed;
+
+        int[] widths;
+        GC gc = new GC(this);
+        int tabAreaWidth = size.x - borderLeft - borderRight - 3;
+        if (showMin)
+            tabAreaWidth -= BUTTON_SIZE;
+        if (showMax)
+            tabAreaWidth -= BUTTON_SIZE;
+        if (topRightAlignment is DWT.RIGHT && topRight !is null)
+        {
+            Point rightSize = topRight.computeSize(DWT.DEFAULT, DWT.DEFAULT,
+                    false);
+            tabAreaWidth -= rightSize.x + 3;
+        }
+        if (!simple)
+            tabAreaWidth -= curveWidth - 2 * curveIndent;
+        tabAreaWidth = Math.max(0, tabAreaWidth);
+
+        // First, try the minimum tab size at full compression.
+        int minWidth = 0;
+        int[] minWidths = new int[items.length];
+        for (int i = 0; i < priority.length; i++)
+        {
+            int index = priority[i];
+            minWidths[index] = items[index].preferredWidth(gc,
+                    index is selectedIndex, true);
+            minWidth += minWidths[index];
+            if (minWidth > tabAreaWidth)
+                break;
+        }
+        if (minWidth > tabAreaWidth)
+        {
+            // full compression required and a chevron
+            showChevron = items.length > 1;
+            if (showChevron)
+                tabAreaWidth -= 3 * BUTTON_SIZE / 2;
+            widths = minWidths;
+            int index = selectedIndex !is -1 ? selectedIndex : 0;
+            if (tabAreaWidth < widths[index])
+            {
+                widths[index] = Math.max(0, tabAreaWidth);
+            }
+        }
+        else
+        {
+            int maxWidth = 0;
+            int[] maxWidths = new int[items.length];
+            for (int i = 0; i < items.length; i++)
+            {
+                maxWidths[i] = items[i].preferredWidth(gc, i is selectedIndex,
+                        false);
+                maxWidth += maxWidths[i];
+            }
+            if (maxWidth <= tabAreaWidth)
+            {
+                // no compression required
+                widths = maxWidths;
+            }
+            else
+            {
+                // determine compression for each item
+                int extra = (tabAreaWidth - minWidth) / items.length;
+                while (true)
+                {
+                    int large = 0, totalWidth = 0;
+                    for (int i = 0; i < items.length; i++)
+                    {
+                        if (maxWidths[i] > minWidths[i] + extra)
+                        {
+                            totalWidth += minWidths[i] + extra;
+                            large++;
+                        }
+                        else
+                        {
+                            totalWidth += maxWidths[i];
+                        }
+                    }
+                    if (totalWidth >= tabAreaWidth)
+                    {
+                        extra--;
+                        break;
+                    }
+                    if (large is 0 || tabAreaWidth - totalWidth < large)
+                        break;
+                    extra++;
+                }
+                widths = new int[items.length];
+                for (int i = 0; i < items.length; i++)
+                {
+                    widths[i] = Math.min(maxWidths[i], minWidths[i] + extra);
+                }
+            }
+        }
+        gc.dispose();
+
+        for (int i = 0; i < items.length; i++)
+        {
+            CTabItem tab = items[i];
+            int width = widths[i];
+            if (tab.height !is tabHeight || tab.width !is width)
+            {
+                changed = true;
+                tab.shortenedText = null;
+                tab.shortenedTextWidth = 0;
+                tab.height = tabHeight;
+                tab.width = width;
+                tab.closeRect.width = tab.closeRect.height = 0;
+                if (showClose || tab.showClose)
+                {
+                    if (i is selectedIndex || showUnselectedClose)
+                    {
+                        tab.closeRect.width = BUTTON_SIZE;
+                        tab.closeRect.height = BUTTON_SIZE;
+                    }
+                }
+            }
+        }
+        return changed;
+    }
+
+    /**
+     * Marks the receiver's maximize button as visible if the argument is <code>true</code>,
+     * and marks it invisible otherwise. 
+     *
+     * @param visible the new visibility state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setMaximizeVisible (bool visible)
+    {
+        checkWidget();
+        if (showMax is visible)
+            return;
+        // display maximize button
+        showMax = visible;
+        updateItems();
+        redraw();
+    }
+
+    /**
+     * Sets the layout which is associated with the receiver to be
+     * the argument which may be null.
+     * <p>
+     * Note: No Layout can be set on this Control because it already
+     * manages the size and position of its children.
+     * </p>
+     *
+     * @param layout the receiver's new layout or null
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setLayout (Layout layout)
+    {
+        checkWidget();
+        return;
+    }
+
+    /**
+     * Sets the maximized state of the receiver.
+     *
+     * @param maximize the new maximized state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void setMaximized (bool maximize)
+    {
+        checkWidget();
+        if (this.maximized is maximize)
+            return;
+        if (maximize && this.minimized)
+            setMinimized(false);
+        this.maximized = maximize;
+        redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
+    }
+
+    /**
+     * Marks the receiver's minimize button as visible if the argument is <code>true</code>,
+     * and marks it invisible otherwise. 
+     *
+     * @param visible the new visibility state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setMinimizeVisible (bool visible)
+    {
+        checkWidget();
+        if (showMin is visible)
+            return;
+        // display minimize button
+        showMin = visible;
+        updateItems();
+        redraw();
+    }
+
+    /**
+     * Sets the minimized state of the receiver.
+     *
+     * @param minimize the new minimized state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void setMinimized (bool minimize)
+    {
+        checkWidget();
+        if (this.minimized is minimize)
+            return;
+        if (minimize && this.maximized)
+            setMaximized(false);
+        this.minimized = minimize;
+        redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
+    }
+
+    /**
+     * Sets the minimum number of characters that will 
+     * be displayed in a fully compressed tab.
+     * 
+     * @param count the minimum number of characters that will be displayed in a fully compressed tab
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_RANGE - if the count is less than zero</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setMinimumCharacters (int count)
+    {
+        checkWidget();
+        if (count < 0)
+            DWT.error(DWT.ERROR_INVALID_RANGE);
+        if (minChars is count)
+            return;
+        minChars = count;
+        if (updateItems())
+            redrawTabs();
+    }
+
+    /**
+     * When there is not enough horizontal space to show all the tabs,
+     * by default, tabs are shown sequentially from left to right in 
+     * order of their index.  When the MRU visibility is turned on,
+     * the tabs that are visible will be the tabs most recently selected.
+     * Tabs will still maintain their left to right order based on index 
+     * but only the most recently selected tabs are visible.
+     * <p>
+     * For example, consider a CTabFolder that contains "Tab 1", "Tab 2",
+     * "Tab 3" and "Tab 4" (in order by index).  The user selects
+     * "Tab 1" and then "Tab 3".  If the CTabFolder is now
+     * compressed so that only two tabs are visible, by default, 
+     * "Tab 2" and "Tab 3" will be shown ("Tab 3" since it is currently 
+     * selected and "Tab 2" because it is the previous item in index order).
+     * If MRU visibility is enabled, the two visible tabs will be "Tab 1"
+     * and "Tab 3" (in that order from left to right).</p>
+     *
+     * @param show the new visibility state
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.1
+     */
+    public void setMRUVisible (bool show)
+    {
+        checkWidget();
+        if (mru is show)
+            return;
+        mru = show;
+        if (!mru)
+        {
+            int idx = firstIndex;
+            int next = 0;
+            for (int i = firstIndex; i < items.length; i++)
+            {
+                priority[next++] = i;
+            }
+            for (int i = 0; i < idx; i++)
+            {
+                priority[next++] = i;
+            }
+            if (updateItems())
+                redrawTabs();
+        }
+    }
+
+    /**
+     * Set the selection to the tab at the specified item.
+     * 
+     * @param item the tab item to be selected
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+     * </ul>
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     * </ul>
+     */
+    public void setSelection (CTabItem item)
+    {
+        checkWidget();
+        if (item is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        int index = indexOf(item);
+        setSelection(index);
+    }
+
+    /**
+     * Set the selection to the tab at the specified index.
+     * 
+     * @param index the index of the tab item to be selected
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setSelection (int index)
+    {
+        checkWidget();
+        if (index < 0 || index >= items.length)
+            return;
+        CTabItem selection = items[index];
+        if (selectedIndex is index)
+        {
+            showItem(selection);
+            return;
+        }
+
+        int oldIndex = selectedIndex;
+        selectedIndex = index;
+        if (oldIndex !is -1)
+        {
+            items[oldIndex].closeImageState = NONE;
+        }
+        selection.closeImageState = NORMAL;
+        selection.showing = false;
+
+        Control newControl = selection.control;
+        Control oldControl = null;
+        if (oldIndex !is -1)
+        {
+            oldControl = items[oldIndex].control;
+        }
+
+        if (newControl !is oldControl)
+        {
+            if (newControl !is null && !newControl.isDisposed())
+            {
+                newControl.setBounds(getClientArea());
+                newControl.setVisible(true);
+            }
+            if (oldControl !is null && !oldControl.isDisposed())
+            {
+                oldControl.setVisible(false);
+            }
+        }
+        showItem(selection);
+        redraw();
+    }
+
+    void setSelection (int index, bool notify)
+    {
+        int oldSelectedIndex = selectedIndex;
+        setSelection(index);
+        if (notify && selectedIndex !is oldSelectedIndex && selectedIndex !is -1)
+        {
+            Event event = new Event();
+            event.item = getItem(selectedIndex);
+            notifyListeners(DWT.Selection, event);
+        }
+    }
+
+    /**
+     * Sets the receiver's selection background color to the color specified
+     * by the argument, or to the default system color for the control
+     * if the argument is null.
+     *
+     * @param color the new color (or null)
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void setSelectionBackground (Color color)
+    {
+        checkWidget();
+        setSelectionHighlightGradientColor(null);
+        if (selectionBackground is color)
+            return;
+        if (color is null)
+            color = getDisplay().getSystemColor(SELECTION_BACKGROUND);
+        selectionBackground = color;
+        if (selectedIndex > -1)
+            redraw();
+    }
+
+    /**
+     * Specify a gradient of colours to be draw in the background of the selected tab.
+     * For example to draw a gradient that varies from dark blue to blue and then to
+     * white, use the following call to setBackground:
+     * <pre>
+     *  cfolder.setBackground(new Color[]{display.getSystemColor(DWT.COLOR_DARK_BLUE), 
+     *                                 display.getSystemColor(DWT.COLOR_BLUE),
+     *                                 display.getSystemColor(DWT.COLOR_WHITE), 
+     *                                 display.getSystemColor(DWT.COLOR_WHITE)},
+     *                     new int[] {25, 50, 100});
+     * </pre>
+     *
+     * @param colors an array of Color that specifies the colors to appear in the gradient 
+     *               in order of appearance left to right.  The value <code>null</code> clears the
+     *               background gradient. The value <code>null</code> can be used inside the array of 
+     *               Color to specify the background color.
+     * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+     *                 of the widget at which the color should change.  The size of the percents array must be one 
+     *                 less than the size of the colors array.
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     */
+    public void setSelectionBackground (Color[] colors, int[] percents)
+    {
+        setSelectionBackground(colors, percents, false);
+    }
+
+    /**
+     * Specify a gradient of colours to be draw in the background of the selected tab.
+     * For example to draw a vertical gradient that varies from dark blue to blue and then to
+     * white, use the following call to setBackground:
+     * <pre>
+     *  cfolder.setBackground(new Color[]{display.getSystemColor(DWT.COLOR_DARK_BLUE), 
+     *                                 display.getSystemColor(DWT.COLOR_BLUE),
+     *                                 display.getSystemColor(DWT.COLOR_WHITE), 
+     *                                 display.getSystemColor(DWT.COLOR_WHITE)},
+     *                        new int[] {25, 50, 100}, true);
+     * </pre>
+     *
+     * @param colors an array of Color that specifies the colors to appear in the gradient 
+     *               in order of appearance left to right.  The value <code>null</code> clears the
+     *               background gradient. The value <code>null</code> can be used inside the array of 
+     *               Color to specify the background color.
+     * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+     *                 of the widget at which the color should change.  The size of the percents array must be one 
+     *                 less than the size of the colors array.
+     * 
+     * @param vertical indicate the direction of the gradient.  True is vertical and false is horizontal. 
+     * 
+     * @exception DWTException <ul>
+     *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+     *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+     *  </ul>
+     *
+     * @since 3.0
+     */
+    public void setSelectionBackground (Color[] colors, int[] percents,
+            bool vertical)
+    {
+        checkWidget();
+        int colorsLength;
+        Color highlightBeginColor = null; //null is no highlight
+
+        if (colors !is null)
+        {
+            //The colors array can optionally have an extra entry which describes the highlight top color
+            //Thus its either one or two larger than the percents array
+            if (percents is null || !((percents.length is colors.length - 1) || (percents.length is colors.length - 2)))
+            {
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            }
+            for (int i = 0; i < percents.length; i++)
+            {
+                if (percents[i] < 0 || percents[i] > 100)
+                {
+                    DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+                }
+                if (i > 0 && percents[i] < percents[i - 1])
+                {
+                    DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+                }
+            }
+            //If the colors is exactly two more than percents then last is highlight
+            //Keep track of *real* colorsLength (minus the highlight)
+            if (percents.length is colors.length - 2)
+            {
+                highlightBeginColor = colors[colors.length - 1];
+                colorsLength = colors.length - 1;
+            }
+            else
+            {
+                colorsLength = colors.length;
+            }
+            if (getDisplay().getDepth() < 15)
+            {
+                // Don't use gradients on low color displays
+                colors = new Color[][colors[colorsLength - 1]];
+                colorsLength = colors.length;
+                percents = new int[][];
+            }
+        }
+        else
+        {
+            colorsLength = 0;
+        }
+
+        // Are these settings the same as before?
+        if (selectionBgImage is null)
+        {
+            if ((selectionGradientColors !is null) && (colors !is null) && (selectionGradientColors.length is colorsLength))
+            {
+                bool same = false;
+                for (int i = 0; i < selectionGradientColors.length; i++)
+                {
+                    if (selectionGradientColors[i] is null)
+                    {
+                        same = colors[i] is null;
+                    }
+                    else
+                    {
+                        same = selectionGradientColors[i].opEquals(colors[i]);
+                    }
+                    if (!same)
+                        break;
+                }
+                if (same)
+                {
+                    for (int i = 0; i < selectionGradientPercents.length; i++)
+                    {
+                        same = selectionGradientPercents[i] is percents[i];
+                        if (!same)
+                            break;
+                    }
+                }
+                if (same && this.selectionGradientVertical is vertical)
+                    return;
+            }
+        }
+        else
+        {
+            selectionBgImage = null;
+        }
+        // Store the new settings
+        if (colors is null)
+        {
+            selectionGradientColors = null;
+            selectionGradientPercents = null;
+            selectionGradientVertical = false;
+            setSelectionBackground(cast(Color) null);
+            setSelectionHighlightGradientColor(null);
+        }
+        else
+        {
+            selectionGradientColors = new Color[colorsLength];
+            for (int i = 0; i < colorsLength; ++i)
+            {
+                selectionGradientColors[i] = colors[i];
+            }
+            selectionGradientPercents = new int[percents.length];
+            for (int i = 0; i < percents.length; ++i)
+            {
+                selectionGradientPercents[i] = percents[i];
+            }
+            selectionGradientVertical = vertical;
+            setSelectionBackground(
+                    selectionGradientColors[selectionGradientColors.length - 1]);
+            setSelectionHighlightGradientColor(highlightBeginColor);
+        }
+
+        // Refresh with the new settings
+        if (selectedIndex > -1)
+            redraw();
+    }
+
+    /*
+     * Set the color for the highlight start for selected tabs.
+     * Update the cache of highlight gradient colors if required.
+     */
+
+    void setSelectionHighlightGradientColor (Color start)
+    {
+        //Set to null to match all the early return cases.
+        //For early returns, don't realloc the cache, we may get a cache hit next time we're given the highlight
+        selectionHighlightGradientBegin = null;
+
+        if (start is null)
+            return;
+
+        //don't bother on low colour
+        if (getDisplay().getDepth() < 15)
+            return;
+
+        //don't bother if we don't have a background gradient
+        if (selectionGradientColors.length < 2)
+            return;
+
+        //OK we know its a valid gradient now
+        selectionHighlightGradientBegin = start;
+
+        if (!isSelectionHighlightColorsCacheHit(start))
+            createSelectionHighlightGradientColors(start); //if no cache hit then compute new ones
+    }
+
+    /*
+     * Return true if given start color, the cache of highlight colors we have
+     * would match the highlight colors we'd compute.
+     */
+    bool isSelectionHighlightColorsCacheHit (Color start)
+    {
+
+        if (selectionHighlightGradientColorsCache is null)
+            return false;
+
+        //this case should never happen but check to be safe before accessing array indexes
+        if (selectionHighlightGradientColorsCache.length < 2)
+            return false;
+
+        Color highlightBegin = selectionHighlightGradientColorsCache[0];
+        Color
+                highlightEnd = selectionHighlightGradientColorsCache[selectionHighlightGradientColorsCache.length - 1];
+
+        if (!highlightBegin.opEquals(start))
+            return false;
+
+        //Compare number of colours we have vs. we'd compute
+        if (selectionHighlightGradientColorsCache.length !is tabHeight)
+            return false;
+
+        //Compare existing highlight end to what it would be (selectionBackground)
+        if (!highlightEnd.opEquals(selectionBackground))
+            return false;
+
+        return true;
+    }
+
+    /**
+     * Set the image to be drawn in the background of the selected tab.  Image
+     * is stretched or compressed to cover entire selection tab area.
+     * 
+     * @param image the image to be drawn in the background
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setSelectionBackground (Image image)
+    {
+        checkWidget();
+        setSelectionHighlightGradientColor(null);
+        if (image is selectionBgImage)
+            return;
+        if (image !is null)
+        {
+            selectionGradientColors = null;
+            selectionGradientPercents = null;
+            disposeSelectionHighlightGradientColors();
+        }
+        selectionBgImage = image;
+        if (selectedIndex > -1)
+            redraw();
+    }
+
+    /**
+     * Set the foreground color of the selected tab.
+     * 
+     * @param color the color of the text displayed in the selected tab
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setSelectionForeground (Color color)
+    {
+        checkWidget();
+        if (selectionForeground is color)
+            return;
+        if (color is null)
+            color = getDisplay().getSystemColor(SELECTION_FOREGROUND);
+        selectionForeground = color;
+        if (selectedIndex > -1)
+            redraw();
+    }
+
+    /*
+     * Allocate colors for the highlight line.
+     * Colours will be a gradual blend ranging from to.
+     * Blend length will be tab height.
+     * Recompute this if tab height changes.
+     * Could remain null if there'd be no gradient (start=end or low colour display)
+     */
+    void createSelectionHighlightGradientColors (Color start)
+    {
+        disposeSelectionHighlightGradientColors(); //dispose if existing
+
+        if (start is null)
+            //shouldn't happen but just to be safe
+            return;
+
+        //alloc colours for entire height to ensure it matches wherever we stop drawing
+        int fadeGradientSize = tabHeight;
+
+        RGB from = start.getRGB();
+        RGB to = selectionBackground.getRGB();
+
+        selectionHighlightGradientColorsCache = new Color[fadeGradientSize];
+        int denom = fadeGradientSize - 1;
+
+        for (int i = 0; i < fadeGradientSize; i++)
+        {
+            int propFrom = denom - i;
+            int propTo = i;
+            int red = (to.red * propTo + from.red * propFrom) / denom;
+            int green = (to.green * propTo + from.green * propFrom) / denom;
+            int blue = (to.blue * propTo + from.blue * propFrom) / denom;
+            selectionHighlightGradientColorsCache[i] = new Color(getDisplay(),
+                    red, green, blue);
+        }
+    }
+
+    void disposeSelectionHighlightGradientColors ()
+    {
+        if (selectionHighlightGradientColorsCache is null)
+            return;
+        for (int i = 0; i < selectionHighlightGradientColorsCache.length; i++)
+        {
+            selectionHighlightGradientColorsCache[i].dispose();
+        }
+        selectionHighlightGradientColorsCache = null;
+    }
+
+    /*
+     * Return the gradient start color for selected tabs, which is the start of the tab fade
+     * (end is selectionBackground).
+     */
+    Color getSelectionBackgroundGradientBegin ()
+    {
+        if (selectionGradientColors is null)
+            return getSelectionBackground();
+        if (selectionGradientColors.length is 0)
+            return getSelectionBackground();
+        return selectionGradientColors[0];
+    }
+
+    /**
+     * Sets the shape that the CTabFolder will use to render itself.  
+     * 
+     * @param simple <code>true</code> if the CTabFolder should render itself in a simple, traditional style
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @since 3.0
+     */
+    public void setSimple (bool simple)
+    {
+        checkWidget();
+        if (this.simple !is simple)
+        {
+            this.simple = simple;
+            Rectangle rectBefore = getClientArea();
+            updateItems();
+            Rectangle rectAfter = getClientArea();
+            if (!rectBefore.opEquals(rectAfter))
+            {
+                notifyListeners(DWT.Resize, new Event());
+            }
+            redraw();
+        }
+    }
+
+    /**
+     * Sets the number of tabs that the CTabFolder should display
+     * 
+     * @param single <code>true</code> if only the selected tab should be displayed otherwise, multiple tabs will be shown.
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setSingle (bool single)
+    {
+        checkWidget();
+        if (this.single !is single)
+        {
+            this.single = single;
+            if (!single)
+            {
+                for (int i = 0; i < items.length; i++)
+                {
+                    if (i !is selectedIndex && items[i].closeImageState is NORMAL)
+                    {
+                        items[i].closeImageState = NONE;
+                    }
+                }
+            }
+            Rectangle rectBefore = getClientArea();
+            updateItems();
+            Rectangle rectAfter = getClientArea();
+            if (!rectBefore.opEquals(rectAfter))
+            {
+                notifyListeners(DWT.Resize, new Event());
+            }
+            redraw();
+        }
+    }
+
+    /**
+     * Specify a fixed height for the tab items.  If no height is specified,
+     * the default height is the height of the text or the image, whichever 
+     * is greater. Specifying a height of -1 will revert to the default height.
+     * 
+     * @param height the pixel value of the height or -1
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if called with a height of less than 0</li>
+     * </ul>
+     */
+    public void setTabHeight (int height)
+    {
+        checkWidget();
+        if (height < -1)
+        {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        fixedTabHeight = height;
+        updateTabHeight(false);
+    }
+
+    /**
+     * Specify whether the tabs should appear along the top of the folder 
+     * or along the bottom of the folder.
+     * 
+     * @param position <code>DWT.TOP</code> for tabs along the top or <code>DWT.BOTTOM</code> for tabs along the bottom
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the position value is not either DWT.TOP or DWT.BOTTOM</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setTabPosition (int position)
+    {
+        checkWidget();
+        if (position !is DWT.TOP && position !is DWT.BOTTOM)
+        {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        if (onBottom !is (position is DWT.BOTTOM))
+        {
+            onBottom = position is DWT.BOTTOM;
+            borderTop = onBottom ? borderLeft : 0;
+            borderBottom = onBottom ? 0 : borderRight;
+            updateTabHeight(true);
+            Rectangle rectBefore = getClientArea();
+            updateItems();
+            Rectangle rectAfter = getClientArea();
+            if (!rectBefore.opEquals(rectAfter))
+            {
+                notifyListeners(DWT.Resize, new Event());
+            }
+            redraw();
+        }
+    }
+
+    /**
+     * Set the control that appears in the top right corner of the tab folder.
+     * Typically this is a close button or a composite with a Menu and close button. 
+     * The topRight control is optional.  Setting the top right control to null will 
+     * remove it from the tab folder.
+     * 
+     * @param control the control to be displayed in the top right corner or null
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this CTabFolder</li>
+     * </ul>
+     * 
+     * @since 2.1
+     */
+    public void setTopRight (Control control)
+    {
+        setTopRight(control, DWT.RIGHT);
+    }
+
+    /**
+     * Set the control that appears in the top right corner of the tab folder.
+     * Typically this is a close button or a composite with a Menu and close button. 
+     * The topRight control is optional.  Setting the top right control to null 
+     * will remove it from the tab folder.
+     * <p>
+     * The alignment parameter sets the layout of the control in the tab area.
+     * <code>DWT.RIGHT</code> will cause the control to be positioned on the far 
+     * right of the folder and it will have its default size.  <code>DWT.FILL</code> 
+     * will size the control to fill all the available space to the right of the
+     * last tab.  If there is no available space, the control will not be visible.
+     * </p>
+     *
+     * @param control the control to be displayed in the top right corner or null
+     * @param alignment <code>DWT.RIGHT</code> or <code>DWT.FILL</code> 
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this CTabFolder</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setTopRight (Control control, int alignment)
+    {
+        checkWidget();
+        if (alignment !is DWT.RIGHT && alignment !is DWT.FILL)
+        {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        if (control !is null && control.getParent() !is this)
+        {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        topRight = control;
+        topRightAlignment = alignment;
+        if (updateItems())
+            redraw();
+    }
+
+    /**
+     * Specify whether the close button appears 
+     * when the user hovers over an unselected tabs.
+     * 
+     * @param visible <code>true</code> makes the close button appear
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setUnselectedCloseVisible (bool visible)
+    {
+        checkWidget();
+        if (showUnselectedClose is visible)
+            return;
+        // display close button when mouse hovers
+        showUnselectedClose = visible;
+        updateItems();
+        redraw();
+    }
+
+    /**
+     * Specify whether the image appears on unselected tabs.
+     * 
+     * @param visible <code>true</code> makes the image appear
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setUnselectedImageVisible (bool visible)
+    {
+        checkWidget();
+        if (showUnselectedImage is visible)
+            return;
+        // display image on unselected items
+        showUnselectedImage = visible;
+        updateItems();
+        redraw();
+    }
+
+    /**
+     * Shows the item.  If the item is already showing in the receiver,
+     * this method simply returns.  Otherwise, the items are scrolled until
+     * the item is visible.
+     * 
+     * @param item the item to be shown
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+     *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see CTabFolder#showSelection()
+     *
+     * @since 2.0
+     */
+    public void showItem (CTabItem item)
+    {
+        checkWidget();
+        if (item is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        if (item.isDisposed())
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        int index = indexOf(item);
+        if (index is -1)
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        int idx = -1;
+        for (int i = 0; i < priority.length; i++)
+        {
+            if (priority[i] is index)
+            {
+                idx = i;
+                break;
+            }
+        }
+        if (mru)
+        {
+            // move to front of mru order
+            int[] newPriority = new int[priority.length];
+            System.arraycopy(priority, 0, newPriority, 1, idx);
+            System.arraycopy(priority, idx + 1, newPriority, idx + 1,
+                    priority.length - idx - 1);
+            newPriority[0] = index;
+            priority = newPriority;
+        }
+        if (item.isShowing())
+            return;
+        updateItems(index);
+        redrawTabs();
+    }
+
+    void showList (Rectangle rect)
+    {
+        if (items.length is 0 || !showChevron)
+            return;
+        if (showMenu is null || showMenu.isDisposed())
+        {
+            showMenu = new Menu(this);
+        }
+        else
+        {
+            MenuItem[] items = showMenu.getItems();
+            for (int i = 0; i < items.length; i++)
+            {
+                items[i].dispose();
+            }
+        }
+        const String id = "CTabFolder_showList_Index"; //$NON-NLS-1$
+        for (int i = 0; i < items.length; i++)
+        {
+            CTabItem tab = items[i];
+            if (tab.showing)
+                continue;
+            MenuItem item = new MenuItem(showMenu, DWT.NONE);
+            item.setText(tab.getText());
+            item.setImage(tab.getImage());
+            item.setData(id, tab);
+            item.addSelectionListener(new class SelectionAdapter
+            {
+                public void widgetSelected (SelectionEvent e)
+                {
+                    MenuItem menuItem = cast(MenuItem) e.widget;
+                    int index = indexOf(cast(CTabItem) menuItem.getData(id));
+                    this.setSelection(index, true);
+                }
+            });
+        }
+        int x = rect.x;
+        int y = rect.y + rect.height;
+        Point location = getDisplay().map(this, null, x, y);
+        showMenu.setLocation(location.x, location.y);
+        showMenu.setVisible(true);
+    }
+
+    /**
+     * Shows the selection.  If the selection is already showing in the receiver,
+     * this method simply returns.  Otherwise, the items are scrolled until
+     * the selection is visible.
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     *
+     * @see CTabFolder#showItem(CTabItem)
+     * 
+     * @since 2.0
+     */
+    public void showSelection ()
+    {
+        checkWidget();
+        if (selectedIndex !is -1)
+        {
+            showItem(getSelection());
+        }
+    }
+
+    void _setToolTipText (int x, int y)
+    {
+        String oldTip = getToolTipText();
+        String newTip = _getToolTip(x, y);
+        if (newTip is null || !newTip.opEquals(oldTip))
+        {
+            setToolTipText(newTip);
+        }
+    }
+
+    bool updateItems ()
+    {
+        return updateItems(selectedIndex);
+    }
+
+    bool updateItems (int showIndex)
+    {
+        if (!single && !mru && showIndex !is -1)
+        {
+            // make sure selected item will be showing
+            int firstIndex = showIndex;
+            if (priority[0] < showIndex)
+            {
+                int maxWidth = getRightItemEdge() - borderLeft;
+                if (!simple)
+                    maxWidth -= curveWidth - 2 * curveIndent;
+                int width = 0;
+                int[] widths = new int[items.length];
+                GC gc = new GC(this);
+                for (int i = priority[0]; i <= showIndex; i++)
+                {
+                    widths[i] = items[i].preferredWidth(gc, i is selectedIndex,
+                            true);
+                    width += widths[i];
+                    if (width > maxWidth)
+                        break;
+                }
+                if (width > maxWidth)
+                {
+                    width = 0;
+                    for (int i = showIndex; i >= 0; i--)
+                    {
+                        if (widths[i] is 0)
+                            widths[i] = items[i].preferredWidth(gc,
+                                    i is selectedIndex, true);
+                        width += widths[i];
+                        if (width > maxWidth)
+                            break;
+                        firstIndex = i;
+                    }
+                }
+                else
+                {
+                    firstIndex = priority[0];
+                    for (int i = showIndex + 1; i < items.length; i++)
+                    {
+                        widths[i] = items[i].preferredWidth(gc,
+                                i is selectedIndex, true);
+                        width += widths[i];
+                        if (width >= maxWidth)
+                            break;
+                    }
+                    if (width < maxWidth)
+                    {
+                        for (int i = priority[0] - 1; i >= 0; i--)
+                        {
+                            if (widths[i] is 0)
+                                widths[i] = items[i].preferredWidth(gc,
+                                        i is selectedIndex, true);
+                            width += widths[i];
+                            if (width > maxWidth)
+                                break;
+                            firstIndex = i;
+                        }
+                    }
+                }
+                gc.dispose();
+            }
+            if (firstIndex !is priority[0])
+            {
+                int index = 0;
+                for (int i = firstIndex; i < items.length; i++)
+                {
+                    priority[index++] = i;
+                }
+                for (int i = 0; i < firstIndex; i++)
+                {
+                    priority[index++] = i;
+                }
+            }
+        }
+
+        bool oldShowChevron = showChevron;
+        bool changed = setItemSize();
+        changed |= setItemLocation();
+        setButtonBounds();
+        changed |= showChevron !is oldShowChevron;
+        if (changed && getToolTipText() !is null)
+        {
+            Point pt = getDisplay().getCursorLocation();
+            pt = toControl(pt);
+            _setToolTipText(pt.x, pt.y);
+        }
+        return changed;
+    }
+
+    bool updateTabHeight (bool force)
+    {
+        int style = getStyle();
+        if (fixedTabHeight is 0 && (style & DWT.FLAT) !is 0 && (style & DWT.BORDER) is 0)
+            highlight_header = 0;
+        int oldHeight = tabHeight;
+        if (fixedTabHeight !is DWT.DEFAULT)
+        {
+            tabHeight = fixedTabHeight is 0 ? 0 : fixedTabHeight + 1; // +1 for line drawn across top of tab
+        }
+        else
+        {
+            int tempHeight = 0;
+            GC gc = new GC(this);
+            if (items.length is 0)
+            {
+                tempHeight = gc.textExtent("Default", CTabItem.FLAGS).y + CTabItem.TOP_MARGIN + CTabItem.BOTTOM_MARGIN; //$NON-NLS-1$
+            }
+            else
+            {
+                for (int i = 0; i < items.length; i++)
+                {
+                    tempHeight = Math.max(tempHeight, items[i].preferredHeight(
+                            gc));
+                }
+            }
+            gc.dispose();
+            tabHeight = tempHeight;
+        }
+        if (!force && tabHeight is oldHeight)
+            return false;
+
+        oldSize = null;
+        if (onBottom)
+        {
+            int d = tabHeight - 12;
+            curve = new int[][0 , 13 + d , 0 , 12 + d , 2 , 12 + d , 3 , 11 + d , 5 , 11 + d , 6 , 10 + d , 7 , 10 + d , 9 , 8 + d , 10 , 8 + d , 11 , 7 + d , 11 + d , 7 , 12 + d , 6 , 13 + d , 6 , 15 + d , 4 , 16 + d , 4 , 17 + d , 3 , 19 + d , 3 , 20 + d , 2 , 22 + d , 2 , 23 + d , 1];
+            curveWidth = 26 + d;
+            curveIndent = curveWidth / 3;
+        }
+        else
+        {
+            int d = tabHeight - 12;
+            curve = new int[][0 , 0 , 0 , 1 , 2 , 1 , 3 , 2 , 5 , 2 , 6 , 3 , 7 , 3 , 9 , 5 , 10 , 5 , 11 , 6 , 11 + d , 6 + d , 12 + d , 7 + d , 13 + d , 7 + d , 15 + d , 9 + d , 16 + d , 9 + d , 17 + d , 10 + d , 19 + d , 10 + d , 20 + d , 11 + d , 22 + d , 11 + d , 23 + d , 12 + d];
+            curveWidth = 26 + d;
+            curveIndent = curveWidth / 3;
+
+            //this could be static but since values depend on curve, better to keep in one place
+            topCurveHighlightStart = new int[][0 , 2 , 1 , 2 , 2 , 2 , 3 , 3 , 4 , 3 , 5 , 3 , 6 , 4 , 7 , 4 , 8 , 5 , 9 , 6 , 10 , 6];
+
+            //also, by adding in 'd' here we save some math cost when drawing the curve
+            topCurveHighlightEnd = new int[][10 + d , 6 + d , 11 + d , 7 + d , 12 + d , 8 + d , 13 + d , 8 + d , 14 + d , 9 + d , 15 + d , 10 + d , 16 + d , 10 + d , 17 + d , 11 + d , 18 + d , 11 + d , 19 + d , 11 + d , 20 + d , 12 + d , 21 + d , 12 + d , 22 + d , 12 + d];
+        }
+        notifyListeners(DWT.Resize, new Event());
+        return true;
+    }
+
+    String _getToolTip (int x, int y)
+    {
+        if (showMin && minRect.contains(x, y))
+            return minimized ? DWT.getMessage("DWT_Restore") : DWT.getMessage(
+                    "DWT_Minimize"); //$NON-NLS-1$ //$NON-NLS-2$
+        if (showMax && maxRect.contains(x, y))
+            return maximized ? DWT.getMessage("DWT_Restore") : DWT.getMessage(
+                    "DWT_Maximize"); //$NON-NLS-1$ //$NON-NLS-2$
+        if (showChevron && chevronRect.contains(x, y))
+            return DWT.getMessage("DWT_ShowList"); //$NON-NLS-1$
+        CTabItem item = getItem(new Point(x, y));
+        if (item is null)
+            return null;
+        if (!item.showing)
+            return null;
+        if ((showClose || item.showClose) && item.closeRect.contains(x, y))
+        {
+            return DWT.getMessage("DWT_Close"); //$NON-NLS-1$
+        }
+        return item.getToolTipText();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabFolder2Adapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CTabFolder2Adapter;
+
+import dwt.custom.CTabFolder2Listener;
+import dwt.custom.CTabFolderEvent;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>CTabFolder2Listener</code> interface.
+ * <p>
+ * Classes that wish to dealF with <code>CTabFolderEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see CTabFolder2Listener
+ * @see CTabFolderEvent
+ * 
+ * @since 3.0
+ */
+public class CTabFolder2Adapter : CTabFolder2Listener {
+
+    /**
+     * Sent when the user clicks on the close button of an item in the CTabFolder.  The item being closed is specified
+     * in the event.item field. Setting the event.doit field to false will stop  the CTabItem from closing. 
+     * When the CTabItem is closed, it is disposed.  The contents of the CTabItem (see CTabItem#setControl) will be 
+     * made not visible when the CTabItem is closed.
+     * <p>
+     * The default behaviour is to close the CTabItem.
+     * </p>
+     * 
+     * @param event an event indicating the item being closed
+     */
+    public void close (CTabFolderEvent event) {
+    }
+
+    /**
+     * Sent when the user clicks on the minimize button of a CTabFolder.
+     * <p>
+     * The default behaviour is to do nothing.
+     * </p>
+     * 
+     * @param event an event containing information about the minimize
+     */
+    public void minimize (CTabFolderEvent event) {
+    }
+
+    /**
+     * Sent when the user clicks on the maximize button of a CTabFolder.
+     * <p>
+     * The default behaviour is to do nothing.
+     * </p>
+     * 
+     * @param event an event containing information about the maximize
+     */
+    public void maximize (CTabFolderEvent event) {
+    }
+
+    /**
+     * Sent when the user clicks on the restore button of a CTabFolder.
+     * <p>
+     * The default behaviour is to do nothing.
+     * </p>
+     * 
+     * @param event an event containing information about the restore
+     */
+    public void restore (CTabFolderEvent event) {
+    }
+
+    /**
+     * Sent when the user clicks on the chevron button of a CTabFolder.
+     * <p>
+     * The default behaviour is to show a list of items that are not currently 
+     * visible and to change the selection based on the item selected from the list.
+     * </p>
+     * 
+     * @param event an event containing information about the show list
+     */
+    public void showList (CTabFolderEvent event) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabFolder2Listener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CTabFolder2Listener;
+
+import dwt.custom.CTabFolderEvent;
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated by the CTabFolder 
+ * control.
+ * <p>
+ * After creating an instance of a class that :
+ * this interface it can be added to a CTabFolder using the
+ * <code>addCTabFolder2Listener</code> method and removed using
+ * the <code>removeCTabFolder2Listener</code> method. When
+ * events occurs in a CTabFolder the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see CTabFolder2Adapter
+ * @see CTabFolderEvent
+ * 
+ * @since 3.0
+ */
+public interface CTabFolder2Listener : DWTEventListener {
+
+    /**
+     * Sent when the user clicks on the close button of an item in the CTabFolder.
+     * The item being closed is specified in the event.item field. 
+     * Setting the event.doit field to false will stop the CTabItem from closing. 
+     * When the CTabItem is closed, it is disposed.  The contents of the 
+     * CTabItem (see CTabItem.setControl) will be made not visible when
+     * the CTabItem is closed.
+     * 
+     * @param event an event indicating the item being closed
+     */
+    public void close (CTabFolderEvent event);
+
+    /**
+     * Sent when the user clicks on the minimize button of a CTabFolder.
+     * The state of the CTabFolder does not change automatically - it 
+     * is up to the application to change the state of the CTabFolder
+     * in response to this event using CTabFolder.setMinimized(true).
+     * 
+     * @param event an event containing information about the minimize
+     * 
+     * @see CTabFolder#getMinimized()
+     * @see CTabFolder#setMinimized(bool)
+     * @see CTabFolder#setMinimizeVisible(bool)
+     */
+    public void minimize (CTabFolderEvent event);
+
+    /**
+     * Sent when the user clicks on the maximize button of a CTabFolder.
+     * The state of the CTabFolder does not change automatically - it 
+     * is up to the application to change the state of the CTabFolder
+     * in response to this event using CTabFolder.setMaximized(true).
+     * 
+     * @param event an event containing information about the maximize
+     * 
+     * @see CTabFolder#getMaximized()
+     * @see CTabFolder#setMaximized(bool)
+     * @see CTabFolder#setMaximizeVisible(bool)
+     */
+    public void maximize (CTabFolderEvent event);
+
+    /**
+     * Sent when the user clicks on the restore button of a CTabFolder.
+     * This event is sent either to restore the CTabFolder from the 
+     * minimized state or from the maximized state.  To determine
+     * which restore is requested, use CTabFolder.getMinimized() or
+     * CTabFolder.getMaximized() to determine the current state.
+     * The state of the CTabFolder does not change automatically - it 
+     * is up to the application to change the state of the CTabFolder
+     * in response to this event using CTabFolder.setMaximized(false)
+     * or CTabFolder.setMinimized(false).
+     * 
+     * @param event an event containing information about the restore
+     * 
+     * @see CTabFolder#getMinimized()
+     * @see CTabFolder#getMaximized()
+     * @see CTabFolder#setMinimized(bool)
+     * @see CTabFolder#setMinimizeVisible(bool)
+     * @see CTabFolder#setMaximized(bool)
+     * @see CTabFolder#setMaximizeVisible(bool)
+     */
+    public void restore (CTabFolderEvent event);
+
+    /**
+     * Sent when the user clicks on the chevron button of the CTabFolder.
+     * A chevron appears in the CTabFolder when there are more tabs 
+     * than can be displayed at the current widget size.  To select a 
+     * tab that is not currently visible, the user clicks on the
+     * chevron and selects a tab item from a list.  By default, the
+     * CTabFolder provides a list of all the items that are not currently
+     * visible, however, the application can provide its own list by setting 
+     * the event.doit field to <code>false</code> and displaying a selection list.
+     * 
+     * @param event an event containing information about the show list  
+     * 
+     * @see CTabFolder#setSelection(CTabItem)
+     */
+    public void showList (CTabFolderEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabFolderAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CTabFolderAdapter;
+
+import dwt.custom.CTabFolderEvent;
+import dwt.custom.CTabFolderListener;
+
+public class CTabFolderAdapter : CTabFolderListener {
+    public void itemClosed (CTabFolderEvent event) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabFolderEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CTabFolderEvent;
+
+import dwt.events.TypedEvent;
+import dwt.widgets.Widget;
+
+import dwt.dwthelper.utils;
+
+/**
+ * 
+ */
+public class CTabFolderEvent : TypedEvent {
+    /**
+     * The tab item for the operation.
+     */
+    public Widget item;
+
+    /**
+     * A flag indicating whether the operation should be allowed.
+     * Setting this field to <code>false</code> will cancel the operation.
+     * Applies to the close and showList events.
+     */
+    public bool doit;
+
+    /**
+     * The widget-relative, x coordinate of the chevron button
+     * at the time of the event.  Applies to the showList event.
+     * 
+     * @since 3.0
+     */
+    public int x;
+    /**
+     * The widget-relative, y coordinate of the chevron button
+     * at the time of the event.  Applies to the showList event.
+     * 
+     * @since 3.0
+     */
+    public int y;
+    /**
+     * The width of the chevron button at the time of the event.
+     * Applies to the showList event.
+     * 
+     * @since 3.0
+     */
+    public int width;
+    /**
+     * The height of the chevron button at the time of the event.
+     * Applies to the showList event.
+     * 
+     * @since 3.0
+     */
+    public int height;
+
+    static final long serialVersionUID = 3760566386225066807L;
+
+    /**
+     * Constructs a new instance of this class.
+     *
+     * @param w the widget that fired the event
+     */
+    this (Widget w) {
+        super(w);
+    }
+
+    /**
+     * Returns a String containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a String representation of the event
+     */
+    public String toString () {
+        String str = super.toString();
+        return str.substring(0, str.length - 1) // remove trailing '}'
+        + " item=" + item + " doit=" + doit + " x=" + x + " y=" + y + " width=" + width + " height=" + height + "}";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabFolderLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CTabFolderLayout;
+
+import Math = tango.math.Math;
+
+import dwt.DWT;
+import dwt.custom.CTabFolder;
+import dwt.custom.CTabItem;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Layout;
+
+/**
+ * This class provides the layout for CTabFolder
+ * 
+ * @see CTabFolder
+ */
+class CTabFolderLayout : Layout {
+    protected Point computeSize (Composite composite, int wHint, int hHint, bool flushCache) {
+        CTabFolder folder = cast(CTabFolder) composite;
+        CTabItem[] items = folder.items;
+        // preferred width of tab area to show all tabs
+        int tabW = 0;
+        GC gc = new GC(folder);
+        for (int i = 0; i < items.length; i++) {
+            if (folder.single) {
+                tabW = Math.max(tabW, items[i].preferredWidth(gc, true, false));
+            }
+            else {
+                tabW += items[i].preferredWidth(gc, i is folder.selectedIndex, false);
+            }
+        }
+        gc.dispose();
+        tabW += 3;
+        if (folder.showMax)
+            tabW += CTabFolder.BUTTON_SIZE;
+        if (folder.showMin)
+            tabW += CTabFolder.BUTTON_SIZE;
+        if (folder.single)
+            tabW += 3 * CTabFolder.BUTTON_SIZE / 2; //chevron
+        if (folder.topRight !is null) {
+            Point pt = folder.topRight.computeSize(DWT.DEFAULT, folder.tabHeight, flushCache);
+            tabW += 3 + pt.x;
+        }
+        if (!folder.single && !folder.simple)
+            tabW += folder.curveWidth - 2 * folder.curveIndent;
+
+        int controlW = 0;
+        int controlH = 0;
+        // preferred size of controls in tab items
+        for (int i = 0; i < items.length; i++) {
+            Control control = items[i].getControl();
+            if (control !is null && !control.isDisposed()) {
+                Point size = control.computeSize(wHint, hHint, flushCache);
+                controlW = Math.max(controlW, size.x);
+                controlH = Math.max(controlH, size.y);
+            }
+        }
+
+        int minWidth = Math.max(tabW, controlW);
+        int minHeight = (folder.minimized) ? 0 : controlH;
+        if (minWidth is 0)
+            minWidth = CTabFolder.DEFAULT_WIDTH;
+        if (minHeight is 0)
+            minHeight = CTabFolder.DEFAULT_HEIGHT;
+
+        if (wHint !is DWT.DEFAULT)
+            minWidth = wHint;
+        if (hHint !is DWT.DEFAULT)
+            minHeight = hHint;
+
+        return new Point(minWidth, minHeight);
+    }
+
+    protected bool flushCache (Control control) {
+        return true;
+    }
+
+    protected void layout (Composite composite, bool flushCache) {
+        CTabFolder folder = cast(CTabFolder) composite;
+        // resize content
+        if (folder.selectedIndex !is -1) {
+            Control control = folder.items[folder.selectedIndex].getControl();
+            if (control !is null && !control.isDisposed()) {
+                control.setBounds(folder.getClientArea());
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabFolderListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.CTabFolderListener;
+
+import dwt.custom.CTabFolderEvent;
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with events generated in the CTabFolder.
+ * <p>
+ * After creating an instance of a class that :
+ * this interface it can be added to a CTabFolder using the
+ * <code>addCTabFolderListener</code> method and removed using
+ * the <code>removeCTabFolderListener</code> method. When a
+ * tab item is closed, the itemClosed method will be invoked.
+ * </p>
+ *
+ * @see CTabFolderEvent
+ */
+public interface CTabFolderListener : DWTEventListener {
+
+    /**
+     * Sent when the user clicks on the close button of an item in the CTabFolder.  The item being closed is specified
+     * in the event.item field. Setting the event.doit field to false will stop the CTabItem from closing. 
+     * When the CTabItem is closed, it is disposed.  The contents of the CTabItem (see CTabItem.setControl) will be 
+     * made not visible when the CTabItem is closed.
+     * 
+     * @param event an event indicating the item being closed
+     * 
+     * @see CTabItem#setControl
+     */
+    public void itemClosed (CTabFolderEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/CTabItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1132 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.custom.CTabFolder;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+import dwt.graphics.Rectangle;
+import dwt.graphics.TextLayout;
+import dwt.widgets.Control;
+import dwt.widgets.Display;
+import dwt.widgets.Item;
+import dwt.widgets.Widget;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represent a page in a notebook widget.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DWT.CLOSE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class CTabItem : Item {
+    CTabFolder parent;
+    int x, y, width, height = 0;
+    Control control; // the tab page
+
+    String toolTipText;
+    String shortenedText;
+    int shortenedTextWidth;
+
+    // Appearance
+    Font font;
+    Image disabledImage;
+
+    Rectangle closeRect = new Rectangle(0, 0, 0, 0);
+    int closeImageState = CTabFolder.NONE;
+    bool showClose = false;
+    bool showing = false;
+
+    // internal constants
+    static final int TOP_MARGIN = 2;
+    static final int BOTTOM_MARGIN = 2;
+    static final int LEFT_MARGIN = 4;
+    static final int RIGHT_MARGIN = 4;
+    static final int INTERNAL_SPACING = 4;
+    static final int FLAGS = DWT.DRAW_TRANSPARENT | DWT.DRAW_MNEMONIC;
+    static final String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * (which must be a <code>CTabFolder</code>) and a style value
+     * describing its behavior and appearance. The item is added
+     * to the end of the items maintained by its parent.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
+     * @param style the style of control to construct
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     *
+     * @see DWT
+     * @see Widget#getStyle()
+     */
+    public this (CTabFolder parent, int style) {
+        this(parent, style, parent.getItemCount());
+    }
+
+    /**
+     * Constructs a new instance of this class given its parent
+     * (which must be a <code>CTabFolder</code>), a style value
+     * describing its behavior and appearance, and the index
+     * at which to place it in the items maintained by its parent.
+     * <p>
+     * The style value is either one of the style constants defined in
+     * class <code>DWT</code> which is applicable to instances of this
+     * class, or must be built by <em>bitwise OR</em>'ing together 
+     * (that is, using the <code>int</code> "|" operator) two or more
+     * of those <code>DWT</code> style constants. The class description
+     * lists the style constants that are applicable to the class.
+     * Style bits are also inherited from superclasses.
+     * </p>
+     *
+     * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
+     * @param style the style of control to construct
+     * @param index the zero-relative index to store the receiver in its parent
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+     *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+     * </ul>
+     *
+     * @see DWT
+     * @see Widget#getStyle()
+     */
+    public this (CTabFolder parent, int style, int index) {
+        super(parent, style);
+        showClose = (style & DWT.CLOSE) !is 0;
+        parent.createItem(this, index);
+    }
+
+    /*
+     * Return whether to use ellipses or just truncate labels
+     */
+    bool useEllipses () {
+        return parent.simple;
+    }
+
+    String shortenText (GC gc, String text, int width) {
+        return useEllipses() ? shortenText(gc, text, width, ELLIPSIS) : shortenText(gc, text, width, ""); //$NON-NLS-1$
+    }
+
+    String shortenText (GC gc, String text, int width, String ellipses) {
+        if (gc.textExtent(text, FLAGS).x <= width)
+            return text;
+        int ellipseWidth = gc.textExtent(ellipses, FLAGS).x;
+        int length = text.length;
+        TextLayout layout = new TextLayout(getDisplay());
+        layout.setText(text);
+        int end = layout.getPreviousOffset(length, DWT.MOVEMENT_CLUSTER);
+        while (end > 0) {
+            text = text.substring(0, end);
+            int l = gc.textExtent(text, FLAGS).x;
+            if (l + ellipseWidth <= width) {
+                break;
+            }
+            end = layout.getPreviousOffset(end, DWT.MOVEMENT_CLUSTER);
+        }
+        layout.dispose();
+        return end is 0 ? text.substring(0, 1) : text + ellipses;
+    }
+
+    public void dispose () {
+        if (isDisposed())
+            return;
+        //if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
+        parent.destroyItem(this);
+        super.dispose();
+        parent = null;
+        control = null;
+        toolTipText = null;
+        shortenedText = null;
+        font = null;
+    }
+
+    void drawClose (GC gc) {
+        if (closeRect.width is 0 || closeRect.height is 0)
+            return;
+        Display display = getDisplay();
+
+        // draw X 9x9
+        int indent = Math.max(1, (CTabFolder.BUTTON_SIZE - 9) / 2);
+        int x = closeRect.x + indent;
+        int y = closeRect.y + indent;
+        y += parent.onBottom ? -1 : 1;
+
+        Color closeBorder = display.getSystemColor(CTabFolder.BUTTON_BORDER);
+        switch (closeImageState) {
+            case CTabFolder.NORMAL: {
+                int[] shape = new int[]
+                {
+                    x , y , x + 2 , y , x + 4 , y + 2 , x + 5 , y + 2 , x + 7 , y , x + 9 , y , x + 9 , y + 2 , x + 7 , y + 4 , x + 7 , y + 5 , x + 9 , y + 7 , x + 9 , y + 9 , x + 7 , y + 9 , x + 5 , y + 7 , x + 4 , y + 7 , x + 2 , y + 9 , x , y + 9 , x , y + 7 , x + 2 , y + 5 , x + 2 , y + 4 , x , y + 2
+                };
+                gc.setBackground(display.getSystemColor(CTabFolder.BUTTON_FILL));
+                gc.fillPolygon(shape);
+                gc.setForeground(closeBorder);
+                gc.drawPolygon(shape);
+                break;
+            }
+            case CTabFolder.HOT: {
+                int[] shape = new int[]
+                {
+                    x , y , x + 2 , y , x + 4 , y + 2 , x + 5 , y + 2 , x + 7 , y , x + 9 , y , x + 9 , y + 2 , x + 7 , y + 4 , x + 7 , y + 5 , x + 9 , y + 7 , x + 9 , y + 9 , x + 7 , y + 9 , x + 5 , y + 7 , x + 4 , y + 7 , x + 2 , y + 9 , x , y + 9 , x , y + 7 , x + 2 , y + 5 , x + 2 , y + 4 , x , y + 2
+                };
+                Color fill = new Color(display, CTabFolder.CLOSE_FILL);
+                gc.setBackground(fill);
+                gc.fillPolygon(shape);
+                fill.dispose();
+                gc.setForeground(closeBorder);
+                gc.drawPolygon(shape);
+                break;
+            }
+            case CTabFolder.SELECTED: {
+                int[] shape = new int[]
+                {
+                    x + 1 , y + 1 , x + 3 , y + 1 , x + 5 , y + 3 , x + 6 , y + 3 , x + 8 , y + 1 , x + 10 , y + 1 , x + 10 , y + 3 , x + 8 , y + 5 , x + 8 , y + 6 , x + 10 , y + 8 , x + 10 , y + 10 , x + 8 , y + 10 , x + 6 , y + 8 , x + 5 , y + 8 , x + 3 , y + 10 , x + 1 , y + 10 , x + 1 , y + 8 , x + 3 , y + 6 , x + 3 , y + 5 , x + 1 , y + 3
+                };
+                Color fill = new Color(display, CTabFolder.CLOSE_FILL);
+                gc.setBackground(fill);
+                gc.fillPolygon(shape);
+                fill.dispose();
+                gc.setForeground(closeBorder);
+                gc.drawPolygon(shape);
+                break;
+            }
+            case CTabFolder.NONE: {
+                int[] shape = new int[]
+                {
+                    x , y , x + 10 , y , x + 10 , y + 10 , x , y + 10
+                };
+                if (parent.gradientColors !is null && !parent.gradientVertical) {
+                    parent.drawBackground(gc, shape, false);
+                }
+                else {
+                    Color defaultBackground = parent.getBackground();
+                    Image image = parent.bgImage;
+                    Color[] colors = parent.gradientColors;
+                    int[] percents = parent.gradientPercents;
+                    bool vertical = parent.gradientVertical;
+                    parent.drawBackground(gc, shape, x, y, 10, 10, defaultBackground, image, colors, percents, vertical);
+                }
+                break;
+            }
+        }
+    }
+
+    void drawSelected (GC gc) {
+        Point size = parent.getSize();
+        int rightEdge = Math.min(x + width, parent.getRightItemEdge());
+
+        //   Draw selection border across all tabs
+        int xx = parent.borderLeft;
+        int
+                yy = parent.onBottom ? size.y - parent.borderBottom - parent.tabHeight - parent.highlight_header : parent.borderTop + parent.tabHeight + 1;
+        int ww = size.x - parent.borderLeft - parent.borderRight;
+        int hh = parent.highlight_header - 1;
+        int[] shape = new int[]
+        {
+            xx , yy , xx + ww , yy , xx + ww , yy + hh , xx , yy + hh
+        };
+        if (parent.selectionGradientColors !is null && !parent.selectionGradientVertical) {
+            parent.drawBackground(gc, shape, true);
+        }
+        else {
+            gc.setBackground(parent.selectionBackground);
+            gc.fillRectangle(xx, yy, ww, hh);
+        }
+
+        if (parent.single) {
+            if (!showing)
+                return;
+        }
+        else {
+            // if selected tab scrolled out of view or partially out of view
+            // just draw bottom line
+            if (!showing) {
+                int x1 = Math.max(0, parent.borderLeft - 1);
+                int y1 = (parent.onBottom) ? y - 1 : y + height;
+                int x2 = size.x - parent.borderRight;
+                gc.setForeground(CTabFolder.borderColor);
+                gc.drawLine(x1, y1, x2, y1);
+                return;
+            }
+
+            // draw selected tab background and outline
+            shape = null;
+            if (this.parent.onBottom) {
+                int[] left = parent.simple ? CTabFolder.SIMPLE_BOTTOM_LEFT_CORNER : CTabFolder.BOTTOM_LEFT_CORNER;
+                int[] right = parent.simple ? CTabFolder.SIMPLE_BOTTOM_RIGHT_CORNER : parent.curve;
+                if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) {
+                    left = new int[]
+                    {
+                        x , y + height
+                    };
+                }
+                shape = new int[left.length + right.length + 8];
+                int index = 0;
+                shape[index++] = x; // first point repeated here because below we reuse shape to draw outline
+                shape[index++] = y - 1;
+                shape[index++] = x;
+                shape[index++] = y - 1;
+                for (int i = 0; i < left.length / 2; i++) {
+                    shape[index++] = x + left[2 * i];
+                    shape[index++] = y + height + left[2 * i + 1] - 1;
+                }
+                for (int i = 0; i < right.length / 2; i++) {
+                    shape[index++] = parent.simple ? rightEdge - 1 + right[2 * i] : rightEdge - parent.curveIndent + right[2 * i];
+                    shape[index++] = parent.simple ? y + height + right[2 * i + 1] - 1 : y + right[2 * i + 1] - 2;
+                }
+                shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+                shape[index++] = y - 1;
+                shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+                shape[index++] = y - 1;
+            }
+            else {
+                int[] left = parent.simple ? CTabFolder.SIMPLE_TOP_LEFT_CORNER : CTabFolder.TOP_LEFT_CORNER;
+                int[] right = parent.simple ? CTabFolder.SIMPLE_TOP_RIGHT_CORNER : parent.curve;
+                if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) {
+                    left = new int[]
+                    {
+                        x , y
+                    };
+                }
+                shape = new int[left.length + right.length + 8];
+                int index = 0;
+                shape[index++] = x; // first point repeated here because below we reuse shape to draw outline
+                shape[index++] = y + height + 1;
+                shape[index++] = x;
+                shape[index++] = y + height + 1;
+                for (int i = 0; i < left.length / 2; i++) {
+                    shape[index++] = x + left[2 * i];
+                    shape[index++] = y + left[2 * i + 1];
+                }
+                for (int i = 0; i < right.length / 2; i++) {
+                    shape[index++] = parent.simple ? rightEdge - 1 + right[2 * i] : rightEdge - parent.curveIndent + right[2 * i];
+                    shape[index++] = y + right[2 * i + 1];
+                }
+                shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+                shape[index++] = y + height + 1;
+                shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+                shape[index++] = y + height + 1;
+            }
+
+            Rectangle clipping = gc.getClipping();
+            Rectangle bounds = getBounds();
+            bounds.height += 1;
+            if (parent.onBottom)
+                bounds.y -= 1;
+            bool tabInPaint = clipping.intersects(bounds);
+
+            if (tabInPaint) {
+                // fill in tab background
+                if (parent.selectionGradientColors !is null && !parent.selectionGradientVertical) {
+                    parent.drawBackground(gc, shape, true);
+                }
+                else {
+                    Color defaultBackground = parent.selectionBackground;
+                    Image image = parent.selectionBgImage;
+                    Color[] colors = parent.selectionGradientColors;
+                    int[] percents = parent.selectionGradientPercents;
+                    bool vertical = parent.selectionGradientVertical;
+                    xx = x;
+                    yy = parent.onBottom ? y - 1 : y + 1;
+                    ww = width;
+                    hh = height;
+                    if (!parent.single && !parent.simple)
+                        ww += parent.curveWidth - parent.curveIndent;
+                    parent.drawBackground(gc, shape, xx, yy, ww, hh, defaultBackground, image, colors, percents, vertical);
+                }
+            }
+
+            //Highlight MUST be drawn before the outline so that outline can cover it in the right spots (start of swoop)
+            //otherwise the curve looks jagged
+            drawHighlight(gc, rightEdge);
+
+            // draw outline
+            shape[0] = Math.max(0, parent.borderLeft - 1);
+            if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) {
+                shape[1] = parent.onBottom ? y + height - 1 : y;
+                shape[5] = shape[3] = shape[1];
+            }
+            shape[shape.length - 2] = size.x - parent.borderRight + 1;
+            for (int i = 0; i < shape.length / 2; i++) {
+                if (shape[2 * i + 1] is y + height + 1)
+                    shape[2 * i + 1] -= 1;
+            }
+            RGB inside = parent.selectionBackground.getRGB();
+            if (parent.selectionBgImage !is null || (parent.selectionGradientColors !is null && parent.selectionGradientColors.length > 1)) {
+                inside = null;
+            }
+            RGB outside = parent.getBackground().getRGB();
+            if (parent.bgImage !is null || (parent.gradientColors !is null && parent.gradientColors.length > 1)) {
+                outside = null;
+            }
+            parent.antialias(shape, CTabFolder.borderColor.getRGB(), inside, outside, gc);
+            gc.setForeground(CTabFolder.borderColor);
+            gc.drawPolyline(shape);
+
+            if (!tabInPaint)
+                return;
+        }
+
+        // draw Image
+        int xDraw = x + LEFT_MARGIN;
+        if (parent.single && (parent.showClose || showClose))
+            xDraw += CTabFolder.BUTTON_SIZE;
+        Image image = getImage();
+        if (image !is null) {
+            Rectangle imageBounds = image.getBounds();
+            // only draw image if it won't overlap with close button
+            int maxImageWidth = rightEdge - xDraw - RIGHT_MARGIN;
+            if (!parent.single && closeRect.width > 0)
+                maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+            if (imageBounds.width < maxImageWidth) {
+                int imageX = xDraw;
+                int imageY = y + (height - imageBounds.height) / 2;
+                imageY += parent.onBottom ? -1 : 1;
+                gc.drawImage(image, imageX, imageY);
+                xDraw += imageBounds.width + INTERNAL_SPACING;
+            }
+        }
+
+        // draw Text
+        int textWidth = rightEdge - xDraw - RIGHT_MARGIN;
+        if (!parent.single && closeRect.width > 0)
+            textWidth -= closeRect.width + INTERNAL_SPACING;
+        if (textWidth > 0) {
+            Font gcFont = gc.getFont();
+            gc.setFont(font is null ? parent.getFont() : font);
+
+            if (shortenedText is null || shortenedTextWidth !is textWidth) {
+                shortenedText = shortenText(gc, getText(), textWidth);
+                shortenedTextWidth = textWidth;
+            }
+            Point extent = gc.textExtent(shortenedText, FLAGS);
+            int textY = y + (height - extent.y) / 2;
+            textY += parent.onBottom ? -1 : 1;
+
+            gc.setForeground(parent.selectionForeground);
+            gc.drawText(shortenedText, xDraw, textY, FLAGS);
+            gc.setFont(gcFont);
+
+            // draw a Focus rectangle
+            if (parent.isFocusControl()) {
+                Display display = getDisplay();
+                if (parent.simple || parent.single) {
+                    gc.setBackground(display.getSystemColor(DWT.COLOR_BLACK));
+                    gc.setForeground(display.getSystemColor(DWT.COLOR_WHITE));
+                    gc.drawFocus(xDraw - 1, textY - 1, extent.x + 2, extent.y + 2);
+                }
+                else {
+                    gc.setForeground(display.getSystemColor(CTabFolder.BUTTON_BORDER));
+                    gc.drawLine(xDraw, textY + extent.y + 1, xDraw + extent.x + 1, textY + extent.y + 1);
+                }
+            }
+        }
+        if (parent.showClose || showClose)
+            drawClose(gc);
+    }
+
+    /*
+     * Draw a highlight effect along the left, top, and right edges of the tab.
+     * Only for curved tabs, on top.
+     * Do not draw if insufficient colors.
+     */
+    void drawHighlight (GC gc, int rightEdge) {
+        //only draw for curvy tabs and only draw for top tabs
+        if (parent.simple || this.parent.onBottom)
+            return;
+
+        if (parent.selectionHighlightGradientBegin is null)
+            return;
+
+        Color[] gradients = parent.selectionHighlightGradientColorsCache;
+        if (gradients is null)
+            return;
+        int gradientsSize = gradients.length;
+        if (gradientsSize is 0)
+            return; //shouldn't happen but just to be tidy
+
+        gc.setForeground(gradients[0]);
+
+        //draw top horizontal line
+        gc.drawLine(CTabFolder.TOP_LEFT_CORNER_HILITE[0] + x + 1, //rely on fact that first pair is top/right of curve
+                1 + y, rightEdge - parent.curveIndent, 1 + y);
+
+        int[] leftHighlightCurve = CTabFolder.TOP_LEFT_CORNER_HILITE;
+
+        int d = parent.tabHeight - parent.topCurveHighlightEnd.length / 2;
+
+        int lastX = 0;
+        int lastY = 0;
+        int lastColorIndex = 0;
+
+        //draw upper left curve highlight
+        for (int i = 0; i < leftHighlightCurve.length / 2; i++) {
+            int rawX = leftHighlightCurve[i * 2];
+            int rawY = leftHighlightCurve[i * 2 + 1];
+            lastX = rawX + x;
+            lastY = rawY + y;
+            lastColorIndex = rawY - 1;
+            gc.setForeground(gradients[lastColorIndex]);
+            gc.drawPoint(lastX, lastY);
+        }
+        //draw left vertical line highlight
+        for (int i = lastColorIndex; i < gradientsSize; i++) {
+            gc.setForeground(gradients[i]);
+            gc.drawPoint(lastX, 1 + lastY++);
+        }
+
+        int rightEdgeOffset = rightEdge - parent.curveIndent;
+
+        //draw right swoop highlight up to diagonal portion
+        for (int i = 0; i < parent.topCurveHighlightStart.length / 2; i++) {
+            int rawX = parent.topCurveHighlightStart[i * 2];
+            int rawY = parent.topCurveHighlightStart[i * 2 + 1];
+            lastX = rawX + rightEdgeOffset;
+            lastY = rawY + y;
+            lastColorIndex = rawY - 1;
+            if (lastColorIndex >= gradientsSize)
+                break; //can happen if tabs are unusually short and cut off the curve
+            gc.setForeground(gradients[lastColorIndex]);
+            gc.drawPoint(lastX, lastY);
+        }
+        //draw right diagonal line highlight
+        for (int i = lastColorIndex; i < lastColorIndex + d; i++) {
+            if (i >= gradientsSize)
+                break; //can happen if tabs are unusually short and cut off the curve
+            gc.setForeground(gradients[i]);
+            gc.drawPoint(1 + lastX++, 1 + lastY++);
+        }
+
+        //draw right swoop highlight from diagonal portion to end
+        for (int i = 0; i < parent.topCurveHighlightEnd.length / 2; i++) {
+            int rawX = parent.topCurveHighlightEnd[i * 2]; //d is already encoded in this value
+            int rawY = parent.topCurveHighlightEnd[i * 2 + 1]; //d already encoded
+            lastX = rawX + rightEdgeOffset;
+            lastY = rawY + y;
+            lastColorIndex = rawY - 1;
+            if (lastColorIndex >= gradientsSize)
+                break; //can happen if tabs are unusually short and cut off the curve
+            gc.setForeground(gradients[lastColorIndex]);
+            gc.drawPoint(lastX, lastY);
+        }
+    }
+
+    /*
+     * Draw the unselected border for the receiver on the right.
+     * 
+     * @param gc
+     */
+    void drawRightUnselectedBorder (GC gc) {
+
+        int[] shape = null;
+        int startX = x + width - 1;
+
+        if (this.parent.onBottom) {
+            int[] right = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.BOTTOM_RIGHT_CORNER;
+
+            shape = new int[right.length + 2];
+            int index = 0;
+
+            for (int i = 0; i < right.length / 2; i++) {
+                shape[index++] = startX + right[2 * i];
+                shape[index++] = y + height + right[2 * i + 1] - 1;
+            }
+            shape[index++] = startX;
+            shape[index++] = y - 1;
+        }
+        else {
+            int[] right = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.TOP_RIGHT_CORNER;
+
+            shape = new int[right.length + 2];
+            int index = 0;
+
+            for (int i = 0; i < right.length / 2; i++) {
+                shape[index++] = startX + right[2 * i];
+                shape[index++] = y + right[2 * i + 1];
+            }
+
+            shape[index++] = startX;
+            shape[index++] = y + height;
+
+        }
+
+        drawBorder(gc, shape);
+
+    }
+
+    /*
+     * Draw the border of the tab
+     * 
+     * @param gc
+     * @param shape
+     */
+    void drawBorder (GC gc, int[] shape) {
+
+        gc.setForeground(CTabFolder.borderColor);
+        gc.drawPolyline(shape);
+    }
+
+    /*
+     * Draw the unselected border for the receiver on the left.
+     * 
+     * @param gc
+     */
+    void drawLeftUnselectedBorder (GC gc) {
+
+        int[] shape = null;
+        if (this.parent.onBottom) {
+            int[] left = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.BOTTOM_LEFT_CORNER;
+
+            shape = new int[left.length + 2];
+            int index = 0;
+            shape[index++] = x;
+            shape[index++] = y - 1;
+            for (int i = 0; i < left.length / 2; i++) {
+                shape[index++] = x + left[2 * i];
+                shape[index++] = y + height + left[2 * i + 1] - 1;
+            }
+        }
+        else {
+            int[] left = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.TOP_LEFT_CORNER;
+
+            shape = new int[left.length + 2];
+            int index = 0;
+            shape[index++] = x;
+            shape[index++] = y + height;
+            for (int i = 0; i < left.length / 2; i++) {
+                shape[index++] = x + left[2 * i];
+                shape[index++] = y + left[2 * i + 1];
+            }
+
+        }
+
+        drawBorder(gc, shape);
+    }
+
+    void drawUnselected (GC gc) {
+        // Do not draw partial items
+        if (!showing)
+            return;
+
+        Rectangle clipping = gc.getClipping();
+        Rectangle bounds = getBounds();
+        if (!clipping.intersects(bounds))
+            return;
+
+        // draw border
+        int index = parent.indexOf(this);
+
+        if (index > 0 && index < parent.selectedIndex)
+            drawLeftUnselectedBorder(gc);
+        // If it is the last one then draw a line
+        if (index > parent.selectedIndex)
+            drawRightUnselectedBorder(gc);
+
+        // draw Image
+        int xDraw = x + LEFT_MARGIN;
+        Image image = getImage();
+        if (image !is null && parent.showUnselectedImage) {
+            Rectangle imageBounds = image.getBounds();
+            // only draw image if it won't overlap with close button
+            int maxImageWidth = x + width - xDraw - RIGHT_MARGIN;
+            if (parent.showUnselectedClose && (parent.showClose || showClose)) {
+                maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+            }
+            if (imageBounds.width < maxImageWidth) {
+                int imageX = xDraw;
+                int imageHeight = imageBounds.height;
+                int imageY = y + (height - imageHeight) / 2;
+                imageY += parent.onBottom ? -1 : 1;
+                int imageWidth = imageBounds.width * imageHeight / imageBounds.height;
+                gc.drawImage(image, imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height, imageX, imageY, imageWidth, imageHeight);
+                xDraw += imageWidth + INTERNAL_SPACING;
+            }
+        }
+        // draw Text
+        int textWidth = x + width - xDraw - RIGHT_MARGIN;
+        if (parent.showUnselectedClose && (parent.showClose || showClose)) {
+            textWidth -= closeRect.width + INTERNAL_SPACING;
+        }
+        if (textWidth > 0) {
+            Font gcFont = gc.getFont();
+            gc.setFont(font is null ? parent.getFont() : font);
+            if (shortenedText is null || shortenedTextWidth !is textWidth) {
+                shortenedText = shortenText(gc, getText(), textWidth);
+                shortenedTextWidth = textWidth;
+            }
+            Point extent = gc.textExtent(shortenedText, FLAGS);
+            int textY = y + (height - extent.y) / 2;
+            textY += parent.onBottom ? -1 : 1;
+            gc.setForeground(parent.getForeground());
+            gc.drawText(shortenedText, xDraw, textY, FLAGS);
+            gc.setFont(gcFont);
+        }
+        // draw close
+        if (parent.showUnselectedClose && (parent.showClose || showClose))
+            drawClose(gc);
+    }
+
+    /**
+     * Returns a rectangle describing the receiver's size and location
+     * relative to its parent.
+     *
+     * @return the receiver's bounding column rectangle
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public Rectangle getBounds () {
+        //checkWidget();
+        int w = width;
+        if (!parent.simple && !parent.single && parent.indexOf(this) is parent.selectedIndex)
+            w += parent.curveWidth - parent.curveIndent;
+        return new Rectangle(x, y, w, height);
+    }
+
+    /**
+     * Gets the control that is displayed in the content area of the tab item.
+     *
+     * @return the control
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public Control getControl () {
+        checkWidget();
+        return control;
+    }
+
+    /**
+     * Get the image displayed in the tab if the tab is disabled.
+     * 
+     * @return the disabled image or null
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @deprecated the disabled image is not used
+     */
+    public Image getDisabledImage () {
+        checkWidget();
+        return disabledImage;
+    }
+
+    /**
+     * Returns the font that the receiver will use to paint textual information.
+     *
+     * @return the receiver's font
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     *  @since 3.0
+     */
+    public Font getFont () {
+        checkWidget();
+        if (font !is null)
+            return font;
+        return parent.getFont();
+    }
+
+    /**
+     * Returns the receiver's parent, which must be a <code>CTabFolder</code>.
+     *
+     * @return the receiver's parent
+     * 
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public CTabFolder getParent () {
+        //checkWidget();
+        return parent;
+    }
+
+    /**
+     * Returns <code>true</code> to indicate that the receiver's close button should be shown.
+     * Otherwise return <code>false</code>. The initial value is defined by the style (DWT.CLOSE)
+     * that was used to create the receiver.
+     * 
+     * @return <code>true</code> if the close button should be shown
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.4
+     */
+    public bool getShowClose () {
+        checkWidget();
+        return showClose;
+    }
+
+    /**
+     * Returns the receiver's tool tip text, or null if it has
+     * not been set.
+     *
+     * @return the receiver's tool tip text
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public String getToolTipText () {
+        checkWidget();
+        if (toolTipText is null && shortenedText !is null) {
+            String text = getText();
+            if (!shortenedText.opEquals(text))
+                return text;
+        }
+        return toolTipText;
+    }
+
+    /**
+     * Returns <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise.
+     * 
+     *  @return <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise.
+     * 
+     *  @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public bool isShowing () {
+        checkWidget();
+        return showing;
+    }
+
+    void onPaint (GC gc, bool isSelected) {
+        if (width is 0 || height is 0)
+            return;
+        if (isSelected) {
+            drawSelected(gc);
+        }
+        else {
+            drawUnselected(gc);
+        }
+    }
+
+    int preferredHeight (GC gc) {
+        Image image = getImage();
+        int h = (image is null) ? 0 : image.getBounds().height;
+        String text = getText();
+        if (font is null) {
+            h = Math.max(h, gc.textExtent(text, FLAGS).y);
+        }
+        else {
+            Font gcFont = gc.getFont();
+            gc.setFont(font);
+            h = Math.max(h, gc.textExtent(text, FLAGS).y);
+            gc.setFont(gcFont);
+        }
+        return h + TOP_MARGIN + BOTTOM_MARGIN;
+    }
+
+    int preferredWidth (GC gc, bool isSelected, bool minimum) {
+        // NOTE: preferred width does not include the "dead space" caused
+        // by the curve.
+        if (isDisposed())
+            return 0;
+        int w = 0;
+        Image image = getImage();
+        if (image !is null && (isSelected || parent.showUnselectedImage)) {
+            w += image.getBounds().width;
+        }
+        String text = null;
+        if (minimum) {
+            int minChars = parent.minChars;
+            text = minChars is 0 ? null : getText();
+            if (text !is null && text.length() > minChars) {
+                if (useEllipses()) {
+                    int end = minChars < ELLIPSIS.length() + 1 ? minChars : minChars - ELLIPSIS.length();
+                    text = text.substring(0, end);
+                    if (minChars > ELLIPSIS.length() + 1)
+                        text += ELLIPSIS;
+                }
+                else {
+                    int end = minChars;
+                    text = text.substring(0, end);
+                }
+            }
+        }
+        else {
+            text = getText();
+        }
+        if (text !is null) {
+            if (w > 0)
+                w += INTERNAL_SPACING;
+            if (font is null) {
+                w += gc.textExtent(text, FLAGS).x;
+            }
+            else {
+                Font gcFont = gc.getFont();
+                gc.setFont(font);
+                w += gc.textExtent(text, FLAGS).x;
+                gc.setFont(gcFont);
+            }
+        }
+        if (parent.showClose || showClose) {
+            if (isSelected || parent.showUnselectedClose) {
+                if (w > 0)
+                    w += INTERNAL_SPACING;
+                w += CTabFolder.BUTTON_SIZE;
+            }
+        }
+        return w + LEFT_MARGIN + RIGHT_MARGIN;
+    }
+
+    /**
+     * Sets the control that is used to fill the client area of
+     * the tab folder when the user selects the tab item.
+     *
+     * @param control the new control (or null)
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+     *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setControl (Control control) {
+        checkWidget();
+        if (control !is null) {
+            if (control.isDisposed())
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            if (control.getParent() !is parent)
+                DWT.error(DWT.ERROR_INVALID_PARENT);
+        }
+        if (this.control !is null && !this.control.isDisposed()) {
+            this.control.setVisible(false);
+        }
+        this.control = control;
+        if (this.control !is null) {
+            int index = parent.indexOf(this);
+            if (index is parent.getSelectionIndex()) {
+                this.control.setBounds(parent.getClientArea());
+                this.control.setVisible(true);
+            }
+            else {
+                this.control.setVisible(false);
+            }
+        }
+    }
+
+    /**
+     * Sets the image that is displayed if the tab item is disabled.
+     * Null will clear the image.
+     * 
+     * @param image the image to be displayed when the item is disabled or null
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @deprecated This image is not used
+     */
+    public void setDisabledImage (Image image) {
+        checkWidget();
+        if (image !is null && image.isDisposed()) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        this.disabledImage = image;
+    }
+
+    /**
+     * Sets the font that the receiver will use to paint textual information
+     * for this item to the font specified by the argument, or to the default font
+     * for that kind of control if the argument is null.
+     *
+     * @param font the new font (or null)
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+     * </ul>
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.0
+     */
+    public void setFont (Font font) {
+        checkWidget();
+        if (font !is null && font.isDisposed()) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        if (font is null && this.font is null)
+            return;
+        if (font !is null && font.opEquals(this.font))
+            return;
+        this.font = font;
+        if (!parent.updateTabHeight(false)) {
+            parent.updateItems();
+            parent.redrawTabs();
+        }
+    }
+
+    public void setImage (Image image) {
+        checkWidget();
+        if (image !is null && image.isDisposed()) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        Image oldImage = getImage();
+        if (image is null && oldImage is null)
+            return;
+        if (image !is null && image.opEquals(oldImage))
+            return;
+        super.setImage(image);
+        if (!parent.updateTabHeight(false)) {
+            // If image is the same size as before, 
+            // redraw only the image
+            if (oldImage !is null && image !is null) {
+                Rectangle oldBounds = oldImage.getBounds();
+                Rectangle bounds = image.getBounds();
+                if (bounds.width is oldBounds.width && bounds.height is oldBounds.height) {
+                    if (showing) {
+                        bool selected = parent.indexOf(this) is parent.selectedIndex;
+                        if (selected || parent.showUnselectedImage) {
+                            int imageX = x + LEFT_MARGIN, maxImageWidth;
+                            if (selected) {
+                                if (parent.single && (parent.showClose || showClose))
+                                    imageX += CTabFolder.BUTTON_SIZE;
+                                int rightEdge = Math.min(x + width, parent.getRightItemEdge());
+                                maxImageWidth = rightEdge - imageX - RIGHT_MARGIN;
+                                if (!parent.single && closeRect.width > 0)
+                                    maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+                            }
+                            else {
+                                maxImageWidth = x + width - imageX - RIGHT_MARGIN;
+                                if (parent.showUnselectedClose && (parent.showClose || showClose)) {
+                                    maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+                                }
+                            }
+                            if (bounds.width < maxImageWidth) {
+                                int imageY = y + (height - bounds.height) / 2 + (parent.onBottom ? -1 : 1);
+                                parent.redraw(imageX, imageY, bounds.width, bounds.height, false);
+                            }
+                        }
+                    }
+                    return;
+                }
+            }
+            parent.updateItems();
+            parent.redrawTabs();
+        }
+    }
+
+    /**
+     * Sets to <code>true</code> to indicate that the receiver's close button should be shown.
+     * If the parent (CTabFolder) was created with DWT.CLOSE style, changing this value has
+     * no effect.
+     * 
+     * @param close the new state of the close button
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     * 
+     * @since 3.4
+     */
+    public void setShowClose (bool close) {
+        checkWidget();
+        if (showClose is close)
+            return;
+        showClose = close;
+        parent.updateItems();
+        parent.redrawTabs();
+    }
+
+    public void setText (String String) {
+        checkWidget();
+        if (String is null)
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        if (String.opEquals(getText()))
+            return;
+        super.setText(String);
+        shortenedText = null;
+        shortenedTextWidth = 0;
+        if (!parent.updateTabHeight(false)) {
+            parent.updateItems();
+            parent.redrawTabs();
+        }
+    }
+
+    /**
+     * Sets the receiver's tool tip text to the argument, which
+     * may be null indicating that no tool tip text should be shown.
+     *
+     * @param String the new tool tip text (or null)
+     *
+     * @exception DWTException <ul>
+     *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+     *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+     * </ul>
+     */
+    public void setToolTipText (String String) {
+        checkWidget();
+        toolTipText = String;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ControlEditor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.custom.ControlEditor;
+
+import Math = tango.math.Math;
+
+import dwt.DWT;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.ScrollBar;
+
+/**
+ *
+ * A ControlEditor is a manager for a Control that appears above a composite and tracks with the
+ * moving and resizing of that composite.  It can be used to display one control above 
+ * another control.  This could be used when editing a control that does not have editing 
+ * capabilities by using a text editor or for launching a dialog by placing a button 
+ * above a control.
+ *
+ * <p> Here is an example of using a ControlEditor:
+ *
+ * <code><pre>
+ * Canvas canvas = new Canvas(shell, DWT.BORDER);
+ * canvas.setBounds(10, 10, 300, 300);  
+ * Color color = new Color(null, 255, 0, 0);
+ * canvas.setBackground(color);
+ * ControlEditor editor = new ControlEditor (canvas);
+ * // The editor will be a button in the bottom right corner of the canvas.
+ * // When selected, it will launch a Color dialog that will change the background 
+ * // of the canvas.
+ * Button button = new Button(canvas, DWT.PUSH);
+ * button.setText("Select Color...");
+ * button.addSelectionListener (new SelectionAdapter() {
+ *  public void widgetSelected(SelectionEvent e) {
+ *      ColorDialog dialog = new ColorDialog(shell);
+ *      dialog.open();
+ *      RGB rgb = dialog.getRGB();
+ *      if (rgb !is null) {
+ *          if (color !is null) color.dispose();
+ *          color = new Color(null, rgb);
+ *          canvas.setBackground(color);
+ *      }
+ *      
+ *  }
+ * });
+ *
+ * editor.horizontalAlignment = DWT.RIGHT;
+ * editor.verticalAlignment = DWT.BOTTOM;
+ * editor.grabHorizontal = false;
+ * editor.grabVertical = false;
+ * Point size = button.computeSize(DWT.DEFAULT, DWT.DEFAULT);
+ * editor.minimumWidth = size.x;
+ * editor.minimumHeight = size.y;
+ * editor.setEditor (button);
+ * </pre></code>
+ */
+public class ControlEditor {
+
+    /**
+     * Specifies how the editor should be aligned relative to the control.  Allowed values
+     * are DWT.LEFT, DWT.RIGHT and DWT.CENTER.  The default value is DWT.CENTER.
+     */
+    public int horizontalAlignment = DWT.CENTER;
+
+    /**
+     * Specifies whether the editor should be sized to use the entire width of the control.
+     * True means resize the editor to the same width as the cell.  False means do not adjust 
+     * the width of the editor. The default value is false.
+     */
+    public bool grabHorizontal = false;
+
+    /**
+     * Specifies the minimum width the editor can have.  This is used in association with
+     * a true value of grabHorizontal.  If the cell becomes smaller than the minimumWidth, the 
+     * editor will not made smaller than the minimum width value.  The default value is 0.
+     */
+    public int minimumWidth = 0;
+
+    /**
+     * Specifies how the editor should be aligned relative to the control.  Allowed values
+     * are DWT.TOP, DWT.BOTTOM and DWT.CENTER.  The default value is DWT.CENTER.
+     */
+    public int verticalAlignment = DWT.CENTER;
+
+    /**
+     * Specifies whether the editor should be sized to use the entire height of the control.
+     * True means resize the editor to the same height as the underlying control.  False means do not adjust 
+     * the height of the editor.    The default value is false.
+     */
+    public bool grabVertical = false;
+
+    /**
+     * Specifies the minimum height the editor can have.  This is used in association with
+     * a true value of grabVertical.  If the control becomes smaller than the minimumHeight, the 
+     * editor will not made smaller than the minimum height value.  The default value is 0.
+     */
+    public int minimumHeight = 0;
+
+    Composite parent;
+    Control editor;
+    private bool hadFocus;
+    private Listener controlListener;
+    private Listener scrollbarListener;
+
+    private const static int[] EVENTS = [DWT.KeyDown, DWT.KeyUp, DWT.MouseDown, DWT.MouseUp, DWT.Resize];
+
+    /**
+     * Creates a ControlEditor for the specified Composite.
+     *
+     * @param parent the Composite above which this editor will be displayed
+     *
+     */
+    public this (Composite parent) {
+        this.parent = parent;
+
+        controlListener = new class Listener {
+            public void handleEvent (Event e) {
+                layout();
+            }
+        };
+        for (int i = 0; i < EVENTS.length; i++) {
+            parent.addListener(EVENTS[i], controlListener);
+        }
+
+        scrollbarListener = new class Listener {
+            public void handleEvent (Event e) {
+                scroll(e);
+            }
+        };
+        ScrollBar hBar = parent.getHorizontalBar();
+        if (hBar !is null)
+            hBar.addListener(DWT.Selection, scrollbarListener);
+        ScrollBar vBar = parent.getVerticalBar();
+        if (vBar !is null)
+            vBar.addListener(DWT.Selection, scrollbarListener);
+    }
+
+    Rectangle computeBounds () {
+        Rectangle clientArea = parent.getClientArea();
+        Rectangle editorRect = new Rectangle(clientArea.x, clientArea.y, minimumWidth, minimumHeight);
+
+        if (grabHorizontal)
+            editorRect.width = Math.max(clientArea.width, minimumWidth);
+
+        if (grabVertical)
+            editorRect.height = Math.max(clientArea.height, minimumHeight);
+
+        switch (horizontalAlignment) {
+            case DWT.RIGHT:
+                editorRect.x += clientArea.width - editorRect.width;
+            break;
+            case DWT.LEFT:
+            // do nothing - clientArea.x is the right answer
+            break;
+            default:
+                // default is CENTER
+                editorRect.x += (clientArea.width - editorRect.width) / 2;
+        }
+
+        switch (verticalAlignment) {
+            case DWT.BOTTOM:
+                editorRect.y += clientArea.height - editorRect.height;
+            break;
+            case DWT.TOP:
+            // do nothing - clientArea.y is the right answer
+            break;
+            default:
+                // default is CENTER
+                editorRect.y += (clientArea.height - editorRect.height) / 2;
+        }
+
+        return editorRect;
+
+    }
+
+    /**
+     * Removes all associations between the Editor and the underlying composite.  The
+     * composite and the editor Control are <b>not</b> disposed.
+     */
+    public void dispose () {
+        if (parent !is null && !parent.isDisposed()) {
+            for (int i = 0; i < EVENTS.length; i++) {
+                parent.removeListener(EVENTS[i], controlListener);
+            }
+            ScrollBar hBar = parent.getHorizontalBar();
+            if (hBar !is null)
+                hBar.removeListener(DWT.Selection, scrollbarListener);
+            ScrollBar vBar = parent.getVerticalBar();
+            if (vBar !is null)
+                vBar.removeListener(DWT.Selection, scrollbarListener);
+        }
+
+        parent = null;
+        editor = null;
+        hadFocus = false;
+        controlListener = null;
+        scrollbarListener = null;
+    }
+
+    /**
+     * Returns the Control that is displayed above the composite being edited.
+     *
+     * @return the Control that is displayed above the composite being edited
+     */
+    public Control getEditor () {
+        return editor;
+    }
+
+    /**
+     * Lays out the control within the underlying composite.  This
+     * method should be called after changing one or more fields to
+     * force the Editor to resize.
+     * 
+     * @since 2.1
+     */
+    public void layout () {
+        if (editor is null || editor.isDisposed())
+            return;
+        if (editor.getVisible()) {
+            hadFocus = editor.isFocusControl();
+        } // this doesn't work because
+        // resizing the column takes the focus away
+        // before we get here
+        editor.setBounds(computeBounds());
+        if (hadFocus) {
+            if (editor is null || editor.isDisposed())
+                return;
+            editor.setFocus();
+        }
+    }
+
+    void scroll (Event e) {
+        if (editor is null || editor.isDisposed())
+            return;
+        layout();
+    }
+
+    /**
+     * Specify the Control that is to be displayed.
+     *
+     * <p>Note: The Control provided as the editor <b>must</b> be created with its parent 
+     * being the Composite specified in the ControlEditor constructor.
+     * 
+     * @param editor the Control that is displayed above the composite being edited
+     */
+    public void setEditor (Control editor) {
+
+        if (editor is null) {
+            // this is the case where the caller is setting the editor to be blank
+            // set all the values accordingly
+            this.editor = null;
+            return;
+        }
+
+        this.editor = editor;
+        layout();
+        if (this.editor is null || this.editor.isDisposed())
+            return;
+        editor.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/DefaultContent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,880 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.internal.Compatibility;
+import dwt.widgets.*;
+import java.util.Vector;
+
+class DefaultContent : StyledTextContent {
+    private final static String LineDelimiter = System.getProperty("line.separator");
+
+    Vector textListeners = new Vector(); // stores text listeners for event sending
+    char[] textStore = new char[0]; // stores the actual text
+    int gapStart = -1;  // the character position start of the gap
+    int gapEnd = -1;    // the character position after the end of the gap
+    int gapLine = -1;   // the line on which the gap exists, the gap will always be associated with one line
+    int highWatermark = 300;    
+    int lowWatermark = 50;      
+    
+    int[][] lines = new int[50][2]; // array of character positions and lengths representing the lines of text
+    int lineCount = 0;  // the number of lines of text  
+    int expandExp = 1;  // the expansion exponent, used to increase the lines array exponentially
+    int replaceExpandExp = 1;   // the expansion exponent, used to increase the lines array exponentially
+
+/** 
+ * Creates a new DefaultContent and initializes it.  A <code>StyledTextContent</> will always have
+ * at least one empty line.
+ */
+DefaultContent() {
+    super();
+    setText("");
+}
+/** 
+ * Adds a line to the end of the line indexes array.  Increases the size of the array if necessary.
+ * <code>lineCount</code> is updated to reflect the new entry.
+ * <p>
+ *
+ * @param start the start of the line
+ * @param length the length of the line
+ */
+void addLineIndex(int start, int length) {
+    int size = lines.length;
+    if (lineCount is size) {
+        // expand the lines by powers of 2
+        int[][] newLines = new int[size+Compatibility.pow2(expandExp)][2];
+        System.arraycopy(lines, 0, newLines, 0, size);
+        lines = newLines;
+        expandExp++;
+    }
+    int[] range = new int[] {start, length};
+    lines[lineCount] = range;
+    lineCount++;
+}
+/** 
+ * Adds a line index to the end of <code>linesArray</code>.  Increases the 
+ * size of the array if necessary and returns a new array.
+ * <p>
+ *
+ * @param start the start of the line
+ * @param length the length of the line
+ * @param linesArray the array to which to add the line index
+ * @param count the position at which to add the line
+ * @return a new array of line indexes
+ */
+int[][] addLineIndex(int start, int length, int[][] linesArray, int count) {
+    int size = linesArray.length;
+    int[][] newLines = linesArray;
+    if (count is size) {
+        newLines = new int[size+Compatibility.pow2(replaceExpandExp)][2];
+        replaceExpandExp++;
+        System.arraycopy(linesArray, 0, newLines, 0, size);
+    }
+    int[] range = new int[] {start, length};
+    newLines[count] = range;
+    return newLines;
+}
+/**
+ * Adds a <code>TextChangeListener</code> listening for 
+ * <code>TextChangingEvent</code> and <code>TextChangedEvent</code>. A 
+ * <code>TextChangingEvent</code> is sent before changes to the text occur.
+ * A <code>TextChangedEvent</code> is sent after changes to the text 
+ * occurred.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangeListener(TextChangeListener listener) {
+    if (listener is null) error(DWT.ERROR_NULL_ARGUMENT);
+    StyledTextListener typedListener = new StyledTextListener(listener);
+    textListeners.addElement(typedListener);    
+}   
+/**
+ * Adjusts the gap to accommodate a text change that is occurring.
+ * <p>
+ *
+ * @param position the position at which a change is occurring
+ * @param sizeHint the size of the change
+ * @param line the line where the gap will go
+ */
+void adjustGap(int position, int sizeHint, int line) {
+    if (position is gapStart) {
+        // text is being inserted at the gap position
+        int size = (gapEnd - gapStart) - sizeHint;
+        if (lowWatermark <= size && size <= highWatermark)
+            return;
+    } else if ((position + sizeHint is gapStart) && (sizeHint < 0)) {
+        // text is being deleted at the gap position
+        int size = (gapEnd - gapStart) - sizeHint;
+        if (lowWatermark <= size && size <= highWatermark)
+            return;
+    }
+    moveAndResizeGap(position, sizeHint, line);
+}
+/**
+ * Calculates the indexes of each line in the text store.  Assumes no gap exists.  
+ * Optimized to do less checking.
+ */
+void indexLines(){
+    int start = 0;
+    lineCount = 0;
+    int textLength = textStore.length;
+    int i;
+    for (i = start; i < textLength; i++) {
+        char ch = textStore[i];                 
+        if (ch is DWT.CR) {
+            // see if the next character is a LF
+            if (i + 1 < textLength) {
+                ch = textStore[i+1];
+                if (ch is DWT.LF) {
+                    i++;
+                }
+            }
+            addLineIndex(start, i - start + 1);
+            start = i + 1;
+        } else if (ch is DWT.LF) {
+            addLineIndex(start, i - start + 1);
+            start = i + 1;
+        }
+    }
+    addLineIndex(start, i - start);
+}
+/** 
+ * Returns whether or not the given character is a line delimiter.  Both CR and LF 
+ * are valid line delimiters.
+ * <p>
+ *
+ * @param ch the character to test
+ * @return true if ch is a delimiter, false otherwise
+ */
+bool isDelimiter(char ch) {
+    if (ch is DWT.CR) return true;
+    if (ch is DWT.LF) return true;
+    return false;
+}   
+/**
+ * Determine whether or not the replace operation is valid.  DefaultContent will not allow
+ * the /r/n line delimiter to be split or partially deleted.
+ * <p>
+ *
+ * @param start start offset of text to replace
+ * @param replaceLength start offset of text to replace
+ * @param newText start offset of text to replace
+ * @return a bool specifying whether or not the replace operation is valid
+ */
+protected bool isValidReplace(int start, int replaceLength, String newText){
+    if (replaceLength is 0) {
+        // inserting text, see if the \r\n line delimiter is being split
+        if (start is 0) return true;
+        if (start is getCharCount()) return true;
+        char before = getTextRange(start - 1, 1).charAt(0);
+        if (before is '\r') {
+            char after = getTextRange(start, 1).charAt(0);
+            if (after is '\n') return false;
+        }
+    } else {
+        // deleting text, see if part of a \r\n line delimiter is being deleted
+        char startChar = getTextRange(start, 1).charAt(0);
+        if (startChar is '\n') {
+            // see if char before delete position is \r
+            if (start !is 0) {
+                char before = getTextRange(start - 1, 1).charAt(0);
+                if (before is '\r') return false;
+            }
+        }
+        char endChar = getTextRange(start + replaceLength - 1, 1).charAt(0);
+        if (endChar is '\r') {
+            // see if char after delete position is \n
+            if (start + replaceLength !is getCharCount()) {
+                char after = getTextRange(start + replaceLength, 1).charAt(0);
+                if (after is '\n') return false;
+            }
+        }
+    } 
+    return true;
+}
+/**
+ * Calculates the indexes of each line of text in the given range.
+ * <p>
+ *
+ * @param offset the logical start offset of the text lineate
+ * @param length the length of the text to lineate, includes gap
+ * @param numLines the number of lines to initially allocate for the line index array,
+ *  passed in for efficiency (the exact number of lines may be known)
+ * @return a line indexes array where each line is identified by a start offset and 
+ *  a length
+ */
+int[][] indexLines(int offset, int length, int numLines){
+    int[][] indexedLines = new int[numLines][2];
+    int start = 0;
+    int lineCount = 0;
+    int i;
+    replaceExpandExp = 1;
+    for (i = start; i < length; i++) {
+        int location = i + offset; 
+        if ((location >= gapStart) && (location < gapEnd)) {
+            // ignore the gap
+        } else {
+            char ch = textStore[location];              
+            if (ch is DWT.CR) {
+                // see if the next character is a LF
+                if (location+1 < textStore.length) {
+                    ch = textStore[location+1];
+                    if (ch is DWT.LF) {
+                        i++;
+                    } 
+                }
+                indexedLines = addLineIndex(start, i - start + 1, indexedLines, lineCount);
+                lineCount++;
+                start = i + 1;
+            } else if (ch is DWT.LF) {
+                indexedLines = addLineIndex(start, i - start + 1, indexedLines, lineCount);
+                lineCount++;
+                start = i + 1;
+            }
+        }
+    }
+    int[][] newLines = new int[lineCount+1][2];
+    System.arraycopy(indexedLines, 0, newLines, 0, lineCount);
+    int[] range = new int[] {start, i - start};
+    newLines[lineCount] = range;
+    return newLines; 
+}
+/**
+ * Inserts text.
+ * <p>
+ *
+ * @param position the position at which to insert the text
+ * @param text the text to insert
+ */
+void insert(int position, String text) {    
+    if (text.length() is 0) return;
+                
+    int startLine = getLineAtOffset(position);
+    int change = text.length();
+    bool endInsert = position is getCharCount();
+    adjustGap(position, change, startLine);
+
+    // during an insert the gap will be adjusted to start at
+    // position and it will be associated with startline, the
+    // inserted text will be placed in the gap      
+    int startLineOffset = getOffsetAtLine(startLine);
+    // at this point, startLineLength will include the start line
+    // and all of the newly inserted text
+    int startLineLength = getPhysicalLine(startLine).length();
+    
+    if (change > 0) {
+        // shrink gap 
+        gapStart += (change);
+        for (int i = 0; i < text.length(); i++) {
+            textStore[position + i]= text.charAt(i);
+        }
+    }
+        
+    // figure out the number of new lines that have been inserted
+    int [][] newLines = indexLines(startLineOffset, startLineLength, 10);
+    // only insert an empty line if it is the last line in the text
+    int numNewLines = newLines.length - 1;
+    if (newLines[numNewLines][1] is 0) {
+        // last inserted line is a new line
+        if (endInsert) {
+            // insert happening at end of the text, leave numNewLines as
+            // is since the last new line will not be concatenated with another
+            // line 
+            numNewLines += 1;
+        } else {
+            numNewLines -= 1;
+        }
+    }
+    
+    // make room for the new lines
+    expandLinesBy(numNewLines);
+    // shift down the lines after the replace line
+    for (int i = lineCount - 1; i > startLine; i--) {
+        lines[i + numNewLines]=lines[i];
+    }
+    // insert the new lines
+    for (int i = 0; i < numNewLines; i++) {
+        newLines[i][0] += startLineOffset;
+        lines[startLine + i]=newLines[i];
+    }
+    // update the last inserted line
+    if (numNewLines < newLines.length) {
+        newLines[numNewLines][0] += startLineOffset;
+        lines[startLine + numNewLines] = newLines[numNewLines];
+    }
+    
+    lineCount += numNewLines;
+    gapLine = getLineAtPhysicalOffset(gapStart);
+}
+/**
+ * Moves the gap and adjusts its size in anticipation of a text change.  
+ * The gap is resized to actual size + the specified size and moved to the given 
+ * position.
+ * <p>
+ *
+ * @param position the position at which a change is occurring
+ * @param size the size of the change
+ * @param newGapLine the line where the gap should be put
+ */
+void moveAndResizeGap(int position, int size, int newGapLine) {
+    char[] content = null;
+    int oldSize = gapEnd - gapStart;
+    int newSize;
+    if (size > 0) {
+        newSize = highWatermark + size;
+    } else {
+        newSize = lowWatermark - size;
+    }
+    // remove the old gap from the lines information
+    if (gapExists()) {
+        // adjust the line length
+        lines[gapLine][1] = lines[gapLine][1] - oldSize;
+        // adjust the offsets of the lines after the gapLine
+        for (int i = gapLine + 1; i < lineCount; i++) {
+            lines[i][0] = lines[i][0] - oldSize;
+        }
+    }
+    
+    if (newSize < 0) {
+        if (oldSize > 0) {
+            // removing the gap
+            content = new char[textStore.length - oldSize];
+            System.arraycopy(textStore, 0, content, 0, gapStart);
+            System.arraycopy(textStore, gapEnd, content, gapStart, content.length - gapStart);
+            textStore = content;
+        }
+        gapStart = gapEnd = position;
+        return;
+    }
+    content = new char[textStore.length + (newSize - oldSize)];
+    int newGapStart = position;
+    int newGapEnd = newGapStart + newSize;
+    if (oldSize is 0) {
+        System.arraycopy(textStore, 0, content, 0, newGapStart);
+        System.arraycopy(textStore, newGapStart, content, newGapEnd, content.length - newGapEnd);   
+    } else if (newGapStart < gapStart) {
+        int delta = gapStart - newGapStart;
+        System.arraycopy(textStore, 0, content, 0, newGapStart);
+        System.arraycopy(textStore, newGapStart, content, newGapEnd, delta);
+        System.arraycopy(textStore, gapEnd, content, newGapEnd + delta, textStore.length - gapEnd);
+    } else {
+        int delta = newGapStart - gapStart;
+        System.arraycopy(textStore, 0, content, 0, gapStart);
+        System.arraycopy(textStore, gapEnd, content, gapStart, delta);
+        System.arraycopy(textStore, gapEnd + delta, content, newGapEnd, content.length - newGapEnd);
+    }
+    textStore = content;
+    gapStart = newGapStart;
+    gapEnd = newGapEnd;
+    
+    // add the new gap to the lines information
+    if (gapExists()) {
+        gapLine = newGapLine;
+        // adjust the line length
+        int gapLength = gapEnd - gapStart;
+        lines[gapLine][1] = lines[gapLine][1] + (gapLength);
+        // adjust the offsets of the lines after the gapLine
+        for (int i = gapLine + 1; i < lineCount; i++) {
+            lines[i][0] = lines[i][0] + gapLength;
+        }
+    }
+}
+/** 
+ * Returns the number of lines that are in the specified text.
+ * <p>
+ *
+ * @param startOffset the start of the text to lineate
+ * @param length the length of the text to lineate
+ * @return number of lines
+ */
+int lineCount(int startOffset, int length){
+    if (length is 0) {
+        return 0;
+    }
+    int lineCount = 0;
+    int count = 0;
+    int i = startOffset;
+    if (i >= gapStart) {
+        i += gapEnd - gapStart;
+    }
+    while (count < length) {
+        if ((i >= gapStart) && (i < gapEnd)) {
+            // ignore the gap
+        } else {
+            char ch = textStore[i];         
+            if (ch is DWT.CR) {
+                // see if the next character is a LF
+                if (i + 1 < textStore.length) {
+                    ch = textStore[i+1];
+                    if (ch is DWT.LF) {
+                        i++;
+                        count++;
+                    } 
+                } 
+                lineCount++;
+            } else if (ch is DWT.LF) {
+                lineCount++;
+            }
+            count++;
+        }
+        i++;
+    }
+    return lineCount;
+}
+/** 
+ * Returns the number of lines that are in the specified text.
+ * <p>
+ *
+ * @param text the text to lineate
+ * @return number of lines in the text
+ */
+int lineCount(String text){
+    int lineCount = 0;
+    int length = text.length();
+    for (int i = 0; i < length; i++) {
+        char ch = text.charAt(i);
+        if (ch is DWT.CR) {
+            if (i + 1 < length && text.charAt(i + 1) is DWT.LF) {
+                i++;
+            }
+            lineCount++;
+        } else if (ch is DWT.LF) {
+            lineCount++;
+        }
+    }
+    return lineCount;   
+}
+/**
+ * @return the logical length of the text store
+ */
+public int getCharCount() {
+    int length = gapEnd - gapStart;
+    return (textStore.length - length);
+}
+/**
+ * Returns the line at <code>index</code> without delimiters.
+ * <p>
+ *
+ * @param index the index of the line to return
+ * @return the logical line text (i.e., without the gap)
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when index is out of range</li>
+ * </ul>
+ */
+public String getLine(int index) {
+    if ((index >= lineCount) || (index < 0)) error(DWT.ERROR_INVALID_ARGUMENT);
+    int start = lines[index][0];
+    int length = lines[index][1];
+    int end = start + length - 1;
+    if (!gapExists() || (end < gapStart) || (start >= gapEnd)) {
+        // line is before or after the gap
+        while ((length - 1 >= 0) && isDelimiter(textStore[start+length-1])) {
+            length--;
+        }
+        return new String(textStore, start, length);
+    } else {
+        // gap is in the specified range, strip out the gap
+        StringBuffer buf = new StringBuffer();
+        int gapLength = gapEnd - gapStart;
+        buf.append(textStore, start, gapStart - start);
+        buf.append(textStore, gapEnd, length - gapLength - (gapStart - start));
+        length = buf.length();
+        while ((length - 1 >=0) && isDelimiter(buf.charAt(length - 1))) {
+            length--;
+        }
+        return buf.toString().substring(0, length);
+    }
+}
+/**
+ * Returns the line delimiter that should be used by the StyledText 
+ * widget when inserting new lines.  This delimiter may be different than the
+ * delimiter that is used by the <code>StyledTextContent</code> interface.
+ * <p>
+ *
+ * @return the platform line delimiter as specified in the line.separator
+ *  system property.
+ */
+public String getLineDelimiter() {
+    return LineDelimiter;
+}
+/**
+ * Returns the line at the given index with delimiters.
+ * <p>
+ * @param index the index of the line to return
+ * @return the logical line text (i.e., without the gap) with delimiters
+ */
+String getFullLine(int index) {
+    int start = lines[index][0];
+    int length = lines[index][1];
+    int end = start + length - 1;
+    if (!gapExists() || (end < gapStart) || (start >= gapEnd)) {
+        // line is before or after the gap
+        return new String(textStore, start, length);
+    } else {
+        // gap is in the specified range, strip out the gap
+        StringBuffer buffer = new StringBuffer();
+        int gapLength = gapEnd - gapStart;
+        buffer.append(textStore, start, gapStart - start);
+        buffer.append(textStore, gapEnd, length - gapLength - (gapStart - start));
+        return buffer.toString();
+    }
+}
+/**
+ * Returns the physical line at the given index (i.e., with delimiters and the gap).
+ * <p>
+ *
+ * @param index the line index
+ * @return the physical line 
+ */
+String getPhysicalLine(int index) {
+    int start = lines[index][0];
+    int length = lines[index][1];
+    return getPhysicalText(start, length);
+}
+/**
+ * @return the number of lines in the text store
+ */
+public int getLineCount(){
+    return lineCount;
+}
+/**
+ * Returns the line at the given offset.
+ * <p>
+ *
+ * @param charPosition logical character offset (i.e., does not include gap)
+ * @return the line index
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when charPosition is out of range</li>
+ * </ul>
+ */
+public int getLineAtOffset(int charPosition){
+    if ((charPosition > getCharCount()) || (charPosition < 0)) error(DWT.ERROR_INVALID_ARGUMENT);
+    int position;
+    if (charPosition < gapStart) {
+        // position is before the gap
+        position = charPosition;
+    } else {
+        // position includes the gap
+        position = charPosition + (gapEnd - gapStart);
+    }
+
+    // if last line and the line is not empty you can ask for 
+    // a position that doesn't exist (the one to the right of the 
+    // last character) - for inserting
+    if (lineCount > 0) {
+        int lastLine = lineCount - 1;
+        if (position is lines[lastLine][0] + lines[lastLine][1]) 
+            return lastLine;
+    }
+
+    int high = lineCount;
+    int low = -1;
+    int index = lineCount;
+    while (high - low > 1) {
+        index = (high + low) / 2;
+        int lineStart = lines[index][0];
+        int lineEnd = lineStart + lines[index][1] - 1;
+        if (position <= lineStart) {
+            high = index;
+        } else if (position <= lineEnd) {
+            high = index;
+            break;
+        } else {
+            low = index;
+        }
+    }
+    return high;
+}
+/**
+ * Returns the line index at the given physical offset.
+ * <p>
+ *
+ * @param position physical character offset (i.e., includes gap)
+ * @return the line index
+ */
+int getLineAtPhysicalOffset(int position){
+    int high = lineCount;
+    int low = -1;
+    int index = lineCount;
+    while (high - low > 1) {
+        index = (high + low) / 2;
+        int lineStart = lines[index][0];
+        int lineEnd = lineStart + lines[index][1] - 1;
+        if (position <= lineStart) {
+            high = index;
+        } else if (position <= lineEnd) {
+            high = index;
+            break;
+        } else {
+            low = index;
+        }
+    }
+    return high;
+}
+/**
+ * Returns the logical offset of the given line.
+ * <p>
+ *
+ * @param lineIndex index of line 
+ * @return the logical starting offset of the line.  When there are not any lines,
+ *  getOffsetAtLine(0) is a valid call that should answer 0.
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when lineIndex is out of range</li>
+ * </ul>
+ */
+public int getOffsetAtLine(int lineIndex) {
+    if (lineIndex is 0) return 0;
+    if ((lineIndex >= lineCount) || (lineIndex < 0)) error(DWT.ERROR_INVALID_ARGUMENT);
+    int start = lines[lineIndex][0];
+    if (start > gapEnd) {
+        return start - (gapEnd - gapStart);
+    } else {
+        return start;
+    }
+}   
+/**
+ * Increases the line indexes array to accommodate more lines.
+ * <p>
+ *
+ * @param numLines the number to increase the array by
+ */
+void expandLinesBy(int numLines) {
+    int size = lines.length;
+    if (size - lineCount >= numLines) {
+        return;
+    }
+    int[][] newLines = new int[size+Math.max(10, numLines)][2];
+    System.arraycopy(lines, 0, newLines, 0, size);
+    lines = newLines;
+}
+/**  
+ * Reports an DWT error.
+ * <p>
+ *
+ * @param code the error code
+ */
+void error (int code) {
+    DWT.error(code);
+}
+/** 
+ * Returns whether or not a gap exists in the text store.
+ * <p>
+ *
+ * @return true if gap exists, false otherwise
+ */
+bool gapExists() {
+    return gapStart !is gapEnd;
+}
+/**
+ * Returns a String representing the continuous content of
+ * the text store.
+ * <p>
+ *
+ * @param start the physical start offset of the text to return
+ * @param length the physical length of the text to return
+ * @return the text
+ */
+String getPhysicalText(int start, int length) {
+    return new String(textStore, start, length);
+}
+/**
+ * Returns a String representing the logical content of
+ * the text store (i.e., gap stripped out).
+ * <p>
+ *
+ * @param start the logical start offset of the text to return
+ * @param length the logical length of the text to return
+ * @return the text
+ */
+public String getTextRange(int start, int length) {
+    if (textStore is null)
+        return "";
+    if (length is 0)
+        return "";
+    int end= start + length;
+    if (!gapExists() || (end < gapStart))
+        return new String(textStore, start, length);
+    if (gapStart < start) {
+        int gapLength= gapEnd - gapStart;
+        return new String(textStore, start + gapLength , length);
+    }
+    StringBuffer buf = new StringBuffer();
+    buf.append(textStore, start, gapStart - start);
+    buf.append(textStore, gapEnd, end - gapStart);
+    return buf.toString();
+}
+/**
+ * Removes the specified <code>TextChangeListener</code>.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangeListener(TextChangeListener listener){
+    if (listener is null) error(DWT.ERROR_NULL_ARGUMENT);
+    for (int i = 0; i < textListeners.size(); i++) {
+        TypedListener typedListener = (TypedListener) textListeners.elementAt(i);
+        if (typedListener.getEventListener () is listener) {
+            textListeners.removeElementAt(i);
+            break;
+        }
+    }
+}
+/**
+ * Replaces the text with <code>newText</code> starting at position <code>start</code> 
+ * for a length of <code>replaceLength</code>.  Notifies the appropriate listeners.
+ * <p>
+ *
+ * When sending the TextChangingEvent, <code>newLineCount</code> is the number of 
+ * lines that are going to be inserted and <code>replaceLineCount</code> is 
+ * the number of lines that are going to be deleted, based on the change 
+ * that occurs visually.  For example:
+ * <ul>
+ * <li>(replaceText,newText) ==> (replaceLineCount,newLineCount)
+ * <li>("","\n") ==> (0,1)
+ * <li>("\n\n","a") ==> (2,0)
+ * </ul>
+ * </p>
+ *
+ * @param start start offset of text to replace
+ * @param replaceLength start offset of text to replace
+ * @param newText start offset of text to replace
+ * 
+ * @exception DWTException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the text change results in a multi byte
+ *      line delimiter being split or partially deleted.  Splitting a line 
+ *      delimiter by inserting text between the CR and LF characters of the 
+ *      \r\n delimiter or deleting part of this line delimiter is not supported</li>
+ * </ul>
+ */
+public void replaceTextRange(int start, int replaceLength, String newText){
+    // check for invalid replace operations
+    if (!isValidReplace(start, replaceLength, newText)) DWT.error(DWT.ERROR_INVALID_ARGUMENT);      
+
+    // inform listeners
+    StyledTextEvent event = new StyledTextEvent(this);
+    event.type = StyledText.TextChanging;
+    event.start = start;
+    event.replaceLineCount = lineCount(start, replaceLength);
+    event.text = newText;
+    event.newLineCount = lineCount(newText);
+    event.replaceCharCount = replaceLength;
+    event.newCharCount = newText.length();
+    sendTextEvent(event);
+
+    // first delete the text to be replaced
+    delete(start, replaceLength, event.replaceLineCount + 1);
+    // then insert the new text
+    insert(start, newText);
+    // inform listeners
+    event = new StyledTextEvent(this);
+    event.type = StyledText.TextChanged;
+    sendTextEvent(event);
+}
+/**
+ * Sends the text listeners the TextChanged event.
+ */
+void sendTextEvent(StyledTextEvent event) {
+    for (int i = 0; i < textListeners.size(); i++) {
+        ((StyledTextListener)textListeners.elementAt(i)).handleEvent(event);
+    }
+}       
+/**
+ * Sets the content to text and removes the gap since there are no sensible predictions 
+ * about where the next change will occur.
+ * <p>
+ *
+ * @param text the text
+ */
+public void setText (String text){
+    textStore = text.toCharArray();
+    gapStart = -1;
+    gapEnd = -1;
+    expandExp = 1;
+    indexLines();
+    StyledTextEvent event = new StyledTextEvent(this);
+    event.type = StyledText.TextSet;
+    event.text = "";
+    sendTextEvent(event);
+}
+/**
+ * Deletes text.
+ * <p>
+ * @param position the position at which the text to delete starts
+ * @param length the length of the text to delete
+ * @param numLines the number of lines that are being deleted
+ */
+void delete(int position, int length, int numLines) {
+    if (length is 0) return;
+        
+    int startLine = getLineAtOffset(position);
+    int startLineOffset = getOffsetAtLine(startLine);
+    int endLine = getLineAtOffset(position + length);
+
+    String endText = "";
+    bool splittingDelimiter = false;
+    if (position + length < getCharCount()) {
+        endText = getTextRange(position + length - 1, 2);
+        if ((endText.charAt(0) is DWT.CR) && (endText.charAt(1) is DWT.LF)) {
+            splittingDelimiter = true;
+        }
+    }
+
+    adjustGap(position + length, -length, startLine);
+    int [][] oldLines = indexLines(position, length + (gapEnd - gapStart), numLines);
+    
+    // enlarge the gap - the gap can be enlarged either to the
+    // right or left
+    if (position + length is gapStart) {
+        gapStart -= length;
+    } else {
+        gapEnd += length;
+    }       
+
+    // figure out the length of the new concatenated line, do so by
+    // finding the first line delimiter after position
+    int j = position;
+    bool eol = false;
+    while (j < textStore.length && !eol) {
+        if (j < gapStart || j >= gapEnd) {
+            char ch = textStore[j];
+            if (isDelimiter(ch)) {
+                if (j + 1 < textStore.length) {
+                    if (ch is DWT.CR && (textStore[j+1] is DWT.LF)) {
+                        j++;
+                    }
+                }
+                eol = true;
+            } 
+        }
+        j++;
+    }
+    // update the line where the deletion started
+    lines[startLine][1] = (position - startLineOffset) + (j - position);
+    // figure out the number of lines that have been deleted
+    int numOldLines = oldLines.length - 1;
+    if (splittingDelimiter) numOldLines -= 1;
+    // shift up the lines after the last deleted line, no need to update
+    // the offset or length of the lines
+    for (int i = endLine + 1; i < lineCount; i++) {
+        lines[i - numOldLines] = lines[i];
+    }
+    lineCount -= numOldLines;
+    gapLine = getLineAtPhysicalOffset(gapStart);        
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ExtendedModifyEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+
+/**
+ * This event is sent after a text change occurs.
+ */
+public final class ExtendedModifyEvent : TypedEvent {
+    /** start offset of the new text */
+    public int start;           
+    /** length of the new text */
+    public int length;
+    /** replaced text or empty String if no text was replaced */
+    public String replacedText;
+    
+    static final long serialVersionUID = 3258696507027830832L;
+    
+public ExtendedModifyEvent(StyledTextEvent e) {
+    super(e);
+    start = e.start;
+    length = e.end - e.start;
+    replacedText = e.text;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ExtendedModifyListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.internal.DWTEventListener;
+
+public interface ExtendedModifyListener : DWTEventListener {
+/**
+ * This method is called after a text change occurs.
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.start the start offset of the new text (input)</li>
+ * <li>event.length the length of the new text (input)</li>
+ * <li>event.replacedText the replaced text (input)</li>
+ * </ul>
+ *
+ * @param event the given event
+ * @see ExtendedModifyEvent
+ */
+public void modifyText(ExtendedModifyEvent event);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/LineBackgroundEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+import dwt.graphics.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ */
+public class LineBackgroundEvent : TypedEvent {
+    
+    /**
+     * line start offset
+     */
+    public int lineOffset;
+    
+    /**
+     * line text
+     */
+    public String lineText;
+    
+    /**
+     * line background color
+     */
+    public Color lineBackground; 
+    
+    static final long serialVersionUID = 3978711687853324342L;
+    
+public LineBackgroundEvent(StyledTextEvent e) {
+    super(e);
+    lineOffset = e.detail;
+    lineText = e.text;
+    lineBackground = e.lineBackground;
+}
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/LineBackgroundListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.internal.DWTEventListener;
+
+public interface LineBackgroundListener : DWTEventListener {
+    
+/**
+ * This method is called when a line is about to be drawn in order to get its
+ * background color.
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.lineBackground line background color (output)</li>
+ * </ul>
+ *
+ * @param event the given event
+ * @see LineBackgroundEvent
+ */
+public void lineGetBackground(LineBackgroundEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/LineStyleEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ */
+public class LineStyleEvent : TypedEvent {
+    
+    /**
+     * line start offset (input)
+     */
+    public int lineOffset;
+    
+    /**
+     * line text (input)
+     */
+    public String lineText;
+    
+    /**
+     * line ranges (output)
+     * 
+     * @since 3.2
+     */
+    public int[] ranges;
+    
+    /**
+     * line styles (output)
+     * 
+     * Note: Because a StyleRange includes the start and length, the
+     * same instance cannot occur multiple times in the array of styles.
+     * If the same style attributes, such as font and color, occur in
+     * multiple StyleRanges, <code>ranges</code> can be used to share
+     * styles and reduce memory usage.
+     */
+    public StyleRange[] styles;
+
+    /** 
+     * line alignment (input, output)
+     * 
+     * @since 3.2
+     */
+    public int alignment;
+
+    /**
+     * line indent (input, output)
+     * 
+     * @since 3.2
+     */
+    public int indent;
+
+    /** 
+     * line justification (input, output)
+     * 
+     * @since 3.2
+     */
+    public bool justify;
+
+    /**
+     * line bullet (output)
+     * @since 3.2
+     */
+    public Bullet bullet;
+
+    /**
+     * line bullet index (output)
+     * @since 3.2
+     */
+    public int bulletIndex;
+    
+    static final long serialVersionUID = 3906081274027192884L;
+    
+public LineStyleEvent(StyledTextEvent e) {
+    super(e);
+    styles = e.styles;
+    ranges = e.ranges;
+    lineOffset = e.detail;
+    lineText = e.text;
+    alignment = e.alignment;
+    justify = e.justify;
+    indent = e.indent;
+    bullet = e.bullet;
+    bulletIndex = e.bulletIndex;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/LineStyleListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.internal.DWTEventListener;
+
+public interface LineStyleListener : DWTEventListener {
+/**
+ * This method is called when a line is about to be drawn in order to get the
+ * line's style information.
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.styles array of StyleRanges, need to be in order (output)</li>
+ * </ul>
+ *
+ * @param event the given event
+ * @see LineStyleEvent
+ */
+public void lineGetStyle(LineStyleEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/MovementEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+
+/**
+ * This event is sent when a new offset is required based on the current
+ * offset and a movement type.
+ * 
+ * @since 3.3
+ */
+public class MovementEvent : TypedEvent {
+    
+    /**
+     * line start offset (input)
+     */
+    public int lineOffset;
+    
+    /**
+     * line text (input)
+     */
+    public String lineText;
+    
+    /**
+     * the current offset (input)
+     */
+    public int offset;
+    
+    /**
+     * the new offset  (input, output)
+     */
+    public int newOffset;
+    
+    /**
+     * the movement type (input)
+     * 
+     * @see dwt.DWT#MOVEMENT_WORD
+     * @see dwt.DWT#MOVEMENT_WORD_END 
+     * @see dwt.DWT#MOVEMENT_WORD_START
+     * @see dwt.DWT#MOVEMENT_CHAR
+     * @see dwt.DWT#MOVEMENT_CLUSTER
+     */
+    public int movement;
+    
+    static final long serialVersionUID = 3978765487853324342L;
+    
+public MovementEvent(StyledTextEvent e) {
+    super(e);
+    lineOffset = e.detail;
+    lineText = e.text;
+    movement = e.count;
+    offset = e.start;
+    newOffset = e.end;
+}
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/MovementListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * This listener is invoked when a new offset is required based on the current
+ * offset and a movement type.
+ *
+ * @see dwt.DWT#MOVEMENT_WORD
+ * @see dwt.DWT#MOVEMENT_WORD_END 
+ * @see dwt.DWT#MOVEMENT_WORD_START
+ * @see dwt.DWT#MOVEMENT_CHAR
+ * @see dwt.DWT#MOVEMENT_CLUSTER
+ * 
+ * @since 3.3
+ */
+public interface MovementListener : DWTEventListener {
+/**
+ * This method is called when a new offset is required based on the current
+ * offset and a movement type.
+ * 
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.movement the movement type (input)</li>
+ * <li>event.offset the current offset (input)</li>
+ * <li>event.newOffset the new offset (input, output)</li>
+ * </ul>
+ *
+ * @param event the event
+ * 
+ * @see MovementEvent
+ * @see StyledText#addWordMovementListener(MovementListener)
+ */
+public void getNextOffset (MovementEvent event);
+/**
+ * This method is called when a new offset is required based on the current
+ * offset and a movement type.
+ * 
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.movement the movement type (input)</li>
+ * <li>event.offset the current offset (input)</li>
+ * <li>event.newOffset the new offset (input, output)</li>
+ * </ul>
+ *
+ * @param event the event
+ * 
+ * @see MovementEvent
+ * @see StyledText#addWordMovementListener(MovementListener)
+ */
+public void getPreviousOffset (MovementEvent event);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/PaintObjectEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+import dwt.graphics.*;
+
+/**
+ * This event is sent when an object needs to be drawn.
+ * 
+ * @since 3.2
+ */
+public class PaintObjectEvent : TypedEvent {
+    
+    /**
+     * the GC
+     */
+    public GC gc;
+    
+    /**
+     * the x location
+     */
+    public int x;
+    
+    /**
+     * the y location
+     */
+    public int y;
+    
+    /**
+     * the line ascent
+     */
+    public int ascent;
+    
+    /**
+     * the line descent
+     */
+    public int descent;
+    
+    /**
+     * the StyleRange
+     */
+    public StyleRange style;
+    
+    /**
+     * the Bullet
+     */
+    public Bullet bullet;
+    
+    /**
+     * the bullet index
+     */
+    public int bulletIndex;
+    
+    static final long serialVersionUID = 3906081274027192855L;
+    
+public PaintObjectEvent(StyledTextEvent e) {
+    super(e);
+    gc = e.gc;
+    x = e.x;
+    y = e.y;
+    ascent = e.ascent;
+    descent = e.descent;
+    style = e.style;
+    bullet = e.bullet;
+    bulletIndex = e.bulletIndex;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/PaintObjectListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.internal.DWTEventListener;
+/**
+ * This listener is invoked when an object needs to be drawn.
+ *
+ * @since 3.2
+ */
+public interface PaintObjectListener : DWTEventListener {
+/**
+ * This method is called when an object needs to be drawn.
+ * 
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.x the x location (input)</li>
+ * <li>event.y the y location (input)</li>
+ * <li>event.ascent the line ascent (input)</li>
+ * <li>event.descent the line descent (input)</li>
+ * <li>event.gc the gc (input)</li>
+ * <li>event.style the style (input)</li>
+ * </ul>
+ *
+ * @param event the event
+ * 
+ * @see PaintObjectEvent
+ * @see StyledText#addPaintObjectListener(PaintObjectListener)
+ */
+public void paintObject(PaintObjectEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/PopupList.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.events.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+/**
+* A PopupList is a list of selectable items that appears in its own shell positioned above
+* its parent shell.  It is used for selecting items when editing a Table cell (similar to the
+* list that appears when you open a Combo box).
+*
+* The list will be positioned so that it does not run off the screen and the largest number of items
+* are visible.  It may appear above the current cursor location or below it depending how close you 
+* are to the edge of the screen.
+*/
+public class PopupList {
+    Shell  shell;
+    List   list;
+    int    minimumWidth;
+/** 
+* Creates a PopupList above the specified shell.
+* 
+* @param parent a Shell control which will be the parent of the new instance (cannot be null)
+*/
+public PopupList(Shell parent) {
+    this (parent, 0);
+}
+/** 
+* Creates a PopupList above the specified shell.
+* 
+* @param parent a widget which will be the parent of the new instance (cannot be null)
+* @param style the style of widget to construct
+* 
+* @since 3.0 
+*/
+public PopupList(Shell parent, int style) {
+    shell = new Shell(parent, checkStyle(style));
+    
+    list = new List(shell, DWT.SINGLE | DWT.V_SCROLL);  
+
+    // close dialog if user selects outside of the shell
+    shell.addListener(DWT.Deactivate, new Listener() {
+        public void handleEvent(Event e){   
+            shell.setVisible (false);
+        }
+    });
+    
+    // resize shell when list resizes
+    shell.addControlListener(new ControlListener() {
+        public void controlMoved(ControlEvent e){}
+        public void controlResized(ControlEvent e){
+            Rectangle shellSize = shell.getClientArea();
+            list.setSize(shellSize.width, shellSize.height);
+        }
+    });
+    
+    // return list selection on Mouse Up or Carriage Return
+    list.addMouseListener(new MouseListener() {
+        public void mouseDoubleClick(MouseEvent e){}
+        public void mouseDown(MouseEvent e){}
+        public void mouseUp(MouseEvent e){
+            shell.setVisible (false);
+        }
+    });
+    list.addKeyListener(new KeyListener() {
+        public void keyReleased(KeyEvent e){}
+        public void keyPressed(KeyEvent e){
+            if (e.character is '\r'){
+                shell.setVisible (false);
+            }
+        }
+    });
+    
+}
+private static int checkStyle (int style) {
+    int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+    return style & mask;
+}
+/**
+* Gets the widget font.
+* <p>
+* @return the widget font
+*
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*   </ul>
+*/
+public Font getFont () {
+    return list.getFont();
+}
+/**
+* Gets the items.
+* <p>
+* This operation will fail if the items cannot
+* be queried from the OS.
+*
+* @return the items in the widget
+*
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*   </ul>
+*/
+public String[] getItems () {
+    return list.getItems();
+}
+/**
+* Gets the minimum width of the list.
+*
+* @return the minimum width of the list
+*/
+public int getMinimumWidth () {
+    return minimumWidth;
+}
+/**
+* Launches the Popup List, waits for an item to be selected and then closes the PopupList.
+*
+* @param rect the initial size and location of the PopupList; the dialog will be
+*        positioned so that it does not run off the screen and the largest number of items are visible
+*
+* @return the text of the selected item or null if no item is selected
+*/
+public String open (Rectangle rect) {
+
+    Point listSize = list.computeSize (rect.width, DWT.DEFAULT, false);
+    Rectangle screenSize = shell.getDisplay().getBounds();
+
+    // Position the dialog so that it does not run off the screen and the largest number of items are visible
+    int spaceBelow = screenSize.height - (rect.y + rect.height) - 30;
+    int spaceAbove = rect.y - 30;
+
+    int y = 0;
+    if (spaceAbove > spaceBelow && listSize.y > spaceBelow) {
+        // place popup list above table cell
+        if (listSize.y > spaceAbove){
+            listSize.y = spaceAbove;
+        } else {
+            listSize.y += 2;
+        }
+        y = rect.y - listSize.y;
+        
+    } else {
+        // place popup list below table cell
+        if (listSize.y > spaceBelow){
+            listSize.y = spaceBelow;
+        } else {
+            listSize.y += 2;
+        }
+        y = rect.y + rect.height;
+    }
+    
+    // Make dialog as wide as the cell
+    listSize.x = rect.width;
+    // dialog width should not be less than minimumWidth
+    if (listSize.x < minimumWidth)
+        listSize.x = minimumWidth;
+    
+    // Align right side of dialog with right side of cell
+    int x = rect.x + rect.width - listSize.x;
+    
+    shell.setBounds(x, y, listSize.x, listSize.y);
+    
+    shell.open();
+    list.setFocus();
+
+    Display display = shell.getDisplay();
+    while (!shell.isDisposed () && shell.isVisible ()) {
+        if (!display.readAndDispatch()) display.sleep();
+    }
+    
+    String result = null;
+    if (!shell.isDisposed ()) {
+        String [] Strings = list.getSelection ();
+        shell.dispose();
+        if (Strings.length !is 0) result = Strings [0];
+    }
+    return result;
+}
+/**
+* Selects an item with text that starts with specified String.
+* <p>
+* If the item is not currently selected, it is selected.  
+* If the item at an index is selected, it remains selected.  
+* If the String is not matched, it is ignored.
+*
+* @param String the text of the item
+*
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*   </ul>
+*/
+public void select(String String) {
+    String[] items = list.getItems();
+
+    // find the first entry in the list that starts with the
+    // specified String
+    if (String !is null){
+        for (int i = 0; i < items.length; i++) {
+            if (items[i].startsWith(String)){
+                int index = list.indexOf(items[i]);
+                list.select(index);
+                break;
+            }
+        }
+    }
+}
+/**
+* Sets the widget font.
+* <p>
+* When new font is null, the font reverts
+* to the default system font for the widget.
+*
+* @param font the new font (or null)
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*   </ul>
+*/
+public void setFont (Font font) {
+    list.setFont(font);
+}
+/**
+* Sets all items.
+* <p>
+* The previous selection is cleared.
+* The previous items are deleted.
+* The new items are added.
+* The top index is set to 0.
+*
+* @param Strings the array of items
+*
+* This operation will fail when an item is null
+* or could not be added in the OS.
+* 
+* @exception IllegalArgumentException <ul>
+*    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+*    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+* </ul>
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*   </ul>
+*/
+public void setItems (String[] Strings) {
+    list.setItems(Strings);
+}
+/**
+* Sets the minimum width of the list.
+*
+* @param width the minimum width of the list
+*/
+public void setMinimumWidth (int width) {
+    if (width < 0)
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        
+    minimumWidth = width;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ST.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+/**
+ * This class provides access to the public constants provided by <code>StyledText</code>.
+ */
+public class ST {
+     
+    /*
+     *  Navigation Key Actions. Key bindings for the actions are set
+     *  by the StyledText widget.
+     */ 
+    public static final int LINE_UP = 16777217;             // binding = DWT.ARROW_UP
+    public static final int LINE_DOWN = 16777218;       // binding = DWT.ARROW_DOWN
+    public static final int LINE_START = 16777223;      // binding = DWT.HOME
+    public static final int LINE_END = 16777224;        // binding = DWT.END
+    public static final int COLUMN_PREVIOUS = 16777219;     // binding = DWT.ARROW_LEFT
+    public static final int COLUMN_NEXT = 16777220;         // binding = DWT.ARROW_RIGHT
+    public static final int PAGE_UP = 16777221;             // binding = DWT.PAGE_UP
+    public static final int PAGE_DOWN = 16777222;       // binding = DWT.PAGE_DOWN
+    public static final int WORD_PREVIOUS = 17039363;   // binding = DWT.MOD1 + DWT.ARROW_LEFT
+    public static final int WORD_NEXT = 17039364;       // binding = DWT.MOD1 + DWT.ARROW_RIGHT
+    public static final int TEXT_START = 17039367;      // binding = DWT.MOD1 + DWT.HOME
+    public static final int TEXT_END = 17039368;        // binding = DWT.MOD1 + DWT.END
+    public static final int WINDOW_START = 17039365;    // binding = DWT.MOD1 + DWT.PAGE_UP
+    public static final int WINDOW_END = 17039366;      // binding = DWT.MOD1 + DWT.PAGE_DOWN
+
+    /* 
+     * Selection Key Actions 
+     */
+    public static final int SELECT_ALL = 262209;                // binding = DWT.MOD1 + 'A'
+    public static final int SELECT_LINE_UP = 16908289;          // binding = DWT.MOD2 + DWT.ARROW_UP
+    public static final int SELECT_LINE_DOWN = 16908290;        // binding = DWT.MOD2 + DWT.ARROW_DOWN
+    public static final int SELECT_LINE_START = 16908295;       // binding = DWT.MOD2 + DWT.HOME
+    public static final int SELECT_LINE_END = 16908296;             // binding = DWT.MOD2 + DWT.END
+    public static final int SELECT_COLUMN_PREVIOUS = 16908291;  // binding = DWT.MOD2 + DWT.ARROW_LEFT
+    public static final int SELECT_COLUMN_NEXT = 16908292;      // binding = DWT.MOD2 + DWT.ARROW_RIGHT
+    public static final int SELECT_PAGE_UP = 16908293;          // binding = DWT.MOD2 + DWT.PAGE_UP
+    public static final int SELECT_PAGE_DOWN = 16908294;        // binding = DWT.MOD2 + DWT.PAGE_DOWN
+    public static final int SELECT_WORD_PREVIOUS = 17170435;        // binding = DWT.MOD1 + DWT.MOD2 + DWT.ARROW_LEFT
+    public static final int SELECT_WORD_NEXT = 17170436;        // binding = DWT.MOD1 + DWT.MOD2 + DWT.ARROW_RIGHT
+    public static final int SELECT_TEXT_START = 17170439;       // binding = DWT.MOD1 + DWT.MOD2 + DWT.HOME
+    public static final int SELECT_TEXT_END = 17170440;             // binding = DWT.MOD1 + DWT.MOD2 + DWT.END
+    public static final int SELECT_WINDOW_START = 17170437;         // binding = DWT.MOD1 + DWT.MOD2 + DWT.PAGE_UP
+    public static final int SELECT_WINDOW_END = 17170438;       // binding = DWT.MOD1 + DWT.MOD2 + DWT.PAGE_DOWN
+
+    /*
+     *  Modification Key Actions 
+     */
+    public static final int CUT = 131199;           // binding = DWT.MOD2 + DWT.DEL
+    public static final int COPY = 17039369;        // binding = DWT.MOD1 + DWT.INSERT;
+    public static final int PASTE = 16908297;       // binding = DWT.MOD2 + DWT.INSERT ;
+    public static final int DELETE_PREVIOUS = '\b';     // binding = DWT.BS;
+    public static final int DELETE_NEXT = 0x7F;         // binding = DWT.DEL;
+    public static final int DELETE_WORD_PREVIOUS = 262152;  // binding = DWT.BS | DWT.MOD1;
+    public static final int DELETE_WORD_NEXT = 262271;  // binding = DWT.DEL | DWT.MOD1;
+
+    /* 
+     * Miscellaneous Key Actions 
+     */
+    public static final int TOGGLE_OVERWRITE = 16777225; // binding = DWT.INSERT;
+    
+    /**
+     *  Bullet style dot.
+     * 
+     *  @see Bullet
+     *  
+     *  @since 3.2
+     */
+    public static final int BULLET_DOT = 1 << 0;
+
+    /**
+     *  Bullet style number.
+     * 
+     *  @see Bullet
+     *  
+     *  @since 3.2
+     */
+    public static final int BULLET_NUMBER = 1 << 1;
+
+    /**
+     *  Bullet style lower case letter.
+     * 
+     *  @see Bullet
+     *  
+     *  @since 3.2
+     */
+    public static final int BULLET_LETTER_LOWER = 1 << 2;
+
+    /**
+     *  Bullet style upper case letter.
+     * 
+     *  @see Bullet
+     *  
+     *  @since 3.2
+     */
+    public static final int BULLET_LETTER_UPPER = 1 << 3;
+
+    /**
+     *  Bullet style text.
+     * 
+     *  @see Bullet
+     *  
+     *  @since 3.2
+     */
+    public static final int BULLET_TEXT = 1 << 4;
+
+    /**
+     *  Bullet style custom draw.
+     *  
+     *  @see StyledText#addPaintObjectListener(PaintObjectListener)
+     *  @see StyledText#removePaintObjectListener(PaintObjectListener)
+     *  @see Bullet 
+     *  
+     *  @since 3.2
+     */
+    public static final int BULLET_CUSTOM = 1 << 5;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/SashForm.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,428 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.*;
+import dwt.widgets.*;
+import dwt.graphics.*;
+
+/**
+ * The SashForm is a composite control that lays out its children in a
+ * row or column arrangement (as specified by the orientation) and places
+ * a Sash between each child. One child may be maximized to occupy the
+ * entire size of the SashForm.  The relative sizes of the children may
+ * be specified using weights.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL, SMOOTH</dd>
+ * </dl>
+ * </p>
+ */
+public class SashForm : Composite {
+
+    public int SASH_WIDTH = 3;
+
+    int sashStyle;
+    Sash[] sashes = new Sash[0];
+    // Remember background and foreground
+    // colors to determine whether to set
+    // sashes to the default color (null) or
+    // a specific color
+    Color background = null;
+    Color foreground = null;
+    Control[] controls = new Control[0];
+    Control maxControl = null;
+    Listener sashListener;
+    static final int DRAG_MINIMUM = 20;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT#HORIZONTAL
+ * @see DWT#VERTICAL
+ * @see #getStyle()
+ */
+public SashForm(Composite parent, int style) {
+    super(parent, checkStyle(style));
+    super.setLayout(new SashFormLayout());
+    sashStyle = ((style & DWT.VERTICAL) !is 0) ? DWT.HORIZONTAL : DWT.VERTICAL;
+    if ((style & DWT.BORDER) !is 0) sashStyle |= DWT.BORDER;
+    if ((style & DWT.SMOOTH) !is 0) sashStyle |= DWT.SMOOTH;
+    sashListener = new Listener() {
+        public void handleEvent(Event e) {
+            onDragSash(e);
+        }
+    };
+}
+static int checkStyle (int style) {
+    int mask = DWT.BORDER | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+    return style & mask;
+}
+/**
+ * Returns DWT.HORIZONTAL if the controls in the SashForm are laid out side by side
+ * or DWT.VERTICAL   if the controls in the SashForm are laid out top to bottom.
+ * 
+ * @return DWT.HORIZONTAL or DWT.VERTICAL
+ */
+public int getOrientation() {
+    //checkWidget();
+    return (sashStyle & DWT.VERTICAL) !is 0 ? DWT.HORIZONTAL : DWT.VERTICAL;
+}
+/**
+ * Returns the width of the sashes when the controls in the SashForm are 
+ * laid out.
+ * 
+ * @return the width of the sashes
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public int getSashWidth() {
+    checkWidget();
+    return SASH_WIDTH;
+}
+public int getStyle() {
+    int style = super.getStyle();
+    style |= getOrientation() is DWT.VERTICAL ? DWT.VERTICAL : DWT.HORIZONTAL;
+    if ((sashStyle & DWT.SMOOTH) !is 0) style |= DWT.SMOOTH;
+    return style;
+}
+/**
+ * Answer the control that currently is maximized in the SashForm.  
+ * This value may be null.
+ * 
+ * @return the control that currently is maximized or null
+ */
+public Control getMaximizedControl(){
+    //checkWidget();
+    return this.maxControl;
+}
+/**
+ * Answer the relative weight of each child in the SashForm.  The weight represents the
+ * percent of the total width (if SashForm has Horizontal orientation) or 
+ * total height (if SashForm has Vertical orientation) each control occupies.
+ * The weights are returned in order of the creation of the widgets (weight[0]
+ * corresponds to the weight of the first child created).
+ * 
+ * @return the relative weight of each child
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+
+public int[] getWeights() {
+    checkWidget();
+    Control[] cArray = getControls(false);
+    int[] ratios = new int[cArray.length];
+    for (int i = 0; i < cArray.length; i++) {
+        Object data = cArray[i].getLayoutData();
+        if (data !is null && data instanceof SashFormData) {
+            ratios[i] = (int)(((SashFormData)data).weight * 1000 >> 16);
+        } else {
+            ratios[i] = 200;
+        }
+    }
+    return ratios;
+}
+Control[] getControls(bool onlyVisible) {
+    Control[] children = getChildren();
+    Control[] result = new Control[0];
+    for (int i = 0; i < children.length; i++) {
+        if (children[i] instanceof Sash) continue;
+        if (onlyVisible && !children[i].getVisible()) continue;
+
+        Control[] newResult = new Control[result.length + 1];
+        System.arraycopy(result, 0, newResult, 0, result.length);
+        newResult[result.length] = children[i];
+        result = newResult;
+    }
+    return result;
+}
+void onDragSash(Event event) {
+    Sash sash = (Sash)event.widget;
+    int sashIndex = -1;
+    for (int i= 0; i < sashes.length; i++) {
+        if (sashes[i] is sash) {
+            sashIndex = i;
+            break;
+        }
+    }
+    if (sashIndex is -1) return;
+
+    Control c1 = controls[sashIndex];
+    Control c2 = controls[sashIndex + 1];
+    Rectangle b1 = c1.getBounds();
+    Rectangle b2 = c2.getBounds();
+    
+    Rectangle sashBounds = sash.getBounds();
+    Rectangle area = getClientArea();
+    bool correction = false;
+    if (getOrientation() is DWT.HORIZONTAL) {
+        correction = b1.width < DRAG_MINIMUM || b2.width < DRAG_MINIMUM;
+        int totalWidth = b2.x + b2.width - b1.x; 
+        int shift = event.x - sashBounds.x;
+        b1.width += shift;
+        b2.x += shift;
+        b2.width -= shift;
+        if (b1.width < DRAG_MINIMUM) {
+            b1.width = DRAG_MINIMUM;
+            b2.x = b1.x + b1.width + sashBounds.width;
+            b2.width = totalWidth - b2.x;
+            event.x = b1.x + b1.width;
+            event.doit = false;
+        }
+        if (b2.width < DRAG_MINIMUM) {
+            b1.width = totalWidth - DRAG_MINIMUM - sashBounds.width;
+            b2.x = b1.x + b1.width + sashBounds.width;
+            b2.width = DRAG_MINIMUM;
+            event.x = b1.x + b1.width;
+            event.doit = false;
+        }
+        Object data1 = c1.getLayoutData();
+        if (data1 is null || !(data1 instanceof SashFormData)) {
+            data1 = new SashFormData();
+            c1.setLayoutData(data1);
+        }
+        Object data2 = c2.getLayoutData();
+        if (data2 is null || !(data2 instanceof SashFormData)) {
+            data2 = new SashFormData();
+            c2.setLayoutData(data2);
+        }
+        ((SashFormData)data1).weight = (((long)b1.width << 16) + area.width - 1) / area.width;
+        ((SashFormData)data2).weight = (((long)b2.width << 16) + area.width - 1) / area.width;
+    } else {
+        correction = b1.height < DRAG_MINIMUM || b2.height < DRAG_MINIMUM;
+        int totalHeight = b2.y + b2.height - b1.y;
+        int shift = event.y - sashBounds.y;
+        b1.height += shift;
+        b2.y += shift;
+        b2.height -= shift;
+        if (b1.height < DRAG_MINIMUM) {
+            b1.height = DRAG_MINIMUM;
+            b2.y = b1.y + b1.height + sashBounds.height;
+            b2.height = totalHeight - b2.y;
+            event.y = b1.y + b1.height;
+            event.doit = false;
+        }
+        if (b2.height < DRAG_MINIMUM) {
+            b1.height = totalHeight - DRAG_MINIMUM - sashBounds.height;
+            b2.y = b1.y + b1.height + sashBounds.height;
+            b2.height = DRAG_MINIMUM;
+            event.y = b1.y + b1.height;
+            event.doit = false;
+        }
+        Object data1 = c1.getLayoutData();
+        if (data1 is null || !(data1 instanceof SashFormData)) {
+            data1 = new SashFormData();
+            c1.setLayoutData(data1);
+        }
+        Object data2 = c2.getLayoutData();
+        if (data2 is null || !(data2 instanceof SashFormData)) {
+            data2 = new SashFormData();
+            c2.setLayoutData(data2);
+        }
+        ((SashFormData)data1).weight = (((long)b1.height << 16) + area.height - 1) / area.height;
+        ((SashFormData)data2).weight = (((long)b2.height << 16) + area.height - 1) / area.height;
+    }
+    if (correction || (event.doit && event.detail !is DWT.DRAG)) {
+        c1.setBounds(b1);
+        sash.setBounds(event.x, event.y, event.width, event.height);
+        c2.setBounds(b2);
+    }
+}
+/**
+ * If orientation is DWT.HORIZONTAL, lay the controls in the SashForm 
+ * out side by side.  If orientation is DWT.VERTICAL, lay the 
+ * controls in the SashForm out top to bottom.
+ * 
+ * @param orientation DWT.HORIZONTAL or DWT.VERTICAL
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the value of orientation is not DWT.HORIZONTAL or DWT.VERTICAL
+ * </ul>
+ */
+public void setOrientation(int orientation) {
+    checkWidget();
+    if (getOrientation() is orientation) return;
+    if (orientation !is DWT.HORIZONTAL && orientation !is DWT.VERTICAL) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    sashStyle &= ~(DWT.HORIZONTAL | DWT.VERTICAL);
+    sashStyle |= orientation is DWT.VERTICAL ? DWT.HORIZONTAL : DWT.VERTICAL;
+    for (int i = 0; i < sashes.length; i++) {
+        sashes[i].dispose();
+        sashes[i] = new Sash(this, sashStyle);
+        sashes[i].setBackground(background);
+        sashes[i].setForeground(foreground);
+        sashes[i].addListener(DWT.Selection, sashListener);
+    }
+    layout(false);
+}
+public void setBackground (Color color) {
+    super.setBackground(color);
+    background = color;
+    for (int i = 0; i < sashes.length; i++) {
+        sashes[i].setBackground(background);
+    }
+}
+public void setForeground (Color color) {
+    super.setForeground(color);
+    foreground = color;
+    for (int i = 0; i < sashes.length; i++) {
+        sashes[i].setForeground(foreground);
+    }
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+    checkWidget();
+    return;
+}
+/**
+ * Specify the control that should take up the entire client area of the SashForm.  
+ * If one control has been maximized, and this method is called with a different control, 
+ * the previous control will be minimized and the new control will be maximized.
+ * If the value of control is null, the SashForm will minimize all controls and return to
+ * the default layout where all controls are laid out separated by sashes.
+ * 
+ * @param control the control to be maximized or null
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximizedControl(Control control){
+    checkWidget();
+    if (control is null) {
+        if (maxControl !is null) {
+            this.maxControl = null;
+            layout(false);
+            for (int i= 0; i < sashes.length; i++){
+                sashes[i].setVisible(true);
+            }
+        }
+        return;
+    }
+    
+    for (int i= 0; i < sashes.length; i++){
+        sashes[i].setVisible(false);
+    }
+    maxControl = control;
+    layout(false);
+}
+
+/**
+ * Specify the width of the sashes when the controls in the SashForm are 
+ * laid out.
+ * 
+ * @param width the width of the sashes
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setSashWidth(int width) {
+    checkWidget();
+    if (SASH_WIDTH is width) return;
+    SASH_WIDTH = width;
+    layout(false);
+}
+/**
+ * Specify the relative weight of each child in the SashForm.  This will determine
+ * what percent of the total width (if SashForm has Horizontal orientation) or 
+ * total height (if SashForm has Vertical orientation) each control will occupy.
+ * The weights must be positive values and there must be an entry for each
+ * non-sash child of the SashForm.
+ * 
+ * @param weights the relative weight of each child
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the weights value is null or of incorrect length (must match the number of children)</li>
+ * </ul>
+ */
+public void setWeights(int[] weights) {
+    checkWidget();
+    Control[] cArray = getControls(false);
+    if (weights is null || weights.length !is cArray.length) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    
+    int total = 0;
+    for (int i = 0; i < weights.length; i++) {
+        if (weights[i] < 0) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        total += weights[i];
+    }
+    if (total is 0) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    for (int i = 0; i < cArray.length; i++) {
+        Object data = cArray[i].getLayoutData();
+        if (data is null || !(data instanceof SashFormData)) {
+            data = new SashFormData();
+            cArray[i].setLayoutData(data);
+        }
+        ((SashFormData)data).weight = (((long)weights[i] << 16) + total - 1) / total;
+    }
+
+    layout(false);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/SashFormData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+class SashFormData {
+
+    long weight;
+
+String getName () {
+    String String = getClass ().getName ();
+    int index = String.lastIndexOf ('.');
+    if (index is -1) return String;
+    return String.substring (index + 1, String.length ());
+}
+
+/**
+ * Returns a String containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a String representation of the event
+ */
+public String toString () {
+    return getName()+" {weight="+weight+"}"; //$NON-NLS-2$
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/SashFormLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * This class provides the layout for SashForm
+ * 
+ * @see SashForm
+ */
+class SashFormLayout : Layout {
+protected Point computeSize(Composite composite, int wHint, int hHint, bool flushCache) {
+    SashForm sashForm = (SashForm)composite;
+    Control[] cArray = sashForm.getControls(true);
+    int width = 0;
+    int height = 0;
+    if (cArray.length is 0) {       
+        if (wHint !is DWT.DEFAULT) width = wHint;
+        if (hHint !is DWT.DEFAULT) height = hHint;
+        return new Point(width, height);
+    }
+    // determine control sizes
+    bool vertical = sashForm.getOrientation() is DWT.VERTICAL;
+    int maxIndex = 0;
+    int maxValue = 0;
+    for (int i = 0; i < cArray.length; i++) {
+        if (vertical) {
+            Point size = cArray[i].computeSize(wHint, DWT.DEFAULT, flushCache);
+            if (size.y > maxValue) {
+                maxIndex = i;
+                maxValue = size.y;
+            }
+            width = Math.max(width, size.x);
+        } else {
+            Point size = cArray[i].computeSize(DWT.DEFAULT, hHint, flushCache);
+            if (size.x > maxValue) {
+                maxIndex = i;
+                maxValue = size.x;
+            }
+            height = Math.max(height, size.y);
+        }
+    }
+    // get the ratios
+    long[] ratios = new long[cArray.length];
+    long total = 0;
+    for (int i = 0; i < cArray.length; i++) {
+        Object data = cArray[i].getLayoutData();
+        if (data !is null && data instanceof SashFormData) {
+            ratios[i] = ((SashFormData)data).weight;
+        } else {
+            data = new SashFormData();
+            cArray[i].setLayoutData(data);
+            ((SashFormData)data).weight = ratios[i] = ((200 << 16) + 999) / 1000;
+            
+        }
+        total += ratios[i];
+    }
+    if (ratios[maxIndex] > 0) {
+        int sashwidth = sashForm.sashes.length > 0 ? sashForm.SASH_WIDTH + sashForm.sashes [0].getBorderWidth() * 2 : sashForm.SASH_WIDTH;
+        if (vertical) {
+            height += (int)(total * maxValue / ratios[maxIndex]) + (cArray.length - 1) * sashwidth;
+        } else {
+            width += (int)(total * maxValue / ratios[maxIndex]) + (cArray.length - 1) * sashwidth;
+        }
+    }
+    width += sashForm.getBorderWidth()*2;
+    height += sashForm.getBorderWidth()*2;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point(width, height);
+}
+
+protected bool flushCache(Control control) {
+    return true;
+}
+
+protected void layout(Composite composite, bool flushCache) {
+    SashForm sashForm = (SashForm)composite;
+    Rectangle area = sashForm.getClientArea();
+    if (area.width <= 1 || area.height <= 1) return;
+    
+    Control[] newControls = sashForm.getControls(true);
+    if (sashForm.controls.length is 0 && newControls.length is 0) return;
+    sashForm.controls = newControls;
+    
+    Control[] controls = sashForm.controls;
+    
+    if (sashForm.maxControl !is null && !sashForm.maxControl.isDisposed()) {
+        for (int i= 0; i < controls.length; i++){
+            if (controls[i] !is sashForm.maxControl) {
+                controls[i].setBounds(-200, -200, 0, 0);
+            } else {
+                controls[i].setBounds(area);
+            }
+        }
+        return;
+    }
+    
+    // keep just the right number of sashes
+    if (sashForm.sashes.length < controls.length - 1) {
+        Sash[] newSashes = new Sash[controls.length - 1];
+        System.arraycopy(sashForm.sashes, 0, newSashes, 0, sashForm.sashes.length);
+        for (int i = sashForm.sashes.length; i < newSashes.length; i++) {
+            newSashes[i] = new Sash(sashForm, sashForm.sashStyle);
+            newSashes[i].setBackground(sashForm.background);
+            newSashes[i].setForeground(sashForm.foreground);
+            newSashes[i].addListener(DWT.Selection, sashForm.sashListener);
+        }
+        sashForm.sashes = newSashes;
+    }
+    if (sashForm.sashes.length > controls.length - 1) {
+        if (controls.length is 0) {
+            for (int i = 0; i < sashForm.sashes.length; i++) {
+                sashForm.sashes[i].dispose();
+            }
+            sashForm.sashes = new Sash[0];
+        } else {
+            Sash[] newSashes = new Sash[controls.length - 1];
+            System.arraycopy(sashForm.sashes, 0, newSashes, 0, newSashes.length);
+            for (int i = controls.length - 1; i < sashForm.sashes.length; i++) {
+                sashForm.sashes[i].dispose();
+            }
+            sashForm.sashes = newSashes;
+        }
+    }
+    if (controls.length is 0) return;
+    Sash[] sashes = sashForm.sashes;
+    // get the ratios
+    long[] ratios = new long[controls.length];
+    long total = 0;
+    for (int i = 0; i < controls.length; i++) {
+        Object data = controls[i].getLayoutData();
+        if (data !is null && data instanceof SashFormData) {
+            ratios[i] = ((SashFormData)data).weight;
+        } else {
+            data = new SashFormData();
+            controls[i].setLayoutData(data);
+            ((SashFormData)data).weight = ratios[i] = ((200 << 16) + 999) / 1000;
+            
+        }
+        total += ratios[i];
+    }
+    
+    int sashwidth = sashes.length > 0 ? sashForm.SASH_WIDTH + sashes [0].getBorderWidth() * 2 : sashForm.SASH_WIDTH;
+    if (sashForm.getOrientation() is DWT.HORIZONTAL) {
+        int width = (int)(ratios[0] * (area.width - sashes.length * sashwidth) / total);
+        int x = area.x;
+        controls[0].setBounds(x, area.y, width, area.height);
+        x += width;
+        for (int i = 1; i < controls.length - 1; i++) {
+            sashes[i - 1].setBounds(x, area.y, sashwidth, area.height);
+            x += sashwidth;
+            width = (int)(ratios[i] * (area.width - sashes.length * sashwidth) / total);
+            controls[i].setBounds(x, area.y, width, area.height);
+            x += width;
+        }
+        if (controls.length > 1) {
+            sashes[sashes.length - 1].setBounds(x, area.y, sashwidth, area.height);
+            x += sashwidth;
+            width = area.width - x;
+            controls[controls.length - 1].setBounds(x, area.y, width, area.height);
+        }
+    } else {
+        int height = (int)(ratios[0] * (area.height - sashes.length * sashwidth) / total);
+        int y = area.y;
+        controls[0].setBounds(area.x, y, area.width, height);
+        y += height;
+        for (int i = 1; i < controls.length - 1; i++) {
+            sashes[i - 1].setBounds(area.x, y, area.width, sashwidth);
+            y += sashwidth;
+            height = (int)(ratios[i] * (area.height - sashes.length * sashwidth) / total);
+            controls[i].setBounds(area.x, y, area.width, height);
+            y += height;
+        }
+        if (controls.length > 1) {
+            sashes[sashes.length - 1].setBounds(area.x, y, area.width, sashwidth);
+            y += sashwidth;
+            height = area.height - y;
+            controls[controls.length - 1].setBounds(area.x, y, area.width, height);
+        }
+
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ScrolledComposite.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,689 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.events.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * A ScrolledComposite provides scrollbars and will scroll its content when the user
+ * uses the scrollbars.
+ *
+ *
+ * <p>There are two ways to use the ScrolledComposite:
+ * 
+ * <p>
+ * 1) Set the size of the control that is being scrolled and the ScrolledComposite 
+ * will show scrollbars when the contained control can not be fully seen.
+ * 
+ * 2) The second way imitates the way a browser would work.  Set the minimum size of
+ * the control and the ScrolledComposite will show scroll bars if the visible area is 
+ * less than the minimum size of the control and it will expand the size of the control 
+ * if the visible area is greater than the minimum size.  This requires invoking 
+ * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical().
+ * 
+ * <code><pre>
+ * public static void main (String [] args) {
+ *      Display display = new Display ();
+ *      Color red = display.getSystemColor(DWT.COLOR_RED);
+ *      Color blue = display.getSystemColor(DWT.COLOR_BLUE);
+ *      Shell shell = new Shell (display);
+ *      shell.setLayout(new FillLayout());
+ *  
+ *      // set the size of the scrolled content - method 1
+ *      final ScrolledComposite sc1 = new ScrolledComposite(shell, DWT.H_SCROLL | DWT.V_SCROLL | DWT.BORDER);
+ *      final Composite c1 = new Composite(sc1, DWT.NONE);
+ *      sc1.setContent(c1);
+ *      c1.setBackground(red);
+ *      GridLayout layout = new GridLayout();
+ *      layout.numColumns = 4;
+ *      c1.setLayout(layout);
+ *      Button b1 = new Button (c1, DWT.PUSH);
+ *      b1.setText("first button");
+ *      c1.setSize(c1.computeSize(DWT.DEFAULT, DWT.DEFAULT));
+ *      
+ *      // set the minimum width and height of the scrolled content - method 2
+ *      final ScrolledComposite sc2 = new ScrolledComposite(shell, DWT.H_SCROLL | DWT.V_SCROLL | DWT.BORDER);
+ *      sc2.setExpandHorizontal(true);
+ *      sc2.setExpandVertical(true);
+ *      final Composite c2 = new Composite(sc2, DWT.NONE);
+ *      sc2.setContent(c2);
+ *      c2.setBackground(blue);
+ *      layout = new GridLayout();
+ *      layout.numColumns = 4;
+ *      c2.setLayout(layout);
+ *      Button b2 = new Button (c2, DWT.PUSH);
+ *      b2.setText("first button");
+ *      sc2.setMinSize(c2.computeSize(DWT.DEFAULT, DWT.DEFAULT));
+ *      
+ *      Button add = new Button (shell, DWT.PUSH);
+ *      add.setText("add children");
+ *      final int[] index = new int[]{0};
+ *      add.addListener(DWT.Selection, new Listener() {
+ *          public void handleEvent(Event e) {
+ *              index[0]++;
+ *              Button button = new Button(c1, DWT.PUSH);
+ *              button.setText("button "+index[0]);
+ *              // reset size of content so children can be seen - method 1
+ *              c1.setSize(c1.computeSize(DWT.DEFAULT, DWT.DEFAULT));
+ *              c1.layout();
+ *              
+ *              button = new Button(c2, DWT.PUSH);
+ *              button.setText("button "+index[0]);
+ *              // reset the minimum width and height so children can be seen - method 2
+ *              sc2.setMinSize(c2.computeSize(DWT.DEFAULT, DWT.DEFAULT));
+ *              c2.layout();
+ *          }
+ *      });
+ * 
+ *      shell.open ();
+ *      while (!shell.isDisposed ()) {
+ *          if (!display.readAndDispatch ()) display.sleep ();
+ *      }
+ *      display.dispose ();
+ * }
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL
+ * </dl>
+ */
+public class ScrolledComposite : Composite {
+
+    Control content;
+    Listener contentListener;
+    Listener filter;
+    
+    int minHeight = 0;
+    int minWidth = 0;
+    bool expandHorizontal = false;
+    bool expandVertical = false;
+    bool alwaysShowScroll = false;
+    bool showFocusedControl = false;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT#H_SCROLL
+ * @see DWT#V_SCROLL
+ * @see #getStyle()
+ */ 
+public ScrolledComposite(Composite parent, int style) {
+    super(parent, checkStyle(style));
+    super.setLayout(new ScrolledCompositeLayout());
+    ScrollBar hBar = getHorizontalBar ();
+    if (hBar !is null) {
+        hBar.setVisible(false);
+        hBar.addListener (DWT.Selection, new Listener () {
+            public void handleEvent (Event e) {
+                hScroll();
+            }
+        });
+    }
+    
+    ScrollBar vBar = getVerticalBar ();
+    if (vBar !is null) {
+        vBar.setVisible(false);
+        vBar.addListener (DWT.Selection, new Listener () {
+            public void handleEvent (Event e) {
+                vScroll();
+            }
+        });
+    }
+    
+    contentListener = new Listener() {
+        public void handleEvent(Event e) {
+            if (e.type !is DWT.Resize) return;
+            layout(false);
+        }
+    };
+    
+    filter = new Listener() {
+        public void handleEvent(Event event) {
+            if (event.widget instanceof Control) {
+                Control control = (Control) event.widget;
+                if (contains(control)) showControl(control);
+            }
+        }
+    };
+    
+    addDisposeListener(new DisposeListener() {
+        public void widgetDisposed(DisposeEvent e) {
+            getDisplay().removeFilter(DWT.FocusIn, filter);
+        }
+    });
+}
+
+static int checkStyle (int style) {
+    int mask = DWT.H_SCROLL | DWT.V_SCROLL | DWT.BORDER | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+    return style & mask;
+}
+
+bool contains(Control control) {
+    if (control is null || control.isDisposed()) return false;
+
+    Composite parent = control.getParent();
+    while (parent !is null && !(parent instanceof Shell)) {
+        if (this is parent) return true;
+        parent = parent.getParent();
+    }
+    return false;
+}
+
+/**
+ * Returns the Always Show Scrollbars flag.  True if the scrollbars are 
+ * always shown even if they are not required.  False if the scrollbars are only 
+ * visible when some part of the composite needs to be scrolled to be seen.
+ * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the 
+ * horizontal and vertical directions.
+ * 
+ * @return the Always Show Scrollbars flag value
+ */
+public bool getAlwaysShowScrollBars() {
+    //checkWidget();
+    return alwaysShowScroll;
+}
+
+/**
+ * Returns <code>true</code> if the content control 
+ * will be expanded to fill available horizontal space.
+ *
+ * @return the receiver's horizontal expansion state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public bool getExpandHorizontal() {
+    checkWidget();
+    return expandHorizontal;
+}
+
+/**
+ * Returns <code>true</code> if the content control 
+ * will be expanded to fill available vertical space.
+ *
+ * @return the receiver's vertical expansion state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public bool getExpandVertical() {
+    checkWidget();
+    return expandVertical;
+}
+
+/**
+ * Returns the minimum width of the content control.
+ *
+ * @return the minimum width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public int getMinWidth() {
+    checkWidget();
+    return minWidth;
+}
+
+/**
+ * Returns the minimum height of the content control.
+ *
+ * @return the minimum height
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public int getMinHeight() {
+    checkWidget();
+    return minHeight;
+}
+
+/**
+ * Get the content that is being scrolled.
+ * 
+ * @return the control displayed in the content area
+ */
+public Control getContent() {
+    //checkWidget();
+    return content;
+}
+
+/**
+ * Returns <code>true</code> if the receiver automatically scrolls to a focused child control 
+ * to make it visible. Otherwise, returns <code>false</code>.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public bool getShowFocusedControl() {
+    checkWidget();
+    return showFocusedControl;
+}
+
+void hScroll() {
+    if (content is null) return;
+    Point location = content.getLocation ();
+    ScrollBar hBar = getHorizontalBar ();
+    int hSelection = hBar.getSelection ();
+    content.setLocation (-hSelection, location.y);
+}
+bool needHScroll(Rectangle contentRect, bool vVisible) {
+    ScrollBar hBar = getHorizontalBar();
+    if (hBar is null) return false;
+    
+    Rectangle hostRect = getBounds();
+    int border = getBorderWidth();
+    hostRect.width -= 2*border;
+    ScrollBar vBar = getVerticalBar();
+    if (vVisible && vBar !is null) hostRect.width -= vBar.getSize().x;
+    
+    if (!expandHorizontal && contentRect.width > hostRect.width) return true;
+    if (expandHorizontal && minWidth > hostRect.width) return true;
+    return false;
+}
+
+bool needVScroll(Rectangle contentRect, bool hVisible) {
+    ScrollBar vBar = getVerticalBar();
+    if (vBar is null) return false;
+    
+    Rectangle hostRect = getBounds();
+    int border = getBorderWidth();
+    hostRect.height -= 2*border;
+    ScrollBar hBar = getHorizontalBar();
+    if (hVisible && hBar !is null) hostRect.height -= hBar.getSize().y;
+    
+    if (!expandVertical && contentRect.height > hostRect.height) return true;
+    if (expandVertical && minHeight > hostRect.height) return true;
+    return false;
+}
+
+/**
+ * Return the point in the content that currently appears in the top left 
+ * corner of the scrolled composite.
+ * 
+ * @return the point in the content that currently appears in the top left 
+ * corner of the scrolled composite.  If no content has been set, this returns
+ * (0, 0).
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Point getOrigin() {
+    checkWidget();
+    if (content is null) return new Point(0, 0);
+    Point location = content.getLocation();
+    return new Point(-location.x, -location.y);
+}
+/**
+ * Scrolls the content so that the specified point in the content is in the top 
+ * left corner.  If no content has been set, nothing will occur.  
+ * 
+ * Negative values will be ignored.  Values greater than the maximum scroll 
+ * distance will result in scrolling to the end of the scrollbar.
+ *
+ * @param origin the point on the content to appear in the top left corner 
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - value of origin is outside of content
+ * </ul>
+ * @since 2.0
+ */
+public void setOrigin(Point origin) {
+    setOrigin(origin.x, origin.y);
+}
+/**
+ * Scrolls the content so that the specified point in the content is in the top 
+ * left corner.  If no content has been set, nothing will occur.  
+ * 
+ * Negative values will be ignored.  Values greater than the maximum scroll 
+ * distance will result in scrolling to the end of the scrollbar.
+ *
+ * @param x the x coordinate of the content to appear in the top left corner 
+ * 
+ * @param y the y coordinate of the content to appear in the top left corner 
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setOrigin(int x, int y) {
+    checkWidget();
+    if (content is null) return;
+    ScrollBar hBar = getHorizontalBar ();
+    if (hBar !is null) {
+        hBar.setSelection(x);
+        x = -hBar.getSelection ();
+    } else {
+        x = 0;
+    }
+    ScrollBar vBar = getVerticalBar ();
+    if (vBar !is null) {
+        vBar.setSelection(y);
+        y = -vBar.getSelection ();
+    } else {
+        y = 0;
+    }
+    content.setLocation(x, y);
+}
+/**
+ * Set the Always Show Scrollbars flag.  True if the scrollbars are 
+ * always shown even if they are not required.  False if the scrollbars are only 
+ * visible when some part of the composite needs to be scrolled to be seen.
+ * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the 
+ * horizontal and vertical directions.
+ * 
+ * @param show true to show the scrollbars even when not required, false to show scrollbars only when required
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlwaysShowScrollBars(bool show) {
+    checkWidget();
+    if (show is alwaysShowScroll) return;
+    alwaysShowScroll = show;
+    ScrollBar hBar = getHorizontalBar ();
+    if (hBar !is null && alwaysShowScroll) hBar.setVisible(true);
+    ScrollBar vBar = getVerticalBar ();
+    if (vBar !is null && alwaysShowScroll) vBar.setVisible(true);
+    layout(false);
+}
+
+/**
+ * Set the content that will be scrolled.
+ * 
+ * @param content the control to be displayed in the content area
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setContent(Control content) {
+    checkWidget();
+    if (this.content !is null && !this.content.isDisposed()) {
+        this.content.removeListener(DWT.Resize, contentListener);
+        this.content.setBounds(new Rectangle(-200, -200, 0, 0));    
+    }
+    
+    this.content = content;
+    ScrollBar vBar = getVerticalBar ();
+    ScrollBar hBar = getHorizontalBar ();
+    if (this.content !is null) {
+        if (vBar !is null) {
+            vBar.setMaximum (0);
+            vBar.setThumb (0);
+            vBar.setSelection(0);
+        }
+        if (hBar !is null) {
+            hBar.setMaximum (0);
+            hBar.setThumb (0);
+            hBar.setSelection(0);
+        }
+        content.setLocation(0, 0);
+        layout(false);
+        this.content.addListener(DWT.Resize, contentListener);
+    } else {
+        if (hBar !is null) hBar.setVisible(alwaysShowScroll);
+        if (vBar !is null) vBar.setVisible(alwaysShowScroll);
+    }
+}
+/**
+ * Configure the ScrolledComposite to resize the content object to be as wide as the 
+ * ScrolledComposite when the width of the ScrolledComposite is greater than the
+ * minimum width specified in setMinWidth.  If the ScrolledComposite is less than the
+ * minimum width, the content will not be resized and instead the horizontal scroll bar will be
+ * used to view the entire width.
+ * If expand is false, this behaviour is turned off.  By default, this behaviour is turned off.
+ * 
+ * @param expand true to expand the content control to fill available horizontal space
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpandHorizontal(bool expand) {
+    checkWidget();
+    if (expand is expandHorizontal) return;
+    expandHorizontal = expand;
+    layout(false);
+}
+/**
+ * Configure the ScrolledComposite to resize the content object to be as tall as the 
+ * ScrolledComposite when the height of the ScrolledComposite is greater than the
+ * minimum height specified in setMinHeight.  If the ScrolledComposite is less than the
+ * minimum height, the content will not be resized and instead the vertical scroll bar will be
+ * used to view the entire height.
+ * If expand is false, this behaviour is turned off.  By default, this behaviour is turned off.
+ * 
+ * @param expand true to expand the content control to fill available vertical space
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpandVertical(bool expand) {
+    checkWidget();
+    if (expand is expandVertical) return;
+    expandVertical = expand;
+    layout(false);
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+    checkWidget();
+    return;
+}
+/**
+ * Specify the minimum height at which the ScrolledComposite will begin scrolling the
+ * content with the vertical scroll bar.  This value is only relevant if  
+ * setExpandVertical(true) has been set.
+ * 
+ * @param height the minimum height or 0 for default height
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinHeight(int height) {
+    setMinSize(minWidth, height);
+}
+/**
+ * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar.  This value is only relevant if  
+ * setExpandHorizontal(true) and setExpandVertical(true) have been set.
+ * 
+ * @param size the minimum size or null for the default size
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinSize(Point size) {
+    if (size is null) {
+        setMinSize(0, 0);
+    } else {
+        setMinSize(size.x, size.y);
+    }
+}
+/**
+ * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar.  This value is only relevant if  
+ * setExpandHorizontal(true) and setExpandVertical(true) have been set.
+ * 
+ * @param width the minimum width or 0 for default width
+ * @param height the minimum height or 0 for default height
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinSize(int width, int height) {
+    checkWidget();
+    if (width is minWidth && height is minHeight) return;
+    minWidth = Math.max(0, width);
+    minHeight = Math.max(0, height);
+    layout(false);
+}
+/**
+ * Specify the minimum width at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar.  This value is only relevant if  
+ * setExpandHorizontal(true) has been set.
+ * 
+ * @param width the minimum width or 0 for default width
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinWidth(int width) {
+    setMinSize(width, minHeight);
+}
+
+/**
+ * Configure the receiver to automatically scroll to a focused child control
+ * to make it visible.
+ * 
+ * If show is <code>false</code>, show a focused control is off.  
+ * By default, show a focused control is off.
+ * 
+ * @param show <code>true</code> to show a focused control.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ *  @since 3.4
+ */
+public void setShowFocusedControl(bool show) {
+    checkWidget();
+    if (showFocusedControl is show) return;
+    Display display = getDisplay();
+    display.removeFilter(DWT.FocusIn, filter);
+    showFocusedControl = show;
+    if (!showFocusedControl) return;
+    display.addFilter(DWT.FocusIn, filter);
+    Control control = display.getFocusControl();
+    if (contains(control)) showControl(control);
+}
+
+/**
+ * Scrolls the content of the receiver so that the control is visible.
+ *
+ * @param control the control to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the control is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void showControl(Control control) {
+    checkWidget ();
+    if (control is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (control.isDisposed ()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (!contains(control)) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    
+    Rectangle itemRect = getDisplay().map(control.getParent(), this, control.getBounds());
+    Rectangle area = getClientArea();
+    Point origin = getOrigin();
+    if (itemRect.x < 0) origin.x = Math.max(0, origin.x + itemRect.x);
+    if (itemRect.y < 0) origin.y = Math.max(0, origin.y + itemRect.y);
+    if (area.width < itemRect.x + itemRect.width) origin.x = Math.max(0, origin.x + itemRect.x + itemRect.width - area.width);
+    if (area.height < itemRect.y + itemRect.height) origin.y = Math.max(0, origin.y + itemRect.y + itemRect.height - area.height);
+    setOrigin(origin);
+}
+
+void vScroll() {
+    if (content is null) return;
+    Point location = content.getLocation ();
+    ScrollBar vBar = getVerticalBar ();
+    int vSelection = vBar.getSelection ();
+    content.setLocation (location.x, -vSelection);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ScrolledCompositeLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * This class provides the layout for ScrolledComposite
+ * 
+ * @see ScrolledComposite
+ */
+class ScrolledCompositeLayout : Layout {
+    
+    bool inLayout = false;
+    static final int DEFAULT_WIDTH  = 64;
+    static final int DEFAULT_HEIGHT = 64;
+    
+protected Point computeSize(Composite composite, int wHint, int hHint, bool flushCache) {
+    ScrolledComposite sc = (ScrolledComposite)composite;
+    Point size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+    if (sc.content !is null) {
+        Point preferredSize = sc.content.computeSize(wHint, hHint, flushCache);
+        Point currentSize = sc.content.getSize();
+        size.x = sc.getExpandHorizontal() ? preferredSize.x : currentSize.x;
+        size.y = sc.getExpandVertical() ? preferredSize.y : currentSize.y;
+    }
+    size.x = Math.max(size.x, sc.minWidth);
+    size.y = Math.max(size.y, sc.minHeight);
+    if (wHint !is DWT.DEFAULT) size.x = wHint;
+    if (hHint !is DWT.DEFAULT) size.y = hHint;
+    return size;
+}
+
+protected bool flushCache(Control control) {
+    return true;
+}
+
+protected void layout(Composite composite, bool flushCache) {
+    if (inLayout) return;
+    ScrolledComposite sc = (ScrolledComposite)composite;
+    if (sc.content is null) return;
+    ScrollBar hBar = sc.getHorizontalBar();
+    ScrollBar vBar = sc.getVerticalBar();
+    if (hBar !is null) {
+        if (hBar.getSize().y >= sc.getSize().y) {
+            return;
+        }
+    }
+    if (vBar !is null) {
+        if (vBar.getSize().x >= sc.getSize().x) {
+            return;
+        }
+    }
+    inLayout = true;
+    Rectangle contentRect = sc.content.getBounds();
+    if (!sc.alwaysShowScroll) {
+        bool hVisible = sc.needHScroll(contentRect, false);
+        bool vVisible = sc.needVScroll(contentRect, hVisible);
+        if (!hVisible && vVisible) hVisible = sc.needHScroll(contentRect, vVisible);
+        if (hBar !is null) hBar.setVisible(hVisible);
+        if (vBar !is null) vBar.setVisible(vVisible);
+    }
+    Rectangle hostRect = sc.getClientArea();
+    if (sc.expandHorizontal) {
+        contentRect.width = Math.max(sc.minWidth, hostRect.width);  
+    }
+    if (sc.expandVertical) {
+        contentRect.height = Math.max(sc.minHeight, hostRect.height);
+    }
+
+    if (hBar !is null) {
+        hBar.setMaximum (contentRect.width);
+        hBar.setThumb (Math.min (contentRect.width, hostRect.width));
+        int hPage = contentRect.width - hostRect.width;
+        int hSelection = hBar.getSelection ();
+        if (hSelection >= hPage) {
+            if (hPage <= 0) {
+                hSelection = 0;
+                hBar.setSelection(0);
+            }
+            contentRect.x = -hSelection;
+        }
+    }
+
+    if (vBar !is null) {
+        vBar.setMaximum (contentRect.height);
+        vBar.setThumb (Math.min (contentRect.height, hostRect.height));
+        int vPage = contentRect.height - hostRect.height;
+        int vSelection = vBar.getSelection ();
+        if (vSelection >= vPage) {
+            if (vPage <= 0) {
+                vSelection = 0;
+                vBar.setSelection(0);
+            }
+            contentRect.y = -vSelection;
+        }
+    }
+    
+    sc.content.setBounds (contentRect);
+    inLayout = false;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StackLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * This Layout stacks all the controls one on top of the other and resizes all controls
+ * to have the same size and location.
+ * The control specified in topControl is visible and all other controls are not visible.
+ * Users must set the topControl value to flip between the visible items and then call 
+ * layout() on the composite which has the StackLayout.
+ * 
+ * <p> Here is an example which places ten buttons in a stack layout and 
+ * flips between them:
+ * 
+ * <pre><code>
+ *  public static void main(String[] args) {
+ *      Display display = new Display();
+ *      Shell shell = new Shell(display);
+ *      shell.setLayout(new GridLayout());
+ *  
+ *      final Composite parent = new Composite(shell, DWT.NONE);
+ *      parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ *      final StackLayout layout = new StackLayout();
+ *      parent.setLayout(layout);
+ *      final Button[] bArray = new Button[10];
+ *      for (int i = 0; i &lt; 10; i++) {
+ *          bArray[i] = new Button(parent, DWT.PUSH);
+ *          bArray[i].setText("Button "+i);
+ *      }
+ *      layout.topControl = bArray[0];
+ *  
+ *      Button b = new Button(shell, DWT.PUSH);
+ *      b.setText("Show Next Button");
+ *      final int[] index = new int[1];
+ *      b.addListener(DWT.Selection, new Listener(){
+ *          public void handleEvent(Event e) {
+ *              index[0] = (index[0] + 1) % 10;
+ *              layout.topControl = bArray[index[0]];
+ *              parent.layout();
+ *          }
+ *      });
+ *  
+ *      shell.open();
+ *      while (shell !is null && !shell.isDisposed()) {
+ *          if (!display.readAndDispatch())
+ *              display.sleep(); 
+ *      }   
+ *  }
+ * </code></pre>
+ */
+
+public class StackLayout : 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;
+
+    /**
+     * topControl the Control that is displayed at the top of the stack.
+     * All other controls that are children of the parent composite will not be visible.
+     */
+    public Control topControl;
+
+protected Point computeSize(Composite composite, int wHint, int hHint, bool flushCache) {
+    Control children[] = composite.getChildren();
+    int maxWidth = 0;
+    int maxHeight = 0;
+    for (int i = 0; i < children.length; i++) {
+        Point size = children[i].computeSize(wHint, hHint, flushCache);
+        maxWidth = Math.max(size.x, maxWidth);
+        maxHeight = Math.max(size.y, maxHeight);
+    }
+    int width = maxWidth + 2 * marginWidth;
+    int height = maxHeight + 2 * marginHeight;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point(width, height);
+}
+
+protected bool flushCache(Control control) {
+    return true;
+}
+
+protected void layout(Composite composite, bool flushCache) {
+    Control children[] = composite.getChildren();
+    Rectangle rect = composite.getClientArea();
+    rect.x += marginWidth;
+    rect.y += marginHeight;
+    rect.width -= 2 * marginWidth;
+    rect.height -= 2 * marginHeight;
+    for (int i = 0; i < children.length; i++) {
+        children[i].setBounds(rect);
+        children[i].setVisible(children[i] is topControl);
+            
+    }
+}
+
+String getName () {
+    String String = getClass ().getName ();
+    int index = String.lastIndexOf ('.');
+    if (index is -1) return String;
+    return String.substring (index + 1, String.length ());
+}
+
+/**
+ * Returns a String containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a String representation of the layout
+ */
+public String toString () {
+    String String = getName ()+" {";
+    if (marginWidth !is 0) String += "marginWidth="+marginWidth+" ";
+    if (marginHeight !is 0) String += "marginHeight="+marginHeight+" ";
+    if (topControl !is null) String += "topControl="+topControl+" ";
+    String = String.trim();
+    String += "}";
+    return String;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyleRange.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.internal.CloneableCompatibility;
+
+public class StyleRange : TextStyle : CloneableCompatibility {
+    
+    /**
+     * the start offset of the range, zero-based from the document start
+     */
+    public int start;
+    
+    /**
+     * the length of the range
+     */
+    public int length;
+
+    /**
+     * the font style of the range. It may be a combination of
+     * DWT.NORMAL, DWT.ITALIC or DWT.BOLD
+     * 
+     * Note: the font style is not used if the <code>font</code> attribute
+     * is set
+     */
+    public int fontStyle = DWT.NORMAL;
+    
+/**
+ * Create a new style range with no styles
+ * 
+ * @since 3.2
+ */
+public StyleRange() {
+}
+
+/** 
+ * Create a new style range from an existing text style.
+ *
+ *@param style the text style to copy
+ *
+ *@since 3.4
+ */
+public StyleRange(TextStyle style) {
+    super(style);
+}
+
+/** 
+ * Create a new style range.
+ *
+ * @param start start offset of the style
+ * @param length length of the style 
+ * @param foreground foreground color of the style, null if none 
+ * @param background background color of the style, null if none
+ */
+public StyleRange(int start, int length, Color foreground, Color background) {
+    super(null, foreground, background);
+    this.start = start;
+    this.length = length;
+}
+
+/** 
+ * Create a new style range.
+ *
+ * @param start start offset of the style
+ * @param length length of the style 
+ * @param foreground foreground color of the style, null if none 
+ * @param background background color of the style, null if none
+ * @param fontStyle font style of the style, may be DWT.NORMAL, DWT.ITALIC or DWT.BOLD
+ */
+public StyleRange(int start, int length, Color foreground, Color background, int fontStyle) {
+    this(start, length, foreground, background);
+    this.fontStyle = fontStyle;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #toHash()
+ */
+public bool opEquals(Object object) {
+    if (object is this) return true;
+    if (object instanceof StyleRange) {
+        StyleRange style = (StyleRange)object;
+        if (start !is style.start) return false;
+        if (length !is style.length) return false;
+        return similarTo(style);
+    }
+    return false;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>opEquals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #opEquals(Object)
+ */
+public int toHash() {
+    return super.toHash() ^ fontStyle;
+}
+bool isVariableHeight() {
+    return font !is null || metrics !is null || rise !is 0;
+}
+/**
+ * Returns whether or not the receiver is unstyled (i.e., does not have any 
+ * style attributes specified).
+ *
+ * @return true if the receiver is unstyled, false otherwise.
+ */
+public bool isUnstyled() {
+    if (font !is null) return false;
+    if (rise !is 0) return false;
+    if (metrics !is null) return false;
+    if (foreground !is null) return false;
+    if (background !is null) return false;
+    if (fontStyle !is DWT.NORMAL) return false;
+    if (underline) return false;
+    if (strikeout) return false;
+    if (borderStyle !is DWT.NONE) return false;
+    return true;
+}
+
+/**
+ * Compares the specified object to this StyleRange and answer if the two 
+ * are similar. The object must be an instance of StyleRange and have the
+ * same field values for except for start and length.
+ *
+ * @param style the object to compare with this object
+ * @return true if the objects are similar, false otherwise
+ */
+public bool similarTo(StyleRange style) {
+    if (!super.opEquals(style)) return false;
+    if (fontStyle !is style.fontStyle) return false;
+    return true;
+}
+
+/**
+ * Returns a new StyleRange with the same values as this StyleRange.
+ *
+ * @return a shallow copy of this StyleRange
+ */ 
+public Object clone() {
+    try {
+        return super.clone();
+    } catch (CloneNotSupportedException e) {
+        return null;
+    }
+}
+
+/**
+ * Returns a String containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a String representation of the StyleRange
+ */
+public String toString() {
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("StyleRange {");
+    buffer.append(start);
+    buffer.append(", ");
+    buffer.append(length);
+    buffer.append(", fontStyle=");
+    switch (fontStyle) {
+        case DWT.BOLD:
+            buffer.append("bold");
+            break;
+        case DWT.ITALIC:
+            buffer.append("italic");
+            break;
+        case DWT.BOLD | DWT.ITALIC:
+            buffer.append("bold-italic");
+            break;
+        default:
+            buffer.append("normal");
+    }
+    String str = super.toString();
+    int index = str.indexOf('{');
+    str = str.substring(index + 1);
+    if (str.length() > 1) buffer.append(", ");
+    buffer.append(str);
+    return buffer.toString();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyledText.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,8302 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import java.util.*;
+
+import dwt.*;
+import dwt.accessibility.*;
+import dwt.dnd.*;
+import dwt.events.*;
+import dwt.graphics.*;
+import dwt.internal.*;
+import dwt.printing.*;
+import dwt.widgets.*;
+
+/**
+ * A StyledText is an editable user interface object that displays lines 
+ * of text.  The following style attributes can be defined for the text: 
+ * <ul>
+ * <li>foreground color 
+ * <li>background color
+ * <li>font style (bold, italic, bold-italic, regular)
+ * <li>underline
+ * <li>strikeout
+ * </ul>
+ * <p>
+ * In addition to text style attributes, the background color of a line may 
+ * be specified.
+ * </p><p>
+ * There are two ways to use this widget when specifying text style information.  
+ * You may use the API that is defined for StyledText or you may define your own 
+ * LineStyleListener.  If you define your own listener, you will be responsible 
+ * for maintaining the text style information for the widget.  IMPORTANT: You may 
+ * not define your own listener and use the StyledText API.  The following
+ * StyledText API is not supported if you have defined a LineStyleListener:
+ * <ul>
+ * <li>getStyleRangeAtOffset(int)
+ * <li>getStyleRanges()
+ * <li>replaceStyleRanges(int,int,StyleRange[])
+ * <li>setStyleRange(StyleRange)
+ * <li>setStyleRanges(StyleRange[])
+ * </ul>
+ * </p><p>
+ * There are two ways to use this widget when specifying line background colors.
+ * You may use the API that is defined for StyledText or you may define your own 
+ * LineBackgroundListener.  If you define your own listener, you will be responsible 
+ * for maintaining the line background color information for the widget.  
+ * IMPORTANT: You may not define your own listener and use the StyledText API.  
+ * The following StyledText API is not supported if you have defined a 
+ * LineBackgroundListener:
+ * <ul>
+ * <li>getLineBackground(int)
+ * <li>setLineBackground(int,int,Color)
+ * </ul>
+ * </p><p>
+ * The content implementation for this widget may also be user-defined.  To do so,
+ * you must implement the StyledTextContent interface and use the StyledText API
+ * setContent(StyledTextContent) to initialize the widget. 
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b><dd>FULL_SELECTION, MULTI, READ_ONLY, SINGLE, WRAP
+ * <dt><b>Events:</b><dd>ExtendedModify, LineGetBackground, LineGetSegments, LineGetStyle, Modify, Selection, Verify, VerifyKey
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class StyledText : Canvas {
+    static final char TAB = '\t';
+    static final String PlatformLineDelimiter = System.getProperty("line.separator");
+    static final int BIDI_CARET_WIDTH = 3;
+    static final int DEFAULT_WIDTH  = 64;
+    static final int DEFAULT_HEIGHT = 64;
+    static final int V_SCROLL_RATE = 50;
+    static final int H_SCROLL_RATE = 10;
+    
+    static final int ExtendedModify = 3000;
+    static final int LineGetBackground = 3001;
+    static final int LineGetStyle = 3002;
+    static final int TextChanging = 3003;
+    static final int TextSet = 3004;
+    static final int VerifyKey = 3005;
+    static final int TextChanged = 3006;
+    static final int LineGetSegments = 3007;
+    static final int PaintObject = 3008;
+    static final int WordNext = 3009;
+    static final int WordPrevious = 3010;
+    
+    static final int PREVIOUS_OFFSET_TRAILING = 0;
+    static final int OFFSET_LEADING = 1;
+    
+    Color selectionBackground;  // selection background color
+    Color selectionForeground;  // selection foreground color
+    StyledTextContent content;          // native content (default or user specified)
+    StyledTextRenderer renderer;
+    Listener listener;
+    TextChangeListener textChangeListener;  // listener for TextChanging, TextChanged and TextSet events from StyledTextContent
+    int verticalScrollOffset = 0;       // pixel based
+    int horizontalScrollOffset = 0;     // pixel based
+    int topIndex = 0;                   // top visible line
+    int topIndexY;
+    int clientAreaHeight = 0;           // the client area height. Needed to calculate content width for new visible lines during Resize callback
+    int clientAreaWidth = 0;            // the client area width. Needed during Resize callback to determine if line wrap needs to be recalculated
+    int tabLength = 4;                  // number of characters in a tab
+    int leftMargin;
+    int topMargin;
+    int rightMargin;
+    int bottomMargin;
+    int columnX;                        // keep track of the horizontal caret position when changing lines/pages. Fixes bug 5935
+    int caretOffset = 0;
+    int caretAlignment;
+    Point selection = new Point(0, 0);  // x and y are start and end caret offsets of selection
+    Point clipboardSelection;           // x and y are start and end caret offsets of previous selection
+    int selectionAnchor;                // position of selection anchor. 0 based offset from beginning of text
+    Point doubleClickSelection;         // selection after last mouse double click
+    bool editable = true;
+    bool wordWrap = false;
+    bool doubleClickEnabled = true; // see getDoubleClickEnabled 
+    bool overwrite = false;         // insert/overwrite edit mode
+    int textLimit = -1;                 // limits the number of characters the user can type in the widget. Unlimited by default.
+    Hashtable keyActionMap = new Hashtable();
+    Color background = null;            // workaround for bug 4791
+    Color foreground = null;            //
+    Clipboard clipboard;
+    int clickCount;
+    int autoScrollDirection = DWT.NULL; // the direction of autoscrolling (up, down, right, left)
+    int autoScrollDistance = 0;
+    int lastTextChangeStart;            // cache data of the 
+    int lastTextChangeNewLineCount;     // last text changing 
+    int lastTextChangeNewCharCount;     // event for use in the 
+    int lastTextChangeReplaceLineCount; // text changed handler
+    int lastTextChangeReplaceCharCount;
+    int lastLineBottom;                 // the bottom pixel of the last line been replaced
+    bool isMirrored;
+    bool bidiColoring = false;      // apply the BIDI algorithm on text segments of the same color
+    Image leftCaretBitmap = null;
+    Image rightCaretBitmap = null;
+    int caretDirection = DWT.NULL;
+    int caretWidth = 0;
+    Caret defaultCaret = null;
+    bool updateCaretDirection = true;
+    bool fixedLineHeight;
+    bool dragDetect = true;
+    IME ime;
+    
+    int alignment;
+    bool justify;
+    int indent;
+    int lineSpacing;
+
+    final static bool IS_CARBON, IS_GTK, IS_MOTIF;
+    static {
+        String platform = DWT.getPlatform();
+        IS_CARBON = "carbon".opEquals(platform);
+        IS_GTK = "gtk".opEquals(platform);
+        IS_MOTIF = "motif".opEquals(platform);
+    }
+
+    /**
+     * The Printing class : printing of a range of text.
+     * An instance of <code>Printing</code> is returned in the 
+     * StyledText#print(Printer) API. The run() method may be 
+     * invoked from any thread.
+     */
+    static class Printing : Runnable {
+        final static int LEFT = 0;                      // left aligned header/footer segment
+        final static int CENTER = 1;                    // centered header/footer segment
+        final static int RIGHT = 2;                     // right aligned header/footer segment
+
+        Printer printer;
+        StyledTextRenderer printerRenderer;
+        StyledTextPrintOptions printOptions;
+        Rectangle clientArea;
+        FontData fontData;
+        Font printerFont;
+        Hashtable resources;
+        int tabLength;
+        GC gc;                                          // printer GC
+        int pageWidth;                                  // width of a printer page in pixels
+        int startPage;                                  // first page to print
+        int endPage;                                    // last page to print
+        int startLine;                                  // first (wrapped) line to print
+        int endLine;                                    // last (wrapped) line to print
+        bool singleLine;                                // widget single line mode
+        Point selection = null;                 // selected text
+        bool mirrored;                      // indicates the printing gc should be mirrored
+        int lineSpacing;
+        int printMargin;
+
+    /**
+     * Creates an instance of <code>Printing</code>.
+     * Copies the widget content and rendering data that needs 
+     * to be requested from listeners.
+     * </p>
+     * @param parent StyledText widget to print.
+     * @param printer printer device to print on.
+     * @param printOptions print options
+     */     
+    Printing(StyledText styledText, Printer printer, StyledTextPrintOptions printOptions) {
+        this.printer = printer;
+        this.printOptions = printOptions;
+        this.mirrored = (styledText.getStyle() & DWT.MIRRORED) !is 0;
+        singleLine = styledText.isSingleLine();
+        startPage = 1;
+        endPage = Integer.MAX_VALUE;
+        PrinterData data = printer.getPrinterData();
+        if (data.scope is PrinterData.PAGE_RANGE) {
+            startPage = data.startPage;
+            endPage = data.endPage;
+            if (endPage < startPage) {
+                int temp = endPage;
+                endPage = startPage;
+                startPage = temp;
+            }
+        } else if (data.scope is PrinterData.SELECTION) {
+            selection = styledText.getSelectionRange();
+        }
+        printerRenderer = new StyledTextRenderer(printer, null);
+        printerRenderer.setContent(copyContent(styledText.getContent()));
+        cacheLineData(styledText);
+    }
+    /**
+     * Caches all line data that needs to be requested from a listener.
+     * </p>
+     * @param printerContent <code>StyledTextContent</code> to request 
+     *  line data for.
+     */
+    void cacheLineData(StyledText styledText) {
+        StyledTextRenderer renderer = styledText.renderer;
+        renderer.copyInto(printerRenderer);
+        fontData = styledText.getFont().getFontData()[0];
+        tabLength = styledText.tabLength;
+        int lineCount = printerRenderer.lineCount;
+        if (styledText.isListening(LineGetBackground) || (styledText.isBidi() && styledText.isListening(LineGetSegments)) || styledText.isListening(LineGetStyle)) {
+            StyledTextContent content = printerRenderer.content;
+            for (int i = 0; i < lineCount; i++) {
+                String line = content.getLine(i);
+                int lineOffset = content.getOffsetAtLine(i);
+                StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);
+                if (event !is null && event.lineBackground !is null) {
+                    printerRenderer.setLineBackground(i, 1, event.lineBackground);
+                }
+                if (styledText.isBidi()) {
+                    int[] segments = styledText.getBidiSegments(lineOffset, line);
+                    printerRenderer.setLineSegments(i, 1, segments);
+                }           
+                event = styledText.getLineStyleData(lineOffset, line);
+                if (event !is null) {
+                    printerRenderer.setLineIndent(i, 1, event.indent);
+                    printerRenderer.setLineAlignment(i, 1, event.alignment);
+                    printerRenderer.setLineJustify(i, 1, event.justify);
+                    printerRenderer.setLineBullet(i, 1, event.bullet);
+                    StyleRange[] styles = event.styles;
+                    if (styles !is null && styles.length > 0) {
+                        printerRenderer.setStyleRanges(event.ranges, styles);
+                    }
+                }
+            }
+        }
+        Point screenDPI = styledText.getDisplay().getDPI();
+        Point printerDPI = printer.getDPI();
+        resources = new Hashtable ();
+        for (int i = 0; i < lineCount; i++) {
+            Color color = printerRenderer.getLineBackground(i, null);
+            if (color !is null) {
+                if (printOptions.printLineBackground) {
+                    Color printerColor = (Color)resources.get(color);
+                    if (printerColor is null) {
+                        printerColor = new Color (printer, color.getRGB());
+                        resources.put(color, printerColor); 
+                    }
+                    printerRenderer.setLineBackground(i, 1, printerColor);
+                } else {
+                    printerRenderer.setLineBackground(i, 1, null);
+                }
+            }
+            int indent = printerRenderer.getLineIndent(i, 0);
+            if (indent !is 0) {
+                printerRenderer.setLineIndent(i, 1, indent * printerDPI.x / screenDPI.x);
+            }
+        }
+        StyleRange[] styles = printerRenderer.styles;
+        for (int i = 0; i < printerRenderer.styleCount; i++) {
+            StyleRange style = styles[i];
+            Font font = style.font;
+            if (style.font !is null) {
+                Font printerFont = (Font)resources.get(font);
+                if (printerFont is null) {
+                    printerFont = new Font (printer, font.getFontData());
+                    resources.put(font, printerFont);                   
+                }
+                style.font = printerFont;
+            }
+            Color color = style.foreground;
+            if (color !is null) {
+                Color printerColor = (Color)resources.get(color);
+                if (printOptions.printTextForeground) {
+                    if (printerColor is null) {
+                        printerColor = new Color (printer, color.getRGB());
+                        resources.put(color, printerColor); 
+                    }
+                    style.foreground = printerColor;
+                } else {
+                    style.foreground = null;
+                }
+            }
+            color = style.background;
+            if (color !is null) {
+                Color printerColor = (Color)resources.get(color);
+                if (printOptions.printTextBackground) {
+                    if (printerColor is null) {
+                        printerColor = new Color (printer, color.getRGB());
+                        resources.put(color, printerColor); 
+                    }
+                    style.background = printerColor;
+                } else {
+                    style.background = null;
+                }
+            }
+            if (!printOptions.printTextFontStyle) {
+                style.fontStyle = DWT.NORMAL;
+            }
+            style.rise = style.rise * printerDPI.y / screenDPI.y;
+            GlyphMetrics metrics = style.metrics;
+            if (metrics !is null) {
+                metrics.ascent = metrics.ascent * printerDPI.y / screenDPI.y;
+                metrics.descent = metrics.descent * printerDPI.y / screenDPI.y;
+                metrics.width = metrics.width * printerDPI.x / screenDPI.x;
+            }
+        }
+        lineSpacing = styledText.lineSpacing * printerDPI.y / screenDPI.y;
+        if (printOptions.printLineNumbers) {
+            printMargin = 3 * printerDPI.x / screenDPI.x;
+        }
+    }
+    /**
+     * Copies the text of the specified <code>StyledTextContent</code>.
+     * </p>
+     * @param original the <code>StyledTextContent</code> to copy.
+     */
+    StyledTextContent copyContent(StyledTextContent original) {
+        StyledTextContent printerContent = new DefaultContent();
+        int insertOffset = 0;
+        for (int i = 0; i < original.getLineCount(); i++) {
+            int insertEndOffset;
+            if (i < original.getLineCount() - 1) {
+                insertEndOffset = original.getOffsetAtLine(i + 1);
+            } else {
+                insertEndOffset = original.getCharCount();
+            }
+            printerContent.replaceTextRange(insertOffset, 0, original.getTextRange(insertOffset, insertEndOffset - insertOffset));
+            insertOffset = insertEndOffset;
+        }
+        return printerContent;
+    }
+    /**
+     * Disposes of the resources and the <code>PrintRenderer</code>.
+     */
+    void dispose() {
+        if (gc !is null) {
+            gc.dispose();
+            gc = null;
+        }
+        if (resources !is null) {
+            Enumeration enumeration = resources.elements();         
+            while (enumeration.hasMoreElements()) {
+                Resource resource = (Resource) enumeration.nextElement();
+                resource.dispose();
+            }
+            resources = null;
+        }
+        if (printerFont !is null) {
+            printerFont.dispose();
+            printerFont = null;
+        }
+        if (printerRenderer !is null) {
+            printerRenderer.dispose();
+            printerRenderer = null;
+        }
+    }
+    void init() {
+        Rectangle trim = printer.computeTrim(0, 0, 0, 0);
+        Point dpi = printer.getDPI();
+        
+        printerFont = new Font(printer, fontData.getName(), fontData.getHeight(), DWT.NORMAL);
+        clientArea = printer.getClientArea();
+        pageWidth = clientArea.width;
+        // one inch margin around text
+        clientArea.x = dpi.x + trim.x;              
+        clientArea.y = dpi.y + trim.y;
+        clientArea.width -= (clientArea.x + trim.width);
+        clientArea.height -= (clientArea.y + trim.height); 
+
+        int style = mirrored ? DWT.RIGHT_TO_LEFT : DWT.LEFT_TO_RIGHT;
+        gc = new GC(printer, style);
+        gc.setFont(printerFont);
+        printerRenderer.setFont(printerFont, tabLength);
+        int lineHeight = printerRenderer.getLineHeight();
+        if (printOptions.header !is null) {
+            clientArea.y += lineHeight * 2;
+            clientArea.height -= lineHeight * 2;
+        }
+        if (printOptions.footer !is null) {
+            clientArea.height -= lineHeight * 2;
+        }
+        
+        // TODO not wrapped
+        StyledTextContent content = printerRenderer.content;
+        startLine = 0;
+        endLine = singleLine ? 0 : content.getLineCount() - 1;
+        PrinterData data = printer.getPrinterData();
+        if (data.scope is PrinterData.PAGE_RANGE) {
+            int pageSize = clientArea.height / lineHeight;//WRONG
+            startLine = (startPage - 1) * pageSize;
+        } else if (data.scope is PrinterData.SELECTION) {
+            startLine = content.getLineAtOffset(selection.x);
+            if (selection.y > 0) {
+                endLine = content.getLineAtOffset(selection.x + selection.y - 1);
+            } else {
+                endLine = startLine - 1;
+            }
+        }
+    }
+    /**
+     * Prints the lines in the specified page range.
+     */
+    void print() {
+        Color background = gc.getBackground();
+        Color foreground = gc.getForeground();
+        int paintY = clientArea.y;
+        int paintX = clientArea.x;
+        int width = clientArea.width;
+        int page = startPage;
+        int pageBottom = clientArea.y + clientArea.height;
+        int orientation =  gc.getStyle() & (DWT.RIGHT_TO_LEFT | DWT.LEFT_TO_RIGHT);
+        TextLayout printLayout = null;
+        if (printOptions.printLineNumbers || printOptions.header !is null || printOptions.footer !is null) {
+            printLayout = new TextLayout(printer);
+            printLayout.setFont(printerFont);
+        }
+        if (printOptions.printLineNumbers) {
+            int numberingWidth = 0;
+            int count = endLine - startLine + 1;
+            String[] lineLabels = printOptions.lineLabels;
+            if (lineLabels !is null) {
+                for (int i = startLine; i < Math.min(count, lineLabels.length); i++) {
+                    if (lineLabels[i] !is null) {
+                        printLayout.setText(lineLabels[i]);
+                        int lineWidth = printLayout.getBounds().width;
+                        numberingWidth = Math.max(numberingWidth, lineWidth);
+                    }
+                }
+            } else {
+                StringBuffer buffer = new StringBuffer("0");
+                while ((count /= 10) > 0) buffer.append("0");
+                printLayout.setText(buffer.toString());
+                numberingWidth = printLayout.getBounds().width;
+            }
+            numberingWidth += printMargin;
+            if (numberingWidth > width) numberingWidth = width;
+            paintX += numberingWidth;
+            width -= numberingWidth;
+        }
+        for (int i = startLine; i <= endLine && page <= endPage; i++) {
+            if (paintY is clientArea.y) {
+                printer.startPage();
+                printDecoration(page, true, printLayout);
+            }
+            TextLayout layout = printerRenderer.getTextLayout(i, orientation, width, lineSpacing);
+            Color lineBackground = printerRenderer.getLineBackground(i, background);
+            int paragraphBottom = paintY + layout.getBounds().height; 
+            if (paragraphBottom <= pageBottom) {
+                //normal case, the whole paragraph fits in the current page
+                printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+                paintY = paragraphBottom;
+            } else {
+                int lineCount = layout.getLineCount();
+                while (paragraphBottom > pageBottom && lineCount > 0) {
+                    lineCount--;
+                    paragraphBottom -= layout.getLineBounds(lineCount).height + layout.getSpacing();
+                }
+                if (lineCount is 0) {
+                    //the whole paragraph goes to the next page
+                    printDecoration(page, false, printLayout);
+                    printer.endPage();
+                    page++;
+                    if (page <= endPage) {
+                        printer.startPage();
+                        printDecoration(page, true, printLayout);
+                        paintY = clientArea.y;
+                        printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+                        paintY += layout.getBounds().height;
+                    }
+                } else {
+                    //draw paragraph top in the current page and paragraph bottom in the next
+                    int height = paragraphBottom - paintY;
+                    gc.setClipping(clientArea.x, paintY, clientArea.width, height);
+                    printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+                    gc.setClipping((Rectangle)null);
+                    printDecoration(page, false, printLayout);
+                    printer.endPage();                  
+                    page++;
+                    if (page <= endPage) {
+                        printer.startPage();
+                        printDecoration(page, true, printLayout);
+                        paintY = clientArea.y - height;
+                        int layoutHeight = layout.getBounds().height;
+                        gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height);
+                        printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+                        gc.setClipping((Rectangle)null);
+                        paintY += layoutHeight;
+                    }
+                }
+            }
+            printerRenderer.disposeTextLayout(layout);
+        }
+        if (page <= endPage && paintY > clientArea.y) {
+            // close partial page
+            printDecoration(page, false, printLayout);
+            printer.endPage();
+        }
+        if (printLayout !is null) printLayout.dispose();
+    }
+    /**
+     * Print header or footer decorations.
+     * 
+     * @param page page number to print, if specified in the StyledTextPrintOptions header or footer.
+     * @param header true = print the header, false = print the footer
+     */
+    void printDecoration(int page, bool header, TextLayout layout) {
+        String text = header ? printOptions.header : printOptions.footer;
+        if (text is null) return;
+        int lastSegmentIndex = 0;
+        for (int i = 0; i < 3; i++) {
+            int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex);
+            String segment;
+            if (segmentIndex is -1) {
+                segment = text.substring(lastSegmentIndex);
+                printDecorationSegment(segment, i, page, header, layout);
+                break;
+            } else {
+                segment = text.substring(lastSegmentIndex, segmentIndex);
+                printDecorationSegment(segment, i, page, header, layout);
+                lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length();
+            }
+        }
+    }
+    /**
+     * Print one segment of a header or footer decoration.
+     * Headers and footers have three different segments.
+     * One each for left aligned, centered, and right aligned text.
+     * 
+     * @param segment decoration segment to print
+     * @param alignment alignment of the segment. 0=left, 1=center, 2=right 
+     * @param page page number to print, if specified in the decoration segment.
+     * @param header true = print the header, false = print the footer
+     */
+    void printDecorationSegment(String segment, int alignment, int page, bool header, TextLayout layout) {      
+        int pageIndex = segment.indexOf(StyledTextPrintOptions.PAGE_TAG);
+        if (pageIndex !is -1) {
+            int pageTagLength = StyledTextPrintOptions.PAGE_TAG.length();
+            StringBuffer buffer = new StringBuffer(segment.substring (0, pageIndex));
+            buffer.append (page);
+            buffer.append (segment.substring(pageIndex + pageTagLength));
+            segment = buffer.toString();
+        }
+        if (segment.length() > 0) {
+            layout.setText(segment);
+            int segmentWidth = layout.getBounds().width;
+            int segmentHeight = printerRenderer.getLineHeight();
+            int drawX = 0, drawY;
+            if (alignment is LEFT) {
+                drawX = clientArea.x;
+            } else if (alignment is CENTER) {
+                drawX = (pageWidth - segmentWidth) / 2;
+            } else if (alignment is RIGHT) {
+                drawX = clientArea.x + clientArea.width - segmentWidth;
+            }
+            if (header) {
+                drawY = clientArea.y - segmentHeight * 2;
+            } else {
+                drawY = clientArea.y + clientArea.height + segmentHeight;
+            }
+            layout.draw(gc, drawX, drawY);
+        }
+    }
+    void printLine(int x, int y, GC gc, Color foreground, Color background, TextLayout layout, TextLayout printLayout, int index) {
+        if (background !is null) {
+            Rectangle rect = layout.getBounds();
+            gc.setBackground(background);
+            gc.fillRectangle(x, y, rect.width, rect.height);
+            
+//          int lineCount = layout.getLineCount();
+//          for (int i = 0; i < lineCount; i++) {
+//              Rectangle rect = layout.getLineBounds(i);
+//              rect.x += paintX;
+//              rect.y += paintY + layout.getSpacing();
+//              rect.width = width;//layout bounds
+//              gc.fillRectangle(rect);
+//          }
+        }
+        if (printOptions.printLineNumbers) {
+            FontMetrics metrics = layout.getLineMetrics(0);
+            printLayout.setAscent(metrics.getAscent() + metrics.getLeading());
+            printLayout.setDescent(metrics.getDescent());
+            String[] lineLabels = printOptions.lineLabels;
+            if (lineLabels !is null) {
+                if (0 <= index && index < lineLabels.length && lineLabels[index] !is null) {
+                    printLayout.setText(lineLabels[index]);
+                } else {
+                    printLayout.setText("");
+                }
+            } else {
+                printLayout.setText(String.valueOf(index));
+            }
+            int paintX = x - printMargin - printLayout.getBounds().width;
+            printLayout.draw(gc, paintX, y);
+            printLayout.setAscent(-1);
+            printLayout.setDescent(-1);
+        }
+        gc.setForeground(foreground);
+        layout.draw(gc, x, y);
+    }
+    /**
+     * Starts a print job and prints the pages specified in the constructor.
+     */
+    public void run() {
+        String jobName = printOptions.jobName;
+        if (jobName is null) {
+            jobName = "Printing";
+        }
+        if (printer.startJob(jobName)) {
+            init();
+            print();
+            dispose();
+            printer.endJob();
+        }
+    }   
+    }
+    /**
+     * The <code>RTFWriter</code> class is used to write widget content as
+     * rich text. The implementation complies with the RTF specification 
+     * version 1.5.
+     * <p>
+     * toString() is guaranteed to return a valid RTF String only after 
+     * close() has been called. 
+     * </p><p>
+     * Whole and partial lines and line breaks can be written. Lines will be
+     * formatted using the styles queried from the LineStyleListener, if 
+     * set, or those set directly in the widget. All styles are applied to
+     * the RTF stream like they are rendered by the widget. In addition, the 
+     * widget font name and size is used for the whole text.
+     * </p>
+     */
+    class RTFWriter : TextWriter {
+        static final int DEFAULT_FOREGROUND = 0;
+        static final int DEFAULT_BACKGROUND = 1;
+        Vector colorTable, fontTable;
+        bool WriteUnicode;
+        
+    /**
+     * Creates a RTF writer that writes content starting at offset "start"
+     * in the document.  <code>start</code> and <code>length</code>can be set to specify partial 
+     * lines.
+     *
+     * @param start start offset of content to write, 0 based from 
+     *  beginning of document
+     * @param length length of content to write
+     */
+    public RTFWriter(int start, int length) {
+        super(start, length);
+        colorTable = new Vector();
+        fontTable = new Vector();
+        colorTable.addElement(getForeground());
+        colorTable.addElement(getBackground());
+        fontTable.addElement(getFont());
+        setUnicode();
+    }
+    /**
+     * Closes the RTF writer. Once closed no more content can be written.
+     * <b>NOTE:</b>  <code>toString()</code> does not return a valid RTF String until 
+     * <code>close()</code> has been called.
+     */
+    public void close() {
+        if (!isClosed()) {
+            writeHeader();
+            write("\n}}\0");
+            super.close();
+        }
+    }   
+    /**
+     * Returns the index of the specified color in the RTF color table.
+     *
+     * @param color the color
+     * @param defaultIndex return value if color is null
+     * @return the index of the specified color in the RTF color table
+     *  or "defaultIndex" if "color" is null.
+     */
+    int getColorIndex(Color color, int defaultIndex) {
+        if (color is null) return defaultIndex;
+        int index = colorTable.indexOf(color);
+        if (index is -1) {
+            index = colorTable.size();
+            colorTable.addElement(color);
+        }
+        return index;
+    }
+    /**
+     * Returns the index of the specified color in the RTF color table.
+     *
+     * @param color the color
+     * @param defaultIndex return value if color is null
+     * @return the index of the specified color in the RTF color table
+     *  or "defaultIndex" if "color" is null.
+     */
+    int getFontIndex(Font font) {
+        int index = fontTable.indexOf(font);
+        if (index is -1) {
+            index = fontTable.size();
+            fontTable.addElement(font);
+        }
+        return index;
+    }
+    /**
+     * Determines if Unicode RTF should be written.
+     * Don't write Unicode RTF on Windows 95/98/ME or NT.
+     */
+    void setUnicode() {
+        final String Win95 = "windows 95";
+        final String Win98 = "windows 98";
+        final String WinME = "windows me";      
+        final String WinNT = "windows nt";
+        String osName = System.getProperty("os.name").toLowerCase();
+        String osVersion = System.getProperty("os.version");
+        int majorVersion = 0;
+        
+        if (osName.startsWith(WinNT) && osVersion !is null) {
+            int majorIndex = osVersion.indexOf('.');
+            if (majorIndex !is -1) {
+                osVersion = osVersion.substring(0, majorIndex);
+                try {
+                    majorVersion = Integer.parseInt(osVersion);
+                } catch (NumberFormatException exception) {
+                    // ignore exception. version number remains unknown.
+                    // will write without Unicode
+                }
+            }
+        }
+        WriteUnicode =  !osName.startsWith(Win95) &&
+                        !osName.startsWith(Win98) &&
+                        !osName.startsWith(WinME) &&
+                        (!osName.startsWith(WinNT) || majorVersion > 4);
+    }
+    /**
+     * Appends the specified segment of "String" to the RTF data.
+     * Copy from <code>start</code> up to, but excluding, <code>end</code>.
+     *
+     * @param String String to copy a segment from. Must not contain
+     *  line breaks. Line breaks should be written using writeLineDelimiter()
+     * @param start start offset of segment. 0 based.
+     * @param end end offset of segment
+     */
+    void write(String String, int start, int end) {
+        for (int index = start; index < end; index++) {
+            char ch = String.charAt(index);
+            if (ch > 0xFF && WriteUnicode) {
+                // write the sub String from the last escaped character 
+                // to the current one. Fixes bug 21698.
+                if (index > start) {
+                    write(String.substring(start, index));
+                }
+                write("\\u");
+                write(Integer.toString((short) ch));
+                write(' ');                     // control word delimiter
+                start = index + 1;
+            } else if (ch is '}' || ch is '{' || ch is '\\') {
+                // write the sub String from the last escaped character 
+                // to the current one. Fixes bug 21698.
+                if (index > start) {
+                    write(String.substring(start, index));
+                }
+                write('\\');
+                write(ch);
+                start = index + 1;
+            }
+        }
+        // write from the last escaped character to the end.
+        // Fixes bug 21698.
+        if (start < end) {
+            write(String.substring(start, end));
+        }
+    }
+    /**
+     * Writes the RTF header including font table and color table.
+     */
+    void writeHeader() {
+        StringBuffer header = new StringBuffer();
+        FontData fontData = getFont().getFontData()[0];
+        header.append("{\\rtf1\\ansi");
+        // specify code page, necessary for copy to work in bidi 
+        // systems that don't support Unicode RTF.
+        String cpg = System.getProperty("file.encoding").toLowerCase();
+        if (cpg.startsWith("cp") || cpg.startsWith("ms")) {
+            cpg = cpg.substring(2, cpg.length());
+            header.append("\\ansicpg");
+            header.append(cpg);
+        }
+        header.append("\\uc0\\deff0{\\fonttbl{\\f0\\fnil ");
+        header.append(fontData.getName());
+        header.append(";");
+        for (int i = 1; i < fontTable.size(); i++) {
+            header.append("\\f");
+            header.append(i);
+            header.append(" ");
+            FontData fd = ((Font)fontTable.elementAt(i)).getFontData()[0];
+            header.append(fd.getName());
+            header.append(";");         
+        }
+        header.append("}}\n{\\colortbl");
+        for (int i = 0; i < colorTable.size(); i++) {
+            Color color = (Color) colorTable.elementAt(i);
+            header.append("\\red");
+            header.append(color.getRed());
+            header.append("\\green");
+            header.append(color.getGreen());
+            header.append("\\blue");
+            header.append(color.getBlue());
+            header.append(";");
+        }
+        // some RTF readers ignore the deff0 font tag. Explicitly 
+        // set the font for the whole document to work around this.
+        header.append("}\n{\\f0\\fs");
+        // font size is specified in half points
+        header.append(fontData.getHeight() * 2);
+        header.append(" ");
+        write(header.toString(), 0);
+    }
+    /**
+     * Appends the specified line text to the RTF data.  Lines will be formatted 
+     * using the styles queried from the LineStyleListener, if set, or those set 
+     * directly in the widget.
+     *
+     * @param line line text to write as RTF. Must not contain line breaks
+     *  Line breaks should be written using writeLineDelimiter()
+     * @param lineOffset offset of the line. 0 based from the start of the 
+     *  widget document. Any text occurring before the start offset or after the 
+     *  end offset specified during object creation is ignored.
+     * @exception DWTException <ul>
+     *   <li>ERROR_IO when the writer is closed.</li>
+     * </ul>
+     */
+    public void writeLine(String line, int lineOffset) {
+        if (isClosed()) {
+            DWT.error(DWT.ERROR_IO);
+        }
+        int lineIndex = content.getLineAtOffset(lineOffset);
+        int lineAlignment, lineIndent;
+        bool lineJustify;
+        int[] ranges;
+        StyleRange[] styles;
+        StyledTextEvent event = getLineStyleData(lineOffset, line);
+        if (event !is null) {
+            lineAlignment = event.alignment;
+            lineIndent = event.indent;
+            lineJustify = event.justify;
+            ranges = event.ranges;
+            styles = event.styles;
+        } else {
+            lineAlignment = renderer.getLineAlignment(lineIndex, alignment);
+            lineIndent =  renderer.getLineIndent(lineIndex, indent);            
+            lineJustify = renderer.getLineJustify(lineIndex, justify);
+            ranges = renderer.getRanges(lineOffset, line.length());
+            styles = renderer.getStyleRanges(lineOffset, line.length(), false);
+        }
+        if (styles is null) styles = new StyleRange[0];     
+        Color lineBackground = renderer.getLineBackground(lineIndex, null);
+        event = getLineBackgroundData(lineOffset, line);
+        if (event !is null && event.lineBackground !is null) lineBackground = event.lineBackground;
+        writeStyledLine(line, lineOffset, ranges, styles, lineBackground, lineIndent, lineAlignment, lineJustify);
+    }
+    /**
+     * Appends the specified line delimiter to the RTF data.
+     *
+     * @param lineDelimiter line delimiter to write as RTF.
+     * @exception DWTException <ul>
+     *   <li>ERROR_IO when the writer is closed.</li>
+     * </ul>
+     */
+    public void writeLineDelimiter(String lineDelimiter) {
+        if (isClosed()) {
+            DWT.error(DWT.ERROR_IO);
+        }
+        write(lineDelimiter, 0, lineDelimiter.length());
+        write("\\par ");
+    }
+    /**
+     * Appends the specified line text to the RTF data.
+     * <p>
+     * Use the colors and font styles specified in "styles" and "lineBackground".
+     * Formatting is written to reflect the text rendering by the text widget.
+     * Style background colors take precedence over the line background color.
+     * Background colors are written using the \highlight tag (vs. the \cb tag).
+     * </p>
+     *
+     * @param line line text to write as RTF. Must not contain line breaks
+     *  Line breaks should be written using writeLineDelimiter()
+     * @param lineOffset offset of the line. 0 based from the start of the 
+     *  widget document. Any text occurring before the start offset or after the 
+     *  end offset specified during object creation is ignored.
+     * @param styles styles to use for formatting. Must not be null.
+     * @param lineBackground line background color to use for formatting. 
+     *  May be null.
+     */
+    void writeStyledLine(String line, int lineOffset, int ranges[], StyleRange[] styles, Color lineBackground, int indent, int alignment, bool justify) {
+        int lineLength = line.length();
+        int startOffset = getStart();
+        int writeOffset = startOffset - lineOffset;
+        if (writeOffset >= lineLength) return;
+        int lineIndex = Math.max(0, writeOffset);
+            
+        write("\\fi");
+        write(indent);
+        switch (alignment) {
+            case DWT.LEFT: write("\\ql"); break;
+            case DWT.CENTER: write("\\qc"); break;
+            case DWT.RIGHT: write("\\qr"); break;
+        }
+        if (justify) write("\\qj");
+        write(" ");
+        
+        if (lineBackground !is null) {
+            write("{\\highlight");
+            write(getColorIndex(lineBackground, DEFAULT_BACKGROUND));
+            write(" "); 
+        }
+        int endOffset = startOffset + super.getCharCount();
+        int lineEndOffset = Math.min(lineLength, endOffset - lineOffset);
+        for (int i = 0; i < styles.length; i++) {
+            StyleRange style = styles[i];
+            int start, end;
+            if (ranges !is null) {
+                start = ranges[i << 1] - lineOffset;
+                end = start + ranges[(i << 1) + 1];
+            } else {
+                start = style.start - lineOffset;
+                end = start + style.length;
+            }
+            // skip over partial first line
+            if (end < writeOffset) {
+                continue;
+            }
+            // style starts beyond line end or RTF write end
+            if (start >= lineEndOffset) {
+                break;
+            }
+            // write any unstyled text
+            if (lineIndex < start) {
+                // copy to start of style
+                // style starting beyond end of write range or end of line 
+                // is guarded against above.
+                write(line, lineIndex, start);
+                lineIndex = start;
+            }
+            // write styled text
+            write("{\\cf");
+            write(getColorIndex(style.foreground, DEFAULT_FOREGROUND));
+            int colorIndex = getColorIndex(style.background, DEFAULT_BACKGROUND);
+            if (colorIndex !is DEFAULT_BACKGROUND) {
+                write("\\highlight");
+                write(colorIndex);
+            }
+            Font font = style.font;
+            if (font !is null) {
+                int fontIndex = getFontIndex(font);
+                write("\\f");
+                write(fontIndex);
+                FontData fontData = font.getFontData()[0];
+                write("\\fs");
+                write(fontData.getHeight() * 2);
+            } else {
+                if ((style.fontStyle & DWT.BOLD) !is 0) {
+                    write("\\b"); 
+                }
+                if ((style.fontStyle & DWT.ITALIC) !is 0) {
+                    write("\\i"); 
+                }
+            }
+            if (style.underline) {
+                write("\\ul");
+            }
+            if (style.strikeout) {
+                write("\\strike");
+            }
+            write(" "); 
+            // copy to end of style or end of write range or end of line
+            int copyEnd = Math.min(end, lineEndOffset);
+            // guard against invalid styles and let style processing continue
+            copyEnd = Math.max(copyEnd, lineIndex);
+            write(line, lineIndex, copyEnd);
+            if (font is null) {
+                if ((style.fontStyle & DWT.BOLD) !is 0) {
+                    write("\\b0"); 
+                }
+                if ((style.fontStyle & DWT.ITALIC) !is 0) {
+                    write("\\i0"); 
+                }
+            }
+            if (style.underline) {
+                write("\\ul0");
+            }
+            if (style.strikeout) {
+                write("\\strike0");
+            }
+            write("}");
+            lineIndex = copyEnd;
+        }
+        // write unstyled text at the end of the line
+        if (lineIndex < lineEndOffset) {
+            write(line, lineIndex, lineEndOffset);
+        }
+        if (lineBackground !is null) write("}");
+    }
+    }
+    /**
+     * The <code>TextWriter</code> class is used to write widget content to
+     * a String.  Whole and partial lines and line breaks can be written. To write 
+     * partial lines, specify the start and length of the desired segment 
+     * during object creation.
+     * <p>
+     * </b>NOTE:</b> <code>toString()</code> is guaranteed to return a valid String only after close() 
+     * has been called.
+     * </p>
+     */
+    class TextWriter {
+        private StringBuffer buffer;
+        private int startOffset;    // offset of first character that will be written
+        private int endOffset;      // offset of last character that will be written. 
+                                    // 0 based from the beginning of the widget text. 
+        private bool isClosed = false;
+    
+    /**
+     * Creates a writer that writes content starting at offset "start"
+     * in the document.  <code>start</code> and <code>length</code> can be set to specify partial lines.
+     *
+     * @param start start offset of content to write, 0 based from beginning of document
+     * @param length length of content to write
+     */
+    public TextWriter(int start, int length) {
+        buffer = new StringBuffer(length);
+        startOffset = start;
+        endOffset = start + length;
+    }
+    /**
+     * Closes the writer. Once closed no more content can be written.
+     * <b>NOTE:</b>  <code>toString()</code> is not guaranteed to return a valid String unless
+     * the writer is closed.
+     */
+    public void close() {
+        if (!isClosed) {
+            isClosed = true;
+        }
+    }
+    /** 
+     * Returns the number of characters to write.
+     * @return the integer number of characters to write
+     */
+    public int getCharCount() {
+        return endOffset - startOffset;
+    }   
+    /** 
+     * Returns the offset where writing starts. 0 based from the start of 
+     * the widget text. Used to write partial lines.
+     * @return the integer offset where writing starts
+     */
+    public int getStart() {
+        return startOffset;
+    }
+    /**
+     * Returns whether the writer is closed.
+     * @return a bool specifying whether or not the writer is closed
+     */
+    public bool isClosed() {
+        return isClosed;
+    }
+    /**
+     * Returns the String.  <code>close()</code> must be called before <code>toString()</code> 
+     * is guaranteed to return a valid String.
+     *
+     * @return the String
+     */
+    public String toString() {
+        return buffer.toString();
+    }
+    /**
+     * Appends the given String to the data.
+     */
+    void write(String String) {
+        buffer.append(String);
+    }
+    /**
+     * Inserts the given String to the data at the specified offset.
+     * <p>
+     * Do nothing if "offset" is < 0 or > getCharCount()
+     * </p>
+     *
+     * @param String text to insert
+     * @param offset offset in the existing data to insert "String" at.
+     */
+    void write(String String, int offset) {
+        if (offset < 0 || offset > buffer.length()) {
+            return;
+        }
+        buffer.insert(offset, String);
+    }
+    /**
+     * Appends the given int to the data.
+     */
+    void write(int i) {
+        buffer.append(i);
+    }
+    /**
+     * Appends the given character to the data.
+     */
+    void write(char i) {
+        buffer.append(i);
+    }
+    /**
+     * Appends the specified line text to the data.
+     *
+     * @param line line text to write. Must not contain line breaks
+     *  Line breaks should be written using writeLineDelimiter()
+     * @param lineOffset offset of the line. 0 based from the start of the 
+     *  widget document. Any text occurring before the start offset or after the 
+     *  end offset specified during object creation is ignored.
+     * @exception DWTException <ul>
+     *   <li>ERROR_IO when the writer is closed.</li>
+     * </ul>
+     */
+    public void writeLine(String line, int lineOffset) {    
+        if (isClosed) {
+            DWT.error(DWT.ERROR_IO);
+        }       
+        int writeOffset = startOffset - lineOffset;
+        int lineLength = line.length();
+        int lineIndex;
+        if (writeOffset >= lineLength) {
+            return;                         // whole line is outside write range
+        } else if (writeOffset > 0) {
+            lineIndex = writeOffset;        // line starts before write start
+        } else {
+            lineIndex = 0;
+        }
+        int copyEnd = Math.min(lineLength, endOffset - lineOffset);
+        if (lineIndex < copyEnd) {
+            write(line.substring(lineIndex, copyEnd));
+        }
+    }
+    /**
+     * Appends the specified line delimiter to the data.
+     *
+     * @param lineDelimiter line delimiter to write
+     * @exception DWTException <ul>
+     *   <li>ERROR_IO when the writer is closed.</li>
+     * </ul>
+     */
+    public void writeLineDelimiter(String lineDelimiter) {
+        if (isClosed) {
+            DWT.error(DWT.ERROR_IO);
+        }
+        write(lineDelimiter);
+    }
+    }
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT#FULL_SELECTION
+ * @see DWT#MULTI
+ * @see DWT#READ_ONLY
+ * @see DWT#SINGLE
+ * @see DWT#WRAP
+ * @see #getStyle
+ */
+public StyledText(Composite parent, int style) {
+    super(parent, checkStyle(style));
+    // set the fg in the OS to ensure that these are the same as StyledText, necessary
+    // for ensuring that the bg/fg the IME box uses is the same as what StyledText uses
+    super.setForeground(getForeground());
+    super.setDragDetect(false);
+    Display display = getDisplay();
+    isMirrored = (super.getStyle() & DWT.MIRRORED) !is 0;
+    fixedLineHeight = true;
+    if ((style & DWT.READ_ONLY) !is 0) {
+        setEditable(false);
+    }
+    leftMargin = rightMargin = isBidiCaret() ? BIDI_CARET_WIDTH - 1: 0;
+    if ((style & DWT.SINGLE) !is 0 && (style & DWT.BORDER) !is 0) {
+        leftMargin = topMargin = rightMargin = bottomMargin = 2;
+    }
+    alignment = style & (DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    if (alignment is 0) alignment = DWT.LEFT;
+    clipboard = new Clipboard(display);
+    installDefaultContent();
+    renderer = new StyledTextRenderer(getDisplay(), this);
+    renderer.setContent(content);
+    renderer.setFont(getFont(), tabLength);
+    ime = new IME(this, DWT.NONE);
+    defaultCaret = new Caret(this, DWT.NONE);
+    if ((style & DWT.WRAP) !is 0) {
+        setWordWrap(true);
+    }
+    if (isBidiCaret()) {
+        createCaretBitmaps();
+        Runnable runnable = new Runnable() {
+            public void run() {
+                int direction = BidiUtil.getKeyboardLanguage() is BidiUtil.KEYBOARD_BIDI ? DWT.RIGHT : DWT.LEFT;
+                if (direction is caretDirection) return;
+                if (getCaret() !is defaultCaret) return;
+                Point newCaretPos = getPointAtOffset(caretOffset);
+                setCaretLocation(newCaretPos, direction);
+            }
+        };
+        BidiUtil.addLanguageListener(this, runnable);
+    }
+    setCaret(defaultCaret); 
+    calculateScrollBars();
+    createKeyBindings();
+    setCursor(display.getSystemCursor(DWT.CURSOR_IBEAM));
+    installListeners();
+    initializeAccessible();
+    setData("DEFAULT_DROP_TARGET_EFFECT", new StyledTextDropTargetEffect(this));
+}
+/**  
+ * Adds an extended modify listener. An ExtendedModify event is sent by the 
+ * widget when the widget text has changed.
+ *
+ * @param extendedModifyListener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener) {
+    checkWidget();
+    if (extendedModifyListener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    StyledTextListener typedListener = new StyledTextListener(extendedModifyListener);
+    addListener(ExtendedModify, typedListener);
+}
+/**
+ * Adds a bidirectional segment listener.
+ * <p>
+ * A BidiSegmentEvent is sent 
+ * whenever a line of text is measured or rendered. The user can 
+ * specify text ranges in the line that should be treated as if they 
+ * had a different direction than the surrounding text.
+ * This may be used when adjacent segments of right-to-left text should
+ * not be reordered relative to each other. 
+ * E.g., Multiple Java String literals in a right-to-left language
+ * should generally remain in logical order to each other, that is, the
+ * way they are stored. 
+ * </p>
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * @see BidiSegmentEvent
+ * @since 2.0
+ */
+public void addBidiSegmentListener(BidiSegmentListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    addListener(LineGetSegments, new StyledTextListener(listener));
+}
+/**
+ * Adds a line background listener. A LineGetBackground event is sent by the 
+ * widget to determine the background color for a line.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addLineBackgroundListener(LineBackgroundListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (!isListening(LineGetBackground)) {
+        renderer.clearLineBackground(0, content.getLineCount());
+    }
+    addListener(LineGetBackground, new StyledTextListener(listener));
+}
+/**
+ * Adds a line style listener. A LineGetStyle event is sent by the widget to 
+ * determine the styles for a line.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addLineStyleListener(LineStyleListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (!isListening(LineGetStyle)) {
+        setStyleRanges(0, 0, null, null, true);
+        renderer.clearLineStyle(0, content.getLineCount());
+    }
+    addListener(LineGetStyle, new StyledTextListener(listener));
+}
+/**  
+ * Adds a modify listener. A Modify event is sent by the widget when the widget text 
+ * has changed.
+ *
+ * @param modifyListener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addModifyListener(ModifyListener modifyListener) {
+    checkWidget();
+    if (modifyListener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    addListener(DWT.Modify, new TypedListener(modifyListener));
+}
+/**  
+ * Adds a paint object listener. A paint object event is sent by the widget when an object
+ * needs to be drawn.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see PaintObjectListener
+ * @see PaintObjectEvent
+ */
+public void addPaintObjectListener(PaintObjectListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    addListener(PaintObject, new StyledTextListener(listener));
+}
+/**  
+ * Adds a selection listener. A Selection event is sent by the widget when the 
+ * user changes the selection.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event x and y fields contain
+ * the start and end caret indices of the selection.
+ * <code>widgetDefaultSelected</code> is not called for StyledTexts.
+ * </p>
+ * 
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    addListener(DWT.Selection, new TypedListener(listener));
+}
+/**  
+ * Adds a verify key listener. A VerifyKey event is sent by the widget when a key 
+ * is pressed. The widget ignores the key press if the listener sets the doit field 
+ * of the event to false. 
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addVerifyKeyListener(VerifyKeyListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    addListener(VerifyKey, new StyledTextListener(listener));
+}
+/**  
+ * Adds a verify listener. A Verify event is sent by the widget when the widget text 
+ * is about to change. The listener can set the event text and the doit field to 
+ * change the text that is set in the widget or to force the widget to ignore the 
+ * text change.
+ *
+ * @param verifyListener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addVerifyListener(VerifyListener verifyListener) {
+    checkWidget();
+    if (verifyListener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    addListener(DWT.Verify, new TypedListener(verifyListener));
+}
+/**  
+ * Adds a word movement listener. A movement event is sent when the boundary 
+ * of a word is needed. For example, this occurs during word next and word 
+ * previous actions.
+ *
+ * @param movementListener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * 
+ * @see MovementEvent
+ * @see MovementListener
+ * @see #removeWordMovementListener
+ * 
+ * @since 3.3 
+ */
+public void addWordMovementListener(MovementListener movementListener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    addListener(WordNext, new StyledTextListener(movementListener));
+    addListener(WordPrevious, new StyledTextListener(movementListener));
+}
+/** 
+ * Appends a String to the text at the end of the widget.
+ *
+ * @param String the String to be appended
+ * @see #replaceTextRange(int,int,String)
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void append(String String) {
+    checkWidget();
+    if (String is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    int lastChar = Math.max(getCharCount(), 0);
+    replaceTextRange(lastChar, 0, String);
+}
+/**
+ * Calculates the scroll bars
+ */
+void calculateScrollBars() {
+    ScrollBar horizontalBar = getHorizontalBar();
+    ScrollBar verticalBar = getVerticalBar();
+    setScrollBars(true);
+    if (verticalBar !is null) {
+        verticalBar.setIncrement(getVerticalIncrement());
+    }   
+    if (horizontalBar !is null) {
+        horizontalBar.setIncrement(getHorizontalIncrement());
+    }
+}
+/**
+ * Calculates the top index based on the current vertical scroll offset.
+ * The top index is the index of the topmost fully visible line or the
+ * topmost partially visible line if no line is fully visible.
+ * The top index starts at 0.
+ */
+void calculateTopIndex(int delta) {
+    int oldTopIndex = topIndex;
+    int oldTopIndexY = topIndexY;
+    if (isFixedLineHeight()) {
+        int verticalIncrement = getVerticalIncrement();
+        if (verticalIncrement is 0) {
+            return;
+        }
+        topIndex = Compatibility.ceil(getVerticalScrollOffset(), verticalIncrement);
+        // Set top index to partially visible top line if no line is fully 
+        // visible but at least some of the widget client area is visible.
+        // Fixes bug 15088.
+        if (topIndex > 0) {
+            if (clientAreaHeight > 0) {
+                int bottomPixel = getVerticalScrollOffset() + clientAreaHeight;
+                int fullLineTopPixel = topIndex * verticalIncrement;
+                int fullLineVisibleHeight = bottomPixel - fullLineTopPixel;
+                // set top index to partially visible line if no line fully fits in 
+                // client area or if space is available but not used (the latter should
+                // never happen because we use claimBottomFreeSpace)
+                if (fullLineVisibleHeight < verticalIncrement) {
+                    topIndex--;
+                }
+            } else if (topIndex >= content.getLineCount()) {
+                topIndex = content.getLineCount() - 1;
+            }
+        }
+    } else {
+        if (delta >= 0) {
+            delta -= topIndexY;
+            int lineIndex = topIndex;
+            int lineCount = content.getLineCount();
+            while (lineIndex < lineCount) {
+                if (delta <= 0) break;
+                delta -= renderer.getLineHeight(lineIndex++);
+            }
+            if (lineIndex < lineCount && -delta + renderer.getLineHeight(lineIndex) <= clientAreaHeight - topMargin - bottomMargin) {
+                topIndex = lineIndex;
+                topIndexY = -delta;
+            } else {
+                topIndex = lineIndex - 1;
+                topIndexY = -renderer.getLineHeight(topIndex) - delta;
+            }
+        } else {
+            delta -= topIndexY;
+            int lineIndex = topIndex;
+            while (lineIndex > 0) {
+                int lineHeight = renderer.getLineHeight(lineIndex - 1);
+                if (delta + lineHeight > 0) break;
+                delta += lineHeight;
+                lineIndex--;
+            }
+            if (lineIndex is 0 || -delta + renderer.getLineHeight(lineIndex) <= clientAreaHeight - topMargin - bottomMargin) {
+                topIndex = lineIndex;
+                topIndexY = - delta;
+            } else {
+                topIndex = lineIndex - 1;
+                topIndexY = - renderer.getLineHeight(topIndex) - delta;
+            }
+        }
+    }
+    if (topIndex !is oldTopIndex || oldTopIndexY !is topIndexY) {
+        renderer.calculateClientArea();
+        setScrollBars(false);
+    }
+}
+/**
+ * Hides the scroll bars if widget is created in single line mode.
+ */
+static int checkStyle(int style) {
+    if ((style & DWT.SINGLE) !is 0) {
+        style &= ~(DWT.H_SCROLL | DWT.V_SCROLL | DWT.WRAP | DWT.MULTI);
+    } else {
+        style |= DWT.MULTI;
+        if ((style & DWT.WRAP) !is 0) {
+            style &= ~DWT.H_SCROLL;
+        }
+    }
+    style |= DWT.NO_REDRAW_RESIZE | DWT.DOUBLE_BUFFERED | DWT.NO_BACKGROUND;
+    return style;
+}
+/**
+ * Scrolls down the text to use new space made available by a resize or by 
+ * deleted lines.
+ */
+void claimBottomFreeSpace() {
+    int clientAreaHeight = this.clientAreaHeight - topMargin - bottomMargin;
+    if (isFixedLineHeight()) {
+        int lineHeight = renderer.getLineHeight();
+        int newVerticalOffset = Math.max(0, content.getLineCount() * lineHeight - clientAreaHeight);
+        if (newVerticalOffset < getVerticalScrollOffset()) {
+            scrollVertical(newVerticalOffset - getVerticalScrollOffset(), true);
+        }
+    } else {
+        int bottomIndex = getPartialBottomIndex();
+        int height = getLinePixel(bottomIndex + 1);
+        if (clientAreaHeight > height) {
+            scrollVertical(-getAvailableHeightAbove(clientAreaHeight - height), true);
+        }
+    }
+}
+/**
+ * Scrolls text to the right to use new space made available by a resize.
+ */
+void claimRightFreeSpace() {
+    int newHorizontalOffset = Math.max(0, renderer.getWidth() - (clientAreaWidth - leftMargin - rightMargin));
+    if (newHorizontalOffset < horizontalScrollOffset) {         
+        // item is no longer drawn past the right border of the client area
+        // align the right end of the item with the right border of the 
+        // client area (window is scrolled right).
+        scrollHorizontal(newHorizontalOffset - horizontalScrollOffset, true);                   
+    }
+}
+/**
+ * Removes the widget selection.
+ *
+ * @param sendEvent a Selection event is sent when set to true and when the selection is actually reset.
+ */
+void clearSelection(bool sendEvent) {
+    int selectionStart = selection.x;
+    int selectionEnd = selection.y; 
+    resetSelection();
+    // redraw old selection, if any
+    if (selectionEnd - selectionStart > 0) {
+        int length = content.getCharCount();
+        // called internally to remove selection after text is removed
+        // therefore make sure redraw range is valid.
+        int redrawStart = Math.min(selectionStart, length);
+        int redrawEnd = Math.min(selectionEnd, length);
+        if (redrawEnd - redrawStart > 0) {
+            internalRedrawRange(redrawStart, redrawEnd - redrawStart);
+        }
+        if (sendEvent) {
+            sendSelectionEvent();
+        }
+    }
+}
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int lineCount = (getStyle() & DWT.SINGLE) !is 0 ? 1 : content.getLineCount();
+    int width = 0;
+    int height = 0;
+    if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) {
+        Display display = getDisplay();
+        int maxHeight = display.getClientArea().height;
+        for (int lineIndex = 0; lineIndex < lineCount; lineIndex++) {
+            TextLayout layout = renderer.getTextLayout(lineIndex);
+            int wrapWidth = layout.getWidth();
+            if (wordWrap) layout.setWidth(wHint is 0 ? 1 : wHint);
+            Rectangle rect = layout.getBounds();
+            height += rect.height;
+            width = Math.max(width, rect.width);
+            layout.setWidth(wrapWidth);
+            renderer.disposeTextLayout(layout);
+            if (isFixedLineHeight() && height > maxHeight) break;
+        }
+        if (isFixedLineHeight()) {
+            height = lineCount * renderer.getLineHeight();
+        }
+    }
+    // Use default values if no text is defined.
+    if (width is 0) width = DEFAULT_WIDTH;
+    if (height is 0) height = DEFAULT_HEIGHT;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    int wTrim = leftMargin + rightMargin + getCaretWidth();
+    int hTrim = topMargin + bottomMargin;
+    Rectangle rect = computeTrim(0, 0, width + wTrim, height + hTrim);
+    return new Point (rect.width, rect.height);
+}
+/**
+ * Copies the selected text to the <code>DND.CLIPBOARD</code> clipboard.
+ * <p>
+ * The text will be put on the clipboard in plain text format and RTF format.
+ * The <code>DND.CLIPBOARD</code> clipboard is used for data that is
+ * transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) or 
+ * by menu action.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void copy() {
+    checkWidget();
+    copy(DND.CLIPBOARD);
+}
+/**
+ * Copies the selected text to the specified clipboard.  The text will be put in the 
+ * clipboard in plain text format and RTF format.
+ * <p>
+ * The clipboardType is  one of the clipboard constants defined in class 
+ * <code>DND</code>.  The <code>DND.CLIPBOARD</code>  clipboard is 
+ * used for data that is transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) 
+ * or by menu action.  The <code>DND.SELECTION_CLIPBOARD</code> 
+ * clipboard is used for data that is transferred by selecting text and pasting 
+ * with the middle mouse button.
+ * </p>
+ * 
+ * @param clipboardType indicates the type of clipboard
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void copy(int clipboardType) {
+    checkWidget();
+    if (clipboardType !is DND.CLIPBOARD && clipboardType !is DND.SELECTION_CLIPBOARD) return;
+    int length = selection.y - selection.x;
+    if (length > 0) {
+        try {
+            setClipboardContent(selection.x, length, clipboardType);
+        } catch (DWTError error) {
+            // Copy to clipboard failed. This happens when another application 
+            // is accessing the clipboard while we copy. Ignore the error.
+            // Fixes 1GDQAVN
+            // Rethrow all other errors. Fixes bug 17578.
+            if (error.code !is DND.ERROR_CANNOT_SET_CLIPBOARD) {
+                throw error;
+            }
+        }
+    }
+}
+/**
+ * Returns the alignment of the widget.
+ * 
+ * @return the alignment
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see #getLineAlignment(int)
+ * 
+ * @since 3.2
+ */
+public int getAlignment() {
+    checkWidget();
+    return alignment;
+}
+int getAvailableHeightAbove(int height) {
+    int maxHeight = verticalScrollOffset;
+    if (maxHeight is -1) {
+        int lineIndex = topIndex - 1;
+        maxHeight = -topIndexY;
+        if (topIndexY > 0) {
+            maxHeight += renderer.getLineHeight(lineIndex--);
+        }
+        while (height > maxHeight && lineIndex >= 0) {
+            maxHeight += renderer.getLineHeight(lineIndex--);
+        }
+    }
+    return Math.min(height, maxHeight);
+}
+int getAvailableHeightBellow(int height) {
+    int partialBottomIndex = getPartialBottomIndex();
+    int topY = getLinePixel(partialBottomIndex);
+    int lineHeight = renderer.getLineHeight(partialBottomIndex);
+    int availableHeight = 0;
+    int clientAreaHeight = this.clientAreaHeight - topMargin - bottomMargin;
+    if (topY + lineHeight > clientAreaHeight) {
+        availableHeight = lineHeight - (clientAreaHeight - topY);
+    }
+    int lineIndex = partialBottomIndex + 1;
+    int lineCount = content.getLineCount();
+    while (height > availableHeight && lineIndex < lineCount) {
+        availableHeight += renderer.getLineHeight(lineIndex++);
+    }
+    return Math.min(height, availableHeight);
+}
+/**
+ * Returns a String that uses only the line delimiter specified by the 
+ * StyledTextContent implementation.
+ * <p>
+ * Returns only the first line if the widget has the DWT.SINGLE style.
+ * </p>
+ *
+ * @param text the text that may have line delimiters that don't 
+ *  match the model line delimiter. Possible line delimiters 
+ *  are CR ('\r'), LF ('\n'), CR/LF ("\r\n")
+ * @return the converted text that only uses the line delimiter 
+ *  specified by the model. Returns only the first line if the widget 
+ *  has the DWT.SINGLE style.
+ */
+String getModelDelimitedText(String text) { 
+    int length = text.length();
+    if (length is 0) {
+        return text;
+    }   
+    int crIndex = 0;
+    int lfIndex = 0;
+    int i = 0;
+    StringBuffer convertedText = new StringBuffer(length);
+    String delimiter = getLineDelimiter();
+    while (i < length) {
+        if (crIndex !is -1) {
+            crIndex = text.indexOf(DWT.CR, i);
+        }
+        if (lfIndex !is -1) {
+            lfIndex = text.indexOf(DWT.LF, i);
+        }
+        if (lfIndex is -1 && crIndex is -1) {   // no more line breaks?
+            break;
+        } else if ((crIndex < lfIndex && crIndex !is -1) || lfIndex is -1) {
+            convertedText.append(text.substring(i, crIndex));
+            if (lfIndex is crIndex + 1) {       // CR/LF combination?
+                i = lfIndex + 1;
+            } else {
+                i = crIndex + 1;
+            }
+        } else {                                    // LF occurs before CR!
+            convertedText.append(text.substring(i, lfIndex));
+            i = lfIndex + 1;
+        }
+        if (isSingleLine()) {
+            break;
+        }
+        convertedText.append(delimiter);
+    }
+    // copy remaining text if any and if not in single line mode or no 
+    // text copied thus far (because there only is one line)
+    if (i < length && (!isSingleLine() || convertedText.length() is 0)) {
+        convertedText.append(text.substring(i));
+    }
+    return convertedText.toString();
+}
+bool checkDragDetect(Event event) {
+    if (!isListening(DWT.DragDetect)) return false;
+    if (IS_MOTIF) {
+        if (event.button !is 2) return false;
+    } else {
+        if (event.button !is 1) return false;
+    }
+    if (selection.x is selection.y) return false;
+    int offset = getOffsetAtPoint(event.x, event.y, null, true);
+    if (selection.x <= offset && offset < selection.y) {
+        return dragDetect(event);
+    }
+    return false;
+}
+/**
+ * Creates default key bindings.
+ */
+void createKeyBindings() {
+    int nextKey = isMirrored() ? DWT.ARROW_LEFT : DWT.ARROW_RIGHT;
+    int previousKey = isMirrored() ? DWT.ARROW_RIGHT : DWT.ARROW_LEFT;
+    
+    // Navigation
+    setKeyBinding(DWT.ARROW_UP, ST.LINE_UP);    
+    setKeyBinding(DWT.ARROW_DOWN, ST.LINE_DOWN);
+    if (IS_CARBON) {
+        setKeyBinding(previousKey | DWT.MOD1, ST.LINE_START);
+        setKeyBinding(nextKey | DWT.MOD1, ST.LINE_END);
+        setKeyBinding(DWT.HOME, ST.TEXT_START);
+        setKeyBinding(DWT.END, ST.TEXT_END);
+        setKeyBinding(DWT.ARROW_UP | DWT.MOD1, ST.TEXT_START);
+        setKeyBinding(DWT.ARROW_DOWN | DWT.MOD1, ST.TEXT_END);
+        setKeyBinding(nextKey | DWT.MOD3, ST.WORD_NEXT);
+        setKeyBinding(previousKey | DWT.MOD3, ST.WORD_PREVIOUS);
+    } else {
+        setKeyBinding(DWT.HOME, ST.LINE_START);
+        setKeyBinding(DWT.END, ST.LINE_END);
+        setKeyBinding(DWT.HOME | DWT.MOD1, ST.TEXT_START);
+        setKeyBinding(DWT.END | DWT.MOD1, ST.TEXT_END);
+        setKeyBinding(nextKey | DWT.MOD1, ST.WORD_NEXT);
+        setKeyBinding(previousKey | DWT.MOD1, ST.WORD_PREVIOUS);
+    }
+    setKeyBinding(DWT.PAGE_UP, ST.PAGE_UP);
+    setKeyBinding(DWT.PAGE_DOWN, ST.PAGE_DOWN);
+    setKeyBinding(DWT.PAGE_UP | DWT.MOD1, ST.WINDOW_START);
+    setKeyBinding(DWT.PAGE_DOWN | DWT.MOD1, ST.WINDOW_END);
+    setKeyBinding(nextKey, ST.COLUMN_NEXT);
+    setKeyBinding(previousKey, ST.COLUMN_PREVIOUS);
+    
+    // Selection
+    setKeyBinding(DWT.ARROW_UP | DWT.MOD2, ST.SELECT_LINE_UP);  
+    setKeyBinding(DWT.ARROW_DOWN | DWT.MOD2, ST.SELECT_LINE_DOWN);
+    if (IS_CARBON) {
+        setKeyBinding(previousKey | DWT.MOD1 | DWT.MOD2, ST.SELECT_LINE_START);
+        setKeyBinding(nextKey | DWT.MOD1 | DWT.MOD2, ST.SELECT_LINE_END);
+        setKeyBinding(DWT.HOME | DWT.MOD2, ST.SELECT_TEXT_START);   
+        setKeyBinding(DWT.END | DWT.MOD2, ST.SELECT_TEXT_END);
+        setKeyBinding(DWT.ARROW_UP | DWT.MOD1 | DWT.MOD2, ST.SELECT_TEXT_START);    
+        setKeyBinding(DWT.ARROW_DOWN | DWT.MOD1 | DWT.MOD2, ST.SELECT_TEXT_END);
+        setKeyBinding(nextKey | DWT.MOD2 | DWT.MOD3, ST.SELECT_WORD_NEXT);
+        setKeyBinding(previousKey | DWT.MOD2 | DWT.MOD3, ST.SELECT_WORD_PREVIOUS);
+    } else  {
+        setKeyBinding(DWT.HOME | DWT.MOD2, ST.SELECT_LINE_START);
+        setKeyBinding(DWT.END | DWT.MOD2, ST.SELECT_LINE_END);
+        setKeyBinding(DWT.HOME | DWT.MOD1 | DWT.MOD2, ST.SELECT_TEXT_START);    
+        setKeyBinding(DWT.END | DWT.MOD1 | DWT.MOD2, ST.SELECT_TEXT_END);
+        setKeyBinding(nextKey | DWT.MOD1 | DWT.MOD2, ST.SELECT_WORD_NEXT);
+        setKeyBinding(previousKey | DWT.MOD1 | DWT.MOD2, ST.SELECT_WORD_PREVIOUS);
+    }
+    setKeyBinding(DWT.PAGE_UP | DWT.MOD2, ST.SELECT_PAGE_UP);
+    setKeyBinding(DWT.PAGE_DOWN | DWT.MOD2, ST.SELECT_PAGE_DOWN);
+    setKeyBinding(DWT.PAGE_UP | DWT.MOD1 | DWT.MOD2, ST.SELECT_WINDOW_START);
+    setKeyBinding(DWT.PAGE_DOWN | DWT.MOD1 | DWT.MOD2, ST.SELECT_WINDOW_END);
+    setKeyBinding(nextKey | DWT.MOD2, ST.SELECT_COLUMN_NEXT);
+    setKeyBinding(previousKey | DWT.MOD2, ST.SELECT_COLUMN_PREVIOUS);   
+                
+    // Modification
+    // Cut, Copy, Paste
+    setKeyBinding('X' | DWT.MOD1, ST.CUT);
+    setKeyBinding('C' | DWT.MOD1, ST.COPY);
+    setKeyBinding('V' | DWT.MOD1, ST.PASTE);
+    if (IS_CARBON) {
+        setKeyBinding(DWT.DEL | DWT.MOD2, ST.DELETE_NEXT);
+        setKeyBinding(DWT.BS | DWT.MOD3, ST.DELETE_WORD_PREVIOUS);
+        setKeyBinding(DWT.DEL | DWT.MOD3, ST.DELETE_WORD_NEXT);
+    } else {
+        // Cut, Copy, Paste Wordstar style
+        setKeyBinding(DWT.DEL | DWT.MOD2, ST.CUT);
+        setKeyBinding(DWT.INSERT | DWT.MOD1, ST.COPY);
+        setKeyBinding(DWT.INSERT | DWT.MOD2, ST.PASTE);
+    }
+    setKeyBinding(DWT.BS | DWT.MOD2, ST.DELETE_PREVIOUS);
+    setKeyBinding(DWT.BS, ST.DELETE_PREVIOUS);
+    setKeyBinding(DWT.DEL, ST.DELETE_NEXT);
+    setKeyBinding(DWT.BS | DWT.MOD1, ST.DELETE_WORD_PREVIOUS);
+    setKeyBinding(DWT.DEL | DWT.MOD1, ST.DELETE_WORD_NEXT);
+    
+    // Miscellaneous
+    setKeyBinding(DWT.INSERT, ST.TOGGLE_OVERWRITE);
+}
+/**
+ * Create the bitmaps to use for the caret in bidi mode.  This
+ * method only needs to be called upon widget creation and when the
+ * font changes (the caret bitmap height needs to match font height).
+ */
+void createCaretBitmaps() {
+    int caretWidth = BIDI_CARET_WIDTH;
+    Display display = getDisplay();
+    if (leftCaretBitmap !is null) {
+        if (defaultCaret !is null && leftCaretBitmap.opEquals(defaultCaret.getImage())) {
+            defaultCaret.setImage(null);
+        }
+        leftCaretBitmap.dispose();
+    }
+    int lineHeight = renderer.getLineHeight();
+    leftCaretBitmap = new Image(display, caretWidth, lineHeight);
+    GC gc = new GC (leftCaretBitmap); 
+    gc.setBackground(display.getSystemColor(DWT.COLOR_BLACK));
+    gc.fillRectangle(0, 0, caretWidth, lineHeight);
+    gc.setForeground(display.getSystemColor(DWT.COLOR_WHITE));
+    gc.drawLine(0,0,0,lineHeight);
+    gc.drawLine(0,0,caretWidth-1,0);
+    gc.drawLine(0,1,1,1);
+    gc.dispose();   
+    
+    if (rightCaretBitmap !is null) {
+        if (defaultCaret !is null && rightCaretBitmap.opEquals(defaultCaret.getImage())) {
+            defaultCaret.setImage(null);
+        }
+        rightCaretBitmap.dispose();
+    }
+    rightCaretBitmap = new Image(display, caretWidth, lineHeight);
+    gc = new GC (rightCaretBitmap); 
+    gc.setBackground(display.getSystemColor(DWT.COLOR_BLACK));
+    gc.fillRectangle(0, 0, caretWidth, lineHeight);
+    gc.setForeground(display.getSystemColor(DWT.COLOR_WHITE));
+    gc.drawLine(caretWidth-1,0,caretWidth-1,lineHeight);
+    gc.drawLine(0,0,caretWidth-1,0);
+    gc.drawLine(caretWidth-1,1,1,1);
+    gc.dispose();
+}
+/**
+ * Moves the selected text to the clipboard.  The text will be put in the 
+ * clipboard in plain text format and RTF format.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void cut(){
+    checkWidget();
+    int length = selection.y - selection.x;
+    if (length > 0) {
+        try {
+            setClipboardContent(selection.x, length, DND.CLIPBOARD);
+        } catch (DWTError error) {
+            // Copy to clipboard failed. This happens when another application 
+            // is accessing the clipboard while we copy. Ignore the error.
+            // Fixes 1GDQAVN
+            // Rethrow all other errors. Fixes bug 17578.
+            if (error.code !is DND.ERROR_CANNOT_SET_CLIPBOARD) {
+                throw error;
+            }
+            // Abort cut operation if copy to clipboard fails.
+            // Fixes bug 21030.
+            return;
+        }
+        doDelete();
+    }
+}
+/** 
+ * A mouse move event has occurred.  See if we should start autoscrolling.  If
+ * the move position is outside of the client area, initiate autoscrolling.  
+ * Otherwise, we've moved back into the widget so end autoscrolling.
+ */
+void doAutoScroll(Event event) {
+    if (event.y > clientAreaHeight) {
+        doAutoScroll(DWT.DOWN, event.y - clientAreaHeight);
+    } else if (event.y < 0) {
+        doAutoScroll(DWT.UP, -event.y);
+    } else if (event.x < leftMargin && !wordWrap) {
+        doAutoScroll(ST.COLUMN_PREVIOUS, leftMargin - event.x);
+    } else if (event.x > clientAreaWidth - leftMargin - rightMargin && !wordWrap) {
+        doAutoScroll(ST.COLUMN_NEXT, event.x - (clientAreaWidth - leftMargin - rightMargin));
+    } else {
+        endAutoScroll();
+    }
+}
+/** 
+ * Initiates autoscrolling.
+ *
+ * @param direction DWT.UP, DWT.DOWN, DWT.COLUMN_NEXT, DWT.COLUMN_PREVIOUS
+ */
+void doAutoScroll(int direction, int distance) {
+    autoScrollDistance = distance;
+    // If we're already autoscrolling in the given direction do nothing
+    if (autoScrollDirection is direction) {
+        return;
+    }
+    
+    Runnable timer = null;
+    final Display display = getDisplay();
+    // Set a timer that will simulate the user pressing and holding
+    // down a cursor key (i.e., arrowUp, arrowDown).
+    if (direction is DWT.UP) {
+        timer = new Runnable() {
+            public void run() {
+                if (autoScrollDirection is DWT.UP) {
+                    doSelectionPageUp(autoScrollDistance);
+                    display.timerExec(V_SCROLL_RATE, this);
+                }
+            }
+        };
+        autoScrollDirection = direction;
+        display.timerExec(V_SCROLL_RATE, timer);
+    } else if (direction is DWT.DOWN) {
+        timer = new Runnable() {
+            public void run() {
+                if (autoScrollDirection is DWT.DOWN) {
+                    doSelectionPageDown(autoScrollDistance);
+                    display.timerExec(V_SCROLL_RATE, this);
+                }
+            }
+        };
+        autoScrollDirection = direction;
+        display.timerExec(V_SCROLL_RATE, timer);
+    } else if (direction is ST.COLUMN_NEXT) {
+        timer = new Runnable() {
+            public void run() {
+                if (autoScrollDirection is ST.COLUMN_NEXT) {
+                    doVisualNext();
+                    setMouseWordSelectionAnchor();
+                    doMouseSelection();
+                    display.timerExec(H_SCROLL_RATE, this);
+                }
+            }
+        };
+        autoScrollDirection = direction;
+        display.timerExec(H_SCROLL_RATE, timer);
+    } else if (direction is ST.COLUMN_PREVIOUS) {
+        timer = new Runnable() {
+            public void run() {
+                if (autoScrollDirection is ST.COLUMN_PREVIOUS) {
+                    doVisualPrevious();
+                    setMouseWordSelectionAnchor();
+                    doMouseSelection();
+                    display.timerExec(H_SCROLL_RATE, this);
+                }
+            }
+        };
+        autoScrollDirection = direction;
+        display.timerExec(H_SCROLL_RATE, timer);
+    }
+}
+/**
+ * Deletes the previous character. Delete the selected text if any.
+ * Move the caret in front of the deleted text.
+ */
+void doBackspace() {
+    Event event = new Event();
+    event.text = "";
+    if (selection.x !is selection.y) {
+        event.start = selection.x;
+        event.end = selection.y;
+        sendKeyEvent(event);
+    } else if (caretOffset > 0) {
+        int lineIndex = content.getLineAtOffset(caretOffset);
+        int lineOffset = content.getOffsetAtLine(lineIndex);
+        if (caretOffset is lineOffset) {
+            lineOffset = content.getOffsetAtLine(lineIndex - 1);
+            event.start = lineOffset + content.getLine(lineIndex - 1).length();
+            event.end = caretOffset;
+        } else {
+            TextLayout layout = renderer.getTextLayout(lineIndex);
+            int start = layout.getPreviousOffset(caretOffset - lineOffset, DWT.MOVEMENT_CHAR);
+            renderer.disposeTextLayout(layout); 
+            event.start = start + lineOffset;
+            event.end = caretOffset;
+        }
+        sendKeyEvent(event);
+    }
+}
+/**
+ * Replaces the selection with the character or insert the character at the 
+ * current caret position if no selection exists.
+ * <p>
+ * If a carriage return was typed replace it with the line break character 
+ * used by the widget on this platform.
+ * </p>
+ *
+ * @param key the character typed by the user
+ */
+void doContent(char key) {
+    Event event = new Event();
+    event.start = selection.x;
+    event.end = selection.y;
+    // replace a CR line break with the widget line break
+    // CR does not make sense on Windows since most (all?) applications
+    // don't recognize CR as a line break.
+    if (key is DWT.CR || key is DWT.LF) {
+        if (!isSingleLine()) {
+            event.text = getLineDelimiter();
+        }
+    } else if (selection.x is selection.y && overwrite && key !is TAB) {
+        // no selection and overwrite mode is on and the typed key is not a
+        // tab character (tabs are always inserted without overwriting)?    
+        int lineIndex = content.getLineAtOffset(event.end);
+        int lineOffset = content.getOffsetAtLine(lineIndex);
+        String line = content.getLine(lineIndex);
+        // replace character at caret offset if the caret is not at the 
+        // end of the line
+        if (event.end < lineOffset + line.length()) {
+            event.end++;
+        }
+        event.text = new String(new char[] {key});
+    } else {
+        event.text = new String(new char[] {key});
+    }
+    if (event.text !is null) {
+        if (textLimit > 0 && content.getCharCount() - (event.end - event.start) >= textLimit) {
+            return;
+        }
+        sendKeyEvent(event);
+    }
+}
+/**
+ * Moves the caret after the last character of the widget content.
+ */
+void doContentEnd() {
+    // place caret at end of first line if receiver is in single 
+    // line mode. fixes 4820.
+    if (isSingleLine()) {
+        doLineEnd();
+    } else {
+        int length = content.getCharCount();        
+        if (caretOffset < length) {
+            caretOffset = length;
+            showCaret();
+        }
+    }
+}
+/**
+ * Moves the caret in front of the first character of the widget content.
+ */
+void doContentStart() {
+    if (caretOffset > 0) {
+        caretOffset = 0;
+        showCaret();
+    }
+}
+/**
+ * Moves the caret to the start of the selection if a selection exists.
+ * Otherwise, if no selection exists move the cursor according to the 
+ * cursor selection rules.
+ *
+ * @see #doSelectionCursorPrevious
+ */
+void doCursorPrevious() {
+    if (selection.y - selection.x > 0) {
+        caretOffset = selection.x;
+        caretAlignment = OFFSET_LEADING;
+        showCaret();
+    } else {
+        doSelectionCursorPrevious();
+    }
+}
+/**
+ * Moves the caret to the end of the selection if a selection exists.
+ * Otherwise, if no selection exists move the cursor according to the 
+ * cursor selection rules.
+ *
+ * @see #doSelectionCursorNext
+ */
+void doCursorNext() {
+    if (selection.y - selection.x > 0) {
+        caretOffset = selection.y;
+        caretAlignment = PREVIOUS_OFFSET_TRAILING;
+        showCaret();
+    } else {
+        doSelectionCursorNext();
+    }
+}
+/**
+ * Deletes the next character. Delete the selected text if any.
+ */
+void doDelete() {
+    Event event = new Event();
+    event.text = "";
+    if (selection.x !is selection.y) {
+        event.start = selection.x;
+        event.end = selection.y;
+        sendKeyEvent(event);
+    } else if (caretOffset < content.getCharCount()) {
+        int line = content.getLineAtOffset(caretOffset);
+        int lineOffset = content.getOffsetAtLine(line);
+        int lineLength = content.getLine(line).length();
+        if (caretOffset is lineOffset + lineLength) {
+            event.start = caretOffset;
+            event.end = content.getOffsetAtLine(line + 1);
+        } else {
+            event.start = caretOffset;
+            event.end = getClusterNext(caretOffset, line);
+        }
+        sendKeyEvent(event);
+    }
+}
+/**
+ * Deletes the next word.
+ */
+void doDeleteWordNext() {
+    if (selection.x !is selection.y) {
+        // if a selection exists, treat the as if 
+        // only the delete key was pressed
+        doDelete();
+    } else {
+        Event event = new Event();
+        event.text = "";
+        event.start = caretOffset;
+        event.end = getWordNext(caretOffset, DWT.MOVEMENT_WORD);
+        sendKeyEvent(event);
+    }
+}
+/**
+ * Deletes the previous word.
+ */
+void doDeleteWordPrevious() {
+    if (selection.x !is selection.y) {
+        // if a selection exists, treat as if 
+        // only the backspace key was pressed
+        doBackspace();
+    } else {
+        Event event = new Event();
+        event.text = "";
+        event.start = getWordPrevious(caretOffset, DWT.MOVEMENT_WORD);
+        event.end = caretOffset;
+        sendKeyEvent(event);
+    }
+}
+/**
+ * Moves the caret one line down and to the same character offset relative 
+ * to the beginning of the line. Move the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ */
+void doLineDown(bool select) {
+    int caretLine = getCaretLine();
+    int lineCount = content.getLineCount();
+    int y = 0;
+    bool lastLine = false;
+    if (wordWrap) {
+        int lineOffset = content.getOffsetAtLine(caretLine);
+        int offsetInLine = caretOffset - lineOffset;
+        TextLayout layout = renderer.getTextLayout(caretLine);
+        int lineIndex = getVisualLineIndex(layout, offsetInLine);
+        int layoutLineCount = layout.getLineCount();
+        if (lineIndex is layoutLineCount - 1) {
+            lastLine = caretLine is lineCount - 1;
+            caretLine++;
+        } else {
+            y = layout.getLineBounds(lineIndex + 1).y;
+        }
+        renderer.disposeTextLayout(layout);
+    } else {
+        lastLine = caretLine is lineCount - 1;
+        caretLine++;
+    }
+    if (lastLine) {
+        if (select) caretOffset = content.getCharCount();
+    } else {
+        caretOffset = getOffsetAtPoint(columnX, y, caretLine);
+    }
+    int oldColumnX = columnX;
+    int oldHScrollOffset = horizontalScrollOffset;
+    if (select) {
+        setMouseWordSelectionAnchor();  
+        // select first and then scroll to reduce flash when key 
+        // repeat scrolls lots of lines
+        doSelection(ST.COLUMN_NEXT);
+    }
+    showCaret();
+    int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+    columnX = oldColumnX + hScrollChange;
+}
+/**
+ * Moves the caret to the end of the line.
+ */
+void doLineEnd() {
+    int caretLine = getCaretLine();
+    int lineOffset = content.getOffsetAtLine(caretLine);    
+    int lineEndOffset;
+    if (wordWrap) {
+        TextLayout layout = renderer.getTextLayout(caretLine);
+        int offsetInLine = caretOffset - lineOffset;
+        int lineIndex = getVisualLineIndex(layout, offsetInLine);
+        int[] offsets = layout.getLineOffsets();
+        lineEndOffset = lineOffset + offsets[lineIndex + 1];
+        renderer.disposeTextLayout(layout);
+    } else {
+        int lineLength = content.getLine(caretLine).length();
+        lineEndOffset = lineOffset + lineLength;
+    }
+    if (caretOffset < lineEndOffset) {
+        caretOffset = lineEndOffset;
+        caretAlignment = PREVIOUS_OFFSET_TRAILING;
+        showCaret();
+    }
+}
+/**
+ * Moves the caret to the beginning of the line.
+ */
+void doLineStart() {
+    int caretLine = getCaretLine();
+    int lineOffset = content.getOffsetAtLine(caretLine);
+    if (wordWrap) {
+        TextLayout layout = renderer.getTextLayout(caretLine);
+        int offsetInLine = caretOffset - lineOffset;
+        int lineIndex = getVisualLineIndex(layout, offsetInLine);
+        int[] offsets = layout.getLineOffsets();
+        lineOffset += offsets[lineIndex];
+        renderer.disposeTextLayout(layout);
+    }
+    if (caretOffset > lineOffset) {
+        caretOffset = lineOffset;
+        caretAlignment = OFFSET_LEADING;
+        showCaret();
+    }
+}
+/**
+ * Moves the caret one line up and to the same character offset relative 
+ * to the beginning of the line. Move the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ */
+void doLineUp(bool select) {
+    int caretLine = getCaretLine(), y = 0;
+    bool firstLine = false;
+    if (wordWrap) {
+        int lineOffset = content.getOffsetAtLine(caretLine);
+        int offsetInLine = caretOffset - lineOffset;
+        TextLayout layout = renderer.getTextLayout(caretLine);
+        int lineIndex = getVisualLineIndex(layout, offsetInLine);
+        if (lineIndex is 0) {
+            firstLine = caretLine is 0;
+            if (!firstLine) {
+                caretLine--;
+                y = renderer.getLineHeight(caretLine) - 1;
+            }
+        } else {
+            y = layout.getLineBounds(lineIndex - 1).y;
+        }
+        renderer.disposeTextLayout(layout);
+    } else {
+        firstLine = caretLine is 0;
+        caretLine--;
+    }
+    if (firstLine) {
+        if (select) caretOffset = 0;
+    } else {
+        caretOffset = getOffsetAtPoint(columnX, y, caretLine);
+    }
+    int oldColumnX = columnX;
+    int oldHScrollOffset = horizontalScrollOffset;
+    if (select) setMouseWordSelectionAnchor();
+    showCaret();
+    if (select) doSelection(ST.COLUMN_PREVIOUS);
+    int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+    columnX = oldColumnX + hScrollChange;
+}
+/**
+ * Moves the caret to the specified location.
+ *
+ * @param x x location of the new caret position
+ * @param y y location of the new caret position
+ * @param select the location change is a selection operation.
+ *  include the line delimiter in the selection
+ */
+void doMouseLocationChange(int x, int y, bool select) {
+    int line = getLineIndex(y);
+
+    updateCaretDirection = true;
+    // allow caret to be placed below first line only if receiver is 
+    // not in single line mode. fixes 4820.
+    if (line < 0 || (isSingleLine() && line > 0)) {
+        return;
+    }
+    int oldCaretAlignment = caretAlignment;
+    int newCaretOffset = getOffsetAtPoint(x, y);
+    
+    if (doubleClickEnabled && clickCount > 1) {
+        newCaretOffset = doMouseWordSelect(x, newCaretOffset, line);
+    }
+    
+    int newCaretLine = content.getLineAtOffset(newCaretOffset);
+    
+    // Is the mouse within the left client area border or on 
+    // a different line? If not the autoscroll selection 
+    // could be incorrectly reset. Fixes 1GKM3XS
+    if (0 <= y && y < clientAreaHeight && 
+        (0 <= x && x < clientAreaWidth || wordWrap ||   
+        newCaretLine !is content.getLineAtOffset(caretOffset))) {
+        if (newCaretOffset !is caretOffset || caretAlignment !is oldCaretAlignment) {
+            caretOffset = newCaretOffset;
+            if (select) doMouseSelection();
+            showCaret();
+        }
+    }
+    if (!select) {
+        caretOffset = newCaretOffset;
+        clearSelection(true);
+    }
+}
+/**
+ * Updates the selection based on the caret position
+ */
+void doMouseSelection() {
+    if (caretOffset <= selection.x || 
+        (caretOffset > selection.x && 
+         caretOffset < selection.y && selectionAnchor is selection.x)) {
+        doSelection(ST.COLUMN_PREVIOUS);
+    } else {
+        doSelection(ST.COLUMN_NEXT);
+    }
+}
+/**
+ * Returns the offset of the word at the specified offset. 
+ * If the current selection : from high index to low index 
+ * (i.e., right to left, or caret is at left border of selection on 
+ * non-bidi platforms) the start offset of the word preceding the
+ * selection is returned. If the current selection : from 
+ * low index to high index the end offset of the word following 
+ * the selection is returned.
+ * 
+ * @param x mouse x location
+ * @param newCaretOffset caret offset of the mouse cursor location
+ * @param line line index of the mouse cursor location
+ */
+int doMouseWordSelect(int x, int newCaretOffset, int line) {
+    // flip selection anchor based on word selection direction from 
+    // base double click. Always do this here (and don't rely on doAutoScroll)
+    // because auto scroll only does not cover all possible mouse selections
+    // (e.g., mouse x < 0 && mouse y > caret line y)
+    if (newCaretOffset < selectionAnchor && selectionAnchor is selection.x) {
+        selectionAnchor = doubleClickSelection.y;
+    } else if (newCaretOffset > selectionAnchor && selectionAnchor is selection.y) {
+        selectionAnchor = doubleClickSelection.x;
+    }
+    if (0 <= x && x < clientAreaWidth) {
+        bool wordSelect = (clickCount & 1) is 0;
+        if (caretOffset is selection.x) {
+            if (wordSelect) {
+                newCaretOffset = getWordPrevious(newCaretOffset, DWT.MOVEMENT_WORD_START);
+            } else {
+                newCaretOffset = content.getOffsetAtLine(line);
+            }
+        } else {
+            if (wordSelect) {
+                newCaretOffset = getWordNext(newCaretOffset, DWT.MOVEMENT_WORD_END);
+            } else {
+                int lineEnd = content.getCharCount();
+                if (line + 1 < content.getLineCount()) {
+                    lineEnd = content.getOffsetAtLine(line + 1);
+                }
+                newCaretOffset = lineEnd; 
+            }
+        }
+    }
+    return newCaretOffset;
+}
+/**
+ * Scrolls one page down so that the last line (truncated or whole)
+ * of the current page becomes the fully visible top line.
+ * <p>
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the end 
+ * of the text where a full page scroll is not possible. In this case 
+ * the caret is moved after the last character.
+ * </p>
+ *
+ * @param select whether or not to select the page
+ */
+void doPageDown(bool select, int height) {
+    if (isSingleLine()) return;
+    int oldColumnX = columnX;
+    int oldHScrollOffset = horizontalScrollOffset;
+    if (isFixedLineHeight()) {
+        int lineCount = content.getLineCount();
+        int caretLine = getCaretLine();
+        if (caretLine < lineCount - 1) {
+            int lineHeight = renderer.getLineHeight();
+            int lines = (height is -1 ? clientAreaHeight : height) / lineHeight;
+            int scrollLines = Math.min(lineCount - caretLine - 1, lines);
+            // ensure that scrollLines never gets negative and at least one 
+            // line is scrolled. fixes bug 5602.
+            scrollLines = Math.max(1, scrollLines);
+            caretOffset = getOffsetAtPoint(columnX, getLinePixel(caretLine + scrollLines));
+            if (select) {
+                doSelection(ST.COLUMN_NEXT);
+            }
+            // scroll one page down or to the bottom
+            int verticalMaximum = lineCount * getVerticalIncrement();
+            int pageSize = clientAreaHeight;
+            int verticalScrollOffset = getVerticalScrollOffset();
+            int scrollOffset = verticalScrollOffset + scrollLines * getVerticalIncrement();
+            if (scrollOffset + pageSize > verticalMaximum) {
+                scrollOffset = verticalMaximum - pageSize;
+            }
+            if (scrollOffset > verticalScrollOffset) {
+                scrollVertical(scrollOffset - verticalScrollOffset, true);
+            }
+        }
+    } else {
+        int lineCount = content.getLineCount();
+        int caretLine = getCaretLine();
+        int lineIndex, lineHeight;
+        if (height is -1) {
+            lineIndex = getPartialBottomIndex();
+            int topY = getLinePixel(lineIndex);
+            lineHeight = renderer.getLineHeight(lineIndex);
+            height = topY;
+            if (topY + lineHeight <= clientAreaHeight) {
+                height += lineHeight;
+            } else {
+                if (wordWrap) {
+                    TextLayout layout = renderer.getTextLayout(lineIndex);
+                    int y = clientAreaHeight - topY;
+                    for (int i = 0; i < layout.getLineCount(); i++) {
+                        Rectangle bounds = layout.getLineBounds(i);
+                        if (bounds.contains(bounds.x, y)) {
+                            height += bounds.y;
+                            break;
+                        }
+                    }
+                    renderer.disposeTextLayout(layout);
+                }
+            }
+        } else {
+            lineIndex = getLineIndex(height);
+            int topLineY = getLinePixel(lineIndex);
+            if (wordWrap) {
+                TextLayout layout = renderer.getTextLayout(lineIndex);
+                int y = height - topLineY;
+                for (int i = 0; i < layout.getLineCount(); i++) {
+                    Rectangle bounds = layout.getLineBounds(i);
+                    if (bounds.contains(bounds.x, y)) {
+                        height = topLineY + bounds.y + bounds.height;
+                        break;
+                    }
+                }
+                renderer.disposeTextLayout(layout);
+            } else {
+                height = topLineY + renderer.getLineHeight(lineIndex);
+            }
+        }
+        int caretHeight = height;
+        if (wordWrap) {
+            TextLayout layout = renderer.getTextLayout(caretLine);
+            int offsetInLine = caretOffset - content.getOffsetAtLine(caretLine);
+            lineIndex = getVisualLineIndex(layout, offsetInLine);
+            caretHeight += layout.getLineBounds(lineIndex).y;
+            renderer.disposeTextLayout(layout);
+        }
+        lineIndex = caretLine;
+        lineHeight = renderer.getLineHeight(lineIndex);
+        while (caretHeight - lineHeight >= 0 && lineIndex < lineCount - 1) {
+            caretHeight -= lineHeight;
+            lineHeight = renderer.getLineHeight(++lineIndex);
+        }
+        caretOffset = getOffsetAtPoint(columnX, caretHeight, lineIndex);
+        if (select) doSelection(ST.COLUMN_NEXT);
+        height = getAvailableHeightBellow(height);
+        scrollVertical(height, true);
+        if (height is 0) setCaretLocation();
+    }   
+    showCaret();
+    int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+    columnX = oldColumnX + hScrollChange;   
+}
+/**
+ * Moves the cursor to the end of the last fully visible line.
+ */
+void doPageEnd() {
+    // go to end of line if in single line mode. fixes 5673
+    if (isSingleLine()) {
+        doLineEnd();
+    } else {
+        int bottomOffset;
+        if (wordWrap) {
+            int lineIndex = getPartialBottomIndex();
+            TextLayout layout = renderer.getTextLayout(lineIndex);
+            int y = (clientAreaHeight - bottomMargin) - getLinePixel(lineIndex);
+            int index = layout.getLineCount() - 1;
+            while (index >= 0) {
+                Rectangle bounds = layout.getLineBounds(index);
+                if (y >= bounds.y + bounds.height) break;
+                index--;
+            }
+            if (index is -1 && lineIndex > 0) {
+                bottomOffset = content.getOffsetAtLine(lineIndex - 1) + content.getLine(lineIndex - 1).length();
+            } else {
+                bottomOffset = content.getOffsetAtLine(lineIndex) + Math.max(0, layout.getLineOffsets()[index + 1] - 1);
+            }
+            renderer.disposeTextLayout(layout);
+        } else {
+            int lineIndex = getBottomIndex();
+            bottomOffset = content.getOffsetAtLine(lineIndex) + content.getLine(lineIndex).length();
+        }
+        if (caretOffset < bottomOffset) {
+            caretOffset = bottomOffset;
+            caretAlignment = OFFSET_LEADING;
+            showCaret();
+        }
+    }
+}
+/**
+ * Moves the cursor to the beginning of the first fully visible line.
+ */
+void doPageStart() {
+    int topOffset;
+    if (wordWrap) {
+        int y, lineIndex;
+        if (topIndexY > 0) {
+            lineIndex = topIndex - 1;
+            y = renderer.getLineHeight(lineIndex) - topIndexY;
+        } else {
+            lineIndex = topIndex;
+            y = -topIndexY;
+        }
+        TextLayout layout = renderer.getTextLayout(lineIndex);
+        int index = 0;
+        int lineCount = layout.getLineCount();
+        while (index < lineCount) {
+            Rectangle bounds = layout.getLineBounds(index);
+            if (y <= bounds.y) break;
+            index++;
+        }
+        if (index is lineCount) {
+            topOffset = content.getOffsetAtLine(lineIndex + 1);
+        } else {
+            topOffset = content.getOffsetAtLine(lineIndex) + layout.getLineOffsets()[index];
+        }
+        renderer.disposeTextLayout(layout);     
+    } else {
+        topOffset = content.getOffsetAtLine(topIndex);
+    }
+    if (caretOffset > topOffset) {
+        caretOffset = topOffset;
+        caretAlignment = OFFSET_LEADING;
+        showCaret();
+    }
+}
+/**
+ * Scrolls one page up so that the first line (truncated or whole)
+ * of the current page becomes the fully visible last line.
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the beginning 
+ * of the text where a full page scroll is not possible. In this case the
+ * caret is moved in front of the first character.
+ */
+void doPageUp(bool select, int height) {
+    if (isSingleLine()) return;
+    int oldHScrollOffset = horizontalScrollOffset;
+    int oldColumnX = columnX;   
+    if (isFixedLineHeight()) {
+        int caretLine = getCaretLine(); 
+        if (caretLine > 0) {
+            int lineHeight = renderer.getLineHeight();
+            int lines = (height is -1 ? clientAreaHeight : height) / lineHeight;
+            int scrollLines = Math.max(1, Math.min(caretLine, lines));
+            caretLine -= scrollLines;
+            caretOffset = getOffsetAtPoint(columnX, getLinePixel(caretLine));
+            if (select) {
+                doSelection(ST.COLUMN_PREVIOUS);
+            }
+            int verticalScrollOffset = getVerticalScrollOffset();
+            int scrollOffset = Math.max(0, verticalScrollOffset - scrollLines * getVerticalIncrement());
+            if (scrollOffset < verticalScrollOffset) {
+                scrollVertical(scrollOffset - verticalScrollOffset, true);
+            }
+        }
+    } else {
+        int caretLine = getCaretLine();
+        int lineHeight, lineIndex;
+        if (height is -1) {
+            if (topIndexY is 0) {
+                height = clientAreaHeight;
+            } else {
+                int y;
+                if (topIndex > 0) {
+                    lineIndex = topIndex - 1;
+                    lineHeight = renderer.getLineHeight(lineIndex);
+                    height = clientAreaHeight - topIndexY;
+                    y = lineHeight - topIndexY;
+                } else {
+                    lineIndex = topIndex;
+                    lineHeight = renderer.getLineHeight(lineIndex);
+                    height = clientAreaHeight - (lineHeight + topIndexY);
+                    y = -topIndexY;
+                }
+                if (wordWrap) {
+                    TextLayout layout = renderer.getTextLayout(lineIndex);
+                    for (int i = 0; i < layout.getLineCount(); i++) {
+                        Rectangle bounds = layout.getLineBounds(i);
+                        if (bounds.contains(bounds.x, y)) {
+                            height += lineHeight - (bounds.y + bounds.height);
+                            break;
+                        }
+                    }
+                    renderer.disposeTextLayout(layout);
+                }
+            }
+        } else {
+            lineIndex = getLineIndex(clientAreaHeight - height);
+            int topLineY = getLinePixel(lineIndex);
+            if (wordWrap) {
+                TextLayout layout = renderer.getTextLayout(lineIndex);
+                int y = topLineY;
+                for (int i = 0; i < layout.getLineCount(); i++) {
+                    Rectangle bounds = layout.getLineBounds(i);
+                    if (bounds.contains(bounds.x, y)) {
+                        height = clientAreaHeight - (topLineY + bounds.y);
+                        break;
+                    }
+                }
+                renderer.disposeTextLayout(layout);
+            } else {
+                height = clientAreaHeight - topLineY;
+            }
+        }
+        int caretHeight = height;
+        if (wordWrap) {
+            TextLayout layout = renderer.getTextLayout(caretLine);
+            int offsetInLine = caretOffset - content.getOffsetAtLine(caretLine);
+            lineIndex = getVisualLineIndex(layout, offsetInLine);
+            caretHeight += layout.getBounds().height - layout.getLineBounds(lineIndex).y;
+            renderer.disposeTextLayout(layout);
+        }
+        lineIndex = caretLine;
+        lineHeight = renderer.getLineHeight(lineIndex);
+        while (caretHeight - lineHeight >= 0 && lineIndex > 0) {
+            caretHeight -= lineHeight;
+            lineHeight = renderer.getLineHeight(--lineIndex);
+        }
+        lineHeight = renderer.getLineHeight(lineIndex);
+        caretOffset = getOffsetAtPoint(columnX, lineHeight - caretHeight, lineIndex);   
+        if (select) doSelection(ST.COLUMN_PREVIOUS);
+        height = getAvailableHeightAbove(height);
+        scrollVertical(-height, true);
+        if (height is 0) setCaretLocation();    
+    }
+    showCaret();
+    int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+    columnX = oldColumnX + hScrollChange;
+}
+/**
+ * Updates the selection to extend to the current caret position.
+ */
+void doSelection(int direction) {
+    int redrawStart = -1;
+    int redrawEnd = -1; 
+    if (selectionAnchor is -1) {
+        selectionAnchor = selection.x;
+    }   
+    if (direction is ST.COLUMN_PREVIOUS) {
+        if (caretOffset < selection.x) {
+            // grow selection
+            redrawEnd = selection.x; 
+            redrawStart = selection.x = caretOffset;        
+            // check if selection has reversed direction
+            if (selection.y !is selectionAnchor) {
+                redrawEnd = selection.y;
+                selection.y = selectionAnchor;
+            }
+        // test whether selection actually changed. Fixes 1G71EO1
+        } else if (selectionAnchor is selection.x && caretOffset < selection.y) {
+            // caret moved towards selection anchor (left side of selection). 
+            // shrink selection         
+            redrawEnd = selection.y;
+            redrawStart = selection.y = caretOffset;        
+        }
+    } else {
+        if (caretOffset > selection.y) {
+            // grow selection
+            redrawStart = selection.y;
+            redrawEnd = selection.y = caretOffset;
+            // check if selection has reversed direction
+            if (selection.x !is selectionAnchor) {
+                redrawStart = selection.x;              
+                selection.x = selectionAnchor;
+            }
+        // test whether selection actually changed. Fixes 1G71EO1   
+        } else if (selectionAnchor is selection.y && caretOffset > selection.x) {
+            // caret moved towards selection anchor (right side of selection). 
+            // shrink selection         
+            redrawStart = selection.x;
+            redrawEnd = selection.x = caretOffset;      
+        }
+    }
+    if (redrawStart !is -1 && redrawEnd !is -1) {
+        internalRedrawRange(redrawStart, redrawEnd - redrawStart);
+        sendSelectionEvent();
+    }
+}
+/**
+ * Moves the caret to the next character or to the beginning of the 
+ * next line if the cursor is at the end of a line.
+ */
+void doSelectionCursorNext() {
+    int caretLine = getCaretLine();
+    int lineOffset = content.getOffsetAtLine(caretLine);
+    int offsetInLine = caretOffset - lineOffset;
+    if (offsetInLine < content.getLine(caretLine).length()) {
+        TextLayout layout = renderer.getTextLayout(caretLine);
+        offsetInLine = layout.getNextOffset(offsetInLine, DWT.MOVEMENT_CLUSTER);
+        int lineStart = layout.getLineOffsets()[layout.getLineIndex(offsetInLine)];
+        renderer.disposeTextLayout(layout);
+        caretOffset = offsetInLine + lineOffset;
+        caretAlignment = offsetInLine is lineStart ? OFFSET_LEADING : PREVIOUS_OFFSET_TRAILING;
+        showCaret();
+    } else if (caretLine < content.getLineCount() - 1 && !isSingleLine()) {
+        caretLine++;        
+        caretOffset = content.getOffsetAtLine(caretLine);
+        caretAlignment = PREVIOUS_OFFSET_TRAILING;
+        showCaret();
+    }
+}
+/**
+ * Moves the caret to the previous character or to the end of the previous 
+ * line if the cursor is at the beginning of a line.
+ */
+void doSelectionCursorPrevious() {
+    int caretLine = getCaretLine();
+    int lineOffset = content.getOffsetAtLine(caretLine);
+    int offsetInLine = caretOffset - lineOffset;
+    caretAlignment = OFFSET_LEADING;
+    if (offsetInLine > 0) {
+        caretOffset = getClusterPrevious(caretOffset, caretLine);
+        showCaret();
+    } else if (caretLine > 0) {
+        caretLine--;
+        lineOffset = content.getOffsetAtLine(caretLine);
+        caretOffset = lineOffset + content.getLine(caretLine).length();
+        showCaret();
+    }
+}
+/**
+ * Moves the caret one line down and to the same character offset relative 
+ * to the beginning of the line. Moves the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ * Moves the caret to the end of the text if the caret already is on the 
+ * last line.
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ */
+void doSelectionLineDown() {
+    int oldColumnX = columnX = getPointAtOffset(caretOffset).x;
+    doLineDown(true);
+    columnX = oldColumnX;
+}
+/**
+ * Moves the caret one line up and to the same character offset relative 
+ * to the beginning of the line. Moves the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ * Moves the caret to the beginning of the document if it is already on the
+ * first line.
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ */
+void doSelectionLineUp() {
+    int oldColumnX = columnX = getPointAtOffset(caretOffset).x; 
+    doLineUp(true); 
+    columnX = oldColumnX;
+}
+/**
+ * Scrolls one page down so that the last line (truncated or whole)
+ * of the current page becomes the fully visible top line.
+ * <p>
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the end 
+ * of the text where a full page scroll is not possible. In this case 
+ * the caret is moved after the last character.
+ * <p></p>
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ * </p>
+ */
+void doSelectionPageDown(int pixels) {
+    int oldColumnX = columnX = getPointAtOffset(caretOffset).x;
+    doPageDown(true, pixels);
+    columnX = oldColumnX;
+}
+/**
+ * Scrolls one page up so that the first line (truncated or whole)
+ * of the current page becomes the fully visible last line.
+ * <p>
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the beginning 
+ * of the text where a full page scroll is not possible. In this case the
+ * caret is moved in front of the first character.
+ * </p><p>
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ * </p>
+ */
+void doSelectionPageUp(int pixels) {
+    int oldColumnX = columnX = getPointAtOffset(caretOffset).x;
+    doPageUp(true, pixels);
+    columnX = oldColumnX;
+}
+/**
+ * Moves the caret to the end of the next word .
+ */
+void doSelectionWordNext() {
+    int newCaretOffset = getWordNext(caretOffset, DWT.MOVEMENT_WORD);
+    // Force symmetrical movement for word next and previous. Fixes 14536
+    caretAlignment = OFFSET_LEADING;
+    // don't change caret position if in single line mode and the cursor 
+    // would be on a different line. fixes 5673
+    if (!isSingleLine() || 
+        content.getLineAtOffset(caretOffset) is content.getLineAtOffset(newCaretOffset)) {
+        caretOffset = newCaretOffset;
+        showCaret();
+    }
+}
+/**
+ * Moves the caret to the start of the previous word.
+ */
+void doSelectionWordPrevious() {
+    caretAlignment = OFFSET_LEADING;
+    caretOffset = getWordPrevious(caretOffset, DWT.MOVEMENT_WORD);
+    int caretLine = content.getLineAtOffset(caretOffset);
+    // word previous always comes from bottom line. when
+    // wrapping lines, stay on bottom line when on line boundary
+    if (wordWrap && caretLine < content.getLineCount() - 1 &&
+        caretOffset is content.getOffsetAtLine(caretLine + 1)) {
+        caretLine++;
+    }
+    showCaret();
+}
+/**
+ * Moves the caret one character to the left.  Do not go to the previous line.
+ * When in a bidi locale and at a R2L character the caret is moved to the 
+ * beginning of the R2L segment (visually right) and then one character to the 
+ * left (visually left because it's now in a L2R segment).
+ */
+void doVisualPrevious() {
+    caretOffset = getClusterPrevious(caretOffset, getCaretLine());
+    showCaret();
+}
+/**
+ * Moves the caret one character to the right.  Do not go to the next line.
+ * When in a bidi locale and at a R2L character the caret is moved to the 
+ * end of the R2L segment (visually left) and then one character to the 
+ * right (visually right because it's now in a L2R segment).
+ */
+void doVisualNext() {
+    caretOffset = getClusterNext(caretOffset, getCaretLine());
+    showCaret();
+}
+/**
+ * Moves the caret to the end of the next word.
+ * If a selection exists, move the caret to the end of the selection
+ * and remove the selection.
+ */
+void doWordNext() {
+    if (selection.y - selection.x > 0) {
+        caretOffset = selection.y;
+        showCaret();
+    } else {
+        doSelectionWordNext();
+    }
+}
+/**
+ * Moves the caret to the start of the previous word.
+ * If a selection exists, move the caret to the start of the selection
+ * and remove the selection.
+ */
+void doWordPrevious() {
+    if (selection.y - selection.x > 0) {
+        caretOffset = selection.x;
+        showCaret();
+    } else {
+        doSelectionWordPrevious();
+    }
+}
+/** 
+ * Ends the autoscroll process.
+ */
+void endAutoScroll() {
+    autoScrollDirection = DWT.NULL;
+}
+public Color getBackground() {
+    checkWidget();
+    if (background is null) {
+        return getDisplay().getSystemColor(DWT.COLOR_LIST_BACKGROUND);
+    }
+    return background;
+}
+/**
+ * Returns the baseline, in pixels.
+ *  
+ * Note: this API should not be used if a StyleRange attribute causes lines to 
+ * have different heights (i.e. different fonts, rise, etc). 
+ *
+ * @return baseline the baseline
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 3.0
+ * 
+ * @see #getBaseline(int)
+ */
+public int getBaseline() {
+    checkWidget();
+    return renderer.getBaseline();
+}
+/**
+ * Returns the baseline at the given offset, in pixels. 
+ *
+ * @param offset the offset
+ * 
+ * @return baseline the baseline
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul>
+ *  
+ * @since 3.2
+ */
+public int getBaseline(int offset) {
+    checkWidget();
+    if (!(0 <= offset && offset <= content.getCharCount())) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    if (isFixedLineHeight()) {
+        return renderer.getBaseline();
+    }
+    int lineIndex = content.getLineAtOffset(offset);
+    int lineOffset = content.getOffsetAtLine(lineIndex);
+    TextLayout layout = renderer.getTextLayout(lineIndex);
+    int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length()));
+    FontMetrics metrics = layout.getLineMetrics(lineInParagraph);
+    renderer.disposeTextLayout(layout);
+    return metrics.getAscent() + metrics.getLeading();
+}
+/**
+ * Gets the BIDI coloring mode.  When true the BIDI text display
+ * algorithm is applied to segments of text that are the same
+ * color.
+ *
+ * @return the current coloring mode
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated use BidiSegmentListener instead.
+ */
+public bool getBidiColoring() {
+    checkWidget();
+    return bidiColoring;
+}
+/** 
+ * Returns the index of the last fully visible line.
+ *
+ * @return index of the last fully visible line.
+ */
+int getBottomIndex() {
+    int bottomIndex;
+    if (isFixedLineHeight()) {
+        int lineCount = 1;
+        int lineHeight = renderer.getLineHeight();
+        if (lineHeight !is 0) {
+            // calculate the number of lines that are fully visible
+            int partialTopLineHeight = topIndex * lineHeight - getVerticalScrollOffset();
+            lineCount = (clientAreaHeight - partialTopLineHeight) / lineHeight;
+        }
+        bottomIndex = Math.min(content.getLineCount() - 1, topIndex + Math.max(0, lineCount - 1));
+    } else {
+        int clientAreaHeight = this.clientAreaHeight - bottomMargin;
+        bottomIndex = getLineIndex(clientAreaHeight);
+        if (bottomIndex > 0) {
+            int linePixel = getLinePixel(bottomIndex);
+            int lineHeight = renderer.getLineHeight(bottomIndex);
+            if (linePixel + lineHeight > clientAreaHeight) {
+                if (getLinePixel(bottomIndex - 1) >= topMargin) {
+                    bottomIndex--;
+                }
+            }
+        }
+    }
+    return bottomIndex;
+}
+Rectangle getBoundsAtOffset(int offset) {
+    int lineIndex = content.getLineAtOffset(offset);
+    int lineOffset = content.getOffsetAtLine(lineIndex);
+    String line = content.getLine(lineIndex);
+    Rectangle bounds;
+    if (line.length() !is 0) {
+        int offsetInLine = offset - lineOffset;
+        TextLayout layout = renderer.getTextLayout(lineIndex);
+        bounds = layout.getBounds(offsetInLine, offsetInLine);
+        renderer.disposeTextLayout(layout);
+    } else {
+        bounds = new Rectangle (0, 0, 0, renderer.getLineHeight());
+    }
+    if (offset is caretOffset) {
+        int lineEnd = lineOffset + line.length();
+        if (offset is lineEnd && caretAlignment is PREVIOUS_OFFSET_TRAILING) {
+            bounds.width += getCaretWidth();
+        }
+    }
+    bounds.x += leftMargin - horizontalScrollOffset;
+    bounds.y += getLinePixel(lineIndex);
+    return bounds;
+}
+/**
+ * Returns the caret position relative to the start of the text.
+ *
+ * @return the caret position relative to the start of the text.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretOffset() {
+    checkWidget();
+    return caretOffset;
+}
+/**
+ * Returns the caret width.
+ *
+ * @return the caret width, 0 if caret is null.
+ */
+int getCaretWidth() {
+    Caret caret = getCaret();
+    if (caret is null) return 0;
+    return caret.getSize().x;
+}
+Object getClipboardContent(int clipboardType) {
+    TextTransfer plainTextTransfer = TextTransfer.getInstance();
+    return clipboard.getContents(plainTextTransfer, clipboardType);
+}
+int getClusterNext(int offset, int lineIndex) {
+    int lineOffset = content.getOffsetAtLine(lineIndex);    
+    TextLayout layout = renderer.getTextLayout(lineIndex);
+    offset -= lineOffset;
+    offset = layout.getNextOffset(offset, DWT.MOVEMENT_CLUSTER);
+    offset += lineOffset;
+    renderer.disposeTextLayout(layout);
+    return offset;
+}
+int getClusterPrevious(int offset, int lineIndex) {
+    int lineOffset = content.getOffsetAtLine(lineIndex);    
+    TextLayout layout = renderer.getTextLayout(lineIndex);
+    offset -= lineOffset;
+    offset = layout.getPreviousOffset(offset, DWT.MOVEMENT_CLUSTER);
+    offset += lineOffset;
+    renderer.disposeTextLayout(layout);
+    return offset;
+}
+/**
+ * Returns the content implementation that is used for text storage.
+ * 
+ * @return content the user defined content implementation that is used for
+ * text storage or the default content implementation if no user defined 
+ * content implementation has been set.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public StyledTextContent getContent() {
+    checkWidget();
+    return content;
+}
+public bool getDragDetect () {
+    checkWidget ();
+    return dragDetect;
+}
+/** 
+ * Returns whether the widget : double click mouse behavior.
+ *
+ * @return true if double clicking a word selects the word, false if double clicks
+ * have the same effect as regular mouse clicks
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getDoubleClickEnabled() {
+    checkWidget();
+    return doubleClickEnabled;
+}
+/**
+ * Returns whether the widget content can be edited.
+ *
+ * @return true if content can be edited, false otherwise
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getEditable() {
+    checkWidget();
+    return editable;
+}
+public Color getForeground() {
+    checkWidget();
+    if (foreground is null) {
+        return getDisplay().getSystemColor(DWT.COLOR_LIST_FOREGROUND);
+    }
+    return foreground;
+}
+/** 
+ * Returns the horizontal scroll increment.
+ *
+ * @return horizontal scroll increment.
+ */
+int getHorizontalIncrement() {  
+    return renderer.averageCharWidth;
+}
+/** 
+ * Returns the horizontal scroll offset relative to the start of the line.
+ *
+ * @return horizontal scroll offset relative to the start of the line,
+ * measured in character increments starting at 0, if > 0 the content is scrolled
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHorizontalIndex() {
+    checkWidget();
+    return horizontalScrollOffset / getHorizontalIncrement();
+}
+/** 
+ * Returns the horizontal scroll offset relative to the start of the line.
+ *
+ * @return the horizontal scroll offset relative to the start of the line,
+ * measured in pixel starting at 0, if > 0 the content is scrolled.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHorizontalPixel() {
+    checkWidget();
+    return horizontalScrollOffset;
+}
+/**
+ * Returns the line indentation of the widget.
+ * 
+ * @return the line indentation
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see #getLineIndent(int)
+ * 
+ * @since 3.2
+ */
+public int getIndent() {
+    checkWidget();
+    return indent;
+}
+/**
+ * Returns whether the widget justifies lines.
+ * 
+ * @return whether lines are justified
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see #getLineJustify(int)
+ * 
+ * @since 3.2
+ */
+public bool getJustify() {
+    checkWidget();
+    return justify;
+}
+/** 
+ * Returns the action assigned to the key.
+ * Returns DWT.NULL if there is no action associated with the key.
+ *
+ * @param key a key code defined in DWT.java or a character. 
+ *  Optionally ORd with a state mask.  Preferred state masks are one or more of
+ *  DWT.MOD1, DWT.MOD2, DWT.MOD3, since these masks account for modifier platform 
+ *  differences.  However, there may be cases where using the specific state masks
+ *  (i.e., DWT.CTRL, DWT.SHIFT, DWT.ALT, DWT.COMMAND) makes sense.
+ * @return one of the predefined actions defined in ST.java or DWT.NULL 
+ *  if there is no action associated with the key.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getKeyBinding(int key) {
+    checkWidget();
+    Integer action = (Integer) keyActionMap.get(new Integer(key));  
+    return action is null ? DWT.NULL : action.intValue();
+}
+/**
+ * Gets the number of characters.
+ *
+ * @return number of characters in the widget
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCharCount() {
+    checkWidget();
+    return content.getCharCount();
+}
+/**
+ * Returns the line at the given line index without delimiters.
+ * Index 0 is the first line of the content. When there are not
+ * any lines, getLine(0) is a valid call that answers an empty String.
+ * <p>
+ *
+ * @param lineIndex index of the line to return.
+ * @return the line text without delimiters
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the line index is outside the valid range (< 0 or >= getLineCount())</li> 
+ * </ul>
+ * @since 3.4
+ */
+public String getLine(int lineIndex) {
+    checkWidget();
+    if (lineIndex < 0 || 
+        (lineIndex > 0 && lineIndex >= content.getLineCount())) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);     
+    }
+    return content.getLine(lineIndex);
+}
+/**
+ * Returns the alignment of the line at the given index.
+ * 
+ * @param index the index of the line
+ * 
+ * @return the line alignment
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @see #getAlignment()
+ * 
+ * @since 3.2
+ */
+public int getLineAlignment(int index) {
+    checkWidget();
+    if (index < 0 || index > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    return renderer.getLineAlignment(index, alignment);
+}
+/**
+ * Returns the line at the specified offset in the text
+ * where 0 &lt; offset &lt; getCharCount() so that getLineAtOffset(getCharCount())
+ * returns the line of the insert location.
+ *
+ * @param offset offset relative to the start of the content. 
+ *  0 <= offset <= getCharCount()
+ * @return line at the specified offset in the text
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul>
+ */
+public int getLineAtOffset(int offset) {
+    checkWidget();  
+    if (offset < 0 || offset > getCharCount()) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);     
+    }
+    return content.getLineAtOffset(offset);
+}
+/**
+ * Returns the background color of the line at the given index.
+ * Returns null if a LineBackgroundListener has been set or if no background 
+ * color has been specified for the line. Should not be called if a
+ * LineBackgroundListener has been set since the listener maintains the
+ * line background colors.
+ * 
+ * @param index the index of the line
+ * @return the background color of the line at the given index.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ */
+public Color getLineBackground(int index) {
+    checkWidget();
+    if (index < 0 || index > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    return isListening(LineGetBackground) ? null : renderer.getLineBackground(index, null);
+}
+/**
+ * Returns the bullet of the line at the given index.
+ * 
+ * @param index the index of the line
+ * 
+ * @return the line bullet
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Bullet getLineBullet(int index) {
+    checkWidget();
+    if (index < 0 || index > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    return isListening(LineGetStyle) ? null : renderer.getLineBullet(index, null);
+}
+/**
+ * Returns the line background data for the given line or null if 
+ * there is none.
+ * 
+ * @param lineOffset offset of the line start relative to the start
+ *  of the content.
+ * @param line line to get line background data for
+ * @return line background data for the given line.
+ */
+StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
+    return sendLineEvent(LineGetBackground, lineOffset, line);
+}
+/** 
+ * Gets the number of text lines.
+ *
+ * @return the number of lines in the widget
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineCount() {
+    checkWidget();
+    return content.getLineCount();
+}
+/**
+ * Returns the number of lines that can be completely displayed in the 
+ * widget client area.
+ *
+ * @return number of lines that can be completely displayed in the widget 
+ *  client area.
+ */
+int getLineCountWhole() {
+    if (isFixedLineHeight()) {
+        int lineHeight = renderer.getLineHeight();
+        return lineHeight !is 0 ? clientAreaHeight / lineHeight : 1;
+    }
+    return getBottomIndex() - topIndex + 1;
+}
+/**
+ * Returns the line delimiter used for entering new lines by key down
+ * or paste operation.
+ *
+ * @return line delimiter used for entering new lines by key down
+ * or paste operation.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getLineDelimiter() {
+    checkWidget();
+    return content.getLineDelimiter();
+}
+/**
+ * Returns the line height.
+ * <p>
+ * Note: this API should not be used if a StyleRange attribute causes lines to 
+ * have different heights (i.e. different fonts, rise, etc).
+ * </p>
+ *
+ * @return line height in pixel.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @see #getLineHeight(int)
+ */
+public int getLineHeight() {
+    checkWidget();
+    return renderer.getLineHeight();
+}
+/**
+ * Returns the line height at the given offset.
+ *
+ * @param offset the offset
+ *  
+ * @return line height in pixels
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul> 
+ * 
+ * @since 3.2
+ */
+public int getLineHeight(int offset) {
+    checkWidget();
+    if (!(0 <= offset && offset <= content.getCharCount())) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    if (isFixedLineHeight()) {
+        return renderer.getLineHeight();
+    }
+    int lineIndex = content.getLineAtOffset(offset);
+    int lineOffset = content.getOffsetAtLine(lineIndex);
+    TextLayout layout = renderer.getTextLayout(lineIndex);
+    int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length()));
+    int height = layout.getLineBounds(lineInParagraph).height;
+    renderer.disposeTextLayout(layout);
+    return height;
+}
+/**
+ * Returns the indentation of the line at the given index.
+ * 
+ * @param index the index of the line
+ * 
+ * @return the line indentation
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @see #getIndent()
+ * 
+ * @since 3.2
+ */
+public int getLineIndent(int index) {
+    checkWidget();
+    if (index < 0 || index > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    return isListening(LineGetStyle) ? 0 : renderer.getLineIndent(index, indent);
+}
+/**
+ * Returns whether the line at the given index is justified.
+ * 
+ * @param index the index of the line
+ * 
+ * @return whether the line is justified 
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @see #getJustify()
+ * 
+ * @since 3.2
+ */
+public bool getLineJustify(int index) {
+    checkWidget();
+    if (index < 0 || index > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    return isListening(LineGetStyle) ? false : renderer.getLineJustify(index, justify); 
+}
+/**
+ * Returns the line spacing of the widget.
+ * 
+ * @return the line spacing
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public int getLineSpacing() {
+    checkWidget();
+    return lineSpacing;
+}
+/**
+ * Returns the line style data for the given line or null if there is 
+ * none.
+ * <p>
+ * If there is a LineStyleListener but it does not set any styles, 
+ * the StyledTextEvent.styles field will be initialized to an empty 
+ * array.
+ * </p>
+ * 
+ * @param lineOffset offset of the line start relative to the start of 
+ *  the content.
+ * @param line line to get line styles for
+ * @return line style data for the given line. Styles may start before 
+ *  line start and end after line end
+ */
+StyledTextEvent getLineStyleData(int lineOffset, String line) {
+    return sendLineEvent(LineGetStyle, lineOffset, line);
+}
+/**
+ * Returns the top pixel, relative to the client area, of a given line.
+ * Clamps out of ranges index.
+ *  
+ * @param lineIndex the line index, the max value is lineCount. If
+ * lineIndex is lineCount it returns the bottom pixel of the last line.
+ * It means this function can be used to retrieve the bottom pixel of any line. 
+ * 
+ * @since 3.2
+ */
+public int getLinePixel(int lineIndex) {
+    checkWidget();
+    int lineCount = content.getLineCount();
+    lineIndex = Math.max(0, Math.min(lineCount, lineIndex));
+    if (isFixedLineHeight()) {
+        int lineHeight = renderer.getLineHeight();
+        return lineIndex * lineHeight - getVerticalScrollOffset() + topMargin;
+    }
+    if (lineIndex is topIndex) return topIndexY + topMargin;
+    int height = topIndexY;
+    if (lineIndex > topIndex) {
+        for (int i = topIndex; i < lineIndex; i++) {
+            height += renderer.getLineHeight(i);
+        }
+    } else {
+        for (int i = topIndex - 1; i >= lineIndex; i--) {
+            height -= renderer.getLineHeight(i);
+        }
+    }
+    return height + topMargin;
+}
+/**
+ * Returns the line index for a y, relative to the client area.
+ * The line index returned is always in the range 0..lineCount - 1.
+ *
+ * @since 3.2
+ */
+public int getLineIndex(int y) {
+    checkWidget();
+    y -= topMargin;
+    if (isFixedLineHeight()) {
+        int lineHeight = renderer.getLineHeight();
+        int lineIndex = (y + getVerticalScrollOffset()) / lineHeight;
+        int lineCount = content.getLineCount();
+        lineIndex = Math.max(0, Math.min(lineCount - 1, lineIndex));
+        return lineIndex;
+    }
+    if (y is topIndexY) return topIndex;
+    int line = topIndex;
+    if (y < topIndexY) {
+        while (y < topIndexY && line > 0) {
+            y += renderer.getLineHeight(--line);
+        }
+    } else {
+        int lineCount = content.getLineCount();
+        int lineHeight = renderer.getLineHeight(line);
+        while (y - lineHeight >= topIndexY && line < lineCount - 1) {
+            y -= lineHeight;
+            lineHeight = renderer.getLineHeight(++line);
+        }
+    }
+    return line;
+}
+/**
+ * Returns the x, y location of the upper left corner of the character 
+ * bounding box at the specified offset in the text. The point is 
+ * relative to the upper left corner of the widget client area.
+ *
+ * @param offset offset relative to the start of the content. 
+ *  0 <= offset <= getCharCount()
+ * @return x, y location of the upper left corner of the character 
+ *  bounding box at the specified offset in the text.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul>
+ */
+public Point getLocationAtOffset(int offset) {
+    checkWidget();
+    if (offset < 0 || offset > getCharCount()) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);     
+    }
+    return getPointAtOffset(offset);
+}
+/**
+ * Returns the character offset of the first character of the given line.
+ *
+ * @param lineIndex index of the line, 0 based relative to the first 
+ *  line in the content. 0 <= lineIndex < getLineCount(), except
+ *  lineIndex may always be 0
+ * @return offset offset of the first character of the line, relative to
+ *  the beginning of the document. The first character of the document is
+ *  at offset 0.  
+ *  When there are not any lines, getOffsetAtLine(0) is a valid call that 
+ *  answers 0.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the line index is outside the valid range (< 0 or >= getLineCount())</li> 
+ * </ul>
+ * @since 2.0
+ */
+public int getOffsetAtLine(int lineIndex) {
+    checkWidget();
+    if (lineIndex < 0 || 
+        (lineIndex > 0 && lineIndex >= content.getLineCount())) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);     
+    }
+    return content.getOffsetAtLine(lineIndex);
+}
+/**
+ * Returns the offset of the character at the given location relative 
+ * to the first character in the document.
+ * <p>
+ * The return value reflects the character offset that the caret will
+ * be placed at if a mouse click occurred at the specified location.
+ * If the x coordinate of the location is beyond the center of a character
+ * the returned offset will be behind the character.
+ * </p>
+ *
+ * @param point the origin of character bounding box relative to 
+ *  the origin of the widget client area.
+ * @return offset of the character at the given location relative 
+ *  to the first character in the document.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when point is null</li>
+ *   <li>ERROR_INVALID_ARGUMENT when there is no character at the specified location</li>
+ * </ul>
+ */
+public int getOffsetAtLocation(Point point) {
+    checkWidget();
+    if (point is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    int[] trailing = new int[1];
+    int offset = getOffsetAtPoint(point.x, point.y, trailing, true);
+    if (offset is -1) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    return offset + trailing[0];
+}
+int getOffsetAtPoint(int x, int y) {
+    int lineIndex = getLineIndex(y);
+    y -= getLinePixel(lineIndex);
+    return getOffsetAtPoint(x, y, lineIndex);
+}
+/**
+ * Returns the offset at the specified x location in the specified line.
+ *
+ * @param x x location of the mouse location
+ * @param line  line the mouse location is in
+ * @return the offset at the specified x location in the specified line,
+ *  relative to the beginning of the document
+ */
+int getOffsetAtPoint(int x, int y, int lineIndex) {
+    TextLayout layout = renderer.getTextLayout(lineIndex);
+    x += horizontalScrollOffset - leftMargin;
+    int[] trailing = new int[1];    
+    int offsetInLine = layout.getOffset(x, y, trailing);
+    caretAlignment = OFFSET_LEADING;
+    if (trailing[0] !is 0) {
+        int lineInParagraph = layout.getLineIndex(offsetInLine + trailing[0]);
+        int lineStart = layout.getLineOffsets()[lineInParagraph];
+        if (offsetInLine + trailing[0] is lineStart) {
+            offsetInLine += trailing[0];
+            caretAlignment = PREVIOUS_OFFSET_TRAILING;
+        } else {
+            String line = content.getLine(lineIndex);           
+            int level;
+            int offset = offsetInLine;
+            while (offset > 0 && Character.isDigit(line.charAt(offset))) offset--;
+            if (offset is 0 && Character.isDigit(line.charAt(offset))) {
+                level = isMirrored() ? 1 : 0;
+            } else {
+                level = layout.getLevel(offset) & 0x1;
+            }
+            offsetInLine += trailing[0];
+            int trailingLevel = layout.getLevel(offsetInLine) & 0x1;
+            if ((level ^ trailingLevel) !is 0) {
+                caretAlignment = PREVIOUS_OFFSET_TRAILING;
+            } else {
+                caretAlignment = OFFSET_LEADING;
+            }
+        }
+    }
+    renderer.disposeTextLayout(layout);
+    return offsetInLine + content.getOffsetAtLine(lineIndex);
+}
+int getOffsetAtPoint(int x, int y, int[] trailing, bool inTextOnly) {
+    if (inTextOnly && y + getVerticalScrollOffset() < 0 || x + horizontalScrollOffset < 0) {
+        return -1;
+    }
+    int bottomIndex = getPartialBottomIndex();
+    int height = getLinePixel(bottomIndex + 1);
+    if (inTextOnly && y > height) {
+        return -1;
+    }
+    int lineIndex = getLineIndex(y);
+    int lineOffset = content.getOffsetAtLine(lineIndex);
+    TextLayout layout = renderer.getTextLayout(lineIndex);  
+    x += horizontalScrollOffset - leftMargin ;
+    y -= getLinePixel(lineIndex);
+    int offset = layout.getOffset(x, y, trailing);
+    Rectangle rect = layout.getLineBounds(layout.getLineIndex(offset));
+    renderer.disposeTextLayout(layout);
+    if (inTextOnly && !(rect.x  <= x && x <=  rect.x + rect.width)) {
+        return -1;
+    }
+    return offset + lineOffset;
+}
+/**
+ * Returns the orientation of the receiver.
+ *
+ * @return the orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public int getOrientation () {
+    checkWidget();
+    return isMirrored() ? DWT.RIGHT_TO_LEFT : DWT.LEFT_TO_RIGHT;
+}
+/** 
+ * Returns the index of the last partially visible line.
+ *
+ * @return index of the last partially visible line.
+ */
+int getPartialBottomIndex() {
+    if (isFixedLineHeight()) {
+        int lineHeight = renderer.getLineHeight();
+        int partialLineCount = Compatibility.ceil(clientAreaHeight, lineHeight);
+        return Math.max(0, Math.min(content.getLineCount(), topIndex + partialLineCount) - 1);
+    }
+    return getLineIndex(clientAreaHeight - bottomMargin);
+}
+/** 
+ * Returns the index of the first partially visible line.
+ *
+ * @return index of the first partially visible line.
+ */
+int getPartialTopIndex() {
+    if (isFixedLineHeight()) {
+        int lineHeight = renderer.getLineHeight();
+        return getVerticalScrollOffset() / lineHeight;
+    }
+    return topIndexY <= 0 ? topIndex : topIndex - 1;
+}
+/**
+ * Returns the content in the specified range using the platform line 
+ * delimiter to separate lines.
+ *
+ * @param writer the TextWriter to write line text into
+ * @return the content in the specified range using the platform line 
+ *  delimiter to separate lines as written by the specified TextWriter.
+ */
+String getPlatformDelimitedText(TextWriter writer) {
+    int end = writer.getStart() + writer.getCharCount();
+    int startLine = content.getLineAtOffset(writer.getStart());
+    int endLine = content.getLineAtOffset(end);
+    String endLineText = content.getLine(endLine);
+    int endLineOffset = content.getOffsetAtLine(endLine);
+    
+    for (int i = startLine; i <= endLine; i++) {
+        writer.writeLine(content.getLine(i), content.getOffsetAtLine(i));
+        if (i < endLine) {
+            writer.writeLineDelimiter(PlatformLineDelimiter);
+        }
+    }
+    if (end > endLineOffset + endLineText.length()) {
+        writer.writeLineDelimiter(PlatformLineDelimiter);
+    }
+    writer.close();
+    return writer.toString();
+}
+/**
+ * Returns all the ranges of text that have an associated StyleRange.
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * <p>
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2] returned by <code>getStyleRanges(int, int, bool)</code>.
+ * </p>
+ * 
+ * @return the ranges or an empty array if a LineStyleListener has been set.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see #getStyleRanges(bool)
+ */
+public int[] getRanges() {
+    checkWidget();
+    if (!isListening(LineGetStyle)) {
+        int[] ranges = renderer.getRanges(0, content.getCharCount());
+        if (ranges !is null) return ranges;
+    }
+    return new int[0];
+}
+/**
+ * Returns the ranges of text that have an associated StyleRange.
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * <p>
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2] returned by <code>getStyleRanges(int, int, bool)</code>.
+ * </p>
+ *
+ * @param start the start offset of the style ranges to return
+ * @param length the number of style ranges to return
+ * 
+ * @return the ranges or an empty array if a LineStyleListener has been set.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE if start or length are outside the widget content</li> 
+ * </ul> 
+ * 
+ * @since 3.2
+ * 
+ * @see #getStyleRanges(int, int, bool)
+ */
+public int[] getRanges(int start, int length) {
+    checkWidget();
+    int contentLength = getCharCount();
+    int end = start + length;
+    if (start > end || start < 0 || end > contentLength) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    if (!isListening(LineGetStyle)) {
+        int[] ranges = renderer.getRanges(start, length);
+        if (ranges !is null) return ranges;
+    }
+    return new int[0];
+}
+/**
+ * Returns the selection.
+ * <p>
+ * Text selections are specified in terms of caret positions.  In a text
+ * widget that contains N characters, there are N+1 caret positions, 
+ * ranging from 0..N
+ * </p>
+ *
+ * @return start and end of the selection, x is the offset of the first 
+ *  selected character, y is the offset after the last selected character.
+ *  The selection values returned are visual (i.e., x will always always be   
+ *  <= y).  To determine if a selection is right-to-left (RtoL) vs. left-to-right 
+ *  (LtoR), compare the caretOffset to the start and end of the selection 
+ *  (e.g., caretOffset is start of selection implies that the selection is RtoL).
+ * @see #getSelectionRange
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection() {
+    checkWidget();
+    return new Point(selection.x, selection.y);
+}
+/**
+ * Returns the selection.
+ *
+ * @return start and length of the selection, x is the offset of the 
+ *  first selected character, relative to the first character of the 
+ *  widget content. y is the length of the selection. 
+ *  The selection values returned are visual (i.e., length will always always be   
+ *  positive).  To determine if a selection is right-to-left (RtoL) vs. left-to-right 
+ *  (LtoR), compare the caretOffset to the start and end of the selection 
+ *  (e.g., caretOffset is start of selection implies that the selection is RtoL).
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelectionRange() {
+    checkWidget();
+    return new Point(selection.x, selection.y - selection.x);
+}
+/**
+ * Returns the receiver's selection background color.
+ *
+ * @return the selection background color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public Color getSelectionBackground() {
+    checkWidget();
+    if (selectionBackground is null) {
+        return getDisplay().getSystemColor(DWT.COLOR_LIST_SELECTION);
+    }
+    return selectionBackground;
+}
+/**
+ * Gets the number of selected characters.
+ *
+ * @return the number of selected characters.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount() {
+    checkWidget();
+    return getSelectionRange().y;
+}
+/**
+ * Returns the receiver's selection foreground color.
+ *
+ * @return the selection foreground color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public Color getSelectionForeground() {
+    checkWidget();
+    if (selectionForeground is null) {
+        return getDisplay().getSystemColor(DWT.COLOR_LIST_SELECTION_TEXT);
+    }
+    return selectionForeground;
+}
+/**
+ * Returns the selected text.
+ *
+ * @return selected text, or an empty String if there is no selection.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getSelectionText() {
+    checkWidget();
+    return content.getTextRange(selection.x, selection.y - selection.x);
+}
+public int getStyle() {
+    int style = super.getStyle();
+    style &= ~(DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT | DWT.MIRRORED);
+    if (isMirrored()) {
+        style |= DWT.RIGHT_TO_LEFT | DWT.MIRRORED;
+    } else {
+        style |= DWT.LEFT_TO_RIGHT;
+    }
+    return style;
+}
+
+/**
+ * Returns the text segments that should be treated as if they 
+ * had a different direction than the surrounding text.
+ *
+ * @param lineOffset offset of the first character in the line. 
+ *  0 based from the beginning of the document.
+ * @param line text of the line to specify bidi segments for
+ * @return text segments that should be treated as if they had a
+ *  different direction than the surrounding text. Only the start 
+ *  index of a segment is specified, relative to the start of the 
+ *  line. Always starts with 0 and ends with the line length. 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the segment indices returned 
+ *      by the listener do not start with 0, are not in ascending order,
+ *      exceed the line length or have duplicates</li>
+ * </ul>
+ */
+int [] getBidiSegments(int lineOffset, String line) {
+    if (!isBidi()) return null;
+    if (!isListening(LineGetSegments)) {
+        return getBidiSegmentsCompatibility(line, lineOffset);
+    }
+    StyledTextEvent event = sendLineEvent(LineGetSegments, lineOffset, line);
+    int lineLength = line.length();
+    int[] segments;
+    if (event is null || event.segments is null || event.segments.length is 0) {
+        segments = new int[] {0, lineLength};
+    } else {
+        int segmentCount = event.segments.length;
+        
+        // test segment index consistency
+        if (event.segments[0] !is 0) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }   
+        for (int i = 1; i < segmentCount; i++) {
+            if (event.segments[i] <= event.segments[i - 1] || event.segments[i] > lineLength) {
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            }   
+        }
+        // ensure that last segment index is line end offset
+        if (event.segments[segmentCount - 1] !is lineLength) {
+            segments = new int[segmentCount + 1];
+            System.arraycopy(event.segments, 0, segments, 0, segmentCount);
+            segments[segmentCount] = lineLength;
+        } else {
+            segments = event.segments;
+        }
+    }
+    return segments;
+}
+/**
+ * @see #getBidiSegments
+ * Supports deprecated setBidiColoring API. Remove when API is removed.
+ */
+int [] getBidiSegmentsCompatibility(String line, int lineOffset) {
+    int lineLength = line.length();
+    if (!bidiColoring) {
+        return new int[] {0, lineLength};
+    }
+    StyleRange [] styles = null;
+    StyledTextEvent event = getLineStyleData(lineOffset, line);
+    if (event !is null) {
+        styles = event.styles;
+    } else {
+        styles = renderer.getStyleRanges(lineOffset, lineLength, true);
+    }
+    if (styles is null || styles.length is 0) {
+        return new int[] {0, lineLength};
+    }
+    int k=0, count = 1;
+    while (k < styles.length && styles[k].start is 0 && styles[k].length is lineLength) {
+        k++;
+    }
+    int[] offsets = new int[(styles.length - k) * 2 + 2];
+    for (int i = k; i < styles.length; i++) {
+        StyleRange style = styles[i];
+        int styleLineStart = Math.max(style.start - lineOffset, 0);
+        int styleLineEnd = Math.max(style.start + style.length - lineOffset, styleLineStart);
+        styleLineEnd = Math.min (styleLineEnd, line.length ());
+        if (i > 0 && count > 1 &&
+            ((styleLineStart >= offsets[count-2] && styleLineStart <= offsets[count-1]) ||
+             (styleLineEnd >= offsets[count-2] && styleLineEnd <= offsets[count-1])) &&
+             style.similarTo(styles[i-1])) {
+            offsets[count-2] = Math.min(offsets[count-2], styleLineStart);
+            offsets[count-1] = Math.max(offsets[count-1], styleLineEnd);
+        } else {
+            if (styleLineStart > offsets[count - 1]) {
+                offsets[count] = styleLineStart;
+                count++;
+            }
+            offsets[count] = styleLineEnd;
+            count++;
+        }
+    }
+    // add offset for last non-colored segment in line, if any
+    if (lineLength > offsets[count-1]) {
+        offsets [count] = lineLength;
+        count++;
+    }
+    if (count is offsets.length) {
+        return offsets;
+    }
+    int [] result = new int [count];
+    System.arraycopy (offsets, 0, result, 0, count);
+    return result;
+}
+/**
+ * Returns the style range at the given offset.
+ * <p>
+ * Returns null if a LineStyleListener has been set or if a style is not set
+ * for the offset. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param offset the offset to return the style for. 
+ *  0 <= offset < getCharCount() must be true.
+ * @return a StyleRange with start is offset and length is 1, indicating
+ *  the style at the given offset. null if a LineStyleListener has been set 
+ *  or if a style is not set for the given offset.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the offset is invalid</li>
+ * </ul>
+ */
+public StyleRange getStyleRangeAtOffset(int offset) {
+    checkWidget();
+    if (offset < 0 || offset >= getCharCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (!isListening(LineGetStyle)) {
+        StyleRange[] ranges = renderer.getStyleRanges(offset, 1, true);
+        if (ranges !is null) return ranges[0];
+    }
+    return null;
+}
+/**
+ * Returns the styles.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * <p></p>
+ * Note: Because a StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>getStyleRanges(bool)</code>
+ * can be used to get the styles without the ranges.
+ * </p>
+ *
+ * @return the styles or an empty array if a LineStyleListener has been set.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getStyleRanges(bool)
+ */
+public StyleRange[] getStyleRanges() {
+    checkWidget();
+    return getStyleRanges(0, content.getCharCount(), true);
+}
+/**
+ * Returns the styles.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p><p>
+ * Note: When <code>includeRanges</code> is true, the start and length
+ * fields of each StyleRange will be valid, however the StyleRange
+ * objects may need to be cloned. When <code>includeRanges</code> is
+ * false, <code>getRanges(int, int)</code> can be used to get the
+ * associated ranges.
+ * </p>
+ * 
+ * @param includeRanges whether the start and length field of the StyleRanges should be set.
+ * 
+ * @return the styles or an empty array if a LineStyleListener has been set.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see #getRanges(int, int)
+ * @see #setStyleRanges(int[], StyleRange[])
+ */
+public StyleRange[] getStyleRanges(bool includeRanges) {
+    checkWidget();
+    return getStyleRanges(0, content.getCharCount(), includeRanges);
+}
+/**
+ * Returns the styles for the given text range.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p><p>
+ * Note: Because the StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>getStyleRanges(int, int, bool)</code>
+ * can be used to get the styles without the ranges.
+ * </p>
+ * @param start the start offset of the style ranges to return
+ * @param length the number of style ranges to return
+ *
+ * @return the styles or an empty array if a LineStyleListener has 
+ *  been set.  The returned styles will reflect the given range.  The first 
+ *  returned <code>StyleRange</code> will have a starting offset >= start 
+ *  and the last returned <code>StyleRange</code> will have an ending 
+ *  offset <= start + length - 1
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ * 
+ * @see #getStyleRanges(int, int, bool)
+ * 
+ * @since 3.0
+ */
+public StyleRange[] getStyleRanges(int start, int length) {
+    checkWidget();
+    return getStyleRanges(start, length, true);
+}
+/**
+ * Returns the styles for the given text range.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p><p>
+ * Note: When <code>includeRanges</code> is true, the start and length
+ * fields of each StyleRange will be valid, however the StyleRange
+ * objects may need to be cloned. When <code>includeRanges</code> is
+ * false, <code>getRanges(int, int)</code> can be used to get the
+ * associated ranges.
+ * </p>
+ * 
+ * @param start the start offset of the style ranges to return
+ * @param length the number of style ranges to return
+ * @param includeRanges whether the start and length field of the StyleRanges should be set.
+ *
+ * @return the styles or an empty array if a LineStyleListener has 
+ *  been set.  The returned styles will reflect the given range.  The first 
+ *  returned <code>StyleRange</code> will have a starting offset >= start 
+ *  and the last returned <code>StyleRange</code> will have an ending 
+ *  offset <= start + length - 1
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see #getRanges(int, int)
+ * @see #setStyleRanges(int[], StyleRange[])
+ */
+public StyleRange[] getStyleRanges(int start, int length, bool includeRanges) {
+    checkWidget();
+    int contentLength = getCharCount();
+    int end = start + length;
+    if (start > end || start < 0 || end > contentLength) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    if (!isListening(LineGetStyle)) {
+        StyleRange[] ranges = renderer.getStyleRanges(start, length, includeRanges);
+        if (ranges !is null) return ranges;
+    }
+    return new StyleRange[0];
+}
+/**
+ * Returns the tab width measured in characters.
+ *
+ * @return tab width measured in characters
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTabs() {
+    checkWidget();
+    return tabLength;
+}
+/**
+ * Returns a copy of the widget content.
+ *
+ * @return copy of the widget content
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText() {
+    checkWidget();
+    return content.getTextRange(0, getCharCount());
+}
+/**
+ * Returns the widget content between the two offsets.
+ *
+ * @param start offset of the first character in the returned String
+ * @param end offset of the last character in the returned String 
+ * @return widget content starting at start and ending at end
+ * @see #getTextRange(int,int)
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ */
+public String getText(int start, int end) {
+    checkWidget();
+    int contentLength = getCharCount();
+    if (start < 0 || start >= contentLength || end < 0 || end >= contentLength || start > end) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    return content.getTextRange(start, end - start + 1);
+}
+/**
+ * Returns the smallest bounding rectangle that includes the characters between two offsets.
+ *
+ * @param start offset of the first character included in the bounding box
+ * @param end offset of the last character included in the bounding box 
+ * @return bounding box of the text between start and end
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ * @since 3.1
+ */
+public Rectangle getTextBounds(int start, int end) {
+    checkWidget();  
+    int contentLength = getCharCount(); 
+    if (start < 0 || start >= contentLength || end < 0 || end >= contentLength || start > end) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    int lineStart = content.getLineAtOffset(start);
+    int lineEnd = content.getLineAtOffset(end);
+    Rectangle rect;
+    int y = getLinePixel(lineStart);
+    int height = 0;
+    int left = 0x7fffffff, right = 0;
+    for (int i = lineStart; i <= lineEnd; i++) {
+        int lineOffset = content.getOffsetAtLine(i);        
+        TextLayout layout = renderer.getTextLayout(i);
+        int length = layout.getText().length();
+        if (length > 0) {
+            if (i is lineStart) {
+                if (i is lineEnd) {
+                    rect = layout.getBounds(start - lineOffset, end - lineOffset);
+                } else {
+                    rect = layout.getBounds(start - lineOffset, length);
+                }
+                y += rect.y;
+            } else if (i is lineEnd) {
+                rect = layout.getBounds(0, end - lineOffset);
+            } else {
+                rect = layout.getBounds();
+            }
+            left = Math.min(left, rect.x);
+            right = Math.max(right, rect.x + rect.width);
+            height += rect.height;
+        } else {
+            height += renderer.getLineHeight();
+        }
+        renderer.disposeTextLayout(layout);
+    }
+    rect = new Rectangle (left, y, right-left, height);
+    rect.x += leftMargin - horizontalScrollOffset;
+    return rect;
+}
+/**
+ * Returns the widget content starting at start for length characters.
+ *
+ * @param start offset of the first character in the returned String
+ * @param length number of characters to return 
+ * @return widget content starting at start and extending length characters.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or length are outside the widget content</li> 
+ * </ul>
+ */
+public String getTextRange(int start, int length) {
+    checkWidget();
+    int contentLength = getCharCount();
+    int end = start + length;
+    if (start > end || start < 0 || end > contentLength) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }   
+    return content.getTextRange(start, length);
+}
+/**
+ * Returns the maximum number of characters that the receiver is capable of holding.
+ * 
+ * @return the text limit
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTextLimit() {
+    checkWidget();
+    return textLimit;
+}
+/**
+ * Gets the top index.
+ * <p>
+ * The top index is the index of the fully visible line that is currently 
+ * at the top of the widget or the topmost partially visible line if no line is fully visible. 
+ * The top index changes when the widget is scrolled. Indexing is zero based.
+ * </p>
+ *
+ * @return the index of the top line
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex() {
+    checkWidget();
+    return topIndex;
+}
+/**
+ * Gets the top pixel.
+ * <p>
+ * The top pixel is the pixel position of the line that is 
+ * currently at the top of the widget. The text widget can be scrolled by pixels 
+ * by dragging the scroll thumb so that a partial line may be displayed at the top 
+ * the widget.  The top pixel changes when the widget is scrolled.  The top pixel 
+ * does not include the widget trimming.
+ * </p>
+ *
+ * @return pixel position of the top line
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopPixel() {
+    checkWidget();
+    return getVerticalScrollOffset();
+}
+/** 
+ * Returns the vertical scroll increment.
+ *
+ * @return vertical scroll increment.
+ */
+int getVerticalIncrement() {
+    return renderer.getLineHeight();
+}
+int getVerticalScrollOffset() {
+    if (verticalScrollOffset is -1) {
+        renderer.calculate(0, topIndex);
+        int height = 0;
+        for (int i = 0; i < topIndex; i++) {
+            height += renderer.getLineHeight(i);
+        }
+        height -= topIndexY;
+        verticalScrollOffset = height;
+    }
+    return verticalScrollOffset;
+}
+int getVisualLineIndex(TextLayout layout, int offsetInLine) {
+    int lineIndex = layout.getLineIndex(offsetInLine);
+    int[] offsets = layout.getLineOffsets();
+    if (lineIndex !is 0 && offsetInLine is offsets[lineIndex]) {
+        int lineY = layout.getLineBounds(lineIndex).y;
+        int caretY = getCaret().getLocation().y - topMargin - getLinePixel(getCaretLine());
+        if (lineY > caretY) lineIndex--;
+    }
+    return lineIndex;
+}
+int getCaretDirection() {
+    if (!isBidiCaret()) return DWT.DEFAULT;
+    if (ime.getCompositionOffset() !is -1) return DWT.DEFAULT;
+    if (!updateCaretDirection && caretDirection !is DWT.NULL) return caretDirection;
+    updateCaretDirection = false;
+    int caretLine = getCaretLine();
+    int lineOffset = content.getOffsetAtLine(caretLine);
+    String line = content.getLine(caretLine);
+    int offset = caretOffset - lineOffset;
+    int lineLength = line.length();
+    if (lineLength is 0) return isMirrored() ? DWT.RIGHT : DWT.LEFT;
+    if (caretAlignment is PREVIOUS_OFFSET_TRAILING && offset > 0) offset--;
+    if (offset is lineLength && offset > 0) offset--;
+    while (offset > 0 && Character.isDigit(line.charAt(offset))) offset--;
+    if (offset is 0 && Character.isDigit(line.charAt(offset))) {
+        return isMirrored() ? DWT.RIGHT : DWT.LEFT;
+    }
+    TextLayout layout = renderer.getTextLayout(caretLine);
+    int level = layout.getLevel(offset);
+    renderer.disposeTextLayout(layout);
+    return ((level & 1) !is 0) ? DWT.RIGHT : DWT.LEFT;
+}
+/*
+ * Returns the index of the line the caret is on.
+ */
+int getCaretLine() {
+    return content.getLineAtOffset(caretOffset);
+}
+int getWrapWidth () {
+    if (wordWrap && !isSingleLine()) {
+        int width = clientAreaWidth - leftMargin - rightMargin - getCaretWidth();
+        return width > 0 ? width : 1;
+    }
+    return -1;
+}
+int getWordNext (int offset, int movement) {
+    int newOffset, lineOffset;
+    String lineText;
+    if (offset >= getCharCount()) {
+        newOffset = offset;
+        int lineIndex = content.getLineCount() - 1;
+        lineOffset = content.getOffsetAtLine(lineIndex);
+        lineText = content.getLine(lineIndex);
+    } else {
+        int lineIndex = content.getLineAtOffset(offset);
+        lineOffset = content.getOffsetAtLine(lineIndex);
+        lineText = content.getLine(lineIndex);
+        int lineLength = lineText.length();
+        if (offset is lineOffset + lineLength) {
+            newOffset = content.getOffsetAtLine(lineIndex + 1);
+        } else {
+            TextLayout layout = renderer.getTextLayout(lineIndex);
+            newOffset = lineOffset + layout.getNextOffset(offset - lineOffset, movement);
+            renderer.disposeTextLayout(layout);
+        }
+    }
+    return sendWordBoundaryEvent(WordNext, movement, offset, newOffset, lineText, lineOffset);
+}
+int getWordPrevious(int offset, int movement) {
+    int newOffset, lineOffset;
+    String lineText;
+    if (offset <= 0) {
+        newOffset = 0;
+        int lineIndex = content.getLineAtOffset(newOffset);
+        lineOffset = content.getOffsetAtLine(lineIndex);
+        lineText = content.getLine(lineIndex);
+    } else {
+        int lineIndex = content.getLineAtOffset(offset);
+        lineOffset = content.getOffsetAtLine(lineIndex);
+        lineText = content.getLine(lineIndex);
+        if (offset is lineOffset) {
+            String nextLineText = content.getLine(lineIndex - 1);
+            int nextLineOffset = content.getOffsetAtLine(lineIndex - 1); 
+            newOffset = nextLineOffset + nextLineText.length();
+        } else {
+            TextLayout layout = renderer.getTextLayout(lineIndex);
+            newOffset = lineOffset + layout.getPreviousOffset(offset - lineOffset, movement);
+            renderer.disposeTextLayout(layout); 
+        }
+    }
+    return sendWordBoundaryEvent(WordPrevious, movement, offset, newOffset, lineText, lineOffset);
+}
+/**
+ * Returns whether the widget wraps lines.
+ *
+ * @return true if widget wraps lines, false otherwise
+ * @since 2.0
+ */
+public bool getWordWrap() {
+    checkWidget();
+    return wordWrap;
+}
+/** 
+ * Returns the location of the given offset.
+ * <p>
+ * <b>NOTE:</b> Does not return correct values for true italic fonts (vs. slanted fonts).
+ * </p>
+ *
+ * @return location of the character at the given offset in the line.
+ */
+Point getPointAtOffset(int offset) {
+    int lineIndex = content.getLineAtOffset(offset);
+    String line = content.getLine(lineIndex);
+    int lineOffset = content.getOffsetAtLine(lineIndex);
+    int offsetInLine = offset - lineOffset;
+    int lineLength = line.length();
+    if (lineIndex < content.getLineCount() - 1) {
+        int endLineOffset = content.getOffsetAtLine(lineIndex + 1) - 1;
+        if (lineLength < offsetInLine && offsetInLine <= endLineOffset) {
+            offsetInLine = lineLength;
+        }
+    }
+    Point point;
+    TextLayout layout = renderer.getTextLayout(lineIndex);
+    if (lineLength !is 0  && offsetInLine <= lineLength) {
+        if (offsetInLine is lineLength) {
+            point = layout.getLocation(offsetInLine - 1, true);
+        } else {
+            switch (caretAlignment) {
+                case OFFSET_LEADING:
+                    point = layout.getLocation(offsetInLine, false);
+                    break;
+                case PREVIOUS_OFFSET_TRAILING:
+                default:
+                    if (offsetInLine is 0) {
+                        point = layout.getLocation(offsetInLine, false);
+                    } else {
+                        point = layout.getLocation(offsetInLine - 1, true);
+                    }
+                    break;
+            }
+        }
+    } else {
+        point = new Point(layout.getIndent(), 0);
+    }
+    renderer.disposeTextLayout(layout);
+    point.x += leftMargin - horizontalScrollOffset;
+    point.y += getLinePixel(lineIndex);
+    return point;
+}
+/** 
+ * Inserts a String.  The old selection is replaced with the new text.  
+ *
+ * @param String the String
+ * @see #replaceTextRange(int,int,String)
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when String is null</li>
+ * </ul>
+ */
+public void insert(String String) {
+    checkWidget();
+    if (String is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    Point sel = getSelectionRange();
+    replaceTextRange(sel.x, sel.y, String);
+}
+/**
+ * Creates content change listeners and set the default content model.
+ */
+void installDefaultContent() {
+    textChangeListener = new TextChangeListener() {
+        public void textChanging(TextChangingEvent event) {
+            handleTextChanging(event);
+        }
+        public void textChanged(TextChangedEvent event) {
+            handleTextChanged(event);
+        }
+        public void textSet(TextChangedEvent event) {
+            handleTextSet(event);
+        }
+    };
+    content = new DefaultContent();
+    content.addTextChangeListener(textChangeListener);
+}
+/** 
+ * Adds event listeners
+ */
+void installListeners() {
+    ScrollBar verticalBar = getVerticalBar();
+    ScrollBar horizontalBar = getHorizontalBar();
+    
+    listener = new Listener() {
+        public void handleEvent(Event event) {
+            switch (event.type) {
+                case DWT.Dispose: handleDispose(event); break;
+                case DWT.KeyDown: handleKeyDown(event); break;
+                case DWT.KeyUp: handleKeyUp(event); break;
+                case DWT.MouseDown: handleMouseDown(event); break;
+                case DWT.MouseUp: handleMouseUp(event); break;
+                case DWT.MouseMove: handleMouseMove(event); break;
+                case DWT.Paint: handlePaint(event); break;
+                case DWT.Resize: handleResize(event); break;
+                case DWT.Traverse: handleTraverse(event); break;
+            }
+        }       
+    };
+    addListener(DWT.Dispose, listener);
+    addListener(DWT.KeyDown, listener);
+    addListener(DWT.KeyUp, listener);
+    addListener(DWT.MouseDown, listener);
+    addListener(DWT.MouseUp, listener);
+    addListener(DWT.MouseMove, listener);
+    addListener(DWT.Paint, listener);
+    addListener(DWT.Resize, listener);
+    addListener(DWT.Traverse, listener);
+    ime.addListener(DWT.ImeComposition, new Listener() {
+        public void handleEvent(Event event) {
+            switch (event.detail) {
+                case DWT.COMPOSITION_SELECTION: handleCompositionSelection(event); break;
+                case DWT.COMPOSITION_CHANGED: handleCompositionChanged(event); break;
+                case DWT.COMPOSITION_OFFSET: handleCompositionOffset(event); break;
+            }
+        }
+    });
+    if (verticalBar !is null) {
+        verticalBar.addListener(DWT.Selection, new Listener() {
+            public void handleEvent(Event event) {
+                handleVerticalScroll(event);
+            }
+        });
+    }
+    if (horizontalBar !is null) {
+        horizontalBar.addListener(DWT.Selection, new Listener() {
+            public void handleEvent(Event event) {
+                handleHorizontalScroll(event);
+            }
+        });
+    }
+}
+void internalRedrawRange(int start, int length) {
+    if (length <= 0) return;
+    int end = start + length;
+    int startLine = content.getLineAtOffset(start);
+    int endLine = content.getLineAtOffset(end);
+    int partialBottomIndex = getPartialBottomIndex();
+    int partialTopIndex = getPartialTopIndex();
+    if (startLine > partialBottomIndex || endLine < partialTopIndex) {
+        return;
+    }
+    if (partialTopIndex > startLine) {
+        startLine = partialTopIndex;
+        start = 0;
+    } else {
+        start -= content.getOffsetAtLine(startLine);
+    }
+    if (partialBottomIndex < endLine) {
+        endLine = partialBottomIndex + 1;
+        end = 0;
+    } else {
+        end -= content.getOffsetAtLine(endLine);
+    }
+
+    TextLayout layout = renderer.getTextLayout(startLine);
+    int lineX = leftMargin - horizontalScrollOffset, startLineY = getLinePixel(startLine);
+    int[] offsets = layout.getLineOffsets();
+    int startIndex = layout.getLineIndex(Math.min(start, layout.getText().length()));
+    
+    /* Redraw end of line before start line if wrapped and start offset is first char */
+    if (wordWrap && startIndex > 0 && offsets[startIndex] is start) {
+        Rectangle rect = layout.getLineBounds(startIndex - 1);
+        rect.x = rect.width;
+        rect.width = clientAreaWidth - rightMargin - rect.x;
+        rect.x += lineX;
+        rect.y += startLineY;
+        super.redraw(rect.x, rect.y, rect.width, rect.height, false);
+    }
+    
+    if (startLine is endLine) {
+        int endIndex = layout.getLineIndex(Math.min(end, layout.getText().length()));
+        if (startIndex is endIndex) {
+            /* Redraw rect between start and end offset if start and end offsets are in same wrapped line */
+            Rectangle rect = layout.getBounds(start, end - 1);
+            rect.x += lineX;
+            rect.y += startLineY;
+            super.redraw(rect.x, rect.y, rect.width, rect.height, false);
+            renderer.disposeTextLayout(layout);
+            return;
+        }
+    }
+
+    /* Redraw start line from the start offset to the end of client area */
+    Rectangle startRect = layout.getBounds(start, offsets[startIndex + 1] - 1);
+    if (startRect.height is 0) {
+        Rectangle bounds = layout.getLineBounds(startIndex);
+        startRect.x = bounds.width;
+        startRect.y = bounds.y;
+        startRect.height = bounds.height;
+    }
+    startRect.x += lineX;
+    startRect.y += startLineY;
+    startRect.width = clientAreaWidth - rightMargin - startRect.x;
+    super.redraw(startRect.x, startRect.y, startRect.width, startRect.height, false);
+
+    /* Redraw end line from the beginning of the line to the end offset */
+    if (startLine !is endLine) {
+        renderer.disposeTextLayout(layout);
+        layout = renderer.getTextLayout(endLine);
+        offsets = layout.getLineOffsets();
+    }
+    int endIndex = layout.getLineIndex(Math.min(end, layout.getText().length()));
+    Rectangle endRect = layout.getBounds(offsets[endIndex], end - 1);
+    if (endRect.height is 0) {
+        Rectangle bounds = layout.getLineBounds(endIndex);
+        endRect.y = bounds.y;
+        endRect.height = bounds.height;
+    }
+    endRect.x += lineX;
+    endRect.y += getLinePixel(endLine);
+    super.redraw(endRect.x, endRect.y, endRect.width, endRect.height, false);
+    renderer.disposeTextLayout(layout);
+
+    /* Redraw all lines in between start and end line */
+    int y = startRect.y + startRect.height;
+    if (endRect.y > y) {
+        super.redraw(leftMargin, y, clientAreaWidth - rightMargin - leftMargin, endRect.y - y, false);
+    }
+}
+void handleCompositionOffset (Event event) {
+    int[] trailing = new int [1];
+    event.index = getOffsetAtPoint(event.x, event.y, trailing, true);
+    event.count = trailing[0];
+}
+void handleCompositionSelection (Event event) {
+    event.start = selection.x;
+    event.end = selection.y;
+    event.text = getSelectionText();
+}
+void handleCompositionChanged(Event event) {
+    String text = event.text;
+    int start = event.start;
+    int end = event.end;
+    int length = text.length();
+    if (length is ime.getCommitCount()) {
+        content.replaceTextRange(start, end - start, "");
+        caretOffset = start;
+        caretWidth = 0;
+        caretDirection = DWT.NULL;
+    } else {
+        content.replaceTextRange(start, end - start, text);
+        caretOffset = ime.getCaretOffset();
+        if (ime.getWideCaret()) {
+            int lineIndex = getCaretLine();
+            int lineOffset = content.getOffsetAtLine(lineIndex);
+            TextLayout layout = renderer.getTextLayout(lineIndex);  
+            caretWidth = layout.getBounds(start - lineOffset, start + length - 1 - lineOffset).width;
+            renderer.disposeTextLayout(layout);
+        }
+    }
+    showCaret();
+}
+/** 
+ * Frees resources.
+ */
+void handleDispose(Event event) {
+    removeListener(DWT.Dispose, listener);
+    notifyListeners(DWT.Dispose, event);
+    event.type = DWT.None;
+
+    clipboard.dispose();
+    if (renderer !is null) {
+        renderer.dispose();
+        renderer = null;
+    }
+    if (content !is null) {
+        content.removeTextChangeListener(textChangeListener);
+        content = null;
+    }
+    if (defaultCaret !is null) {
+        defaultCaret.dispose();
+        defaultCaret = null;
+    }
+    if (leftCaretBitmap !is null) {
+        leftCaretBitmap.dispose();
+        leftCaretBitmap = null;
+    }
+    if (rightCaretBitmap !is null) {
+        rightCaretBitmap.dispose();
+        rightCaretBitmap = null;
+    }
+    if (isBidiCaret()) {
+        BidiUtil.removeLanguageListener(this);
+    }
+    selectionBackground = null;
+    selectionForeground = null;
+    textChangeListener = null;
+    selection = null;
+    doubleClickSelection = null;
+    keyActionMap = null;
+    background = null;
+    foreground = null;
+    clipboard = null;
+}
+/** 
+ * Scrolls the widget horizontally.
+ */
+void handleHorizontalScroll(Event event) {
+    int scrollPixel = getHorizontalBar().getSelection() - horizontalScrollOffset;
+    scrollHorizontal(scrollPixel, false);
+}
+/**
+ * If an action has been registered for the key stroke execute the action.
+ * Otherwise, if a character has been entered treat it as new content.
+ *
+ * @param event keyboard event
+ */
+void handleKey(Event event) {
+    int action;
+    caretAlignment = PREVIOUS_OFFSET_TRAILING;
+    if (event.keyCode !is 0) {
+        // special key pressed (e.g., F1)
+        action = getKeyBinding(event.keyCode | event.stateMask);
+    } else {
+        // character key pressed
+        action = getKeyBinding(event.character | event.stateMask);
+        if (action is DWT.NULL) {
+            // see if we have a control character
+            if ((event.stateMask & DWT.CTRL) !is 0 && (event.character >= 0) && event.character <= 31) {
+                // get the character from the CTRL+char sequence, the control
+                // key subtracts 64 from the value of the key that it modifies
+                int c = event.character + 64;
+                action = getKeyBinding(c | event.stateMask);
+            }
+        }
+    }
+    if (action is DWT.NULL) {
+        bool ignore = false;
+        
+        if (IS_CARBON) {
+            // Ignore accelerator key combinations (we do not want to 
+            // insert a character in the text in this instance). Do not  
+            // ignore COMMAND+ALT combinations since that key sequence
+            // produces characters on the mac.
+            ignore = (event.stateMask ^ DWT.COMMAND) is 0 ||
+                    (event.stateMask ^ (DWT.COMMAND | DWT.SHIFT)) is 0;
+        } else if (IS_MOTIF) {
+            // Ignore accelerator key combinations (we do not want to 
+            // insert a character in the text in this instance). Do not  
+            // ignore ALT combinations since this key sequence
+            // produces characters on motif.
+            ignore = (event.stateMask ^ DWT.CTRL) is 0 ||
+                    (event.stateMask ^ (DWT.CTRL | DWT.SHIFT)) is 0;
+        } else {
+            // Ignore accelerator key combinations (we do not want to 
+            // insert a character in the text in this instance). Don't  
+            // ignore CTRL+ALT combinations since that is the Alt Gr 
+            // key on some keyboards.  See bug 20953. 
+            ignore = (event.stateMask ^ DWT.ALT) is 0 || 
+                    (event.stateMask ^ DWT.CTRL) is 0 ||
+                    (event.stateMask ^ (DWT.ALT | DWT.SHIFT)) is 0 ||
+                    (event.stateMask ^ (DWT.CTRL | DWT.SHIFT)) is 0;
+        }
+        // -ignore anything below SPACE except for line delimiter keys and tab.
+        // -ignore DEL 
+        if (!ignore && event.character > 31 && event.character !is DWT.DEL || 
+            event.character is DWT.CR || event.character is DWT.LF || 
+            event.character is TAB) {
+            doContent(event.character);
+            update();
+        }
+    } else {
+        invokeAction(action);
+    }
+}
+/**
+ * If a VerifyKey listener exists, verify that the key that was entered
+ * should be processed.
+ *
+ * @param event keyboard event
+ */
+void handleKeyDown(Event event) {
+    if (clipboardSelection is null) {
+        clipboardSelection = new Point(selection.x, selection.y);
+    }
+    
+    Event verifyEvent = new Event();
+    verifyEvent.character = event.character;
+    verifyEvent.keyCode = event.keyCode;
+    verifyEvent.stateMask = event.stateMask;
+    verifyEvent.doit = true;
+    notifyListeners(VerifyKey, verifyEvent);
+    if (verifyEvent.doit) {
+        handleKey(event);
+    }
+}
+/**
+ * Update the Selection Clipboard.
+ *
+ * @param event keyboard event
+ */
+void handleKeyUp(Event event) {
+    if (clipboardSelection !is null) {
+        if (clipboardSelection.x !is selection.x || clipboardSelection.y !is selection.y) {
+            try {
+                if (selection.y - selection.x > 0) {
+                    setClipboardContent(selection.x, selection.y - selection.x, DND.SELECTION_CLIPBOARD);
+                }
+            } catch (DWTError error) {
+                // Copy to clipboard failed. This happens when another application 
+                // is accessing the clipboard while we copy. Ignore the error.
+                // Fixes 1GDQAVN
+                // Rethrow all other errors. Fixes bug 17578.
+                if (error.code !is DND.ERROR_CANNOT_SET_CLIPBOARD) {
+                    throw error;
+                }
+            }
+        }
+    }
+    clipboardSelection = null;
+}
+/** 
+ * Updates the caret location and selection if mouse button 1 has been 
+ * pressed.
+ */
+void handleMouseDown(Event event) {
+    //force focus (object support)
+    forceFocus();
+        
+    //drag detect
+    if (dragDetect && checkDragDetect(event)) return;
+        
+    //paste clipboard selection
+    if (event.button is 2) {
+        String text = (String)getClipboardContent(DND.SELECTION_CLIPBOARD);
+        if (text !is null && text.length() > 0) {
+            // position cursor
+            doMouseLocationChange(event.x, event.y, false);
+            // insert text
+            Event e = new Event();
+            e.start = selection.x;
+            e.end = selection.y;
+            e.text = getModelDelimitedText(text);
+            sendKeyEvent(e);
+        }
+    }
+    
+    //set selection
+    if ((event.button !is 1) || (IS_CARBON && (event.stateMask & DWT.MOD4) !is 0)) {
+        return; 
+    }
+    clickCount = event.count;
+    if (clickCount is 1) {
+        bool select = (event.stateMask & DWT.MOD2) !is 0;
+        doMouseLocationChange(event.x, event.y, select);
+    } else {
+        if (doubleClickEnabled) {
+            clearSelection(false);
+            int offset = getOffsetAtPoint(event.x, event.y);
+            int lineIndex = content.getLineAtOffset(offset);
+            int lineOffset = content.getOffsetAtLine(lineIndex);
+            int lineEnd = content.getCharCount();
+            if (lineIndex + 1 < content.getLineCount()) {
+                lineEnd = content.getOffsetAtLine(lineIndex + 1);
+            }
+            int start, end;
+            if ((clickCount & 1) is 0) {
+                start = Math.max(0, getWordPrevious(offset, DWT.MOVEMENT_WORD_START));
+                end = Math.min(content.getCharCount(), getWordNext(start, DWT.MOVEMENT_WORD_END));
+            } else {
+                start = lineOffset;
+                end = lineEnd;
+            }
+            caretOffset = start;
+            resetSelection();
+            caretOffset = end;
+            showCaret();
+            doMouseSelection();
+            doubleClickSelection = new Point(selection.x, selection.y);
+        }
+    }
+}
+/** 
+ * Updates the caret location and selection if mouse button 1 is pressed 
+ * during the mouse move.
+ */
+void handleMouseMove(Event event) {
+    if (clickCount is 0) return;
+    doMouseLocationChange(event.x, event.y, true);
+    update();
+    doAutoScroll(event);
+}
+/** 
+ * Autoscrolling ends when the mouse button is released.
+ */
+void handleMouseUp(Event event) {
+    clickCount = 0;
+    endAutoScroll();
+    if (event.button is 1) {
+        try {
+            if (selection.y - selection.x > 0) {
+                setClipboardContent(selection.x, selection.y - selection.x, DND.SELECTION_CLIPBOARD);
+            }
+        } catch (DWTError error) {
+            // Copy to clipboard failed. This happens when another application 
+            // is accessing the clipboard while we copy. Ignore the error.
+            // Fixes 1GDQAVN
+            // Rethrow all other errors. Fixes bug 17578.
+            if (error.code !is DND.ERROR_CANNOT_SET_CLIPBOARD) {
+                throw error;
+            }
+        }
+    }
+}
+/**
+ * Renders the invalidated area specified in the paint event.
+ *
+ * @param event paint event
+ */
+void handlePaint(Event event) {
+    if (event.width is 0 || event.height is 0) return;
+    if (clientAreaWidth is 0 || clientAreaHeight is 0) return;
+
+    int startLine = getLineIndex(event.y);
+    int y = getLinePixel(startLine);
+    int endY = event.y + event.height;
+    GC gc = event.gc;
+    Color background = getBackground();
+    Color foreground = getForeground();
+    if (endY > 0) {
+        int lineCount = isSingleLine() ? 1 : content.getLineCount();
+        int x = leftMargin - horizontalScrollOffset;
+        for (int i = startLine; y < endY && i < lineCount; i++) {
+            y += renderer.drawLine(i, x, y, gc, background, foreground);
+        }
+        if (y < endY) {
+            gc.setBackground(background);
+            drawBackground(gc, 0, y, clientAreaWidth, endY - y);
+        }
+    }
+    // fill the margin background
+    gc.setBackground(background);
+    if (topMargin > 0) {
+        drawBackground(gc, 0, 0, clientAreaWidth, topMargin);
+    }
+    if (bottomMargin > 0) {
+        drawBackground(gc, 0, clientAreaHeight - bottomMargin, clientAreaWidth, bottomMargin);
+    }
+    if (leftMargin > 0) {
+        drawBackground(gc, 0, 0, leftMargin, clientAreaHeight);
+    }
+    if (rightMargin > 0) {
+        drawBackground(gc, clientAreaWidth - rightMargin, 0, rightMargin, clientAreaHeight);
+    }
+}
+/**
+ * Recalculates the scroll bars. Rewraps all lines when in word 
+ * wrap mode.
+ *
+ * @param event resize event
+ */
+void handleResize(Event event) {
+    int oldHeight = clientAreaHeight;
+    int oldWidth = clientAreaWidth;
+    Rectangle clientArea = getClientArea();
+    clientAreaHeight = clientArea.height;
+    clientAreaWidth = clientArea.width;
+    /* Redraw the old or new right/bottom margin if needed */
+    if (oldWidth !is clientAreaWidth) {
+        if (rightMargin > 0) {
+            int x = (oldWidth < clientAreaWidth ? oldWidth : clientAreaWidth) - rightMargin; 
+            super.redraw(x, 0, rightMargin, oldHeight, false);
+        }
+    }
+    if (oldHeight !is clientAreaHeight) {
+        if (bottomMargin > 0) {
+            int y = (oldHeight < clientAreaHeight ? oldHeight : clientAreaHeight) - bottomMargin; 
+            super.redraw(0, y, oldWidth, bottomMargin, false);
+        }
+    }
+    if (wordWrap) {
+        if (oldWidth !is clientAreaWidth) {
+            renderer.reset(0, content.getLineCount());
+            verticalScrollOffset = -1;
+            renderer.calculateIdle();
+            super.redraw();
+        }
+        if (oldHeight !is clientAreaHeight) {
+            if (oldHeight is 0) topIndexY = 0;
+            setScrollBars(true);
+        }
+        setCaretLocation();
+    } else  {
+        renderer.calculateClientArea();
+        setScrollBars(true);
+        claimRightFreeSpace();
+        // StyledText allows any value for horizontalScrollOffset when clientArea is zero
+        // in setHorizontalPixel() and setHorisontalOffset(). Fixes bug 168429.
+        if (clientAreaWidth !is 0) {
+            ScrollBar horizontalBar = getHorizontalBar();
+            if (horizontalBar !is null && horizontalBar.getVisible()) {
+                if (horizontalScrollOffset !is horizontalBar.getSelection()) {
+                    horizontalBar.setSelection(horizontalScrollOffset);
+                    horizontalScrollOffset = horizontalBar.getSelection();
+                }
+            }
+        }
+    }
+    claimBottomFreeSpace();
+    //TODO FIX TOP INDEX DURING RESIZE
+//  if (oldHeight !is clientAreaHeight || wordWrap) {
+//      calculateTopIndex(0);
+//  }
+}
+/**
+ * Updates the caret position and selection and the scroll bars to reflect 
+ * the content change.
+ */
+void handleTextChanged(TextChangedEvent event) {
+    int firstLine = content.getLineAtOffset(lastTextChangeStart);
+    resetCache(firstLine, 0);
+    if (!isFixedLineHeight() && topIndex > firstLine) {
+        topIndex = firstLine;
+        topIndexY = 0;
+        super.redraw();
+    } else {
+        int lastLine = firstLine + lastTextChangeNewLineCount;
+        int firstLineTop = getLinePixel(firstLine);
+        int newLastLineBottom = getLinePixel(lastLine + 1);
+        if (lastLineBottom !is newLastLineBottom) {
+            super.redraw();
+            if (wordWrap) setCaretLocation();
+        } else {
+            super.redraw(0, firstLineTop, clientAreaWidth, newLastLineBottom - firstLineTop, false);
+            redrawLinesBullet(renderer.redrawLines);
+        }
+    }
+    renderer.redrawLines = null;
+    // update selection/caret location after styles have been changed.
+    // otherwise any text measuring could be incorrect
+    // 
+    // also, this needs to be done after all scrolling. Otherwise, 
+    // selection redraw would be flushed during scroll which is wrong.
+    // in some cases new text would be drawn in scroll source area even 
+    // though the intent is to scroll it.
+    updateSelection(lastTextChangeStart, lastTextChangeReplaceCharCount, lastTextChangeNewCharCount);
+    if (lastTextChangeReplaceLineCount > 0 || wordWrap) {
+        claimBottomFreeSpace();
+    }
+    if (lastTextChangeReplaceCharCount > 0) {
+        claimRightFreeSpace();
+    }
+}
+/**
+ * Updates the screen to reflect a pending content change.
+ *
+ * @param event .start the start offset of the change
+ * @param event .newText text that is going to be inserted or empty String 
+ *  if no text will be inserted
+ * @param event .replaceCharCount length of text that is going to be replaced
+ * @param event .newCharCount length of text that is going to be inserted
+ * @param event .replaceLineCount number of lines that are going to be replaced
+ * @param event .newLineCount number of new lines that are going to be inserted
+ */
+void handleTextChanging(TextChangingEvent event) {
+    if (event.replaceCharCount < 0) {
+        event.start += event.replaceCharCount;
+        event.replaceCharCount *= -1;
+    }
+    lastTextChangeStart = event.start;
+    lastTextChangeNewLineCount = event.newLineCount;
+    lastTextChangeNewCharCount = event.newCharCount;
+    lastTextChangeReplaceLineCount = event.replaceLineCount;
+    lastTextChangeReplaceCharCount = event.replaceCharCount;    
+    int lineIndex = content.getLineAtOffset(event.start);
+    int srcY = getLinePixel(lineIndex + event.replaceLineCount + 1);
+    int destY = getLinePixel(lineIndex + 1) + event.newLineCount * renderer.getLineHeight();
+    lastLineBottom = destY;
+    if (srcY < 0 && destY < 0) {
+        lastLineBottom += srcY - destY;
+        verticalScrollOffset += destY - srcY;
+        calculateTopIndex(destY - srcY);
+        setScrollBars(true);
+    } else {
+        scrollText(srcY, destY);
+    }
+
+    renderer.textChanging(event);
+    
+    // Update the caret offset if it is greater than the length of the content.
+    // This is necessary since style range API may be called between the
+    // handleTextChanging and handleTextChanged events and this API sets the
+    // caretOffset.
+    int newEndOfText = content.getCharCount() - event.replaceCharCount + event.newCharCount;
+    if (caretOffset > newEndOfText) caretOffset = newEndOfText;
+}
+/**
+ * Called when the widget content is set programmatically, overwriting 
+ * the old content. Resets the caret position, selection and scroll offsets. 
+ * Recalculates the content width and scroll bars. Redraws the widget.
+ *
+ * @param event text change event. 
+ */
+void handleTextSet(TextChangedEvent event) {
+    reset();
+}
+/**
+ * Called when a traversal key is pressed.
+ * Allow tab next traversal to occur when the widget is in single 
+ * line mode or in multi line and non-editable mode . 
+ * When in editable multi line mode we want to prevent the tab 
+ * traversal and receive the tab key event instead.
+ *
+ * @param event the event
+ */
+void handleTraverse(Event event) {
+    switch (event.detail) {
+        case DWT.TRAVERSE_ESCAPE:
+        case DWT.TRAVERSE_PAGE_NEXT:
+        case DWT.TRAVERSE_PAGE_PREVIOUS:
+            event.doit = true;
+            break;
+        case DWT.TRAVERSE_RETURN:
+        case DWT.TRAVERSE_TAB_NEXT:
+        case DWT.TRAVERSE_TAB_PREVIOUS:
+            if ((getStyle() & DWT.SINGLE) !is 0) {
+                event.doit = true;
+            } else {
+                if (!editable || (event.stateMask & DWT.MODIFIER_MASK) !is 0) {
+                    event.doit = true;
+                }
+            }
+            break;
+    }
+}
+/** 
+ * Scrolls the widget vertically.
+ */
+void handleVerticalScroll(Event event) {
+    int scrollPixel = getVerticalBar().getSelection() - getVerticalScrollOffset();
+    scrollVertical(scrollPixel, false);
+}
+/**
+ * Add accessibility support for the widget.
+ */
+void initializeAccessible() {
+    final Accessible accessible = getAccessible();
+    accessible.addAccessibleListener(new AccessibleAdapter() {
+        public void getName (AccessibleEvent e) {
+            String name = null;
+            Label label = getAssociatedLabel ();
+            if (label !is null) {
+                name = stripMnemonic (label.getText());
+            }
+            e.result = name;
+        }
+        public void getHelp(AccessibleEvent e) {
+            e.result = getToolTipText();
+        }
+        public void getKeyboardShortcut(AccessibleEvent e) {
+            String shortcut = null;
+            Label label = getAssociatedLabel ();
+            if (label !is null) {
+                String text = label.getText ();
+                if (text !is null) {
+                    char mnemonic = _findMnemonic (text);
+                    if (mnemonic !is '\0') {
+                        shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
+                    }
+                }
+            }
+            e.result = shortcut;
+        }
+    });
+    accessible.addAccessibleTextListener(new AccessibleTextAdapter() {
+        public void getCaretOffset(AccessibleTextEvent e) {
+            e.offset = StyledText.this.getCaretOffset();
+        }
+        public void getSelectionRange(AccessibleTextEvent e) {
+            Point selection = StyledText.this.getSelectionRange();
+            e.offset = selection.x;
+            e.length = selection.y;
+        }
+    });
+    accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
+        public void getRole(AccessibleControlEvent e) {
+            e.detail = ACC.ROLE_TEXT;
+        }
+        public void getState(AccessibleControlEvent e) {
+            int state = 0;
+            if (isEnabled()) state |= ACC.STATE_FOCUSABLE;
+            if (isFocusControl()) state |= ACC.STATE_FOCUSED;
+            if (!isVisible()) state |= ACC.STATE_INVISIBLE;
+            if (!getEditable()) state |= ACC.STATE_READONLY;
+            e.detail = state;
+        }
+        public void getValue(AccessibleControlEvent e) {
+            e.result = StyledText.this.getText();
+        }
+    }); 
+    addListener(DWT.FocusIn, new Listener() {
+        public void handleEvent(Event event) {
+            accessible.setFocus(ACC.CHILDID_SELF);
+        }
+    }); 
+}
+/* 
+ * Return the Label immediately preceding the receiver in the z-order, 
+ * or null if none. 
+ */
+Label getAssociatedLabel () {
+    Control[] siblings = getParent ().getChildren ();
+    for (int i = 0; i < siblings.length; i++) {
+        if (siblings [i] is StyledText.this) {
+            if (i > 0 && siblings [i-1] instanceof Label) {
+                return (Label) siblings [i-1];
+            }
+        }
+    }
+    return null;
+}
+String stripMnemonic (String String) {
+    int index = 0;
+    int length = String.length ();
+    do {
+        while ((index < length) && (String.charAt (index) !is '&')) index++;
+        if (++index >= length) return String;
+        if (String.charAt (index) !is '&') {
+            return String.substring(0, index-1) + String.substring(index, length);
+        }
+        index++;
+    } while (index < length);
+    return String;
+}
+/*
+ * Return the lowercase of the first non-'&' character following
+ * an '&' character in the given String. If there are no '&'
+ * characters in the given String, return '\0'.
+ */
+char _findMnemonic (String String) {
+    if (String is null) return '\0';
+    int index = 0;
+    int length = String.length ();
+    do {
+        while (index < length && String.charAt (index) !is '&') index++;
+        if (++index >= length) return '\0';
+        if (String.charAt (index) !is '&') return Character.toLowerCase (String.charAt (index));
+        index++;
+    } while (index < length);
+    return '\0';
+}
+/**
+ * Executes the action.
+ *
+ * @param action one of the actions defined in ST.java
+ */
+public void invokeAction(int action) {
+    checkWidget();
+    updateCaretDirection = true;
+    switch (action) {
+        // Navigation
+        case ST.LINE_UP:
+            doLineUp(false);
+            clearSelection(true);
+            break;
+        case ST.LINE_DOWN:
+            doLineDown(false);
+            clearSelection(true);
+            break;
+        case ST.LINE_START:
+            doLineStart();
+            clearSelection(true);
+            break;
+        case ST.LINE_END:
+            doLineEnd();
+            clearSelection(true);
+            break;
+        case ST.COLUMN_PREVIOUS:
+            doCursorPrevious();
+            clearSelection(true);
+            break;
+        case ST.COLUMN_NEXT:
+            doCursorNext();
+            clearSelection(true);
+            break;
+        case ST.PAGE_UP:
+            doPageUp(false, -1);
+            clearSelection(true);
+            break;
+        case ST.PAGE_DOWN:
+            doPageDown(false, -1);
+            clearSelection(true);
+            break;
+        case ST.WORD_PREVIOUS:
+            doWordPrevious();
+            clearSelection(true);
+            break;
+        case ST.WORD_NEXT:
+            doWordNext();
+            clearSelection(true);
+            break;
+        case ST.TEXT_START:
+            doContentStart();
+            clearSelection(true);
+            break;
+        case ST.TEXT_END:
+            doContentEnd();
+            clearSelection(true);
+            break;
+        case ST.WINDOW_START:
+            doPageStart();
+            clearSelection(true);
+            break;
+        case ST.WINDOW_END:
+            doPageEnd();
+            clearSelection(true);
+            break;
+        // Selection    
+        case ST.SELECT_LINE_UP:
+            doSelectionLineUp();
+            break;
+        case ST.SELECT_ALL:
+            selectAll();
+            break;
+        case ST.SELECT_LINE_DOWN:
+            doSelectionLineDown();
+            break;
+        case ST.SELECT_LINE_START:
+            doLineStart();
+            doSelection(ST.COLUMN_PREVIOUS);
+            break;
+        case ST.SELECT_LINE_END:
+            doLineEnd();
+            doSelection(ST.COLUMN_NEXT);
+            break;
+        case ST.SELECT_COLUMN_PREVIOUS:
+            doSelectionCursorPrevious();
+            doSelection(ST.COLUMN_PREVIOUS);
+            break;
+        case ST.SELECT_COLUMN_NEXT:
+            doSelectionCursorNext();
+            doSelection(ST.COLUMN_NEXT);
+            break;
+        case ST.SELECT_PAGE_UP:
+            doSelectionPageUp(-1);
+            break;
+        case ST.SELECT_PAGE_DOWN:
+            doSelectionPageDown(-1);
+            break;
+        case ST.SELECT_WORD_PREVIOUS:
+            doSelectionWordPrevious();
+            doSelection(ST.COLUMN_PREVIOUS);
+            break;
+        case ST.SELECT_WORD_NEXT:
+            doSelectionWordNext();
+            doSelection(ST.COLUMN_NEXT);
+            break;
+        case ST.SELECT_TEXT_START:
+            doContentStart();
+            doSelection(ST.COLUMN_PREVIOUS);
+            break;
+        case ST.SELECT_TEXT_END:
+            doContentEnd();
+            doSelection(ST.COLUMN_NEXT);
+            break;
+        case ST.SELECT_WINDOW_START:
+            doPageStart();
+            doSelection(ST.COLUMN_PREVIOUS);
+            break;
+        case ST.SELECT_WINDOW_END:
+            doPageEnd();
+            doSelection(ST.COLUMN_NEXT);
+            break;
+        // Modification         
+        case ST.CUT:
+            cut();
+            break;
+        case ST.COPY:
+            copy();
+            break;
+        case ST.PASTE:
+            paste();
+            break;
+        case ST.DELETE_PREVIOUS:
+            doBackspace();
+            break;
+        case ST.DELETE_NEXT:
+            doDelete();
+            break;
+        case ST.DELETE_WORD_PREVIOUS:
+            doDeleteWordPrevious();
+            break;
+        case ST.DELETE_WORD_NEXT:
+            doDeleteWordNext();
+            break;
+        // Miscellaneous
+        case ST.TOGGLE_OVERWRITE:
+            overwrite = !overwrite;     // toggle insert/overwrite mode
+            break;
+    }
+}
+/**
+ * Temporary until DWT provides this
+ */
+bool isBidi() {
+    return IS_GTK || IS_CARBON || BidiUtil.isBidiPlatform() || isMirrored;
+}
+bool isBidiCaret() {
+    return BidiUtil.isBidiPlatform();
+}
+bool isFixedLineHeight() {
+    return fixedLineHeight;
+}
+/**
+ * Returns whether the given offset is inside a multi byte line delimiter.
+ * Example: 
+ * "Line1\r\n" isLineDelimiter(5) is false but isLineDelimiter(6) is true
+ * 
+ * @return true if the given offset is inside a multi byte line delimiter.
+ * false if the given offset is before or after a line delimiter.
+ */
+bool isLineDelimiter(int offset) {
+    int line = content.getLineAtOffset(offset);
+    int lineOffset = content.getOffsetAtLine(line); 
+    int offsetInLine = offset - lineOffset;
+    // offsetInLine will be greater than line length if the line 
+    // delimiter is longer than one character and the offset is set
+    // in between parts of the line delimiter.
+    return offsetInLine > content.getLine(line).length();
+}
+/**
+ * Returns whether the widget is mirrored (right oriented/right to left 
+ * writing order). 
+ * 
+ * @return isMirrored true=the widget is right oriented, false=the widget 
+ *  is left oriented
+ */
+bool isMirrored() {
+    return isMirrored;
+}
+/**
+ * Returns whether the widget can have only one line.
+ *
+ * @return true if widget can have only one line, false if widget can have 
+ *  multiple lines
+ */
+bool isSingleLine() {
+    return (getStyle() & DWT.SINGLE) !is 0;
+}
+/**
+ * Sends the specified verify event, replace/insert text as defined by 
+ * the event and send a modify event.
+ *
+ * @param event the text change event. 
+ *  <ul>
+ *  <li>event.start - the replace start offset</li>
+ *  <li>event.end - the replace end offset</li>
+ *  <li>event.text - the new text</li>
+ *  </ul>
+ * @param updateCaret whether or not he caret should be set behind
+ *  the new text
+ */
+void modifyContent(Event event, bool updateCaret) {
+    event.doit = true;
+    notifyListeners(DWT.Verify, event);
+    if (event.doit) {
+        StyledTextEvent styledTextEvent = null;
+        int replacedLength = event.end - event.start;
+        if (isListening(ExtendedModify)) {
+            styledTextEvent = new StyledTextEvent(content);
+            styledTextEvent.start = event.start;
+            styledTextEvent.end = event.start + event.text.length();
+            styledTextEvent.text = content.getTextRange(event.start, replacedLength);
+        }
+        if (updateCaret) {
+            //Fix advancing flag for delete/backspace key on direction boundary
+            if (event.text.length() is 0) {
+                int lineIndex = content.getLineAtOffset(event.start);
+                int lineOffset = content.getOffsetAtLine(lineIndex);
+                TextLayout layout = renderer.getTextLayout(lineIndex);
+                int levelStart = layout.getLevel(event.start - lineOffset);
+                int lineIndexEnd = content.getLineAtOffset(event.end);
+                if (lineIndex !is lineIndexEnd) {
+                    renderer.disposeTextLayout(layout);
+                    lineOffset = content.getOffsetAtLine(lineIndexEnd);
+                    layout = renderer.getTextLayout(lineIndexEnd);
+                }
+                int levelEnd = layout.getLevel(event.end - lineOffset);
+                renderer.disposeTextLayout(layout);
+                if (levelStart !is levelEnd) {
+                    caretAlignment = PREVIOUS_OFFSET_TRAILING;
+                } else {
+                    caretAlignment = OFFSET_LEADING;
+                }
+            }
+        }
+        content.replaceTextRange(event.start, replacedLength, event.text);
+        // set the caret position prior to sending the modify event.
+        // fixes 1GBB8NJ
+        if (updateCaret) {
+            // always update the caret location. fixes 1G8FODP
+            setSelection(event.start + event.text.length(), 0, true);
+            showCaret();
+        }
+        sendModifyEvent(event);
+        if (isListening(ExtendedModify)) {
+            notifyListeners(ExtendedModify, styledTextEvent);
+        }
+    }
+}
+void paintObject(GC gc, int x, int y, int ascent, int descent, StyleRange style, Bullet bullet, int bulletIndex) {
+    if (isListening(PaintObject)) {
+        StyledTextEvent event = new StyledTextEvent (content) ;
+        event.gc = gc;
+        event.x = x;
+        event.y = y;
+        event.ascent = ascent;
+        event.descent = descent;
+        event.style = style;
+        event.bullet = bullet;
+        event.bulletIndex = bulletIndex;
+        notifyListeners(PaintObject, event);
+    }
+}
+/** 
+ * Replaces the selection with the text on the <code>DND.CLIPBOARD</code>  
+ * clipboard  or, if there is no selection,  inserts the text at the current 
+ * caret offset.   If the widget has the DWT.SINGLE style and the 
+ * clipboard text contains more than one line, only the first line without
+ * line delimiters is  inserted in the widget.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void paste(){
+    checkWidget();  
+    String text = (String) getClipboardContent(DND.CLIPBOARD);
+    if (text !is null && text.length() > 0) {
+        Event event = new Event();
+        event.start = selection.x;
+        event.end = selection.y;
+        event.text = getModelDelimitedText(text);
+        sendKeyEvent(event);
+    }
+}
+/** 
+ * Prints the widget's text to the default printer.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void print() {
+    checkWidget();
+    Printer printer = new Printer();
+    StyledTextPrintOptions options = new StyledTextPrintOptions();
+    options.printTextForeground = true;
+    options.printTextBackground = true;
+    options.printTextFontStyle = true;
+    options.printLineBackground = true; 
+    new Printing(this, printer, options).run();
+    printer.dispose();
+}
+/** 
+ * Returns a runnable that will print the widget's text
+ * to the specified printer.
+ * <p>
+ * The runnable may be run in a non-UI thread.
+ * </p>
+ * 
+ * @param printer the printer to print to
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when printer is null</li>
+ * </ul>
+ */
+public Runnable print(Printer printer) {
+    checkWidget();  
+    if (printer is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    StyledTextPrintOptions options = new StyledTextPrintOptions();
+    options.printTextForeground = true;
+    options.printTextBackground = true;
+    options.printTextFontStyle = true;
+    options.printLineBackground = true;
+    return print(printer, options);
+}
+/** 
+ * Returns a runnable that will print the widget's text
+ * to the specified printer.
+ * <p>
+ * The runnable may be run in a non-UI thread.
+ * </p>
+ * 
+ * @param printer the printer to print to
+ * @param options print options to use during printing
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when printer or options is null</li>
+ * </ul>
+ * @since 2.1
+ */
+public Runnable print(Printer printer, StyledTextPrintOptions options) {
+    checkWidget();
+    if (printer is null || options is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    return new Printing(this, printer, options);
+}
+/**
+ * Causes the entire bounds of the receiver to be marked
+ * as needing to be redrawn. The next time a paint request
+ * is processed, the control will be completely painted.
+ * <p>
+ * Recalculates the content width for all lines in the bounds.
+ * When a <code>LineStyleListener</code> is used a redraw call 
+ * is the only notification to the widget that styles have changed 
+ * and that the content width may have changed.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#update()
+ */
+public void redraw() {
+    super.redraw();
+    int itemCount = getPartialBottomIndex() - topIndex + 1;
+    renderer.reset(topIndex, itemCount);
+    renderer.calculate(topIndex, itemCount);
+    setScrollBars(false);
+}
+/**
+ * Causes the rectangular area of the receiver specified by
+ * the arguments to be marked as needing to be redrawn. 
+ * The next time a paint request is processed, that area of
+ * the receiver will be painted. If the <code>all</code> flag
+ * is <code>true</code>, any children of the receiver which
+ * intersect with the specified area will also paint their
+ * intersecting areas. If the <code>all</code> flag is 
+ * <code>false</code>, the children will not be painted.
+ * <p>
+ * Marks the content width of all lines in the specified rectangle
+ * as unknown. Recalculates the content width of all visible lines.
+ * When a <code>LineStyleListener</code> is used a redraw call 
+ * is the only notification to the widget that styles have changed 
+ * and that the content width may have changed.
+ * </p>
+ *
+ * @param x the x coordinate of the area to draw
+ * @param y the y coordinate of the area to draw
+ * @param width the width of the area to draw
+ * @param height the height of the area to draw
+ * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#update()
+ */
+public void redraw(int x, int y, int width, int height, bool all) {
+    super.redraw(x, y, width, height, all);
+    if (height > 0) {
+        int firstLine = getLineIndex(y);
+        int lastLine = getLineIndex(y + height);
+        resetCache(firstLine, lastLine - firstLine + 1);
+    }
+}
+void redrawLines(int startLine, int lineCount) {
+    // do nothing if redraw range is completely invisible   
+    int partialBottomIndex = getPartialBottomIndex();
+    if (startLine > partialBottomIndex || startLine + lineCount - 1 < topIndex) {
+        return;
+    }
+    // only redraw visible lines
+    if (startLine < topIndex) {
+        lineCount -= topIndex - startLine;
+        startLine = topIndex;
+    }
+    if (startLine + lineCount - 1 > partialBottomIndex) {
+        lineCount = partialBottomIndex - startLine + 1;
+    }
+    startLine -= topIndex;
+    int redrawTop = getLinePixel(startLine);
+    int redrawBottom = getLinePixel(startLine + lineCount);
+    int redrawWidth = clientAreaWidth - leftMargin - rightMargin; 
+    super.redraw(leftMargin, redrawTop, redrawWidth, redrawBottom - redrawTop, true);
+}
+void redrawLinesBullet (int[] redrawLines) {
+    if (redrawLines is null) return;
+    int topIndex = getPartialTopIndex();
+    int bottomIndex = getPartialBottomIndex();
+    for (int i = 0; i < redrawLines.length; i++) {
+        int lineIndex = redrawLines[i];
+        if (!(topIndex <= lineIndex && lineIndex <= bottomIndex)) continue;
+        int width = -1;
+        Bullet bullet = renderer.getLineBullet(lineIndex, null);
+        if (bullet !is null) {
+            StyleRange style = bullet.style;
+            GlyphMetrics metrics = style.metrics;
+            width = metrics.width;
+        }
+        if (width is -1) width = getClientArea().width;
+        int height = renderer.getLineHeight(lineIndex);
+        int y = getLinePixel(lineIndex);
+        super.redraw(0, y, width, height, false);
+    }
+}
+/** 
+ * Redraws the specified text range.
+ *
+ * @param start offset of the first character to redraw
+ * @param length number of characters to redraw
+ * @param clearBackground true if the background should be cleared as
+ *  part of the redraw operation.  If true, the entire redraw range will
+ *  be cleared before anything is redrawn.  If the redraw range includes
+ *  the last character of a line (i.e., the entire line is redrawn) the 
+ *  line is cleared all the way to the right border of the widget.
+ *  The redraw operation will be faster and smoother if clearBackground 
+ *  is set to false.  Whether or not the flag can be set to false depends 
+ *  on the type of change that has taken place.  If font styles or 
+ *  background colors for the redraw range have changed, clearBackground 
+ *  should be set to true.  If only foreground colors have changed for 
+ *  the redraw range, clearBackground can be set to false. 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ */
+public void redrawRange(int start, int length, bool clearBackground) {
+    checkWidget();
+    int end = start + length;
+    int contentLength = content.getCharCount();
+    if (start > end || start < 0 || end > contentLength) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    int firstLine = content.getLineAtOffset(start);
+    int lastLine = content.getLineAtOffset(end);
+    resetCache(firstLine, lastLine - firstLine + 1);
+    internalRedrawRange(start, length);
+}
+/**
+ * Removes the specified bidirectional segment listener.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * @since 2.0
+ */
+public void removeBidiSegmentListener(BidiSegmentListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(LineGetSegments, listener);  
+}
+/**
+ * Removes the specified extended modify listener.
+ *
+ * @param extendedModifyListener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener) {
+    checkWidget();
+    if (extendedModifyListener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(ExtendedModify, extendedModifyListener); 
+}
+/**
+ * Removes the specified line background listener.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeLineBackgroundListener(LineBackgroundListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(LineGetBackground, listener);
+}
+/**
+ * Removes the specified line style listener.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeLineStyleListener(LineStyleListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(LineGetStyle, listener);
+}
+/**
+ * Removes the specified modify listener.
+ *
+ * @param modifyListener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeModifyListener(ModifyListener modifyListener) {
+    checkWidget();
+    if (modifyListener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(DWT.Modify, modifyListener);
+}
+/**
+ * Removes the specified listener.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * @since 3.2
+ */
+public void removePaintObjectListener(PaintObjectListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(PaintObject, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(DWT.Selection, listener);
+}
+/**
+ * Removes the specified verify listener.
+ *
+ * @param verifyListener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeVerifyListener(VerifyListener verifyListener) {
+    checkWidget();
+    if (verifyListener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(DWT.Verify, verifyListener);
+}
+/**
+ * Removes the specified key verify listener.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeVerifyKeyListener(VerifyKeyListener listener) {
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(VerifyKey, listener);
+}
+/**
+ * Removes the specified word movement listener.
+ *
+ * @param listener the listener
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * 
+ * @see MovementEvent
+ * @see MovementListener
+ * @see #addWordMovementListener
+ * 
+ * @since 3.3
+ */
+
+public void removeWordMovementListener(MovementListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    removeListener(WordNext, listener); 
+    removeListener(WordPrevious, listener);
+}
+/** 
+ * Replaces the styles in the given range with new styles.  This method
+ * effectively deletes the styles in the given range and then adds the
+ * the new styles. 
+ * <p>
+ * Note: Because a StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>setStyleRanges(int, int, int[], StyleRange[])</code>
+ * can be used to share styles and reduce memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param start offset of first character where styles will be deleted
+ * @param length length of the range to delete styles in
+ * @param ranges StyleRange objects containing the new style information.
+ * The ranges should not overlap and should be within the specified start 
+ * and length. The style rendering is undefined if the ranges do overlap
+ * or are ill-defined. Must not be null.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li> 
+ *   <li>ERROR_NULL_ARGUMENT when ranges is null</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ * @see #setStyleRanges(int, int, int[], StyleRange[])
+ */
+public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    setStyleRanges(start, length, null, ranges, false);
+}
+/**
+ * Replaces the given text range with new text.
+ * If the widget has the DWT.SINGLE style and "text" contains more than 
+ * one line, only the first line is rendered but the text is stored 
+ * unchanged. A subsequent call to getText will return the same text 
+ * that was set. Note that only a single line of text should be set when 
+ * the DWT.SINGLE style is used.
+ * <p>
+ * <b>NOTE:</b> During the replace operation the current selection is
+ * changed as follows:
+ * <ul> 
+ * <li>selection before replaced text: selection unchanged
+ * <li>selection after replaced text: adjust the selection so that same text 
+ * remains selected
+ * <li>selection intersects replaced text: selection is cleared and caret
+ * is placed after inserted text
+ * </ul>
+ * </p>
+ *
+ * @param start offset of first character to replace
+ * @param length number of characters to replace. Use 0 to insert text
+ * @param text new text. May be empty to delete text.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li> 
+ *   <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter. 
+ *      Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li>  
+ *   <li>ERROR_NULL_ARGUMENT when String is null</li>
+ * </ul>
+ */
+public void replaceTextRange(int start, int length, String text) {
+    checkWidget();
+    if (text is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    int contentLength = getCharCount();
+    int end = start + length;
+    if (start > end || start < 0 || end > contentLength) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    Event event = new Event();
+    event.start = start;
+    event.end = end;
+    event.text = text;
+    modifyContent(event, false);
+}
+/**
+ * Resets the caret position, selection and scroll offsets. Recalculate
+ * the content width and scroll bars. Redraw the widget.
+ */
+void reset() {
+    ScrollBar verticalBar = getVerticalBar();
+    ScrollBar horizontalBar = getHorizontalBar();
+    caretOffset = 0;
+    topIndex = 0;
+    topIndexY = 0;
+    verticalScrollOffset = 0;
+    horizontalScrollOffset = 0; 
+    resetSelection();
+    renderer.setContent(content);
+    if (verticalBar !is null) {
+        verticalBar.setSelection(0);
+    }
+    if (horizontalBar !is null) {
+        horizontalBar.setSelection(0);  
+    }
+    resetCache(0, 0);
+    setCaretLocation();
+    super.redraw();
+}
+void resetCache(int firstLine, int count) {
+    int maxLineIndex = renderer.maxWidthLineIndex;
+    renderer.reset(firstLine, count);
+    renderer.calculateClientArea();
+    if (0 <= maxLineIndex && maxLineIndex < content.getLineCount()) {
+        renderer.calculate(maxLineIndex, 1);
+    }
+    setScrollBars(true);
+    if (!isFixedLineHeight()) {
+        if (topIndex > firstLine) {
+            verticalScrollOffset = -1;
+        }
+        renderer.calculateIdle();
+    }
+}
+/**
+ * Resets the selection.
+ */
+void resetSelection() {
+    selection.x = selection.y = caretOffset;
+    selectionAnchor = -1;
+}
+
+public void scroll(int destX, int destY, int x, int y, int width, int height, bool all) {
+    super.scroll(destX, destY, x, y, width, height, false);
+    if (all) {
+        int deltaX = destX - x, deltaY = destY - y;
+        Control[] children = getChildren();
+        for (int i=0; i<children.length; i++) {
+            Control child = children[i];
+            Rectangle rect = child.getBounds();
+            child.setLocation(rect.x + deltaX, rect.y + deltaY);
+        }
+    }
+}
+
+/**
+ * Scrolls the widget horizontally.
+ *
+ * @param pixels number of pixels to scroll, > 0 = scroll left,
+ *  < 0 scroll right
+ * @param adjustScrollBar 
+ *  true= the scroll thumb will be moved to reflect the new scroll offset.
+ *  false = the scroll thumb will not be moved
+ * @return 
+ *  true=the widget was scrolled 
+ *  false=the widget was not scrolled, the given offset is not valid.
+ */
+bool scrollHorizontal(int pixels, bool adjustScrollBar) {
+    if (pixels is 0) {
+        return false;
+    }
+    ScrollBar horizontalBar = getHorizontalBar();
+    if (horizontalBar !is null && adjustScrollBar) {
+        horizontalBar.setSelection(horizontalScrollOffset + pixels);
+    }
+    int scrollHeight = clientAreaHeight - topMargin - bottomMargin;
+    if (pixels > 0) {
+        int sourceX = leftMargin + pixels;
+        int scrollWidth = clientAreaWidth - sourceX - rightMargin;
+        if (scrollWidth > 0) {
+            scroll(leftMargin, topMargin, sourceX, topMargin, scrollWidth, scrollHeight, true);
+        }
+        if (sourceX > scrollWidth) {
+            super.redraw(leftMargin + scrollWidth, topMargin, pixels - scrollWidth, scrollHeight, true);
+        }
+    } else {
+        int destinationX = leftMargin - pixels;
+        int scrollWidth = clientAreaWidth - destinationX - rightMargin;
+        if (scrollWidth > 0) {
+            scroll(destinationX, topMargin, leftMargin, topMargin, scrollWidth, scrollHeight, true);
+        }
+        if (destinationX > scrollWidth) {
+            super.redraw(leftMargin + scrollWidth, topMargin, -pixels - scrollWidth, scrollHeight, true);
+        }
+    }
+    horizontalScrollOffset += pixels;
+    setCaretLocation();
+    return true;
+}
+/**
+ * Scrolls the widget vertically.
+ *
+ * @param pixel the new vertical scroll offset
+ * @param adjustScrollBar 
+ *  true= the scroll thumb will be moved to reflect the new scroll offset.
+ *  false = the scroll thumb will not be moved
+ * @return 
+ *  true=the widget was scrolled 
+ *  false=the widget was not scrolled
+ */
+bool scrollVertical(int pixels, bool adjustScrollBar) {
+    if (pixels is 0) {
+        return false;
+    }
+    if (verticalScrollOffset !is -1) {
+        ScrollBar verticalBar = getVerticalBar();
+        if (verticalBar !is null && adjustScrollBar) {
+            verticalBar.setSelection(verticalScrollOffset + pixels);
+        }
+        int scrollWidth = clientAreaWidth - leftMargin - rightMargin;
+        if (pixels > 0) {
+            int sourceY = topMargin + pixels;
+            int scrollHeight = clientAreaHeight - sourceY - bottomMargin;
+            if (scrollHeight > 0) {
+                scroll(leftMargin, topMargin, leftMargin, sourceY, scrollWidth, scrollHeight, true);
+            }
+            if (sourceY > scrollHeight) {
+                int redrawY = Math.max(0, topMargin + scrollHeight);
+                int redrawHeight = Math.min(clientAreaHeight, pixels - scrollHeight);
+                super.redraw(leftMargin, redrawY, scrollWidth, redrawHeight, true);
+            }
+        } else {
+            int destinationY = topMargin - pixels;
+            int scrollHeight = clientAreaHeight - destinationY - bottomMargin;
+            if (scrollHeight > 0) {
+                scroll(leftMargin, destinationY, leftMargin, topMargin, scrollWidth, scrollHeight, true);
+            }
+            if (destinationY > scrollHeight) {
+                int redrawY = Math.max(0, topMargin + scrollHeight);
+                int redrawHeight = Math.min(clientAreaHeight, -pixels - scrollHeight);
+                super.redraw(leftMargin, redrawY, scrollWidth, redrawHeight, true);
+            }
+        }
+        verticalScrollOffset += pixels;
+        calculateTopIndex(pixels);
+    } else {
+        calculateTopIndex(pixels);
+        super.redraw();
+    }
+    setCaretLocation();
+    return true;
+}
+void scrollText(int srcY, int destY) {
+    if (srcY is destY) return;
+    int deltaY = destY - srcY;
+    int scrollWidth = clientAreaWidth - leftMargin - rightMargin, scrollHeight;
+    if (deltaY > 0) {
+        scrollHeight = clientAreaHeight - srcY - bottomMargin;
+    } else {
+        scrollHeight = clientAreaHeight - destY - bottomMargin;
+    }
+    scroll(leftMargin, destY, leftMargin, srcY, scrollWidth, scrollHeight, true);
+    if ((0 < srcY + scrollHeight) && (topMargin > srcY)) {
+        super.redraw(leftMargin, deltaY, scrollWidth, topMargin, false);
+    }
+    if ((0 < destY + scrollHeight) && (topMargin > destY)) {
+        super.redraw(leftMargin, 0, scrollWidth, topMargin, false);
+    }
+    if ((clientAreaHeight - bottomMargin < srcY + scrollHeight) && (clientAreaHeight > srcY)) {
+        super.redraw(leftMargin, clientAreaHeight - bottomMargin + deltaY, scrollWidth, bottomMargin, false);
+    }
+    if ((clientAreaHeight - bottomMargin < destY + scrollHeight) && (clientAreaHeight > destY)) {
+        super.redraw(leftMargin, clientAreaHeight - bottomMargin, scrollWidth, bottomMargin, false);
+    }
+}
+/** 
+ * Selects all the text.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll() {
+    checkWidget();
+    setSelection(0, Math.max(getCharCount(),0));
+}
+/**
+ * Replaces/inserts text as defined by the event.
+ *
+ * @param event the text change event. 
+ *  <ul>
+ *  <li>event.start - the replace start offset</li>
+ *  <li>event.end - the replace end offset</li>
+ *  <li>event.text - the new text</li>
+ *  </ul>
+ */
+void sendKeyEvent(Event event) {
+    if (editable) {
+        modifyContent(event, true);
+    }
+}
+/**
+ * Returns a StyledTextEvent that can be used to request data such 
+ * as styles and background color for a line.
+ * <p>
+ * The specified line may be a visual (wrapped) line if in word 
+ * wrap mode. The returned object will always be for a logical 
+ * (unwrapped) line.
+ * </p>
+ *
+ * @param lineOffset offset of the line. This may be the offset of
+ *  a visual line if the widget is in word wrap mode.
+ * @param line line text. This may be the text of a visual line if 
+ *  the widget is in word wrap mode.
+ * @return StyledTextEvent that can be used to request line data 
+ *  for the given line.
+ */
+StyledTextEvent sendLineEvent(int eventType, int lineOffset, String line) {
+    StyledTextEvent event = null;
+    if (isListening(eventType)) {
+        event = new StyledTextEvent(content);
+        event.detail = lineOffset;
+        event.text = line;
+        event.alignment = alignment;
+        event.indent = indent;
+        event.justify = justify;
+        notifyListeners(eventType, event);
+    }
+    return event;
+}
+void sendModifyEvent(Event event) {
+    Accessible accessible = getAccessible();
+    if (event.text.length() is 0) {
+        accessible.textChanged(ACC.TEXT_DELETE, event.start, event.end - event.start);
+    } else {
+        if (event.start is event.end) {
+            accessible.textChanged(ACC.TEXT_INSERT, event.start, event.text.length());
+        } else {
+            accessible.textChanged(ACC.TEXT_DELETE, event.start, event.end - event.start);
+            accessible.textChanged(ACC.TEXT_INSERT, event.start, event.text.length());  
+        }
+    }
+    notifyListeners(DWT.Modify, event);
+}
+/**
+ * Sends the specified selection event.
+ */
+void sendSelectionEvent() {
+    getAccessible().textSelectionChanged();
+    Event event = new Event();
+    event.x = selection.x;
+    event.y = selection.y;
+    notifyListeners(DWT.Selection, event);
+}
+int sendWordBoundaryEvent(int eventType, int movement, int offset, int newOffset, String lineText, int lineOffset) {
+    if (isListening(eventType)) {
+        StyledTextEvent event = new StyledTextEvent(content);
+        event.detail = lineOffset;
+        event.text = lineText;
+        event.count = movement;
+        event.start = offset;
+        event.end = newOffset;
+        notifyListeners(eventType, event);
+        offset = event.end;
+        if (offset !is newOffset) {
+            int length = getCharCount();
+            if (offset < 0) {
+                offset = 0;
+            } else if (offset > length) {
+                offset = length;
+            } else {
+                if (isLineDelimiter(offset)) {
+                    DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+                }
+            }
+        }
+        return offset;
+    }
+    return newOffset;
+}
+/**
+ * Sets the alignment of the widget. The argument should be one of <code>DWT.LEFT</code>, 
+ * <code>DWT.CENTER</code> or <code>DWT.RIGHT</code>. The alignment applies for all lines.
+ * </p><p>
+ * Note that if <code>DWT.MULTI</code> is set, then <code>DWT.WRAP</code> must also be set
+ * in order to stabilize the right edge before setting alignment.
+ * </p>
+ * 
+ * @param alignment the new alignment
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLineAlignment(int, int, int)
+ *  
+ * @since 3.2
+ */
+public void setAlignment(int alignment) {
+    checkWidget();
+    alignment &= (DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    if (alignment is 0 || this.alignment is alignment) return;
+    this.alignment = alignment;
+    resetCache(0, content.getLineCount());
+    setCaretLocation();
+    super.redraw();
+}
+/**
+ * @see Control#setBackground(Color)
+ */
+public void setBackground(Color color) {
+    checkWidget();
+    background = color;
+    super.setBackground(color);
+    super.redraw();
+}
+/**
+ * Sets the receiver's caret.  Set the caret's height and location.
+ * 
+ * </p>
+ * @param caret the new caret for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCaret(Caret caret) {
+    checkWidget ();
+    super.setCaret(caret);
+    caretDirection = DWT.NULL;
+    if (caret !is null) {
+        setCaretLocation();
+    }
+}
+/**
+ * Sets the BIDI coloring mode.  When true the BIDI text display
+ * algorithm is applied to segments of text that are the same
+ * color.
+ *
+ * @param mode the new coloring mode
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated use BidiSegmentListener instead.
+ */
+public void setBidiColoring(bool mode) {
+    checkWidget();
+    bidiColoring = mode;
+}
+/**
+ * Moves the Caret to the current caret offset.
+ */
+void setCaretLocation() {
+    Point newCaretPos = getPointAtOffset(caretOffset);
+    setCaretLocation(newCaretPos, getCaretDirection());
+}
+void setCaretLocation(Point location, int direction) {
+    Caret caret = getCaret();
+    if (caret !is null) {
+        bool isDefaultCaret = caret is defaultCaret;
+        int lineHeight = renderer.getLineHeight();
+        int caretHeight = lineHeight;
+        if (!isFixedLineHeight() && isDefaultCaret) {
+            caretHeight = getBoundsAtOffset(caretOffset).height;
+            if (caretHeight !is lineHeight) {
+                direction = DWT.DEFAULT;
+            }
+        }
+        int imageDirection = direction;
+        if (isMirrored()) {
+            if (imageDirection is DWT.LEFT) {
+                imageDirection = DWT.RIGHT;
+            } else if (imageDirection is DWT.RIGHT) {
+                imageDirection = DWT.LEFT;
+            }
+        }
+        if (isDefaultCaret && imageDirection is DWT.RIGHT) {
+            location.x -= (caret.getSize().x - 1);
+        }
+        if (isDefaultCaret) {
+            caret.setBounds(location.x, location.y, caretWidth, caretHeight);
+        } else {
+            caret.setLocation(location);
+        }
+        getAccessible().textCaretMoved(getCaretOffset());
+        if (direction !is caretDirection) {
+            caretDirection = direction;
+            if (isDefaultCaret) {
+                if (imageDirection is DWT.DEFAULT) {
+                    defaultCaret.setImage(null);
+                } else if (imageDirection is DWT.LEFT) {
+                    defaultCaret.setImage(leftCaretBitmap);
+                } else if (imageDirection is DWT.RIGHT) {
+                    defaultCaret.setImage(rightCaretBitmap);
+                }
+            }
+            if (caretDirection is DWT.LEFT) {
+                BidiUtil.setKeyboardLanguage(BidiUtil.KEYBOARD_NON_BIDI);
+            } else if (caretDirection is DWT.RIGHT) {
+                BidiUtil.setKeyboardLanguage(BidiUtil.KEYBOARD_BIDI);
+            }
+        }
+    }
+    columnX = location.x;
+}
+/**
+ * Sets the caret offset.
+ *
+ * @param offset caret offset, relative to the first character in the text.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setCaretOffset(int offset) {
+    checkWidget();
+    int length = getCharCount();
+    if (length > 0 && offset !is caretOffset) {
+        if (offset < 0) {
+            caretOffset = 0;
+        } else if (offset > length) {
+            caretOffset = length;
+        } else {
+            if (isLineDelimiter(offset)) {
+                // offset is inside a multi byte line delimiter. This is an 
+                // illegal operation and an exception is thrown. Fixes 1GDKK3R
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            }
+            caretOffset = offset;
+        }
+        caretAlignment = PREVIOUS_OFFSET_TRAILING;
+        // clear the selection if the caret is moved.
+        // don't notify listeners about the selection change.
+        clearSelection(false);
+    }
+    setCaretLocation();
+}   
+/**
+ * Copies the specified text range to the clipboard.  The text will be placed
+ * in the clipboard in plain text format and RTF format.
+ *
+ * @param start start index of the text
+ * @param length length of text to place in clipboard
+ * 
+ * @exception DWTError, see Clipboard.setContents
+ * @see dwt.dnd.Clipboard#setContents
+ */
+void setClipboardContent(int start, int length, int clipboardType) throws DWTError {
+    if (clipboardType is DND.SELECTION_CLIPBOARD && !(IS_MOTIF || IS_GTK)) return;
+    TextTransfer plainTextTransfer = TextTransfer.getInstance();
+    TextWriter plainTextWriter = new TextWriter(start, length);
+    String plainText = getPlatformDelimitedText(plainTextWriter);
+    Object[] data;
+    Transfer[] types;
+    if (clipboardType is DND.SELECTION_CLIPBOARD) {
+        data = new Object[]{plainText};
+        types = new Transfer[]{plainTextTransfer};
+    } else {
+        RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+        RTFWriter rtfWriter = new RTFWriter(start, length);
+        String rtfText = getPlatformDelimitedText(rtfWriter);
+        data = new Object[]{rtfText, plainText};
+        types = new Transfer[]{rtfTransfer, plainTextTransfer};
+    }
+    clipboard.setContents(data, types, clipboardType);
+}
+/**
+ * Sets the content implementation to use for text storage.
+ *
+ * @param newContent StyledTextContent implementation to use for text storage.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void setContent(StyledTextContent newContent) {
+    checkWidget();  
+    if (newContent is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    if (content !is null) {
+        content.removeTextChangeListener(textChangeListener);
+    }
+    content = newContent;
+    content.addTextChangeListener(textChangeListener);
+    reset();
+}
+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument.  Overridden to handle the null case since the 
+ * StyledText widget uses an ibeam as its default cursor.
+ *
+ * @see Control#setCursor(Cursor)
+ */
+public void setCursor (Cursor cursor) {
+    if (cursor is null) {
+        Display display = getDisplay();
+        super.setCursor(display.getSystemCursor(DWT.CURSOR_IBEAM));
+    } else {
+        super.setCursor(cursor);
+    }
+}
+/** 
+ * Sets whether the widget : double click mouse behavior.
+ * </p>
+ *
+ * @param enable if true double clicking a word selects the word, if false
+ *  double clicks have the same effect as regular mouse clicks.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDoubleClickEnabled(bool enable) {
+    checkWidget();
+    doubleClickEnabled = enable;
+}
+public void setDragDetect (bool dragDetect) {
+    checkWidget ();
+    this.dragDetect = dragDetect;
+}
+/**
+ * Sets whether the widget content can be edited.
+ * </p>
+ *
+ * @param editable if true content can be edited, if false content can not be 
+ *  edited
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEditable(bool editable) {
+    checkWidget();
+    this.editable = editable;
+}
+/**
+ * Sets a new font to render text with.
+ * <p>
+ * <b>NOTE:</b> Italic fonts are not supported unless they have no overhang
+ * and the same baseline as regular fonts.
+ * </p>
+ *
+ * @param font new font
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont(Font font) {
+    checkWidget();
+    int oldLineHeight = renderer.getLineHeight();
+    super.setFont(font);    
+    renderer.setFont(getFont(), tabLength);
+    // keep the same top line visible. fixes 5815
+    if (isFixedLineHeight()) {
+        int lineHeight = renderer.getLineHeight();
+        if (lineHeight !is oldLineHeight) {
+            int vscroll = (getVerticalScrollOffset() * lineHeight / oldLineHeight) - getVerticalScrollOffset();
+            scrollVertical(vscroll, true);
+        }
+    }
+    resetCache(0, content.getLineCount());
+    claimBottomFreeSpace(); 
+    calculateScrollBars();
+    if (isBidiCaret()) createCaretBitmaps();
+    caretDirection = DWT.NULL;
+    setCaretLocation();
+    super.redraw();
+}
+/**
+ * @see dwt.widgets.Control#setForeground
+ */
+public void setForeground(Color color) {
+    checkWidget();
+    foreground = color;
+    super.setForeground(getForeground());
+    super.redraw();
+}
+/** 
+ * Sets the horizontal scroll offset relative to the start of the line.
+ * Do nothing if there is no text set.
+ * <p>
+ * <b>NOTE:</b> The horizontal index is reset to 0 when new text is set in the 
+ * widget.
+ * </p>
+ *
+ * @param offset horizontal scroll offset relative to the start 
+ *  of the line, measured in character increments starting at 0, if 
+ *  equal to 0 the content is not scrolled, if > 0 = the content is scrolled.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHorizontalIndex(int offset) {
+    checkWidget();
+    if (getCharCount() is 0) {
+        return;
+    }   
+    if (offset < 0) {
+        offset = 0;
+    }
+    offset *= getHorizontalIncrement();
+    // allow any value if client area width is unknown or 0. 
+    // offset will be checked in resize handler.
+    // don't use isVisible since width is known even if widget 
+    // is temporarily invisible
+    if (clientAreaWidth > 0) {
+        int width = renderer.getWidth();
+        // prevent scrolling if the content fits in the client area.
+        // align end of longest line with right border of client area
+        // if offset is out of range.
+        if (offset > width - clientAreaWidth) {
+            offset = Math.max(0, width - clientAreaWidth);
+        }
+    }
+    scrollHorizontal(offset - horizontalScrollOffset, true);
+}
+/** 
+ * Sets the horizontal pixel offset relative to the start of the line.
+ * Do nothing if there is no text set.
+ * <p>
+ * <b>NOTE:</b> The horizontal pixel offset is reset to 0 when new text 
+ * is set in the widget.
+ * </p>
+ *
+ * @param pixel horizontal pixel offset relative to the start 
+ *  of the line.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.0
+ */
+public void setHorizontalPixel(int pixel) {
+    checkWidget();
+    if (getCharCount() is 0) {
+        return;
+    }   
+    if (pixel < 0) {
+        pixel = 0;
+    }
+    // allow any value if client area width is unknown or 0. 
+    // offset will be checked in resize handler.
+    // don't use isVisible since width is known even if widget 
+    // is temporarily invisible
+    if (clientAreaWidth > 0) {
+        int width = renderer.getWidth();
+        // prevent scrolling if the content fits in the client area.
+        // align end of longest line with right border of client area
+        // if offset is out of range.
+        if (pixel > width - clientAreaWidth) {
+            pixel = Math.max(0, width - clientAreaWidth);
+        }
+    }
+    scrollHorizontal(pixel - horizontalScrollOffset, true);
+}
+/**
+ * Sets the line indentation of the widget.
+ * <p>
+ * It is the amount of blank space, in pixels, at the beginning of each line. 
+ * When a line wraps in several lines only the first one is indented. 
+ * </p>
+ * 
+ * @param indent the new indent
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLineIndent(int, int, int)
+ *  
+ * @since 3.2
+ */
+public void setIndent(int indent) {
+    checkWidget();
+    if (this.indent is indent || indent < 0) return;
+    this.indent = indent;
+    resetCache(0, content.getLineCount());
+    setCaretLocation();
+    super.redraw(); 
+}
+/**
+ * Sets whether the widget should justify lines.  
+ * 
+ * @param justify whether lines should be justified
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLineJustify(int, int, bool)
+ *  
+ * @since 3.2
+ */
+public void setJustify(bool justify) {
+    checkWidget();
+    if (this.justify is justify) return;
+    this.justify = justify;
+    resetCache(0, content.getLineCount());
+    setCaretLocation();
+    super.redraw(); 
+}
+/** 
+ * Maps a key to an action.
+ * <p>
+ * One action can be associated with N keys. However, each key can only 
+ * have one action (key:action is N:1 relation).
+ * </p>
+ *
+ * @param key a key code defined in DWT.java or a character. 
+ *  Optionally ORd with a state mask.  Preferred state masks are one or more of
+ *  DWT.MOD1, DWT.MOD2, DWT.MOD3, since these masks account for modifier platform 
+ *  differences.  However, there may be cases where using the specific state masks
+ *  (i.e., DWT.CTRL, DWT.SHIFT, DWT.ALT, DWT.COMMAND) makes sense.
+ * @param action one of the predefined actions defined in ST.java. 
+ *  Use DWT.NULL to remove a key binding.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setKeyBinding(int key, int action) {
+    checkWidget();
+    int modifierValue = key & DWT.MODIFIER_MASK;
+    char keyChar = (char)(key & DWT.KEY_MASK);
+    if (Compatibility.isLetter(keyChar)) {
+        // make the keybinding case insensitive by adding it
+        // in its upper and lower case form
+        char ch = Character.toUpperCase(keyChar);
+        int newKey = ch | modifierValue;
+        if (action is DWT.NULL) {
+            keyActionMap.remove(new Integer(newKey));
+        } else {
+            keyActionMap.put(new Integer(newKey), new Integer(action));
+        }
+        ch = Character.toLowerCase(keyChar);
+        newKey = ch | modifierValue;
+        if (action is DWT.NULL) {
+            keyActionMap.remove(new Integer(newKey));
+        } else {
+            keyActionMap.put(new Integer(newKey), new Integer(action));
+        }
+    } else {
+        if (action is DWT.NULL) {
+            keyActionMap.remove(new Integer(key));
+        } else {
+            keyActionMap.put(new Integer(key), new Integer(action));
+        }
+    }       
+}
+/**
+ * Sets the alignment of the specified lines. The argument should be one of <code>DWT.LEFT</code>, 
+ * <code>DWT.CENTER</code> or <code>DWT.RIGHT</code>.
+ * <p><p>
+ * Note that if <code>DWT.MULTI</code> is set, then <code>DWT.WRAP</code> must also be set
+ * in order to stabilize the right edge before setting alignment.
+ * </p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged. 
+ *   
+ * @param startLine first line the alignment is applied to, 0 based
+ * @param lineCount number of lines the alignment applies to.
+ * @param alignment line alignment
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @see #setAlignment(int)
+ * @since 3.2
+ */
+public void setLineAlignment(int startLine, int lineCount, int alignment) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+
+    renderer.setLineAlignment(startLine, lineCount, alignment);
+    resetCache(startLine, lineCount);
+    redrawLines(startLine, lineCount);
+    int caretLine = getCaretLine();
+    if (startLine <= caretLine && caretLine < startLine + lineCount) {
+        setCaretLocation();
+    }
+}
+/** 
+ * Sets the background color of the specified lines.
+ * <p>
+ * The background color is drawn for the width of the widget. All
+ * line background colors are discarded when setText is called.
+ * The text background color if defined in a StyleRange overlays the 
+ * line background color. 
+ * </p><p>
+ * Should not be called if a LineBackgroundListener has been set since the 
+ * listener maintains the line backgrounds.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged. 
+ * </p>
+ * 
+ * @param startLine first line the color is applied to, 0 based
+ * @param lineCount number of lines the color applies to.
+ * @param background line background color
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ */
+public void setLineBackground(int startLine, int lineCount, Color background) {
+    checkWidget();  
+    if (isListening(LineGetBackground)) return;
+    if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (background !is null) {
+        renderer.setLineBackground(startLine, lineCount, background);
+    } else {
+        renderer.clearLineBackground(startLine, lineCount);
+    }
+    redrawLines(startLine, lineCount);
+}
+/**
+ * Sets the bullet of the specified lines.
+ * <p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged.
+ * </p>
+ *
+ * @param startLine first line the bullet is applied to, 0 based
+ * @param lineCount number of lines the bullet applies to.
+ * @param bullet line bullet
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @since 3.2
+ */
+public void setLineBullet(int startLine, int lineCount, Bullet bullet) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;  
+    if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+
+    renderer.setLineBullet(startLine, lineCount, bullet);
+    resetCache(startLine, lineCount);
+    redrawLines(startLine, lineCount);
+    int caretLine = getCaretLine();
+    if (startLine <= caretLine && caretLine < startLine + lineCount) {
+        setCaretLocation();
+    }
+}
+void setVariableLineHeight () {
+    if (!fixedLineHeight) return;
+    fixedLineHeight = false;
+    renderer.calculateIdle();
+}
+/**
+ * Sets the indent of the specified lines.
+ * <p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged.
+ * </p>
+ *
+ * @param startLine first line the indent is applied to, 0 based
+ * @param lineCount number of lines the indent applies to.
+ * @param indent line indent
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @see #setIndent(int)
+ * @since 3.2
+ */
+public void setLineIndent(int startLine, int lineCount, int indent) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+
+    renderer.setLineIndent(startLine, lineCount, indent);
+    resetCache(startLine, lineCount);
+    redrawLines(startLine, lineCount);
+    int caretLine = getCaretLine();
+    if (startLine <= caretLine && caretLine < startLine + lineCount) {
+        setCaretLocation();
+    }
+}
+/**
+ * Sets the justify of the specified lines.
+ * <p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged.
+ * </p>
+ *  
+ * @param startLine first line the justify is applied to, 0 based
+ * @param lineCount number of lines the justify applies to.
+ * @param justify true if lines should be justified
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @see #setJustify(bool)
+ * @since 3.2
+ */
+public void setLineJustify(int startLine, int lineCount, bool justify) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+
+    renderer.setLineJustify(startLine, lineCount, justify);
+    resetCache(startLine, lineCount);
+    redrawLines(startLine, lineCount);
+    int caretLine = getCaretLine();
+    if (startLine <= caretLine && caretLine < startLine + lineCount) {
+        setCaretLocation();
+    }
+}
+/**
+ * Sets the line spacing of the widget. The line spacing applies for all lines.
+ * 
+ * @param lineSpacing the line spacing
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 3.2
+ */
+public void setLineSpacing(int lineSpacing) {
+    checkWidget();
+    if (this.lineSpacing is lineSpacing || lineSpacing < 0) return;
+    this.lineSpacing = lineSpacing; 
+    setVariableLineHeight();
+    resetCache(0, content.getLineCount());
+    setCaretLocation();
+    super.redraw();
+}
+void setMargins (int leftMargin, int topMargin, int rightMargin, int bottomMargin) {
+    checkWidget();
+    this.leftMargin = leftMargin;
+    this.topMargin = topMargin;
+    this.rightMargin = rightMargin;
+    this.bottomMargin = bottomMargin;
+    setCaretLocation();
+}
+/**
+ * Flips selection anchor based on word selection direction.
+ */
+void setMouseWordSelectionAnchor() {
+    if (clickCount > 1) {
+        if (caretOffset < doubleClickSelection.x) {
+            selectionAnchor = doubleClickSelection.y;
+        } else if (caretOffset > doubleClickSelection.y) {
+            selectionAnchor = doubleClickSelection.x;
+        }
+    }
+}
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of the constants <code>DWT.LEFT_TO_RIGHT</code> or <code>DWT.RIGHT_TO_LEFT</code>.
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public void setOrientation(int orientation) {
+    if ((orientation & (DWT.RIGHT_TO_LEFT | DWT.LEFT_TO_RIGHT)) is 0) { 
+        return;
+    }
+    if ((orientation & DWT.RIGHT_TO_LEFT) !is 0 && (orientation & DWT.LEFT_TO_RIGHT) !is 0) {
+        return; 
+    }
+    if ((orientation & DWT.RIGHT_TO_LEFT) !is 0 && isMirrored()) {
+        return; 
+    } 
+    if ((orientation & DWT.LEFT_TO_RIGHT) !is 0 && !isMirrored()) {
+        return;
+    }
+    if (!BidiUtil.setOrientation(this, orientation)) {
+        return;
+    }
+    isMirrored = (orientation & DWT.RIGHT_TO_LEFT) !is 0;
+    caretDirection = DWT.NULL;
+    resetCache(0, content.getLineCount());
+    setCaretLocation();
+    keyActionMap.clear();
+    createKeyBindings();
+    super.redraw();
+}
+/**
+ * Adjusts the maximum and the page size of the scroll bars to 
+ * reflect content width/length changes.
+ * 
+ * @param vertical indicates if the vertical scrollbar also needs to be set 
+ */
+void setScrollBars(bool vertical) {
+    int inactive = 1;
+    if (vertical || !isFixedLineHeight()) {
+        ScrollBar verticalBar = getVerticalBar();
+        if (verticalBar !is null) {
+            int maximum = renderer.getHeight();
+            // only set the real values if the scroll bar can be used 
+            // (ie. because the thumb size is less than the scroll maximum)
+            // avoids flashing on Motif, fixes 1G7RE1J and 1G5SE92
+            if (clientAreaHeight < maximum) {
+                verticalBar.setMaximum(maximum);
+                verticalBar.setThumb(clientAreaHeight);
+                verticalBar.setPageIncrement(clientAreaHeight);
+            } else if (verticalBar.getThumb() !is inactive || verticalBar.getMaximum() !is inactive) {
+                verticalBar.setValues(
+                    verticalBar.getSelection(),
+                    verticalBar.getMinimum(),
+                    inactive,
+                    inactive,
+                    verticalBar.getIncrement(),
+                    inactive);
+            }
+        }
+    }
+    ScrollBar horizontalBar = getHorizontalBar();
+    if (horizontalBar !is null && horizontalBar.getVisible()) {
+        int maximum = renderer.getWidth();
+        // only set the real values if the scroll bar can be used 
+        // (ie. because the thumb size is less than the scroll maximum)
+        // avoids flashing on Motif, fixes 1G7RE1J and 1G5SE92
+        if (clientAreaWidth < maximum) {
+            horizontalBar.setMaximum(maximum);
+            horizontalBar.setThumb(clientAreaWidth - leftMargin - rightMargin);
+            horizontalBar.setPageIncrement(clientAreaWidth - leftMargin - rightMargin);
+        } else if (horizontalBar.getThumb() !is inactive || horizontalBar.getMaximum() !is inactive) {
+            horizontalBar.setValues(
+                horizontalBar.getSelection(),
+                horizontalBar.getMinimum(),
+                inactive,
+                inactive,
+                horizontalBar.getIncrement(),
+                inactive);
+        }
+    }
+}
+/** 
+ * Sets the selection to the given position and scrolls it into view.  Equivalent to setSelection(start,start).
+ *
+ * @param start new caret position
+ * @see #setSelection(int,int)
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul> 
+ */
+public void setSelection(int start) {
+    // checkWidget test done in setSelectionRange   
+    setSelection(start, start);
+}
+/** 
+ * Sets the selection and scrolls it into view.
+ * <p>
+ * Indexing is zero based.  Text selections are specified in terms of
+ * caret positions.  In a text widget that contains N characters, there are 
+ * N+1 caret positions, ranging from 0..N
+ * </p>
+ *
+ * @param point x=selection start offset, y=selection end offset
+ *  The caret will be placed at the selection start when x > y.
+ * @see #setSelection(int,int)
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when point is null</li>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul> 
+ */
+public void setSelection(Point point) {
+    checkWidget();
+    if (point is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 
+    setSelection(point.x, point.y);
+}
+/**
+ * Sets the receiver's selection background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public void setSelectionBackground (Color color) {
+    checkWidget ();
+    if (color !is null) {
+        if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    selectionBackground = color;
+    super.redraw();
+}
+/**
+ * Sets the receiver's selection foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null. 
+ * <p>
+ * Note that this is a <em>HINT</em>. Some platforms do not allow the application
+ * to change the selection foreground color.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public void setSelectionForeground (Color color) {
+    checkWidget ();
+    if (color !is null) {
+        if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    selectionForeground = color;
+    super.redraw();
+}
+/** 
+ * Sets the selection and scrolls it into view.
+ * <p>
+ * Indexing is zero based.  Text selections are specified in terms of
+ * caret positions.  In a text widget that contains N characters, there are 
+ * N+1 caret positions, ranging from 0..N
+ * </p>
+ *
+ * @param start selection start offset. The caret will be placed at the 
+ *  selection start when start > end.
+ * @param end selection end offset
+ * @see #setSelectionRange(int,int)
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelection(int start, int end) {
+    setSelectionRange(start, end - start);
+    showSelection();
+}
+/** 
+ * Sets the selection.
+ * <p>
+ * The new selection may not be visible. Call showSelection to scroll 
+ * the selection into view.
+ * </p>
+ *
+ * @param start offset of the first selected character, start >= 0 must be true.
+ * @param length number of characters to select, 0 <= start + length 
+ *  <= getCharCount() must be true. 
+ *  A negative length places the caret at the selection start.
+ * @param sendEvent a Selection event is sent when set to true and when 
+ *  the selection is reset.
+ */
+void setSelection(int start, int length, bool sendEvent) {
+    int end = start + length;
+    if (start > end) {
+        int temp = end;
+        end = start;
+        start = temp;
+    }
+    // is the selection range different or is the selection direction 
+    // different?
+    if (selection.x !is start || selection.y !is end || 
+        (length > 0 && selectionAnchor !is selection.x) || 
+        (length < 0 && selectionAnchor !is selection.y)) {
+        clearSelection(sendEvent);
+        if (length < 0) {
+            selectionAnchor = selection.y = end;
+            caretOffset = selection.x = start;
+        } else {
+            selectionAnchor = selection.x = start;
+            caretOffset = selection.y = end;
+        }
+        caretAlignment = PREVIOUS_OFFSET_TRAILING;
+        internalRedrawRange(selection.x, selection.y - selection.x);
+    }
+}
+/** 
+ * Sets the selection.
+ * <p>
+ * The new selection may not be visible. Call showSelection to scroll the selection
+ * into view. A negative length places the caret at the visual start of the selection.
+ * </p>
+ *
+ * @param start offset of the first selected character
+ * @param length number of characters to select
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelectionRange(int start, int length) {
+    checkWidget();
+    int contentLength = getCharCount();
+    start = Math.max(0, Math.min (start, contentLength));
+    int end = start + length;
+    if (end < 0) {
+        length = -start;
+    } else {
+        if (end > contentLength) length = contentLength - start;
+    }
+    if (isLineDelimiter(start) || isLineDelimiter(start + length)) {
+        // the start offset or end offset of the selection range is inside a 
+        // multi byte line delimiter. This is an illegal operation and an exception 
+        // is thrown. Fixes 1GDKK3R
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    setSelection(start, length, false);
+    setCaretLocation();
+}
+/** 
+ * Adds the specified style.
+ * <p>
+ * The new style overwrites existing styles for the specified range.
+ * Existing style ranges are adjusted if they partially overlap with 
+ * the new style. To clear an individual style, call setStyleRange 
+ * with a StyleRange that has null attributes. 
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param range StyleRange object containing the style information.
+ * Overwrites the old style in the given range. May be null to delete
+ * all styles.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the style range is outside the valid range (> getCharCount())</li> 
+ * </ul>
+ */
+public void setStyleRange(StyleRange range) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (range !is null) {
+        if (range.isUnstyled()) {
+            setStyleRanges(range.start, range.length, null, null, false);
+        } else {
+            setStyleRanges(range.start, 0, null, new StyleRange[]{range}, false);
+        }
+    } else {
+        setStyleRanges(0, 0, null, null, true);
+    }
+}
+/** 
+ * Clears the styles in the range specified by <code>start</code> and 
+ * <code>length</code> and adds the new styles.
+ * <p>
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2].  The range fields within each StyleRange are ignored.
+ * If ranges or styles is null, the specified range is cleared.
+ * </p><p>
+ * Note: It is expected that the same instance of a StyleRange will occur
+ * multiple times within the styles array, reducing memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param start offset of first character where styles will be deleted
+ * @param length length of the range to delete styles in
+ * @param ranges the array of ranges.  The ranges must not overlap and must be in order.
+ * @param styles the array of StyleRanges.  The range fields within the StyleRange are unused.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when an element in the styles array is null</li>
+ *    <li>ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 is styles.length)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range overlaps</li> 
+ * </ul>
+ * 
+ * @since 3.2 
+ */
+public void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (ranges is null || styles is null) {
+        setStyleRanges(start, length, null, null, false);
+    } else {
+        setStyleRanges(start, length, ranges, styles, false);
+    }
+}
+/** 
+ * Sets styles to be used for rendering the widget content.
+ * <p>
+ * All styles in the widget will be replaced with the given set of ranges and styles.
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2].  The range fields within each StyleRange are ignored.
+ * If either argument is null, the styles are cleared.
+ * </p><p>
+ * Note: It is expected that the same instance of a StyleRange will occur
+ * multiple times within the styles array, reducing memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param ranges the array of ranges.  The ranges must not overlap and must be in order.
+ * @param styles the array of StyleRanges.  The range fields within the StyleRange are unused.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when an element in the styles array is null</li>
+ *    <li>ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 is styles.length)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range overlaps</li> 
+ * </ul>
+ * 
+ * @since 3.2 
+ */
+public void setStyleRanges(int[] ranges, StyleRange[] styles) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (ranges is null || styles is null) {
+        setStyleRanges(0, 0, null, null, true);
+    } else {
+        setStyleRanges(0, 0, ranges, styles, true);
+    }
+}
+void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles, bool reset) {
+    int charCount = content.getCharCount();
+    int end = start + length;
+    if (start > end || start < 0) {
+        DWT.error(DWT.ERROR_INVALID_RANGE);
+    }
+    if (styles !is null) {
+        if (end > charCount) {
+            DWT.error(DWT.ERROR_INVALID_RANGE);
+        }
+        if (ranges !is null) {
+            if (ranges.length !is styles.length << 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        int lastOffset = 0;
+        bool variableHeight = false; 
+        for (int i = 0; i < styles.length; i ++) {
+            if (styles[i] is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            int rangeStart, rangeLength;
+            if (ranges !is null) {
+                rangeStart = ranges[i << 1];
+                rangeLength = ranges[(i << 1) + 1];
+            } else {
+                rangeStart = styles[i].start;
+                rangeLength = styles[i].length;
+            }
+            if (rangeLength < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
+            if (!(0 <= rangeStart && rangeStart + rangeLength <= charCount)) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            if (lastOffset > rangeStart) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            variableHeight |= styles[i].isVariableHeight();
+            lastOffset = rangeStart + rangeLength;
+        }
+        if (variableHeight) setVariableLineHeight();
+    }
+    int rangeStart = start, rangeEnd = end;
+    if (styles !is null && styles.length > 0) {
+        if (ranges !is null) {
+            rangeStart = ranges[0];
+            rangeEnd = ranges[ranges.length - 2] + ranges[ranges.length - 1];
+        } else {
+            rangeStart = styles[0].start;
+            rangeEnd = styles[styles.length - 1].start + styles[styles.length - 1].length;
+        }
+    }
+    int lastLineBottom = 0;
+    if (!isFixedLineHeight() && !reset) {
+        int lineEnd = content.getLineAtOffset(Math.max(end, rangeEnd));
+        int partialTopIndex = getPartialTopIndex();
+        int partialBottomIndex = getPartialBottomIndex();
+        if (partialTopIndex <= lineEnd && lineEnd <= partialBottomIndex) {
+            lastLineBottom = getLinePixel(lineEnd + 1);
+        }
+    }
+    if (reset) {
+        renderer.setStyleRanges(null, null);
+    } else {
+        renderer.updateRanges(start, length, length);
+    }
+    if (styles !is null && styles.length > 0) {
+        renderer.setStyleRanges(ranges, styles);
+    }
+    if (reset) {
+        resetCache(0, content.getLineCount());
+        super.redraw();
+    } else {
+        int lineStart = content.getLineAtOffset(Math.min(start, rangeStart));
+        int lineEnd = content.getLineAtOffset(Math.max(end, rangeEnd));
+        resetCache(lineStart, lineEnd - lineStart + 1);
+        int partialTopIndex = getPartialTopIndex();
+        int partialBottomIndex = getPartialBottomIndex();
+        if (!(lineStart > partialBottomIndex || lineEnd < partialTopIndex)) {
+            int y = 0;
+            int height = clientAreaHeight;
+            if (partialTopIndex <= lineStart && lineStart <= partialBottomIndex) {
+                int lineTop = Math.max(y, getLinePixel(lineStart));
+                y = lineTop;
+                height -= lineTop;
+            }
+            if (partialTopIndex <= lineEnd && lineEnd <= partialBottomIndex) {
+                int newLastLineBottom = getLinePixel(lineEnd + 1);
+                if (!isFixedLineHeight()) {
+                    scrollText(lastLineBottom, newLastLineBottom);
+                }
+                height = newLastLineBottom - y;
+            }
+            super.redraw(0, y, clientAreaWidth, height, false);     
+        }
+    }
+    setCaretLocation();
+}
+/** 
+ * Sets styles to be used for rendering the widget content. All styles 
+ * in the widget will be replaced with the given set of styles.
+ * <p>
+ * Note: Because a StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>setStyleRanges(int[], StyleRange[])</code>
+ * can be used to share styles and reduce memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param ranges StyleRange objects containing the style information.
+ * The ranges should not overlap. The style rendering is undefined if 
+ * the ranges do overlap. Must not be null. The styles need to be in order.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when the list of ranges is null</li>
+ *    <li>ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())</li> 
+ * </ul>
+ * 
+ * @see #setStyleRanges(int[], StyleRange[])
+ */
+public void setStyleRanges(StyleRange[] ranges) {
+    checkWidget();
+    if (isListening(LineGetStyle)) return;
+    if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    setStyleRanges(0, 0, null, ranges, true);
+}
+/** 
+ * Sets the tab width. 
+ *
+ * @param tabs tab width measured in characters.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabs(int tabs) {
+    checkWidget();  
+    tabLength = tabs;
+    renderer.setFont(null, tabs);
+    resetCache(0, content.getLineCount());
+    setCaretLocation();
+    super.redraw();
+}
+/** 
+ * Sets the widget content. 
+ * If the widget has the DWT.SINGLE style and "text" contains more than 
+ * one line, only the first line is rendered but the text is stored 
+ * unchanged. A subsequent call to getText will return the same text 
+ * that was set.
+ * <p>
+ * <b>Note:</b> Only a single line of text should be set when the DWT.SINGLE 
+ * style is used.
+ * </p>
+ *
+ * @param text new widget content. Replaces existing content. Line styles 
+ *  that were set using StyledText API are discarded.  The
+ *  current selection is also discarded.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when String is null</li>
+ * </ul>
+ */
+public void setText(String text) {
+    checkWidget();
+    if (text is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    Event event = new Event();
+    event.start = 0;
+    event.end = getCharCount();
+    event.text = text;
+    event.doit = true;  
+    notifyListeners(DWT.Verify, event);
+    if (event.doit) {
+        StyledTextEvent styledTextEvent = null;
+        if (isListening(ExtendedModify)) {
+            styledTextEvent = new StyledTextEvent(content);
+            styledTextEvent.start = event.start;
+            styledTextEvent.end = event.start + event.text.length();
+            styledTextEvent.text = content.getTextRange(event.start, event.end - event.start);
+        }
+        content.setText(event.text);
+        sendModifyEvent(event); 
+        if (styledTextEvent !is null) {
+            notifyListeners(ExtendedModify, styledTextEvent);
+        }
+    }
+}
+/**
+ * Sets the text limit to the specified number of characters.
+ * <p>
+ * The text limit specifies the amount of text that
+ * the user can type into the widget.
+ * </p>
+ *
+ * @param limit the new text limit.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_CANNOT_BE_ZERO when limit is 0</li>
+ * </ul>
+ */
+public void setTextLimit(int limit) {
+    checkWidget();
+    if (limit is 0) {
+        DWT.error(DWT.ERROR_CANNOT_BE_ZERO);
+    }
+    textLimit = limit;
+}
+/**
+ * Sets the top index. Do nothing if there is no text set.
+ * <p>
+ * The top index is the index of the line that is currently at the top 
+ * of the widget. The top index changes when the widget is scrolled.
+ * Indexing starts from zero.
+ * Note: The top index is reset to 0 when new text is set in the widget.
+ * </p>
+ *
+ * @param topIndex new top index. Must be between 0 and 
+ *  getLineCount() - fully visible lines per page. If no lines are fully 
+ *  visible the maximum value is getLineCount() - 1. An out of range 
+ *  index will be adjusted accordingly.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex(int topIndex) {
+    checkWidget();
+    if (getCharCount() is 0) {
+        return;
+    }
+    int lineCount = content.getLineCount(), pixel;
+    if (isFixedLineHeight()) {
+        int pageSize = Math.max(1, Math.min(lineCount, getLineCountWhole()));
+        if (topIndex < 0) {
+            topIndex = 0;
+        } else if (topIndex > lineCount - pageSize) {
+            topIndex = lineCount - pageSize;
+        }
+        pixel = getLinePixel(topIndex);
+    } else {
+        topIndex = Math.max(0, Math.min(lineCount - 1, topIndex));
+        pixel = getLinePixel(topIndex);
+        if (pixel > 0) {
+            pixel = getAvailableHeightBellow(pixel);
+        } else {
+            pixel = getAvailableHeightAbove(pixel);
+        }
+    } 
+    scrollVertical(pixel, true);
+}
+/**
+ * Sets the top pixel offset. Do nothing if there is no text set.
+ * <p>
+ * The top pixel offset is the vertical pixel offset of the widget. The
+ * widget is scrolled so that the given pixel position is at the top.
+ * The top index is adjusted to the corresponding top line.
+ * Note: The top pixel is reset to 0 when new text is set in the widget.
+ * </p>
+ *
+ * @param pixel new top pixel offset. Must be between 0 and 
+ *  (getLineCount() - visible lines per page) / getLineHeight()). An out
+ *  of range offset will be adjusted accordingly.
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.0
+ */
+public void setTopPixel(int pixel) {
+    checkWidget();
+    if (getCharCount() is 0) {
+        return;
+    }   
+    if (pixel < 0) pixel = 0;
+    int lineCount = content.getLineCount();
+    int height = clientAreaHeight - topMargin - bottomMargin;
+    int verticalOffset = getVerticalScrollOffset();
+    if (isFixedLineHeight()) {
+        int maxTopPixel = Math.max(0, lineCount * getVerticalIncrement() - height);
+        if (pixel > maxTopPixel) pixel = maxTopPixel;
+        pixel -= verticalOffset; 
+    } else {
+        pixel -= verticalOffset;
+        if (pixel > 0) {
+            pixel = getAvailableHeightBellow(pixel);
+        }
+    }
+    scrollVertical(pixel, true);
+}
+/**
+ * Sets whether the widget wraps lines.
+ * <p>
+ * This overrides the creation style bit DWT.WRAP.
+ * </p>
+ *
+ * @param wrap true=widget wraps lines, false=widget does not wrap lines
+ * @since 2.0
+ */
+public void setWordWrap(bool wrap) {
+    checkWidget();
+    if ((getStyle() & DWT.SINGLE) !is 0) return;
+    if (wordWrap is wrap) return;
+    wordWrap = wrap;
+    setVariableLineHeight();
+    resetCache(0, content.getLineCount());
+    horizontalScrollOffset = 0;
+    ScrollBar horizontalBar = getHorizontalBar();
+    if (horizontalBar !is null) {
+        horizontalBar.setVisible(!wordWrap);
+    }
+    setScrollBars(true);
+    setCaretLocation();
+    super.redraw();
+}
+bool showLocation(Rectangle rect, bool scrollPage) {
+    int clientAreaWidth = this.clientAreaWidth - leftMargin - rightMargin;
+    int clientAreaHeight = this.clientAreaHeight - topMargin - bottomMargin;
+    bool scrolled = false;
+    if (rect.y <= topMargin) {
+        scrolled = scrollVertical(rect.y - topMargin, true);
+    } else if (rect.y + rect.height > clientAreaHeight) {
+        if (clientAreaHeight is 0) {
+            scrolled = scrollVertical(rect.y, true);
+        } else {
+            scrolled = scrollVertical(rect.y + rect.height - clientAreaHeight, true);
+        }
+    }
+    if (clientAreaWidth > 0) {
+        int minScroll = scrollPage ? clientAreaWidth / 4 : 0;
+        if (rect.x < leftMargin) {
+            int scrollWidth = Math.max(leftMargin - rect.x, minScroll);
+            int maxScroll = horizontalScrollOffset;
+            scrolled = scrollHorizontal(-Math.min(maxScroll, scrollWidth), true);
+        } else if (rect.x + rect.width > clientAreaWidth) {
+            int scrollWidth =  Math.max(rect.x + rect.width - clientAreaWidth, minScroll);
+            int maxScroll = renderer.getWidth() - horizontalScrollOffset - this.clientAreaWidth;
+            scrolled = scrollHorizontal(Math.min(maxScroll, scrollWidth), true);
+        }
+    }
+    return scrolled;
+}
+/**
+ * Sets the caret location and scrolls the caret offset into view.
+ */
+void showCaret() {
+    Rectangle bounds = getBoundsAtOffset(caretOffset);
+    if (!showLocation(bounds, true)) {
+        setCaretLocation();
+    }
+}
+/**
+ * Scrolls the selection into view.
+ * <p>
+ * The end of the selection will be scrolled into view.
+ * Note that if a right-to-left selection exists, the end of the selection is
+ * the visual beginning of the selection (i.e., where the caret is located).
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void showSelection() {
+    checkWidget();
+    // is selection from right-to-left?
+    bool rightToLeft = caretOffset is selection.x;
+    int startOffset, endOffset;
+    if (rightToLeft) {
+        startOffset = selection.y;
+        endOffset = selection.x;
+    } else {
+        startOffset = selection.x;
+        endOffset = selection.y;
+    }
+    
+    Rectangle startBounds = getBoundsAtOffset(startOffset);
+    Rectangle endBounds = getBoundsAtOffset(endOffset);
+    
+    // can the selection be fully displayed within the widget's visible width?
+    int w = clientAreaWidth - leftMargin - rightMargin;
+    bool selectionFits = rightToLeft ? startBounds.x - endBounds.x <= w : endBounds.x - startBounds.x <= w;
+    if (selectionFits) {
+        // show as much of the selection as possible by first showing
+        // the start of the selection
+        if (showLocation(startBounds, false)) {
+            // endX value could change if showing startX caused a scroll to occur
+            endBounds = getBoundsAtOffset(endOffset);
+        }
+        // the character at endOffset is not part of the selection
+        endBounds.width = 0;
+        showLocation(endBounds, false);
+    } else {
+        // just show the end of the selection since the selection start 
+        // will not be visible
+        showLocation(endBounds, true);
+    }
+}
+/**
+ * Updates the selection and caret position depending on the text change.
+ * <p>
+ * If the selection intersects with the replaced text, the selection is 
+ * reset and the caret moved to the end of the new text.
+ * If the selection is behind the replaced text it is moved so that the
+ * same text remains selected.  If the selection is before the replaced text 
+ * it is left unchanged.
+ * </p>
+ *
+ * @param startOffset offset of the text change
+ * @param replacedLength length of text being replaced
+ * @param newLength length of new text
+ */
+void updateSelection(int startOffset, int replacedLength, int newLength) {
+    if (selection.y <= startOffset) {
+        // selection ends before text change
+        return;
+    }
+    if (selection.x < startOffset) {
+        // clear selection fragment before text change
+        internalRedrawRange(selection.x, startOffset - selection.x);
+    }
+    if (selection.y > startOffset + replacedLength && selection.x < startOffset + replacedLength) {
+        // clear selection fragment after text change.
+        // do this only when the selection is actually affected by the 
+        // change. Selection is only affected if it intersects the change (1GDY217).
+        int netNewLength = newLength - replacedLength;
+        int redrawStart = startOffset + newLength;
+        internalRedrawRange(redrawStart, selection.y + netNewLength - redrawStart);
+    }
+    if (selection.y > startOffset && selection.x < startOffset + replacedLength) {
+        // selection intersects replaced text. set caret behind text change
+        setSelection(startOffset + newLength, 0, true);
+    } else {
+        // move selection to keep same text selected
+        setSelection(selection.x + newLength - replacedLength, selection.y - selection.x, true);
+    }
+    setCaretLocation();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyledTextContent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+/**
+ * Clients may implement the StyledTextContent interface to provide a 
+ * custom store for the StyledText widget content. The StyledText widget 
+ * interacts with its StyledTextContent in order to access and update 
+ * the text that is being displayed and edited in the widget. 
+ * A custom content implementation can be set in the widget using the
+ * StyledText.setContent API.
+ */
+public interface StyledTextContent {
+
+/**
+ * Called by StyledText to add itself as an Observer to content changes.
+ * See TextChangeListener for a description of the listener methods that
+ * are called when text changes occur.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangeListener(TextChangeListener listener);
+
+/**
+ * Return the number of characters in the content.
+ * <p>
+ *
+ * @return the number of characters in the content.
+ */
+public int getCharCount();
+
+/**
+ * Return the line at the given line index without delimiters.
+ * <p>
+ *
+ * @param lineIndex index of the line to return. Does not include 
+ *  delimiters of preceding lines. Index 0 is the first line of the 
+ *  content.
+ * @return the line text without delimiters
+ */
+public String getLine(int lineIndex);
+
+/**
+ * Return the line index at the given character offset.
+ * <p>
+ *
+ * @param offset offset of the line to return. The first character of the 
+ *  document is at offset 0.  An offset of getLength() is valid and should 
+ *  answer the number of lines. 
+ * @return the line index. The first line is at index 0.  If the character 
+ *  at offset is a delimiter character, answer the line index of the line 
+ *  that is delimited. 
+ *  For example, if text = "\r\n\r\n", and delimiter = "\r\n", then:
+ * <ul>
+ * <li>getLineAtOffset(0) is 0
+ * <li>getLineAtOffset(1) is 0
+ * <li>getLineAtOffset(2) is 1
+ * <li>getLineAtOffset(3) is 1
+ * <li>getLineAtOffset(4) is 2
+ * </ul>
+ */
+public int getLineAtOffset(int offset);
+
+/**
+ * Return the number of lines.  Should answer 1 when no text is specified.
+ * The  StyledText widget relies on this behavior for drawing the cursor.
+ * <p>
+ *
+ * @return the number of lines.  For example:
+ * <ul>
+ * <li> text value ==> getLineCount     
+ * <li> null ==> 1      
+ * <li> "" ==> 1        
+ * <li> "a\n" ==> 2         
+ * <li> "\n\n" ==> 3            
+ * </ul>
+ */
+public int getLineCount();
+
+/**
+ * Return the line delimiter that should be used by the StyledText 
+ * widget when inserting new lines. New lines entered using key strokes 
+ * and paste operations use this line delimiter.
+ * Implementors may use System.getProperty("line.separator") to return
+ * the platform line delimiter.
+ * <p>
+ *
+ * @return the line delimiter that should be used by the StyledText widget
+ *  when inserting new lines.
+ */
+public String getLineDelimiter();
+
+/**
+ * Return the character offset of the first character of the given line.
+ * <p>
+ * <b>NOTE:</b> When there is no text (i.e., no lines), getOffsetAtLine(0) 
+ * is a valid call that should return 0.
+ * </p>
+ *
+ * @param lineIndex index of the line. The first line is at index 0.
+ * @return offset offset of the first character of the line. The first 
+ *  character of the document is at offset 0.  The return value should 
+ *  include line delimiters.  
+ *  For example, if text = "\r\ntest\r\n" and delimiter = "\r\n", then:
+ * <ul>
+ * <li>getOffsetAtLine(0) is 0
+ * <li>getOffsetAtLine(1) is 2
+ * <li>getOffsetAtLine(2) is 8
+ * </ul>
+ */
+public int getOffsetAtLine(int lineIndex);
+
+/**
+ * Returns a String representing the content at the given range.
+ * <p>
+ *
+ * @param start the start offset of the text to return. Offset 0 is the 
+ *  first character of the document.
+ * @param length the length of the text to return
+ * @return the text at the given range
+ */
+public String getTextRange(int start, int length);
+
+/**
+ * Remove the specified text changed listener.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangeListener(TextChangeListener listener);
+
+/**
+ * Replace the text with "newText" starting at position "start" 
+ * for a length of "replaceLength".
+ * <p>
+ * Implementors have to notify the TextChangeListeners that were added 
+ * using <code>addTextChangeListener</code> before and after the content 
+ * is changed. A <code>TextChangingEvent</code> has to be sent to the 
+ * textChanging method before the content is changed and a 
+ * <code>TextChangedEvent</code> has to be sent to the textChanged method
+ * after the content has changed.
+ * The text change that occurs after the <code>TextChangingEvent</code> 
+ * has been sent has to be consistent with the data provided in the 
+ * <code>TextChangingEvent</code>.
+ * This data will be cached by the widget and will be used when the 
+ * <code>TextChangedEvent</code> is received.
+ * <p>
+ * The <code>TextChangingEvent</code> should be set as follows:
+ * <ul>
+ * <li>event.start = start of the replaced text
+ * <li>event.newText = text that is going to be inserted or empty String 
+ *  if no text will be inserted
+ * <li>event.replaceCharCount = length of text that is going to be replaced
+ * <li>event.newCharCount = length of text that is going to be inserted
+ * <li>event.replaceLineCount = number of lines that are going to be replaced
+ * <li>event.newLineCount = number of new lines that are going to be inserted
+ * </ul>
+ * <b>NOTE:</b> newLineCount is the number of inserted lines and replaceLineCount 
+ * is the number of deleted lines based on the change that occurs visually.  
+ * For example:
+ * <ul>
+ * <li>(replaceText, newText) ==> (replaceLineCount, newLineCount)
+ * <li>("", "\n") ==> (0, 1)
+ * <li>("\n\n", "a") ==> (2, 0)
+ * <li>("a", "\n\n") ==> (0, 2)
+ * <li>("\n", "") ==> (1, 0)
+ * </ul>
+ * </p>
+ *
+ * @param start start offset of text to replace, none of the offsets include 
+ *  delimiters of preceding lines, offset 0 is the first character of the 
+ *  document 
+ * @param replaceLength length of text to replace
+ * @param text text to replace
+ * @see TextChangeListener
+ */
+public void replaceTextRange(int start, int replaceLength, String text);
+
+/**
+ * Set text to "text".
+ * Implementors have to send a <code>TextChangedEvent</code> to the 
+ * textSet method of the TextChangeListeners that were added using 
+ * <code>addTextChangeListener</code>.
+ * <p>
+ *
+ * @param text the new text
+ * @see TextChangeListener
+ */
+public void setText(String text);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyledTextDropTargetEffect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.dnd.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * This adapter class provides a default drag under effect (eg. select and scroll) 
+ * when a drag occurs over a <code>StyledText</code>.
+ * 
+ * <p>Classes that wish to provide their own drag under effect for a <code>StyledText</code>
+ * can extend this class, override the <code>StyledTextDropTargetEffect.dragOver</code>
+ * method and override any other applicable methods in <code>StyledTextDropTargetEffect</code> to 
+ * display their own drag under effect.</p>
+ *
+ * Subclasses that override any methods of this class should call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_SELECT, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * 
+ * @since 3.3
+ */
+public class StyledTextDropTargetEffect : DropTargetEffect {
+    static final int CARET_WIDTH = 2;
+    static final int SCROLL_HYSTERESIS = 100; // milli seconds
+    static final int SCROLL_TOLERANCE = 20; // pixels
+    
+    int currentOffset = -1;
+    long scrollBeginTime;
+    int scrollX = -1, scrollY = -1;
+    Listener paintListener;
+    
+    /**
+     * Creates a new <code>StyledTextDropTargetEffect</code> to handle the drag under effect on the specified 
+     * <code>StyledText</code>.
+     * 
+     * @param styledText the <code>StyledText</code> over which the user positions the cursor to drop the data
+     */
+    public StyledTextDropTargetEffect(StyledText styledText) {
+        super(styledText);
+        paintListener = new Listener () {
+            public void handleEvent (Event event) {
+                if (currentOffset !is -1) {
+                    StyledText text = (StyledText) getControl();
+                    Point position = text.getLocationAtOffset(currentOffset);
+                    int height = text.getLineHeight(currentOffset);
+                    event.gc.setBackground(event.display.getSystemColor (DWT.COLOR_BLACK));
+                    event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height);
+                }
+            }
+        };
+    }
+    
+    /**
+     * This implementation of <code>dragEnter</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragEnter</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragEnter(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag start event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     */
+    public void dragEnter(DropTargetEvent event) {
+        currentOffset = -1;
+        scrollBeginTime = 0;
+        scrollX = -1;
+        scrollY = -1;
+        getControl().removeListener(DWT.Paint, paintListener);
+        getControl().addListener (DWT.Paint, paintListener);
+    }
+    
+    /**
+     * This implementation of <code>dragLeave</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragLeave</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragLeave(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag leave event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     */
+    public void dragLeave(DropTargetEvent event) {
+        StyledText text = (StyledText) getControl();
+        if (currentOffset !is -1) {
+            refreshCaret(text, currentOffset, -1);
+        }
+        text.removeListener(DWT.Paint, paintListener);
+        scrollBeginTime = 0;
+        scrollX = -1;
+        scrollY = -1;
+    }
+
+    /**
+     * This implementation of <code>dragOver</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragOver</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragOver(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag over event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     * @see DND#FEEDBACK_SELECT
+     * @see DND#FEEDBACK_SCROLL
+     */
+    public void dragOver(DropTargetEvent event) {
+        int effect = event.feedback;
+        StyledText text = (StyledText) getControl();
+        
+        Point pt = text.getDisplay().map(null, text, event.x, event.y);
+        if ((effect & DND.FEEDBACK_SCROLL) is 0) {
+            scrollBeginTime = 0;
+            scrollX = scrollY = -1;
+        } else {
+            if (text.getCharCount() is 0) {
+                scrollBeginTime = 0;
+                scrollX = scrollY = -1;
+            } else {
+                if (scrollX !is -1 && scrollY !is -1 && scrollBeginTime !is 0 &&
+                    (pt.x >= scrollX && pt.x <= (scrollX + SCROLL_TOLERANCE) ||
+                     pt.y >= scrollY && pt.y <= (scrollY + SCROLL_TOLERANCE))) {
+                    if (System.currentTimeMillis() >= scrollBeginTime) {
+                        Rectangle area = text.getClientArea();
+                        GC gc = new GC(text);
+                        FontMetrics fm = gc.getFontMetrics();
+                        gc.dispose();
+                        int charWidth = fm.getAverageCharWidth();
+                        int scrollAmount = 10*charWidth;
+                        if (pt.x < area.x + 3*charWidth) {
+                            int leftPixel = text.getHorizontalPixel();
+                            text.setHorizontalPixel(leftPixel - scrollAmount);
+                        }
+                        if (pt.x > area.width - 3*charWidth) {
+                            int leftPixel = text.getHorizontalPixel();
+                            text.setHorizontalPixel(leftPixel + scrollAmount);
+                        }
+                        int lineHeight = text.getLineHeight();
+                        if (pt.y < area.y + lineHeight) {
+                            int topPixel = text.getTopPixel();
+                            text.setTopPixel(topPixel - lineHeight);
+                        }
+                        if (pt.y > area.height - lineHeight) {
+                            int topPixel = text.getTopPixel();
+                            text.setTopPixel(topPixel + lineHeight);
+                        }
+                        scrollBeginTime = 0;
+                        scrollX = scrollY = -1;
+                    }
+                } else {
+                    scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+                    scrollX = pt.x;
+                    scrollY = pt.y;
+                }
+            }
+        }
+            
+        if ((effect & DND.FEEDBACK_SELECT) !is 0) {
+            int[] trailing = new int [1];
+            int newOffset = text.getOffsetAtPoint(pt.x, pt.y, trailing, false);
+            newOffset += trailing [0];
+            if (newOffset !is currentOffset) {
+                refreshCaret(text, currentOffset, newOffset);
+                currentOffset = newOffset;
+            }
+        }
+    }
+
+    void refreshCaret(StyledText text, int oldOffset, int newOffset) {
+        if (oldOffset !is newOffset) {
+            if (oldOffset !is -1) {
+                Point oldPos = text.getLocationAtOffset(oldOffset);
+                int oldHeight = text.getLineHeight(oldOffset);
+                text.redraw (oldPos.x, oldPos.y, CARET_WIDTH, oldHeight, false);
+            }
+            if (newOffset !is -1) {
+                Point newPos = text.getLocationAtOffset(newOffset);
+                int newHeight = text.getLineHeight(newOffset);
+                text.redraw (newPos.x, newPos.y, CARET_WIDTH, newHeight, false);
+            }
+        }
+    }
+
+    /**
+     * This implementation of <code>dropAccept</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dropAccept</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dropAccept(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drop accept event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     */
+    public void dropAccept(DropTargetEvent event) {
+        if (currentOffset !is -1) {
+            StyledText text = (StyledText) getControl();
+            text.setSelection(currentOffset);
+            currentOffset = -1;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyledTextEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ *
+ */ 
+class StyledTextEvent : Event {
+    // used by LineStyleEvent
+    int[] ranges;
+    StyleRange[] styles;
+    int alignment;
+    int indent;
+    bool justify;
+    Bullet bullet;
+    int bulletIndex;
+    // used by LineBackgroundEvent
+    Color lineBackground;
+    // used by BidiSegmentEvent
+    int[] segments; 
+    // used by TextChangedEvent
+    int replaceCharCount;   
+    int newCharCount; 
+    int replaceLineCount;
+    int newLineCount;
+    // used by PaintObjectEvent
+    int x;
+    int y;
+    int ascent;
+    int descent;
+    StyleRange style;
+
+StyledTextEvent (StyledTextContent content) {
+    super();
+    data = content; 
+}
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyledTextListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+import dwt.widgets.*;
+import dwt.internal.DWTEventListener;
+
+class StyledTextListener : TypedListener {
+/**
+ */
+StyledTextListener(DWTEventListener listener) {
+    super(listener);
+}
+/**
+ * Process StyledText events by invoking the event's handler.
+ */
+public void handleEvent(Event e) {
+    
+    switch (e.type) {
+        case StyledText.ExtendedModify:
+            ExtendedModifyEvent extendedModifyEvent = new ExtendedModifyEvent((StyledTextEvent) e);
+            ((ExtendedModifyListener) eventListener).modifyText(extendedModifyEvent);
+            break;      
+        case StyledText.LineGetBackground:
+            LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e);
+            ((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent);
+            ((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground;
+            break;      
+        case StyledText.LineGetSegments:
+            BidiSegmentEvent segmentEvent = new BidiSegmentEvent((StyledTextEvent) e);
+            ((BidiSegmentListener) eventListener).lineGetSegments(segmentEvent);
+            ((StyledTextEvent) e).segments = segmentEvent.segments;
+            break;      
+        case StyledText.LineGetStyle:
+            LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e);
+            ((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent);
+            ((StyledTextEvent) e).ranges = lineStyleEvent.ranges;
+            ((StyledTextEvent) e).styles = lineStyleEvent.styles;
+            ((StyledTextEvent) e).alignment = lineStyleEvent.alignment;
+            ((StyledTextEvent) e).indent = lineStyleEvent.indent;
+            ((StyledTextEvent) e).justify = lineStyleEvent.justify;
+            ((StyledTextEvent) e).bullet = lineStyleEvent.bullet;
+            ((StyledTextEvent) e).bulletIndex = lineStyleEvent.bulletIndex;
+            break;
+        case StyledText.PaintObject:
+            PaintObjectEvent paintObjectEvent = new PaintObjectEvent((StyledTextEvent) e);
+            ((PaintObjectListener) eventListener).paintObject(paintObjectEvent);
+            break;          
+        case StyledText.VerifyKey:
+            VerifyEvent verifyEvent = new VerifyEvent(e);
+            ((VerifyKeyListener) eventListener).verifyKey(verifyEvent);
+            e.doit = verifyEvent.doit;
+            break;
+        case StyledText.TextChanged: {
+            TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
+            ((TextChangeListener) eventListener).textChanged(textChangedEvent);
+            break;
+        }
+        case StyledText.TextChanging:
+            TextChangingEvent textChangingEvent = new TextChangingEvent((StyledTextContent) e.data, (StyledTextEvent) e);
+            ((TextChangeListener) eventListener).textChanging(textChangingEvent);
+            break;
+        case StyledText.TextSet: {
+            TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
+            ((TextChangeListener) eventListener).textSet(textChangedEvent);
+            break;
+        }
+        case StyledText.WordNext: {
+            MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e);
+            ((MovementListener) eventListener).getNextOffset(wordBoundaryEvent);
+            ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset;
+            break;
+        }
+        case StyledText.WordPrevious: {
+            MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e);
+            ((MovementListener) eventListener).getPreviousOffset(wordBoundaryEvent);
+            ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset;
+            break;
+        }
+    }
+}
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyledTextPrintOptions.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+/**
+ * Use StyledTextPrintOptions to specify printing options for the
+ * StyledText.print(Printer, StyledTextPrintOptions) API.
+ * <p>
+ * The following example prints a right aligned page number in the footer,
+ * sets the job name to "Example" and prints line background colors but no other
+ * formatting:
+ * </p>
+ * <pre>
+ * StyledTextPrintOptions options = new StyledTextPrintOptions();
+ * options.footer = "\t\t&lt;page&gt;"; 
+ * options.jobName = "Example";
+ * options.printLineBackground = true;
+ * 
+ * Runnable runnable = styledText.print(new Printer(), options); 
+ * runnable.run();
+ * </pre>
+ * @since 2.1
+ */
+public class StyledTextPrintOptions {
+    /**
+     * Page number placeholder constant for use in <code>header</code>
+     * and <code>footer</code>. Value is <code>&lt;page&gt;</code>
+     */
+    public static final String PAGE_TAG = "<page>";
+    /**
+     * Separator constant for use in <code>header</code> and
+     * <code>footer</code>. Value is <code>\t</code>
+     */
+    public static final String SEPARATOR = "\t";
+    /**
+     * Formatted text to print in the header of each page.
+     * <p>"left '\t' center '\t' right"</p>
+     * <p>left, center, right = &lt;page&gt; | #CDATA</p>
+     * <p>Header and footer are defined as three separate regions for arbitrary
+     * text or the page number placeholder &lt;page&gt;
+     * (<code>StyledTextPrintOptions.PAGE_TAG</code>). The three regions are 
+     * left aligned, centered and right aligned. They are separated by a tab
+     * character (<code>StyledTextPrintOptions.SEPARATOR</code>).
+     */
+    public String header = null;
+    /**
+     * Formatted text to print in the footer of each page.
+     * <p>"left '\t' center '\t' right"</p>
+     * <p>left, center, right = &lt;page&gt; | #CDATA</p>
+     * <p>Header and footer are defined as three separate regions for arbitrary
+     * text or the page number placeholder &lt;page&gt;
+     * (<code>StyledTextPrintOptions.PAGE_TAG</code>). The three regions are 
+     * left aligned, centered and right aligned. They are separated by a tab
+     * character (<code>StyledTextPrintOptions.SEPARATOR</code>).
+     */
+    public String footer = null;
+    /**
+     * Name of the print job.
+     */
+    public String jobName = null;
+    
+    /**
+     * Print the text foreground color. Default value is <code>false</code>.
+     */
+    public bool printTextForeground = false;
+    /**
+     * Print the text background color. Default value is <code>false</code>.
+     */
+    public bool printTextBackground = false;
+    /**
+     * Print the font styles. Default value is <code>false</code>.
+     */
+    public bool printTextFontStyle = false;
+    /**
+     * Print the line background color. Default value is <code>false</code>.
+     */
+    public bool printLineBackground = false;
+    
+    /**
+     * Print line numbers. Default value is <code>false</code>.
+     * 
+     * @since 3.3
+     */
+    public bool printLineNumbers = false;
+    
+    /**
+     * Labels used for printing line numbers.
+     * 
+     * @since 3.4
+     */
+    public String[] lineLabels = null;
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/StyledTextRenderer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1519 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.DWT;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * A StyledTextRenderer renders the content of a StyledText widget.
+ * This class can be used to render to the display or to a printer.
+ */
+class StyledTextRenderer {
+    Device device;
+    StyledText styledText;
+    StyledTextContent content;
+
+    /* Font info */
+    Font regularFont, boldFont, italicFont, boldItalicFont;
+    int tabWidth;
+    int ascent, descent;
+    int averageCharWidth;
+    
+    /* Line data */
+    int topIndex = -1;
+    TextLayout[] layouts;
+    int lineCount;
+    int[] lineWidth;
+    int[] lineHeight;
+    LineInfo[] lines;
+    int maxWidth;
+    int maxWidthLineIndex;
+    bool idleRunning;
+    
+    /* Bullet */
+    Bullet[] bullets;
+    int[] bulletsIndices;
+    int[] redrawLines;
+    
+    /* Style data */
+    int[] ranges;
+    int styleCount; 
+    StyleRange[] styles;
+    StyleRange[] stylesSet;
+    int stylesSetCount = 0;
+    final static int BULLET_MARGIN = 8;
+    
+    final static bool COMPACT_STYLES = true;
+    final static bool MERGE_STYLES = true;
+    
+    final static int GROW = 32;
+    final static int IDLE_TIME = 50;
+    final static int CACHE_SIZE = 128;
+    
+    final static int BACKGROUND = 1 << 0;
+    final static int ALIGNMENT = 1 << 1;
+    final static int INDENT = 1 << 2;
+    final static int JUSTIFY = 1 << 3;
+    final static int SEGMENTS = 1 << 5;
+    
+    static class LineInfo {
+        int flags;
+        Color background;
+        int alignment;
+        int indent;
+        bool justify;
+        int[] segments;
+
+        public LineInfo() {
+        }
+        public LineInfo(LineInfo info) {
+            if (info !is null) {
+                flags = info.flags;
+                background = info.background;
+                alignment = info.alignment;
+                indent = info.indent;
+                justify = info.justify;
+                segments = info.segments;
+            }
+        }
+    }
+    
+StyledTextRenderer(Device device, StyledText styledText) {
+    this.device = device;
+    this.styledText = styledText;
+}
+int addMerge(int[] mergeRanges, StyleRange[] mergeStyles, int mergeCount, int modifyStart, int modifyEnd) {
+    int rangeCount = styleCount << 1;
+    StyleRange endStyle = null;
+    int endStart = 0, endLength = 0;
+    if (modifyEnd < rangeCount) {
+        endStyle = styles[modifyEnd >> 1];
+        endStart = ranges[modifyEnd];
+        endLength = ranges[modifyEnd + 1];
+    }
+    int grow = mergeCount - (modifyEnd - modifyStart);
+    if (rangeCount + grow >= ranges.length) {
+        int[] tmpRanges = new int[ranges.length + grow + (GROW << 1)];
+        System.arraycopy(ranges, 0, tmpRanges, 0, modifyStart);
+        StyleRange[] tmpStyles = new StyleRange[styles.length + (grow >> 1) + GROW];
+        System.arraycopy(styles, 0, tmpStyles, 0, modifyStart >> 1);
+        if (rangeCount > modifyEnd) {
+            System.arraycopy(ranges, modifyEnd, tmpRanges, modifyStart + mergeCount, rangeCount - modifyEnd);
+            System.arraycopy(styles, modifyEnd >> 1, tmpStyles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));
+        }
+        ranges = tmpRanges;
+        styles = tmpStyles;
+    } else {
+        if (rangeCount > modifyEnd) {
+            System.arraycopy(ranges, modifyEnd, ranges, modifyStart + mergeCount, rangeCount - modifyEnd);
+            System.arraycopy(styles, modifyEnd >> 1, styles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));
+        }
+    }
+    if (MERGE_STYLES) {
+        int j = modifyStart;    
+        for (int i = 0; i < mergeCount; i += 2) {
+            if (j > 0 && ranges[j - 2] + ranges[j - 1] is mergeRanges[i] && mergeStyles[i >> 1].similarTo(styles[(j - 2) >> 1])) {
+                ranges[j - 1] += mergeRanges[i + 1];
+            } else {
+                styles[j >> 1] = mergeStyles[i >> 1];
+                ranges[j++] = mergeRanges[i];
+                ranges[j++] = mergeRanges[i + 1];
+            }
+        }
+        if (endStyle !is null && ranges[j - 2] + ranges[j - 1] is endStart && endStyle.similarTo(styles[(j - 2) >> 1])) {
+            ranges[j - 1] += endLength;
+            modifyEnd += 2;
+            mergeCount += 2;
+        }
+        if (rangeCount > modifyEnd) {
+            System.arraycopy(ranges, modifyStart + mergeCount, ranges, j, rangeCount - modifyEnd);
+            System.arraycopy(styles, (modifyStart + mergeCount) >> 1, styles, j >> 1, styleCount - (modifyEnd >> 1));
+        }
+        grow = (j - modifyStart) - (modifyEnd - modifyStart);
+    } else {
+        System.arraycopy(mergeRanges, 0, ranges, modifyStart, mergeCount);
+        System.arraycopy(mergeStyles, 0, styles, modifyStart >> 1, mergeCount >> 1);
+    }
+    styleCount += grow >> 1;
+    return grow;
+}
+int addMerge(StyleRange[] mergeStyles, int mergeCount, int modifyStart, int modifyEnd) {
+    int grow = mergeCount - (modifyEnd - modifyStart);
+    StyleRange endStyle = null;
+    if (modifyEnd < styleCount) endStyle = styles[modifyEnd];
+    if (styleCount + grow >= styles.length) {
+        StyleRange[] tmpStyles = new StyleRange[styles.length + grow + GROW];
+        System.arraycopy(styles, 0, tmpStyles, 0, modifyStart);
+        if (styleCount > modifyEnd) {
+            System.arraycopy(styles, modifyEnd, tmpStyles, modifyStart + mergeCount, styleCount - modifyEnd);
+        }
+        styles = tmpStyles;
+    } else {
+        if (styleCount > modifyEnd) {
+            System.arraycopy(styles, modifyEnd, styles, modifyStart + mergeCount, styleCount - modifyEnd);
+        }
+    }
+    if (MERGE_STYLES) {
+        int j = modifyStart;
+        for (int i = 0; i < mergeCount; i++) {
+            StyleRange newStyle = mergeStyles[i], style;
+            if (j > 0 && (style = styles[j - 1]).start + style.length is newStyle.start && newStyle.similarTo(style)) {
+                style.length += newStyle.length;
+            } else {
+                styles[j++] = newStyle;
+            }
+        }
+        StyleRange style = styles[j - 1];
+        if (endStyle !is null && style.start + style.length is endStyle.start && endStyle.similarTo(style)) {
+            style.length += endStyle.length;
+            modifyEnd++;
+            mergeCount++;
+        }
+        if (styleCount > modifyEnd) {
+            System.arraycopy(styles, modifyStart + mergeCount, styles, j, styleCount - modifyEnd);
+        }
+        grow = (j - modifyStart) - (modifyEnd - modifyStart);
+    } else {
+        System.arraycopy(mergeStyles, 0, styles, modifyStart, mergeCount);
+    }
+    styleCount += grow;
+    return grow;
+}
+void calculate(int startLine, int lineCount) {
+    int endLine = startLine + lineCount;
+    if (startLine < 0 || endLine > lineWidth.length) {
+        return;
+    }
+    int hTrim = styledText.leftMargin + styledText.rightMargin + styledText.getCaretWidth();
+    for (int i = startLine; i < endLine; i++) {
+        if (lineWidth[i] is -1 || lineHeight[i] is -1) {
+            TextLayout layout = getTextLayout(i);
+            Rectangle rect = layout.getBounds();
+            lineWidth[i] = rect.width + hTrim;
+            lineHeight[i] = rect.height;
+            disposeTextLayout(layout);
+        }
+        if (lineWidth[i] > maxWidth) {
+            maxWidth = lineWidth[i];
+            maxWidthLineIndex = i;
+        }
+    }
+}
+void calculateClientArea () {
+    int index = styledText.getTopIndex();
+    int lineCount = content.getLineCount();
+    int height = styledText.getClientArea().height;
+    int y = 0;
+    while (height > y && lineCount > index) {
+        calculate(index, 1);
+        y += lineHeight[index++];
+    }
+}
+void calculateIdle () {
+    if (idleRunning) return;
+    Runnable runnable = new Runnable() {
+        public void run() {
+            if (styledText is null) return;
+            int i;
+            long start = System.currentTimeMillis();
+            for (i = 0; i < lineCount; i++) {
+                if (lineHeight[i] is -1 || lineWidth[i] is -1) {
+                    calculate(i, 1);
+                    if (System.currentTimeMillis() - start > IDLE_TIME) break;
+                }
+            }
+            if (i < lineCount) {
+                Display display = styledText.getDisplay();              
+                display.asyncExec(this);
+            } else {
+                idleRunning = false;
+                styledText.setScrollBars(true);
+                ScrollBar bar = styledText.getVerticalBar();
+                if (bar !is null) {
+                    bar.setSelection(styledText.getVerticalScrollOffset());
+                }                   
+            }
+        }
+    };      
+    Display display = styledText.getDisplay();
+    display.asyncExec(runnable);
+    idleRunning = true;
+}
+void clearLineBackground(int startLine, int count) {
+    if (lines is null) return;
+    for (int i = startLine; i < startLine + count; i++) {
+        LineInfo info = lines[i];
+        if (info !is null) {
+            info.flags &= ~BACKGROUND;
+            info.background = null;
+            if (info.flags is 0) lines[i] = null;
+        }
+    }
+}
+void clearLineStyle(int startLine, int count) {
+    if (lines is null) return;
+    for (int i = startLine; i < startLine + count; i++) {
+        LineInfo info = lines[i];
+        if (info !is null) {
+            info.flags &= ~(ALIGNMENT | INDENT | JUSTIFY);
+            if (info.flags is 0) lines[i] = null;
+        }
+    }
+}
+void copyInto(StyledTextRenderer renderer) {
+    if (ranges !is null) {
+        int[] newRanges = renderer.ranges = new int[styleCount << 1];
+        System.arraycopy(ranges, 0, newRanges, 0, newRanges.length);
+    }
+    if (styles !is null) {
+        StyleRange[] newStyles = renderer.styles = new StyleRange[styleCount];
+        for (int i = 0; i < newStyles.length; i++) {
+            newStyles[i] = (StyleRange)styles[i].clone();
+        }
+        renderer.styleCount = styleCount;
+    }
+    if (lines !is null) {
+        LineInfo[] newLines = renderer.lines = new LineInfo[lineCount];
+        for (int i = 0; i < newLines.length; i++) {
+            newLines[i] = new LineInfo(lines[i]);               
+        }
+        renderer.lineCount = lineCount;
+    }
+}
+void dispose() {
+    if (boldFont !is null) boldFont.dispose();
+    if (italicFont !is null) italicFont.dispose();
+    if (boldItalicFont !is null) boldItalicFont.dispose();
+    boldFont = italicFont = boldItalicFont = null;
+    reset();
+    content = null;
+    device = null;
+    styledText = null;
+}
+void disposeTextLayout (TextLayout layout) {
+    if (layouts !is null) {
+        for (int i = 0; i < layouts.length; i++) {
+            if (layouts[i] is layout) return;
+        }
+    }
+    layout.dispose();
+}
+void drawBullet(Bullet bullet, GC gc, int paintX, int paintY, int index, int lineAscent, int lineDescent) {
+    StyleRange style = bullet.style;
+    GlyphMetrics metrics = style.metrics;
+    Color color = style.foreground;
+    if (color !is null) gc.setForeground(color);
+    if ((bullet.type & ST.BULLET_DOT) !is 0 && StyledText.IS_MOTIF) {
+        int size = Math.max(4, (lineAscent + lineDescent) / 4);
+        if ((size & 1) is 0) size++;
+        if (color is null) {
+            Display display = styledText.getDisplay();
+            color = display.getSystemColor(DWT.COLOR_BLACK);
+        }
+        gc.setBackground(color);
+        int x = paintX + Math.max(0, metrics.width - size - BULLET_MARGIN);
+        gc.fillArc(x, paintY + size, size + 1, size + 1, 0, 360);
+        return;
+    }
+    Font font = style.font;
+    if (font !is null) gc.setFont(font);
+    String String = "";
+    int type = bullet.type & (ST.BULLET_DOT|ST.BULLET_NUMBER|ST.BULLET_LETTER_LOWER|ST.BULLET_LETTER_UPPER);
+    switch (type) {
+        case ST.BULLET_DOT: String = "\u2022"; break;
+        case ST.BULLET_NUMBER: String = String.valueOf(index); break;
+        case ST.BULLET_LETTER_LOWER: String = String.valueOf((char) (index % 26 + 97)); break;
+        case ST.BULLET_LETTER_UPPER: String = String.valueOf((char) (index % 26 + 65)); break;
+    }
+    if ((bullet.type & ST.BULLET_TEXT) !is 0) String += bullet.text;
+    Display display = styledText.getDisplay();
+    TextLayout layout = new TextLayout(display);
+    layout.setText(String);
+    layout.setAscent(lineAscent);
+    layout.setDescent(lineDescent);
+    style = (StyleRange)style.clone();
+    style.metrics = null;
+    if (style.font is null) style.font = getFont(style.fontStyle);
+    layout.setStyle(style, 0, String.length()); 
+    int x = paintX + Math.max(0, metrics.width - layout.getBounds().width - BULLET_MARGIN);
+    layout.draw(gc, x, paintY);
+    layout.dispose();
+}
+int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground) {
+    TextLayout layout = getTextLayout(lineIndex);
+    String line = content.getLine(lineIndex);
+    int lineOffset = content.getOffsetAtLine(lineIndex);
+    int lineLength = line.length();
+    Point selection = styledText.getSelection();
+    int selectionStart = selection.x - lineOffset;
+    int selectionEnd = selection.y - lineOffset;
+    Rectangle client = styledText.getClientArea();  
+    Color lineBackground = getLineBackground(lineIndex, null);
+    StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);
+    if (event !is null && event.lineBackground !is null) lineBackground = event.lineBackground;
+    int height = layout.getBounds().height;
+    if (lineBackground !is null) {
+        gc.setBackground(lineBackground);
+        gc.fillRectangle(client.x, paintY, client.width, height);
+    } else {
+        gc.setBackground(widgetBackground);
+        styledText.drawBackground(gc, client.x, paintY, client.width, height);
+    }
+    gc.setForeground(widgetForeground);
+    if (selectionStart is selectionEnd || (selectionEnd <= 0 && selectionStart > lineLength - 1)) {
+        layout.draw(gc, paintX, paintY);
+    } else {
+        int start = Math.max(0, selectionStart);
+        int end = Math.min(lineLength, selectionEnd);
+        Color selectionFg = styledText.getSelectionForeground();
+        Color selectionBg = styledText.getSelectionBackground();
+        int flags;
+        if ((styledText.getStyle() & DWT.FULL_SELECTION) !is 0) {
+            flags = DWT.FULL_SELECTION;
+        } else {
+            flags = DWT.DELIMITER_SELECTION;
+        }
+        if (selectionStart <= lineLength && lineLength < selectionEnd ) {
+            flags |= DWT.LAST_LINE_SELECTION;
+        }
+        layout.draw(gc, paintX, paintY, start, end - 1, selectionFg, selectionBg, flags);
+    }
+    
+    // draw objects
+    Bullet bullet = null;
+    int bulletIndex = -1;
+    if (bullets !is null) {
+        if (bulletsIndices !is null) {
+            int index = lineIndex - topIndex;
+            if (0 <= index && index < CACHE_SIZE) {
+                bullet = bullets[index];
+                bulletIndex = bulletsIndices[index];
+            }
+        } else {
+            for (int i = 0; i < bullets.length; i++) {
+                bullet = bullets[i];
+                bulletIndex = bullet.indexOf(lineIndex);
+                if (bulletIndex !is -1) break;
+            }
+        }
+    }
+    if (bulletIndex !is -1 && bullet !is null) {
+        FontMetrics metrics = layout.getLineMetrics(0);
+        int lineAscent = metrics.getAscent() + metrics.getLeading();
+        if (bullet.type is ST.BULLET_CUSTOM) {
+            bullet.style.start = lineOffset;
+            styledText.paintObject(gc, paintX, paintY, lineAscent, metrics.getDescent(), bullet.style, bullet, bulletIndex);
+        } else {
+            drawBullet(bullet, gc, paintX, paintY, bulletIndex, lineAscent, metrics.getDescent());
+        }
+    }
+    TextStyle[] styles = layout.getStyles();
+    int[] ranges = null;
+    for (int i = 0; i < styles.length; i++) {
+        if (styles[i].metrics !is null) {
+            if (ranges is null) ranges = layout.getRanges();
+            int start = ranges[i << 1];
+            int length = ranges[(i << 1) + 1] - start;
+            Point point = layout.getLocation(start, false);
+            FontMetrics metrics = layout.getLineMetrics(layout.getLineIndex(start));
+            StyleRange style = (StyleRange)((StyleRange)styles[i]).clone();
+            style.start = start + lineOffset;
+            style.length = length;
+            int lineAscent = metrics.getAscent() + metrics.getLeading();
+            styledText.paintObject(gc, point.x + paintX, point.y + paintY, lineAscent, metrics.getDescent(), style, null, 0);
+        }
+    }
+    disposeTextLayout(layout);
+    return height;
+}
+int getBaseline() {
+    return ascent;
+}
+Font getFont(int style) {
+    switch (style) {
+        case DWT.BOLD:
+            if (boldFont !is null) return boldFont;
+            return boldFont = new Font(device, getFontData(style));
+        case DWT.ITALIC:
+            if (italicFont !is null) return italicFont;
+            return italicFont = new Font(device, getFontData(style));
+        case DWT.BOLD | DWT.ITALIC:
+            if (boldItalicFont !is null) return boldItalicFont;
+            return boldItalicFont = new Font(device, getFontData(style));
+        default:
+            return regularFont;
+    }
+}
+FontData[] getFontData(int style) {
+    FontData[] fontDatas = regularFont.getFontData();
+    for (int i = 0; i < fontDatas.length; i++) {
+        fontDatas[i].setStyle(style);
+    }
+    return fontDatas;
+}
+int getHeight () {
+    int defaultLineHeight = getLineHeight();
+    if (styledText.isFixedLineHeight()) {
+        return lineCount * defaultLineHeight;
+    }
+    int totalHeight = 0;
+    int width = styledText.getWrapWidth();
+    for (int i = 0; i < lineCount; i++) {
+        int height = lineHeight[i];
+        if (height is -1) {
+            if (width > 0) {
+                int length = content.getLine(i).length();
+                height = ((length * averageCharWidth / width) + 1) * defaultLineHeight;
+            } else {
+                height = defaultLineHeight;
+            }
+        }
+        totalHeight += height;
+    }
+    return totalHeight + styledText.topMargin + styledText.bottomMargin;
+}
+int getLineAlignment(int index, int defaultAlignment) {
+    if (lines is null) return defaultAlignment;
+    LineInfo info = lines[index];
+    if (info !is null && (info.flags & ALIGNMENT) !is 0) {
+        return info.alignment;
+    }
+    return defaultAlignment;
+}
+Color getLineBackground(int index, Color defaultBackground) {
+    if (lines is null) return defaultBackground;
+    LineInfo info = lines[index];
+    if (info !is null && (info.flags & BACKGROUND) !is 0) {
+        return info.background;
+    }
+    return defaultBackground;
+}
+Bullet getLineBullet (int index, Bullet defaultBullet) {
+    if (bullets is null) return defaultBullet;
+    if (bulletsIndices !is null) return defaultBullet;
+    for (int i = 0; i < bullets.length; i++) {
+        Bullet bullet = bullets[i];
+        if (bullet.indexOf(index) !is -1) return bullet;
+    }
+    return defaultBullet;
+}
+int getLineHeight() {
+    return ascent + descent;
+}
+int getLineHeight(int lineIndex) {
+    if (lineHeight[lineIndex] is -1) {
+        calculate(lineIndex, 1);
+    }
+    return lineHeight[lineIndex];
+}
+int getLineIndent(int index, int defaultIndent) {
+    if (lines is null) return defaultIndent;
+    LineInfo info = lines[index];
+    if (info !is null && (info.flags & INDENT) !is 0) {
+        return info.indent;
+    }
+    return defaultIndent;
+}
+bool getLineJustify(int index, bool defaultJustify) {
+    if (lines is null) return defaultJustify;
+    LineInfo info = lines[index];
+    if (info !is null && (info.flags & JUSTIFY) !is 0) {
+        return info.justify;
+    }
+    return defaultJustify;
+}
+int[] getLineSegments(int index, int[] defaultSegments) {
+    if (lines is null) return defaultSegments;
+    LineInfo info = lines[index];
+    if (info !is null && (info.flags & SEGMENTS) !is 0) {
+        return info.segments;
+    }
+    return defaultSegments;
+}
+int getRangeIndex(int offset, int low, int high) {
+    if (styleCount is 0) return 0;
+    if (ranges !is null)  {
+        while (high - low > 2) {
+            int index = ((high + low) / 2) / 2 * 2;
+            int end = ranges[index] + ranges[index + 1];
+            if (end > offset) {
+                high = index;
+            } else {
+                low = index;
+            }
+        }
+    } else {
+        while (high - low > 1) {
+            int index = ((high + low) / 2);
+            int end = styles[index].start + styles[index].length;
+            if (end > offset) {
+                high = index;
+            } else {
+                low = index;
+            }
+        }
+    }
+    return high;
+}
+int[] getRanges(int start, int length) {
+    int[] newRanges;
+    int end = start + length - 1;
+    if (ranges !is null) {
+        int rangeCount = styleCount << 1;
+        int rangeStart = getRangeIndex(start, -1, rangeCount);
+        if (rangeStart >= rangeCount) return null;
+        if (ranges[rangeStart] > end) return null;
+        int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount) + 1);
+        newRanges = new int[rangeEnd - rangeStart + 2];
+        System.arraycopy(ranges, rangeStart, newRanges, 0, newRanges.length);
+    } else {
+        int rangeStart = getRangeIndex(start, -1, styleCount);
+        if (rangeStart >= styleCount) return null;
+        if (styles[rangeStart].start > end) return null;
+        int rangeEnd = Math.min(styleCount - 1, getRangeIndex(end, rangeStart - 1, styleCount));
+        newRanges = new int[(rangeEnd - rangeStart + 1) << 1];
+        for (int i = rangeStart, j = 0; i <= rangeEnd; i++, j += 2) {
+            StyleRange style = styles[i];
+            newRanges[j] = style.start;
+            newRanges[j + 1] = style.length;
+        }       
+    }
+    if (start > newRanges[0]) {
+        newRanges[1] = newRanges[0] + newRanges[1] - start;
+        newRanges[0] = start;
+    }
+    if (end < newRanges[newRanges.length - 2] + newRanges[newRanges.length - 1] - 1) {
+        newRanges[newRanges.length - 1] = end - newRanges[newRanges.length - 2] + 1;
+    }
+    return newRanges;
+}
+StyleRange[] getStyleRanges(int start, int length, bool includeRanges) {
+    StyleRange[] newStyles;
+    int end = start + length - 1;
+    if (ranges !is null) {
+        int rangeCount = styleCount << 1;
+        int rangeStart = getRangeIndex(start, -1, rangeCount);
+        if (rangeStart >= rangeCount) return null;
+        if (ranges[rangeStart] > end) return null;
+        int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount) + 1);
+        newStyles = new StyleRange[((rangeEnd - rangeStart) >> 1) + 1];
+        if (includeRanges) {
+            for (int i = rangeStart, j = 0; i <= rangeEnd; i += 2, j++) {
+                newStyles[j] = (StyleRange)styles[i >> 1].clone();
+                newStyles[j].start = ranges[i];
+                newStyles[j].length = ranges[i + 1];
+            }
+        } else {
+            System.arraycopy(styles, rangeStart >> 1, newStyles, 0, newStyles.length);
+        }
+    } else {
+        int rangeStart = getRangeIndex(start, -1, styleCount);
+        if (rangeStart >= styleCount) return null;
+        if (styles[rangeStart].start > end) return null;
+        int rangeEnd = Math.min(styleCount - 1, getRangeIndex(end, rangeStart - 1, styleCount));
+        newStyles = new StyleRange[rangeEnd - rangeStart + 1];
+        System.arraycopy(styles, rangeStart, newStyles, 0, newStyles.length);
+    }
+    StyleRange style = newStyles[0];
+    if (start > style.start) {
+        if (!includeRanges || ranges is null) newStyles[0] = style = (StyleRange)style.clone();
+        style.length = style.start + style.length - start;
+        style.start = start;
+    }
+    style = newStyles[newStyles.length - 1];
+    if (end < style.start + style.length - 1) {
+        if (end < style.start) {
+            StyleRange[] tmp = new StyleRange[newStyles.length - 1];
+            System.arraycopy(newStyles, 0, tmp, 0, newStyles.length - 1);
+            newStyles = tmp;
+        } else {
+            if (!includeRanges || ranges is null) newStyles[newStyles.length - 1] = style = (StyleRange)style.clone();
+            style.length = end - style.start + 1;
+        }
+    }
+    return newStyles;
+}
+StyleRange getStyleRange(StyleRange style) {
+    if (style.start is 0 && style.length is 0 && style.fontStyle is DWT.NORMAL) return style;
+    StyleRange clone = (StyleRange)style.clone();
+    clone.start = clone.length = 0;
+    clone.fontStyle = DWT.NORMAL;
+    if (clone.font is null) clone.font = getFont(style.fontStyle);
+    return clone;
+}
+TextLayout getTextLayout(int lineIndex) {
+    return getTextLayout(lineIndex, styledText.getOrientation(), styledText.getWrapWidth(), styledText.lineSpacing);
+}
+TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpacing) {
+    TextLayout layout = null;
+    if (styledText !is null) {
+        int topIndex = styledText.topIndex > 0 ? styledText.topIndex - 1 : 0;   
+        if (layouts is null || topIndex !is this.topIndex) {
+            TextLayout[] newLayouts = new TextLayout[CACHE_SIZE];
+            if (layouts !is null) {
+                for (int i = 0; i < layouts.length; i++) {
+                    if (layouts[i] !is null) {
+                        int layoutIndex = (i + this.topIndex) - topIndex;
+                        if (0 <= layoutIndex && layoutIndex < newLayouts.length) {
+                            newLayouts[layoutIndex] = layouts[i];
+                        } else {
+                            layouts[i].dispose();
+                        }
+                    }
+                }
+            }
+            if (bullets !is null && bulletsIndices !is null && topIndex !is this.topIndex) {
+                int delta = topIndex - this.topIndex;
+                if (delta > 0) {
+                    if (delta < bullets.length) {
+                        System.arraycopy(bullets, delta, bullets, 0, bullets.length - delta);
+                        System.arraycopy(bulletsIndices, delta, bulletsIndices, 0, bulletsIndices.length - delta);
+                    }
+                    int startIndex = Math.max(0, bullets.length - delta);
+                    for (int i = startIndex; i < bullets.length; i++) bullets[i] = null;
+                } else {
+                    if (-delta < bullets.length) {
+                        System.arraycopy(bullets, 0, bullets, -delta, bullets.length + delta);
+                        System.arraycopy(bulletsIndices, 0, bulletsIndices, -delta, bulletsIndices.length + delta);
+                    }
+                    int endIndex = Math.min(bullets.length, -delta);
+                    for (int i = 0; i < endIndex; i++) bullets[i] = null;
+                }
+            }
+            this.topIndex = topIndex;
+            layouts = newLayouts;
+        }
+        if (layouts !is null) {
+            int layoutIndex = lineIndex - topIndex;
+            if (0 <= layoutIndex && layoutIndex < layouts.length) {
+                layout = layouts[layoutIndex];
+                if (layout !is null) {
+                    if (lineWidth[lineIndex] !is -1) return layout;
+                } else {
+                    layout = layouts[layoutIndex] = new TextLayout(device);
+                }
+            }
+        }
+    }
+    if (layout is null) layout = new TextLayout(device);
+    String line = content.getLine(lineIndex);
+    int lineOffset = content.getOffsetAtLine(lineIndex);
+    int[] segments = null;
+    int indent = 0;
+    int alignment = DWT.LEFT;
+    bool justify = false;
+    Bullet bullet = null;
+    int[] ranges = null;
+    StyleRange[] styles = null;
+    int rangeStart = 0, styleCount = 0;
+    StyledTextEvent event = null;
+    if (styledText !is null) {
+        event = styledText.getLineStyleData(lineOffset, line);
+        segments = styledText.getBidiSegments(lineOffset, line);
+        indent = styledText.indent;
+        alignment = styledText.alignment;
+        justify = styledText.justify;
+    }
+    if (event !is null) {
+        indent = event.indent;
+        alignment = event.alignment;
+        justify = event.justify;
+        bullet = event.bullet;
+        ranges = event.ranges;
+        styles = event.styles;
+        if (styles !is null) {
+            styleCount = styles.length;
+            if (styledText.isFixedLineHeight()) {
+                for (int i = 0; i < styleCount; i++) {
+                    if (styles[i].isVariableHeight()) {
+                        styledText.verticalScrollOffset = -1;
+                        styledText.setVariableLineHeight();
+                        styledText.redraw();
+                        break;
+                    }
+                }
+            }
+        }
+        if (bullets is null || bulletsIndices is null) {
+            bullets = new Bullet[CACHE_SIZE];
+            bulletsIndices = new int[CACHE_SIZE];
+        }
+        int index = lineIndex - topIndex;
+        if (0 <= index && index < CACHE_SIZE) {
+            bullets[index] = bullet;
+            bulletsIndices[index] = event.bulletIndex;
+        }
+    } else {
+        if (lines !is null) {
+            LineInfo info = lines[lineIndex];
+            if (info !is null) {
+                if ((info.flags & INDENT) !is 0) indent = info.indent;
+                if ((info.flags & ALIGNMENT) !is 0) alignment = info.alignment;
+                if ((info.flags & JUSTIFY) !is 0) justify = info.justify;
+                if ((info.flags & SEGMENTS) !is 0) segments = info.segments;
+            }
+        }
+        if (bulletsIndices !is null) {
+            bullets = null;
+            bulletsIndices = null;
+        }
+        if (bullets !is null) {
+            for (int i = 0; i < bullets.length; i++) {
+                if (bullets[i].indexOf(lineIndex) !is -1) {
+                    bullet = bullets[i];
+                    break;
+                }
+            }
+        }
+        ranges = this.ranges;
+        styles = this.styles;
+        styleCount = this.styleCount;
+        if (ranges !is null) {
+            rangeStart = getRangeIndex(lineOffset, -1, styleCount << 1);
+        } else {
+            rangeStart = getRangeIndex(lineOffset, -1, styleCount);
+        }
+    }
+    if (bullet !is null) {
+        StyleRange style = bullet.style;
+        GlyphMetrics metrics = style.metrics;
+        indent += metrics.width;
+    }
+    layout.setFont(regularFont);
+    layout.setAscent(ascent);
+    layout.setDescent(descent);
+    layout.setText(line);
+    layout.setOrientation(orientation);
+    layout.setSegments(segments);
+    layout.setWidth(width);
+    layout.setSpacing(lineSpacing);
+    layout.setTabs(new int[]{tabWidth});
+    layout.setIndent(indent);
+    layout.setAlignment(alignment);
+    layout.setJustify(justify);
+    
+    int lastOffset = 0;
+    int length = line.length();
+    if (styles !is null) {
+        if (ranges !is null) {
+            int rangeCount = styleCount << 1;
+            for (int i = rangeStart; i < rangeCount; i += 2) {
+                int start, end;
+                if (lineOffset > ranges[i]) {
+                    start = 0;
+                    end = Math.min (length, ranges[i + 1] - lineOffset + ranges[i]);
+                } else {
+                    start = ranges[i] - lineOffset;
+                    end = Math.min(length, start + ranges[i + 1]);
+                }
+                if (start >= length) break;
+                if (lastOffset < start) {
+                    layout.setStyle(null, lastOffset, start - 1);
+                }
+                layout.setStyle(getStyleRange(styles[i >> 1]), start, end);
+                lastOffset = Math.max(lastOffset, end);
+            }
+        } else {
+            for (int i = rangeStart; i < styleCount; i++) {
+                int start, end;
+                if (lineOffset > styles[i].start) {
+                    start = 0;
+                    end = Math.min (length, styles[i].length - lineOffset + styles[i].start);
+                } else {
+                    start = styles[i].start - lineOffset;
+                    end = Math.min(length, start + styles[i].length);
+                }
+                if (start >= length) break;
+                if (lastOffset < start) {
+                    layout.setStyle(null, lastOffset, start - 1);
+                }
+                layout.setStyle(getStyleRange(styles[i]), start, end);
+                lastOffset = Math.max(lastOffset, end);
+            }
+        }
+    }
+    if (lastOffset < length) layout.setStyle(null, lastOffset, length);
+    if (styledText !is null && styledText.ime !is null) {
+        IME ime = styledText.ime;
+        int compositionOffset = ime.getCompositionOffset();
+        if (compositionOffset !is -1) {
+            int commitCount = ime.getCommitCount();
+            int compositionLength = ime.getText().length();
+            if (compositionLength !is commitCount) {
+                int compositionLine = content.getLineAtOffset(compositionOffset);
+                if (compositionLine is lineIndex) {
+                    int[] imeRanges = ime.getRanges();
+                    TextStyle[] imeStyles = ime.getStyles();
+                    if (imeRanges.length > 0) {
+                        for (int i = 0; i < imeStyles.length; i++) {
+                            int start = imeRanges[i*2] - lineOffset;
+                            int end = imeRanges[i*2+1] - lineOffset;
+                            TextStyle imeStyle = imeStyles[i], userStyle;
+                            for (int j = start; j <= end; j++) {
+                                userStyle = layout.getStyle(j);
+                                if (userStyle is null && j > 0) userStyle = layout.getStyle(j - 1);
+                                if (userStyle is null && j + 1 < length) userStyle = layout.getStyle(j + 1);
+                                if (userStyle is null) {
+                                    layout.setStyle(imeStyle, j, j);
+                                } else {
+                                    TextStyle newStyle = new TextStyle(imeStyle);
+                                    if (newStyle.font is null) newStyle.font = userStyle.font;
+                                    if (newStyle.foreground is null) newStyle.foreground = userStyle.foreground;
+                                    if (newStyle.background is null) newStyle.background = userStyle.background;
+                                    layout.setStyle(newStyle, j, j);
+                                }
+                            }
+                        }
+                    } else {
+                        int start = compositionOffset - lineOffset;
+                        int end = start + compositionLength - 1;
+                        TextStyle userStyle = layout.getStyle(start);
+                        if (userStyle is null) {
+                            if (start > 0) userStyle = layout.getStyle(start - 1);
+                            if (userStyle is null && end + 1 < length) userStyle = layout.getStyle(end + 1);
+                            if (userStyle !is null) {
+                                TextStyle newStyle = new TextStyle();
+                                newStyle.font = userStyle.font;
+                                newStyle.foreground = userStyle.foreground;
+                                newStyle.background = userStyle.background;
+                                layout.setStyle(newStyle, start, end);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    
+    if (styledText !is null && styledText.isFixedLineHeight()) {
+        int index = -1;
+        int lineCount = layout.getLineCount();
+        int height = getLineHeight();
+        for (int i = 0; i < lineCount; i++) {
+            int lineHeight = layout.getLineBounds(i).height;
+            if (lineHeight > height) {
+                height = lineHeight;
+                index = i;
+            }
+        }
+        if (index !is -1) {
+            FontMetrics metrics = layout.getLineMetrics(index);
+            ascent = metrics.getAscent() + metrics.getLeading();
+            descent = metrics.getDescent();
+            if (layouts !is null) {
+                for (int i = 0; i < layouts.length; i++) {
+                    if (layouts[i] !is null && layouts[i] !is layout) {
+                        layouts[i].setAscent(ascent);
+                        layouts[i].setDescent(descent);
+                    }
+                }
+            }
+            if (styledText.verticalScrollOffset !is 0) {
+                int topIndex = styledText.topIndex;
+                int topIndexY = styledText.topIndexY;
+                int lineHeight = getLineHeight();
+                if (topIndexY >= 0) {
+                    styledText.verticalScrollOffset = (topIndex - 1) * lineHeight + lineHeight - topIndexY;
+                } else {
+                    styledText.verticalScrollOffset = topIndex * lineHeight - topIndexY;
+                }
+            }
+            styledText.calculateScrollBars();
+            if (styledText.isBidiCaret()) styledText.createCaretBitmaps();
+            styledText.caretDirection = DWT.NULL;
+            styledText.setCaretLocation();
+            styledText.redraw();
+        }
+    }
+    return layout;
+}
+int getWidth() {
+    return maxWidth;
+}
+void reset() {
+    if (layouts !is null) {
+        for (int i = 0; i < layouts.length; i++) {
+            TextLayout layout = layouts[i];
+            if (layout !is null) layout.dispose();
+        }
+        layouts = null;
+    }
+    topIndex = -1;
+    stylesSetCount = styleCount = lineCount = 0;
+    ranges = null;
+    styles = null;
+    stylesSet = null;
+    lines = null;
+    lineWidth = null;
+    lineHeight = null;
+    bullets = null;
+    bulletsIndices = null;
+    redrawLines = null;
+}
+void reset(int startLine, int lineCount) {
+    int endLine = startLine + lineCount;
+    if (startLine < 0 || endLine > lineWidth.length) return;
+    for (int i = startLine; i < endLine; i++) {
+        lineWidth[i] = -1;
+        lineHeight[i] = -1;
+    }
+    if (startLine <= maxWidthLineIndex && maxWidthLineIndex < endLine) {
+        maxWidth = 0;
+        maxWidthLineIndex = -1;
+        if (lineCount !is this.lineCount) {
+            for (int i = 0; i < this.lineCount; i++) {
+                if (lineWidth[i] > maxWidth) {
+                    maxWidth = lineWidth[i];
+                    maxWidthLineIndex = i;
+                }
+            }
+        }
+    }
+}
+void setContent(StyledTextContent content) {
+    reset();
+    this.content = content;
+    lineCount = content.getLineCount();
+    lineWidth = new int[lineCount];
+    lineHeight = new int[lineCount];
+    reset(0, lineCount);
+}
+void setFont(Font font, int tabs) {
+    TextLayout layout = new TextLayout(device);
+    layout.setFont(regularFont);
+    if (font !is null) {
+        if (boldFont !is null) boldFont.dispose();
+        if (italicFont !is null) italicFont.dispose();
+        if (boldItalicFont !is null) boldItalicFont.dispose();
+        boldFont = italicFont = boldItalicFont = null;
+        regularFont = font;
+        layout.setText("    ");
+        layout.setFont(font);
+        layout.setStyle(new TextStyle(getFont(DWT.NORMAL), null, null), 0, 0);
+        layout.setStyle(new TextStyle(getFont(DWT.BOLD), null, null), 1, 1);
+        layout.setStyle(new TextStyle(getFont(DWT.ITALIC), null, null), 2, 2);
+        layout.setStyle(new TextStyle(getFont(DWT.BOLD | DWT.ITALIC), null, null), 3, 3);
+        FontMetrics metrics = layout.getLineMetrics(0);
+        ascent = metrics.getAscent() + metrics.getLeading();
+        descent = metrics.getDescent();
+        boldFont.dispose();
+        italicFont.dispose();
+        boldItalicFont.dispose();
+        boldFont = italicFont = boldItalicFont = null;
+    }
+    layout.dispose();
+    layout = new TextLayout(device);
+    layout.setFont(regularFont);
+    StringBuffer tabBuffer = new StringBuffer(tabs);
+    for (int i = 0; i < tabs; i++) {
+        tabBuffer.append(' ');
+    }
+    layout.setText(tabBuffer.toString());
+    tabWidth = layout.getBounds().width;
+    layout.dispose();
+    if (styledText !is null) {
+        GC gc = new GC(styledText);
+        averageCharWidth = gc.getFontMetrics().getAverageCharWidth();
+        gc.dispose();
+    }
+}
+void setLineAlignment(int startLine, int count, int alignment) {
+    if (lines is null) lines = new LineInfo[lineCount];
+    for (int i = startLine; i < startLine + count; i++) {
+        if (lines[i] is null) {
+            lines[i] = new LineInfo();
+        }
+        lines[i].flags |= ALIGNMENT;
+        lines[i].alignment = alignment;
+    }
+}
+void setLineBackground(int startLine, int count, Color background) {
+    if (lines is null) lines = new LineInfo[lineCount];
+    for (int i = startLine; i < startLine + count; i++) {
+        if (lines[i] is null) {
+            lines[i] = new LineInfo();
+        }
+        lines[i].flags |= BACKGROUND;
+        lines[i].background = background;
+    }
+}
+void setLineBullet(int startLine, int count, Bullet bullet) {
+    if (bulletsIndices !is null) {
+        bulletsIndices = null;
+        bullets = null;
+    }
+    if (bullets is null) {
+        if (bullet is null) return;
+        bullets = new Bullet[1];
+        bullets[0] = bullet;
+    }
+    int index = 0;
+    while (index < bullets.length) {
+        if (bullet is bullets[index]) break;
+        index++;
+    }
+    if (bullet !is null) {
+        if (index is bullets.length) {
+            Bullet[] newBulletsList = new Bullet[bullets.length + 1];
+            System.arraycopy(bullets, 0, newBulletsList, 0, bullets.length);
+            newBulletsList[index] = bullet;
+            bullets = newBulletsList;
+        }
+        bullet.addIndices(startLine, count);
+    } else {
+        updateBullets(startLine, count, 0, false);
+        styledText.redrawLinesBullet(redrawLines);
+        redrawLines = null;
+    }
+}
+void setLineIndent(int startLine, int count, int indent) {
+    if (lines is null) lines = new LineInfo[lineCount];
+    for (int i = startLine; i < startLine + count; i++) {
+        if (lines[i] is null) {
+            lines[i] = new LineInfo();
+        }
+        lines[i].flags |= INDENT;
+        lines[i].indent = indent;
+    }
+}
+void setLineJustify(int startLine, int count, bool justify) {
+    if (lines is null) lines = new LineInfo[lineCount];
+    for (int i = startLine; i < startLine + count; i++) {
+        if (lines[i] is null) {
+            lines[i] = new LineInfo();
+        }
+        lines[i].flags |= JUSTIFY;
+        lines[i].justify = justify;
+    }
+}
+void setLineSegments(int startLine, int count, int[] segments) {
+    if (lines is null) lines = new LineInfo[lineCount];
+    for (int i = startLine; i < startLine + count; i++) {
+        if (lines[i] is null) {
+            lines[i] = new LineInfo();
+        }
+        lines[i].flags |= SEGMENTS;
+        lines[i].segments = segments;
+    }
+}
+void setStyleRanges (int[] newRanges, StyleRange[] newStyles) {
+    if (newStyles is null) {
+        stylesSetCount = styleCount = 0;
+        ranges = null;
+        styles = null;
+        stylesSet = null;
+        return;
+    }
+    if (newRanges is null && COMPACT_STYLES) {
+        newRanges = new int[newStyles.length << 1];     
+        StyleRange[] tmpStyles = new StyleRange[newStyles.length];
+        if (stylesSet is null) stylesSet = new StyleRange[4];
+        for (int i = 0, j = 0; i < newStyles.length; i++) {
+            StyleRange newStyle = newStyles[i];
+            newRanges[j++] = newStyle.start;
+            newRanges[j++] = newStyle.length;
+            int index = 0;
+            while (index < stylesSetCount) {
+                if (stylesSet[index].similarTo(newStyle)) break;
+                index++;
+            }
+            if (index is stylesSetCount) {
+                if (stylesSetCount is stylesSet.length) {
+                    StyleRange[] tmpStylesSet = new StyleRange[stylesSetCount + 4];
+                    System.arraycopy(stylesSet, 0, tmpStylesSet, 0, stylesSetCount);
+                    stylesSet = tmpStylesSet;
+                }
+                stylesSet[stylesSetCount++] = newStyle;
+            }
+            tmpStyles[i] = stylesSet[index];
+        }
+        newStyles = tmpStyles;
+    }
+    
+    if (styleCount is 0) {
+        if (newRanges !is null) {
+            ranges = new int[newRanges.length];
+            System.arraycopy(newRanges, 0, ranges, 0, ranges.length);
+        }
+        styles = new StyleRange[newStyles.length];
+        System.arraycopy(newStyles, 0, styles, 0, styles.length);
+        styleCount = newStyles.length;
+        return;
+    }
+    if (newRanges !is null && ranges is null) {
+        ranges = new int[styles.length << 1];
+        for (int i = 0, j = 0; i < styleCount; i++) {
+            ranges[j++] = styles[i].start;
+            ranges[j++] = styles[i].length;
+        }
+    }
+    if (newRanges is null && ranges !is null) {
+        newRanges = new int[newStyles.length << 1];
+        for (int i = 0, j = 0; i < newStyles.length; i++) {
+            newRanges[j++] = newStyles[i].start;
+            newRanges[j++] = newStyles[i].length;
+        }
+    }
+    if (ranges !is null) {
+        int rangeCount = styleCount << 1;
+        int start = newRanges[0];
+        int modifyStart = getRangeIndex(start, -1, rangeCount), modifyEnd;
+        bool insert = modifyStart is rangeCount;
+        if (!insert) {
+            int end = newRanges[newRanges.length - 2] + newRanges[newRanges.length - 1];
+            modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount);
+            insert = modifyStart is modifyEnd && ranges[modifyStart] >= end;
+        }
+        if (insert) {
+            addMerge(newRanges, newStyles, newRanges.length, modifyStart, modifyStart);
+            return;
+        }
+        modifyEnd = modifyStart;
+        int[] mergeRanges = new int[6];
+        StyleRange[] mergeStyles = new StyleRange[3];
+        for (int i = 0; i < newRanges.length; i += 2) {
+            int newStart = newRanges[i];
+            int newEnd = newStart + newRanges[i + 1];
+            if (newStart is newEnd) continue;
+            int modifyLast = 0, mergeCount = 0;
+            while (modifyEnd < rangeCount) {
+                if (newStart >= ranges[modifyStart] + ranges[modifyStart + 1]) modifyStart += 2;
+                if (ranges[modifyEnd] + ranges[modifyEnd + 1] > newEnd) break;
+                modifyEnd += 2;
+            }
+            if (ranges[modifyStart] < newStart && newStart < ranges[modifyStart] + ranges[modifyStart + 1]) {
+                mergeStyles[mergeCount >> 1] = styles[modifyStart >> 1];
+                mergeRanges[mergeCount] = ranges[modifyStart];
+                mergeRanges[mergeCount + 1] = newStart - ranges[modifyStart];               
+                mergeCount += 2;
+            }
+            mergeStyles[mergeCount >> 1] = newStyles[i >> 1];
+            mergeRanges[mergeCount] = newStart;
+            mergeRanges[mergeCount + 1] = newRanges[i + 1];
+            mergeCount += 2;
+            if (modifyEnd < rangeCount && ranges[modifyEnd] < newEnd && newEnd < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
+                mergeStyles[mergeCount >> 1] = styles[modifyEnd >> 1];
+                mergeRanges[mergeCount] = newEnd;
+                mergeRanges[mergeCount + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - newEnd;
+                mergeCount += 2;
+                modifyLast = 2;
+            }
+            int grow = addMerge(mergeRanges, mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);
+            rangeCount += grow;
+            modifyStart = modifyEnd += grow;
+        }
+    } else {
+        int start = newStyles[0].start;
+        int modifyStart = getRangeIndex(start, -1, styleCount), modifyEnd;
+        bool insert = modifyStart is styleCount;
+        if (!insert) {
+            int end = newStyles[newStyles.length - 1].start + newStyles[newStyles.length - 1].length;
+            modifyEnd = getRangeIndex(end, modifyStart - 1, styleCount);
+            insert = modifyStart is modifyEnd && styles[modifyStart].start >= end;
+        }
+        if (insert) {
+            addMerge(newStyles, newStyles.length, modifyStart, modifyStart);
+            return;
+        }
+        modifyEnd = modifyStart;
+        StyleRange[] mergeStyles = new StyleRange[3];
+        for (int i = 0; i < newStyles.length; i++) {
+            StyleRange newStyle = newStyles[i], style; 
+            int newStart = newStyle.start;
+            int newEnd = newStart + newStyle.length;
+            if (newStart is newEnd) continue;
+            int modifyLast = 0, mergeCount = 0;
+            while (modifyEnd < styleCount) {
+                if (newStart >= styles[modifyStart].start + styles[modifyStart].length) modifyStart++;
+                if (styles[modifyEnd].start + styles[modifyEnd].length > newEnd) break;
+                modifyEnd++;
+            }
+            style = styles[modifyStart];
+            if (style.start < newStart && newStart < style.start + style.length) {
+                style = mergeStyles[mergeCount++] = (StyleRange)style.clone();
+                style.length = newStart - style.start;
+            }
+            mergeStyles[mergeCount++] = newStyle;
+            if (modifyEnd < styleCount) {
+                style = styles[modifyEnd];
+                if (style.start < newEnd && newEnd < style.start + style.length) {
+                    style = mergeStyles[mergeCount++] = (StyleRange)style.clone();
+                    style.length += style.start - newEnd;
+                    style.start = newEnd;
+                    modifyLast = 1;
+                }
+            }
+            int grow = addMerge(mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);
+            modifyStart = modifyEnd += grow;
+        }
+    }
+}
+void textChanging(TextChangingEvent event) {
+    int start = event.start;
+    int newCharCount = event.newCharCount, replaceCharCount = event.replaceCharCount;
+    int newLineCount = event.newLineCount, replaceLineCount = event.replaceLineCount;
+    
+    updateRanges(start, replaceCharCount, newCharCount);    
+    
+    int startLine = content.getLineAtOffset(start);
+    if (replaceCharCount is content.getCharCount()) lines = null;
+    if (replaceLineCount is lineCount) {
+        lineCount = newLineCount;
+        lineWidth = new int[lineCount];
+        lineHeight = new int[lineCount];
+        reset(0, lineCount);
+    } else {
+        int delta = newLineCount - replaceLineCount;
+        if (lineCount + delta > lineWidth.length) {
+            int[] newWidths = new int[lineCount + delta + GROW];
+            System.arraycopy(lineWidth, 0, newWidths, 0, lineCount);
+            lineWidth = newWidths;          
+            int[] newHeights = new int[lineCount + delta + GROW];
+            System.arraycopy(lineHeight, 0, newHeights, 0, lineCount);
+            lineHeight = newHeights;
+        }
+        if (lines !is null) {
+            if (lineCount + delta > lines.length) {
+                LineInfo[] newLines = new LineInfo[lineCount + delta + GROW];
+                System.arraycopy(lines, 0, newLines, 0, lineCount);
+                lines = newLines;
+            }
+        }
+        int startIndex = startLine + replaceLineCount + 1;
+        int endIndex = startLine + newLineCount + 1;
+        System.arraycopy(lineWidth, startIndex, lineWidth, endIndex, lineCount - startIndex);
+        System.arraycopy(lineHeight, startIndex, lineHeight, endIndex, lineCount - startIndex);
+        for (int i = startLine; i < endIndex; i++) {
+            lineWidth[i] = lineHeight[i] = -1;
+        }
+        for (int i = lineCount + delta; i < lineCount; i++) {
+            lineWidth[i] = lineHeight[i] = -1;
+        }
+        if (layouts !is null) {
+            int layoutStartLine = startLine - topIndex;
+            int layoutEndLine = layoutStartLine + replaceLineCount + 1;
+            for (int i = layoutStartLine; i < layoutEndLine; i++) {
+                if (0 <= i && i < layouts.length) {
+                    if (layouts[i] !is null) layouts[i].dispose();
+                    layouts[i] = null;
+                    if (bullets !is null && bulletsIndices !is null) bullets[i] = null;
+                }
+            }
+            if (delta > 0) {
+                for (int i = layouts.length - 1; i >= layoutEndLine; i--) {
+                    if (0 <= i && i < layouts.length) {
+                        endIndex = i + delta;
+                        if (0 <= endIndex && endIndex < layouts.length) {
+                            layouts[endIndex] = layouts[i];
+                            layouts[i] = null;
+                            if (bullets !is null && bulletsIndices !is null) {
+                                bullets[endIndex] = bullets[i];
+                                bulletsIndices[endIndex] = bulletsIndices[i];
+                                bullets[i] = null;
+                            }
+                        } else {
+                            if (layouts[i] !is null) layouts[i].dispose();
+                            layouts[i] = null;
+                            if (bullets !is null && bulletsIndices !is null) bullets[i] = null;
+                        }
+                    }
+                }
+            } else if (delta < 0) {
+                for (int i = layoutEndLine; i < layouts.length; i++) {
+                    if (0 <= i && i < layouts.length) {
+                        endIndex = i + delta;
+                        if (0 <= endIndex && endIndex < layouts.length) {
+                            layouts[endIndex] = layouts[i];
+                            layouts[i] = null;
+                            if (bullets !is null && bulletsIndices !is null) {
+                                bullets[endIndex] = bullets[i];
+                                bulletsIndices[endIndex] = bulletsIndices[i];
+                                bullets[i] = null;
+                            }
+                        } else {
+                            if (layouts[i] !is null) layouts[i].dispose();
+                            layouts[i] = null;
+                            if (bullets !is null && bulletsIndices !is null) bullets[i] = null;
+                        }
+                    }
+                }
+            }
+        }
+        if (replaceLineCount !is 0 || newLineCount !is 0) {
+            int startLineOffset = content.getOffsetAtLine(startLine);
+            if (startLineOffset !is start) startLine++;
+            updateBullets(startLine, replaceLineCount, newLineCount, true);
+            if (lines !is null) {
+                startIndex = startLine + replaceLineCount;
+                endIndex = startLine + newLineCount;
+                System.arraycopy(lines, startIndex, lines, endIndex, lineCount - startIndex);
+                for (int i = startLine; i < endIndex; i++) {
+                    lines[i] = null;
+                }
+                for (int i = lineCount + delta; i < lineCount; i++) {
+                    lines[i] = null;
+                }
+            }
+        }
+        lineCount += delta;
+        if (maxWidthLineIndex !is -1 && startLine <= maxWidthLineIndex && maxWidthLineIndex <= startLine + replaceLineCount) {
+            maxWidth = 0;
+            maxWidthLineIndex = -1;
+            for (int i = 0; i < lineCount; i++) {
+                if (lineWidth[i] > maxWidth) {
+                    maxWidth = lineWidth[i];
+                    maxWidthLineIndex = i;
+                }
+            }
+        }
+    }
+}
+void updateBullets(int startLine, int replaceLineCount, int newLineCount, bool update) {
+    if (bullets is null) return;
+    if (bulletsIndices !is null) return;
+    for (int i = 0; i < bullets.length; i++) {
+        Bullet bullet = bullets[i];
+        int[] lines = bullet.removeIndices(startLine, replaceLineCount, newLineCount, update);
+        if (lines !is null) {
+            if (redrawLines is null) {
+                redrawLines = lines;
+            } else {
+                int[] newRedrawBullets = new int[redrawLines.length + lines.length];
+                System.arraycopy(redrawLines, 0, newRedrawBullets, 0, redrawLines.length);
+                System.arraycopy(lines, 0, newRedrawBullets, redrawLines.length, lines.length);
+                redrawLines = newRedrawBullets;
+            }
+        }
+    }
+    int removed = 0;
+    for (int i = 0; i < bullets.length; i++) {
+        if (bullets[i].size() is 0) removed++;
+    }
+    if (removed > 0) {
+        if (removed is bullets.length) {
+            bullets = null;
+        } else {
+            Bullet[] newBulletsList = new Bullet[bullets.length - removed];
+            for (int i = 0, j = 0; i < bullets.length; i++) {
+                Bullet bullet = bullets[i];
+                if (bullet.size() > 0) newBulletsList[j++] = bullet;
+            }
+            bullets = newBulletsList;
+        }
+    }
+}
+void updateRanges(int start, int replaceCharCount, int newCharCount) {
+    if (styleCount is 0 || (replaceCharCount is 0 && newCharCount is 0)) return;
+    if (ranges !is null) {
+        int rangeCount = styleCount << 1;
+        int modifyStart = getRangeIndex(start, -1, rangeCount);
+        if (modifyStart is rangeCount) return;
+        int end = start + replaceCharCount;
+        int modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount);
+        int offset = newCharCount - replaceCharCount;
+        if (modifyStart is modifyEnd && ranges[modifyStart] < start && end < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
+            if (newCharCount is 0) {
+                ranges[modifyStart + 1] -= replaceCharCount;
+                modifyEnd += 2;
+            } else {
+                if (rangeCount + 2 > ranges.length) {
+                    int[] newRanges = new int[ranges.length + (GROW << 1)];
+                    System.arraycopy(ranges, 0, newRanges, 0, rangeCount);
+                    ranges = newRanges;
+                    StyleRange[] newStyles = new StyleRange[styles.length + GROW];
+                    System.arraycopy(styles, 0, newStyles, 0, styleCount);
+                    styles = newStyles;
+                }
+                System.arraycopy(ranges, modifyStart + 2, ranges, modifyStart + 4, rangeCount - (modifyStart + 2));
+                System.arraycopy(styles, (modifyStart + 2) >> 1, styles, (modifyStart + 4) >> 1, styleCount - ((modifyStart + 2) >> 1));
+                ranges[modifyStart + 3] = ranges[modifyStart] + ranges[modifyStart + 1] - end;
+                ranges[modifyStart + 2] = start + newCharCount;
+                ranges[modifyStart + 1] = start - ranges[modifyStart];
+                styles[(modifyStart >> 1) + 1] = styles[modifyStart >> 1]; 
+                rangeCount += 2;
+                styleCount++;
+                modifyEnd += 4;
+            }
+            if (offset !is 0) {
+                for (int i = modifyEnd; i < rangeCount; i += 2) {
+                    ranges[i] += offset;
+                }
+            }
+        } else {
+            if (ranges[modifyStart] < start && start < ranges[modifyStart] + ranges[modifyStart + 1]) {
+                ranges[modifyStart + 1] = start - ranges[modifyStart];
+                modifyStart += 2;
+            }
+            if (modifyEnd < rangeCount && ranges[modifyEnd] < end && end < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
+                ranges[modifyEnd + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - end;
+                ranges[modifyEnd] = end;
+            }
+            if (offset !is 0) {
+                for (int i = modifyEnd; i < rangeCount; i += 2) {
+                    ranges[i] += offset;
+                }
+            }
+            System.arraycopy(ranges, modifyEnd, ranges, modifyStart, rangeCount - modifyEnd);
+            System.arraycopy(styles, modifyEnd >> 1, styles, modifyStart >> 1, styleCount - (modifyEnd >> 1));
+            styleCount -= (modifyEnd - modifyStart) >> 1;
+        }
+    } else {
+        int modifyStart = getRangeIndex(start, -1, styleCount);
+        if (modifyStart is styleCount) return;
+        int end = start + replaceCharCount;
+        int modifyEnd = getRangeIndex(end, modifyStart - 1, styleCount);
+        int offset = newCharCount - replaceCharCount;
+        if (modifyStart is modifyEnd && styles[modifyStart].start < start && end < styles[modifyEnd].start + styles[modifyEnd].length) {
+            if (newCharCount is 0) {
+                styles[modifyStart].length -= replaceCharCount;
+                modifyEnd++;
+            } else {
+                if (styleCount + 1 > styles.length) {
+                    StyleRange[] newStyles = new StyleRange[styles.length + GROW];
+                    System.arraycopy(styles, 0, newStyles, 0, styleCount);
+                    styles = newStyles;
+                }
+                System.arraycopy(styles, modifyStart + 1, styles, modifyStart + 2, styleCount - (modifyStart + 1));
+                styles[modifyStart + 1] = (StyleRange)styles[modifyStart].clone();
+                styles[modifyStart + 1].length = styles[modifyStart].start + styles[modifyStart].length - end;
+                styles[modifyStart + 1].start = start + newCharCount;
+                styles[modifyStart].length = start - styles[modifyStart].start;
+                styleCount++;
+                modifyEnd += 2;
+            }
+            if (offset !is 0) {
+                for (int i = modifyEnd; i < styleCount; i++) {
+                    styles[i].start += offset;
+                }
+            }
+        } else {
+            if (styles[modifyStart].start < start && start < styles[modifyStart].start + styles[modifyStart].length) {
+                styles[modifyStart].length = start - styles[modifyStart].start;
+                modifyStart++;
+            }
+            if (modifyEnd < styleCount && styles[modifyEnd].start < end && end < styles[modifyEnd].start + styles[modifyEnd].length) {
+                styles[modifyEnd].length = styles[modifyEnd].start + styles[modifyEnd].length - end;
+                styles[modifyEnd].start = end;
+            }
+            if (offset !is 0) {
+                for (int i = modifyEnd; i < styleCount; i++) {
+                    styles[i].start += offset;
+                }
+            }
+            System.arraycopy(styles, modifyEnd, styles, modifyStart, styleCount - modifyEnd);
+            styleCount -= modifyEnd - modifyStart;
+        }
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TableCursor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,757 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+import dwt.events.*;
+
+/**
+ * A TableCursor provides a way for the user to navigate around a Table
+ * using the keyboard.  It also provides a mechanism for selecting an
+ * individual cell in a table.
+ * 
+ * <p> Here is an example of using a TableCursor to navigate to a cell and then edit it.
+ * 
+ * <code><pre>
+ *  public static void main(String[] args) {
+ *      Display display = new Display();
+ *      Shell shell = new Shell(display);
+ *      shell.setLayout(new GridLayout());
+ *  
+ *      // create a a table with 3 columns and fill with data
+ *      final Table table = new Table(shell, DWT.BORDER | DWT.MULTI | DWT.FULL_SELECTION);
+ *      table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ *      TableColumn column1 = new TableColumn(table, DWT.NONE);
+ *      TableColumn column2 = new TableColumn(table, DWT.NONE);
+ *      TableColumn column3 = new TableColumn(table, DWT.NONE);
+ *      for (int i = 0; i &lt; 100; i++) {
+ *          TableItem item = new TableItem(table, DWT.NONE);
+ *          item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"});
+ *      }
+ *      column1.pack();
+ *      column2.pack();
+ *      column3.pack();
+ *  
+ *      // create a TableCursor to navigate around the table
+ *      final TableCursor cursor = new TableCursor(table, DWT.NONE);
+ *      // create an editor to edit the cell when the user hits "ENTER" 
+ *      // while over a cell in the table
+ *      final ControlEditor editor = new ControlEditor(cursor);
+ *      editor.grabHorizontal = true;
+ *      editor.grabVertical = true;
+ *  
+ *      cursor.addSelectionListener(new SelectionAdapter() {
+ *          // when the TableEditor is over a cell, select the corresponding row in 
+ *          // the table
+ *          public void widgetSelected(SelectionEvent e) {
+ *              table.setSelection(new TableItem[] {cursor.getRow()});
+ *          }
+ *          // when the user hits "ENTER" in the TableCursor, pop up a text editor so that 
+ *          // they can change the text of the cell
+ *          public void widgetDefaultSelected(SelectionEvent e){
+ *              final Text text = new Text(cursor, DWT.NONE);
+ *              TableItem row = cursor.getRow();
+ *              int column = cursor.getColumn();
+ *              text.setText(row.getText(column));
+ *              text.addKeyListener(new KeyAdapter() {
+ *                  public void keyPressed(KeyEvent e) {
+ *                      // close the text editor and copy the data over 
+ *                      // when the user hits "ENTER"
+ *                      if (e.character is DWT.CR) {
+ *                          TableItem row = cursor.getRow();
+ *                          int column = cursor.getColumn();
+ *                          row.setText(column, text.getText());
+ *                          text.dispose();
+ *                      }
+ *                      // close the text editor when the user hits "ESC"
+ *                      if (e.character is DWT.ESC) {
+ *                          text.dispose();
+ *                      }
+ *                  }
+ *              });
+ *              editor.setEditor(text);
+ *              text.setFocus();
+ *          }
+ *      });
+ *      // Hide the TableCursor when the user hits the "MOD1" or "MOD2" key.
+ *      // This allows the user to select multiple items in the table.
+ *      cursor.addKeyListener(new KeyAdapter() {
+ *          public void keyPressed(KeyEvent e) {
+ *              if (e.keyCode is DWT.MOD1 || 
+ *                  e.keyCode is DWT.MOD2 || 
+ *                  (e.stateMask & DWT.MOD1) !is 0 || 
+ *                  (e.stateMask & DWT.MOD2) !is 0) {
+ *                  cursor.setVisible(false);
+ *              }
+ *          }
+ *      });
+ *      // Show the TableCursor when the user releases the "MOD2" or "MOD1" key.
+ *      // This signals the end of the multiple selection task.
+ *      table.addKeyListener(new KeyAdapter() {
+ *          public void keyReleased(KeyEvent e) {
+ *              if (e.keyCode is DWT.MOD1 && (e.stateMask & DWT.MOD2) !is 0) return;
+ *              if (e.keyCode is DWT.MOD2 && (e.stateMask & DWT.MOD1) !is 0) return;
+ *              if (e.keyCode !is DWT.MOD1 && (e.stateMask & DWT.MOD1) !is 0) return;
+ *              if (e.keyCode !is DWT.MOD2 && (e.stateMask & DWT.MOD2) !is 0) return;
+ *          
+ *              TableItem[] selection = table.getSelection();
+ *              TableItem row = (selection.length is 0) ? table.getItem(table.getTopIndex()) : selection[0];
+ *              table.showItem(row);
+ *              cursor.setSelection(row, 0);
+ *              cursor.setVisible(true);
+ *              cursor.setFocus();
+ *          }
+ *      });
+ *  
+ *      shell.open();
+ *      while (!shell.isDisposed()) {
+ *          if (!display.readAndDispatch())
+ *              display.sleep();
+ *      }
+ *      display.dispose();
+ *  }
+ * </pre></code>
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * 
+ * @since 2.0
+ * 
+ */
+public class TableCursor : Canvas {
+    Table table;
+    TableItem row = null;
+    TableColumn column = null;
+    Listener tableListener, resizeListener, disposeItemListener, disposeColumnListener;
+
+    Color background = null;
+    Color foreground = null;
+
+    // By default, invert the list selection colors
+    static final int BACKGROUND = DWT.COLOR_LIST_SELECTION_TEXT;
+    static final int FOREGROUND = DWT.COLOR_LIST_SELECTION;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * table and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a Table control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#BORDER
+ * @see Widget#checkSubclass()
+ * @see Widget#getStyle()
+ */
+public TableCursor(Table parent, int style) {
+    super(parent, style);
+    table = parent;
+    setBackground(null);
+    setForeground(null);
+    
+    Listener listener = new Listener() {
+        public void handleEvent(Event event) {
+            switch (event.type) {
+                case DWT.Dispose :
+                    dispose(event);
+                    break;
+                case DWT.FocusIn :
+                case DWT.FocusOut :
+                    redraw();
+                    break;
+                case DWT.KeyDown :
+                    keyDown(event);
+                    break;
+                case DWT.Paint :
+                    paint(event);
+                    break;
+                case DWT.Traverse : {
+                    event.doit = true;
+                    switch (event.detail) {
+                        case DWT.TRAVERSE_ARROW_NEXT :
+                        case DWT.TRAVERSE_ARROW_PREVIOUS :
+                        case DWT.TRAVERSE_RETURN :
+                            event.doit = false;
+                            break;
+                    }
+                    break;
+                }
+            }
+        }
+    };
+    int[] events = new int[] {DWT.Dispose, DWT.FocusIn, DWT.FocusOut, DWT.KeyDown, DWT.Paint, DWT.Traverse};
+    for (int i = 0; i < events.length; i++) {
+        addListener(events[i], listener);
+    }
+
+    tableListener = new Listener() {
+        public void handleEvent(Event event) {
+            switch (event.type) {
+                case DWT.MouseDown :
+                    tableMouseDown(event);
+                    break;
+                case DWT.FocusIn :
+                    tableFocusIn(event);
+                    break;
+            }
+        }
+    };
+    table.addListener(DWT.FocusIn, tableListener);
+    table.addListener(DWT.MouseDown, tableListener);
+
+    disposeItemListener = new Listener() {
+        public void handleEvent(Event event) {
+            unhookRowColumnListeners();
+            row = null;
+            column = null;
+            _resize();
+        }
+    };
+    disposeColumnListener = new Listener() {
+        public void handleEvent(Event event) {
+            unhookRowColumnListeners();
+            row = null;
+            column = null;
+            _resize();
+        }
+    };
+    resizeListener = new Listener() {
+        public void handleEvent(Event event) {
+            _resize();
+        }
+    };
+    ScrollBar hBar = table.getHorizontalBar();
+    if (hBar !is null) {
+        hBar.addListener(DWT.Selection, resizeListener);
+    }
+    ScrollBar vBar = table.getVerticalBar();
+    if (vBar !is null) {
+        vBar.addListener(DWT.Selection, resizeListener);
+    }
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has <code>DWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>DWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see SelectionEvent
+ * @see #removeSelectionListener(SelectionListener)
+ * 
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null)
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection, typedListener);
+    addListener(DWT.DefaultSelection, typedListener);
+}
+
+void dispose(Event event) {
+    table.removeListener(DWT.FocusIn, tableListener);
+    table.removeListener(DWT.MouseDown, tableListener);
+    unhookRowColumnListeners();
+    ScrollBar hBar = table.getHorizontalBar();
+    if (hBar !is null) {
+        hBar.removeListener(DWT.Selection, resizeListener);
+    }
+    ScrollBar vBar = table.getVerticalBar();
+    if (vBar !is null) {
+        vBar.removeListener(DWT.Selection, resizeListener);
+    }
+}
+
+void keyDown(Event event) {
+    if (row is null) return;
+    switch (event.character) {
+        case DWT.CR :
+            notifyListeners(DWT.DefaultSelection, new Event());
+            return;
+    }
+    int rowIndex = table.indexOf(row);
+    int columnIndex = column is null ? 0 : table.indexOf(column);
+    switch (event.keyCode) {
+        case DWT.ARROW_UP :
+            setRowColumn(Math.max(0, rowIndex - 1), columnIndex, true);
+            break;
+        case DWT.ARROW_DOWN :
+            setRowColumn(Math.min(rowIndex + 1, table.getItemCount() - 1), columnIndex, true);
+            break;
+        case DWT.ARROW_LEFT :
+        case DWT.ARROW_RIGHT :
+            {   
+                int columnCount = table.getColumnCount();
+                if (columnCount is 0) break;
+                int[] order = table.getColumnOrder();
+                int index = 0;
+                while (index < order.length) {
+                    if (order[index] is columnIndex) break;
+                    index++;
+                }
+                if (index is order.length) index = 0;
+                int leadKey = (getStyle() & DWT.RIGHT_TO_LEFT) !is 0 ? DWT.ARROW_RIGHT : DWT.ARROW_LEFT;
+                if (event.keyCode is leadKey) {
+                   setRowColumn(rowIndex, order[Math.max(0, index - 1)], true);
+                } else {
+                   setRowColumn(rowIndex, order[Math.min(columnCount - 1, index + 1)], true);
+                }
+                break;
+            }
+        case DWT.HOME :
+            setRowColumn(0, columnIndex, true);
+            break;
+        case DWT.END :
+            {
+                int i = table.getItemCount() - 1;
+                setRowColumn(i, columnIndex, true);
+                break;
+            }
+        case DWT.PAGE_UP :
+            {
+                int index = table.getTopIndex();
+                if (index is rowIndex) {
+                    Rectangle rect = table.getClientArea();
+                    TableItem item = table.getItem(index);
+                    Rectangle itemRect = item.getBounds(0);
+                    rect.height -= itemRect.y;
+                    int height = table.getItemHeight();
+                    int page = Math.max(1, rect.height / height);
+                    index = Math.max(0, index - page + 1);
+                }
+                setRowColumn(index, columnIndex, true);
+                break;
+            }
+        case DWT.PAGE_DOWN :
+            {
+                int index = table.getTopIndex();
+                Rectangle rect = table.getClientArea();
+                TableItem item = table.getItem(index);
+                Rectangle itemRect = item.getBounds(0);
+                rect.height -= itemRect.y;
+                int height = table.getItemHeight();
+                int page = Math.max(1, rect.height / height);
+                int end = table.getItemCount() - 1;
+                index = Math.min(end, index + page - 1);
+                if (index is rowIndex) {
+                    index = Math.min(end, index + page - 1);
+                }
+                setRowColumn(index, columnIndex, true);
+                break;
+            }
+    }
+}
+
+void paint(Event event) {
+    if (row is null) return;
+    int columnIndex = column is null ? 0 : table.indexOf(column);
+    GC gc = event.gc;
+    Display display = getDisplay();
+    gc.setBackground(getBackground());
+    gc.setForeground(getForeground());
+    gc.fillRectangle(event.x, event.y, event.width, event.height);
+    int x = 0;
+    Point size = getSize();
+    Image image = row.getImage(columnIndex);
+    if (image !is null) {
+        Rectangle imageSize = image.getBounds();
+        int imageY = (size.y - imageSize.height) / 2;
+        gc.drawImage(image, x, imageY);
+        x += imageSize.width;
+    }
+    String text = row.getText(columnIndex);
+    if (text.length() > 0) {
+        Rectangle bounds = row.getBounds(columnIndex);
+        Point extent = gc.StringExtent(text);
+        // Temporary code - need a better way to determine table trim
+        String platform = DWT.getPlatform();
+        if ("win32".opEquals(platform)) { //$NON-NLS-1$
+            if (table.getColumnCount() is 0 || columnIndex is 0) {
+                x += 2; 
+            } else {
+                int alignmnent = column.getAlignment();
+                switch (alignmnent) {
+                    case DWT.LEFT:
+                        x += 6;
+                        break;
+                    case DWT.RIGHT:
+                        x = bounds.width - extent.x - 6;
+                        break;
+                    case DWT.CENTER:
+                        x += (bounds.width - x - extent.x) / 2;
+                        break;
+                }
+            }
+        }  else {
+            if (table.getColumnCount() is 0) {
+                x += 5; 
+            } else {
+                int alignmnent = column.getAlignment();
+                switch (alignmnent) {
+                    case DWT.LEFT:
+                        x += 5;
+                        break;
+                    case DWT.RIGHT:
+                        x = bounds.width- extent.x - 2;
+                        break;
+                    case DWT.CENTER:
+                        x += (bounds.width - x - extent.x) / 2 + 2;
+                        break;
+                }
+            }
+        }
+        int textY = (size.y - extent.y) / 2;
+        gc.drawString(text, x, textY);
+    }
+    if (isFocusControl()) {
+        gc.setBackground(display.getSystemColor(DWT.COLOR_BLACK));
+        gc.setForeground(display.getSystemColor(DWT.COLOR_WHITE));
+        gc.drawFocus(0, 0, size.x, size.y);
+    }
+}
+
+void tableFocusIn(Event event) {
+    if (isDisposed()) return;
+    if (isVisible()) {
+        if (row is null && column is null) return;
+        setFocus();
+    }
+}
+
+void tableMouseDown(Event event) {
+    if (isDisposed() || !isVisible()) return;
+    Point pt = new Point(event.x, event.y);
+    int lineWidth = table.getLinesVisible() ? table.getGridLineWidth() : 0;
+    TableItem item = table.getItem(pt);
+    if ((table.getStyle() & DWT.FULL_SELECTION) !is 0) {
+        if (item is null) return;
+    } else {
+        int start = item !is null ? table.indexOf(item) : table.getTopIndex();
+        int end = table.getItemCount();
+        Rectangle clientRect = table.getClientArea();
+        for (int i = start; i < end; i++) {
+            TableItem nextItem = table.getItem(i);
+            Rectangle rect = nextItem.getBounds(0);
+            if (pt.y >= rect.y && pt.y < rect.y + rect.height + lineWidth) {
+                item = nextItem;
+                break;
+            }
+            if (rect.y > clientRect.y + clientRect.height)  return;
+        }
+        if (item is null) return;
+    }
+    TableColumn newColumn = null;
+    int columnCount = table.getColumnCount();
+    if (columnCount is 0) {
+        if ((table.getStyle() & DWT.FULL_SELECTION) is 0) {
+            Rectangle rect = item.getBounds(0);
+            rect.width += lineWidth;
+            rect.height += lineWidth;
+            if (!rect.contains(pt)) return;
+        }
+    } else {
+        for (int i = 0; i < columnCount; i++) {
+            Rectangle rect = item.getBounds(i);
+            rect.width += lineWidth;
+            rect.height += lineWidth;
+            if (rect.contains(pt)) {
+                newColumn = table.getColumn(i);
+                break;
+            }
+        }
+        if (newColumn is null) {
+            if ((table.getStyle() & DWT.FULL_SELECTION) is 0) return;
+            newColumn = table.getColumn(0);
+        }
+    }
+    setRowColumn(item, newColumn, true);
+    setFocus();
+    return;
+}
+void setRowColumn(int row, int column, bool notify) {
+    TableItem item = row is -1 ? null : table.getItem(row);
+    TableColumn col = column is -1 || table.getColumnCount() is 0 ? null : table.getColumn(column);
+    setRowColumn(item, col, notify);
+}
+void setRowColumn(TableItem row, TableColumn column, bool notify) {
+    if (this.row is row && this.column is column) {
+        return;
+    }
+    if (this.row !is null && this.row !is row) {
+        this.row.removeListener(DWT.Dispose, disposeItemListener);
+        this.row = null;
+    }
+    if (this.column !is null && this.column !is column) {
+        this.column.removeListener(DWT.Dispose, disposeColumnListener);
+        this.column.removeListener(DWT.Move, resizeListener);
+        this.column.removeListener(DWT.Resize, resizeListener);
+        this.column = null;
+    }
+    if (row !is null) {
+        if (this.row !is row) {
+            this.row = row;
+            row.addListener(DWT.Dispose, disposeItemListener);
+            table.showItem(row);
+        }
+        if (this.column !is column && column !is null) {
+            this.column = column;
+            column.addListener(DWT.Dispose, disposeColumnListener);
+            column.addListener(DWT.Move, resizeListener);
+            column.addListener(DWT.Resize, resizeListener);
+            table.showColumn(column);
+        }
+        int columnIndex = column is null ? 0 : table.indexOf(column);
+        setBounds(row.getBounds(columnIndex));
+        redraw();
+        if (notify) {
+            notifyListeners(DWT.Selection, new Event());
+        }
+    }
+}
+
+public void setVisible(bool visible) {
+    checkWidget();
+    if (visible) _resize();
+    super.setVisible(visible);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener(SelectionListener)
+ * 
+ * @since 3.0
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) {
+        DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    }
+    removeListener(DWT.Selection, listener);
+    removeListener(DWT.DefaultSelection, listener); 
+}
+
+void _resize() {
+    if (row is null) {
+        setBounds(-200, -200, 0, 0);
+    } else {
+        int columnIndex = column is null ? 0 : table.indexOf(column);
+        setBounds(row.getBounds(columnIndex));
+    }
+}
+/**
+ * Returns the column over which the TableCursor is positioned.
+ *
+ * @return the column for the current position
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getColumn() {
+    checkWidget();
+    return column is null ? 0 : table.indexOf(column);
+}
+/**
+ * Returns the background color that the receiver will use to draw.
+ *
+ * @return the receiver's background color
+ */
+public Color getBackground() {
+    checkWidget();
+    if (background is null) {
+        return getDisplay().getSystemColor(BACKGROUND);
+    }
+    return background;
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ */
+public Color getForeground() {
+    checkWidget();
+    if (foreground is null) {
+        return getDisplay().getSystemColor(FOREGROUND);
+    }
+    return foreground;
+}
+/**
+ * Returns the row over which the TableCursor is positioned.
+ *
+ * @return the item for the current position
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getRow() {
+    checkWidget();
+    return row;
+}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * For example, on Windows the background of a Button cannot be changed.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground (Color color) {
+    background = color;
+    super.setBackground(getBackground());
+    redraw();
+}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setForeground (Color color) {
+    foreground = color;
+    super.setForeground(getForeground());
+    redraw();
+}
+/**
+ * Positions the TableCursor over the cell at the given row and column in the parent table. 
+ *
+ * @param row the index of the row for the cell to select
+ * @param column the index of column for the cell to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void setSelection(int row, int column) {
+    checkWidget();
+    int columnCount = table.getColumnCount();
+    int maxColumnIndex =  columnCount is 0 ? 0 : columnCount - 1;
+    if (row < 0
+        || row >= table.getItemCount()
+        || column < 0
+        || column > maxColumnIndex)
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    setRowColumn(row, column, false);
+}
+/**
+ * Positions the TableCursor over the cell at the given row and column in the parent table. 
+ *
+ * @param row the TableItem of the row for the cell to select
+ * @param column the index of column for the cell to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void setSelection(TableItem row, int column) {
+    checkWidget();
+    int columnCount = table.getColumnCount();
+    int maxColumnIndex =  columnCount is 0 ? 0 : columnCount - 1;
+    if (row is null
+        || row.isDisposed()
+        || column < 0
+        || column > maxColumnIndex)
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    setRowColumn(table.indexOf(row), column, false);
+}
+void unhookRowColumnListeners() {
+    if (column !is null) {
+        column.removeListener(DWT.Dispose, disposeColumnListener);
+        column.removeListener(DWT.Move, resizeListener);
+        column.removeListener(DWT.Resize, resizeListener);
+        column = null;
+    }
+    if (row !is null) {
+        row.removeListener(DWT.Dispose, disposeItemListener);
+        row = null;
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TableEditor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.*;
+import dwt.events.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+*
+* A TableEditor is a manager for a Control that appears above a cell in a Table and tracks with the
+* moving and resizing of that cell.  It can be used to display a text widget above a cell
+* in a Table so that the user can edit the contents of that cell.  It can also be used to display
+* a button that can launch a dialog for modifying the contents of the associated cell.
+*
+* <p> Here is an example of using a TableEditor:
+* <code><pre>
+*   final Table table = new Table(shell, DWT.FULL_SELECTION | DWT.HIDE_SELECTION);
+*   TableColumn column1 = new TableColumn(table, DWT.NONE);
+*   TableColumn column2 = new TableColumn(table, DWT.NONE);
+*   for (int i = 0; i &lt; 10; i++) {
+*       TableItem item = new TableItem(table, DWT.NONE);
+*       item.setText(new String[] {"item " + i, "edit this value"});
+*   }
+*   column1.pack();
+*   column2.pack();
+*   
+*   final TableEditor editor = new TableEditor(table);
+*   //The editor must have the same size as the cell and must
+*   //not be any smaller than 50 pixels.
+*   editor.horizontalAlignment = DWT.LEFT;
+*   editor.grabHorizontal = true;
+*   editor.minimumWidth = 50;
+*   // editing the second column
+*   final int EDITABLECOLUMN = 1;
+*   
+*   table.addSelectionListener(new SelectionAdapter() {
+*       public void widgetSelected(SelectionEvent e) {
+*           // Clean up any previous editor control
+*           Control oldEditor = editor.getEditor();
+*           if (oldEditor !is null) oldEditor.dispose();
+*   
+*           // Identify the selected row
+*           TableItem item = (TableItem)e.item;
+*           if (item is null) return;
+*   
+*           // The control that will be the editor must be a child of the Table
+*           Text newEditor = new Text(table, DWT.NONE);
+*           newEditor.setText(item.getText(EDITABLECOLUMN));
+*           newEditor.addModifyListener(new ModifyListener() {
+*               public void modifyText(ModifyEvent e) {
+*                   Text text = (Text)editor.getEditor();
+*                   editor.getItem().setText(EDITABLECOLUMN, text.getText());
+*               }
+*           });
+*           newEditor.selectAll();
+*           newEditor.setFocus();
+*           editor.setEditor(newEditor, item, EDITABLECOLUMN);
+*       }
+*   });
+* </pre></code>
+*/
+public class TableEditor : ControlEditor {
+    Table table;
+    TableItem item;
+    int column = -1;
+    ControlListener columnListener;
+    Runnable timer;
+    static final int TIMEOUT = 1500;
+/**
+* Creates a TableEditor for the specified Table.
+*
+* @param table the Table Control above which this editor will be displayed
+*
+*/
+public TableEditor (Table table) {
+    super(table);
+    this.table = table;
+    
+    columnListener = new ControlListener() {
+        public void controlMoved(ControlEvent e){
+            layout ();
+        }
+        public void controlResized(ControlEvent e){
+            layout ();
+        }
+    };
+    timer = new Runnable () {
+        public void run() {
+            layout ();
+        }
+    };
+    
+    // To be consistent with older versions of DWT, grabVertical defaults to true
+    grabVertical = true;
+}
+Rectangle computeBounds () {
+    if (item is null || column is -1 || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+    Rectangle cell = item.getBounds(column);
+    Rectangle rect = item.getImageBounds(column);
+    cell.x = rect.x + rect.width;
+    cell.width -= rect.width;
+    Rectangle area = table.getClientArea();
+    if (cell.x < area.x + area.width) {
+        if (cell.x + cell.width > area.x + area.width) {
+            cell.width = area.x + area.width - cell.x;
+        }
+    }
+    Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+    if (grabHorizontal) {
+        editorRect.width = Math.max(cell.width, minimumWidth);
+    }
+    
+    if (grabVertical) {
+        editorRect.height = Math.max(cell.height, minimumHeight);
+    }
+    
+    if (horizontalAlignment is DWT.RIGHT) {
+        editorRect.x += cell.width - editorRect.width;
+    } else if (horizontalAlignment is DWT.LEFT) {
+        // do nothing - cell.x is the right answer
+    } else { // default is CENTER
+        editorRect.x += (cell.width - editorRect.width)/2;
+    }
+    
+    if (verticalAlignment is DWT.BOTTOM) {
+        editorRect.y += cell.height - editorRect.height;
+    } else if (verticalAlignment is DWT.TOP) {
+        // do nothing - cell.y is the right answer
+    } else { // default is CENTER
+        editorRect.y += (cell.height - editorRect.height)/2;
+    }
+    return editorRect;
+}
+/**
+ * Removes all associations between the TableEditor and the cell in the table.  The
+ * Table and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+    if (table !is null && !table.isDisposed()) {
+        if (this.column > -1 && this.column < table.getColumnCount()){
+            TableColumn tableColumn = table.getColumn(this.column);
+            tableColumn.removeControlListener(columnListener);
+        }
+    }
+    columnListener = null;
+    table = null;
+    item = null;
+    column = -1;
+    timer = null;
+    super.dispose();
+}
+/**
+* Returns the zero based index of the column of the cell being tracked by this editor.
+*
+* @return the zero based index of the column of the cell being tracked by this editor
+*/
+public int getColumn () {
+    return column;
+}
+/**
+* Returns the TableItem for the row of the cell being tracked by this editor.
+*
+* @return the TableItem for the row of the cell being tracked by this editor
+*/
+public TableItem getItem () {
+    return item;
+}
+void resize () {
+    layout();
+    /*
+     * On some platforms, the table scrolls when an item that
+     * is partially visible at the bottom of the table is
+     * selected.  Ensure that the correct row is edited by
+     * laying out one more time in a timerExec().
+     */
+    if (table !is null) {
+        Display display = table.getDisplay();
+        display.timerExec(-1, timer);
+        display.timerExec(TIMEOUT, timer);
+    }
+}
+/**
+* Sets the zero based index of the column of the cell being tracked by this editor.
+* 
+* @param column the zero based index of the column of the cell being tracked by this editor 
+*/
+public void setColumn(int column) {
+    int columnCount = table.getColumnCount();
+    // Separately handle the case where the table has no TableColumns.
+    // In this situation, there is a single default column.
+    if (columnCount is 0) {
+        this.column = (column is 0) ? 0 : -1;
+        resize();
+        return;
+    }
+    if (this.column > -1 && this.column < columnCount){
+        TableColumn tableColumn = table.getColumn(this.column);
+        tableColumn.removeControlListener(columnListener);
+        this.column = -1;
+    }
+
+    if (column < 0  || column >= table.getColumnCount()) return;    
+        
+    this.column = column;
+    TableColumn tableColumn = table.getColumn(this.column);
+    tableColumn.addControlListener(columnListener);
+    resize();
+}
+public void setItem (TableItem item) {  
+    this.item = item;
+    resize();
+}
+public void setEditor (Control editor) {
+    super.setEditor(editor);
+    resize();
+}
+/**
+* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
+* specified in the TableEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TableItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TableItem item, int column) {
+    setItem(item);
+    setColumn(column);
+    setEditor(editor);
+}
+public void layout () {
+    if (table is null || table.isDisposed()) return;
+    if (item is null || item.isDisposed()) return;
+    int columnCount = table.getColumnCount();
+    if (columnCount is 0 && column !is 0) return;
+    if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
+    super.layout();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TableTree.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,814 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.*;
+import dwt.events.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/** 
+ * A TableTree is a selectable user interface object
+ * that displays a hierarchy of items, and issues
+ * notification when an item is selected.
+ * A TableTree may be single or multi select.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableTreeItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ *  <dt><b>Styles:</b> <dd> SINGLE, MULTI, CHECK, FULL_SELECTION
+ *  <dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p>
+ * 
+ * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn
+ */
+public class TableTree : Composite {
+    Table table;
+    TableTreeItem[] items = EMPTY_ITEMS;
+    Image plusImage, minusImage, sizeImage;
+
+    /*
+    * TableTreeItems are not treated as children but rather as items.
+    * When the TableTree is disposed, all children are disposed because 
+    * TableTree inherits this behaviour from Composite.  The items
+    * must be disposed separately.  Because TableTree is not part of
+    * the dwt.widgets module, the method releaseWidget can 
+    * not be overridden (this is how items are disposed of in Table and Tree).
+    * Instead, the items are disposed of in response to the dispose event on the
+    * TableTree.  The "inDispose" flag is used to distinguish between disposing
+    * one TableTreeItem (e.g. when removing an entry from the TableTree) and 
+    * disposing the entire TableTree.
+    */
+    bool inDispose = false;
+    
+    static final TableTreeItem[] EMPTY_ITEMS = new TableTreeItem [0];   
+    static final String[] EMPTY_TEXTS = new String [0]; 
+    static final Image[] EMPTY_IMAGES = new Image [0];
+    static final String ITEMID = "TableTreeItemID"; //$NON-NLS-1$
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT#SINGLE
+ * @see DWT#MULTI
+ * @see DWT#CHECK
+ * @see DWT#FULL_SELECTION
+ * @see #getStyle
+ */
+public TableTree(Composite parent, int style) {
+    super(parent, checkStyle (style));
+    table = new Table(this, style);
+    Listener tableListener = new Listener() {
+        public void handleEvent(Event e) {
+            switch (e.type) {
+            case DWT.MouseDown: onMouseDown(e); break;
+            case DWT.Selection: onSelection(e); break;
+            case DWT.DefaultSelection: onSelection(e); break;
+            case DWT.KeyDown: onKeyDown(e); break;
+            }
+        }
+    };
+    int[] tableEvents = new int[]{DWT.MouseDown, 
+                                   DWT.Selection, 
+                                   DWT.DefaultSelection, 
+                                   DWT.KeyDown};
+    for (int i = 0; i < tableEvents.length; i++) {
+        table.addListener(tableEvents[i], tableListener);
+    }
+    
+    Listener listener = new Listener() {
+        public void handleEvent(Event e) {
+            switch (e.type) {
+            case DWT.Dispose: onDispose(e); break;
+            case DWT.Resize:  onResize(e); break;
+            case DWT.FocusIn: onFocusIn(e); break;
+            }
+        }
+    };
+    int[] events = new int[]{DWT.Dispose, 
+                              DWT.Resize, 
+                              DWT.FocusIn};
+    for (int i = 0; i < events.length; i++) {
+        addListener(events[i], listener);
+    }                         
+}
+
+int addItem(TableTreeItem item, int index) {
+    if (index < 0 || index > items.length) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    TableTreeItem[] newItems = new TableTreeItem[items.length + 1];
+    System.arraycopy(items, 0, newItems, 0, index);
+    newItems[index] = item;
+    System.arraycopy(items, index, newItems, index + 1, items.length - index); 
+    items = newItems;
+
+    /* Return the index in the table where this table should be inserted */
+    if (index is items.length - 1 ) 
+        return table.getItemCount();
+    else 
+        return table.indexOf(items[index+1].tableItem);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has <code>DWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>DWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>TreeListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #removeTreeListener
+ */
+public void addTreeListener(TreeListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Expand, typedListener);
+    addListener (DWT.Collapse, typedListener);
+}
+private static int checkStyle (int style) {
+    int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT; 
+    style = style & mask;
+    return style;
+} 
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    return table.computeSize (wHint, hHint, changed);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+    checkWidget();
+    return table.computeTrim(x, y, width, height);
+}
+
+/**
+ * Deselects all items.
+ * <p>
+ * If an item is selected, it is deselected.
+ * If an item is not selected, it remains unselected.
+ *
+ * @exception DWTException <ul>
+ *  <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *  <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void deselectAll () {
+    checkWidget();
+    table.deselectAll();
+}
+
+/* Expand upward from the specified leaf item. */
+void expandItem (TableTreeItem item) {
+    if (item is null) return;
+    expandItem(item.parentItem);
+    if (!item.getVisible()) item.setVisible(true);
+    if ( !item.expanded && item.items.length > 0) {
+        item.setExpanded(true);
+        Event event = new Event();
+        event.item = item;
+        notifyListeners(DWT.Expand, event);
+    }
+}
+public Color getBackground () {
+    // This method must be overridden otherwise, in a TableTree in which the first
+    // item has no sub items, a grey (Widget background colour) square will appear in
+    // the first column of the first item.
+    // It is not possible in the constructor to set the background of the TableTree
+    // to be the same as the background of the Table because this interferes with 
+    // the TableTree adapting to changes in the System color settings.
+    return table.getBackground();
+}
+public Rectangle getClientArea () {
+    return table.getClientArea();
+}
+public Color getForeground () {
+    return table.getForeground();
+}
+public Font getFont () {
+    return table.getFont();
+}
+/**
+ * Gets the number of items.
+ * <p>
+ * @return the number of items in the widget
+ */
+public int getItemCount () {
+    //checkWidget();
+    return items.length;
+}
+
+/**
+ * Gets the height of one item.
+ * <p>
+ * This operation will fail if the height of
+ * one item could not be queried from the OS.
+ *
+ * @return the height of one item in the widget
+ *
+ * @exception DWTException <ul>
+ *  <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *  <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public int getItemHeight () {
+    checkWidget();
+    return table.getItemHeight();
+}
+
+/**
+ * Gets the items.
+ * <p>
+ * @return the items in the widget
+ */
+public TableTreeItem [] getItems () {
+    //checkWidget();
+    TableTreeItem[] newItems = new TableTreeItem[items.length];
+    System.arraycopy(items, 0, newItems, 0, items.length);
+    return newItems;
+}
+
+/**
+ * Gets the selected items.
+ * <p>
+ * This operation will fail if the selected
+ * items cannot be queried from the OS.
+ *
+ * @return the selected items in the widget
+ *
+ * @exception DWTException <ul>
+ *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *  </ul>
+ */
+public TableTreeItem [] getSelection () {
+    checkWidget();
+    TableItem[] selection = table.getSelection();
+    TableTreeItem [] result = new TableTreeItem[selection.length];
+    for (int i = 0; i < selection.length; i++){
+        result[i] = (TableTreeItem) selection[i].getData(ITEMID);
+    }
+    return result;
+}
+
+/**
+ * Gets the number of selected items.
+ * <p>
+ * This operation will fail if the number of selected
+ * items cannot be queried from the OS.
+ *
+ * @return the number of selected items in the widget
+ *
+ * @exception DWTException <ul>
+ *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *  </ul>
+ */
+public int getSelectionCount () {
+    checkWidget();
+    return table.getSelectionCount();
+}
+
+public int getStyle () {
+    checkWidget();
+    return table.getStyle();
+}
+
+/**
+ * Returns the underlying Table control.
+ *
+ * @return the underlying Table control
+ */
+public Table getTable () {
+    //checkWidget();
+    return table;
+}
+
+void createImages () {
+    
+    int itemHeight = sizeImage.getBounds().height;
+    // Calculate border around image. 
+    // At least 9 pixels are needed to draw the image
+    // Leave at least a 6 pixel border.
+    int indent = Math.min(6, (itemHeight - 9) / 2);
+    indent = Math.max(0, indent);
+    int size = Math.max (10, itemHeight - 2 * indent); 
+    size = ((size + 1) / 2) * 2; // size must be an even number
+    int midpoint = indent + size / 2;
+    
+    Color foreground = getForeground();
+    Color plusMinus = getDisplay().getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW);
+    Color background = getBackground();
+    
+    /* Plus image */
+    PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
+    ImageData imageData = new ImageData(itemHeight, itemHeight, 4, palette);
+    imageData.transparentPixel = 1;
+    plusImage = new Image(getDisplay(), imageData);
+    GC gc = new GC(plusImage);
+    gc.setBackground(background);
+    gc.fillRectangle(0, 0, itemHeight, itemHeight);
+    gc.setForeground(plusMinus);
+    gc.drawRectangle(indent, indent, size, size);
+    gc.setForeground(foreground);
+    gc.drawLine(midpoint, indent + 2, midpoint, indent + size - 2);
+    gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
+    gc.dispose();
+    
+    /* Minus image */
+    palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
+    imageData = new ImageData(itemHeight, itemHeight, 4, palette);
+    imageData.transparentPixel = 1;
+    minusImage = new Image(getDisplay(), imageData);
+    gc = new GC(minusImage);
+    gc.setBackground(background);
+    gc.fillRectangle(0, 0, itemHeight, itemHeight);
+    gc.setForeground(plusMinus);
+    gc.drawRectangle(indent, indent, size, size);
+    gc.setForeground(foreground);
+    gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
+    gc.dispose();
+}
+
+Image getPlusImage() {
+    if (plusImage is null) createImages();
+    return plusImage;
+}
+
+Image getMinusImage() {
+    if (minusImage is null) createImages();
+    return minusImage;
+}
+
+/**
+ * Gets the index of an item.
+ * 
+ * <p>The widget is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned.  Indexing
+ * is zero based.  This index is relative to the parent only.
+ *
+ * @param item the search item
+ * @return the index of the item or -1
+ */
+public int indexOf (TableTreeItem item) {
+    //checkWidget();
+    for (int i = 0; i < items.length; i++) {
+        if (item is items[i]) return i;
+    }
+    return -1;
+}
+
+void onDispose(Event e) {
+    /*
+     * Usually when an item is disposed, destroyItem will change the size of the items array
+     * and dispose of the underlying table items.
+     * Since the whole table tree is being disposed, this is not necessary.  For speed
+     * the inDispose flag is used to skip over this part of the item dispose.
+     */
+    inDispose = true;
+    for (int i = 0; i < items.length; i++) {
+        items[i].dispose();
+    }
+    inDispose = false;
+    if (plusImage !is null) plusImage.dispose();
+    if (minusImage !is null) minusImage.dispose();
+    if (sizeImage !is null) sizeImage.dispose();
+    plusImage = minusImage = sizeImage = null;
+}
+
+void onResize(Event e) {
+    Point size = getSize();
+    table.setBounds(0, 0, size.x, size.y);
+}
+
+void onSelection(Event e) {
+    Event event = new Event();
+    TableItem tableItem = (TableItem)e.item;
+    TableTreeItem item = getItem(tableItem);
+    event.item = item;
+
+    if (e.type is DWT.Selection && e.detail is DWT.CHECK && item !is null) {
+        event.detail = DWT.CHECK;
+        item.checked = tableItem.getChecked();
+    }
+    notifyListeners(e.type, event);
+}
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TableTreeItem getItem (int index) {
+    checkWidget();
+    int count = items.length;
+    if (!(0 <= index && index < count)) DWT.error (DWT.ERROR_INVALID_RANGE);
+    return items [index];
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableTreeItem getItem(Point point) {
+    checkWidget();
+    TableItem item = table.getItem(point);
+    if (item is null) return null;
+    return getItem(item);
+    
+}
+TableTreeItem getItem(TableItem tableItem) {
+    if (tableItem is null) return null;
+    for (int i = 0; i < items.length; i++) {
+            TableTreeItem item = items[i].getItem(tableItem);
+            if (item !is null) return item;
+    }
+    return null;
+}
+void onFocusIn (Event e) {
+    table.setFocus();
+}
+
+void onKeyDown (Event e) {
+    TableTreeItem[] selection = getSelection();
+    if (selection.length is 0) return;
+    TableTreeItem item = selection[0];
+    int type = 0;
+    if (e.keyCode is DWT.ARROW_RIGHT || e.keyCode is DWT.ARROW_LEFT) {
+        int trailKey = (getStyle() & DWT.MIRRORED) !is 0 ? DWT.ARROW_LEFT : DWT.ARROW_RIGHT;
+        if (e.keyCode is trailKey) {
+            if (item.getItemCount() is 0) return;
+            if (item.getExpanded()) {
+                TableTreeItem newSelection = item.getItems()[0];
+                table.setSelection(new TableItem[]{newSelection.tableItem});
+                showItem(newSelection);
+                type = DWT.Selection;
+            } else {
+                item.setExpanded(true);
+                type = DWT.Expand;
+            }
+        } else {
+            if (item.getExpanded()) {
+                item.setExpanded(false);
+                type = DWT.Collapse;
+            } else {
+                TableTreeItem parent = item.getParentItem();
+                if (parent !is null) {
+                    int index = parent.indexOf(item);
+                    if (index !is 0) return;
+                    table.setSelection(new TableItem[]{parent.tableItem});
+                    type = DWT.Selection;
+                }
+            }
+        }
+    }
+    if (e.character is '*') {
+        item.expandAll(true);
+    }
+    if (e.character is '-') {
+        if (item.getExpanded()) {
+            item.setExpanded(false);
+            type = DWT.Collapse;
+        }
+    }
+    if (e.character is '+') {
+        if (item.getItemCount() > 0 && !item.getExpanded()) {
+            item.setExpanded(true);
+            type = DWT.Expand;
+        }
+    } 
+    if (type is 0) return;
+    Event event = new Event();
+    event.item = item;
+    notifyListeners(type, event);
+}
+void onMouseDown(Event event) {
+    /* If user clicked on the [+] or [-], expand or collapse the tree. */
+    TableItem[] items = table.getItems();
+    for (int i = 0; i < items.length; i++) {
+        Rectangle rect = items[i].getImageBounds(0);
+        if (rect.contains(event.x, event.y)) {
+            TableTreeItem item = (TableTreeItem) items[i].getData(ITEMID);
+            event = new Event();
+            event.item = item;
+            item.setExpanded(!item.getExpanded());
+            if (item.getExpanded()) {
+                notifyListeners(DWT.Expand, event);
+            } else {
+                notifyListeners(DWT.Collapse, event);
+            }
+            return;
+        }
+    }
+}
+
+/**
+ * Removes all items.
+ * <p>
+ * This operation will fail when an item
+ * could not be removed in the OS.
+ *
+ * @exception DWTException <ul>
+ *  <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *  <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void removeAll () {
+    checkWidget();
+    setRedraw(false);
+    for (int i = items.length - 1; i >= 0; i--) {
+        items[i].dispose();
+    }
+    items = EMPTY_ITEMS;
+    setRedraw(true);
+}
+
+void removeItem(TableTreeItem item) {
+    int index = 0;
+    while (index < items.length && items[index] !is item) index++;
+    if (index is items.length) return;
+    TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
+    System.arraycopy(items, 0, newItems, 0, index);
+    System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+    items = newItems;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    removeListener(DWT.Selection, listener);
+    removeListener(DWT.DefaultSelection, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #addTreeListener
+ */
+public void removeTreeListener (TreeListener listener) {
+    checkWidget();
+    if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    removeListener(DWT.Expand, listener);
+    removeListener(DWT.Collapse, listener);
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ *
+ * @exception DWTException <ul>
+ *  <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *  <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void selectAll () {
+    checkWidget();
+    table.selectAll();
+}
+public void setBackground (Color color) {
+    super.setBackground(color);
+    table.setBackground(color);
+    if (sizeImage !is null) {
+        GC gc = new GC (sizeImage);
+        gc.setBackground(getBackground());
+        Rectangle size = sizeImage.getBounds();
+        gc.fillRectangle(size);
+        gc.dispose();
+    }
+}
+public void setEnabled (bool enabled) {
+    super.setEnabled(enabled);
+    table.setEnabled(enabled);
+}
+public void setFont (Font font) {
+    super.setFont(font);
+    table.setFont(font);
+}
+public void setForeground (Color color) {
+    super.setForeground(color);
+    table.setForeground(color);
+}
+public void setMenu (Menu menu) {
+    super.setMenu(menu);
+    table.setMenu(menu);
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TableTree#deselectAll()
+ */
+public void setSelection (TableTreeItem[] items) {
+    checkWidget ();
+    if (items is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    int length = items.length;
+    if (length is 0 || ((table.getStyle() & DWT.SINGLE) !is 0 && length > 1)) {
+        deselectAll();
+        return;
+    }
+    TableItem[] tableItems = new TableItem[length];
+    for (int i = 0; i < length; i++) {
+        if (items[i] is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        if (!items[i].getVisible()) expandItem (items[i]);
+        tableItems[i] = items[i].tableItem;
+    }
+    table.setSelection(tableItems);
+}
+public void setToolTipText (String String) {
+    super.setToolTipText(String);
+    table.setToolTipText(String);
+}
+
+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TableTree#showSelection()
+ */
+public void showItem (TableTreeItem item) {
+    checkWidget();
+    if (item is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    if (!item.getVisible()) expandItem (item);
+    TableItem tableItem = item.tableItem;
+    table.showItem(tableItem);
+}
+
+/**
+ * Shows the selection.
+ * <p>
+ * If there is no selection or the selection
+ * is already visible, this method does nothing.
+ * If the selection is scrolled out of view,
+ * the top index of the widget is changed such
+ * that selection becomes visible.
+ *
+ * @exception DWTException <ul>
+ *  <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *  <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void showSelection () {
+    checkWidget();
+    table.showSelection();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TableTreeEditor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+import dwt.events.*;
+/**
+*
+* A TableTreeEditor is a manager for a Control that appears above a cell in a TableTree
+* and tracks with the moving and resizing of that cell.  It can be used to display a
+* text widget above a cell in a TableTree so that the user can edit the contents of 
+* that cell.  It can also be used to display a button that can launch a dialog for 
+* modifying the contents of the associated cell.
+*
+* <p> Here is an example of using a TableTreeEditor:
+* <code><pre>
+*   final TableTree tableTree = new TableTree(shell, DWT.FULL_SELECTION | DWT.HIDE_SELECTION);
+*   final Table table = tableTree.getTable();
+*   TableColumn column1 = new TableColumn(table, DWT.NONE);
+*   TableColumn column2 = new TableColumn(table, DWT.NONE);
+*   for (int i = 0; i &lt; 10; i++) {
+*       TableTreeItem item = new TableTreeItem(tableTree, DWT.NONE);
+*       item.setText(0, "item " + i);
+*       item.setText(1, "edit this value");
+*       for (int j = 0; j &lt; 3; j++) {
+*           TableTreeItem subitem = new TableTreeItem(item, DWT.NONE);
+*           subitem.setText(0, "subitem " + i + " " + j);
+*           subitem.setText(1, "edit this value");
+*       }
+*   }
+*   column1.setWidth(100);
+*   column2.pack();
+*   
+*   final TableTreeEditor editor = new TableTreeEditor(tableTree);
+*   //The editor must have the same size as the cell and must
+*   //not be any smaller than 50 pixels.
+*   editor.horizontalAlignment = DWT.LEFT;
+*   editor.grabHorizontal = true;
+*   editor.minimumWidth = 50;
+*   // editing the second column
+*   final int EDITABLECOLUMN = 1;
+*   
+*   tableTree.addSelectionListener(new SelectionAdapter() {
+*       public void widgetSelected(SelectionEvent e) {
+*           // Clean up any previous editor control
+*           Control oldEditor = editor.getEditor();
+*           if (oldEditor !is null) oldEditor.dispose();
+*   
+*           // Identify the selected row
+*           TableTreeItem item = (TableTreeItem)e.item;
+*           if (item is null) return;
+*   
+*           // The control that will be the editor must be a child of the Table
+*           Text newEditor = new Text(table, DWT.NONE);
+*           newEditor.setText(item.getText(EDITABLECOLUMN));
+*           newEditor.addModifyListener(new ModifyListener() {
+*               public void modifyText(ModifyEvent e) {
+*                   Text text = (Text)editor.getEditor();
+*                   editor.getItem().setText(EDITABLECOLUMN, text.getText());
+*               }
+*           });
+*           newEditor.selectAll();
+*           newEditor.setFocus();
+*           editor.setEditor(newEditor, item, EDITABLECOLUMN);
+*       }
+*   });
+* </pre></code>
+* 
+* @deprecated As of 3.1 use TreeEditor with Tree, TreeItem and TreeColumn
+*/
+public class TableTreeEditor : ControlEditor {
+
+    TableTree tableTree;
+    TableTreeItem item;
+    int column = -1;
+    ControlListener columnListener;
+    TreeListener treeListener;
+/**
+* Creates a TableTreeEditor for the specified TableTree.
+*
+* @param tableTree the TableTree Control above which this editor will be displayed
+*
+*/
+public TableTreeEditor (TableTree tableTree) {
+    super(tableTree.getTable());
+    this.tableTree = tableTree;
+
+    treeListener = new TreeListener () {
+        final Runnable runnable = new Runnable() {
+            public void run() {
+                if (editor is null || editor.isDisposed()) return;
+                if (TableTreeEditor.this.tableTree.isDisposed()) return;
+                layout();
+                editor.setVisible(true);
+            }
+        };
+        public void treeCollapsed(TreeEvent e) {
+            if (editor is null || editor.isDisposed ()) return;
+            editor.setVisible(false);
+            e.display.asyncExec(runnable);
+        }
+        public void treeExpanded(TreeEvent e) {
+            if (editor is null || editor.isDisposed ()) return;
+            editor.setVisible(false);
+            e.display.asyncExec(runnable);
+        }
+    };
+    tableTree.addTreeListener(treeListener);
+    
+    columnListener = new ControlListener() {
+        public void controlMoved(ControlEvent e){
+            layout ();
+        }
+        public void controlResized(ControlEvent e){
+            layout ();
+        }
+    };
+    
+    // To be consistent with older versions of DWT, grabVertical defaults to true
+    grabVertical = true;
+}
+Rectangle computeBounds () {
+    if (item is null || column is -1 || item.isDisposed() || item.tableItem is null) return new Rectangle(0, 0, 0, 0);
+    Rectangle cell = item.getBounds(column);
+    Rectangle area = tableTree.getClientArea();
+    if (cell.x < area.x + area.width) {
+        if (cell.x + cell.width > area.x + area.width) {
+            cell.width = area.x + area.width - cell.x;
+        }
+    }
+    Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+    if (grabHorizontal) {
+        editorRect.width = Math.max(cell.width, minimumWidth);
+    }
+    
+    if (grabVertical) {
+        editorRect.height = Math.max(cell.height, minimumHeight);
+    }
+    
+    if (horizontalAlignment is DWT.RIGHT) {
+        editorRect.x += cell.width - editorRect.width;
+    } else if (horizontalAlignment is DWT.LEFT) {
+        // do nothing - cell.x is the right answer
+    } else { // default is CENTER
+        editorRect.x += (cell.width - editorRect.width)/2;
+    }
+    
+    if (verticalAlignment is DWT.BOTTOM) {
+        editorRect.y += cell.height - editorRect.height;
+    } else if (verticalAlignment is DWT.TOP) {
+        // do nothing - cell.y is the right answer
+    } else { // default is CENTER
+        editorRect.y += (cell.height - editorRect.height)/2;
+    }
+    return editorRect;
+}
+/**
+ * Removes all associations between the TableTreeEditor and the cell in the table tree.  The
+ * TableTree and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+    if (tableTree !is null && !tableTree.isDisposed()) {
+        Table table = tableTree.getTable();
+        if (table !is null && !table.isDisposed()) {
+            if (this.column > -1 && this.column < table.getColumnCount()){
+                TableColumn tableColumn = table.getColumn(this.column);
+                tableColumn.removeControlListener(columnListener);
+            }
+        }
+        if (treeListener !is null) tableTree.removeTreeListener(treeListener);
+    }
+    treeListener = null;
+    columnListener = null;
+    tableTree = null;
+    item = null;
+    column = -1;
+    super.dispose();
+}
+/**
+* Returns the zero based index of the column of the cell being tracked by this editor.
+*
+* @return the zero based index of the column of the cell being tracked by this editor
+*/
+public int getColumn () {
+    return column;
+}
+/**
+* Returns the TableTreeItem for the row of the cell being tracked by this editor.
+*
+* @return the TableTreeItem for the row of the cell being tracked by this editor
+*/
+public TableTreeItem getItem () {
+    return item;
+}
+public void setColumn(int column) {
+    Table table = tableTree.getTable();
+    int columnCount = table.getColumnCount();
+    // Separately handle the case where the table has no TableColumns.
+    // In this situation, there is a single default column.
+    if (columnCount is 0) {
+        this.column = (column is 0) ? 0 : -1;
+        layout();
+        return;
+    }
+    if (this.column > -1 && this.column < columnCount){
+        TableColumn tableColumn = table.getColumn(this.column);
+        tableColumn.removeControlListener(columnListener);
+        this.column = -1;
+    }
+
+    if (column < 0  || column >= table.getColumnCount()) return;    
+        
+    this.column = column;
+    TableColumn tableColumn = table.getColumn(this.column);
+    tableColumn.addControlListener(columnListener);
+    layout();
+}
+public void setItem (TableTreeItem item) {  
+    this.item = item;
+    layout();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
+* specified in the TableEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TableItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TableTreeItem item, int column) {
+    setItem(item);
+    setColumn(column);
+    setEditor(editor);
+}
+public void layout () {
+    if (tableTree is null || tableTree.isDisposed()) return;
+    if (item is null || item.isDisposed()) return;
+    Table table = tableTree.getTable();
+    int columnCount = table.getColumnCount();
+    if (columnCount is 0 && column !is 0) return;
+    if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
+    super.layout();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TableTreeItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,876 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * A TableTreeItem is a selectable user interface object
+ * that represents an item in a hierarchy of items in a
+ * TableTree.
+ * 
+ * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn
+ */
+public class TableTreeItem : Item {
+    TableItem tableItem;
+    TableTree parent;
+    TableTreeItem parentItem;
+    TableTreeItem [] items = TableTree.EMPTY_ITEMS;
+    String[] texts = TableTree.EMPTY_TEXTS;
+    Image[] images = TableTree.EMPTY_IMAGES;
+    Color background;
+    Color foreground;
+    Font font;
+    bool expanded;
+    bool checked;
+    bool grayed;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTree</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTree parent, int style) {
+    this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTree</code>,
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTree parent, int style, int index) {
+    this (parent, null, style, index);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTreeItem parent, int style) {
+    this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTreeItem parent, int style, int index) {
+    this (parent.getParent(), parent, style, index);
+}
+
+TableTreeItem(TableTree parent, TableTreeItem parentItem, int style, int index) {
+    super(parent, style);
+    this.parent = parent;
+    this.parentItem = parentItem;
+    if (parentItem is null) {
+        
+        /* Root items are visible immediately */
+        int tableIndex = parent.addItem(this, index);
+        tableItem = new TableItem(parent.getTable(), style, tableIndex);
+        tableItem.setData(TableTree.ITEMID, this);
+        addCheck();
+        /*
+        * Feature in the Table.  The table uses the first image that
+        * is inserted into the table to size the table rows.  If the
+        * user is allowed to insert the first image, this will cause
+        * the +/- images to be scaled.  The fix is to insert a dummy
+        * image to force the size.
+        */
+        if (parent.sizeImage is null) {
+            int itemHeight = parent.getItemHeight();
+            parent.sizeImage = new Image(parent.getDisplay(), itemHeight, itemHeight);
+            GC gc = new GC (parent.sizeImage);
+            gc.setBackground(parent.getBackground());
+            gc.fillRectangle(0, 0, itemHeight, itemHeight);
+            gc.dispose();
+            tableItem.setImage(0, parent.sizeImage);
+        }
+    } else {
+        parentItem.addItem(this, index);
+    }
+}
+void addCheck() {
+    Table table = parent.getTable();
+    if ((table.getStyle() & DWT.CHECK) is 0) return;
+    tableItem.setChecked(checked);
+    tableItem.setGrayed(grayed);
+}
+void addItem(TableTreeItem item, int index) {
+    if (item is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (index < 0 || index > items.length) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        
+    /* Now that item has a sub-node it must indicate that it can be expanded */
+    if (items.length is 0 && index is 0) {
+        if (tableItem !is null) {
+            Image image = expanded ? parent.getMinusImage() : parent.getPlusImage();
+            tableItem.setImage(0, image);
+        }
+    }
+    
+    /* Put the item in the items list */
+    TableTreeItem[] newItems = new TableTreeItem[items.length + 1];
+    System.arraycopy(items, 0, newItems, 0, index);
+    newItems[index] = item;
+    System.arraycopy(items, index, newItems, index + 1, items.length - index);
+    items = newItems;
+    if (expanded) item.setVisible(true);
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getBackground () {
+    checkWidget ();
+    return (background is null) ? parent.getBackground() : background;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds (int index) {
+    checkWidget();
+    if (tableItem !is null) {
+        return tableItem.getBounds(index);
+    } else {
+        return new Rectangle(0, 0, 0, 0);
+    }
+}
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK style, return false.
+ *
+ * @return the checked state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getChecked () {
+    checkWidget();
+    if (tableItem is null) return checked;
+    return tableItem.getChecked();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public bool getGrayed () {
+    checkWidget();
+    if (tableItem is null) return grayed;
+    return tableItem.getGrayed();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is expanded,
+ * and false otherwise.
+ * <p>
+ *
+ * @return the expanded state
+ */
+public bool getExpanded () {
+    //checkWidget();
+    return expanded;
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information for this item.
+ *
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont () {
+    checkWidget ();
+    return (font is null) ? parent.getFont() : font;
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getForeground () {
+    checkWidget ();
+    return (foreground is null) ? parent.getForeground() : foreground;
+}
+/**
+ * Gets the first image.
+ * <p>
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore getImage(0) will return null.
+ *
+ * @return the image at index 0
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+    checkWidget();
+    return getImage(0);
+}
+
+/**
+ * Gets the image at the specified index.
+ * <p>
+ * Indexing is zero based. The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore getImage(0) will return null.
+ * Return null if the index is out of range.
+ *
+ * @param index the index of the image
+ * @return the image at the specified index or null
+ */
+public Image getImage (int index) {
+    //checkWidget();
+    if (0 < index && index < images.length) return images[index];
+    return null;
+}
+
+int getIndent() {
+    if (parentItem is null) return 0;
+    return parentItem.getIndent() + 1;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TableTreeItem getItem (int index) {
+    checkWidget();
+    int count = items.length;
+    if (!(0 <= index && index < count)) DWT.error (DWT.ERROR_INVALID_RANGE);
+    return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.
+ *
+ * @return the number of items
+ */
+public int getItemCount () {
+    //checkWidget();
+    return items.length;
+}
+
+/**
+ * Returns an array of <code>TableTreeItem</code>s which are the
+ * direct item children of the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items
+ */
+public TableTreeItem[] getItems () {
+    //checkWidget();
+    TableTreeItem[] newItems = new TableTreeItem[items.length];
+    System.arraycopy(items, 0, newItems, 0, items.length);
+    return newItems;
+}
+
+TableTreeItem getItem(TableItem tableItem) {
+    if (tableItem is null) return null;
+    if (this.tableItem is tableItem) return this;
+    for (int i = 0; i < items.length; i++) {
+        TableTreeItem item =  items[i].getItem(tableItem);
+            if (item !is null) return item;
+    }
+    return null;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>TableTree</code>.
+ *
+ * @return the receiver's parent
+ */
+public TableTree getParent () {
+    //checkWidget();
+    return parent;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TableTreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ */
+public TableTreeItem getParentItem () {
+    //checkWidget();
+    return parentItem;
+}
+public String getText () {
+    checkWidget();
+    return getText(0);
+}
+
+/**
+ * Gets the item text at the specified index.
+ * <p>
+ * Indexing is zero based.
+ *
+ * This operation will fail when the index is out
+ * of range or an item could not be queried from
+ * the OS.
+ *
+ * @param index the index of the item
+ * @return the item text at the specified index, which can be null
+ */
+public String getText(int index) {
+    //checkWidget();
+    if (0 <= index && index < texts.length) return texts[index];
+    return null;
+}
+
+bool getVisible () {
+    return tableItem !is null;
+}
+
+/**
+ * Gets the index of the specified item.
+ * 
+ * <p>The widget is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned.  Indexing
+ * is zero based.  This index is relative to the parent only.
+ *
+ * @param item the search item
+ * @return the index of the item or -1 if the item is not found
+ *
+ */
+public int indexOf (TableTreeItem item) {
+    //checkWidget();    
+    for (int i = 0; i < items.length; i++) {
+        if (items[i] is item) return i;
+    }
+    return -1;
+}
+
+void expandAll(bool notify) {
+    if (items.length is 0) return;
+    if (!expanded) {
+        setExpanded(true);
+        if (notify) {
+            Event event = new Event();
+            event.item = this;
+            parent.notifyListeners(DWT.Expand, event);
+        }
+    }
+    for (int i = 0; i < items.length; i++) {
+        items[i].expandAll(notify);
+    }
+}
+int expandedIndexOf (TableTreeItem item) {  
+    int index = 0;
+    for (int i = 0; i < items.length; i++) {
+        if (items[i] is item) return index;
+        if (items[i].expanded) index += items[i].visibleChildrenCount ();
+        index++;
+    }
+    return -1;
+}
+
+int visibleChildrenCount () {
+    int count = 0;
+    for (int i = 0; i < items.length; i++) {
+        if (items[i].getVisible ()) {
+            count += 1 + items[i].visibleChildrenCount ();
+        }
+    }
+    return count;
+}
+
+public void dispose () {
+    if (isDisposed()) return;
+    for (int i = items.length - 1; i >= 0; i--) {
+        items[i].dispose();
+    }
+    super.dispose();
+    if (!parent.inDispose) {
+        if (parentItem !is null) {
+            parentItem.removeItem(this);
+        } else {
+            parent.removeItem(this);
+        }
+        if (tableItem !is null) tableItem.dispose();
+    }
+    items = null;
+    parentItem = null;
+    parent = null;
+    images = null;
+    texts = null;
+    tableItem = null;
+    foreground = null;
+    background = null;
+    font = null;
+}
+
+void removeItem(TableTreeItem item) {
+    int index = 0;
+    while (index < items.length && items[index] !is item) index++;
+    if (index is items.length) return;
+    TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
+    System.arraycopy(items, 0, newItems, 0, index);
+    System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+    items = newItems;
+    if (items.length is 0) {
+        if (tableItem !is null) tableItem.setImage(0, null);
+    }
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setBackground (Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (tableItem !is null) {
+        tableItem.setBackground(color);
+    }
+    background = color;
+}
+
+/**
+ * Sets the checked state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the DWT.CHECK style.
+ *
+ * @param checked the new checked state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (bool checked) {
+    checkWidget();
+    Table table = parent.getTable();
+    if ((table.getStyle() & DWT.CHECK) is 0) return;
+    if (tableItem !is null) {
+        tableItem.setChecked(checked);
+    }
+    this.checked = checked;
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the DWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox; 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void setGrayed (bool grayed) {
+    checkWidget();
+    Table table = parent.getTable();
+    if ((table.getStyle() & DWT.CHECK) is 0) return;
+    if (tableItem !is null) {
+        tableItem.setGrayed(grayed);
+    }
+    this.grayed = grayed;
+}
+
+/**
+ * Sets the expanded state.
+ * <p>
+ * @param expanded the new expanded state.
+ *
+ * @exception DWTException <ul>
+ *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *  </ul>
+ */
+public void setExpanded (bool expanded) {
+    checkWidget();
+    if (items.length is 0) return;
+    if (this.expanded is expanded) return;
+    this.expanded = expanded;
+    if (tableItem is null) return;
+    parent.setRedraw(false);
+    for (int i = 0; i < items.length; i++) {
+        items[i].setVisible(expanded);
+    }
+    Image image = expanded ? parent.getMinusImage() : parent.getPlusImage();
+    tableItem.setImage(0, image);
+    parent.setRedraw(true);
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (Font font){
+    checkWidget ();
+    if (font !is null && font.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (tableItem !is null) {
+        tableItem.setFont(font);
+    }
+    this.font = font;
+}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setForeground (Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (tableItem !is null) {
+        tableItem.setForeground(color);
+    }
+    foreground = color;
+}
+
+/**
+ * Sets the image at an index.
+ * <p>
+ * The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore do nothing if index is 0.
+ *
+ * @param image the new image or null
+ *
+ * @exception DWTException <ul>
+ *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *  </ul>
+ */
+public void setImage (int index, Image image) {
+    checkWidget();
+    int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
+    if (index <= 0 || index >= columnCount) return;
+    if (images.length < columnCount) {
+        Image[] newImages = new Image[columnCount];
+        System.arraycopy(images, 0, newImages, 0, images.length);
+        images = newImages;
+    }
+    images[index] = image;
+    if (tableItem !is null) tableItem.setImage(index, image);
+}
+
+/**
+ * Sets the first image.
+ * <p>
+ * The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore do nothing.
+ *
+ * @param image the new image or null
+ * 
+ * @exception DWTException <ul>
+ *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *  </ul>
+ */
+public void setImage (Image image) {
+    setImage(0, image);
+}
+
+/**
+ * Sets the widget text.
+ * <p>
+ *
+ * The widget text for an item is the label of the
+ * item or the label of the text specified by a column
+ * number.
+ *
+ * @param index the column number
+ * @param text the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *      <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *      <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *  </ul>
+ */
+public void setText(int index, String text) {
+    checkWidget();
+    if (text is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
+    if (index < 0 || index >= columnCount) return;
+    if (texts.length < columnCount) {
+        String[] newTexts = new String[columnCount];
+        System.arraycopy(texts, 0, newTexts, 0, texts.length);
+        texts = newTexts;
+    }
+    texts[index] = text;
+    if (tableItem !is null) tableItem.setText(index, text);
+}
+public void setText (String String) {
+    setText(0, String);
+}
+
+void setVisible (bool show) {
+    if (parentItem is null) return; // this is a root and can not be toggled between visible and hidden
+    if (getVisible() is show) return;
+
+    if (show) {
+        if (!parentItem.getVisible()) return; // parentItem must already be visible
+        // create underlying table item and set data in table item to stored data
+        Table table = parent.getTable();
+        int parentIndex = table.indexOf(parentItem.tableItem);
+        int index = parentItem.expandedIndexOf(this) + parentIndex + 1;
+        if (index < 0) return;
+        tableItem = new TableItem(table, getStyle(), index);
+        tableItem.setData(TableTree.ITEMID, this);
+        tableItem.setImageIndent(getIndent());
+        if (background !is null) tableItem.setBackground(background);
+        if (foreground !is null) tableItem.setForeground(foreground);
+        if (font !is null) tableItem.setFont(font);
+        addCheck();
+
+        // restore fields to item
+        // ignore any images in the first column
+        int columnCount = Math.max(table.getColumnCount(), 1);
+        for (int i = 0; i < columnCount; i++) {
+            if (i < texts.length && texts[i] !is null) setText(i, texts[i]);
+            if (i < images.length && images[i] !is null) setImage(i, images[i]);
+        }
+
+        // display the children and the appropriate [+]/[-] symbol as required
+        if (items.length !is 0) {
+            if (expanded) {
+                tableItem.setImage(0, parent.getMinusImage());
+                for (int i = 0, length = items.length; i < length; i++) {
+                    items[i].setVisible(true);
+                }
+            } else {
+                tableItem.setImage(0, parent.getPlusImage());
+            }
+        }
+        
+    } else {
+
+        for (int i = 0, length = items.length; i < length; i++) {
+            items[i].setVisible(false);
+        }
+        // remove row from table
+        tableItem.dispose();
+        tableItem = null;
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TextChangeListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * The StyledText widget : this listener to receive
+ * notifications when changes to the model occur.
+ * It is not intended to be implemented by clients or by 
+ * implementors of StyledTextContent. 
+ * Clients should listen to the ModifyEvent or ExtendedModifyEvent 
+ * that is sent by the StyledText widget to receive text change 
+ * notifications.
+ * Implementors of StyledTextContent should call the textChanging
+ * and textChanged methods when text changes occur as described 
+ * below. If the entire text is replaced the textSet method 
+ * should be called instead.
+ */
+public interface TextChangeListener : DWTEventListener {
+
+/**
+ * This method is called when the content is about to be changed.
+ * Callers also need to call the textChanged method after the 
+ * content change has been applied. The widget only updates the 
+ * screen properly when it receives both events. 
+ * 
+ * @param event the text changing event. All event fields need
+ *  to be set by the sender.
+ * @see TextChangingEvent
+ */
+public void textChanging(TextChangingEvent event);
+/**
+ * This method is called when the content has changed.
+ * Callers need to have called the textChanging method prior to 
+ * applying the content change and calling this method. The widget 
+ * only updates the screen properly when it receives both events.
+ * 
+ * @param event the text changed event
+ */
+public void textChanged(TextChangedEvent event);
+/**
+ * This method is called instead of the textChanging/textChanged 
+ * combination when the entire old content has been replaced 
+ * (e.g., by a call to StyledTextContent.setText()).
+ * 
+ * @param event the text changed event
+ */
+public void textSet(TextChangedEvent event);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TextChangedEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+
+/**
+ * This event is sent by the StyledTextContent implementor when a change to 
+ * the text occurs.
+ */
+public class TextChangedEvent : TypedEvent {
+
+    static final long serialVersionUID = 3258696524257835065L;
+
+/**
+ * Create the TextChangedEvent to be used by the StyledTextContent implementor.
+ * <p>
+ *
+ * @param source the object that will be sending the TextChangedEvent, 
+ *  cannot be null  
+ */
+public TextChangedEvent(StyledTextContent source) {
+    super(source);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TextChangingEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.events.*;
+
+/**
+ * This event is sent by the StyledTextContent implementor when a change
+ * to the text is about to occur.
+ */
+public class TextChangingEvent : TypedEvent {
+    /**
+     * Start offset of the text that is going to be replaced
+     */
+    public int start;
+    /**
+     * Text that is going to be inserted or empty String
+     * if no text will be inserted
+     */
+    public String newText;
+    /**
+     * Length of text that is going to be replaced
+     */
+    public int replaceCharCount;
+    /**
+     * Length of text that is going to be inserted
+     */
+    public int newCharCount;
+    /**
+     * Number of lines that are going to be replaced
+     */
+    public int replaceLineCount;
+    /**
+     * Number of new lines that are going to be inserted
+     */
+    public int newLineCount;
+
+    static final long serialVersionUID = 3257290210114352439L;
+    
+/**
+ * Create the TextChangedEvent to be used by the StyledTextContent implementor.
+ * <p>
+ *
+ * @param source the object that will be sending the new TextChangingEvent, 
+ *  cannot be null  
+ */
+public TextChangingEvent(StyledTextContent source) {
+    super(source);
+}
+TextChangingEvent(StyledTextContent source, StyledTextEvent e) {
+    super(source);
+    start = e.start;
+    replaceCharCount = e.replaceCharCount;
+    newCharCount = e.newCharCount;
+    replaceLineCount = e.replaceLineCount;
+    newLineCount = e.newLineCount;
+    newText = e.text;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/TreeEditor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.*;
+import dwt.events.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+*
+* A TreeEditor is a manager for a Control that appears above a cell in a Tree and tracks with the
+* moving and resizing of that cell.  It can be used to display a text widget above a cell
+* in a Tree so that the user can edit the contents of that cell.  It can also be used to display
+* a button that can launch a dialog for modifying the contents of the associated cell.
+*
+* <p> Here is an example of using a TreeEditor:
+* <code><pre>
+*   final Tree tree = new Tree(shell, DWT.BORDER);
+*   for (int i = 0; i &lt; 3; i++) {
+*       TreeItem item = new TreeItem(tree, DWT.NONE);
+*       item.setText("item " + i);
+*       for (int j = 0; j &lt; 3; j++) {
+*           TreeItem subItem = new TreeItem(item, DWT.NONE);
+*           subItem.setText("item " + i + " " + j);
+*       }
+*   }
+*   
+*   final TreeEditor editor = new TreeEditor(tree);
+*   //The editor must have the same size as the cell and must
+*   //not be any smaller than 50 pixels.
+*   editor.horizontalAlignment = DWT.LEFT;
+*   editor.grabHorizontal = true;
+*   editor.minimumWidth = 50;
+*   
+*   tree.addSelectionListener(new SelectionAdapter() {
+*       public void widgetSelected(SelectionEvent e) {
+*           // Clean up any previous editor control
+*           Control oldEditor = editor.getEditor();
+*           if (oldEditor !is null) oldEditor.dispose();
+*   
+*           // Identify the selected row
+*           TreeItem item = (TreeItem)e.item;
+*           if (item is null) return;
+*   
+*           // The control that will be the editor must be a child of the Tree
+*           Text newEditor = new Text(tree, DWT.NONE);
+*           newEditor.setText(item.getText());
+*           newEditor.addModifyListener(new ModifyListener() {
+*               public void modifyText(ModifyEvent e) {
+*                   Text text = (Text)editor.getEditor();
+*                   editor.getItem().setText(text.getText());
+*               }
+*           });
+*           newEditor.selectAll();
+*           newEditor.setFocus();
+*           editor.setEditor(newEditor, item);
+*       }
+*   });
+* </pre></code>
+*/
+public class TreeEditor : ControlEditor {   
+    Tree tree;
+    TreeItem item;
+    int column = 0;
+    ControlListener columnListener;
+    TreeListener treeListener;
+    Runnable timer;
+    static final int TIMEOUT = 1500;
+    
+/**
+* Creates a TreeEditor for the specified Tree.
+*
+* @param tree the Tree Control above which this editor will be displayed
+*
+*/
+public TreeEditor (Tree tree) {
+    super(tree);
+    this.tree = tree;
+
+    columnListener = new ControlListener() {
+        public void controlMoved(ControlEvent e){
+            layout();
+        }
+        public void controlResized(ControlEvent e){
+            layout();
+        }
+    };
+    timer = new Runnable () {
+        public void run() {
+            layout ();
+        }
+    };
+    treeListener = new TreeListener () {
+        final Runnable runnable = new Runnable() {
+            public void run() {
+                if (editor is null || editor.isDisposed()) return;
+                if (TreeEditor.this.tree.isDisposed()) return;
+                layout();
+                editor.setVisible(true);
+            }
+        };
+        public void treeCollapsed(TreeEvent e) {
+            if (editor is null || editor.isDisposed ()) return;
+            editor.setVisible(false);
+            e.display.asyncExec(runnable);
+        }
+        public void treeExpanded(TreeEvent e) {
+            if (editor is null || editor.isDisposed ()) return;
+            editor.setVisible(false);
+            e.display.asyncExec(runnable);
+        }
+    };
+    tree.addTreeListener(treeListener);
+    
+    // To be consistent with older versions of DWT, grabVertical defaults to true
+    grabVertical = true;
+}
+
+Rectangle computeBounds () {
+    if (item is null || column is -1 || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+    Rectangle cell = item.getBounds(column);
+    Rectangle rect = item.getImageBounds(column);
+    cell.x = rect.x + rect.width;
+    cell.width -= rect.width;
+    Rectangle area = tree.getClientArea();
+    if (cell.x < area.x + area.width) {
+        if (cell.x + cell.width > area.x + area.width) {
+            cell.width = area.x + area.width - cell.x;
+        }
+    }
+    Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+    if (grabHorizontal) {
+        if (tree.getColumnCount() is 0) {
+            // Bounds of tree item only include the text area - stretch out to include 
+            // entire client area
+            cell.width = area.x + area.width - cell.x;
+        }
+        editorRect.width = Math.max(cell.width, minimumWidth);
+    }
+    
+    if (grabVertical) {
+        editorRect.height = Math.max(cell.height, minimumHeight);
+    }
+    
+    if (horizontalAlignment is DWT.RIGHT) {
+        editorRect.x += cell.width - editorRect.width;
+    } else if (horizontalAlignment is DWT.LEFT) {
+        // do nothing - cell.x is the right answer
+    } else { // default is CENTER
+        editorRect.x += (cell.width - editorRect.width)/2;
+    }
+    // don't let the editor overlap with the +/- of the tree
+    editorRect.x = Math.max(cell.x, editorRect.x);
+    
+    if (verticalAlignment is DWT.BOTTOM) {
+        editorRect.y += cell.height - editorRect.height;
+    } else if (verticalAlignment is DWT.TOP) {
+        // do nothing - cell.y is the right answer
+    } else { // default is CENTER
+        editorRect.y += (cell.height - editorRect.height)/2;
+    }
+    return editorRect;
+}
+
+/**
+ * Removes all associations between the TreeEditor and the row in the tree.  The
+ * tree and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+    if (tree !is null && !tree.isDisposed()) {
+        if (this.column > -1 && this.column < tree.getColumnCount()){
+            TreeColumn treeColumn = tree.getColumn(this.column);
+            treeColumn.removeControlListener(columnListener);
+        }
+        if (treeListener !is null) tree.removeTreeListener(treeListener);
+    }
+    columnListener = null;
+    treeListener = null;
+    tree = null;
+    item = null;
+    column = 0;
+    timer = null;
+    super.dispose();
+}
+
+/**
+* Returns the zero based index of the column of the cell being tracked by this editor.
+*
+* @return the zero based index of the column of the cell being tracked by this editor
+*
+* @since 3.1
+*/
+public int getColumn () {
+    return column;
+}
+
+/**
+* Returns the TreeItem for the row of the cell being tracked by this editor.
+*
+* @return the TreeItem for the row of the cell being tracked by this editor
+*/
+public TreeItem getItem () {
+    return item;
+}
+
+void resize () {
+    layout();
+    /*
+     * On some platforms, the table scrolls when an item that
+     * is partially visible at the bottom of the table is
+     * selected.  Ensure that the correct row is edited by
+     * laying out one more time in a timerExec().
+     */
+    if (tree !is null) {
+        Display display = tree.getDisplay();
+        display.timerExec(-1, timer);
+        display.timerExec(TIMEOUT, timer);
+    }
+}
+
+/**
+* Sets the zero based index of the column of the cell being tracked by this editor.
+* 
+* @param column the zero based index of the column of the cell being tracked by this editor
+*
+* @since 3.1
+*/
+public void setColumn(int column) {
+    int columnCount = tree.getColumnCount();
+    // Separately handle the case where the tree has no TreeColumns.
+    // In this situation, there is a single default column.
+    if (columnCount is 0) {
+        this.column = (column is 0) ? 0 : -1;
+        resize();
+        return;
+    }
+    if (this.column > -1 && this.column < columnCount){
+        TreeColumn treeColumn = tree.getColumn(this.column);
+        treeColumn.removeControlListener(columnListener);
+        this.column = -1;
+    }
+
+    if (column < 0  || column >= tree.getColumnCount()) return; 
+        
+    this.column = column;
+    TreeColumn treeColumn = tree.getColumn(this.column);
+    treeColumn.addControlListener(columnListener);
+    resize();
+}
+
+public void setItem (TreeItem item) {
+    this.item = item;
+    resize();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control
+* specified in the TreeEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TreeItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*
+* @since 3.1
+*/
+public void setEditor (Control editor, TreeItem item, int column) {
+    setItem(item);
+    setColumn(column);
+    setEditor(editor);
+}
+public void setEditor (Control editor) {
+    super.setEditor(editor);
+    resize();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control
+* specified in the TreeEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TreeItem for the row of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TreeItem item) {
+    setItem(item);
+    setEditor(editor);
+}
+
+public void layout () {
+    if (tree is null || tree.isDisposed()) return;
+    if (item is null || item.isDisposed()) return;  
+    int columnCount = tree.getColumnCount();
+    if (columnCount is 0 && column !is 0) return;
+    if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
+    super.layout();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/VerifyKeyListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.events.*;
+import dwt.internal.DWTEventListener;
+
+public interface VerifyKeyListener : DWTEventListener {
+/**
+ * The following event fields are used:<ul>
+ * <li>event.character is the character that was typed (input)</li>
+ * <li>event.keyCode is the key code that was typed (input)</li>
+ * <li>event.stateMask is the state of the keyboard (input)</li>
+ * <li>event.doit is processed or not (output)</li>
+ * </ul>
+ * @param event the verify event
+ * @see VerifyEvent
+ */
+public void verifyKey (VerifyEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ViewForm.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,468 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+
+import dwt.graphics.*;
+import dwt.widgets.*;
+import dwt.*;
+
+/**
+ * Instances of this class implement a Composite that positions and sizes
+ * children and allows programmatic control of layout and border parameters. 
+ * ViewForm is used in the workbench to lay out a view's label/menu/toolbar
+ * local bar.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, FLAT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(None)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class ViewForm : Composite {
+
+    /**
+     * marginWidth specifies the number of pixels of horizontal margin
+     * that will be placed along the left and right edges of the form.
+     *
+     * 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 form.
+     *
+     * The default value is 0.
+     */
+    public int marginHeight = 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 1.
+     */
+    public int horizontalSpacing = 1;
+    /**
+     * 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 1.
+     */
+    public int verticalSpacing = 1;
+    
+    /**
+     * Color of innermost line of drop shadow border.
+     * 
+     * NOTE This field is badly named and can not be fixed for backwards compatibility.
+     * It should be capitalized.
+     * 
+     * @deprecated
+     */
+    public static RGB borderInsideRGB  = new RGB (132, 130, 132);
+    /**
+     * Color of middle line of drop shadow border.
+     * 
+     * NOTE This field is badly named and can not be fixed for backwards compatibility.
+     * It should be capitalized.
+     * 
+     * @deprecated
+     */
+    public static RGB borderMiddleRGB  = new RGB (143, 141, 138);
+    /**
+     * Color of outermost line of drop shadow border.
+     * 
+     * NOTE This field is badly named and can not be fixed for backwards compatibility.
+     * It should be capitalized.
+     * 
+     * @deprecated
+     */
+    public static RGB borderOutsideRGB = new RGB (171, 168, 165);
+    
+    // DWT widgets
+    Control topLeft;
+    Control topCenter;
+    Control topRight;
+    Control content;
+    
+    // Configuration and state info
+    bool separateTopCenter = false;
+    bool showBorder = false;
+    
+    int separator = -1;
+    int borderTop = 0;
+    int borderBottom = 0;
+    int borderLeft = 0;
+    int borderRight = 0;
+    int highlight = 0;
+    Point oldSize;
+    
+    Color selectionBackground;
+    
+    static final int OFFSCREEN = -200;
+    static final int BORDER1_COLOR = DWT.COLOR_WIDGET_NORMAL_SHADOW;
+    static final int SELECTION_BACKGROUND = DWT.COLOR_LIST_BACKGROUND;
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT#BORDER
+ * @see DWT#FLAT
+ * @see #getStyle()
+ */     
+public ViewForm(Composite parent, int style) {
+    super(parent, checkStyle(style));
+    super.setLayout(new ViewFormLayout());
+    
+    setBorderVisible((style & DWT.BORDER) !is 0);
+    
+    Listener listener = new Listener() {
+        public void handleEvent(Event e) {
+            switch (e.type) {
+                case DWT.Dispose: onDispose(); break;
+                case DWT.Paint: onPaint(e.gc); break;
+                case DWT.Resize: onResize(); break;
+            }
+        }
+    };
+    
+    int[] events = new int[] {DWT.Dispose, DWT.Paint, DWT.Resize};
+    
+    for (int i = 0; i < events.length; i++) {
+        addListener(events[i], listener);
+    }
+}
+
+static int checkStyle (int style) {
+    int mask = DWT.FLAT | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+    return style & mask | DWT.NO_REDRAW_RESIZE;
+}
+
+//protected void checkSubclass () {
+//  String name = getClass().getName ();
+//  String validName = ViewForm.class.getName();
+//  if (!validName.opEquals(name)) {
+//      DWT.error (DWT.ERROR_INVALID_SUBCLASS);
+//  }
+//}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+    checkWidget ();
+    int trimX = x - borderLeft - highlight;
+    int trimY = y - borderTop - highlight;
+    int trimWidth = width + borderLeft + borderRight + 2*highlight;
+    int trimHeight = height + borderTop + borderBottom + 2*highlight;
+    return new Rectangle(trimX, trimY, trimWidth, trimHeight);
+}
+public Rectangle getClientArea() {
+    checkWidget();
+    Rectangle clientArea = super.getClientArea();
+    clientArea.x += borderLeft;
+    clientArea.y += borderTop;
+    clientArea.width -= borderLeft + borderRight;
+    clientArea.height -= borderTop + borderBottom;
+    return clientArea;
+}
+/**
+* Returns the content area.
+* 
+* @return the control in the content area of the pane or null
+*/
+public Control getContent() {
+    //checkWidget();
+    return content;
+}
+/**
+* Returns Control that appears in the top center of the pane.
+* Typically this is a toolbar.
+* 
+* @return the control in the top center of the pane or null
+*/
+public Control getTopCenter() {
+    //checkWidget();
+    return topCenter;
+}
+/**
+* Returns the Control that appears in the top left corner of the pane.
+* Typically this is a label such as CLabel.
+* 
+* @return the control in the top left corner of the pane or null
+*/
+public Control getTopLeft() {
+    //checkWidget();
+    return topLeft;
+}
+/**
+* Returns the control in the top right corner of the pane.
+* Typically this is a Close button or a composite with a Menu and Close button.
+* 
+* @return the control in the top right corner of the pane or null
+*/
+public Control getTopRight() {
+    //checkWidget();
+    return topRight;
+}
+void onDispose() {
+    topLeft = null;
+    topCenter = null;
+    topRight = null;
+    content = null;
+    oldSize = null;
+    selectionBackground = null;
+}
+void onPaint(GC gc) {
+    Color gcForeground = gc.getForeground();
+    Point size = getSize();
+    Color border = getDisplay().getSystemColor(BORDER1_COLOR);
+    if (showBorder) {
+        gc.setForeground(border);
+        gc.drawRectangle(0, 0, size.x - 1, size.y - 1);
+        if (highlight > 0) {
+            int x1 = 1;
+            int y1 = 1;
+            int x2 = size.x - 1;
+            int y2 = size.y - 1;
+            int[] shape = new int[] {x1,y1, x2,y1, x2,y2, x1,y2, x1,y1+highlight,
+                               x1+highlight,y1+highlight, x1+highlight,y2-highlight, 
+                               x2-highlight,y2-highlight, x2-highlight,y1+highlight, x1,y1+highlight};
+            Color highlightColor = getDisplay().getSystemColor(DWT.COLOR_LIST_SELECTION);
+            gc.setBackground(highlightColor);
+            gc.fillPolygon(shape);
+        }
+    }
+    if (separator > -1) {
+        gc.setForeground(border);
+        gc.drawLine(borderLeft + highlight, separator, size.x - borderLeft - borderRight - highlight, separator);
+    }
+    gc.setForeground(gcForeground);
+}
+void onResize() {
+    Point size = getSize();
+    if (oldSize is null || oldSize.x is 0 || oldSize.y is 0) {
+        redraw();
+    } else {
+        int width = 0;
+        if (oldSize.x < size.x) {
+            width = size.x - oldSize.x + borderRight + highlight;
+        } else if (oldSize.x > size.x) {
+            width = borderRight + highlight;            
+        }
+        redraw(size.x - width, 0, width, size.y, false);
+        
+        int height = 0;
+        if (oldSize.y < size.y) {
+            height = size.y - oldSize.y + borderBottom + highlight;     
+        }
+        if (oldSize.y > size.y) {
+            height = borderBottom + highlight;      
+        }
+        redraw(0, size.y - height, size.x, height, false);
+    }
+    oldSize = size;
+}
+/**
+* Sets the content.
+* Setting the content to null will remove it from 
+* the pane - however, the creator of the content must dispose of the content.
+* 
+* @param content the control to be displayed in the content area or null
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setContent(Control content) {
+    checkWidget();
+    if (content !is null && content.getParent() !is this) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (this.content !is null && !this.content.isDisposed()) {
+        this.content.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
+    }
+    this.content = content;
+    layout(false);
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+    checkWidget();
+    return;
+}
+void setSelectionBackground (Color color) {
+    checkWidget();
+    if (selectionBackground is color) return;
+    if (color is null) color = getDisplay().getSystemColor(SELECTION_BACKGROUND);
+    selectionBackground = color;
+    redraw();
+}
+/**
+* Set the control that appears in the top center of the pane.
+* Typically this is a toolbar.
+* The topCenter is optional.  Setting the topCenter to null will remove it from 
+* the pane - however, the creator of the topCenter must dispose of the topCenter.
+* 
+* @param topCenter the control to be displayed in the top center or null
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setTopCenter(Control topCenter) {
+    checkWidget();
+    if (topCenter !is null && topCenter.getParent() !is this) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (this.topCenter !is null && !this.topCenter.isDisposed()) {
+        Point size = this.topCenter.getSize();
+        this.topCenter.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+    }
+    this.topCenter = topCenter;
+    layout(false);
+}
+/**
+* Set the control that appears in the top left corner of the pane.
+* Typically this is a label such as CLabel.
+* The topLeft is optional.  Setting the top left control to null will remove it from 
+* the pane - however, the creator of the control must dispose of the control.
+* 
+* @param c the control to be displayed in the top left corner or null
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setTopLeft(Control c) {
+    checkWidget();
+    if (c !is null && c.getParent() !is this) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (this.topLeft !is null && !this.topLeft.isDisposed()) {
+        Point size = this.topLeft.getSize();
+        this.topLeft.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+    }
+    this.topLeft = c;
+    layout(false);
+}
+/**
+* Set the control that appears in the top right corner of the pane.
+* Typically this is a Close button or a composite with a Menu and Close button.
+* The topRight is optional.  Setting the top right control to null will remove it from 
+* the pane - however, the creator of the control must dispose of the control.
+* 
+* @param c the control to be displayed in the top right corner or null
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setTopRight(Control c) {
+    checkWidget();
+    if (c !is null && c.getParent() !is this) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (this.topRight !is null && !this.topRight.isDisposed()) {
+        Point size = this.topRight.getSize();
+        this.topRight.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+    }
+    this.topRight = c;
+    layout(false);
+}
+/**
+* Specify whether the border should be displayed or not.
+* 
+* @param show true if the border should be displayed
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setBorderVisible(bool show) {
+    checkWidget();
+    if (showBorder is show) return;
+    
+    showBorder = show;
+    if (showBorder) {
+        borderLeft = borderTop = borderRight = borderBottom = 1;
+        if ((getStyle() & DWT.FLAT)== 0) highlight = 2;
+    } else {
+        borderBottom = borderTop = borderLeft = borderRight = 0;
+        highlight = 0;
+    }
+    layout(false);
+    redraw();
+}
+/**
+* If true, the topCenter will always appear on a separate line by itself, otherwise the 
+* topCenter will appear in the top row if there is room and will be moved to the second row if
+* required.
+* 
+* @param show true if the topCenter will always appear on a separate line by itself
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setTopCenterSeparate(bool show) {
+    checkWidget();
+    separateTopCenter = show;
+    layout(false);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/custom/ViewFormLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.custom;
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+/**
+ * This class provides the layout for ViewForm
+ * 
+ * @see ViewForm
+ */
+class ViewFormLayout : Layout {
+
+protected Point computeSize(Composite composite, int wHint, int hHint, bool flushCache) {
+    ViewForm form = (ViewForm)composite;
+    Control left = form.topLeft;
+    Control center = form.topCenter;
+    Control right = form.topRight;
+    Control content = form.content;
+    
+    Point leftSize = new Point(0, 0);
+    if (left !is null) {
+        leftSize = computeChildSize(left, DWT.DEFAULT, DWT.DEFAULT, flushCache);
+    }
+    Point centerSize = new Point(0, 0);
+    if (center !is null) {
+         centerSize = computeChildSize(center, DWT.DEFAULT, DWT.DEFAULT, flushCache);
+    }
+    Point rightSize = new Point(0, 0);
+    if (right !is null) {
+         rightSize = computeChildSize(right, DWT.DEFAULT, DWT.DEFAULT, flushCache);
+    }
+    Point size = new Point(0, 0);
+    // calculate width of title bar
+    if (form.separateTopCenter ||
+        (wHint !is DWT.DEFAULT &&  leftSize.x + centerSize.x + rightSize.x > wHint)) {
+        size.x = leftSize.x + rightSize.x;
+        if (leftSize.x > 0 && rightSize.x > 0) size.x += form.horizontalSpacing;
+        size.x = Math.max(centerSize.x, size.x);
+        size.y = Math.max(leftSize.y, rightSize.y);
+        if (center !is null){
+            size.y += centerSize.y;
+            if (left !is null ||right !is null)size.y += form.verticalSpacing;
+        }   
+    } else {
+        size.x = leftSize.x + centerSize.x + rightSize.x;
+        int count = -1;
+        if (leftSize.x > 0) count++;
+        if (centerSize.x > 0) count++;
+        if (rightSize.x > 0) count++;
+        if (count > 0) size.x += count * form.horizontalSpacing;
+        size.y = Math.max(leftSize.y, Math.max(centerSize.y, rightSize.y));
+    }
+    
+    if (content !is null) {
+        if (left !is null || right !is null || center !is null) size.y += 1; // allow space for a vertical separator
+        Point contentSize = new Point(0, 0);
+        contentSize = computeChildSize(content, DWT.DEFAULT, DWT.DEFAULT, flushCache); 
+        size.x = Math.max (size.x, contentSize.x);
+        size.y += contentSize.y;
+        if (size.y > contentSize.y) size.y += form.verticalSpacing;
+    }
+    
+    size.x += 2*form.marginWidth;
+    size.y += 2*form.marginHeight;
+    
+    if (wHint !is DWT.DEFAULT) size.x  = wHint;
+    if (hHint !is DWT.DEFAULT) size.y = hHint;
+    
+    return size;
+}
+
+Point computeChildSize(Control control, int wHint, int hHint, bool flushCache) {
+    Object data = control.getLayoutData();
+    if (data is null || !(data instanceof CLayoutData)) {
+        data = new CLayoutData();
+        control.setLayoutData(data);
+    }
+    return ((CLayoutData)data).computeSize(control, wHint, hHint, flushCache);
+}
+
+int computeTrim(Control c) {
+    if (c instanceof Scrollable) {
+        Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
+        return rect.width;
+    }
+    return c.getBorderWidth () * 2;
+}
+
+protected bool flushCache(Control control) {
+    Object data = control.getLayoutData();
+    if (data !is null && data instanceof CLayoutData) ((CLayoutData)data).flushCache();
+    return true;
+}
+
+protected void layout(Composite composite, bool flushCache) {
+    ViewForm form = (ViewForm)composite;
+    Control left = form.topLeft;
+    Control center = form.topCenter;
+    Control right = form.topRight;
+    Control content = form.content;
+    
+    Rectangle rect = composite.getClientArea();
+    
+    Point leftSize = new Point(0, 0);
+    if (left !is null && !left.isDisposed()) {
+        leftSize = computeChildSize(left, DWT.DEFAULT, DWT.DEFAULT, flushCache);
+    }
+    Point centerSize = new Point(0, 0);
+    if (center !is null && !center.isDisposed()) {
+         centerSize = computeChildSize(center, DWT.DEFAULT, DWT.DEFAULT, flushCache);
+    }
+    Point rightSize = new Point(0, 0);
+    if (right !is null && !right.isDisposed()) {
+         rightSize = computeChildSize(right, DWT.DEFAULT, DWT.DEFAULT, flushCache);
+    }
+    
+    int minTopWidth = leftSize.x + centerSize.x + rightSize.x + 2*form.marginWidth + 2*form.highlight;
+    int count = -1;
+    if (leftSize.x > 0) count++;
+    if (centerSize.x > 0) count++;
+    if (rightSize.x > 0) count++;
+    if (count > 0) minTopWidth += count * form.horizontalSpacing;
+        
+    int x = rect.x + rect.width - form.marginWidth - form.highlight;
+    int y = rect.y + form.marginHeight + form.highlight;
+    
+    bool top = false;
+    if (form.separateTopCenter || minTopWidth > rect.width) {
+        int topHeight = Math.max(rightSize.y, leftSize.y);
+        if (right !is null && !right.isDisposed()) {
+            top = true;
+            x -= rightSize.x;
+            right.setBounds(x, y, rightSize.x, topHeight);
+            x -= form.horizontalSpacing;
+        }
+        if (left !is null && !left.isDisposed()) {
+            top = true;
+            int trim = computeTrim(left);
+            int leftW = x - rect.x - form.marginWidth - form.highlight - trim;
+            leftSize = computeChildSize(left, leftW, DWT.DEFAULT, false);
+            left.setBounds(rect.x + form.marginWidth + form.highlight, y, leftSize.x, topHeight);
+        }
+        if (top) y += topHeight + form.verticalSpacing;
+        if (center !is null && !center.isDisposed()) {
+            top = true;
+            int trim = computeTrim(center);
+            int w = rect.width - 2*form.marginWidth - 2*form.highlight - trim;
+            centerSize = computeChildSize(center, w, DWT.DEFAULT, false);
+            center.setBounds(rect.x + rect.width - form.marginWidth - form.highlight - centerSize.x, y, centerSize.x, centerSize.y);
+            y += centerSize.y + form.verticalSpacing;
+        }       
+    } else {
+        int topHeight = Math.max(rightSize.y, Math.max(centerSize.y, leftSize.y));
+        if (right !is null && !right.isDisposed()) {
+            top = true;
+            x -= rightSize.x;
+            right.setBounds(x, y, rightSize.x, topHeight);
+            x -= form.horizontalSpacing;
+        }
+        if (center !is null && !center.isDisposed()) {
+            top = true;
+            x -= centerSize.x;
+            center.setBounds(x, y, centerSize.x, topHeight);
+            x -= form.horizontalSpacing;
+        }
+        if (left !is null && !left.isDisposed()) {
+            top = true;
+            Rectangle trim = left instanceof Composite ? ((Composite)left).computeTrim(0, 0, 0, 0) : new Rectangle(0, 0, 0, 0);
+            int w = x - rect.x - form.marginWidth - form.highlight - trim.width;
+            int h = topHeight - trim.height;
+            leftSize = computeChildSize(left, w, h, false);
+            left.setBounds(rect.x + form.marginWidth + form.highlight, y, leftSize.x, topHeight);
+        }
+        if (top)y += topHeight + form.verticalSpacing;
+    }
+    int oldSeperator = form.separator;
+    form.separator = -1;
+    if (content !is null && !content.isDisposed()) {
+        if (left !is null || right!= null || center !is null){
+            form.separator = y;
+            y++;
+        }
+         content.setBounds(rect.x + form.marginWidth + form.highlight, y, rect.width - 2 * form.marginWidth - 2*form.highlight, rect.y + rect.height - y - form.marginHeight - form.highlight);
+    }
+    if (oldSeperator !is -1 && form.separator !is -1) {
+        int t = Math.min(form.separator, oldSeperator);
+        int b = Math.max(form.separator, oldSeperator);
+        form.redraw(form.borderLeft, t, form.getSize().x - form.borderLeft - form.borderRight, b - t, false);
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/ByteArrayTransfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+ 
+/**
+ * The class <code>ByteArrayTransfer</code> provides a platform specific 
+ * mechanism for converting a java <code>byte[]</code> to a platform 
+ * specific representation of the byte array and vice versa.  See 
+ * <code>Transfer</code> for additional information.
+ *
+ * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed 
+ * by transfer agents that convert between data in a java format such as a
+ * <code>String</code> and a platform specific byte array.
+ * 
+ * <p>If the data you are converting <b>does not</b> map to a 
+ * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly 
+ * and do your own mapping to a platform data type.</p>
+ * 
+ * <p>The following snippet shows a subclass of ByteArrayTransfer that transfers
+ * data defined by the class <code>MyType</code>.</p>
+ * 
+ * <pre><code>
+ * public class MyType {
+ *  public String fileName;
+ *  public long fileLength;
+ *  public long lastModified;
+ * }
+ * </code></pre>
+ * 
+ * <pre><code>
+ * public class MyTypeTransfer : ByteArrayTransfer {
+ *  
+ *  private static final String MYTYPENAME = "my_type_name";
+ *  private static final int MYTYPEID = registerType(MYTYPENAME);
+ *  private static MyTypeTransfer _instance = new MyTypeTransfer();
+ * 
+ * private MyTypeTransfer() {}
+ * 
+ * public static MyTypeTransfer getInstance () {
+ *  return _instance;
+ * }
+ * public void javaToNative (Object object, TransferData transferData) {
+ *  if (object is null || !(object instanceof MyType[])) return;
+ *  
+ *  if (isSupportedType(transferData)) {
+ *      MyType[] myTypes = (MyType[]) object;   
+ *      try {
+ *          // write data to a byte array and then ask super to convert to pMedium
+ *          ByteArrayOutputStream out = new ByteArrayOutputStream();
+ *          DataOutputStream writeOut = new DataOutputStream(out);
+ *          for (int i = 0, length = myTypes.length; i &lt; length;  i++){
+ *              byte[] buffer = myTypes[i].fileName.getBytes();
+ *              writeOut.writeInt(buffer.length);
+ *              writeOut.write(buffer);
+ *              writeOut.writeLong(myTypes[i].fileLength);
+ *              writeOut.writeLong(myTypes[i].lastModified);
+ *          }
+ *          byte[] buffer = out.toByteArray();
+ *          writeOut.close();
+ * 
+ *          super.javaToNative(buffer, transferData);
+ *          
+ *      } catch (IOException e) {
+ *      }
+ *  }
+ * }
+ * public Object nativeToJava(TransferData transferData){   
+ * 
+ *  if (isSupportedType(transferData)) {
+ *      
+ *      byte[] buffer = (byte[])super.nativeToJava(transferData);
+ *      if (buffer is null) return null;
+ *      
+ *      MyType[] myData = new MyType[0];
+ *      try {
+ *          ByteArrayInputStream in = new ByteArrayInputStream(buffer);
+ *          DataInputStream readIn = new DataInputStream(in);
+ *          while(readIn.available() > 20) {
+ *              MyType datum = new MyType();
+ *              int size = readIn.readInt();
+ *              byte[] name = new byte[size];
+ *              readIn.read(name);
+ *              datum.fileName = new String(name);
+ *              datum.fileLength = readIn.readLong();
+ *              datum.lastModified = readIn.readLong();
+ *              MyType[] newMyData = new MyType[myData.length + 1];
+ *              System.arraycopy(myData, 0, newMyData, 0, myData.length);
+ *              newMyData[myData.length] = datum;
+ *              myData = newMyData;
+ *          }
+ *          readIn.close();
+ *      } catch (IOException ex) {
+ *          return null;
+ *      }
+ *      return myData;
+ *  }
+ * 
+ *  return null;
+ * }
+ * protected String[] getTypeNames(){
+ *  return new String[]{MYTYPENAME};
+ * }
+ * protected int[] getTypeIds(){
+ *  return new int[] {MYTYPEID};
+ * }
+ * }
+ * </code></pre>
+ */
+public abstract class ByteArrayTransfer : Transfer {
+
+public TransferData[] getSupportedTypes() {
+    int[] types = getTypeIds();
+    TransferData[] data = new TransferData[types.length];
+    for (int i = 0; i < types.length; i++) {
+        data[i] = new TransferData();
+        data[i].type = types[i];
+    }
+    return data;
+}
+
+public bool isSupportedType(TransferData transferData){
+    if (transferData is null) return false;
+    int[] types = getTypeIds();
+    for (int i = 0; i < types.length; i++) {
+        if (transferData.type is types[i]) return true;
+    }
+    return false;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a java 
+ * <code>byte[]</code> to a platform specific representation.  For additional
+ * information see <code>Transfer#javaToNative</code>.
+ * 
+ * @see Transfer#javaToNative
+ * 
+ * @param object a java <code>byte[]</code> containing the data to be converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ *  object will be filled in on return with the platform specific format of the data
+ */
+protected void javaToNative (Object object, TransferData transferData) {
+    if (!checkByteArray(object) && !isSupportedType(transferData)) {
+        DND.error(DND.ERROR_INVALID_DATA);
+    }
+    byte[] orig = (byte[])object;
+    byte[] buffer = new byte[orig.length];
+    System.arraycopy(orig, 0, buffer, 0, orig.length);
+    transferData.data = new byte[1][];
+    transferData.data[0] = buffer;
+    transferData.result = 0;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of a byte array to a java <code>byte[]</code>.   
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ * 
+ * @see Transfer#nativeToJava
+ * 
+ * @param transferData the platform specific representation of the data to be 
+ * been converted
+ * @return a java <code>byte[]</code> containing the converted data if the 
+ * conversion was successful; otherwise null
+ */
+protected Object nativeToJava(TransferData transferData) {
+    if (!isSupportedType(transferData) || transferData.data is null) return null;
+    if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
+    return transferData.data[0];
+}
+bool checkByteArray(Object object) {
+    return (object !is null && object instanceof byte[] && ((byte[])object).length > 0);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/Clipboard.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,567 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+
+import dwt.*;
+import dwt.widgets.*;
+import dwt.internal.cocoa.OS;
+
+/**
+ * The <code>Clipboard</code> provides a mechanism for transferring data from one
+ * application to another or within an application.
+ * 
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ */
+public class Clipboard {
+
+    Display display;
+    int scrap = 0;
+
+/**
+ * Constructs a new instance of this class.  Creating an instance of a Clipboard
+ * may cause system resources to be allocated depending on the platform.  It is therefore
+ * mandatory that the Clipboard instance be disposed when no longer required.
+ *
+ * @param display the display on which to allocate the clipboard
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Clipboard#dispose
+ * @see Clipboard#checkSubclass
+ */
+public Clipboard(Display display) { 
+    checkSubclass ();
+    if (display is null) {
+        display = Display.getCurrent();
+        if (display is null) {
+            display = Display.getDefault();
+        }
+    }
+    if (display.getThread() !is Thread.currentThread()) {
+        DND.error(DWT.ERROR_THREAD_INVALID_ACCESS);
+    }
+    this.display = display;
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The DWT class library is intended to be subclassed 
+ * only at specific, controlled points. This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not 
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between DWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed DWT classes
+ * is intended purely to enable those not on the DWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+    String name = getClass().getName ();
+    String validName = Clipboard.class.getName();
+    if (!validName.opEquals(name)) {
+        DND.error (DWT.ERROR_INVALID_SUBCLASS);
+    }
+}
+/**
+ * Throws an <code>DWTException</code> if the receiver can not
+ * be accessed by the caller. This may include both checks on
+ * the state of the receiver and more generally on the entire
+ * execution context. This method <em>should</em> be called by
+ * widget implementors to enforce the standard DWT invariants.
+ * <p>
+ * Currently, it is an error to invoke any method (other than
+ * <code>isDisposed()</code>) on a widget that has had its 
+ * <code>dispose()</code> method called. It is also an error
+ * to call widget methods from any thread that is different
+ * from the thread that created the widget.
+ * </p><p>
+ * In future releases of DWT, there may be more or fewer error
+ * checks and exceptions may be thrown for different reasons.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+protected void checkWidget () {
+    Display display = this.display;
+    if (display is null) DND.error (DWT.ERROR_WIDGET_DISPOSED);
+    if (display.getThread() !is Thread.currentThread ()) DND.error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    if (display.isDisposed()) DND.error(DWT.ERROR_WIDGET_DISPOSED);
+}
+
+/**
+ * If this clipboard is currently the owner of the data on the system clipboard,
+ * clear the contents.  If this clipboard is not the owner, then nothing is done.
+ * Note that there are clipboard assistant applications that take ownership of 
+ * data or make copies of data when it is placed on the clipboard.  In these 
+ * cases, it may not be possible to clear the clipboard.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void clearContents() {
+    clearContents(DND.CLIPBOARD);
+}
+
+/**
+ * If this clipboard is currently the owner of the data on the specified 
+ * clipboard, clear the contents.  If this clipboard is not the owner, then 
+ * nothing is done.
+ * 
+ * <p>Note that there are clipboard assistant applications that take ownership
+ * of data or make copies of data when it is placed on the clipboard.  In these 
+ * cases, it may not be possible to clear the clipboard.</p>
+ * 
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * @param clipboards to be cleared
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public void clearContents(int clipboards) {
+    checkWidget();
+    if ((clipboards & DND.CLIPBOARD) is 0 || scrap is 0) return;
+    int oldScrap = scrap;
+    scrap = 0;
+    int[] currentScrap = new int[1];
+    if (OS.GetCurrentScrap(currentScrap) !is OS.noErr) return;
+    if (currentScrap[0] is oldScrap) {
+        OS.ClearCurrentScrap();
+    }
+}
+
+/**
+ * Disposes of the operating system resources associated with the clipboard. 
+ * The data will still be available on the system clipboard after the dispose 
+ * method is called.  
+ * 
+ * <p>NOTE: On some platforms the data will not be available once the application
+ * has exited or the display has been disposed.</p>
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+public void dispose () {
+    if (isDisposed()) return;
+    if (display.getThread() !is Thread.currentThread()) DND.error(DWT.ERROR_THREAD_INVALID_ACCESS);
+    display = null;
+}
+
+/**
+ * Retrieve the data of the specified type currently available on the system 
+ * clipboard.  Refer to the specific subclass of <code>Transfer</code> to 
+ * determine the type of object returned.
+ * 
+ * <p>The following snippet shows text and RTF text being retrieved from the 
+ * clipboard:</p>
+ * 
+ *    <code><pre>
+ *    Clipboard clipboard = new Clipboard(display);
+ *    TextTransfer textTransfer = TextTransfer.getInstance();
+ *    String textData = (String)clipboard.getContents(textTransfer);
+ *    if (textData !is null) System.out.println("Text is "+textData);
+ *    RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *    String rtfData = (String)clipboard.getContents(rtfTransfer);
+ *    if (rtfData !is null) System.out.println("RTF Text is "+rtfData);
+ *    clipboard.dispose();
+ *    </code></pre>
+ * 
+ * @param transfer the transfer agent for the type of data being requested
+ * @return the data obtained from the clipboard or null if no data of this type is available
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if transfer is null</li>
+ * </ul>
+ * 
+ * @see Transfer
+ */
+public Object getContents(Transfer transfer) {
+    return getContents(transfer, DND.CLIPBOARD);
+}
+
+/**
+ * Retrieve the data of the specified type currently available on the specified 
+ * clipboard.  Refer to the specific subclass of <code>Transfer</code> to 
+ * determine the type of object returned.
+ * 
+ * <p>The following snippet shows text and RTF text being retrieved from the 
+ * clipboard:</p>
+ * 
+ *    <code><pre>
+ *    Clipboard clipboard = new Clipboard(display);
+ *    TextTransfer textTransfer = TextTransfer.getInstance();
+ *    String textData = (String)clipboard.getContents(textTransfer);
+ *    if (textData !is null) System.out.println("Text is "+textData);
+ *    RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *    String rtfData = (String)clipboard.getContents(rtfTransfer, DND.CLIPBOARD);
+ *    if (rtfData !is null) System.out.println("RTF Text is "+rtfData);
+ *    clipboard.dispose();
+ *    </code></pre>
+ * 
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * @param transfer the transfer agent for the type of data being requested
+ * @param clipboards on which to look for data
+ *  
+ * @return the data obtained from the clipboard or null if no data of this type is available
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if transfer is null</li>
+ * </ul>
+ * 
+ * @see Transfer
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public Object getContents(Transfer transfer, int clipboards) {
+    checkWidget();
+    if (transfer is null) DND.error(DWT.ERROR_NULL_ARGUMENT);
+    if ((clipboards & DND.CLIPBOARD) is 0) return null;
+    int[] scrap = new int[1];
+    if (OS.GetCurrentScrap(scrap) !is OS.noErr) return null;
+    int[] typeIds = transfer.getTypeIds();
+    int[] size = new int[1];    
+    // get data from system clipboard
+    for (int i=0; i<typeIds.length; i++) {
+        int type = typeIds[i];
+        size[0] = 0;
+        if (OS.GetScrapFlavorSize(scrap[0], type, size) is OS.noErr && size[0] > 0) {
+            byte[] buffer = new byte[size[0]];
+            if (OS.GetScrapFlavorData(scrap[0], type, size, buffer) is OS.noErr) {
+                TransferData tdata = new TransferData();
+                tdata.type = type;      
+                tdata.data = new byte[1][];
+                tdata.data[0] = buffer;
+                return transfer.nativeToJava(tdata);
+            }
+        }
+    }
+    return null;    // No data available for this transfer
+}
+
+/**
+ * Returns <code>true</code> if the clipboard has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the clipboard.
+ * When a clipboard has been disposed, it is an error to
+ * invoke any other method using the clipboard.
+ * </p>
+ *
+ * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
+ * 
+ * @since 3.0
+ */
+public bool isDisposed () {
+    return (display is null);
+}
+
+/**
+ * Place data of the specified type on the system clipboard.  More than one type
+ * of data can be placed on the system clipboard at the same time.  Setting the
+ * data clears any previous data from the system clipboard, regardless of type.
+ * 
+ * <p>NOTE: On some platforms, the data is immediately copied to the system
+ * clipboard but on other platforms it is provided upon request.  As a result,
+ * if the application modifies the data object it has set on the clipboard, that 
+ * modification may or may not be available when the data is subsequently 
+ * requested.</p>
+ *
+ * <p>The following snippet shows text and RTF text being set on the copy/paste
+ * clipboard:
+ * </p>
+ * 
+ * <code><pre>
+ *  Clipboard clipboard = new Clipboard(display);
+ *  String textData = "Hello World";
+ *  String rtfData = "{\\rtf1\\b\\i Hello World}";
+ *  TextTransfer textTransfer = TextTransfer.getInstance();
+ *  RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *  Transfer[] transfers = new Transfer[]{textTransfer, rtfTransfer};
+ *  Object[] data = new Object[]{textData, rtfData};
+ *  clipboard.setContents(data, transfers);
+ *  clipboard.dispose();
+ * </code></pre>
+ *
+ * @param data the data to be set in the clipboard
+ * @param dataTypes the transfer agents that will convert the data to its 
+ * platform specific format; each entry in the data array must have a 
+ * corresponding dataType
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if data is null or datatypes is null 
+ *          or the length of data is not the same as the length of dataTypes</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  @exception DWTError <ul>
+ *    <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or otherwise unavailable</li>
+ * </ul>
+ * 
+ * <p>NOTE: ERROR_CANNOT_SET_CLIPBOARD should be an DWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ */
+public void setContents(Object[] data, Transfer[] dataTypes) {
+    setContents(data, dataTypes, DND.CLIPBOARD);
+}
+
+/**
+ * Place data of the specified type on the specified clipboard.  More than one 
+ * type of data can be placed on the specified clipboard at the same time.
+ * Setting the data clears any previous data from the specified
+ * clipboard, regardless of type.
+ * 
+ * <p>NOTE: On some platforms, the data is immediately copied to the specified
+ * clipboard but on other platforms it is provided upon request.  As a result, 
+ * if the application modifies the data object it has set on the clipboard, that 
+ * modification may or may not be available when the data is subsequently 
+ * requested.</p>
+ *
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * <p>The following snippet shows text and RTF text being set on the copy/paste
+ * clipboard:
+ * </p>
+ * 
+ * <code><pre>
+ *  Clipboard clipboard = new Clipboard(display);
+ *  String textData = "Hello World";
+ *  String rtfData = "{\\rtf1\\b\\i Hello World}";
+ *  TextTransfer textTransfer = TextTransfer.getInstance();
+ *  RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *  Transfer[] transfers = new Transfer[]{textTransfer, rtfTransfer};
+ *  Object[] data = new Object[]{textData, rtfData};
+ *  clipboard.setContents(data, transfers, DND.CLIPBOARD);
+ *  clipboard.dispose();
+ * </code></pre>
+ *
+ * @param data the data to be set in the clipboard
+ * @param dataTypes the transfer agents that will convert the data to its 
+ * platform specific format; each entry in the data array must have a 
+ * corresponding dataType
+ * @param clipboards on which to set the data
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if data is null or datatypes is null 
+ *          or the length of data is not the same as the length of dataTypes</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  @exception DWTError <ul>
+ *    <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or otherwise unavailable</li>
+ * </ul>
+ * 
+ * <p>NOTE: ERROR_CANNOT_SET_CLIPBOARD should be an DWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ * 
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public void setContents(Object[] data, Transfer[] dataTypes, int clipboards) {
+    checkWidget();
+    if (data is null || dataTypes is null || data.length !is dataTypes.length || data.length is 0) {
+        DND.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    for (int i = 0; i < data.length; i++) {
+        if (data[i] is null || dataTypes[i] is null || !dataTypes[i].validate(data[i])) {
+            DND.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+    if ((clipboards & DND.CLIPBOARD) is 0) return;
+    if (OS.ClearCurrentScrap() !is OS.noErr) {
+        DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+    }
+    scrap = 0;
+    int[] currentScrap = new int[1];
+    if (OS.GetCurrentScrap(currentScrap) !is OS.noErr) {
+        DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+    }
+    scrap = currentScrap[0];
+    // copy data directly over to System clipboard (not deferred)
+    for (int i=0; i<dataTypes.length; i++) {
+        int[] typeIds = dataTypes[i].getTypeIds();
+        for (int j=0; j<typeIds.length; j++) {
+            TransferData transferData = new TransferData();
+            transferData.type = typeIds[j];
+            dataTypes[i].javaToNative(data[i], transferData); 
+            if (transferData.result !is OS.noErr) {
+                DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+            }
+            //Drag and Drop can handle multiple items in one transfer but the
+            //Clipboard can not.
+            byte[] datum = transferData.data[0];
+            if (OS.PutScrapFlavor(scrap, transferData.type, 0, datum.length, datum) !is OS.noErr){
+                DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+            }
+        }
+    }
+}
+
+/**
+ * Returns an array of the data types currently available on the system 
+ * clipboard. Use with Transfer.isSupportedType.
+ *
+ * @return array of data types currently available on the system clipboard
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Transfer#isSupportedType
+ * 
+ * @since 3.0
+ */
+public TransferData[] getAvailableTypes() {
+    return getAvailableTypes(DND.CLIPBOARD);
+}
+
+/**
+ * Returns an array of the data types currently available on the specified 
+ * clipboard. Use with Transfer.isSupportedType.
+ * 
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * @param clipboards from which to get the data types
+ * @return array of data types currently available on the specified clipboard
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Transfer#isSupportedType
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public TransferData[] getAvailableTypes(int clipboards) {
+    checkWidget();
+    if ((clipboards & DND.CLIPBOARD) is 0) return new TransferData[0]; 
+    int[] types = _getAvailableTypes();
+    TransferData[] result = new TransferData[types.length];
+    for (int i = 0; i < types.length; i++) {
+        result[i] = new TransferData();
+        result[i].type = types[i];
+    }
+    return result;
+}
+
+/**
+ * Returns a platform specific list of the data types currently available on the 
+ * system clipboard.
+ * 
+ * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer 
+ * sub-class.  It should NOT be used within an application because it provides 
+ * platform specific information.</p>
+ * 
+ * @return a platform specific list of the data types currently available on the 
+ * system clipboard
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String[] getAvailableTypeNames() {
+    checkWidget();
+    int[] types = _getAvailableTypes();
+    String[] names = new String[types.length];
+    for (int i = 0; i < types.length; i++) {
+        int type = types[i];
+        StringBuffer sb = new StringBuffer();
+        sb.append((char)((type & 0xff000000) >> 24));
+        sb.append((char)((type & 0x00ff0000) >> 16));
+        sb.append((char)((type & 0x0000ff00) >> 8));
+        sb.append((char)((type & 0x000000ff) >> 0));
+        names[i] = sb.toString();
+    }
+    return names;
+}
+
+int[] _getAvailableTypes() {
+    int[] types = new int[0];
+    int[] scrap = new int[1];
+    if (OS.GetCurrentScrap(scrap) !is OS.noErr) return types;
+    int[] count = new int[1];
+    if (OS.GetScrapFlavorCount(scrap[0], count) !is OS.noErr || count[0] is 0) return types;
+    int[] info = new int[count[0] * 2];
+    if (OS.GetScrapFlavorInfoList(scrap[0], count, info) !is OS.noErr) return types;
+    types = new int[count[0]];
+    for (int i= 0; i < count [0]; i++) {
+        types[i] = info[i*2];
+    }
+    return types;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DND.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+ 
+import dwt.*;
+
+/**
+ *
+ * Class DND contains all the constants used in defining a 
+ * DragSource or a DropTarget.
+ *
+ */
+public class DND {
+    
+    /**
+     * The transfer mechanism for data that is being cut
+     * and then pasted or copied and then pasted (value is 1).
+     * 
+     * @see Clipboard
+     * 
+     * @since 3.1
+     */
+    public final static int CLIPBOARD = 1 << 0;
+    
+    /**
+     * The transfer mechanism for clients that use the selection 
+     * mechanism (value is 2).
+     * 
+     * @see Clipboard
+     *
+     * @since 3.1
+     */
+    public final static int SELECTION_CLIPBOARD = 1 << 1;
+
+    /**
+     * Drag and Drop Operation: no drag/drop operation performed
+     * (value is 0).
+     */
+    public final static int DROP_NONE = 0;
+    
+    /**
+     * Drag and Drop Operation: a copy of the data in the drag source is 
+     * added to the drop target (value is 1 &lt;&lt; 0).
+     */
+    public final static int DROP_COPY = 1 << 0;
+    
+    /**
+     * Drag and Drop Operation: a copy of the data is added to the drop target and 
+     * the original data is removed from the drag source (value is 1 &lt;&lt; 1).
+     */
+    public final static int DROP_MOVE = 1 << 1;
+    
+    /**
+     * Drag and Drop Operation: the drop target makes a link to the data in 
+     * the drag source (value is 1 &lt;&lt; 2).
+     */
+    public final static int DROP_LINK = 1 << 2;
+    
+    /**
+     * Drag and Drop Operation: the drop target moves the data and the drag source removes 
+     * any references to the data and updates its display.  This is not available on all platforms
+     * and is only used when a non-DWT application is the drop target.  In this case, the DWT 
+     * drag source is informed in the dragFinished event that the drop target has moved the data.
+     * (value is 1 &lt;&lt; 3).
+     * 
+     * @see DragSourceListener#dragFinished
+     */
+    public final static int DROP_TARGET_MOVE = 1 << 3;
+    
+    /**
+     * Drag and Drop Operation: During a dragEnter event or a dragOperationChanged, if no modifier keys
+     * are pressed, the operation is set to DROP_DEFAULT.  The application can choose what the default 
+     * operation should be by setting a new value in the operation field.  If no value is choosen, the
+     * default operation for the platform will be selected (value is 1 &lt;&lt; 4).
+     * 
+     * @see DropTargetListener#dragEnter
+     * @see DropTargetListener#dragOperationChanged
+     * @since 2.0 
+     */
+    public final static int DROP_DEFAULT = 1 << 4;
+    
+    /**
+     * DragSource Event: the drop has successfully completed or has been terminated (such as hitting 
+     * the ESC key); perform cleanup such as removing data on a move operation (value is 2000).
+     */
+    public static final int DragEnd     = 2000;
+    
+    /**
+     * DragSource Event: the data to be dropped is required from the drag source (value is 2001).
+     */
+    public static final int DragSetData = 2001;
+    
+    /**
+     * DropTarget Event: the cursor has entered the drop target boundaries (value is 2002).
+     */
+    public static final int DragEnter   = 2002;
+    
+    /**
+     * DropTarget Event: the cursor has left the drop target boundaries OR the drop
+     * operation has been cancelled (such as by hitting ECS) OR the drop is about to 
+     * happen (user has released the mouse button over this target) (value is 2003).
+     */
+    public static final int DragLeave   = 2003;
+    
+    /**
+     * DropTarget Event: the cursor is over the drop target (value is 2004).
+     */
+    public static final int DragOver    = 2004;
+    
+    /**
+     * DropTarget Event: the operation being performed has changed usually due to the user 
+     * changing the selected modifier keys while dragging (value is 2005).
+     */
+    public static final int DragOperationChanged = 2005;
+    
+    /**
+     * DropTarget Event: the data has been dropped (value is 2006).
+     */
+    public static final int Drop = 2006;
+    
+    /**
+     * DropTarget Event: the drop target is given a last chance to modify the drop (value is 2007).
+     */
+    public static final int DropAccept  = 2007;
+    
+    /**
+     * DragSource Event: a drag is about to begin (value is 2008).
+     */
+    public static final int DragStart = 2008;
+
+    /**
+     * DropTarget drag under effect: No effect is shown (value is 0).
+     */
+    public static final int FEEDBACK_NONE = 0;
+    
+    /**
+     * DropTarget drag under effect: The item under the cursor is selected; applies to tables
+     * and trees (value is 1).
+     */
+    public static final int FEEDBACK_SELECT = 1;
+    
+    /**
+     * DropTarget drag under effect: An insertion mark is shown before the item under the cursor; applies to 
+     * trees (value is 2).
+     */
+    public static final int FEEDBACK_INSERT_BEFORE = 2;
+    
+    /**
+     * DropTarget drag under effect:An insertion mark is shown after the item under the cursor; applies to
+     * trees (value is 4).
+     */ 
+    public static final int FEEDBACK_INSERT_AFTER = 4;
+    
+    /**
+     * DropTarget drag under effect: The widget is scrolled up or down to allow the user to drop on items that 
+     * are not currently visible;  applies to tables and trees (value is 8).
+     */ 
+    public static final int FEEDBACK_SCROLL = 8;
+    
+    /**
+     * DropTarget drag under effect: The item currently under the cursor is expanded to allow the user to 
+     * select a drop target from a sub item; applies to trees (value is 16).
+     */ 
+    public static final int FEEDBACK_EXPAND = 16;
+
+    /**
+     * Error code: drag source can not be initialized (value is 2000).
+     */
+    public static final int ERROR_CANNOT_INIT_DRAG = 2000;
+    
+    /**
+     * Error code: drop target cannot be initialized (value is 2001).
+     */
+    public static final int ERROR_CANNOT_INIT_DROP = 2001;
+    
+    /**
+     * Error code: Data can not be set on system clipboard (value is 2002).
+     */
+    public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
+    
+    /**
+     * Error code: Data does not have correct format for type (value is 2003).
+     * @since 3.1
+     */
+    public static final int ERROR_INVALID_DATA = 2003;
+    
+    /**
+     * DropTarget Key: The String constant for looking up the drop target 
+     * for a control using <code>getData(String)</code>. When a drop target 
+     * is created for a control, it is stored as a property in the control 
+     * using <code>setData(String, Object)</code>.
+     * 
+     * @since 3.4
+     */
+    public static final String DROP_TARGET_KEY = "DropTarget"; //$NON-NLS-1$
+    
+    /**
+     * DragSource Key: The String constant for looking up the drag source 
+     * for a control using <code>getData(String)</code>. When a drag source 
+     * is created for a control, it is stored as a property in the control 
+     * using <code>setData(String, Object)</code>.
+     * 
+     * @since 3.4
+     */
+    public static final String DRAG_SOURCE_KEY = "DragSource"; //$NON-NLS-1$
+
+    static final String INIT_DRAG_MESSAGE = "Cannot initialize Drag"; //$NON-NLS-1$
+    static final String INIT_DROP_MESSAGE = "Cannot initialize Drop"; //$NON-NLS-1$
+    static final String CANNOT_SET_CLIPBOARD_MESSAGE = "Cannot set data in clipboard"; //$NON-NLS-1$
+    static final String INVALID_DATA_MESSAGE = "Data does not have correct format for type"; //$NON-NLS-1$
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ *
+ * @param code the DND error code
+ */
+public static void error (int code) {
+    error (code, 0);
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ * The <code>hresult</code> argument should be either 0, or the
+ * platform specific error code.
+ * <p>
+ * In DND, errors are reported by throwing one of three exceptions:
+ * <dl>
+ * <dd>java.lang.IllegalArgumentException</dd>
+ * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+ * <dd>dwt.DWTException (: java.lang.RuntimeException)</dd>
+ * <dt>thrown whenever a recoverable error happens internally in DWT</dt>
+ * <dd>dwt.DWTError (: java.lang.Error)</dd>
+ * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in DWT</dt>
+ * </dl>
+ * This method provides the logic which maps between error codes
+ * and one of the above exceptions.
+ * </p>
+ *
+ * @param code the DND error code.
+ * @param hresult the platform specific error code.
+ *
+ * @see DWTError
+ * @see DWTException
+ * @see IllegalArgumentException
+ */
+public static void error (int code, int hresult) {      
+    switch (code) {     
+        /* OS Failure/Limit (fatal, may occur only on some platforms) */
+        case DND.ERROR_CANNOT_INIT_DRAG:{
+            String msg = DND.INIT_DRAG_MESSAGE;
+            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            throw new DWTError (code, msg);
+        }
+        case DND.ERROR_CANNOT_INIT_DROP:{
+            String msg = DND.INIT_DROP_MESSAGE;
+            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            throw new DWTError (code, msg);
+        }
+        case DND.ERROR_CANNOT_SET_CLIPBOARD:{
+            String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
+            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            throw new DWTError (code, msg);
+        }
+        case DND.ERROR_INVALID_DATA:{
+            String msg = DND.INVALID_DATA_MESSAGE;
+            if (hresult !is 0) msg += " result = "+hresult; //$NON-NLS-1$
+            throw new DWTException (code, msg);
+        }
+    }
+            
+    /* Unknown/Undefined Error */
+    DWT.error(code);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DNDEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+class DNDEvent : Event {
+    public TransferData dataType;
+    public TransferData[] dataTypes;
+    public int operations;
+    public int feedback;
+    public Image image;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DNDListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.internal.*;
+import dwt.widgets.*;
+
+
+class DNDListener : TypedListener {
+    Widget dndWidget;
+/**
+ * DNDListener constructor comment.
+ * @param listener dwt.internal.DWTEventListener
+ */
+DNDListener(DWTEventListener listener) {
+    super(listener);
+}
+public void handleEvent (Event e) {
+    switch (e.type) {
+        case DND.DragStart: {
+            DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+            DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
+            if (sourceEffect !is null) {
+                sourceEffect.dragStart (event);
+            }
+            ((DragSourceListener) eventListener).dragStart (event);
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.DragEnd: {
+            DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+            DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
+            if (sourceEffect !is null) {
+                sourceEffect.dragFinished (event);
+            }
+            ((DragSourceListener) eventListener).dragFinished (event);
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.DragSetData: {
+            DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+            DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
+            if (sourceEffect !is null) {
+                sourceEffect.dragSetData (event);
+            }
+            ((DragSourceListener) eventListener).dragSetData (event);
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.DragEnter: {
+            DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+            ((DropTargetListener) eventListener).dragEnter (event);
+            DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+            if (dropEffect !is null) {
+                dropEffect.dragEnter (event);
+            }
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.DragLeave: {
+            DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+            ((DropTargetListener) eventListener).dragLeave (event);
+            DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+            if (dropEffect !is null) {
+                dropEffect.dragLeave (event);
+            }
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.DragOver: {
+            DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+            ((DropTargetListener) eventListener).dragOver (event);
+            DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+            if (dropEffect !is null) {
+                dropEffect.dragOver (event);
+            }
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.Drop: {
+            DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+            ((DropTargetListener) eventListener).drop (event);
+            DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+            if (dropEffect !is null) {
+                dropEffect.drop (event);
+            }
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.DropAccept: {
+            DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+            ((DropTargetListener) eventListener).dropAccept (event);
+            DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+            if (dropEffect !is null) {
+                dropEffect.dropAccept (event);
+            }
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        case DND.DragOperationChanged: {
+            DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+            ((DropTargetListener) eventListener).dragOperationChanged (event);
+            DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+            if (dropEffect !is null) {
+                dropEffect.dragOperationChanged (event);
+            }
+            event.updateEvent((DNDEvent)e);
+            break;
+        }
+        
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DragSource.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,556 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+ 
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+import dwt.internal.Callback;
+import dwt.internal.cocoa.CGPoint;
+import dwt.internal.cocoa.EventRecord;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.Point;
+
+/**
+ *
+ * <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ *  
+ * <p>A drag source is the object which originates a drag and drop operation. For the specified widget, 
+ * it defines the type of data that is available for dragging and the set of operations that can 
+ * be performed on that data.  The operations can be any bit-wise combination of DND.MOVE, DND.COPY or 
+ * DND.LINK.  The type of data that can be transferred is specified by subclasses of Transfer such as 
+ * TextTransfer or FileTransfer.  The type of data transferred can be a predefined system type or it 
+ * can be a type defined by the application.  For instructions on how to define your own transfer type,
+ * refer to <code>ByteArrayTransfer</code>.</p>
+ *
+ * <p>You may have several DragSources in an application but you can only have one DragSource 
+ * per Control.  Data dragged from this DragSource can be dropped on a site within this application 
+ * or it can be dropped on another application such as an external Text editor.</p>
+ * 
+ * <p>The application supplies the content of the data being transferred by implementing the
+ * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
+ * 
+ * <p>When a successful move operation occurs, the application is required to take the appropriate 
+ * action to remove the data from its display and remove any associated operating system resources or
+ * internal references.  Typically in a move operation, the drop target makes a copy of the data 
+ * and the drag source deletes the original.  However, sometimes copying the data can take a long 
+ * time (such as copying a large file).  Therefore, on some platforms, the drop target may actually 
+ * move the data in the operating system rather than make a copy.  This is usually only done in 
+ * file transfers.  In this case, the drag source is informed in the DragEnd event that a
+ * DROP_TARGET_MOVE was performed.  It is the responsibility of the drag source at this point to clean 
+ * up its displayed information.  No action needs to be taken on the operating system resources.</p>
+ *
+ * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
+ * 
+ * <code><pre>
+ *  // Enable a label as a Drag Source
+ *  Label label = new Label(shell, DWT.NONE);
+ *  // This example will allow text to be dragged
+ *  Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ *  // This example will allow the text to be copied or moved to the drop target
+ *  int operations = DND.DROP_MOVE | DND.DROP_COPY;
+ *  
+ *  DragSource source = new DragSource(label, operations);
+ *  source.setTransfer(types);
+ *  source.addDragListener(new DragSourceListener() {
+ *      public void dragStart(DragSourceEvent e) {
+ *          // Only start the drag if there is actually text in the
+ *          // label - this text will be what is dropped on the target.
+ *          if (label.getText().length() is 0) {
+ *              event.doit = false;
+ *          }
+ *      };
+ *      public void dragSetData(DragSourceEvent event) {
+ *          // A drop has been performed, so provide the data of the 
+ *          // requested type.
+ *          // (Checking the type of the requested data is only 
+ *          // necessary if the drag source supports more than 
+ *          // one data type but is shown here as an example).
+ *          if (TextTransfer.getInstance().isSupportedType(event.dataType)){
+ *              event.data = label.getText();
+ *          }
+ *      }
+ *      public void dragFinished(DragSourceEvent event) {
+ *          // A Move operation has been performed so remove the data
+ *          // from the source
+ *          if (event.detail is DND.DROP_MOVE)
+ *              label.setText("");
+ *      }
+ *  });
+ * </pre></code>
+ *
+ *
+ * <dl>
+ *  <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ *  <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
+ * </dl>
+ */
+public class DragSource : Widget {
+
+    // info for registering as a drag source
+    Control control;
+    Listener controlListener;
+    Transfer[] transferAgents = new Transfer[0];
+    DragSourceEffect dragEffect;
+
+    static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
+    static Callback DragSendDataProc;
+    
+    static {
+        DragSendDataProc = new Callback(DragSource.class, "DragSendDataProc", 4); //$NON-NLS-1$
+        int dragSendDataProcAddress = DragSendDataProc.getAddress();
+        if (dragSendDataProcAddress is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+    }
+
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.  
+ * It is therefore mandatory that the DragSource instance be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> that the user clicks on to initiate the drag
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of 
+ *                  DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_CANNOT_INIT_DRAG - unable to initiate drag source; this will occur if more than one
+ *        drag source is created for a control or if the operating system will not allow the creation
+ *        of the drag source</li>
+ * </ul>
+ * 
+ * <p>NOTE: ERROR_CANNOT_INIT_DRAG should be an DWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ * 
+ * @see Widget#dispose
+ * @see DragSource#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DragSource(Control control, int style) {
+    super (control, checkStyle(style));
+    this.control = control;
+    if (control.getData(DND.DRAG_SOURCE_KEY) !is null) {
+        DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+    }
+    control.setData(DND.DRAG_SOURCE_KEY, this);
+    
+    controlListener = new Listener () {
+        public void handleEvent (Event event) {
+            if (event.type is DWT.Dispose) {
+                if (!DragSource.this.isDisposed()) {
+                    DragSource.this.dispose();
+                }
+            }
+            if (event.type is DWT.DragDetect) {
+                if (!DragSource.this.isDisposed()) {
+                    DragSource.this.drag(event);
+                }
+            }
+        }
+    };
+    control.addListener (DWT.Dispose, controlListener);
+    control.addListener (DWT.DragDetect, controlListener);
+    
+    this.addListener(DWT.Dispose, new Listener() {
+        public void handleEvent(Event e) {
+            onDispose();
+        }
+    });
+    
+    Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT);
+    if (effect instanceof DragSourceEffect) {
+        dragEffect = (DragSourceEffect) effect;
+    } else if (control instanceof Tree) {
+        dragEffect = new TreeDragSourceEffect((Tree) control);
+    } else if (control instanceof Table) {
+        dragEffect = new TableDragSourceEffect((Table) control);
+    }
+}
+
+static int checkStyle (int style) {
+    if (style is DWT.NONE) return DND.DROP_MOVE;
+    return style;
+}
+
+static int DragSendDataProc(int theType, int dragSendRefCon, int theItemRef, int theDrag) {
+    DragSource source = FindDragSource(dragSendRefCon, theDrag);
+    if (source is null) return OS.cantGetFlavorErr;
+    return source.dragSendDataProc(theType, dragSendRefCon, theItemRef, theDrag);
+}
+
+static DragSource FindDragSource(int dragSendRefCon, int theDrag) {
+    if (dragSendRefCon is 0) return null;
+    Display display = Display.findDisplay(Thread.currentThread());
+    if (display is null || display.isDisposed()) return null;
+    Widget widget = display.findWidget(dragSendRefCon);
+    if (widget is null) return null;
+    return (DragSource)widget.getData(DND.DRAG_SOURCE_KEY); 
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DragSourceListener</code>
+ * interface.
+ * 
+ * <p><ul>
+ * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget. 
+ * This event gives the application the chance to decide if a drag should be started.
+ * <li><code>dragSetData</code> is called when the data is required from the drag source.
+ * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up 
+ * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup 
+ * such as removing data from the source side on a successful move operation.
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #removeDragListener
+ * @see DragSourceEvent
+ */
+public void addDragListener(DragSourceListener listener) {
+    if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
+    DNDListener typedListener = new DNDListener (listener);
+    typedListener.dndWidget = this;
+    addListener (DND.DragStart, typedListener);
+    addListener (DND.DragSetData, typedListener);
+    addListener (DND.DragEnd, typedListener);
+}
+
+protected void checkSubclass () {
+    String name = getClass().getName ();
+    String validName = DragSource.class.getName();
+    if (!validName.opEquals(name)) {
+        DND.error (DWT.ERROR_INVALID_SUBCLASS);
+    }
+}
+
+void drag(Event dragEvent) {
+    DNDEvent event = new DNDEvent();
+    event.widget = this;
+    event.x = dragEvent.x;
+    event.y = dragEvent.y;
+    event.time = dragEvent.time;
+    event.doit = true;
+    notifyListeners(DND.DragStart, event);
+    if (!event.doit || transferAgents is null || transferAgents.length is 0) return;
+    
+    int[] theDrag = new int[1];
+    if (OS.NewDrag(theDrag) !is OS.noErr) {
+        event = new DNDEvent();
+        event.widget = this;
+        event.time = (int)System.currentTimeMillis();
+        event.doit = false;
+        event.detail = DND.DROP_NONE; 
+        notifyListeners(DND.DragEnd, event);
+        return;
+    }
+    
+    Point pt = new Point();
+    OS.GetGlobalMouse (pt);
+
+    for (int i = 0; i < transferAgents.length; i++) {
+        Transfer transfer = transferAgents[i];
+        if (transfer !is null) {
+            int[] types = transfer.getTypeIds();
+            if (transfer instanceof FileTransfer) {
+                TransferData transferData = new TransferData();
+                transferData.type = types[0];
+                DNDEvent event2 = new DNDEvent();
+                event2.widget = this;
+                event2.time = (int)System.currentTimeMillis(); 
+                event2.dataType = transferData; 
+                notifyListeners(DND.DragSetData, event2);
+                if (event2.data !is null) {
+                    for (int j = 0; j < types.length; j++) {
+                        transferData.type = types[j];
+                        transfer.javaToNative(event2.data, transferData);
+                        if (transferData.result is OS.noErr) {
+                            for (int k = 0; k < transferData.data.length; k++) {
+                                byte[] datum = transferData.data[k];
+                                OS.AddDragItemFlavor(theDrag[0], 1 + k, types[j], datum, datum.length, 0);
+                            }
+                        }
+                    }
+                }
+            } else {
+                for (int j = 0; j < types.length; j++) {
+                    OS.AddDragItemFlavor(theDrag[0], 1, types[j], null, 0, 0);  
+                }   
+            }
+        }
+    }
+    
+    OS.SetDragSendProc(theDrag[0], DragSendDataProc.getAddress(), control.handle);
+    
+    int theRegion = 0;
+    Image newImage = null;
+    try {   
+        theRegion = OS.NewRgn();
+        OS.SetRectRgn(theRegion, (short)(pt.h), (short)(pt.v), (short)(pt.h+20), (short)(pt.v+20));
+        
+        int operations = opToOsOp(getStyle());
+        //set operations twice - local and not local
+        OS.SetDragAllowableActions(theDrag[0], operations, true);
+        OS.SetDragAllowableActions(theDrag[0], operations, false);
+        
+        Image image = event.image;
+        if (image !is null) {
+            CGPoint imageOffsetPt = new CGPoint();
+            imageOffsetPt.x = 0;
+            imageOffsetPt.y = 0;
+            /*
+            * Bug in the Macintosh.  For  some reason, it seems that SetDragImageWithCGImage() 
+            * expects an image with the alpha, otherwise the image does not draw.  The fix is
+            * to make sure that the image has an alpha by creating a new image with alpha
+            * when necessary.
+            */
+            if (OS.CGImageGetAlphaInfo(image.handle) is OS.kCGImageAlphaNoneSkipFirst) {
+                ImageData data = image.getImageData();
+                data.alpha = 0xFF;
+                newImage = new Image(image.getDevice(), data);
+                image = newImage;
+            }
+            OS.SetDragImageWithCGImage(theDrag[0], image.handle, imageOffsetPt, 0);
+        }
+        EventRecord theEvent = new EventRecord();
+        theEvent.message = OS.kEventMouseMoved;
+        theEvent.modifiers = (short)OS.GetCurrentEventKeyModifiers();
+        theEvent.what = (short)OS.osEvt;
+        theEvent.where_h = pt.h;
+        theEvent.where_v = pt.v;    
+        int result = OS.TrackDrag(theDrag[0], theEvent, theRegion);
+        int operation = DND.DROP_NONE;
+        if (result is OS.noErr) { 
+            int[] outAction = new int[1];
+            OS.GetDragDropAction(theDrag[0], outAction);
+            operation = osOpToOp(outAction[0]);
+        }   
+        event = new DNDEvent();
+        event.widget = this;
+        event.time = (int)System.currentTimeMillis();
+        event.doit = result is OS.noErr;
+        event.detail = operation; 
+        notifyListeners(DND.DragEnd, event);
+    } finally { 
+        if (theRegion !is 0) OS.DisposeRgn(theRegion);
+        if (newImage !is null) newImage.dispose();
+    }
+    OS.DisposeDrag(theDrag[0]);
+}
+
+int dragSendDataProc(int theType, int dragSendRefCon, int theItemRef, int theDrag) {
+    if (theType is 0) return OS.badDragFlavorErr;
+    TransferData transferData = new TransferData();
+    transferData.type = theType;
+    DNDEvent event = new DNDEvent();
+    event.widget = this;
+    event.time = (int)System.currentTimeMillis(); 
+    event.dataType = transferData; 
+    notifyListeners(DND.DragSetData, event);
+    Transfer transfer = null;
+    for (int i = 0; i < transferAgents.length; i++) {
+        Transfer transferAgent = transferAgents[i];
+        if (transferAgent !is null && transferAgent.isSupportedType(transferData)) {
+            transfer = transferAgent;
+            break;
+        }
+    }
+    if (transfer is null) return OS.badDragFlavorErr;
+    transfer.javaToNative(event.data, transferData);
+    if (transferData.result !is OS.noErr) return transferData.result;
+    // Except for FileTransfer (see #drag), only one item can be transferred
+    // in a Drag operation
+    byte[] datum = transferData.data[0];
+    if (datum is null) return OS.cantGetFlavorErr;
+    return OS.SetDragItemFlavorData(theDrag, theItemRef, theType, datum, datum.length, 0);
+}
+
+/**
+ * Returns the Control which is registered for this DragSource.  This is the control that the 
+ * user clicks in to initiate dragging.
+ *
+ * @return the Control which is registered for this DragSource
+ */
+public Control getControl () {
+    return control;
+}
+
+/**
+ * Returns an array of listeners who will be notified when a drag and drop 
+ * operation is in progress, by sending it one of the messages defined in 
+ * the <code>DragSourceListener</code> interface.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ * @see #removeDragListener
+ * @see DragSourceEvent
+ * 
+ * @since 3.4
+ */
+public DragSourceListener[] getDragListeners() {
+    Listener[] listeners = getListeners(DND.DragStart);
+    int length = listeners.length;
+    DragSourceListener[] dragListeners = new DragSourceListener[length];
+    int count = 0;
+    for (int i = 0; i < length; i++) {
+        Listener listener = listeners[i];
+        if (listener instanceof DNDListener) {
+            dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener();
+            count++;
+        }
+    }
+    if (count is length) return dragListeners;
+    DragSourceListener[] result = new DragSourceListener[count];
+    System.arraycopy(dragListeners, 0, result, 0, count);
+    return result;
+}
+
+/**
+ * Returns the drag effect that is registered for this DragSource.  This drag
+ * effect will be used during a drag and drop operation.
+ *
+ * @return the drag effect that is registered for this DragSource
+ * 
+ * @since 3.3
+ */
+public DragSourceEffect getDragSourceEffect() {
+    return dragEffect;
+}
+
+/**
+ * Returns the list of data types that can be transferred by this DragSource.
+ *
+ * @return the list of data types that can be transferred by this DragSource
+ */
+public Transfer[] getTransfer(){
+    return transferAgents;
+}
+
+void onDispose() {
+    if (control is null)
+        return;
+    if (controlListener !is null) {
+        control.removeListener(DWT.Dispose, controlListener);
+        control.removeListener(DWT.DragDetect, controlListener);
+    }
+    controlListener = null;
+    control.setData(DND.DRAG_SOURCE_KEY, null);
+    control = null;
+    transferAgents = null;
+}
+
+int opToOsOp(int operation) {
+    int osOperation = 0;
+    if ((operation & DND.DROP_COPY) !is 0){
+        osOperation |= OS.kDragActionCopy;
+    }
+    if ((operation & DND.DROP_LINK) !is 0) {
+        osOperation |= OS.kDragActionAlias;
+    }
+    if ((operation & DND.DROP_MOVE) !is 0) {
+        osOperation |= OS.kDragActionMove;
+    }
+    if ((operation & DND.DROP_TARGET_MOVE) !is 0) {
+        osOperation |= OS.kDragActionDelete;
+    }
+    return osOperation;
+}
+
+int osOpToOp(int osOperation){
+    int operation = 0;
+    if ((osOperation & OS.kDragActionCopy) !is 0){
+        operation |= DND.DROP_COPY;
+    }
+    if ((osOperation & OS.kDragActionAlias) !is 0) {
+        operation |= DND.DROP_LINK;
+    }
+    if ((osOperation & OS.kDragActionDelete) !is 0) {
+        operation |= DND.DROP_TARGET_MOVE;
+    }
+    if ((osOperation & OS.kDragActionMove) !is 0) {
+        operation |= DND.DROP_MOVE;
+    }
+    if (osOperation is OS.kDragActionAll) {
+        operation = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+    }
+    return operation;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ */
+public void removeDragListener(DragSourceListener listener) {
+    if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
+    removeListener (DND.DragStart, listener);
+    removeListener (DND.DragSetData, listener);
+    removeListener (DND.DragEnd, listener);
+}
+
+/**
+ * Specifies the drag effect for this DragSource.  This drag effect will be 
+ * used during a drag and drop operation.
+ *
+ * @param effect the drag effect that is registered for this DragSource
+ * 
+ * @since 3.3
+ */
+public void setDragSourceEffect(DragSourceEffect effect) {
+    dragEffect = effect;
+}
+/**
+ * Specifies the list of data types that can be transferred by this DragSource.
+ * The application must be able to provide data to match each of these types when
+ * a successful drop has occurred.
+ * 
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dragged from this source
+ */
+public void setTransfer(Transfer[] transferAgents){
+    this.transferAgents = transferAgents;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DragSourceAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.dnd;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DragSourceListener</code> interface.
+ * 
+ * <p>Classes that wish to deal with <code>DragSourceEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.</p>
+ *
+ * @see DragSourceListener
+ * @see DragSourceEvent
+ */
+public class DragSourceAdapter : DragSourceListener {
+    /**
+     * This implementation of <code>dragStart</code> permits the drag operation to start.
+     * For additional information see <code>DragSourceListener.dragStart</code>.
+     */
+    public void dragStart(DragSourceEvent event){}
+    /**
+     * This implementation of <code>dragFinished</code> does nothing.
+     * For additional information see <code>DragSourceListener.dragFinished</code>.
+     */
+    public void dragFinished(DragSourceEvent event){}
+    /**
+     * This implementation of <code>dragSetData</code> does nothing.
+     * For additional information see <code>DragSourceListener.dragSetData</code>.
+     */
+    public void dragSetData(DragSourceEvent event){}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DragSourceEffect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.*;
+import dwt.widgets.*;
+
+/**
+ * This class provides default implementations to display a drag source
+ * effect during a drag and drop operation. The current implementation
+ * does not provide any visual feedback. 
+ * 
+ * <p>The drag source effect has the same API as the 
+ * <code>DragSourceAdapter</code> so that it can provide custom visual 
+ * feedback when a <code>DragSourceEvent</code> occurs. 
+ * </p>
+ * 
+ * <p>Classes that wish to provide their own drag source effect such as
+ * displaying a default source image during a drag can extend the <code>DragSourceEffect</code> 
+ * class, override the <code>DragSourceAdapter.dragStart</code> method and set 
+ * the field <code>DragSourceEvent.image</code> with their own image.
+ * The image should be disposed when <code>DragSourceAdapter.dragFinished</code> is called.
+ * </p> 
+ *
+ * @see DragSourceAdapter
+ * @see DragSourceEvent
+ * 
+ * @since 3.3
+ */
+public class DragSourceEffect : DragSourceAdapter {
+    Control control = null;
+
+    /**
+     * Creates a new <code>DragSourceEffect</code> to handle drag effect from the specified <code>Control</code>.
+     *
+     * @param control the <code>Control</code> that the user clicks on to initiate the drag
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the control is null</li>
+     * </ul>
+     */
+    public DragSourceEffect(Control control) {
+        if (control is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        this.control = control;
+    }
+
+    /**
+     * Returns the Control which is registered for this DragSourceEffect.  This is the control that the 
+     * user clicks in to initiate dragging.
+     *
+     * @return the Control which is registered for this DragSourceEffect
+     */
+    public Control getControl() {
+        return control;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DragSourceEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.events.TypedEvent;
+import dwt.graphics.*;
+
+/**
+ * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
+ * 
+ * @see DragSourceListener
+ */
+public class DragSourceEvent : TypedEvent {
+    /**
+     * The operation that was performed.
+     * @see DND#DROP_NONE
+     * @see DND#DROP_MOVE
+     * @see DND#DROP_COPY
+     * @see DND#DROP_LINK
+     * @see DND#DROP_TARGET_MOVE
+     */
+    public int detail;
+    
+    /**
+     * In dragStart, the doit field determines if the drag and drop operation 
+     * should proceed; in dragFinished, the doit field indicates whether 
+     * the operation was performed successfully.
+     * <p></p>
+     * In dragStart:
+     * <p>Flag to determine if the drag and drop operation should proceed.
+     * The application can set this value to false to prevent the drag from starting. 
+     * Set to true by default.</p>
+     * 
+     * <p>In dragFinished:</p>
+     * <p>Flag to indicate if the operation was performed successfully. 
+     * True if the operation was performed successfully.</p>
+     */
+    public bool doit;
+
+    /**
+     * In dragStart, the x coordinate (relative to the control) of the 
+     * position the mouse went down to start the drag.
+     * @since 3.2
+     */
+    public int x;
+    /**
+     * In dragStart, the y coordinate (relative to the control) of the 
+     * position the mouse went down to start the drag .
+     * @since 3.2
+     */
+    public int y;
+    
+    /**
+     * The type of data requested.
+     * Data provided in the data field must be of the same type.
+     */
+    public TransferData dataType;
+    
+    /**
+     * The drag source image to be displayed during the drag.
+     * <p>A value of null indicates that no drag image will be displayed.</p>
+     * <p>The default value is null.</p>
+     * 
+     * @since 3.3
+     */
+    public Image image;
+
+    static final long serialVersionUID = 3257002142513770808L;
+    
+/**
+ * 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 DragSourceEvent(DNDEvent e) {
+    super(e);
+    this.data = e.data;
+    this.detail = e.detail;
+    this.doit = e.doit;
+    this.dataType = e.dataType;
+    this.x = e.x;
+    this.y = e.y;
+    this.image = e.image;
+}
+void updateEvent(DNDEvent e) {
+    e.widget = this.widget;
+    e.time = this.time;
+    e.data = this.data;
+    e.detail = this.detail;
+    e.doit = this.doit;
+    e.dataType = this.dataType;
+    e.x = this.x;
+    e.y = this.y;
+    e.image = this.image;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DragSourceListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * The <code>DragSourceListener</code> class provides event notification to the application for DragSource events.
+ *
+ * <p>When the user drops data on a <code>DropTarget</code>, the application which defines the <code>DragSource</code>
+ * must provide the dropped data by implementing <code>dragSetData</code>.  In the dragSetData, the application
+ * must support all the data types that were specified in the DragSource#setTransfer method.</p>
+ *
+ * <p>After the drop has completed successfully or has been aborted, the application which defines the 
+ * <code>DragSource</code> is required to take the appropriate cleanup action.  In the case of a successful 
+ * <b>move</b> operation, the application must remove the data that was transferred.</p>
+ *
+ */
+public interface DragSourceListener : DWTEventListener {
+
+/**
+ * The user has begun the actions required to drag the widget. This event gives the application 
+ * the chance to decide if a drag should be started.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in,out)doit
+ * </ul></p>
+ *
+ * @param event the information associated with the drag start event
+ * 
+ * @see DragSourceEvent
+ */
+public void dragStart(DragSourceEvent event);
+
+/**
+ * The data is required from the drag source.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)dataType - the type of data requested.
+ * <li>(out)data    - the application inserts the actual data here (must match the dataType)
+ * </ul></p>
+ *
+ * @param event the information associated with the drag set data event
+ * 
+ * @see DragSourceEvent
+ */
+public void dragSetData(DragSourceEvent event);
+
+/**
+ * The drop has successfully completed(mouse up over a valid target) or has been terminated (such as hitting 
+ * the ESC key). Perform cleanup such as removing data from the source side on a successful move operation.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)doit
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event the information associated with the drag finished event
+ * 
+ * @see DragSourceEvent
+ */
+public void dragFinished(DragSourceEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DropTarget.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,804 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+
+import dwt.*;
+import dwt.widgets.*;
+import dwt.internal.*;
+import dwt.internal.carbon.*;
+
+/**
+ *
+ * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class identifies the <code>Control</code> over which the user must position the cursor
+ * in order to drop the data being transferred.  It also specifies what data types can be dropped on 
+ * this control and what operations can be performed.  You may have several DropTragets in an 
+ * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
+ * The DropTarget can receive data from within the same application or from other applications 
+ * (such as text dragged from a text editor like Word).</p>
+ *
+ * <code><pre>
+ *  int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ *  Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ *  DropTarget target = new DropTarget(label, operations);
+ *  target.setTransfer(types);
+ * </code></pre>
+ *
+ * <p>The application is notified of data being dragged over this control and of when a drop occurs by 
+ * implementing the interface <code>DropTargetListener</code> which uses the class 
+ * <code>DropTargetEvent</code>.  The application can modify the type of drag being performed 
+ * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the 
+ * <code>event.currentDataType</code> field.  When the data is dropped, it is the responsibility of 
+ * the application to copy this data for its own purposes.
+ *
+ * <code><pre>
+ *  target.addDropListener (new DropTargetListener() {
+ *      public void dragEnter(DropTargetEvent event) {};
+ *      public void dragOver(DropTargetEvent event) {};
+ *      public void dragLeave(DropTargetEvent event) {};
+ *      public void dragOperationChanged(DropTargetEvent event) {};
+ *      public void dropAccept(DropTargetEvent event) {}
+ *      public void drop(DropTargetEvent event) {
+ *          // A drop has occurred, copy over the data
+ *          if (event.data is null) { // no data to copy, indicate failure in event.detail
+ *              event.detail = DND.DROP_NONE;
+ *              return;
+ *          }
+ *          label.setText ((String) event.data); // data copied to label text
+ *      }
+ *  });
+ * </pre></code>
+ *
+ * <dl>
+ *  <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ *  <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged, 
+ *                             DND.DropAccept, DND.Drop </dd>
+ * </dl>
+ */
+public class DropTarget : Widget {
+
+    Control control;
+    Listener controlListener;
+    Transfer[] transferAgents = new Transfer[0];
+    DropTargetEffect dropEffect;
+    int feedback = DND.FEEDBACK_NONE;
+
+    // Track application selections
+    TransferData selectedDataType;
+    int selectedOperation;
+    
+    // workaround - There is no event for "operation changed" so track operation based on key state
+    int keyOperation = -1;
+    
+    // workaround - Simulate events when mouse is not moving
+    long dragOverStart;
+    Runnable dragOverHeartbeat;
+    DNDEvent dragOverEvent;
+    
+    // workaround - OS events are relative to the application, not the control.
+    // Track which control is the current target to determine when drag and
+    // drop enters or leaves a widget.
+    static DropTarget CurrentDropTarget = null;
+    
+    static final String DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$
+    static final int DRAGOVER_HYSTERESIS = 50;
+    
+    static Callback DragTrackingHandler;
+    static Callback DragReceiveHandler;
+    
+    static {
+        DragTrackingHandler = new Callback(DropTarget.class, "DragTrackingHandler", 4); //$NON-NLS-1$
+        int dragTrackingHandlerAddress = DragTrackingHandler.getAddress();
+        if (dragTrackingHandlerAddress is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+        DragReceiveHandler = new Callback(DropTarget.class, "DragReceiveHandler", 3); //$NON-NLS-1$
+        int dragReceiveHandlerAddress = DragReceiveHandler.getAddress();
+        if (dragReceiveHandlerAddress is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+        OS.InstallTrackingHandler(dragTrackingHandlerAddress, 0, null);
+        OS.InstallReceiveHandler(dragReceiveHandlerAddress, 0, null);
+    }
+
+/**
+ * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified 
+ * <code>Control</code>.
+ * Creating an instance of a DropTarget may cause system resources to be allocated 
+ * depending on the platform.  It is therefore mandatory that the DropTarget instance 
+ * be disposed when no longer required.
+ * 
+ * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of 
+ *         DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_CANNOT_INIT_DROP - unable to initiate drop target; this will occur if more than one
+ *        drop target is created for a control or if the operating system will not allow the creation
+ *        of the drop target</li>
+ * </ul>
+ *
+ * <p>NOTE: ERROR_CANNOT_INIT_DROP should be an DWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ * 
+ * @see Widget#dispose
+ * @see DropTarget#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DropTarget(Control control, int style) {
+    super(control, checkStyle(style));
+    this.control = control;
+    if (DragTrackingHandler is null || DragTrackingHandler is null) {
+        DND.error(DND.ERROR_CANNOT_INIT_DROP);
+    }
+    if (control.getData(DND.DROP_TARGET_KEY) !is null) {
+        DND.error(DND.ERROR_CANNOT_INIT_DROP);
+    }
+    control.setData(DND.DROP_TARGET_KEY, this);
+
+    controlListener = new Listener () {
+        public void handleEvent (Event event) {
+            if (!DropTarget.this.isDisposed()) {
+                DropTarget.this.dispose();
+            }
+        }
+    };
+    control.addListener (DWT.Dispose, controlListener);
+    
+    this.addListener(DWT.Dispose, new Listener() {
+        public void handleEvent (Event event) {
+            onDispose();
+        }
+    });
+
+    Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT);
+    if (effect instanceof DropTargetEffect) {
+        dropEffect = (DropTargetEffect) effect;
+    } else if (control instanceof Table) {
+        dropEffect = new TableDropTargetEffect((Table) control);
+    } else if (control instanceof Tree) {
+        dropEffect = new TreeDropTargetEffect((Tree) control);
+    }
+
+    dragOverHeartbeat = new Runnable() {
+        public void run() {
+            Control control = DropTarget.this.control;
+            if (control is null || control.isDisposed() || dragOverStart is 0) return;
+            long time = System.currentTimeMillis();
+            int delay = DRAGOVER_HYSTERESIS;
+            if (time < dragOverStart) {
+                delay = (int)(dragOverStart - time);
+            } else {    
+                int allowedOperations = dragOverEvent.operations;
+                TransferData[] allowedTypes = dragOverEvent.dataTypes;
+                //pass a copy of data types in to listeners in case application modifies it
+                TransferData[] dataTypes = new TransferData[allowedTypes.length];
+                System.arraycopy(allowedTypes, 0, dataTypes, 0, dataTypes.length);
+    
+                DNDEvent event = new DNDEvent();
+                event.widget = dragOverEvent.widget;
+                event.x = dragOverEvent.x;
+                event.y = dragOverEvent.y;
+                event.time = (int)time;
+                event.feedback = DND.FEEDBACK_SELECT;
+                event.dataTypes = dataTypes;
+                event.dataType = selectedDataType;
+                event.operations = dragOverEvent.operations;
+                event.detail  = selectedOperation;
+                if (dropEffect !is null) {
+                    event.item = dropEffect.getItem(event.x, event.y);
+                }
+                selectedDataType = null;
+                selectedOperation = DND.DROP_NONE;              
+                notifyListeners(DND.DragOver, event);
+                if (event.dataType !is null) {
+                    for (int i = 0; i < allowedTypes.length; i++) {
+                        if (allowedTypes[i].type is event.dataType.type) {
+                            selectedDataType = event.dataType;
+                            break;
+                        }
+                    }
+                }
+                if (selectedDataType !is null && (event.detail & allowedOperations) !is 0) {
+                    selectedOperation = event.detail;
+                }
+            }
+            control = DropTarget.this.control;
+            if (control is null || control.isDisposed()) return;
+            control.getDisplay().timerExec(delay, dragOverHeartbeat);
+        }
+    };
+}
+
+static int checkStyle (int style) {
+    if (style is DWT.NONE) return DND.DROP_MOVE;
+    return style;
+}
+
+static int DragReceiveHandler(int theWindow, int handlerRefCon, int theDrag) {
+    DropTarget target = FindDropTarget(theWindow, theDrag);
+    if (target is null) return OS.noErr;
+    return target.dragReceiveHandler(theWindow, handlerRefCon, theDrag);   
+}
+
+static int DragTrackingHandler(int message, int theWindow, int handlerRefCon, int theDrag) {
+    if (message is OS.kDragTrackingLeaveHandler || message is OS.kDragTrackingEnterHandler) {
+        CurrentDropTarget = null;
+        return OS.noErr;
+    }
+    DropTarget target = FindDropTarget(theWindow, theDrag);
+    if (CurrentDropTarget !is null) {
+        if (target is null || CurrentDropTarget.control.handle !is target.control.handle) {
+            CurrentDropTarget.dragTrackingHandler(OS.kDragTrackingLeaveWindow, theWindow, handlerRefCon, theDrag);
+            CurrentDropTarget = target;
+            message = OS.kDragTrackingEnterWindow;
+        }
+    } else {
+        CurrentDropTarget = target;
+        message = OS.kDragTrackingEnterWindow;
+    }
+    if (target is null) return OS.noErr;
+    return target.dragTrackingHandler(message, theWindow, handlerRefCon, theDrag);   
+}
+
+static DropTarget FindDropTarget(int theWindow, int theDrag) {
+    Display display = Display.findDisplay(Thread.currentThread());
+    if (display is null || display.isDisposed()) return null;
+    Point mouse = new Point();
+    OS.GetDragMouse(theDrag, mouse, null);
+    int[] theRoot = new int[1];
+    OS.GetRootControl(theWindow, theRoot);
+    int[] theControl = new int[1];
+    Rect rect = new Rect();
+    OS.GetWindowBounds (theWindow, (short) OS.kWindowContentRgn, rect);
+    CGPoint inPoint = new CGPoint();
+    inPoint.x = mouse.h - rect.left;
+    inPoint.y = mouse.v - rect.top;
+    OS.HIViewGetSubviewHit(theRoot[0], inPoint, true, theControl);
+    if (!OS.IsControlEnabled(theControl[0])) return null;               
+    Widget widget = display.findWidget(theControl[0]);
+    if (widget is null) return null;
+    return (DropTarget)widget.getData(DND.DROP_TARGET_KEY);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DropTargetListener</code>
+ * interface.
+ * 
+ * <p><ul>
+ * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
+ * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
+ * the drop occurs or is cancelled.
+ * <li><code>dragOperationChanged</code> is called when the operation being performed has changed 
+ * (usually due to the user changing the selected modifier key(s) while dragging)
+ * <li><code>dragOver</code> is called when the cursor is moving over the drop target
+ * <li><code>dropAccept</code> is called just before the drop is performed.  The drop target is given 
+ * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
+ * <li><code>drop</code> is called when the data is being dropped
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ */
+public void addDropListener(DropTargetListener listener) {
+    if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
+    DNDListener typedListener = new DNDListener (listener);
+    typedListener.dndWidget = this;
+    addListener (DND.DragEnter, typedListener);
+    addListener (DND.DragLeave, typedListener);
+    addListener (DND.DragOver, typedListener);
+    addListener (DND.DragOperationChanged, typedListener);
+    addListener (DND.Drop, typedListener);
+    addListener (DND.DropAccept, typedListener);
+}
+
+protected void checkSubclass () {
+    String name = getClass().getName ();
+    String validName = DropTarget.class.getName();
+    if (!validName.opEquals(name)) {
+        DND.error (DWT.ERROR_INVALID_SUBCLASS);
+    }
+}
+
+int dragReceiveHandler(int theWindow, int handlerRefCon, int theDrag) {
+    updateDragOverHover(0, null);
+    if (keyOperation is -1) return OS.dragNotAcceptedErr;
+
+    DNDEvent event = new DNDEvent();
+    event.widget = this;
+    event.time = (int)System.currentTimeMillis();
+    event.detail = DND.DROP_NONE;
+    notifyListeners(DND.DragLeave, event);
+    
+    event = new DNDEvent();
+    if (!setEventData(theDrag, event)) {
+        return OS.dragNotAcceptedErr;
+    }
+    
+    keyOperation = -1;
+    int allowedOperations = event.operations;
+    TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+    System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, event.dataTypes.length);
+    event.dataType = selectedDataType;
+    event.detail = selectedOperation;
+    selectedDataType = null;
+    selectedOperation = DND.DROP_NONE;
+    notifyListeners(DND.DropAccept, event);
+    
+    if (event.dataType !is null) {
+        for (int i = 0; i < allowedDataTypes.length; i++) {
+            if (allowedDataTypes[i].type is event.dataType.type) {
+                selectedDataType = allowedDataTypes[i];
+                break;
+            }
+        }
+    }
+    if (selectedDataType !is null && (event.detail & allowedOperations) !is 0) {
+        selectedOperation = event.detail;
+    }   
+    if (selectedOperation is DND.DROP_NONE) {
+        // this was not a successful drop
+        return OS.dragNotAcceptedErr;
+    }
+    // ask drag source for dropped data
+    byte[][] data  = new byte[0][];
+    // locate all the items with data of the desired type 
+    short[] numItems = new short[1];
+    OS.CountDragItems(theDrag, numItems);
+    for (short i = 0; i < numItems[0]; i++) {
+        int[] theItemRef = new int[1];
+        OS.GetDragItemReferenceNumber(theDrag, (short) (i+1), theItemRef);
+        int[] size = new int[1];
+        OS.GetFlavorDataSize(theDrag, theItemRef[0], selectedDataType.type, size);
+        if (size[0] > 0) {
+            byte[] buffer = new byte[size[0]];
+            OS.GetFlavorData(theDrag, theItemRef[0], selectedDataType.type, buffer, size, 0);
+            byte[][] newData = new byte[data.length + 1][];
+            System.arraycopy(data, 0, newData, 0, data.length);
+            newData[data.length] = buffer;
+            data = newData;
+        }
+    }
+    // Get Data in a Java format
+    Object object = null;
+    for (int i = 0; i < transferAgents.length; i++) {
+        Transfer transfer = transferAgents[i];
+        if (transfer !is null && transfer.isSupportedType(selectedDataType)) {
+            selectedDataType.data = data;
+            object = transfer.nativeToJava(selectedDataType);
+            break;
+        }
+    }
+    
+    if (object is null) {
+        selectedOperation = DND.DROP_NONE;
+    }
+        
+    event.dataType = selectedDataType;
+    event.detail = selectedOperation;
+    event.data = object;
+    notifyListeners(DND.Drop, event);
+    selectedOperation = DND.DROP_NONE;
+    if ((allowedOperations & event.detail) is event.detail) {
+        selectedOperation = event.detail;
+    }
+    //notify source of action taken
+    int action = opToOsOp(selectedOperation);
+    OS.SetDragDropAction(theDrag, action);
+    return (selectedOperation is DND.DROP_NONE) ? OS.dragNotAcceptedErr : OS.noErr;
+}
+
+int dragTrackingHandler(int message, int theWindow, int handlerRefCon, int theDrag) {
+    
+    if (message is OS.kDragTrackingLeaveWindow) {
+        updateDragOverHover(0, null);
+        OS.SetThemeCursor(OS.kThemeArrowCursor);
+        if (keyOperation is -1) return OS.dragNotAcceptedErr;
+        keyOperation = -1;
+        
+        DNDEvent event = new DNDEvent();
+        event.widget = this;
+        event.time = (int)System.currentTimeMillis();
+        event.detail = DND.DROP_NONE;
+        notifyListeners(DND.DragLeave, event);
+        return OS.noErr;
+    }
+    
+    int oldKeyOperation = keyOperation;
+    
+    if (message is OS.kDragTrackingEnterWindow) {
+        selectedDataType = null;
+        selectedOperation = 0;
+    }
+    
+    DNDEvent event = new DNDEvent();
+    if (!setEventData(theDrag, event)) {
+        keyOperation = -1;
+        OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+        return OS.dragNotAcceptedErr;
+    }
+    
+    int allowedOperations = event.operations;
+    TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+    System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, allowedDataTypes.length);
+    
+    switch (message) {
+        case OS.kDragTrackingEnterWindow:
+            event.type = DND.DragEnter;
+            break;
+        case OS.kDragTrackingInWindow:
+            if (keyOperation is oldKeyOperation) {
+                event.type = DND.DragOver;
+                event.dataType = selectedDataType;
+                event.detail = selectedOperation;
+            }else {
+                event.type = DND.DragOperationChanged;
+                event.dataType = selectedDataType;
+            }
+            break;
+    }
+    
+    updateDragOverHover(DRAGOVER_HYSTERESIS, event);
+    selectedDataType = null;
+    selectedOperation = DND.DROP_NONE;
+    notifyListeners(event.type, event);
+
+    if (event.detail is DND.DROP_DEFAULT) {
+        event.detail = (allowedOperations & DND.DROP_MOVE) !is 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+    }
+    
+    if (event.dataType !is null) {
+        for (int i = 0; i < allowedDataTypes.length; i++) {
+            if (allowedDataTypes[i].type is event.dataType.type) {
+                selectedDataType = allowedDataTypes[i];
+                break;
+            }
+        }
+    }
+
+    if (selectedDataType !is null && (allowedOperations & event.detail) !is 0) {
+        selectedOperation = event.detail;
+    }
+    
+    OS.SetDragDropAction(theDrag, opToOsOp(selectedOperation));
+
+    switch (selectedOperation) {
+        case DND.DROP_COPY:
+            OS.SetThemeCursor(OS.kThemeCopyArrowCursor);
+            break;
+        case DND.DROP_LINK:
+            OS.SetThemeCursor(OS.kThemeAliasArrowCursor);
+            break;
+        case DND.DROP_MOVE:
+            OS.SetThemeCursor(OS.kThemeArrowCursor);
+            break;
+        default:
+            OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+    }
+    
+    if (message is OS.kDragTrackingEnterWindow) {
+        dragOverHeartbeat.run();        
+    }
+    return OS.noErr;
+}
+
+/**
+ * Returns the Control which is registered for this DropTarget.  This is the control over which the 
+ * user positions the cursor to drop the data.
+ *
+ * @return the Control which is registered for this DropTarget
+ */
+public Control getControl () {
+    return control;
+}
+
+/**
+ * Returns an array of listeners who will be notified when a drag and drop 
+ * operation is in progress, by sending it one of the messages defined in 
+ * the <code>DropTargetListener</code> interface.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ * 
+ * @since 3.4
+ */
+public DropTargetListener[] getDropListeners() {
+    Listener[] listeners = getListeners(DND.DragEnter);
+    int length = listeners.length;
+    DropTargetListener[] dropListeners = new DropTargetListener[length];
+    int count = 0;
+    for (int i = 0; i < length; i++) {
+        Listener listener = listeners[i];
+        if (listener instanceof DNDListener) {
+            dropListeners[count] = (DropTargetListener) ((DNDListener) listener).getEventListener();
+            count++;
+        }
+    }
+    if (count is length) return dropListeners;
+    DropTargetListener[] result = new DropTargetListener[count];
+    System.arraycopy(dropListeners, 0, result, 0, count);
+    return result;
+}
+
+/**
+ * Returns the drop effect for this DropTarget.  This drop effect will be 
+ * used during a drag and drop to display the drag under effect on the 
+ * target widget.
+ *
+ * @return the drop effect that is registered for this DropTarget
+ * 
+ * @since 3.3
+ */
+public DropTargetEffect getDropTargetEffect() {
+    return dropEffect;
+}
+
+int getOperationFromKeyState(int theDrag) {
+    short[] modifiers = new short[1];
+    OS.GetDragModifiers(theDrag, modifiers, null, null);
+    bool option = (modifiers[0] & OS.optionKey) is OS.optionKey;
+    bool command = (modifiers[0] & OS.cmdKey) is OS.cmdKey;
+    if (option && command) return DND.DROP_LINK;
+    if (option) return DND.DROP_COPY;
+    if (command) return DND.DROP_MOVE;
+    return DND.DROP_DEFAULT; 
+}
+
+/**
+ * Returns a list of the data types that can be transferred to this DropTarget.
+ *
+ * @return a list of the data types that can be transferred to this DropTarget
+ */
+public Transfer[] getTransfer() {
+    return transferAgents;
+}
+
+void onDispose () { 
+    if (control is null)
+        return;
+    if (controlListener !is null)
+        control.removeListener(DWT.Dispose, controlListener);
+    controlListener = null;
+    control.setData(DND.DROP_TARGET_KEY, null);
+    transferAgents = null;
+    control = null;
+}
+
+int opToOsOp(int operation) {
+    int osOperation = 0;
+    if ((operation & DND.DROP_COPY) !is 0){
+        osOperation |= OS.kDragActionCopy;
+    }
+    if ((operation & DND.DROP_LINK) !is 0) {
+        osOperation |= OS.kDragActionAlias;
+    }
+    if ((operation & DND.DROP_MOVE) !is 0) {
+        osOperation |= OS.kDragActionMove;
+    }
+    return osOperation;
+}
+
+int osOpToOp(int osOperation){
+    int operation = 0;
+    if ((osOperation & OS.kDragActionCopy) !is 0){
+        operation |= DND.DROP_COPY;
+    }
+    if ((osOperation & OS.kDragActionAlias) !is 0) {
+        operation |= DND.DROP_LINK;
+    }
+    if ((osOperation & OS.kDragActionMove) !is 0) {
+        operation |= DND.DROP_MOVE;
+    }
+    if (osOperation is OS.kDragActionAll) {
+        operation = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+    }
+    return operation;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ */
+public void removeDropListener(DropTargetListener listener) {   
+    if (listener is null) DND.error (DWT.ERROR_NULL_ARGUMENT);
+    removeListener (DND.DragEnter, listener);
+    removeListener (DND.DragLeave, listener);
+    removeListener (DND.DragOver, listener);
+    removeListener (DND.DragOperationChanged, listener);
+    removeListener (DND.Drop, listener);
+    removeListener (DND.DropAccept, listener);
+}
+
+/**
+ * Specifies the drop effect for this DropTarget.  This drop effect will be 
+ * used during a drag and drop to display the drag under effect on the 
+ * target widget.
+ *
+ * @param effect the drop effect that is registered for this DropTarget
+ * 
+ * @since 3.3
+ */
+public void setDropTargetEffect(DropTargetEffect effect) {
+    dropEffect = effect;
+}
+
+bool setEventData(int theDrag, DNDEvent event) {
+    if (theDrag is 0) return false;
+    
+    // get allowed operations
+    int style = getStyle();
+    int[] outActions = new int[1];
+    OS.GetDragAllowableActions(theDrag, outActions);
+    int operations = osOpToOp(outActions[0]) & style;
+    if (operations is DND.DROP_NONE) return false;
+    
+    //get current operation
+    int operation =  getOperationFromKeyState(theDrag);
+    keyOperation = operation;
+    if (operation is DND.DROP_DEFAULT) {
+         if ((style & DND.DROP_DEFAULT) is 0) {
+            operation = (operations & DND.DROP_MOVE) !is 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+         }
+    } else {
+        if ((operation & operations) is 0) operation = DND.DROP_NONE;
+    }
+    
+    // get allowed transfer types
+    short[] numItems = new short[1];
+    OS.CountDragItems(theDrag, numItems);
+    int[] flavors = new int[10];
+    int index = -1;
+    //Get a unique list of flavors
+    for (short i = 0; i < numItems[0]; i++) {
+        int[] theItemRef = new int[1];
+        OS.GetDragItemReferenceNumber(theDrag, (short) (i+1), theItemRef);
+        short[] numFlavors = new short[1];
+        OS.CountDragItemFlavors(theDrag, theItemRef[0], numFlavors);
+        int[] theType = new int[1];
+        for (int j = 0; j < numFlavors[0]; j++) {
+            theType[0] = 0;
+            if (OS.GetFlavorType(theDrag, theItemRef[0], (short) (j+1), theType) is OS.noErr) {
+                bool unique = true;
+                for (int k = 0; k < flavors.length; k++) {
+                    if (flavors[k] is theType[0]) {
+                        unique = false;
+                        break;
+                    }
+                }
+                if (unique) {
+                    if (index is flavors.length - 1) {
+                        int[] temp = new int[flavors.length + 10];
+                        System.arraycopy(flavors, 0, temp, 0, flavors.length);
+                        flavors = temp;
+                    }
+                    flavors[++index] = theType[0];
+                }
+            }
+        }
+    }
+    if (index is -1) return false;
+    
+    TransferData[] dataTypes = new TransferData[index+1];
+    index = -1;
+    for (int i = 0; i < dataTypes.length; i++) {
+        if (flavors[i] !is 0) {
+            TransferData data = new TransferData();
+            data.type = flavors[i];
+            for (int j = 0; j < transferAgents.length; j++) {
+                Transfer transfer = transferAgents[j];
+                if (transfer !is null && transfer.isSupportedType(data)) {
+                    dataTypes[++index] = data;
+                    break;
+                }
+            }
+        }
+    }
+    if (index is -1) return false;
+    
+    if (index < dataTypes.length - 1) {
+        TransferData[] temp = new TransferData[index + 1];
+        System.arraycopy(dataTypes, 0, temp, 0, index + 1);
+        dataTypes = temp;
+    }
+
+    Point mouse = new Point();
+    OS.GetDragMouse(theDrag, mouse, null);
+    
+    event.widget = this;
+    event.x = mouse.h;
+    event.y = mouse.v;
+    event.time = (int)System.currentTimeMillis();
+    event.feedback = DND.FEEDBACK_SELECT;
+    event.dataTypes = dataTypes;
+    event.dataType = dataTypes[0];
+    event.operations = operations;
+    event.detail = operation;
+    if (dropEffect !is null) {
+        event.item = dropEffect.getItem(event.x, event.y);
+    }
+    
+    return true;
+}
+
+/**
+ * Specifies the data types that can be transferred to this DropTarget.  If data is 
+ * being dragged that does not match one of these types, the drop target will be notified of 
+ * the drag and drop operation but the currentDataType will be null and the operation 
+ * will be DND.NONE.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ *                       dropped on this target
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
+ * </ul>
+ */
+public void setTransfer(Transfer[] transferAgents){
+    if (transferAgents is null) DND.error(DWT.ERROR_NULL_ARGUMENT);
+    this.transferAgents = transferAgents;
+}
+
+void updateDragOverHover(long delay, DNDEvent event) {
+    if (delay is 0) {
+        dragOverStart = 0;
+        dragOverEvent = null;
+        return;
+    }
+    dragOverStart = System.currentTimeMillis() + delay;
+    if (dragOverEvent is null) dragOverEvent = new DNDEvent();
+    dragOverEvent.x = event.x;
+    dragOverEvent.y = event.y;
+    dragOverEvent.dataTypes  = event.dataTypes;
+    dragOverEvent.operations = event.operations;
+    dragOverEvent.dataType  = event.dataType;
+    dragOverEvent.detail  = event.detail;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DropTargetAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DropTargetListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>DropTargetEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see DropTargetListener
+ * @see DropTargetEvent
+ */
+public class DropTargetAdapter : DropTargetListener {
+
+/**
+ * This implementation of <code>dragEnter</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragEnter</code>.
+ */
+public void dragEnter(DropTargetEvent event){}
+/**
+ * This implementation of <code>dragLeave</code> does nothing.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ */
+public void dragLeave(DropTargetEvent event){}
+/**
+ * This implementation of <code>dragOperationChanged</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ */
+public void dragOperationChanged(DropTargetEvent event){}
+/**
+ * This implementation of <code>dragOver</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOver</code>.
+ */
+public void dragOver(DropTargetEvent event){}
+/**
+ * This implementation of <code>drop</code> does nothing.
+ * For additional information see <code>DropTargetListener.drop</code>.
+ */
+public void drop(DropTargetEvent event){}
+/**
+ * This implementation of <code>dropAccept</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dropAccept</code>.
+ */
+public void dropAccept(DropTargetEvent event){}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DropTargetEffect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.widgets.*;
+
+
+/**
+ * This class provides a default drag under effect during a drag and drop. 
+ * The current implementation does not provide any visual feedback.
+ * 
+ * <p>The drop target effect has the same API as the 
+ * <code>DropTargetAdapter</code> so that it can provide custom visual 
+ * feedback when a <code>DropTargetEvent</code> occurs. 
+ * </p>
+ * 
+ * <p>Classes that wish to provide their own drag under effect
+ * can extend the <code>DropTargetEffect</code> and override any applicable methods 
+ * in <code>DropTargetAdapter</code> to display their own drag under effect.</p>
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_EXPAND, FEEDBACK_INSERT_AFTER, FEEDBACK_INSERT_BEFORE, 
+ * FEEDBACK_NONE, FEEDBACK_SELECT, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * 
+ * @since 3.3
+ */
+public class DropTargetEffect : DropTargetAdapter {
+    Control control;
+
+    /**
+     * Creates a new <code>DropTargetEffect</code> to handle the drag under effect on the specified 
+     * <code>Control</code>.
+     * 
+     * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+     * 
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_NULL_ARGUMENT - if the control is null</li>
+     * </ul>
+     */
+    public DropTargetEffect(Control control) {
+        if (control is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        this.control = control;
+    }
+
+    /**
+     * Returns the Control which is registered for this DropTargetEffect.  This is the control over which the 
+     * user positions the cursor to drop the data.
+     *
+     * @return the Control which is registered for this DropTargetEffect
+     */
+    public Control getControl() {
+        return control;
+    }
+    
+    /**
+     * Returns the item at the given x-y coordinate in the receiver
+     * or null if no such item exists. The x-y coordinate is in the
+     * display relative coordinates.
+     *
+     * @param x the x coordinate used to locate the item
+     * @param y the y coordinate used to locate the item
+     * @return the item at the given x-y coordinate, or null if the coordinate is not in a selectable item
+     */
+    public Widget getItem(int x, int y) {
+        if (control instanceof Table) {
+            return getItem((Table) control, x, y);
+        }
+        if (control instanceof Tree) {
+            return getItem((Tree) control, x, y);
+        }           
+        return null;
+    }
+    
+    Widget getItem(Table table, int x, int y) {
+        Point coordinates = new Point(x, y);
+        coordinates = table.toControl(coordinates);
+        TableItem item = table.getItem(coordinates);
+        if (item !is null) return item;
+        Rectangle area = table.getClientArea();
+        int tableBottom = area.y + area.height;
+        int itemCount = table.getItemCount();
+        for (int i=table.getTopIndex(); i<itemCount; i++) {
+            item = table.getItem(i);
+            Rectangle rect = item.getBounds();
+            rect.x = area.x;
+            rect.width = area.width;
+            if (rect.contains(coordinates)) return item;
+            if (rect.y > tableBottom) break;
+        }
+        return null;
+    }
+    
+    Widget getItem(Tree tree, int x, int y) {
+        Point point = new Point(x, y);
+        point = tree.toControl(point);
+        TreeItem item = tree.getItem(point);
+        if (item is null) {
+            Rectangle area = tree.getClientArea();
+            if (area.contains(point)) {
+                int treeBottom = area.y + area.height;
+                item = tree.getTopItem();
+                while (item !is null) {
+                    Rectangle rect = item.getBounds();
+                    int itemBottom = rect.y + rect.height;
+                    if (rect.y <= point.y && point.y < itemBottom) return item;
+                    if (itemBottom > treeBottom) break;
+                    item = nextItem(tree, item);
+                }
+                return null;
+            }
+        }
+        return item;
+    }
+    
+    TreeItem nextItem(Tree tree, TreeItem item) {
+        if (item is null) return null;
+        if (item.getExpanded() && item.getItemCount() > 0) return item.getItem(0);
+        TreeItem childItem = item;
+        TreeItem parentItem = childItem.getParentItem();
+        int index = parentItem is null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
+        int count = parentItem is null ? tree.getItemCount() : parentItem.getItemCount();
+        while (true) {
+            if (index + 1 < count) return parentItem is null ? tree.getItem(index + 1) : parentItem.getItem(index + 1);
+            if (parentItem is null) return null;
+            childItem = parentItem;
+            parentItem = childItem.getParentItem();
+            index = parentItem is null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
+            count = parentItem is null ? tree.getItemCount() : parentItem.getItemCount();
+        }
+    }
+    
+    TreeItem previousItem(Tree tree, TreeItem item) {
+        if (item is null) return null;
+        TreeItem childItem = item;
+        TreeItem parentItem = childItem.getParentItem();
+        int index = parentItem is null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
+        if (index is 0) return parentItem;
+        TreeItem nextItem = parentItem is null ? tree.getItem(index-1) : parentItem.getItem(index-1);
+        int count = nextItem.getItemCount();
+        while (count > 0 && nextItem.getExpanded()) {
+            nextItem = nextItem.getItem(count - 1);
+            count = nextItem.getItemCount();
+        }
+        return nextItem;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DropTargetEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.events.TypedEvent;
+import dwt.widgets.Widget;
+
+/**
+ * The DropTargetEvent contains the event information passed in the methods of the DropTargetListener.
+ */
+public class DropTargetEvent : TypedEvent {
+    /**
+     * The x-cordinate of the cursor relative to the <code>Display</code>
+     */
+    public int x;
+    
+    /**
+     * The y-cordinate of the cursor relative to the <code>Display</code>
+     */
+    public int y;
+    
+    /**
+     * The operation being performed.
+     * @see DND#DROP_NONE
+     * @see DND#DROP_MOVE
+     * @see DND#DROP_COPY
+     * @see DND#DROP_LINK
+     */
+    public int detail;
+    
+    /**
+     * A bitwise OR'ing of the operations that the DragSource can support 
+     * (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK).
+     * The detail value must be a member of this list or DND.DROP_NONE.
+     * @see DND#DROP_NONE
+     * @see DND#DROP_MOVE
+     * @see DND#DROP_COPY
+     * @see DND#DROP_LINK
+     */
+    public int operations;
+    
+    /**
+     * A bitwise OR'ing of the drag under effect feedback to be displayed to the user
+     * (e.g. DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND).
+     * <p>A value of DND.FEEDBACK_NONE indicates that no drag under effect will be displayed.</p>
+     * <p>Feedback effects will only be applied if they are applicable.</p>
+     * <p>The default value is DND.FEEDBACK_SELECT.</p>
+     * @see DND#FEEDBACK_NONE
+     * @see DND#FEEDBACK_SELECT
+     * @see DND#FEEDBACK_INSERT_BEFORE
+     * @see DND#FEEDBACK_INSERT_AFTER
+     * @see DND#FEEDBACK_SCROLL
+     * @see DND#FEEDBACK_EXPAND
+     */
+    public int feedback;
+    
+    /**
+     * If the associated control is a table or tree, this field contains the item located 
+     * at the cursor coordinates.
+     */
+    public Widget item;
+    
+    /**
+     * The type of data that will be dropped.
+     */
+    public TransferData currentDataType;
+    
+    /**
+     * A list of the types of data that the DragSource is capable of providing.
+     * The currentDataType must be a member of this list.
+     */
+    public TransferData[] dataTypes;
+
+    static final long serialVersionUID = 3256727264573338678L;
+    
+/**
+ * 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 DropTargetEvent(DNDEvent e) {
+    super(e);
+    this.data = e.data;
+    this.x = e.x;
+    this.y = e.y;
+    this.detail = e.detail;
+    this.currentDataType = e.dataType;
+    this.dataTypes = e.dataTypes;
+    this.operations = e.operations;
+    this.feedback = e.feedback;
+    this.item = e.item;
+}
+void updateEvent(DNDEvent e) {
+    e.widget = this.widget;
+    e.time = this.time;
+    e.data = this.data;
+    e.x = this.x;
+    e.y = this.y;
+    e.detail = this.detail;
+    e.dataType = this.currentDataType;
+    e.dataTypes = this.dataTypes;
+    e.operations = this.operations;
+    e.feedback = this.feedback;
+    e.item = this.item;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/DropTargetListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,250 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * The <code>DropTargetListener</code> class provides event notification to the application 
+ * for DropTarget events.
+ *
+ * <p>As the user moves the cursor into, over and out of a Control that has been designated 
+ * as a DropTarget, events indicate what operation can be performed and what data can be 
+ * transferred if a drop where to occur at that point.
+ * The application can respond to these events and change the type of data that will 
+ * be dropped by modifying event.currentDataType, or change the operation that will be performed 
+ * by modifying the event.detail field or stop any drop from happening on the current target
+ * by setting the event.detail field to DND_DROP_NONE.</p>
+ *
+ * <p>When the user causes a drop to happen by releasing the mouse over a valid drop target, 
+ * the application has one last chance to change the data type of the drop through the 
+ * DropAccept event.  If the drop is still allowed, the DropAccept event is immediately 
+ * followed by the Drop event.  In the Drop event, the application can still change the
+ * operation that is performed but the data type is fixed.</p>
+ * 
+ * @see DropTargetEvent
+ *
+ */
+public interface DropTargetListener : DWTEventListener {
+    
+/**
+ * The cursor has entered the drop target boundaries.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.  
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.  
+ * If the application does not set the <code>event.detail</code> to something other 
+ * than <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard 
+ * default.</p>
+ * 
+ * <p>The <code>currentDataType</code> is determined by the first transfer agent specified in 
+ * setTransfer() that matches a data type provided by the drag source.</p>
+ * 
+ * <p>It is possible to get a DragEnter event when the drag source does not provide any matching data.
+ * In this case, the default operation is DND.DROP_NONE and the currentDataType is null.</p>
+ * 
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code> 
+ * field or DND.DROP_NONE.</p>
+ * 
+ * <p>The application can also change the type of data being requested by 
+ * modifying the <code>currentDataTypes</code> field  but the value must be one of the values 
+ * in the <code>dataTypes</code> list.</p>
+ *
+ * @param event  the information associated with the drag enter event
+ * 
+ * @see DropTargetEvent
+ */
+public void dragEnter(DropTargetEvent event);
+
+/**
+ * The cursor has left the drop target boundaries OR the drop has been cancelled OR the data 
+ * is about to be dropped.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in)currentDataType
+ * <li>(in)operations
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event  the information associated with the drag leave event
+ *
+ * @see DropTargetEvent
+ */
+public void dragLeave(DropTargetEvent event);
+
+/**
+ * The operation being performed has changed (usually due to the user changing the selected modifier key(s)
+ * while dragging).
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.  
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.  
+ * If the application does not set the <code>event.detail</code> to something other than 
+ * <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard default.</p>
+ * 
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to 
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ * 
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code> 
+ * field.</p>
+ * 
+ * <p>The application can also change the type of data being requested by modifying 
+ * the <code>currentDataTypes</code> field  but the value must be one of the values in the 
+ * <code>dataTypes</code> list.</p>
+ *
+ * @param event  the information associated with the drag operation changed event
+ * 
+ * @see DropTargetEvent
+ */
+public void dragOperationChanged(DropTargetEvent event);
+
+/**
+ * The cursor is moving over the drop target.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the value assigned to 
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ * 
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to 
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ * 
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code> 
+ * field.</p>
+ * 
+ * <p>The application can also change the type of data being requested by modifying the 
+ * <code>currentDataTypes</code> field  but the value must be one of the values in the 
+ * <code>dataTypes</code> list.</p>
+ * 
+ * <p>NOTE: At this point the <code>data</code> field is null.  On some platforms, it is possible 
+ * to obtain the data being transferred before the transfer occurs but in most platforms this is 
+ * not possible.  On those platforms where the data is available, the application can access the 
+ * data as follows:</p>
+ * 
+ * <pre><code>
+ * public void dragOver(DropTargetEvent event) {
+ *       TextTransfer textTransfer = TextTransfer.getInstance();
+ *       String data = (String)textTransfer.nativeToJava(event.currentDataType);
+ *       if (data !is null) {
+ *           System.out.println("Data to be dropped is (Text)"+data);
+ *       }
+ * };
+ * </code></pre>
+ *
+ * @param event  the information associated with the drag over event
+ * 
+ * @see DropTargetEvent
+ */
+public void dragOver(DropTargetEvent event);
+
+/**
+ * The data is being dropped.  The data field contains java format of the data being dropped.  
+ * To determine the type of the data object, refer to the documentation for the Transfer subclass 
+ * specified in event.currentDataType.
+ *
+ * <p>The following fields in DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x 
+ * <li>(in)y
+ * <li>(in,out)detail
+ * <li>(in)currentDataType
+ * <li>(in)data
+ * </ul></p>
+ *
+ * <p>The application can refuse to perform the drop operation by setting the detail 
+ * field to DND.DROP_NONE.</p>
+ *
+ * @param event the information associated with the drop event
+ * 
+ * @see DropTargetEvent
+ */
+public void drop(DropTargetEvent event);
+
+/**
+ * The drop is about to be performed.  
+ * The drop target is given a last chance to change the nature of the drop.
+ * 
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * </ul></p>
+ *
+ * <p>The application can veto the drop by setting the <code>event.detail</code> field to 
+ * <code>DND.DROP_NONE</code>.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the 
+ * <code>operations</code> field.</p>
+ * 
+ * <p>The application can also change the type of data being requested by modifying the 
+ * <code>currentDataTypes</code> field  but the value must be one of the values in the <
+ * code>dataTypes</code> list.</p>
+ *
+ * @param event  the information associated with the drop accept event
+ * 
+ * @see DropTargetEvent
+ */
+public void dropAccept(DropTargetEvent event);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/FileTransfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * 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
+ *     Outhink - support for typeFileURL
+ *******************************************************************************/
+module dwt.dnd;
+
+import java.io.*;
+import dwt.internal.carbon.*;
+ 
+/**
+ * The class <code>FileTransfer</code> provides a platform specific mechanism 
+ * for converting a list of files represented as a java <code>String[]</code> to a 
+ * platform specific representation of the data and vice versa.  
+ * Each <code>String</code> in the array contains the absolute path for a single 
+ * file or directory.
+ * See <code>Transfer</code> for additional information.
+ * 
+ * <p>An example of a java <code>String[]</code> containing a list of files is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     File file1 = new File("C:\temp\file1");
+ *     File file2 = new File("C:\temp\file2");
+ *     String[] fileData = new String[2];
+ *     fileData[0] = file1.getAbsolutePath();
+ *     fileData[1] = file2.getAbsolutePath();
+ * </code></pre>
+ */
+public class FileTransfer : ByteArrayTransfer {
+    
+    static FileTransfer _instance = new FileTransfer();
+    static final String HFS = "hfs "; //$NON-NLS-1$
+    static final String FURL = "furl"; //$NON-NLS-1$
+    static final int HFSID = registerType(HFS);
+    static final int FURLID = registerType(FURL);
+    
+FileTransfer() {}
+
+/**
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
+ */
+public static FileTransfer getInstance () {
+    return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a list of file names
+ * represented by a java <code>String[]</code> to a platform specific representation.
+ * Each <code>String</code> in the array contains the absolute path for a single 
+ * file or directory.  For additional information see 
+ * <code>Transfer#javaToNative</code>.
+ * 
+ * @param object a java <code>String[]</code> containing the file names to be 
+ * converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ *  object will be filled in on return with the platform specific format of the data
+ */
+public void javaToNative(Object object, TransferData transferData) {
+    if (!checkFile(object) || !isSupportedType(transferData)) {
+        DND.error(DND.ERROR_INVALID_DATA);
+    }
+    String[] files = (String[])object;
+    transferData.result = -1;
+    byte[][] data = new byte[files.length][];
+    for (int i = 0; i < data.length; i++) {
+        File file = new File(files[i]);
+        bool isDirectory = file.isDirectory();
+        String fileName = files[i];
+        char [] chars = new char [fileName.length ()];
+        fileName.getChars (0, chars.length, chars, 0);
+        int cfString = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length);
+        if (cfString is 0) return;
+        try {
+            int url = OS.CFURLCreateWithFileSystemPath(OS.kCFAllocatorDefault, cfString, OS.kCFURLPOSIXPathStyle, isDirectory);
+            if (url is 0) return;
+            try {
+                if (transferData.type is HFSID) {
+                    byte[] fsRef = new byte[80];
+                    if (!OS.CFURLGetFSRef(url, fsRef)) return;
+                    byte[] fsSpec = new byte[70];
+                    if (OS.FSGetCatalogInfo(fsRef, 0, null, null, fsSpec, null) !is OS.noErr) return;
+                    byte[] hfsflavor = new byte[10 + fsSpec.length];
+                    byte[] finfo = new byte[16];
+                    OS.FSpGetFInfo(fsSpec, finfo);
+                    System.arraycopy(finfo, 0, hfsflavor, 0, 10);
+                    System.arraycopy(fsSpec, 0, hfsflavor, 10, fsSpec.length);
+                    data[i] = hfsflavor;
+                }
+                if (transferData.type is FURLID) {
+                    int encoding = OS.CFStringGetSystemEncoding();
+                    int theData = OS.CFURLCreateData(OS.kCFAllocatorDefault, url, encoding, true);
+                    if (theData is 0) return;
+                    try {
+                        int length = OS.CFDataGetLength(theData);
+                        byte[] buffer = new byte[length];
+                        CFRange range = new CFRange();
+                        range.length = length;
+                        OS.CFDataGetBytes(theData, range, buffer);
+                        data[i] = buffer;
+                    } finally {
+                        OS.CFRelease(theData);
+                    }
+                }
+            } finally {
+                OS.CFRelease(url);
+            }
+        } finally {
+            OS.CFRelease(cfString);
+        }
+    }
+    transferData.data = data;
+    transferData.result = 0;
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of a list of file names to a java <code>String[]</code>.  
+ * Each String in the array contains the absolute path for a single file or directory. 
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be 
+ * been converted
+ * @return a java <code>String[]</code> containing a list of file names if the 
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData) {
+    if (!isSupportedType(transferData) || transferData.data is null) return null;
+    if (transferData.data.length is 0) return null;
+    int count = transferData.data.length;
+    String[] fileNames = new String[count];
+    for (int i=0; i<count; i++) {
+        byte[] data = transferData.data[i];
+        int url = 0;
+        if (transferData.type is HFSID) {
+            byte[] fsspec = new byte[data.length - 10];
+            System.arraycopy(data, 10, fsspec, 0, fsspec.length);
+            byte[] fsRef = new byte[80];
+            if (OS.FSpMakeFSRef(fsspec, fsRef) !is OS.noErr) return null;
+            url = OS.CFURLCreateFromFSRef(OS.kCFAllocatorDefault, fsRef);
+            if (url is 0) return null;
+        }
+        if (transferData.type is FURLID) {
+            int encoding = OS.kCFStringEncodingUTF8;
+            url = OS.CFURLCreateWithBytes(OS.kCFAllocatorDefault, data, data.length, encoding, 0);
+            if (url is 0) return null;
+        }
+        try {
+            int path = OS.CFURLCopyFileSystemPath(url, OS.kCFURLPOSIXPathStyle);
+            if (path is 0) return null;
+            try {
+                int length = OS.CFStringGetLength(path);
+                if (length is 0) return null;
+                char[] buffer= new char[length];
+                CFRange range = new CFRange();
+                range.length = length;
+                OS.CFStringGetCharacters(path, range, buffer);
+                fileNames[i] = new String(buffer);
+            } finally {
+                OS.CFRelease(path);
+            }
+        } finally {
+            OS.CFRelease(url);
+        }
+    }
+    return fileNames;
+}
+
+protected int[] getTypeIds(){
+    return new int[] {FURLID, HFSID};
+}
+
+protected String[] getTypeNames(){
+    return new String[] {FURL, HFS};
+}
+
+bool checkFile(Object object) {
+    if (object is null || !(object instanceof String[]) || ((String[])object).length is 0) return false;
+    String[] Strings = (String[])object;
+    for (int i = 0; i < Strings.length; i++) {
+        if (Strings[i] is null || Strings[i].length() is 0) return false;
+    }
+    return true;
+}
+
+protected bool validate(Object object) {
+    return checkFile(object);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/HTMLTransfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+ 
+import dwt.internal.carbon.OS;
+
+/**
+ * The class <code>HTMLTransfer</code> provides a platform specific mechanism 
+ * for converting text in HTML format represented as a java <code>String</code> 
+ * to a platform specific representation of the data and vice versa.  See 
+ * <code>Transfer</code> for additional information.
+ * 
+ * <p>An example of a java <code>String</code> containing HTML text is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     String htmlData = "<p>This is a paragraph of text.</p>";
+ * </code></pre>
+ */
+public class HTMLTransfer : ByteArrayTransfer {
+
+    static HTMLTransfer _instance = new HTMLTransfer();
+    static final String HTML = "HTML"; //$NON-NLS-1$
+    static final int HTMLID = registerType(HTML);
+
+HTMLTransfer() {}
+
+/**
+ * Returns the singleton instance of the HTMLTransfer class.
+ *
+ * @return the singleton instance of the HTMLTransfer class
+ */
+public static HTMLTransfer getInstance () {
+    return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts HTML-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ * 
+ * @param object a java <code>String</code> containing HTML text
+ * @param transferData an empty <code>TransferData</code> object; this
+ *  object will be filled in on return with the platform specific format of the data
+ */
+public void javaToNative (Object object, TransferData transferData){
+    if (!checkHTML(object) || !isSupportedType(transferData)) {
+        DND.error(DND.ERROR_INVALID_DATA);
+    }
+    String String = (String)object;
+    int count = String.length();
+    char[] chars = new char[count];
+    String.getChars(0, count, chars, 0);
+    byte[] buffer = new byte[chars.length * 2];
+    OS.memmove(buffer, chars, buffer.length);
+    transferData.data = new byte[1][];
+    transferData.data[0] = buffer;
+    transferData.result = OS.noErr;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of HTML text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be 
+ * been converted
+ * @return a java <code>String</code> containing HTML text if the 
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData){
+    if (!isSupportedType(transferData) || transferData.data is null) return null;
+    if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
+    byte[] buffer = transferData.data[0];
+    char[] chars = new char[(buffer.length + 1) / 2];
+    OS.memmove(chars, buffer, buffer.length);
+    return new String(chars);
+}
+
+protected int[] getTypeIds() {
+    return new int[] {HTMLID};
+}
+
+protected String[] getTypeNames() {
+    return new String[] {HTML};
+}
+
+bool checkHTML(Object object) {
+    return (object !is null && object instanceof String && ((String)object).length() > 0);
+}
+
+protected bool validate(Object object) {
+    return checkHTML(object);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/ImageTransfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *     Outhink - support for typeFileURL
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.DWT;
+import dwt.graphics.*;
+import dwt.internal.carbon.*;
+import dwt.widgets.*;
+
+/**
+ * The class <code>ImageTransfer</code> provides a platform specific mechanism
+ * for converting an Image represented as a java <code>ImageData</code> to a
+ * platform specific representation of the data and vice versa. The
+ * <code>ImageData</code> contains infomration about the Image. See
+ * <code>Transfer</code> for additional information.
+ * 
+ * <p>
+ * An example of a java <code>Image</code> containing an ImageData is shown
+ * below:
+ * </p>
+ * 
+ * <code><pre>
+ * Image image = new Image(display, fileName);
+ * ImageData imgData = image.getImageData();
+ * </code></pre>
+ */
+public class ImageTransfer : ByteArrayTransfer {
+
+static ImageTransfer _instance = new ImageTransfer();
+static final String PICT = "PICT"; //$NON-NLS-1$
+static final String TIFF = "TIFF"; //$NON-NLS-1$
+static final int PICTID = registerType(PICT);
+static final int TIFFID = registerType(TIFF);
+
+ImageTransfer() {
+}
+
+/**
+ * Returns the singleton instance of the ImageTransfer class.
+ * 
+ * @return the singleton instance of the ImageTransfer class
+ */
+public static ImageTransfer getInstance() {
+    return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts an ImageData
+ * object represented by a java <code>ImageData</code> to a platform
+ * specific representation. For additional information see
+ * <code>Transfer#javaToNative</code>.
+ * 
+ * @param object
+ *            a java <code>ImageData</code>
+ * @param transferData
+ *            an empty <code>TransferData</code> object; this object will
+ *            be filled in on return with the platform specific format of
+ *            the data
+ */
+public void javaToNative(Object object, TransferData transferData) {
+    if (!checkImage(object) || !isSupportedType(transferData)) {
+        DND.error(DND.ERROR_INVALID_DATA);
+    }
+    transferData.result = -1;
+
+    ImageData imgData = (ImageData) object;
+    Image image = new Image(Display.getCurrent(), imgData);
+    int handle = image.handle;
+    int width = OS.CGImageGetWidth(handle);
+    int height = OS.CGImageGetHeight(handle);
+    int alphaInfo = OS.CGImageGetAlphaInfo(handle);
+    int bpr = OS.CGImageGetBytesPerRow(handle);
+
+    Rect rect = new Rect();
+    rect.left = 0;
+    rect.top = 0;
+    rect.right = (short) width;
+    rect.bottom = (short) height;
+
+    int[] gWorld = new int[1];
+    int format = OS.k24RGBPixelFormat;
+    if (alphaInfo !is OS.kCGImageAlphaNoneSkipFirst) {
+        format = OS.k32ARGBPixelFormat;
+    }
+    OS.NewGWorldFromPtr(gWorld, format, rect, 0, 0, 0, image.data, bpr);
+    int[] curPort = new int[1];
+    int[] curGWorld = new int[1];
+    OS.GetGWorld(curPort, curGWorld);
+    OS.SetGWorld(gWorld[0], curGWorld[0]);
+    int pictHandle = OS.OpenPicture(rect);
+    int portBitMap = OS.GetPortBitMapForCopyBits(gWorld[0]);
+    OS.CopyBits(portBitMap, portBitMap, rect, rect, (short) OS.srcCopy, 0);
+    OS.ClosePicture();
+    OS.SetGWorld(curPort[0], curGWorld[0]);
+    OS.DisposeGWorld(gWorld[0]);
+    int length = OS.GetHandleSize(pictHandle);
+    OS.HLock(pictHandle);
+    int[] buffer = new int[1];
+    OS.memmove(buffer, pictHandle, 4);
+    byte[] pictData = new byte[length];
+    OS.memmove(pictData, buffer[0], length);
+    OS.HUnlock(pictHandle);
+    OS.KillPicture(pictHandle);
+    image.dispose();
+
+    transferData.data = new byte[][] { pictData };
+    transferData.result = OS.noErr;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform
+ * specific representation of an ImageData <code>ImageData</code>. For
+ * additional information see <code>Transfer#nativeToJava</code>.
+ * 
+ * @param transferData
+ *            the platform specific representation of the data to be been
+ *            converted
+ * @return a java <code>ImageData</code> object if the conversion was
+ *         successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData) {
+    if (!isSupportedType(transferData) || transferData.data is null)
+        return null;
+    if (transferData.data.length is 0)
+        return null;
+    byte[] dataArr = transferData.data[0];
+    int size = dataArr.length;
+    int pictPtr = OS.NewPtr(size);
+    OS.memmove(pictPtr, dataArr, size);
+    int dataProvider = OS.CGDataProviderCreateWithData(0, pictPtr, size, 0);
+    if (dataProvider !is 0) {
+        int pictDataRef = OS.QDPictCreateWithProvider(dataProvider);
+        // get bounds for the image
+        CGRect rect = new CGRect();
+        OS.QDPictGetBounds(pictDataRef, rect);
+        int width = (int) rect.width;
+        int height = (int) rect.height;
+
+        /* Create the image */
+        int bpr = width * 4;
+        int dataSize = height * bpr;
+        int data = OS.NewPtr(dataSize);
+        if (data is 0)
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        int provider = OS
+                .CGDataProviderCreateWithData(0, data, dataSize, 0);
+        if (provider is 0) {
+            OS.DisposePtr(data);
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        }
+        int colorspace = OS.CGColorSpaceCreateDeviceRGB();
+        if (colorspace is 0)
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        int handle = OS.CGImageCreate(width, height, 8, 32, bpr,
+                colorspace, OS.kCGImageAlphaNoneSkipFirst, provider, null,
+                true, 0);
+        OS.CGDataProviderRelease(provider);
+        if (handle is 0) {
+            OS.DisposePtr(data);
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        }
+        int bpc = OS.CGImageGetBitsPerComponent(handle);
+        int context = OS.CGBitmapContextCreate(data, width, height, bpc,
+                bpr, colorspace, OS.kCGImageAlphaNoneSkipFirst);
+        if (context is 0) {
+            OS.CGImageRelease(handle);
+            OS.DisposePtr(data);
+            DWT.error(DWT.ERROR_NO_HANDLES);
+        }
+        int status = OS.QDPictDrawToCGContext(context, rect, pictDataRef);
+        ImageData imgData = null;
+        if (status is 0) {
+            Image image = Image.carbon_new(Display.getCurrent(),
+                    DWT.BITMAP, handle, data);
+            imgData = image.getImageData();
+            image.dispose();
+        }
+        OS.CGContextRelease(context);
+        OS.QDPictRelease(pictDataRef);
+        return imgData;
+    }
+    return null;
+}
+
+protected int[] getTypeIds() {
+    return new int[] { PICTID };
+}
+
+protected String[] getTypeNames() {
+    return new String[] { PICT };
+}
+
+bool checkImage(Object object) {
+    if (object is null || !(object instanceof ImageData)) return false;
+    return true;
+}
+
+protected bool validate(Object object) {
+    return checkImage(object);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/RTFTransfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+ 
+import dwt.internal.carbon.OS;
+import dwt.internal.carbon.CFRange;
+
+/**
+ * The class <code>RTFTransfer</code> provides a platform specific mechanism 
+ * for converting text in RTF format represented as a java <code>String</code> 
+ * to a platform specific representation of the data and vice versa.  See 
+ * <code>Transfer</code> for additional information.
+ * 
+ * <p>An example of a java <code>String</code> containing RTF text is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
+ * </code></pre>
+ */
+public class RTFTransfer : ByteArrayTransfer {
+
+    static RTFTransfer _instance = new RTFTransfer();
+    static final String RTF = "RTF "; //$NON-NLS-1$
+    static final int RTFID = registerType(RTF);
+
+RTFTransfer() {}
+
+/**
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ */
+public static RTFTransfer getInstance () {
+    return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts RTF-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ * 
+ * @param object a java <code>String</code> containing RTF text
+ * @param transferData an empty <code>TransferData</code> object; this
+ *  object will be filled in on return with the platform specific format of the data
+ */
+public void javaToNative (Object object, TransferData transferData){
+    if (!checkRTF(object) || !isSupportedType(transferData)) {
+        DND.error(DND.ERROR_INVALID_DATA);
+    }
+    transferData.result = -1;
+    String String = (String)object;
+    int count = String.length();
+    char[] chars = new char[count];
+    String.getChars(0, count, chars, 0);
+    int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, count);
+    if (cfString is 0) return;
+    try {
+        CFRange range = new CFRange();
+        range.length = chars.length;
+        int encoding = OS.CFStringGetSystemEncoding();
+        int[] size = new int[1];
+        int numChars = OS.CFStringGetBytes(cfString, range, encoding, (byte)'?', true, null, 0, size);
+        if (numChars is 0 || size[0] is 0) return;
+        byte[] buffer = new byte[size[0]];
+        numChars = OS.CFStringGetBytes(cfString, range, encoding, (byte)'?', true, buffer, size [0], size);
+        if (numChars is 0) return;
+        transferData.data = new byte[1][];
+        transferData.data[0] = buffer;
+        transferData.result = 0;
+    } finally {
+        OS.CFRelease(cfString);
+    }
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of RTF text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be 
+ * been converted
+ * @return a java <code>String</code> containing RTF text if the 
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData){
+    if (!isSupportedType(transferData) || transferData.data is null) return null;
+    if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
+    byte[] buffer = transferData.data[0];
+    int encoding = OS.CFStringGetSystemEncoding();
+    int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
+    if (cfString is 0) return null;
+    try {
+        int length = OS.CFStringGetLength(cfString);
+        if (length is 0) return null;
+        char[] chars = new char[length];
+        CFRange range = new CFRange();
+        range.length = length;
+        OS.CFStringGetCharacters(cfString, range, chars);
+        return new String(chars);
+    } finally {
+        OS.CFRelease(cfString);
+    }
+}
+
+protected int[] getTypeIds() {
+    return new int[] {RTFID};
+}
+
+protected String[] getTypeNames() {
+    return new String[] {RTF};
+}
+
+bool checkRTF(Object object) {
+    return (object !is null && object instanceof String && ((String)object).length() > 0);
+}
+
+protected bool validate(Object object) {
+    return checkRTF(object);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/TableDragSourceEffect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.widgets.*;
+
+/**
+ * This class provides default implementations to display a source image
+ * when a drag is initiated from a <code>Table</code>.
+ * 
+ * <p>Classes that wish to provide their own source image for a <code>Table</code> can
+ * extend the <code>TableDragSourceEffect</code> class, override the 
+ * <code>TableDragSourceEffect.dragStart</code> method and set the field 
+ * <code>DragSourceEvent.image</code> with their own image.</p>
+ *
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag source effect implementation.
+ *
+ * @see DragSourceEffect
+ * @see DragSourceEvent
+ * 
+ * @since 3.3
+ */
+public class TableDragSourceEffect : DragSourceEffect {
+    /**
+     * Creates a new <code>TableDragSourceEffect</code> to handle drag effect 
+     * from the specified <code>Table</code>.
+     *
+     * @param table the <code>Table</code> that the user clicks on to initiate the drag
+     */
+    public TableDragSourceEffect(Table table) {
+        super(table);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/TableDropTargetEffect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.DWT;
+import dwt.graphics.*;
+import dwt.internal.Callback;
+import dwt.internal.carbon.DataBrowserCallbacks;
+import dwt.internal.carbon.OS;
+import dwt.widgets.*;
+
+/**
+ * This class provides a default drag under effect (eg. select, insert and scroll) 
+ * when a drag occurs over a <code>Table</code>.
+ * 
+ * <p>Classes that wish to provide their own drag under effect for a <code>Table</code>
+ * can extend the <code>TableDropTargetEffect</code> and override any applicable methods 
+ * in <code>TableDropTargetEffect</code> to display their own drag under effect.</p>
+ * 
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_SELECT, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * 
+ * @since 3.3
+ */
+public class TableDropTargetEffect : DropTargetEffect {
+    static final int SCROLL_HYSTERESIS = 150; // milli seconds
+
+    TableItem scrollItem;
+    long scrollBeginTime;
+    DataBrowserCallbacks callbacks = null;
+
+    static Callback AcceptDragProc;
+    static {
+        AcceptDragProc = new Callback(TableDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
+        int acceptDragProc = AcceptDragProc.getAddress();
+        if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+    }
+
+    static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
+        DropTarget target = FindDropTarget(theControl, theDrag);
+        if (target is null) return 0;
+        return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
+    }
+    
+    static DropTarget FindDropTarget(int theControl, int theDrag) {
+        if (theControl is 0) return null;
+        Display display = Display.findDisplay(Thread.currentThread());
+        if (display is null || display.isDisposed()) return null;
+        Widget widget = display.findWidget(theControl);
+        if (widget is null) return null;
+        return (DropTarget)widget.getData(DND.DROP_TARGET_KEY); 
+    }
+    
+    /**
+     * Creates a new <code>TableDropTargetEffect</code> to handle the drag under effect on the specified 
+     * <code>Table</code>.
+     * 
+     * @param table the <code>Table</code> over which the user positions the cursor to drop the data
+     */
+    public TableDropTargetEffect(Table table) {
+        super(table);
+    }
+
+    int checkEffect(int effect) {
+        // Some effects are mutually exclusive.  Make sure that only one of the mutually exclusive effects has been specified.
+        if ((effect & DND.FEEDBACK_SELECT) !is 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER & ~DND.FEEDBACK_INSERT_BEFORE;
+        if ((effect & DND.FEEDBACK_INSERT_BEFORE) !is 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER;
+        return effect;
+    }
+    
+    /**
+     * This implementation of <code>dragEnter</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragEnter</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragEnter(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag enter event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     */
+    public void dragEnter(DropTargetEvent event) {
+        if (callbacks is null) {
+            Table table = (Table) control;
+            DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+            OS.GetDataBrowserCallbacks (table.handle, callbacks);
+            callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
+            OS.SetDataBrowserCallbacks(table.handle, callbacks);
+        }
+        scrollBeginTime = 0;
+        scrollItem = null;
+    }
+
+    /**
+     * This implementation of <code>dragLeave</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>. 
+     * 
+     * For additional information see <code>DropTargetAdapter.dragLeave</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragLeave(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag leave event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     */
+    public void dragLeave(DropTargetEvent event) {
+        scrollBeginTime = 0;
+        scrollItem = null;
+    }
+
+    /**
+     * This implementation of <code>dragOver</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>. The class description 
+     * lists the FEEDBACK constants that are applicable to the class.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragOver</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragOver(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag over event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     * @see DND#FEEDBACK_SELECT
+     * @see DND#FEEDBACK_SCROLL
+     */
+    public void dragOver(DropTargetEvent event) {
+        Table table = (Table) control;
+        int effect = checkEffect(event.feedback);
+
+        TableItem item = (TableItem)getItem(table, event.x, event.y);
+
+        if ((effect & DND.FEEDBACK_SCROLL) is 0) {
+            scrollBeginTime = 0;
+            scrollItem = null;
+        } else {
+            if (item !is null && item.opEquals(scrollItem)  && scrollBeginTime !is 0) {
+                if (System.currentTimeMillis() >= scrollBeginTime) {
+                    Rectangle area = table.getClientArea();
+                    int headerHeight = table.getHeaderHeight();
+                    int itemHeight= table.getItemHeight();
+                    Point pt = new Point(event.x, event.y);
+                    pt = table.getDisplay().map(null, table, pt);
+                    TableItem nextItem = null;
+                    if (pt.y < area.y + headerHeight + 2 * itemHeight) {
+                        int index = Math.max(0, table.indexOf(item)-1);
+                        nextItem = table.getItem(index);
+                    }
+                    if (pt.y > area.y + area.height - 2 * itemHeight) {
+                        int index = Math.min(table.getItemCount()-1, table.indexOf(item)+1);
+                        nextItem = table.getItem(index);
+                    }
+                    if (nextItem !is null) table.showItem(nextItem);
+                    scrollBeginTime = 0;
+                    scrollItem = null;
+                }
+            } else {
+                scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+                scrollItem = item;
+            }
+        }
+        
+        // store current effect for selection feedback
+        ((DropTarget)event.widget).feedback = effect;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/TextTransfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.internal.carbon.CFRange;
+import dwt.internal.carbon.OS;
+ 
+/**
+ * The class <code>TextTransfer</code> provides a platform specific mechanism 
+ * for converting plain text represented as a java <code>String</code> 
+ * to a platform specific representation of the data and vice versa.
+ * 
+ * <p>An example of a java <code>String</code> containing plain text is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     String textData = "Hello World";
+ * </code></pre>
+ * 
+ * @see Transfer
+ */
+public class TextTransfer : ByteArrayTransfer {
+
+    static TextTransfer _instance = new TextTransfer();
+    static final String TEXT = "TEXT"; //$NON-NLS-1$
+    static final String UTEXT = "utxt"; //$NON-NLS-1$
+    static final int TEXTID = OS.kScrapFlavorTypeText;
+    static final int UTEXTID = OS.kScrapFlavorTypeUnicode;
+
+TextTransfer() {}
+
+/**
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
+ */
+public static TextTransfer getInstance () {
+    return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts plain text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * 
+ * @param object a java <code>String</code> containing text
+ * @param transferData an empty <code>TransferData</code> object; this object
+ *  will be filled in on return with the platform specific format of the data
+ *  
+ * @see Transfer#javaToNative
+ */
+public void javaToNative (Object object, TransferData transferData) {
+    if (!checkText(object) || !isSupportedType(transferData)) {
+        DND.error(DND.ERROR_INVALID_DATA);
+    }
+    String String = (String)object;
+    char[] chars = new char[String.length()];
+    String.getChars (0, chars.length, chars, 0);
+    transferData.result = -1;
+    switch (transferData.type) {
+        case TEXTID: {
+            int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, chars.length);
+            if (cfString is 0) return;
+            byte[] buffer = null;
+            try {
+                CFRange range = new CFRange();
+                range.length = chars.length;
+                int encoding = OS.CFStringGetSystemEncoding();
+                int[] size = new int[1];
+                int numChars = OS.CFStringGetBytes(cfString, range, encoding, (byte)'?', true, null, 0, size);
+                if (numChars is 0) return;
+                buffer = new byte[size[0]];
+                numChars = OS.CFStringGetBytes(cfString, range, encoding, (byte)'?', true, buffer, size [0], size);
+                if (numChars is 0) return;
+            } finally {
+                OS.CFRelease(cfString);
+            }
+            transferData.data = new byte[1][];
+            transferData.data[0] = buffer;
+            transferData.result = OS.noErr;
+            break;
+        }
+        case UTEXTID: {
+            byte[] buffer = new byte[chars.length * 2];
+            OS.memmove(buffer, chars, buffer.length);
+            transferData.data = new byte[1][];
+            transferData.data[0] = buffer;
+            transferData.result = OS.noErr;
+            break;
+        }
+    }
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of plain text to a java <code>String</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>String</code> containing text if the conversion was successful; otherwise null
+ * 
+ * @see Transfer#nativeToJava
+ */
+public Object nativeToJava(TransferData transferData){
+    if (!isSupportedType(transferData) || transferData.data is null) return null;
+    if (transferData.data.length is 0 || transferData.data[0].length is 0) return null;
+    byte[] buffer = transferData.data[0];
+    switch (transferData.type) {
+        case TEXTID: {
+            int encoding = OS.CFStringGetSystemEncoding();
+            int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
+            if (cfString is 0) return null;
+            try {
+                int length = OS.CFStringGetLength(cfString);
+                if (length is 0) return null;
+                char[] chars = new char[length];
+                CFRange range = new CFRange();
+                range.length = length;
+                OS.CFStringGetCharacters(cfString, range, chars);
+                return new String(chars);
+            } finally {
+                OS.CFRelease(cfString);
+            }
+        }
+        case UTEXTID: {
+            char[] chars = new char[(buffer.length + 1) / 2];
+            OS.memmove(chars, buffer, buffer.length);
+            return new String(chars);
+        }
+    }
+    return null;
+}
+
+protected int[] getTypeIds() {
+    return new int[] {UTEXTID, TEXTID};
+}
+
+protected String[] getTypeNames() {
+    return new String[] {UTEXT, TEXT};
+}
+
+bool checkText(Object object) {
+    return (object !is null && object instanceof String && ((String)object).length() > 0);
+}
+protected bool validate(Object object) {
+    return checkText(object);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/Transfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+ 
+/**
+ * <code>Transfer</code> provides a mechanism for converting between a java 
+ * representation of data and a platform specific representation of data and 
+ * vice versa.  It is used in data transfer operations such as drag and drop and 
+ * clipboard copy/paste.
+ *
+ * <p>You should only need to become familiar with this class if you are 
+ * implementing a Transfer subclass and you are unable to subclass the 
+ * ByteArrayTransfer class.</p>
+ * 
+ * @see ByteArrayTransfer
+ */
+public abstract class Transfer {
+    
+/**
+ * Returns a list of the platform specific data types that can be converted using 
+ * this transfer agent.
+ *
+ * <p>Only the data type fields of the <code>TransferData</code> objects are filled 
+ * in.</p>
+ *
+ * @return a list of the data types that can be converted using this transfer agent
+ */
+abstract public TransferData[] getSupportedTypes();
+
+/**
+ * Returns true if the <code>TransferData</code> data type can be converted 
+ * using this transfer agent, or false otherwise (including if transferData is
+ * <code>null</code>).
+ *
+ * @param transferData a platform specific description of a data type; only the data
+ *  type fields of the <code>TransferData</code> object need to be filled in
+ *
+ * @return true if the transferData data type can be converted using this transfer 
+ * agent
+ */
+abstract public bool isSupportedType(TransferData transferData);
+
+/**
+ * Returns the platform specific ids of the  data types that can be converted using 
+ * this transfer agent.
+ * 
+ * @return the platform specific ids of the data types that can be converted using 
+ * this transfer agent
+ */
+abstract protected int[] getTypeIds();
+
+/**
+ * Returns the platform specific names of the  data types that can be converted 
+ * using this transfer agent.
+ * 
+ * @return the platform specific names of the data types that can be converted 
+ * using this transfer agent.
+ */
+abstract protected String[] getTypeNames();
+
+/**
+ * Converts a java representation of data to a platform specific representation of 
+ * the data. 
+ *
+ * <p>On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: COM.S_OK
+ * <li>Motif: 1
+ * <li>GTK: 1
+ * <li>Photon: 1
+ * </ul></p>
+ * 
+ * <p>If this transfer agent is unable to perform the conversion, the transferData.result 
+ * field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
+ * <li>Motif: 0
+ * <li>GTK: 0
+ * <li>Photon: 0
+ * </ul></p>
+ *
+ * @param object a java representation of the data to be converted; the type of
+ * Object that is passed in is dependent on the <code>Transfer</code> subclass.
+ *
+ * @param transferData an empty TransferData object; this object will be 
+ * filled in on return with the platform specific representation of the data
+ * 
+ * @exception dwt.DWTException <ul>
+ *    <li>ERROR_INVALID_DATA - if object does not contain data in a valid format or is <code>null</code></li>
+ * </ul>
+ */
+abstract protected void javaToNative (Object object, TransferData transferData);
+
+/**
+ * Converts a platform specific representation of data to a java representation.
+ * 
+ * @param transferData the platform specific representation of the data to be 
+ * converted
+ *
+ * @return a java representation of the converted data if the conversion was 
+ * successful; otherwise null.  If transferData is <code>null</code> then
+ * <code>null</code> is returned.  The type of Object that is returned is 
+ * dependent on the <code>Transfer</code> subclass.
+ */
+abstract protected Object nativeToJava(TransferData transferData);
+
+/**
+ * Registers a name for a data type and returns the associated unique identifier.
+ *
+ * <p>You may register the same type more than once, the same unique identifier 
+ * will be returned if the type has been previously registered.</p>
+ *
+ * <p>Note: On windows, do <b>not</b> call this method with pre-defined 
+ * Clipboard Format types such as CF_TEXT or CF_BITMAP because the 
+ * pre-defined identifier will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with this data type
+ */
+public static int registerType(String formatName) {
+    int length = formatName.length();
+    // TODO - hashcode may not be unique - need another way
+    if (length > 4) return formatName.toHash();
+    int type = 0;
+    if (length > 0) type |= (formatName.charAt(0) & 0xff) << 24;
+    if (length > 1) type |= (formatName.charAt(1) & 0xff) << 16;
+    if (length > 2) type |= (formatName.charAt(2) & 0xff) << 8;
+    if (length > 3) type |= formatName.charAt(3) & 0xff; 
+    return type;
+}
+
+/**
+ * Test that the object is of the correct format for this Transfer class.
+ * 
+ * @param object a java representation of the data to be converted
+ * 
+ * @return true if object is of the correct form for this transfer type
+ * 
+ * @since 3.1
+ */
+protected bool validate(Object object) {
+    return true;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/TransferData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+ 
+/**
+ * The <code>TransferData</code> class is a platform specific data structure for
+ * describing the type and the contents of data being converted by a transfer agent.
+ *
+ * <p>As an application writer, you do not need to know the specifics of 
+ * TransferData.  TransferData instances are passed to a subclass of Transfer 
+ * and the Transfer object manages the platform specific issues.  
+ * You can ask a Transfer subclass if it can handle this data by calling 
+ * Transfer.isSupportedType(transferData).</p>
+ *
+ * <p>You should only need to become familiar with the fields in this class if you 
+ * are implementing a Transfer subclass and you are unable to subclass the 
+ * ByteArrayTransfer class.</p>
+ */
+public class TransferData {
+    /**
+     * The type is a unique identifier of a system format or user defined format.
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the modules provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public int type;
+    
+    /**
+     * The data being transferred.
+     * The data field may contain multiple values.
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the modules provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public byte[][] data;
+    
+    /**
+     * The result field contains the result of converting a
+     * java data type into a platform specific value.
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the modules provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     * <p>The value of result is 1 if the conversion was successful.
+     * The value of result is 0 if the conversion failed.</p>
+     */
+    public int result;
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/TreeDragSourceEffect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.widgets.*;
+
+/**
+ * This class provides default implementations to display a source image
+ * when a drag is initiated from a <code>Tree</code>.
+ * 
+ * <p>Classes that wish to provide their own source image for a <code>Tree</code> can
+ * extend <code>TreeDragSourceEffect</code> class and override the <code>TreeDragSourceEffect.dragStart</code>
+ * method and set the field <code>DragSourceEvent.image</code> with their own image.</p>
+ *
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * @see DragSourceEffect
+ * @see DragSourceEvent
+ * 
+ * @since 3.3
+ */
+public class TreeDragSourceEffect : DragSourceEffect {
+    /**
+     * Creates a new <code>TreeDragSourceEffect</code> to handle drag effect 
+     * from the specified <code>Tree</code>.
+     *
+     * @param tree the <code>Tree</code> that the user clicks on to initiate the drag
+     */
+    public TreeDragSourceEffect(Tree tree) {
+        super(tree);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/TreeDropTargetEffect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.dnd;
+
+import dwt.*;
+import dwt.graphics.*;
+import dwt.internal.Callback;
+import dwt.internal.carbon.DataBrowserCallbacks;
+import dwt.internal.carbon.OS;
+import dwt.widgets.*;
+
+/**
+ * This class provides a default drag under effect (eg. select, insert, scroll and expand) 
+ * when a drag occurs over a <code>Tree</code>.
+ * 
+ * <p>Classes that wish to provide their own drag under effect for a <code>Tree</code>
+ * can extend the <code>TreeDropTargetEffect</code> class and override any applicable methods 
+ * in <code>TreeDropTargetEffect</code> to display their own drag under effect.</p>
+ *
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_SELECT, FEEDBACK_INSERT_BEFORE, FEEDBACK_INSERT_AFTER, FEEDBACK_EXPAND, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles FEEDBACK_SELECT, FEEDBACK_INSERT_BEFORE or
+ * FEEDBACK_INSERT_AFTER may be specified.
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * 
+ * @since 3.3
+ */
+public class TreeDropTargetEffect : DropTargetEffect {
+    static final int SCROLL_HYSTERESIS = 150; // milli seconds
+    static final int EXPAND_HYSTERESIS = 1000; // milli seconds
+
+    int currentEffect = DND.FEEDBACK_NONE;
+    TreeItem currentItem;
+
+    TreeItem insertItem = null;
+    bool insertBefore = false;
+
+    TreeItem scrollItem;
+    long scrollBeginTime;
+
+    TreeItem expandItem;
+    long expandBeginTime;
+    
+    DataBrowserCallbacks callbacks = null;
+    
+    int acceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
+        return (currentEffect & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
+    }
+
+    static Callback AcceptDragProc;
+    static {
+        AcceptDragProc = new Callback(TreeDropTargetEffect.class, "AcceptDragProc", 5); //$NON-NLS-1$
+        int acceptDragProc = AcceptDragProc.getAddress();
+        if (acceptDragProc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+    }
+
+    static int AcceptDragProc(int theControl, int itemID, int property, int theRect, int theDrag) {
+        DropTarget target = FindDropTarget(theControl, theDrag);
+        if (target is null) return 0;
+        return (target.feedback & DND.FEEDBACK_SELECT) !is 0 ? 1 : 0;
+    }
+    
+    static DropTarget FindDropTarget(int theControl, int theDrag) {
+        if (theControl is 0) return null;
+        Display display = Display.findDisplay(Thread.currentThread());
+        if (display is null || display.isDisposed()) return null;
+        Widget widget = display.findWidget(theControl);
+        if (widget is null) return null;
+        return (DropTarget)widget.getData(DND.DROP_TARGET_KEY); 
+    }
+
+    /**
+     * Creates a new <code>TreeDropTargetEffect</code> to handle the drag under effect on the specified 
+     * <code>Tree</code>.
+     * 
+     * @param tree the <code>Tree</code> over which the user positions the cursor to drop the data
+     */
+    public TreeDropTargetEffect(Tree tree) {
+        super(tree);
+    }
+
+    int checkEffect(int effect) {
+        // Some effects are mutually exclusive.  Make sure that only one of the mutually exclusive effects has been specified.
+        if ((effect & DND.FEEDBACK_SELECT) !is 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER & ~DND.FEEDBACK_INSERT_BEFORE;
+        if ((effect & DND.FEEDBACK_INSERT_BEFORE) !is 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER;
+        return effect;
+    }
+
+    /**
+     * This implementation of <code>dragEnter</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragEnter</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragEnter(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag enter event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     */
+    public void dragEnter(DropTargetEvent event) {
+        if (callbacks is null) {
+            Tree table = (Tree) control;
+            DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+            OS.GetDataBrowserCallbacks (table.handle, callbacks);
+            callbacks.v1_acceptDragCallback = AcceptDragProc.getAddress();
+            OS.SetDataBrowserCallbacks(table.handle, callbacks);
+        }
+        insertItem = null;
+        expandBeginTime = 0;
+        expandItem = null;
+        scrollBeginTime = 0;
+        scrollItem = null;
+    }
+
+    /**
+     * This implementation of <code>dragLeave</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragLeave</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragLeave(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag leave event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     */
+    public void dragLeave(DropTargetEvent event) {
+        Tree tree = (Tree) control;
+        if (insertItem !is null) {
+            setInsertMark(tree, null, false);
+            insertItem = null;
+        }
+        expandBeginTime = 0;
+        expandItem = null;
+        scrollBeginTime = 0;
+        scrollItem = null;
+    }
+
+    /**
+     * This implementation of <code>dragOver</code> provides a default drag under effect
+     * for the feedback specified in <code>event.feedback</code>.
+     * 
+     * For additional information see <code>DropTargetAdapter.dragOver</code>.
+     * 
+     * Subclasses that override this method should call <code>super.dragOver(event)</code>
+     * to get the default drag under effect implementation.
+     *
+     * @param event  the information associated with the drag over event
+     * 
+     * @see DropTargetAdapter
+     * @see DropTargetEvent
+     * @see DND#FEEDBACK_SELECT
+     * @see DND#FEEDBACK_INSERT_BEFORE
+     * @see DND#FEEDBACK_INSERT_AFTER
+     * @see DND#FEEDBACK_SCROLL
+     */
+    public void dragOver(DropTargetEvent event) {
+        Tree tree = (Tree) control;
+        TreeItem item = (TreeItem)getItem(tree, event.x, event.y);
+        int effect = checkEffect(event.feedback);       
+        if ((effect & DND.FEEDBACK_EXPAND) is 0) {
+            expandBeginTime = 0;
+            expandItem = null;
+        } else {
+            if (item !is null && item.opEquals(expandItem) && expandBeginTime !is 0) {
+                if (System.currentTimeMillis() >= expandBeginTime) {
+                    if (item.getItemCount() > 0 && !item.getExpanded()) {
+                        Event e = new Event();
+                        e.x = event.x;
+                        e.y = event.y;
+                        e.item = item;
+                        e.time = (int) System.currentTimeMillis();
+                        tree.notifyListeners(DWT.Expand, e);
+                        if (item.isDisposed()) return;
+                        item.setExpanded(true);
+                    }
+                    expandBeginTime = 0;
+                    expandItem = null;
+                }
+            } else {
+                expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
+                expandItem = item;
+            }
+        }
+        
+        if ((effect & DND.FEEDBACK_SCROLL) is 0) {
+            scrollBeginTime = 0;
+            scrollItem = null;
+        } else {
+            if (item !is null && item.opEquals(scrollItem)  && scrollBeginTime !is 0) {
+                if (System.currentTimeMillis() >= scrollBeginTime) {
+                    Rectangle area = tree.getClientArea();
+                    int headerHeight = tree.getHeaderHeight();
+                    int itemHeight= tree.getItemHeight();
+                    Point pt = new Point(event.x, event.y);
+                    pt = tree.getDisplay().map(null, tree, pt);
+                    TreeItem nextItem = null;
+                    if (pt.y < area.y + headerHeight + 2 * itemHeight) {
+                        nextItem = previousItem(tree, item);
+                    }
+                    if (pt.y > area.y + area.height - 2 * itemHeight) {
+                        nextItem = nextItem(tree, item);
+                    }
+                    if (nextItem !is null) tree.showItem(nextItem);
+                    scrollBeginTime = 0;
+                    scrollItem = null;
+                }
+            } else {
+                scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+                scrollItem = item;
+            }
+        }
+        
+        if ((effect & DND.FEEDBACK_INSERT_AFTER) !is 0 ||
+            (effect & DND.FEEDBACK_INSERT_BEFORE) !is 0) {
+            if (currentItem !is item || 
+                 ((effect & DND.FEEDBACK_INSERT_AFTER) !is (currentEffect & DND.FEEDBACK_INSERT_AFTER)) ||
+                 ((effect & DND.FEEDBACK_INSERT_BEFORE) !is (currentEffect & DND.FEEDBACK_INSERT_BEFORE))) { 
+                setInsertMark(tree, item, (effect & DND.FEEDBACK_INSERT_BEFORE) !is 0);
+                currentEffect = effect;
+                currentItem = item;
+            }
+        } else {
+            setInsertMark(tree, null, false);
+        }
+        // save current effect for selection feedback
+        ((DropTarget)event.widget).feedback = effect;
+    }
+
+    void setInsertMark(Tree tree, TreeItem item, bool before) {
+        if (item is insertItem && before is insertBefore) return;
+        insertItem = item;
+        insertBefore = before;
+        tree.setInsertMark(item, before);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dnd/URLTransfer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1 @@
+/*******************************************************************************
 * Copyright (c) 20007 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
 *******************************************************************************/
module dwt.dnd;

import dwt.internal.carbon.*;

/**
 * The class <code>URLTransfer</code> provides a platform specific mechanism 
 * for converting text in URL format represented as a java <code>String</code> 
 * to a platform specific representation of the data and vice versa.  See 
 * <code>Transfer</code> for additional information. The String  
 * must contain the fully specified url.
 * 
 * <p>An example of a java <code>String[]</code> containing a URL is shown 
 * below:</p>
 * 
 * <code><pre>
 *     String url = "http://www.eclipse.org";
 * </code></pre>
 */
public class URLTransfer : ByteArrayTransfer {

  static URLTransfer _instance = new URLTransfer();
 static final String URL = "url "; //$NON-NLS-1$
   static final int URL_ID = registerType(URL);
  static final String URLN = "urln"; //$NON-NLS-1$
  static final int URLN_ID = registerType(URLN);

private URLTransfer() {}

/**
 * Returns the singleton instance of the URLTransfer class.
 *
 * @return the singleton instance of the URLTransfer class
 */
public static URLTransfer getInstance () {
   return _instance;
}

/**
 * This implementation of <code>javaToNative</code> converts a URL
 * represented by a java <code>String</code> to a platform specific representation.
 * For additional information see <code>Transfer#javaToNative</code>.
 * 
 * @param object a java <code>String[]</code> containing a URL
 * @param transferData an empty <code>TransferData</code> object; this
 *  object will be filled in on return with the platform specific format of the data
 */
public void javaToNative (Object object, TransferData transferData){
 if (!checkURL(object) || !isSupportedType(transferData)) {
        DND.error(DND.ERROR_INVALID_DATA);
    }
 transferData.result = -1;
 String url = (String)object;
  int count = url.length();
 char[] chars = new char[count];
   url.getChars(0, count, chars, 0);
 int cfString = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, count);
 if (cfString is 0) return;
    try {
     CFRange range = new CFRange();
        range.length = chars.length;
      int encoding = OS.CFStringGetSystemEncoding();
        int[] size = new int[1];
      int numChars = OS.CFStringGetBytes(cfString, range, encoding, (byte)'?', true, null, 0, size);
        if (numChars is 0 || size[0] is 0) return;
        byte[] buffer = new byte[size[0]];
        numChars = OS.CFStringGetBytes(cfString, range, encoding, (byte)'?', true, buffer, size [0], size);
       if (numChars is 0) return;
        transferData.data = new byte[][] {buffer};
        transferData.result = 0;
  } finally {
       OS.CFRelease(cfString);
   }
}

/**
 * This implementation of <code>nativeToJava</code> converts a platform specific 
 * representation of a URL to a java <code>String</code>.
 * For additional information see <code>Transfer#nativeToJava</code>.
 * 
 * @param transferData the platform specific representation of the data to be 
 * converted
 * @return a java <code>String[]</code> containing a URL if the 
 * conversion was successful; otherwise null
 */
public Object nativeToJava(TransferData transferData){
  if (!isSupportedType(transferData) || transferData.data is null) return null;
 if (transferData.data.length is 0) return null;
   byte[] buffer = transferData.data[0];
 int encoding = OS.CFStringGetSystemEncoding();
    int cfString = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
 if (cfString is 0) return null;
   try {
     int length = OS.CFStringGetLength(cfString);
      if (length is 0) return null;
     char[] chars = new char[length];
      CFRange range = new CFRange();
        range.length = length;
        OS.CFStringGetCharacters(cfString, range, chars);
     return new String(chars);
 } finally {
       OS.CFRelease(cfString);
   }
}

protected int[] getTypeIds(){
 return new int[] {URL_ID, URLN_ID};
}

protected String[] getTypeNames(){
  return new String[] {URL, URLN}; 
}

bool checkURL(Object object) {
    return object !is null && (object instanceof String) && ((String)object).length() > 0;
}

protected bool validate(Object object) {
 return checkURL(object);
}
}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/BufferedInputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,107 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+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 is count );
+        pos = 0;
+        count = 0;
+        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();
+    }
+
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/BufferedOutputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,154 @@
+/*
+ * @(#)BufferedInputStream.java 1.50 04/05/03
+ *
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ * 
+ * Port to the D programming language:
+ *      Jacob Carlborg <jacob.carlborg@gmail.com>
+ */
+module dwt.dwthelper.BufferedOutputStream;
+
+import tango.core.Exception;
+
+import dwt.dwthelper.OutputStream;
+import dwt.dwthelper.System;
+
+/**
+ * The class : a buffered output stream. By setting up such 
+ * an output stream, an application can write bytes to the underlying 
+ * output stream without necessarily causing a call to the underlying 
+ * system for each byte written.
+ *
+ * Authors: Arthur van Hoff, Jacob Carlborg
+ * Version: 1.33, 12/19/03
+ * Since: JDK1.0
+ */
+class BufferedOutputStream : OutputStream
+{
+    /// The internal buffer where data is stored.
+    protected byte buf[];
+
+    /**
+     * The number of valid bytes in the buffer. This value is always 
+     * in the range <tt>0</tt> through <tt>buf.length</tt>; elements 
+     * <tt>buf[0]</tt> through <tt>buf[count-1]</tt> contain valid 
+     * byte data.
+     */
+    protected int count;
+
+    /**
+     * Creates a new buffered output stream to write data to the
+     * specified underlying output stream.
+     * 
+     * Params:
+     *     ostr = the underlying output stream.
+     */
+    public this (OutputStream ostr)
+    {
+        this(ostr, 8192);
+    }
+
+    /**
+     * Creates a new buffered output stream to write data to the 
+     * specified underlying output stream with the specified buffer 
+     * size.
+     * 
+     * Params:
+     *     ostr = the underlying output stream
+     *     size = the buffer size.
+     *     
+     * Throws: IllegalArgumentException if size &lt;= 0.
+     */
+    public this (OutputStream ostr, int size)
+    {
+        super(ostr);
+
+        if (size <= 0)
+            throw new IllegalArgumentException("Buffer size <= 0");
+
+        buf = new byte[size];
+    }
+
+    /**
+     * Flush the internal buffer
+     *
+     * Throws: IOException
+     */
+    private void flushBuffer ()
+    {
+        if (count > 0)
+        {
+            ostr.write(buf, 0, count);
+            count = 0;
+        }
+    }
+
+    /**
+     * Writes the specified byte to this buffered output stream.
+     * 
+     * Params:
+     *     b = he byte to be written.
+     *     
+     * Throws: IOException if an I/O error occurs.
+     */
+    public synchronized void write (int b)
+    {
+        if (count >= buf.length)
+            flushBuffer();
+
+        buf[count] = cast(byte) b;
+        count++;
+    }
+
+    /**
+     * Writes $(D_CODE len) bytes from the specified byte array 
+     * starting at offset $(D_CODE off) to this buffered output stream.
+     * 
+     * $(P Ordinarily this method stores bytes from the given array into this
+     * stream's buffer, flushing the buffer to the underlying output stream as
+     * needed.  If the requested length is at least as large as this stream's
+     * buffer, however, then this method will flush the buffer and write the
+     * bytes directly to the underlying output stream.  Thus redundant
+     * $(D_CODE BufferedOutputStream)s will not copy data unnecessarily.)
+     * 
+     * Params:
+     *     b = the data
+     *     off = the start offset in the data
+     *     len = the number of bytes to write
+     *     
+     * Throws: IOException if an I/O error occurs
+     */
+    public synchronized void write (byte b[], int off, int len)
+    {
+        if (len >= buf.length)
+        {
+            /* If the request length exceeds the size of the output buffer,
+             flush the output buffer and then write the data directly.
+             In this way buffered streams will cascade harmlessly. */
+            flushBuffer();
+            ostr.write(b, off, len);
+            return;
+        }
+
+        if (len > buf.length - count)
+            flushBuffer();
+
+        System.arraycopy(b, off, buf, count, len);
+        count += len;
+    }
+
+    /**
+     * 
+     * Flushes this buffered output stream. This forces any buffered 
+     * output bytes to be written out to the underlying output stream.
+     * 
+     * Throws: IOException if an I/O error occurs
+     * See_Also: java.io.FilterOutputStream#out
+     */
+    public synchronized void flush ()
+    {
+        flushBuffer();
+        ostr.flush();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/ByteArrayInputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,70 @@
+/* language convertion www.dsource.org/project/tioport */
+module dwt.dwthelper.ByteArrayInputStream;
+
+import dwt.dwthelper.InputStream;
+
+public class ByteArrayInputStream : 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 pos;
+    protected int fld_mark = 0;
+    //protected int count;
+    public this ( byte[] aBuf ){
+        this.buf = aBuf;
+    }
+
+    public this ( byte[] aBuf, int offset, int length_ESCAPE ){
+        this.buf = aBuf[ offset .. offset+length_ESCAPE ];
+    }
+
+    public synchronized int read(){
+        if( pos >= this.buf.length ){
+            return -1;
+        }
+        int result = this.buf[pos];
+        pos++;
+        return result & 0xFF;
+    }
+
+    public synchronized int read( byte[] b, int off, int len ){
+        return super.read( b, off, len );
+    }
+
+    public synchronized long skip( long n ){
+        pos += n;
+        return 0L;
+    }
+
+    public synchronized int available(){
+        if( pos >= this.buf.length ){
+            return 0;
+        }
+        return this.buf.length - pos;
+    }
+
+    public bool markSupported(){
+        return false;
+    }
+
+    public void mark( int readAheadLimit ){
+    }
+
+    public synchronized void reset(){
+        pos = 0;
+    }
+
+    public void close(){
+    }
+
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/ByteArrayOutputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,69 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+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__ );
+    }
+
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/File.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,202 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+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;
+    }
+
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/FileInputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,77 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+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 is 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();
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/FileOutputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,55 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+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__ );
+    }
+
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/InflaterInputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,68 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+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__ );
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/InputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,61 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+
+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 is -1 ){
+                return ( idx is 0 ) ? -1 : 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;
+    }
+
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/OutputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,50 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+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__ );
+    }
+
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/ResourceBundle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,144 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+module dwt.dwthelper.ResourceBundle;
+
+import tango.text.Util;
+import tango.io.Stdout;
+
+import dwt.DWT;
+import dwt.dwthelper.utils;
+import dwt.dwthelper.utils : IOException;
+import tango.io.File;
+
+class ResourceBundle {
+
+    char[][ char[] ] map;
+
+    public this( char[] data ){
+        char[] line;
+        int dataIndex;
+
+        //tango.io.Stdout.Stdout.formatln( "properties put ..." );
+        void readLine(){
+            line.length = 0;
+            char i = data[ dataIndex++ ];
+            while( dataIndex < data.length && i !is '\n' && i !is '\r' ){
+                line ~= i;
+                i = data[ dataIndex++ ];
+            }
+        }
+
+        //tango.io.Stdout.Stdout.formatln( "properties put {}", __LINE__ );
+        bool linecontinue = false;
+        bool iskeypart = true;
+        char[] key;
+        char[] value;
+nextline:
+        while( dataIndex < data.length ){
+            //tango.io.Stdout.Stdout.formatln( "properties put {} startline", __LINE__ );
+            readLine();
+            line = dwt.dwthelper.utils.trim(line);
+            if( line.length is 0 ){
+                //tango.io.Stdout.Stdout.formatln( "properties put {} was 0 length", __LINE__ );
+                continue;
+            }
+            if( line[0] is '#' ){
+                //tango.io.Stdout.Stdout.formatln( "properties put {} was comment", __LINE__ );
+                continue;
+            }
+            int pos = 0;
+            bool esc = false;
+            if( !linecontinue ){
+                iskeypart = true;
+                key = null;
+                value = null;
+            }
+            else{
+                linecontinue = false;
+            }
+            while( pos < line.length ){
+                char c = line[pos];
+                if( esc ){
+                    esc = false;
+                    switch( c ){
+                    case 't' : c = '\t'; break;
+                    case 'n' : c = '\n'; break;
+                    case '\\': c = '\\'; break;
+                    case '\"': c = '\"'; break;
+                    //case ':' : c = ':' ; break;
+                    default: break;
+                    }
+                }
+                else{
+                    if( c is '\\' ){
+                        if( pos is line.length -1 ){
+                            linecontinue = true;
+                            goto nextline;
+                        }
+                        esc = true;
+                        pos++;
+                        continue;
+                    }
+                    else if( iskeypart && c is '=' ){
+                        pos++;
+                        iskeypart = false;
+                        continue;
+                    }
+                }
+                pos++;
+                if( iskeypart ){
+                    key ~= c;
+                }
+                else{
+                    value ~= c;
+                }
+            }
+            if( iskeypart ){
+                // Cannot find '=' in record
+                DWT.error( __FILE__, __LINE__, DWT.ERROR_INVALID_ARGUMENT );
+                continue;
+            }
+            key = dwt.dwthelper.utils.trim(key);
+            value = dwt.dwthelper.utils.trim(value);
+            //tango.io.Stdout.Stdout.formatln( "properties put {}=>{}", key, value );
+
+            map[ key.dup ] = value.dup;
+            //tango.io.Stdout.Stdout.formatln( "properties put {}", __LINE__ );
+        }
+    }
+
+    public bool hasString( char[] key ){
+        return ( key in map ) !is null;
+    }
+
+    public char[] getString( char[] key ){
+        if( auto v = key in map ){
+            return (*v).dup;
+        }
+        throw new MissingResourceException( "key not found", this.classinfo.name, key );
+    }
+
+    public char[][] getKeys(){
+        return map.keys;
+    }
+
+    public static ResourceBundle getBundle( ImportData data ){
+        return new ResourceBundle( cast(char[]) data.data );
+    }
+    public static ResourceBundle getBundle( char[] name ){
+        try{
+            scope f = new File(name);
+            return new ResourceBundle( cast(char[]) f.read() );
+        }
+        catch( IOException e){
+            e.msg ~= " file:" ~ name;
+            throw e;
+        }
+    }
+    public static ResourceBundle getBundleFromData( char[] data ){
+        return new ResourceBundle( data );
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/Runnable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/**
+ * Authors: Frank Benoit <benoit@tionex.de>
+ */
+module dwt.dwthelper.Runnable;
+
+
+import tango.core.Tuple;
+import tango.core.Traits;
+
+public interface Runnable  {
+
+    public abstract void run();
+
+}
+
+class _DgRunnableT(Dg,T...) : Runnable {
+
+    alias ParameterTupleOf!(Dg) DgArgs;
+    static assert( is(DgArgs == Tuple!(T)),
+                "Delegate args not correct" );
+
+    Dg dg;
+    T t;
+
+    private this( Dg dg, T t ){
+        this.dg = dg;
+        static if( T.length > 0 ){
+            this.t = t;
+        }
+    }
+
+    void run( ){
+        dg(t);
+    }
+}
+
+_DgRunnableT!(Dg,T) dgRunnable(Dg,T...)( Dg dg, T args ){
+    return new _DgRunnableT!(Dg,T)(dg,args);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/System.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,145 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+module dwt.dwthelper.System;
+
+import tango.core.Exception;
+import tango.time.Clock;
+import tango.stdc.stdlib : exit;
+
+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 is 0)
+            return;
+
+        if(index < 0 || index >= items.length){
+            throw new ArrayBoundsException(__FILE__, __LINE__);
+        }
+
+        T element = items[index];
+
+        int length = items.length;
+        if(length is 1){
+            items.length = 0;
+            return;// element;
+        }
+
+        if(index is 0)
+            items = items[1 .. $];
+        else if(index is 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 is -1)
+            index = items.length;
+
+        if(index < 0 || index > items.length ){
+            throw new ArrayBoundsException(__FILE__, __LINE__);
+        }
+
+        if(index is items.length){
+            items ~= item;
+        }else if(index is 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 is 0) return;
+
+        assert(src);
+        assert(dest);
+        debug{validCheck(src.length - srcPos, dest.length - destPos, len);}
+
+        if(src is dest){
+            for(int i=0; i<len; ++i){
+                dest[destPos+i] = src[srcPos+i];
+            }
+        }else{
+            dest[destPos..(len+destPos)] = src[srcPos..(len+srcPos)];
+        }
+    }
+}
+
+
+class System {
+
+    alias SimpleType!(int).arraycopy arraycopy;
+    alias SimpleType!(byte).arraycopy arraycopy;
+    alias SimpleType!(double).arraycopy arraycopy;
+    alias SimpleType!(float).arraycopy arraycopy;
+    alias SimpleType!(short).arraycopy arraycopy;
+    alias SimpleType!(long).arraycopy arraycopy;
+    alias SimpleType!(uint).arraycopy arraycopy;
+    alias SimpleType!(ushort).arraycopy arraycopy;
+    alias SimpleType!(ubyte).arraycopy arraycopy;
+    alias SimpleType!(ulong).arraycopy arraycopy;
+    alias SimpleType!(char).arraycopy arraycopy;
+    alias SimpleType!(wchar).arraycopy arraycopy;
+    alias SimpleType!(Object).arraycopy arraycopy;
+    alias SimpleType!(void*).arraycopy arraycopy;
+
+    alias SimpleType!(int[]).arraycopy arraycopy;
+    alias SimpleType!(byte[]).arraycopy arraycopy;
+    alias SimpleType!(double[]).arraycopy arraycopy;
+    alias SimpleType!(float[]).arraycopy arraycopy;
+    alias SimpleType!(short[]).arraycopy arraycopy;
+    alias SimpleType!(long[]).arraycopy arraycopy;
+    alias SimpleType!(uint[]).arraycopy arraycopy;
+    alias SimpleType!(ushort[]).arraycopy arraycopy;
+    alias SimpleType!(ubyte[]).arraycopy arraycopy;
+    alias SimpleType!(ulong[]).arraycopy arraycopy;
+    alias SimpleType!(char[]).arraycopy arraycopy;
+    alias SimpleType!(wchar[]).arraycopy arraycopy;
+    alias SimpleType!(Object[]).arraycopy arraycopy;
+    alias SimpleType!(void*[]).arraycopy arraycopy;
+    alias SimpleType!(void*[]).arraycopy arraycopy;
+
+    static long currentTimeMillis(){
+        return Clock.now().ticks() / 10000;
+    }
+
+    static void exit( int code ){
+        .exit(code);
+    }
+    public static int identityHashCode(Object x){
+        if( x is null ){
+            return 0;
+        }
+        return (*cast(Object *)&x).toHash();
+    }
+
+    public static char[] getProperty( char[] key ){
+        switch( key ){
+        case "os.name": return "windows";
+        default: return null;
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/WeakHashMap.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,33 @@
+module dwt.dwthelper.WeakHashMap;
+
+
+/+
+    Is not yet 'weak'
++/
+class WeakHashMap {
+
+    static class Ref {
+        size_t ptr;
+        this(Object k){
+            ptr = cast(size_t)cast(void*)k;
+        }
+    }
+
+    Object[ Ref ] data;
+
+    public void add (Object key, Object element){
+        auto k = new Ref(key);
+        data[ k ] = element;
+    }
+    public void removeKey (Object key){
+        scope k = new Ref(key);
+        data.remove( k );
+    }
+    public Object get(Object key){
+        scope k = new Ref(key);
+        if( auto p = k in data ){
+            return *p;
+        }
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/WeakRef.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,88 @@
+/*==========================================================================
+ * weakref.d
+ *    Written in the D Programming Language (http://www.digitalmars.com/d)
+ */
+/***************************************************************************
+ * Creates a weak reference to a class instance.
+ *
+ * A weak reference lets you hold onto a pointer to an object without
+ * preventing the garbage collector from collecting it.
+ * If the garbage collector collects the object then the weak pointer will
+ * become 'null'.  Thus one should always check a weak pointer for null
+ * before doing anything that depends upon it having a value.
+ *
+ * Tested with:
+ *    DMD 1.025 / Phobos 1.025
+ *    DMD 1.025 / Tango 0.99.4
+ *
+ * Usage example:
+---
+ class Something {}
+
+ auto a = new Something();
+ auto wa = new WeakRef!(Something)(a);
+ std.gc.fullCollect();
+
+ // Reference 'a' prevents collection so wa.ptr is non-null
+ assert(wa.ptr is a);
+
+ delete a;
+
+ // 'a' is gone now, so wa.ptr magically becomes null
+ assert(wa.ptr is null);
+---
+ *
+ *
+ * Author:  William V. Baxter III
+ * Contributors:
+ * Date: 21 Jan 2008
+ * Copyright: (C) 2008  William Baxter
+ * License: Public Domain where allowed by law, ZLIB/PNG otherwise.
+ */
+//===========================================================================
+
+module dwt.dwthelper.WeakRef;
+
+private {
+    alias void delegate(Object) DisposeEvt;
+    extern (C) void  rt_attachDisposeEvent( Object obj, DisposeEvt evt );
+    extern (C) void  rt_detachDisposeEvent( Object obj, DisposeEvt evt );
+}
+
+class WeakRef(T : Object) {
+private:
+    size_t cast_ptr_;
+    void unhook(Object o) {
+        if (cast(size_t)cast(void*)o is cast_ptr_) {
+            rt_detachDisposeEvent(o, &unhook);
+            cast_ptr_ = 0;
+        }
+    }
+public:
+
+    this(T tptr) {
+        cast_ptr_ = cast(size_t)cast(void*)tptr;
+        rt_attachDisposeEvent(tptr, &unhook);
+    }
+    ~this() {
+        T p = ptr();
+        if (p) {
+            rt_detachDisposeEvent(p, &unhook);
+        }
+    }
+    T ptr() {
+        return cast(T)cast(void*)cast_ptr_;
+    }
+    WeakRef dup() {
+        return new WeakRef(ptr());
+    }
+    int opEquals( Object o ){
+        if( auto other = cast( WeakRef!(T) )o ){
+            return other.cast_ptr_ is cast_ptr_;
+        }
+        return false;
+    }
+    hash_t toHash(){
+        return cast_ptr_;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/XmlTranscode.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,182 @@
+module dwt.dwthelper.XmlTranscode;
+
+import dwt.dwthelper.utils;
+import tango.core.Exception;
+import Math = tango.math.Math;
+
+/++
+ + Decode XML entities into UTF8 String.
+ + Eg. "&amp;" -> "&", "&#38;" -> "&", "&#x26;" -> "&"
+ + Throws TextException on failure
+ + The given String is modified.
+ +/
+char[] xmlUnescape( char[] str ){
+
+    void error(){
+        throw new TextException( "xmlUnescape" );
+    }
+    // &lt; ...
+    // &#1234;
+    // &#x12AF;
+    char[] src = str;
+    char[] trg = str;
+    while( src.length ){
+        if( src[0] !is '&' ){
+            trg[0] = src[0];
+            trg = trg[1..$];
+            src = src[1..$];
+        }
+        else{
+            src = src[1..$]; //  go past '&'
+            if( src.length < 2 ) error();
+
+            // search semi
+            int len = Math.min( src.length, 10 ); // limit semi search to possible longest entityname
+            int semi = tango.text.Util.locate( src[0 .. len ], ';' );
+            if( semi is len ) error(); // no semi found
+
+            char[] entityName = src[ 0 .. semi ]; // name without semi
+            dchar entityValue = 0;
+            switch( entityName ){
+                case "lt":   entityValue = '<'; break;
+                case "gt":   entityValue = '>'; break;
+                case "amp":  entityValue = '&'; break;
+                case "quot": entityValue = '\"'; break;
+                case "apos": entityValue = '\''; break;
+                default:
+                    if( entityName[0] is 'x' ){
+                        if( semi < 2 ) error();
+                        if( semi > 9 ) error();
+                        foreach( hex; entityName[1..$] ){
+                            entityValue <<= 4;
+                            if( hex >= '0' && hex <= '9' ){
+                                entityValue |= ( hex - '0' );
+                            }
+                            else if( hex >= 'a' && hex <= 'f' ){
+                                entityValue |= ( hex - 'a' );
+                            }
+                            else if( hex >= 'A' && hex <= 'F' ){
+                                entityValue |= ( hex - 'A' );
+                            }
+                            else{
+                                error();
+                            }
+                        }
+                    }
+                    else{
+                        if( semi < 1 ) error();
+                        if( semi > 9 ) error();
+                        foreach( dec; entityName[1..$] ){
+                            if( dec >= '0' && dec <= '9' ){
+                                entityValue *= 10;
+                                entityValue += ( dec - '0' );
+                            }
+                            else{
+                                error();
+                            }
+                        }
+                    }
+            }
+            dchar[1] arr;
+            arr[0] = entityValue;
+            uint ate = 0;
+            char[] res = tango.text.convert.Utf.toString( arr, trg, &ate );
+            trg = trg[ res.length .. $ ];
+            src = src[ semi +1 .. $ ]; // go past semi
+        }
+    }
+    return str[ 0 .. trg.ptr-str.ptr ];
+}
+
+
+/++
+ + Encode XML entities into UTF8 String.
+ + First checks if processing is needed.
+ + If not, the original String is returned.
+ + If processing is needed, a new String is allocated.
+ +/
+char[] xmlEscape( char[] xml ){
+    bool needsReplacement( dchar c ){
+        switch( c ){
+            case '<':
+            case '>':
+            case '&':
+            case '\"':
+            case '\'':
+            case '\r':
+            case '\n':
+            case '\u0009':
+                return true;
+            default:
+                return c > 0x7F;
+        }
+    }
+
+    // Check if processing is needed
+    foreach( char c; xml ){
+        if( needsReplacement( c )){
+            goto Lprocess;
+        }
+    }
+    return xml;
+Lprocess:
+
+    // yes, do a new String, start with +20 chars
+    char[] res = new char[ xml.length + 20 ];
+    res.length = 0;
+
+    foreach( dchar c; xml ){
+
+        if( !needsReplacement( c )){
+            res ~= c;
+        }
+        else{
+            res ~= '&';
+            switch( c ){
+                case '<': res ~= "lt"; break;
+                case '>': res ~= "gt"; break;
+                case '&': res ~= "amp"; break;
+                case '\"': res ~= "quot"; break;
+                case '\'': res ~= "apos"; break;
+                case '\r': case '\n': case '\u0009':
+                default:
+                    char toHexDigit( int i ){
+                        if( i < 10 ) return '0'+i;
+                        return 'A'+i-10;
+                    }
+                    res ~= "#x";
+                    if( c <= 0xFF ){
+                        res ~= toHexDigit(( c >> 4 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 0 ) & 0x0F );
+                    }
+                    else if( c <= 0xFFFF ){
+                        res ~= toHexDigit(( c >> 12 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 8 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 4 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 0 ) & 0x0F );
+                    }
+                    else if( c <= 0xFFFFFF ){
+                        res ~= toHexDigit(( c >> 20 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 16 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 12 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 8 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 4 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 0 ) & 0x0F );
+                    }
+                    else {
+                        res ~= toHexDigit(( c >> 28 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 24 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 20 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 16 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 12 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 8 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 4 ) & 0x0F );
+                        res ~= toHexDigit(( c >> 0 ) & 0x0F );
+                    }
+                    break;
+            }
+            res ~= ';';
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/utils.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,973 @@
+/**
+ * Authors: Frank Benoit <keinfarbton@googlemail.com>
+ */
+module dwt.dwthelper.utils;
+
+public import dwt.dwthelper.System;
+public import Math = tango.math.Math;
+
+public import tango.core.Exception : IllegalArgumentException, IOException;
+
+import tango.io.Stdout;
+import tango.io.Print;
+import tango.stdc.stringz;
+static import tango.text.Util;
+static import tango.text.Text;
+import tango.text.Unicode;
+import tango.text.convert.Utf;
+import tango.core.Exception;
+import tango.stdc.stdlib : exit;
+
+import tango.util.log.Trace;
+import tango.text.UnicodeData;
+static import tango.util.collection.model.Seq;
+
+alias char[] String;
+alias char[] string;
+alias tango.text.Text.Text!(char) StringBuffer;
+
+void implMissing( String file, uint line ){
+    Stderr.formatln( "implementation missing in file {} line {}", file, line );
+    Stderr.formatln( "exiting ..." );
+    exit(1);
+}
+
+abstract class ArrayWrapper{
+}
+abstract class ValueWrapper{
+}
+
+class ArrayWrapperT(T) : ArrayWrapper {
+    public T[] array;
+    public this( T[] data ){
+        array = data;
+    }
+}
+
+class ValueWrapperT(T) : ValueWrapper {
+    public T value;
+    public this( T data ){
+        value = data;
+    }
+    public int opEquals( T other ){
+        return value == other;
+    }
+    public int opEquals( Object other ){
+        if( auto o = cast(ValueWrapperT!(T))other ){
+            return value == o.value;
+        }
+        return false;
+    }
+}
+
+class Boolean : ValueWrapperT!(bool) {
+    public static Boolean TRUE;
+    public static Boolean FALSE;
+
+    static this(){
+        TRUE  = new Boolean(true);
+        FALSE = new Boolean(false);
+    }
+    public this( bool v ){
+        super(v);
+    }
+
+    alias ValueWrapperT!(bool).opEquals opEquals;
+    public int opEquals( int other ){
+        return value == ( other !is 0 );
+    }
+    public int opEquals( Object other ){
+        if( auto o = cast(Boolean)other ){
+            return value == o.value;
+        }
+        return false;
+    }
+    public bool booleanValue(){
+        return value;
+    }
+    public static Boolean valueOf( String s ){
+        if( s == "yes" || s == "true" ){
+            return TRUE;
+        }
+        return FALSE;
+    }
+    public static Boolean valueOf( bool b ){
+        return b ? TRUE : FALSE;
+    }
+}
+
+alias Boolean    ValueWrapperBool;
+
+
+class Byte : ValueWrapperT!(byte) {
+    public static byte parseByte( String s ){
+        try{
+            int res = tango.text.convert.Integer.parse( s );
+            if( res < byte.min || res > byte.max ){
+                throw new NumberFormatException( "out of range" );
+            }
+            return res;
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+    this( byte value ){
+        super( value );
+    }
+}
+alias Byte ValueWrapperByte;
+
+
+class Integer : ValueWrapperT!(int) {
+
+    public static const int MIN_VALUE = 0x80000000;
+    public static const int MAX_VALUE = 0x7fffffff;
+    public static const int SIZE = 32;
+
+    public this ( int value ){
+        super( value );
+    }
+
+    public this ( String s ){
+        super(parseInt(s));
+    }
+
+    public static String 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 String toHexString( int i ){
+        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex );
+    }
+
+    public static String toOctalString( int i ){
+        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal );
+    }
+
+    public static String toBinaryString( int i ){
+        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary );
+    }
+
+    public static String toString( int i ){
+        return tango.text.convert.Integer.toString(i);
+    }
+
+    public static int parseInt( String s, int radix ){
+        try{
+            return tango.text.convert.Integer.parse( s, cast(uint)radix );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+
+    public static int parseInt( String s ){
+        try{
+            return tango.text.convert.Integer.parse( s );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+
+    public static Integer valueOf( String s, int radix ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public static Integer valueOf( String s ){
+        return valueOf( parseInt(s));
+    }
+
+    public static Integer valueOf( int i ){
+        return new Integer(i);
+    }
+
+    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 String toString(){
+        return tango.text.convert.Integer.toString( value );
+    }
+}
+alias Integer ValueWrapperInt;
+
+class Double : ValueWrapperT!(double) {
+    this( double value ){
+        super(value);
+    }
+    this( String str ){
+        implMissing( __FILE__, __LINE__ );
+        super(0.0);
+    }
+    public double doubleValue(){
+        return value;
+    }
+    public static String toString( double value ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+}
+
+class Float : ValueWrapperT!(float) {
+
+    public static float POSITIVE_INFINITY = (1.0f / 0.0f);
+    public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f);
+    public static float NaN = (0.0f / 0.0f);
+    public static float MAX_VALUE = 3.4028235e+38f;
+    public static float MIN_VALUE = 1.4e-45f;
+    public static int SIZE = 32;
+
+    this( float value ){
+        super(value);
+    }
+    this( String str ){
+        implMissing( __FILE__, __LINE__ );
+        super(0.0);
+    }
+    public float floatValue(){
+        return value;
+    }
+    public static String toString( float value ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+    public static float parseFloat( String s ){
+        try{
+            return tango.text.convert.Float.toFloat( s );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+
+}
+class Long : ValueWrapperT!(long) {
+    this( long value ){
+        super(value);
+    }
+    this( String str ){
+        implMissing( __FILE__, __LINE__ );
+        super(0);
+    }
+    public long longValue(){
+        return value;
+    }
+    public static long parseLong(String s){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+    public static String toString( double value ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+}
+alias Long ValueWrapperLong;
+
+
+// alias ValueWrapperT!(int)     ValueWrapperInt;
+
+alias ArrayWrapperT!(byte)    ArrayWrapperByte;
+alias ArrayWrapperT!(int)     ArrayWrapperInt;
+alias ArrayWrapperT!(Object)  ArrayWrapperObject;
+alias ArrayWrapperT!(char)    ArrayWrapperString;
+alias ArrayWrapperT!(String)  ArrayWrapperString2;
+
+Object[] StringArrayToObjectArray( String[] strs ){
+    Object[] res = new Object[strs.length];
+    foreach( idx, str; strs ){
+        res[idx] = new ArrayWrapperString(str);
+    }
+    return res;
+}
+int codepointIndexToIndex( String str, int cpIndex ){
+    int cps = cpIndex;
+    int res = 0;
+    while( cps > 0 ){
+        cps--;
+        if( str[res] < 0x80 ){
+            res+=1;
+        }
+        else if( str[res] < 0xE0 ){
+            res+=2;
+        }
+        else if( str[res] & 0xF0 ){
+            res+=3;
+        }
+        else{
+            res+=4;
+        }
+    }
+    return res;
+}
+int indexToCodepointIndex( String str, int index ){
+    int i = 0;
+    int res = 0;
+    while( i < index ){
+        if( str[i] < 0x80 ){
+            i+=1;
+        }
+        else if( str[i] < 0xE0 ){
+            i+=2;
+        }
+        else if( str[i] & 0xF0 ){
+            i+=3;
+        }
+        else{
+            i+=4;
+        }
+        res++;
+    }
+    return res;
+}
+
+String firstCodePointStr( String str, out int consumed ){
+    dchar[1] buf;
+    uint ate;
+    dchar[] res = str.toString32( buf, &ate );
+    consumed = ate;
+    return str[ 0 .. ate ];
+}
+
+dchar firstCodePoint( String str ){
+    int dummy;
+    return firstCodePoint( str, dummy );
+}
+dchar firstCodePoint( String str, out int consumed ){
+    dchar[1] buf;
+    uint ate;
+    dchar[] res = str.toString32( buf, &ate );
+    consumed = ate;
+    if( ate is 0 || res.length is 0 ){
+        Trace.formatln( "dwthelper.utils {}: str.length={} str={:X2}", __LINE__, str.length, cast(ubyte[])str );
+    }
+    assert( ate > 0 );
+    assert( res.length is 1 );
+    return res[0];
+}
+
+String dcharToString( dchar key ){
+    dchar[1] buf;
+    buf[0] = key;
+    return tango.text.convert.Utf.toString( buf );
+}
+
+int codepointCount( String str ){
+    scope dchar[] buf = new dchar[]( str.length );
+    uint ate;
+    dchar[] res = tango.text.convert.Utf.toString32( str, buf, &ate );
+    assert( ate is str.length );
+    return res.length;
+}
+
+alias tango.text.convert.Utf.toString16 toString16;
+alias tango.text.convert.Utf.toString toString;
+
+int getRelativeCodePointOffset( String str, int startIndex, int searchRelCp ){
+    int ignore;
+    int i = startIndex;
+    if( searchRelCp > 0 ){
+        while( searchRelCp !is 0 ){
+
+            if( ( i < str.length )
+                && ( str[i] & 0x80 ) is 0x00 )
+            {
+                i+=1;
+            }
+            else if( ( i+1 < str.length )
+                && (( str[i+1] & 0xC0 ) is 0x80 )
+                && (( str[i  ] & 0xE0 ) is 0xC0 ))
+            {
+                i+=2;
+            }
+            else if( ( i+2 < str.length )
+                && (( str[i+2] & 0xC0 ) is 0x80 )
+                && (( str[i+1] & 0xC0 ) is 0x80 )
+                && (( str[i  ] & 0xF0 ) is 0xE0 ))
+            {
+                i+=3;
+            }
+            else if(( i+3 < str.length )
+                && (( str[i+3] & 0xC0 ) is 0x80 )
+                && (( str[i+2] & 0xC0 ) is 0x80 )
+                && (( str[i+1] & 0xC0 ) is 0x80 )
+                && (( str[i  ] & 0xF8 ) is 0xF0 ))
+            {
+                i+=4;
+            }
+            else{
+                Trace.formatln( "invalid utf8 characters: {:X2}", cast(ubyte[]) str );
+                tango.text.convert.Utf.onUnicodeError( "invalid utf8 input", i );
+            }
+            searchRelCp--;
+        }
+    }
+    else if( searchRelCp < 0 ){
+        while( searchRelCp !is 0 ){
+            do{
+                i--;
+                if( i < 0 ){
+                    Trace.formatln( "dwthelper.utils getRelativeCodePointOffset {}: str={}, startIndex={}, searchRelCp={}", __LINE__, str, startIndex, searchRelCp );
+                    tango.text.convert.Utf.onUnicodeError( "invalid utf8 input", i );
+                }
+            } while(( str[i] & 0xC0 ) is 0x80 );
+            searchRelCp++;
+        }
+    }
+    return i - startIndex;
+}
+dchar getRelativeCodePoint( String str, int startIndex, int searchRelCp, out int relIndex ){
+    relIndex = getRelativeCodePointOffset( str, startIndex, searchRelCp );
+    int ignore;
+    return firstCodePoint( str[ startIndex+relIndex .. $ ], ignore );
+}
+
+int utf8AdjustOffset( String str, int offset ){
+    if( str.length <= offset || offset <= 0 ){
+        return offset;
+    }
+    while(( str[offset] & 0xC0 ) is 0x80 ){
+        offset--;
+    }
+    return offset;
+}
+
+bool CharacterIsDefined( dchar ch ){
+    return (ch in tango.text.UnicodeData.unicodeData) !is null;
+}
+dchar CharacterFirstToLower( String str ){
+    int consumed;
+    return CharacterFirstToLower( str, consumed );
+}
+dchar CharacterFirstToLower( String str, out int consumed ){
+    dchar[1] buf;
+    buf[0] = firstCodePoint( str, consumed );
+    dchar[] r = tango.text.Unicode.toLower( buf );
+    return r[0];
+}
+
+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];
+}
+bool CharacterIsWhitespace( dchar c ){
+    return tango.text.Unicode.isWhitespace( c );
+}
+bool CharacterIsDigit( dchar c ){
+    return tango.text.Unicode.isDigit( c );
+}
+bool CharacterIsLetter( dchar c ){
+    return tango.text.Unicode.isLetter( c );
+}
+public String toUpperCase( String str ){
+    return tango.text.Unicode.toUpper( str );
+}
+
+public int indexOf( String str, char searched ){
+    int res = tango.text.Util.locate( str, searched );
+    if( res is str.length ) res = -1;
+    return res;
+}
+
+public int indexOf( String str, char searched, int startpos ){
+    int res = tango.text.Util.locate( str, searched, startpos );
+    if( res is str.length ) res = -1;
+    return res;
+}
+
+public int indexOf(String str, String ch){
+    return indexOf( str, ch, 0 );
+}
+
+public int indexOf(String str, String ch, int start){
+    int res = tango.text.Util.locatePattern( str, ch, start );
+    if( res is str.length ) res = -1;
+    return res;
+}
+
+public int lastIndexOf(String str, char ch){
+    return lastIndexOf( str, ch, str.length );
+}
+public int lastIndexOf(String str, char ch, int formIndex){
+    int res = tango.text.Util.locatePrior( str, ch, formIndex );
+    if( res is str.length ) res = -1;
+    return res;
+}
+public int lastIndexOf(String str, String ch ){
+    return lastIndexOf( str, ch, str.length );
+}
+public int lastIndexOf(String str, String ch, int start ){
+    int res = tango.text.Util.locatePatternPrior( str, ch, start );
+    if( res is str.length ) res = -1;
+    return res;
+}
+
+public size_t length(T)(T arr){
+    return str.length;
+}
+
+public String replace( String str, char from, char to ){
+    return tango.text.Util.replace( str.dup, from, to );
+}
+
+public String substring( String str, int start ){
+    return str[ start .. $ ].dup;
+}
+
+public String substring( String str, int start, int end ){
+    return str[ start .. end ].dup;
+}
+
+public wchar[] substring( wchar[] str, int start ){
+    return str[ start .. $ ].dup;
+}
+
+public wchar[] substring( wchar[] str, int start, int end ){
+    return str[ start .. end ].dup;
+}
+
+public char charAt( String str, int pos ){
+    return str[ pos ];
+}
+
+public void getChars( String src, int srcBegin, int srcEnd, String dst, int dstBegin){
+    dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ];
+}
+
+public wchar[] toCharArray( String str ){
+    return toString16( str );
+}
+
+public bool endsWith( String src, String pattern ){
+    if( src.length < pattern.length ){
+        return false;
+    }
+    return src[ $-pattern.length .. $ ] == pattern;
+}
+
+public bool equals( String src, String other ){
+    return src == other;
+}
+
+public bool equalsIgnoreCase( String src, String other ){
+    return tango.text.Unicode.toFold(src) == tango.text.Unicode.toFold(other);
+}
+
+public int compareToIgnoreCase( String src, String other ){
+    return compareTo( tango.text.Unicode.toFold(src), tango.text.Unicode.toFold(other));
+}
+public int compareTo( String src, String other ){
+    return typeid(String).compare( cast(void*)&src, cast(void*)&other );
+}
+
+public bool startsWith( String src, String pattern ){
+    if( src.length < pattern.length ){
+        return false;
+    }
+    return src[ 0 .. pattern.length ] == pattern;
+}
+
+public String toLowerCase( String src ){
+    return tango.text.Unicode.toLower( src );
+}
+
+public hash_t toHash( String src ){
+    return typeid(String).getHash(&src);
+}
+
+public String trim( String str ){
+    return tango.text.Util.trim( str ).dup;
+}
+public String intern( String str ){
+    return str;
+}
+
+public char* toStringzValidPtr( String src ){
+    if( src ){
+        return src.toStringz();
+    }
+    else{
+        static const String nullPtr = "\0";
+        return nullPtr.ptr;
+    }
+}
+
+static String toHex(uint value, bool prefix = true, int radix = 8){
+    return tango.text.convert.Integer.toString(
+            value,
+            radix is 10 ? tango.text.convert.Integer.Style.Signed :
+            radix is  8 ? tango.text.convert.Integer.Style.Octal  :
+            radix is 16 ? tango.text.convert.Integer.Style.Hex    :
+                          tango.text.convert.Integer.Style.Signed,
+            prefix ? tango.text.convert.Integer.Flags.Prefix : tango.text.convert.Integer.Flags.None
+            );
+}
+
+class RuntimeException : Exception {
+    this( String e = null){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+        next = e;
+    }
+    public Exception getCause() {
+        return next;
+    }
+
+}
+class IndexOutOfBoundsException : Exception {
+    this( String e = null){
+        super(e);
+    }
+}
+
+class UnsupportedOperationException : RuntimeException {
+    this( String e = null){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class NumberFormatException : IllegalArgumentException {
+    this( String e ){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class NullPointerException : Exception {
+    this( String e = null ){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class IllegalStateException : Exception {
+    this( String e = null ){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class InterruptedException : Exception {
+    this( String e = null ){
+        super(e);
+    }
+    this( Exception e ){
+        super(e.toString);
+    }
+}
+class InvocationTargetException : Exception {
+    Exception cause;
+    this( Exception e = null, String msg = null ){
+        super(msg);
+        cause = e;
+    }
+
+    alias getCause getTargetException;
+    Exception getCause(){
+        return cause;
+    }
+}
+class MissingResourceException : Exception {
+    String classname;
+    String key;
+    this( String msg, String classname, String key ){
+        super(msg);
+        this.classname = classname;
+        this.key = key;
+    }
+}
+class ParseException : Exception {
+    this( String e = null ){
+        super(e);
+    }
+}
+
+interface Cloneable{
+}
+
+interface Comparable {
+    int compareTo(Object o);
+}
+interface Comparator {
+    int compare(Object o1, Object o2);
+}
+interface EventListener{
+}
+
+class EventObject {
+    protected Object source;
+
+    public this(Object source) {
+        if (source is null)
+        throw new IllegalArgumentException( "null arg" );
+        this.source = source;
+    }
+
+    public Object getSource() {
+        return source;
+    }
+
+    public override String toString() {
+        return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]";
+    }
+}
+
+private struct GCStats {
+    size_t poolsize;        // total size of pool
+    size_t usedsize;        // bytes allocated
+    size_t freeblocks;      // number of blocks marked FREE
+    size_t freelistsize;    // total of memory on free lists
+    size_t pageblocks;      // number of blocks marked PAGE
+}
+private extern(C) GCStats gc_stats();
+
+size_t RuntimeTotalMemory(){
+    GCStats s = gc_stats();
+    return s.poolsize;
+}
+
+String ExceptionGetLocalizedMessage( Exception e ){
+    return e.msg;
+}
+
+void ExceptionPrintStackTrace( Exception e ){
+    ExceptionPrintStackTrace( e, Stderr );
+}
+void ExceptionPrintStackTrace( Exception e, Print!(char) print ){
+    Exception exception = e;
+    while( exception !is null ){
+        print.formatln( "Exception in {}({}): {}", exception.file, exception.line, exception.msg );
+        if( exception.info !is null ){
+            foreach( msg; exception.info ){
+                print.formatln( "trc {}", msg );
+            }
+        }
+        exception = exception.next;
+    }
+}
+
+interface Reader{
+}
+interface Writer{
+}
+
+
+class Collator : Comparator {
+    public static Collator getInstance(){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+    private this(){
+    }
+    int compare(Object o1, Object o2){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+}
+
+interface Enumeration {
+    public bool hasMoreElements();
+    public Object nextElement();
+}
+
+
+template arraycast(T) {
+    T[] arraycast(U) (U[] u) {
+        static if (
+            (is (T == interface ) && is (U == interface )) ||
+            (is (T == class ) && is (U == class ))) {
+            return(cast(T[])u);
+        }
+        else {
+            int l = u.length;
+            T[] res;
+            res.length = l;
+            for (int i = 0; i < l; i++) {
+                res[i] = cast(T)u[i];
+            }
+            return(res);
+        }
+    }
+}
+
+String stringcast( Object o ){
+    if( auto str = cast(ArrayWrapperString) o ){
+        return str.array;
+    }
+    return null;
+}
+String[] stringcast( Object[] objs ){
+    String[] res = new String[](objs.length);
+    foreach( idx, obj; objs ){
+        res[idx] = stringcast(obj);
+    }
+    return res;
+}
+ArrayWrapperString stringcast( String str ){
+    return new ArrayWrapperString( str );
+}
+ArrayWrapperString[] stringcast( String[] strs ){
+    ArrayWrapperString[] res = new ArrayWrapperString[ strs.length ];
+    foreach( idx, str; strs ){
+        res[idx] = stringcast(str);
+    }
+    return res;
+}
+
+
+bool ArrayEquals(T)( T[] a, T[] b ){
+    if( a.length !is b.length ){
+        return false;
+    }
+    for( int i = 0; i < a.length; i++ ){
+        static if( is( T==class) || is(T==interface)){
+            if( a[i] !is null && b[i] !is null ){
+                if( a[i] != b[i] ){
+                    return false;
+                }
+            }
+            else if( a[i] is null && b[i] is null ){
+            }
+            else{
+                return false;
+            }
+        }
+        else{
+            if( a[i] != b[i] ){
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+class Arrays{
+    public static bool equals(Object[] a, Object[] b){
+        if( a.length !is b.length ){
+            return false;
+        }
+        for( int i = 0; i < a.length; i++ ){
+            if( a[i] is null && b[i] is null ){
+                continue;
+            }
+            if( a[i] !is null && b[i] !is null && a[i] == b[i] ){
+                continue;
+            }
+            return false;
+        }
+        return true;
+    }
+}
+
+int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){
+    int idx;
+    foreach( e; s ){
+        if( e == src ){
+            return idx;
+        }
+        idx++;
+    }
+    return -1;
+}
+int arrayIndexOf(T)( T[] arr, T v ){
+    int res = -1;
+    int idx = 0;
+    foreach( p; arr ){
+        if( p == v){
+            res = idx;
+            break;
+        }
+        idx++;
+    }
+    return res;
+}
+
+int seqIndexOf( tango.util.collection.model.Seq.Seq!(Object) seq, Object v ){
+    int res = -1;
+    int idx = 0;
+    foreach( p; seq ){
+        if( p == v){
+            res = idx;
+            break;
+        }
+        idx++;
+    }
+    return res;
+}
+
+void PrintStackTrace( int deepth = 100, String prefix = "trc" ){
+    auto e = new Exception( null );
+    int idx = 0;
+    const start = 3;
+    foreach( msg; e.info ){
+        if( idx >= start && idx < start+deepth ) {
+            Trace.formatln( "{}: {}", prefix, msg );
+        }
+        idx++;
+    }
+}
+
+struct ImportData{
+    void[] data;
+    String name;
+
+    public static ImportData opCall( void[] data, String name ){
+        ImportData res;
+        res.data = data;
+        res.name = name;
+        return res;
+    }
+}
+
+template getImportData(String name ){
+    const ImportData getImportData = ImportData( import(name), name );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/effects/Effect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ *******************************************************************************/
+module dwt.effects;
+
+import dwt.dwthelper.utils;
+
+/**
+ * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED
+ */
+public class Effect {
+    public int handle;
+    
+    public Effect() {
+    }
+
+    public void dispose() {
+    }   
+
+    public bool isDisposed() {
+        return handle is 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ArmEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ArmEvent;
+
+import dwt.dwthelper.utils;
+import dwt.widgets.Event;
+
+/**
+ * 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 ArmEvent(Event e) {
+    super(e);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ArmListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ArmListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * 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.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * <code>addArmListener</code> method and removed using
+ * the <code>removeArmListener</code> method. When the
+ * widget is armed, the widgetArmed method will be invoked.
+ * </p>
+ *
+ * @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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ControlAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.ControlAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>ControlListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>ControlEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see ControlListener
+ * @see ControlEvent
+ */
+public abstract class ControlAdapter implements ControlListener {
+
+/**
+ * Sent when the location (x, y) of a control changes relative
+ * to its parent (or relative to the display, for <code>Shell</code>s).
+ * 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ControlEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.ControlEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * 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 ControlEvent(Event e) {
+    super(e);
+}
+
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ControlListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.ControlListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated by moving
+ * and resizing controls. 
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addControlListener</code> method and removed using
+ * the <code>removeControlListener</code> method. When a
+ * control is moved or resized, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @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 <code>Shell</code>s).
+ *
+ * @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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/DisposeEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.DisposeEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * 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 DisposeEvent(Event e) {
+    super(e);
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/DisposeListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.DisposeListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when a widget
+ * is disposed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * <code>addDisposeListener</code> method and removed using
+ * the <code>removeDisposeListener</code> method. When a
+ * widget is disposed, the widgetDisposed method will
+ * be invoked.
+ * </p>
+ *
+ * @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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/DragDetectEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.DragDetectEvent;
+
+import dwt.dwthelper.utils;
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * a drag gesture.
+ *
+ * @see DragDetectListener
+ * 
+ * @since 3.3
+ */
+
+public final class DragDetectEvent extends 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 DragDetectEvent(Event e) {
+    super(e);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/DragDetectListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.DragDetectListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when a drag
+ * gesture is detected.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addDragDetectListener</code> method and removed using
+ * the <code>removeDragDetectListener</code> method. When the
+ * drag is detected, the drageDetected method will be invoked.
+ * </p>
+ *
+ * @see DragDetectEvent
+ * 
+ * @since 3.3
+ */
+public interface DragDetectListener extends DWTEventListener {
+
+/**
+ * Sent when a drag gesture is detected.
+ *
+ * @param e an event containing information about the drag
+ */
+public void dragDetected(DragDetectEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ExpandAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ExpandAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>ExpandListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>ExpandEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see ExpandListener
+ * @see ExpandEvent
+ * 
+ * @since 3.2
+ */
+public abstract class ExpandAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ExpandEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ExpandEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * <code>ExpandItem</code>s being expanded or collapsed.
+ *
+ * @see ExpandListener
+ * 
+ * @since 3.2
+ */
+
+public class ExpandEvent extends 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 ExpandEvent(Event e) {
+    super(e);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ExpandListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.ExpandListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the expanding and collapsing of <code>ExpandItem</code>s.
+ *
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a <code>ExpandBar</code> 
+ * control using the <code>addExpandListener</code> method and
+ * removed using the <code>removeExpandListener</code> method. 
+ * When a item of the <code>ExpandBar</code> is expanded or
+ * collapsed, the appropriate method will be invoked.
+ * </p>
+ *
+ * @see ExpandAdapter
+ * @see ExpandEvent
+ * 
+ * @since 3.2
+ */
+public interface ExpandListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/FocusAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.FocusAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>FocusListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>FocusEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see FocusListener
+ * @see FocusEvent
+ */
+public abstract class FocusAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/FocusEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.FocusEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets gaining and losing focus.
+ *
+ * @see FocusListener
+ */
+
+public final class FocusEvent extends 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 FocusEvent(Event e) {
+    super(e);
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/FocusListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.FocusListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as controls
+ * gain and lose focus.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addFocusListener</code> method and removed using
+ * the <code>removeFocusListener</code> method. When a
+ * control gains or loses focus, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see FocusAdapter
+ * @see FocusEvent
+ */
+public interface FocusListener extends 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);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/HelpEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.HelpEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * help being requested for a widget.
+ *
+ * @see HelpListener
+ */
+
+public final class HelpEvent extends 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 HelpEvent(Event e) {
+    super(e);
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/HelpListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.HelpListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * 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.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addHelpListener</code> method and removed using
+ * the <code>removeHelpListener</code> method. When help
+ * is requested for a control, the helpRequested method
+ * will be invoked.
+ * </p>
+ *
+ * @see HelpEvent
+ */
+public interface HelpListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/KeyAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.KeyAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>KeyListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>KeyEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see KeyListener
+ * @see KeyEvent
+ */
+public abstract class KeyAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/KeyEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.KeyEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * keys being pressed and released on the keyboard.
+ * <p>
+ * 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.
+ * </p>
+ * @see KeyListener
+ * @see TraverseListener
+ */
+
+public class KeyEvent extends 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 char character;
+    
+    /**
+     * the key code of the key that was typed,
+     * as defined by the key code constants in class <code>DWT</code>.
+     * 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 <code>DWT</code>.
+     * 
+     * @see dwt.DWT
+     */
+    public int stateMask;
+    
+    /**
+     * A flag indicating whether the operation should be allowed.
+     * Setting this field to <code>false</code> 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 KeyEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " character='" + ((character is 0) ? "\\0" : "" + character) + "'"
+        + " keyCode=" + keyCode
+        + " stateMask=" + stateMask
+        + " doit=" + doit
+        + "}";
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/KeyListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.KeyListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as keys
+ * are pressed on the system keyboard.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addKeyListener</code> method and removed using
+ * the <code>removeKeyListener</code> method. When a
+ * key is pressed or released, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see KeyAdapter
+ * @see KeyEvent
+ */
+public interface KeyListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MenuAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MenuAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>MenuListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>MenuEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see MenuListener
+ * @see MenuEvent
+ */
+public abstract class MenuAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MenuDetectEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MenuDetectEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * 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 extends 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 <code>false</code> 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 MenuDetectEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " x=" + x
+        + " y=" + y
+        + " doit=" + doit
+        + "}";
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MenuDetectListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.MenuDetectListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * 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.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control or TrayItem
+ * using the <code>addMenuDetectListener</code> method and
+ * removed using the <code>removeMenuDetectListener</code> method.
+ * When the context menu trigger occurs, the
+ * <code>menuDetected</code> method will be invoked.
+ * </p>
+ *
+ * @see MenuDetectEvent
+ *
+ * @since 3.3
+ */
+public interface MenuDetectListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MenuEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MenuEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * menus being shown and hidden.
+ *
+ * @see MenuListener
+ */
+
+public final class MenuEvent extends 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 MenuEvent(Event e) {
+    super(e);
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MenuListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MenuListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the hiding and showing of menus.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a menu using the
+ * <code>addMenuListener</code> method and removed using
+ * the <code>removeMenuListener</code> method. When the
+ * menu is hidden or shown, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see MenuAdapter
+ * @see MenuEvent
+ */
+public interface MenuListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ModifyEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ModifyEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * text being modified.
+ *
+ * @see ModifyListener
+ */
+
+public final class ModifyEvent extends 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 ModifyEvent(Event e) {
+    super(e);
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ModifyListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ModifyListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when text
+ * is modified.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text widget using the
+ * <code>addModifyListener</code> method and removed using
+ * the <code>removeModifyListener</code> method. When the
+ * text is modified, the modifyText method will be invoked.
+ * </p>
+ *
+ * @see ModifyEvent
+ */
+public interface ModifyListener extends DWTEventListener {
+
+/**
+ * Sent when the text is modified.
+ *
+ * @param e an event containing information about the modify
+ */
+public void modifyText(ModifyEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MouseAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.MouseAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>MouseListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>MouseEvent</code>s 
+ * which occur as mouse buttons are pressed and released can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see MouseListener
+ * @see MouseEvent
+ */
+public abstract class MouseAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MouseEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MouseEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * 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.
+ * <p>
+ * Note: The <code>button</code> field is an integer that
+ * represents the mouse button number.  This is not the same
+ * as the <code>DWT</code> mask constants <code>BUTTONx</code>.
+ * </p>
+ *
+ * @see MouseListener
+ * @see MouseMoveListener
+ * @see MouseTrackListener
+ */
+
+public class MouseEvent extends 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 MouseEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " button=" + button
+        + " stateMask=" + stateMask
+        + " x=" + x
+        + " y=" + y
+        + " count=" + count
+        + "}";
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MouseListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MouseListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as mouse buttons
+ * are pressed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseListener</code> method and removed using
+ * the <code>removeMouseListener</code> method. When a
+ * mouse button is pressed or released, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see MouseAdapter
+ * @see MouseEvent
+ */
+public interface MouseListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MouseMoveListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MouseMoveListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated as the mouse
+ * pointer moves.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseMoveListener</code> method and removed using
+ * the <code>removeMouseMoveListener</code> method. As the
+ * mouse moves, the mouseMove method will be invoked.
+ * </p>
+ *
+ * @see MouseEvent
+ */
+public interface MouseMoveListener extends DWTEventListener {
+
+/**
+ * Sent when the mouse moves.
+ *
+ * @param e an event containing information about the mouse move
+ */
+public void mouseMove(MouseEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MouseTrackAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.MouseTrackAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>MouseTrackListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>MouseEvent</code>s 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.
+ * </p>
+ *
+ * @see MouseTrackListener
+ * @see MouseEvent
+ */
+public abstract class MouseTrackAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MouseTrackListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MouseTrackListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as the mouse
+ * pointer passes (or hovers) over controls.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseTrackListener</code> method and removed using
+ * the <code>removeMouseTrackListener</code> 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.
+ * </p>
+ *
+ * @see MouseTrackAdapter
+ * @see MouseEvent
+ */
+public interface MouseTrackListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/MouseWheelListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.MouseWheelListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated as the mouse
+ * wheel is scrolled.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseWheelListener</code> method and removed using
+ * the <code>removeMouseWheelListener</code> method. When the
+ * mouse wheel is scrolled the <code>mouseScrolled</code> method
+ * will be invoked.
+ * </p>
+ *
+ * @see MouseEvent
+ *
+ * @since 3.3
+ */
+public interface MouseWheelListener extends DWTEventListener {
+
+/**
+ * Sent when the mouse wheel is scrolled.
+ *
+ * @param e an event containing information about the mouse wheel action
+ */
+public void mouseScrolled (MouseEvent e);   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/PaintEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.PaintEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.graphics.GC;
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * visible areas of controls requiring re-painting.
+ *
+ * @see PaintListener
+ */
+
+public final class PaintEvent extends 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 PaintEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " gc=" + gc
+        + " x=" + x
+        + " y=" + y
+        + " width=" + width
+        + " height=" + height
+        + " count=" + count
+        + "}";
+}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/PaintListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.PaintListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when the
+ * control needs to be painted. 
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addPaintListener</code> method and removed using
+ * the <code>removePaintListener</code> method. When a
+ * paint event occurs, the paintControl method will be
+ * invoked.
+ * </p>
+ *
+ * @see PaintEvent
+ */
+public interface PaintListener extends DWTEventListener {
+
+/**
+ * Sent when a paint event occurs for the control.
+ *
+ * @param e an event containing information about the paint
+ */
+public void paintControl(PaintEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/SelectionAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.SelectionAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>SelectionListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>SelectionEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see SelectionListener
+ * @see SelectionEvent
+ */
+public abstract class SelectionAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/SelectionEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.SelectionEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+import dwt.widgets.Widget;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets being selected.
+ * <p>
+ * Note: The fields that are filled in depend on the widget.
+ * </p>
+ *
+ * @see SelectionListener
+ */
+
+public class SelectionEvent extends TypedEvent {
+    
+    /**
+     * The item that was selected.
+     */
+    public Widget item;
+    
+    /**
+     * Extra detail information about the selection, depending on the widget.
+     * 
+     * <p><b>Sash</b><ul>
+     * <li>{@link dwt.DWT#DRAG}</li>
+     * </ul></p><p><b>ScrollBar and Slider</b><ul>
+     * <li>{@link dwt.DWT#DRAG}</li>
+     * <li>{@link dwt.DWT#HOME}</li>
+     * <li>{@link dwt.DWT#END}</li>
+     * <li>{@link dwt.DWT#ARROW_DOWN}</li>
+     * <li>{@link dwt.DWT#ARROW_UP}</li>
+     * <li>{@link dwt.DWT#PAGE_DOWN}</li>
+     * <li>{@link dwt.DWT#PAGE_UP}</li>
+     * </ul></p><p><b>Table and Tree</b><ul>
+     * <li>{@link dwt.DWT#CHECK}</li>
+     * </ul></p><p><b>Text</b><ul>
+     * <li>{@link dwt.DWT#CANCEL}</li>
+     * </ul></p><p><b>CoolItem and ToolItem</b><ul>
+     * <li>{@link dwt.DWT#ARROW}</li>
+     * </ul></p>
+     */
+    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 String text;
+    
+    /**
+     * A flag indicating whether the operation should be allowed.
+     * Setting this field to <code>false</code> 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 SelectionEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " item=" + item
+        + " detail=" + detail
+        + " x=" + x
+        + " y=" + y
+        + " width=" + width
+        + " height=" + height
+        + " stateMask=" + stateMask
+        + " text=" + text
+        + " doit=" + doit
+        + "}";
+}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/SelectionListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.SelectionListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when selection
+ * occurs in a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addSelectionListener</code> method and removed using
+ * the <code>removeSelectionListener</code> method. When
+ * selection occurs in a control the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see SelectionAdapter
+ * @see SelectionEvent
+ */
+public interface SelectionListener extends DWTEventListener {
+
+/**
+ * Sent when selection occurs in the control.
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @param e an event containing information about the selection
+ */
+public void widgetSelected(SelectionEvent e);
+
+/**
+ * Sent when default selection occurs in the control.
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @param e an event containing information about the default selection
+ */
+public void widgetDefaultSelected(SelectionEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ShellAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ShellAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>ShellListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>ShellEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see ShellListener
+ * @see ShellEvent
+ */
+public abstract class ShellAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ShellEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.ShellEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * operations being performed on shells.
+ *
+ * @see ShellListener
+ */
+
+public final class ShellEvent extends TypedEvent {
+
+    /**
+     * A flag indicating whether the operation should be allowed.
+     * Setting this field to <code>false</code> 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 ShellEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " doit=" + doit
+        + "}";
+}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/ShellListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.ShellListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with changes in state of <code>Shell</code>s.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a shell using the
+ * <code>addShellListener</code> method and removed using
+ * the <code>removeShellListener</code> method. When the
+ * state of the shell changes, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see ShellAdapter
+ * @see ShellEvent
+ */
+public interface ShellListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/TraverseEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.TraverseEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widget traversal actions.
+ * <p>
+ * 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, <code>detail</code> and <code>doit</code>.
+ * </p><p>
+ * 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 <code>TRAVERSE_ARROW_NEXT</code>
+ * and the doit field is <code>false</code>, 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 <code>true</code>, 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.
+ * </p><p>
+ * How can the traversal event be used to implement traversal?
+ * When a tab key is pressed in a canvas, the detail field will be
+ * <code>TRAVERSE_TAB_NEXT</code> and the doit field will be
+ * <code>false</code>.  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 <code>TRAVERSE_TAB_NEXT</code> 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 <code>false</code>, 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 <code>true</code>, indicating
+ * that the system should perform tab traversal and that the key should not
+ * be delivered to the list widget.
+ * </p><p>
+ * 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 <code>TRAVERSE_RETURN</code> and the doit field
+ * is <code>true</code>.  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 <code>false</code> 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 <code>TRAVERSE_RETURN</code> 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 <code>true</code>, and the detail
+ * to <code>TRAVERSE_NONE</code>.
+ * </p><p>
+ * Note: A widget implementor will typically implement traversal using
+ * only the doit flag to either enable or disable system traversal.
+ * </p>
+ * 
+ * @see TraverseListener
+ */
+
+public final class TraverseEvent extends KeyEvent {
+    
+    /**
+     * The traversal type.
+     * <p><ul>
+     * <li>{@link dwt.DWT#TRAVERSE_NONE}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_ESCAPE}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_RETURN}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_TAB_NEXT}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_TAB_PREVIOUS}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_ARROW_NEXT}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_ARROW_PREVIOUS}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_MNEMONIC}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_PAGE_NEXT}</li>
+     * <li>{@link dwt.DWT#TRAVERSE_PAGE_PREVIOUS}</li>
+     * </ul></p>
+     * 
+     * Setting this field will change the type of traversal.
+     * For example, setting the detail to <code>TRAVERSE_NONE</code>
+     * causes no traversal action to be taken.
+     * 
+     * When used in conjunction with the <code>doit</code> field, the
+     * traversal detail field can be useful when overriding the default
+     * traversal mechanism for a control. For example, setting the doit
+     * field to <code>false</code> will cancel the operation and allow
+     * the traversal key stroke to be delivered to the control. Setting
+     * the doit field to <code>true</code> 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 TraverseEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " detail=" + detail
+        + "}";
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/TraverseListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.TraverseListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when a
+ * traverse event occurs in a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addTraverseListener</code> method and removed using
+ * the <code>removeTraverseListener</code> method. When a
+ * traverse event occurs in a control, the keyTraversed method
+ * will be invoked.
+ * </p>
+ *
+ * @see TraverseEvent
+ */
+public interface TraverseListener extends DWTEventListener {
+
+/**
+ * Sent when a traverse event occurs in a control.
+ * <p>
+ * 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 <code>TRAVERSE_</code> are defined
+ * in the <code>DWT</code> class.
+ * </p>
+ *
+ * @param e an event containing information about the traverse
+ */
+public void keyTraversed(TraverseEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/TreeAdapter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.TreeAdapter;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>TreeListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>TreeEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see TreeListener
+ * @see TreeEvent
+ */
+public abstract class TreeAdapter implements 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) {
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/TreeEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.TreeEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * trees being expanded and collapsed.
+ *
+ * @see TreeListener
+ */
+
+public final class TreeEvent extends 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 TreeEvent(Event e) {
+    super(e);
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/TreeListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.events.TreeListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the expanding and collapsing of tree
+ * branches.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a tree control using the
+ * <code>addTreeListener</code> method and removed using
+ * the <code>removeTreeListener</code> method. When a branch
+ * of the tree is expanded or collapsed, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see TreeAdapter
+ * @see TreeEvent
+ */
+public interface TreeListener extends 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);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/TypedEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.TypedEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.internal.DWTEventObject;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Widget;
+
+/**
+ * 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 extends 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 TypedEvent(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 TypedEvent(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 package name.
+ *
+ * @return the name of the event
+ */
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+    return getName ()
+        + "{" + widget
+        + " time=" + time
+        + " data=" + data
+        + "}";
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/VerifyEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.VerifyEvent;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets handling keyboard events
+ *
+ * @see VerifyListener
+ */
+
+public final class VerifyEvent extends 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 String 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 VerifyEvent(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 String toString() {
+    String string = super.toString ();
+    return string.substring (0, string.length() - 1) // remove trailing '}'
+        + " start=" + start
+        + " end=" + end
+        + " text=" + text
+        + "}";
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/events/VerifyListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.events.VerifyListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when text
+ * is about to be modified.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text control using the
+ * <code>addVerifyListener</code> method and removed using
+ * the <code>removeVerifyListener</code> method. When the
+ * text is about to be modified, the verifyText method
+ * will be invoked.
+ * </p>
+ *
+ * @see VerifyEvent
+ */
+public interface VerifyListener extends DWTEventListener {
+
+/**
+ * Sent when the text is about to be modified.
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @param e an event containing information about the verify
+ */
+public void verifyText(VerifyEvent e);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Color.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Color;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+
+/**
+ * Instances of this class manage the operating system resources that
+ * implement DWT's RGB color model. To create a color you can either
+ * specify the individual color components as integers in the range 
+ * 0 to 255 or provide an instance of an <code>RGB</code>. 
+ * <p>
+ * Application code must explicitly invoke the <code>Color.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see RGB
+ * @see Device#getSystemColor
+ */
+public final class Color extends Resource {
+    /**
+     * the handle to the OS color resource 
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public float[] handle;
+
+Color(Device device) {
+    super(device);
+}
+
+/**  
+ * Constructs a new instance of this class given a device and the
+ * desired red, green and blue values expressed as ints in the range
+ * 0 to 255 (where 0 is black and 255 is full brightness). On limited
+ * color devices, the color instance created by this call may not have
+ * the same RGB values as the ones specified by the arguments. The
+ * RGB values on the returned instance will be the color values of 
+ * the operating system color.
+ * <p>
+ * You must dispose the color when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param red the amount of red in the color
+ * @param green the amount of green in the color
+ * @param blue the amount of blue in the color
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Color(Device device, int red, int green, int blue) {
+    super(device);
+    init(red, green, blue);
+    init();
+}
+
+/**  
+ * Constructs a new instance of this class given a device and an
+ * <code>RGB</code> describing the desired red, green and blue values.
+ * On limited color devices, the color instance created by this call
+ * may not have the same RGB values as the ones specified by the
+ * argument. The RGB values on the returned instance will be the color
+ * values of the operating system color.
+ * <p>
+ * You must dispose the color when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param rgb the RGB values of the desired color
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Color(Device device, RGB rgb) {
+    super(device);
+    if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    init(rgb.red, rgb.green, rgb.blue);
+    init();
+}
+
+void destroy() {
+    handle = null;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals(Object object) {
+    if (object is this) return true;
+    if (!(object instanceof Color)) return false;
+    Color color = (Color)object;
+    float[] rgbColor = color.handle;
+    if (handle is rgbColor) return true;
+    return device is color.device &&
+        (int)(handle[0] * 255) is (int)(rgbColor[0] * 255) &&
+        (int)(handle[1] * 255) is (int)(rgbColor[1] * 255) &&
+        (int)(handle[2] * 255) is (int)(rgbColor[2] * 255);
+}
+
+/**
+ * Returns the amount of blue in the color, from 0 to 255.
+ *
+ * @return the blue component of the color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getBlue() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return (int)(handle[2] * 255);
+}
+
+/**
+ * Returns the amount of green in the color, from 0 to 255.
+ *
+ * @return the green component of the color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getGreen() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return (int)(handle[1] * 255);
+}
+
+/**
+ * Returns the amount of red in the color, from 0 to 255.
+ *
+ * @return the red component of the color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getRed() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return (int)(handle[0] * 255);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+    if (isDisposed()) return 0;
+    return (int)(handle[0] * 255) ^ (int)(handle[1] * 255) ^ (int)(handle[2] * 255);
+}
+
+/**
+ * Returns an <code>RGB</code> representing the receiver.
+ *
+ * @return the RGB for the color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public RGB getRGB () {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return new RGB(getRed(), getGreen(), getBlue());
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new color.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Color</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the color
+ * 
+ * @private
+ */
+public static Color cocoa_new(Device device, float[] rgbColor) {
+    Color color = new Color(device);
+    color.handle = rgbColor;
+    return color;
+}
+
+void init(int red, int green, int blue) {
+    if ((red > 255) || (red < 0) ||
+        (green > 255) || (green < 0) ||
+        (blue > 255) || (blue < 0)) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    float[] rgbColor = new float[4];
+    rgbColor[0] = red / 255f;
+    rgbColor[1] = green / 255f;
+    rgbColor[2] = blue / 255f;
+    rgbColor[3] = 1;
+    handle = rgbColor;
+}
+
+/**
+ * Returns <code>true</code> if the color has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the color.
+ * When a color has been disposed, it is an error to
+ * invoke any other method using the color.
+ *
+ * @return <code>true</code> when the color is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "Color {*DISPOSED*}";
+    return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Cursor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Cursor;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.internal.cocoa.NSBitmapImageRep;
+import dwt.internal.cocoa.NSCursor;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class manage operating system resources that
+ * specify the appearance of the on-screen pointer. To create a
+ * cursor you specify the device and either a simple cursor style
+ * describing one of the standard operating system provided cursors
+ * or the image and mask data for the desired appearance.
+ * <p>
+ * Application code must explicitly invoke the <code>Cursor.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>
+ *   CURSOR_ARROW, CURSOR_WAIT, CURSOR_CROSS, CURSOR_APPSTARTING, CURSOR_HELP,
+ *   CURSOR_SIZEALL, CURSOR_SIZENESW, CURSOR_SIZENS, CURSOR_SIZENWSE, CURSOR_SIZEWE,
+ *   CURSOR_SIZEN, CURSOR_SIZES, CURSOR_SIZEE, CURSOR_SIZEW, CURSOR_SIZENE, CURSOR_SIZESE,
+ *   CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
+ * </dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
+ */
+
+public final class Cursor extends Resource {
+    
+    /**
+     * the handle to the OS cursor resource
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public NSCursor handle;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Cursor(Device device) {
+    super(device);
+}
+
+/**  
+ * Constructs a new cursor given a device and a style
+ * constant describing the desired cursor appearance.
+ * <p>
+ * You must dispose the cursor when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the cursor
+ * @param style the style of cursor to allocate
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT - when an unknown style is specified</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ *
+ * @see DWT#CURSOR_ARROW
+ * @see DWT#CURSOR_WAIT
+ * @see DWT#CURSOR_CROSS
+ * @see DWT#CURSOR_APPSTARTING
+ * @see DWT#CURSOR_HELP
+ * @see DWT#CURSOR_SIZEALL
+ * @see DWT#CURSOR_SIZENESW
+ * @see DWT#CURSOR_SIZENS
+ * @see DWT#CURSOR_SIZENWSE
+ * @see DWT#CURSOR_SIZEWE
+ * @see DWT#CURSOR_SIZEN
+ * @see DWT#CURSOR_SIZES
+ * @see DWT#CURSOR_SIZEE
+ * @see DWT#CURSOR_SIZEW
+ * @see DWT#CURSOR_SIZENE
+ * @see DWT#CURSOR_SIZESE
+ * @see DWT#CURSOR_SIZESW
+ * @see DWT#CURSOR_SIZENW
+ * @see DWT#CURSOR_UPARROW
+ * @see DWT#CURSOR_IBEAM
+ * @see DWT#CURSOR_NO
+ * @see DWT#CURSOR_HAND
+ */
+public Cursor(Device device, int style) {
+    super(device);
+    switch (style) {
+        case DWT.CURSOR_HAND:           handle = NSCursor.pointingHandCursor(); break;
+        case DWT.CURSOR_ARROW:          handle = NSCursor.arrowCursor(); break;
+        case DWT.CURSOR_WAIT:           handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_CROSS:          handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_APPSTARTING:    handle = NSCursor.arrowCursor(); break;
+        case DWT.CURSOR_HELP:           handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_SIZEALL:        handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_SIZENESW:       handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_SIZENS:         handle = NSCursor.resizeUpDownCursor(); break;
+        case DWT.CURSOR_SIZENWSE:       handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_SIZEWE:         handle = NSCursor.resizeLeftRightCursor(); break;
+        case DWT.CURSOR_SIZEN:          handle = NSCursor.resizeUpCursor(); break;
+        case DWT.CURSOR_SIZES:          handle = NSCursor.resizeDownCursor(); break;
+        case DWT.CURSOR_SIZEE:          handle = NSCursor.resizeRightCursor(); break;
+        case DWT.CURSOR_SIZEW:          handle = NSCursor.resizeLeftCursor(); break;
+        case DWT.CURSOR_SIZENE:         handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_SIZESE:         handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_SIZESW:         handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_SIZENW:         handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_UPARROW:        handle = NSCursor.crosshairCursor(); break;
+        case DWT.CURSOR_IBEAM:          handle = NSCursor.IBeamCursor(); break;
+        case DWT.CURSOR_NO:             handle = NSCursor.crosshairCursor(); break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    handle.retain();
+    handle.setOnMouseEntered(true);
+    init();
+}
+
+/**  
+ * Constructs a new cursor given a device, image and mask
+ * data describing the desired cursor appearance, and the x
+ * and y coordinates of the <em>hotspot</em> (that is, the point
+ * within the area covered by the cursor which is considered
+ * to be where the on-screen pointer is "pointing").
+ * <p>
+ * The mask data is allowed to be null, but in this case the source
+ * must be an ImageData representing an icon that specifies both
+ * color data and mask data.
+ * <p>
+ * You must dispose the cursor when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the cursor
+ * @param source the color data for the cursor
+ * @param mask the mask data for the cursor (or null)
+ * @param hotspotX the x coordinate of the cursor's hotspot
+ * @param hotspotY the y coordinate of the cursor's hotspot
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the source is null</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same 
+ *          size, or if the hotspot is outside the bounds of the image</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ */
+public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
+    super(device);
+    if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (mask is null) {
+        if (source.getTransparencyType() !is DWT.TRANSPARENCY_MASK) {
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        }
+        mask = source.getTransparencyMask();
+    }
+    /* Check the bounds. Mask must be the same size as source */
+    if (mask.width !is source.width || mask.height !is source.height) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    /* Check the hotspots */
+    if (hotspotX >= source.width || hotspotX < 0 ||
+        hotspotY >= source.height || hotspotY < 0) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    byte[] data = new byte[source.width * source.height * 4];
+    for (int y = 0; y < source.height; y++) {
+        int offset = y * source.width * 4;
+        for (int x = 0; x < source.width; x++) {
+            int pixel = source.getPixel(x, y);
+            int maskPixel = mask.getPixel(x, y);
+            if (pixel is 0 && maskPixel is 0) {
+                // BLACK
+                data[offset] = (byte)0xFF;
+            } else if (pixel is 0 && maskPixel is 1) {
+                // WHITE - cursor color
+                data[offset] = data[offset + 1] = data[offset + 2] = data[offset + 3] = (byte)0xFF;
+            } else if (pixel is 1 && maskPixel is 0) {
+                // SCREEN
+            } else {
+                /*
+                * Feature in the Macintosh. It is not possible to have
+                * the reverse screen case using NSCursor.
+                * Reverse screen will be the same as screen.
+                */
+                // REVERSE SCREEN -> SCREEN
+            }
+            offset += 4;
+        }
+    }
+    createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
+    init();
+}
+
+void createNSCursor(int hotspotX, int hotspotY, byte[] buffer, int width, int height) {
+    NSImage nsImage = (NSImage)new NSImage().alloc();
+    NSBitmapImageRep nsImageRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
+    handle = (NSCursor)new NSCursor().alloc();
+    NSSize size = new NSSize();
+    size.width = width;
+    size.height =  height;
+    nsImage = nsImage.initWithSize(size);
+    nsImageRep = nsImageRep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(0, width, height,
+            8, 4, true, false, new NSString(OS.NSDeviceRGBColorSpace()),
+            OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, width * 4, 32);
+    OS.memmove(nsImageRep.bitmapData(), buffer, buffer.length);
+    nsImage.addRepresentation(nsImageRep);
+    NSPoint point = new NSPoint();
+    point.x = hotspotX;
+    point.y = hotspotY;
+    handle = handle.initWithImage_hotSpot_(nsImage, point);
+    nsImageRep.release();
+    nsImage.release();
+}
+
+/**  
+ * Constructs a new cursor given a device, image data describing
+ * the desired cursor appearance, and the x and y coordinates of
+ * the <em>hotspot</em> (that is, the point within the area
+ * covered by the cursor which is considered to be where the
+ * on-screen pointer is "pointing").
+ * <p>
+ * You must dispose the cursor when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the cursor
+ * @param source the image data for the cursor
+ * @param hotspotX the x coordinate of the cursor's hotspot
+ * @param hotspotY the y coordinate of the cursor's hotspot
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the hotspot is outside the bounds of the
+ *       image</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
+    super(device);
+    if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (hotspotX >= source.width || hotspotX < 0 ||
+        hotspotY >= source.height || hotspotY < 0) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    byte[] data = new byte[source.width * source.height * 4];
+    PaletteData palette = source.palette;
+    if (palette.isDirect) {
+        ImageData.blit(ImageData.BLIT_SRC,
+            source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, palette.redMask, palette.greenMask, palette.blueMask,
+            ImageData.ALPHA_OPAQUE, null, 0, 0, 0, 
+            data, 32, source.width * 4, ImageData.MSB_FIRST, 0, 0, source.width, source.height, 0xFF0000, 0xFF00, 0xFF,
+            false, false);
+    } else {
+        RGB[] rgbs = palette.getRGBs();
+        int length = rgbs.length;
+        byte[] srcReds = new byte[length];
+        byte[] srcGreens = new byte[length];
+        byte[] srcBlues = new byte[length];
+        for (int i = 0; i < rgbs.length; i++) {
+            RGB rgb = rgbs[i];
+            if (rgb is null) continue;
+            srcReds[i] = (byte)rgb.red;
+            srcGreens[i] = (byte)rgb.green;
+            srcBlues[i] = (byte)rgb.blue;
+        }
+        ImageData.blit(ImageData.BLIT_SRC,
+            source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, srcReds, srcGreens, srcBlues,
+            ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+            data, 32, source.width * 4, ImageData.MSB_FIRST, 0, 0, source.width, source.height, 0xFF0000, 0xFF00, 0xFF,
+            false, false);
+    }
+    if (source.maskData !is null || source.transparentPixel !is -1) {
+        ImageData mask = source.getTransparencyMask();
+        byte[] maskData = mask.data;
+        int maskBpl = mask.bytesPerLine;
+        int offset = 0, maskOffset = 0;
+        for (int y = 0; y<source.height; y++) {
+            for (int x = 0; x<source.width; x++) {
+                data[offset] = ((maskData[maskOffset + (x >> 3)]) & (1 << (7 - (x & 0x7)))) !is 0 ? (byte)0xff : 0;
+                offset += 4;
+            }
+            maskOffset += maskBpl;
+        }
+    } else if (source.alpha !is -1) {
+        byte alpha = (byte)source.alpha;
+        for (int i=0; i<data.length; i+=4) {
+            data[i] = alpha;                
+        }
+    } else if (source.alphaData !is null) {
+        byte[] alphaData = source.alphaData;
+        for (int i=0; i<data.length; i+=4) {
+            data[i] = alphaData[i/4];
+        }
+    }
+    createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
+    init();
+}
+
+void destroy() {
+    handle.release();
+    handle = null;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof Cursor)) return false;
+    Cursor cursor = (Cursor) object;
+    return device is cursor.device && handle is cursor.handle;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode () {
+    return handle !is null ? handle.id : 0;
+}
+
+/**
+ * Returns <code>true</code> if the cursor has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the cursor.
+ * When a cursor has been disposed, it is an error to
+ * invoke any other method using the cursor.
+ *
+ * @return <code>true</code> when the cursor is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "Cursor {*DISPOSED*}";
+    return "Cursor {" + handle + "}";
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new cursor.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Cursor</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the cursor
+ * 
+ * @private
+ */
+public static Cursor cocoa_new(Device device, NSCursor handle) {
+    Cursor cursor = new Cursor(device);
+    cursor.handle = handle;
+    return cursor;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Device.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,636 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Device;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.Compatibility;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSFontManager;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScreen;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSValue;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.id;
+
+/**
+ * This class is the abstract superclass of all device objects,
+ * such as the Display device and the Printer device. Devices
+ * can have a graphics context (GC) created for them, and they
+ * can be drawn on by sending messages to the associated GC.
+ */
+public abstract class Device implements Drawable {
+    
+    /* Debugging */
+    public static bool DEBUG;
+    bool debug = DEBUG;
+    bool tracking = DEBUG;
+    Error [] errors;
+    Object [] objects;
+    Object trackingLock;
+    
+    /* Disposed flag */
+    bool disposed, warnings;
+    
+    Color COLOR_BLACK, COLOR_DARK_RED, COLOR_DARK_GREEN, COLOR_DARK_YELLOW, COLOR_DARK_BLUE;
+    Color COLOR_DARK_MAGENTA, COLOR_DARK_CYAN, COLOR_GRAY, COLOR_DARK_GRAY, COLOR_RED;
+    Color COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE;
+
+    /* System Font */
+    Font systemFont;
+
+    /*
+    * TEMPORARY CODE. When a graphics object is
+    * created and the device parameter is null,
+    * the current Display is used. This presents
+    * a problem because DWT graphics does not
+    * reference classes in DWT widgets. The correct
+    * fix is to remove this feature. Unfortunately,
+    * too many application programs rely on this
+    * feature.
+    *
+    * This code will be removed in the future.
+    */
+    protected static Device CurrentDevice;
+    protected static Runnable DeviceFinder;
+    static {
+        try {
+            Class.forName ("dwt.widgets.Display");
+        } catch (Throwable e) {}
+    }   
+
+/*
+* TEMPORARY CODE.
+*/
+static synchronized Device getDevice () {
+    if (DeviceFinder !is null) DeviceFinder.run();
+    Device device = CurrentDevice;
+    CurrentDevice = null;
+    return device;
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * You must dispose the device when it is no longer required. 
+ * </p>
+ *
+ * @see #create
+ * @see #init
+ * 
+ * @since 3.1
+ */
+public Device() {
+    this(null);
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * You must dispose the device when it is no longer required. 
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #create
+ * @see #init
+ * @see DeviceData
+ */
+public Device(DeviceData data) {
+    synchronized (Device.class) {
+        if (data !is null) {
+            debug = data.debug;
+            tracking = data.tracking;
+        }
+        if (tracking) {
+            errors = new Error [128];
+            objects = new Object [128];
+            trackingLock = new Object ();
+        }
+        create (data);
+        init ();
+    }
+}
+
+/**
+ * Throws an <code>DWTException</code> if the receiver can not
+ * be accessed by the caller. This may include both checks on
+ * the state of the receiver and more generally on the entire
+ * execution context. This method <em>should</em> be called by
+ * device implementors to enforce the standard DWT invariants.
+ * <p>
+ * Currently, it is an error to invoke any method (other than
+ * <code>isDisposed()</code> and <code>dispose()</code>) on a
+ * device that has had its <code>dispose()</code> method called.
+ * </p><p>
+ * In future releases of DWT, there may be more or fewer error
+ * checks and exceptions may be thrown for different reasons.
+ * <p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+protected void checkDevice () {
+    if (disposed) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
+}
+
+/**
+ * Creates the device in the operating system.  If the device
+ * does not have a handle, this method may do nothing depending
+ * on the device.
+ * <p>
+ * This method is called before <code>init</code>.
+ * </p><p>
+ * Subclasses are supposed to reimplement this method and not
+ * call the <code>super</code> implementation.
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #init
+ */
+protected void create (DeviceData data) {
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the receiver. After this method has been invoked, the receiver
+ * will answer <code>true</code> when sent the message
+ * <code>isDisposed()</code>.
+ *
+ * @see #release
+ * @see #destroy
+ * @see #checkDevice
+ */
+public void dispose () {
+    synchronized (Device.class) {
+        if (isDisposed()) return;
+        checkDevice ();
+        release ();
+        destroy ();
+        disposed = true;
+        if (tracking) {
+            synchronized (trackingLock) {
+                objects = null;
+                errors = null;
+                trackingLock = null;
+            }
+        }
+    }
+}
+
+void dispose_Object (Object object) {
+    synchronized (trackingLock) {
+        for (int i=0; i<objects.length; i++) {
+            if (objects [i] is object) {
+                objects [i] = null;
+                errors [i] = null;
+                return;
+            }
+        }
+    }
+}
+
+/**
+ * Destroys the device in the operating system and releases
+ * the device's handle.  If the device does not have a handle,
+ * this method may do nothing depending on the device.
+ * <p>
+ * This method is called after <code>release</code>.
+ * </p><p>
+ * Subclasses are supposed to reimplement this method and not
+ * call the <code>super</code> implementation.
+ * </p>
+ *
+ * @see #dispose
+ * @see #release
+ */
+protected void destroy () {
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ *
+ * @return the bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+    checkDevice ();
+    NSScreen screen = NSScreen.mainScreen();
+    NSRect rect = screen.frame();
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns a <code>DeviceData</code> based on the receiver.
+ * Modifications made to this <code>DeviceData</code> will not
+ * affect the receiver.
+ *
+ * @return a <code>DeviceData</code> containing the device's data and attributes
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see DeviceData
+ */
+public DeviceData getDeviceData () {
+    checkDevice();
+    DeviceData data = new DeviceData ();
+    data.debug = debug;
+    data.tracking = tracking;
+    if (tracking) {
+        synchronized (trackingLock) {
+            int count = 0, length = objects.length;
+            for (int i=0; i<length; i++) {
+                if (objects [i] !is null) count++;
+            }
+            int index = 0;
+            data.objects = new Object [count];
+            data.errors = new Error [count];
+            for (int i=0; i<length; i++) {
+                if (objects [i] !is null) {
+                    data.objects [index] = objects [i];
+                    data.errors [index] = errors [i];
+                    index++;
+                }
+            }
+        }
+    } else {
+        data.objects = new Object [0];
+        data.errors = new Error [0];
+    }
+    return data;
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * 
+ * @return the client area
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
+ */
+public Rectangle getClientArea () {
+    checkDevice ();
+    NSScreen screen = NSScreen.mainScreen();
+    NSRect rect = screen.visibleFrame();
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns the bit depth of the screen, which is the number of
+ * bits it takes to represent the number of unique colors that
+ * the screen is currently capable of displaying. This number 
+ * will typically be one of 1, 8, 15, 16, 24 or 32.
+ *
+ * @return the depth of the screen
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getDepth () {
+    checkDevice (); 
+    return OS.NSBitsPerPixelFromDepth(NSScreen.mainScreen().depth());
+}
+
+/**
+ * Returns a point whose x coordinate is the horizontal
+ * dots per inch of the display, and whose y coordinate
+ * is the vertical dots per inch of the display.
+ *
+ * @return the horizontal and vertical DPI
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point getDPI () {
+    checkDevice ();
+    NSDictionary dictionary = NSScreen.mainScreen().deviceDescription();
+    NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution())).id);
+    NSSize size = value.sizeValue();
+    return new Point((int)size.width, (int)size.height);
+}
+
+/**
+ * Returns <code>FontData</code> objects which describe
+ * the fonts that match the given arguments. If the
+ * <code>faceName</code> is null, all fonts will be returned.
+ *
+ * @param faceName the name of the font to look for, or null
+ * @param scalable if true only scalable fonts are returned, otherwise only non-scalable fonts are returned.
+ * @return the matching font data
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontData[] getFontList (String faceName, bool scalable) {
+    checkDevice ();
+    if (!scalable) return new FontData[0];
+    NSArray fonts = NSFontManager.sharedFontManager().availableFonts();
+    int count = 0;
+    FontData[] fds = new FontData[fonts.count()];
+    for (int i = 0; i < fds.length; i++) {
+        NSString str = new NSString(fonts.objectAtIndex(i));
+        char[] buffer = new char[str.length()];
+        str.getCharacters_(buffer);
+        String nsName = new String(buffer);
+        String name = nsName;
+        int index = nsName.indexOf('-');
+        if (index !is -1) name = name.substring(0, index);
+        int style = DWT.NORMAL;
+        if (nsName.indexOf("Italic") !is -1) style |= DWT.ITALIC;
+        if (nsName.indexOf("Bold") !is -1) style |= DWT.BOLD;
+        if (faceName is null || Compatibility.equalsIgnoreCase(faceName, name)) {
+            FontData data = new FontData(name, 0, style);
+            data.nsName = nsName;
+            fds[count++] = data;
+        }
+    }
+    if (count is fds.length) return fds;
+    FontData[] result = new FontData[count];
+    System.arraycopy(fds, 0, result, 0, count);
+    return result;
+}
+
+/**
+ * Returns the matching standard color for the given
+ * constant, which should be one of the color constants
+ * specified in class <code>DWT</code>. Any value other
+ * than one of the DWT color constants which is passed
+ * in will result in the color black. This color should
+ * not be freed because it was allocated by the system,
+ * not the application.
+ *
+ * @param id the color constant
+ * @return the matching color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see DWT
+ */
+public Color getSystemColor (int id) {
+    checkDevice ();
+    switch (id) {
+        case DWT.COLOR_BLACK:               return COLOR_BLACK;
+        case DWT.COLOR_DARK_RED:            return COLOR_DARK_RED;
+        case DWT.COLOR_DARK_GREEN:          return COLOR_DARK_GREEN;
+        case DWT.COLOR_DARK_YELLOW:         return COLOR_DARK_YELLOW;
+        case DWT.COLOR_DARK_BLUE:           return COLOR_DARK_BLUE;
+        case DWT.COLOR_DARK_MAGENTA:        return COLOR_DARK_MAGENTA;
+        case DWT.COLOR_DARK_CYAN:           return COLOR_DARK_CYAN;
+        case DWT.COLOR_GRAY:                return COLOR_GRAY;
+        case DWT.COLOR_DARK_GRAY:           return COLOR_DARK_GRAY;
+        case DWT.COLOR_RED:                 return COLOR_RED;
+        case DWT.COLOR_GREEN:               return COLOR_GREEN;
+        case DWT.COLOR_YELLOW:              return COLOR_YELLOW;
+        case DWT.COLOR_BLUE:                return COLOR_BLUE;
+        case DWT.COLOR_MAGENTA:             return COLOR_MAGENTA;
+        case DWT.COLOR_CYAN:                return COLOR_CYAN;
+        case DWT.COLOR_WHITE:               return COLOR_WHITE;
+    }
+    return COLOR_BLACK;
+}
+
+/**
+ * Returns a reasonable font for applications to use.
+ * On some platforms, this will match the "default font"
+ * or "system font" if such can be found.  This font
+ * should not be freed because it was allocated by the
+ * system, not the application.
+ * <p>
+ * Typically, applications which want the default look
+ * should simply not set the font on the widgets they
+ * create. Widgets are always created with the correct
+ * default font for the class of user-interface component
+ * they represent.
+ * </p>
+ *
+ * @return a font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getSystemFont () {
+    checkDevice ();
+    return systemFont;
+}
+
+/**
+ * Returns <code>true</code> if the underlying window system prints out
+ * warning messages on the console, and <code>setWarnings</code>
+ * had previously been called with <code>true</code>.
+ *
+ * @return <code>true</code>if warnings are being handled, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public bool getWarnings () {
+    checkDevice ();
+    return warnings;
+}
+
+/**
+ * Initializes any internal resources needed by the
+ * device.
+ * <p>
+ * This method is called after <code>create</code>.
+ * </p><p>
+ * If subclasses reimplement this method, they must
+ * call the <code>super</code> implementation.
+ * </p>
+ * 
+ * @see #create
+ */
+protected void init () {
+    /* Create the standard colors */
+    COLOR_BLACK = new Color (this, 0,0,0);
+    COLOR_DARK_RED = new Color (this, 0x80,0,0);
+    COLOR_DARK_GREEN = new Color (this, 0,0x80,0);
+    COLOR_DARK_YELLOW = new Color (this, 0x80,0x80,0);
+    COLOR_DARK_BLUE = new Color (this, 0,0,0x80);
+    COLOR_DARK_MAGENTA = new Color (this, 0x80,0,0x80);
+    COLOR_DARK_CYAN = new Color (this, 0,0x80,0x80);
+    COLOR_GRAY = new Color (this, 0xC0,0xC0,0xC0);
+    COLOR_DARK_GRAY = new Color (this, 0x80,0x80,0x80);
+    COLOR_RED = new Color (this, 0xFF,0,0);
+    COLOR_GREEN = new Color (this, 0,0xFF,0);
+    COLOR_YELLOW = new Color (this, 0xFF,0xFF,0);
+    COLOR_BLUE = new Color (this, 0,0,0xFF);
+    COLOR_MAGENTA = new Color (this, 0xFF,0,0xFF);
+    COLOR_CYAN = new Color (this, 0,0xFF,0xFF);
+    COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF);
+    
+    /* Initialize the system font slot */
+    NSFont font = NSFont.systemFontOfSize(NSFont.systemFontSize());
+    systemFont = Font.cocoa_new(this, font);
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Device</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public abstract int internal_new_GC (GCData data);
+
+/**  
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Device</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public abstract void internal_dispose_GC (int handle, GCData data);
+
+/**
+ * Returns <code>true</code> if the device has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the device.
+ * When a device has been disposed, it is an error to
+ * invoke any other method using the device.
+ *
+ * @return <code>true</code> when the device is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed () {
+    synchronized (Device.class) {
+        return disposed;
+    }
+}
+
+/**
+ * Loads the font specified by a file.  The font will be
+ * present in the list of fonts available to the application.
+ *
+ * @param path the font file path
+ * @return whether the font was successfully loaded
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if path is null</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Font
+ * 
+ * @since 3.3
+ */
+public bool loadFont (String path) {
+    checkDevice();
+    if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    bool result = false;
+    char [] chars = new char [path.length ()];
+    path.getChars (0, chars.length, chars, 0);
+    return result;
+}
+
+void new_Object (Object object) {
+    synchronized (trackingLock) {
+        for (int i=0; i<objects.length; i++) {
+            if (objects [i] is null) {
+                objects [i] = object;
+                errors [i] = new Error ();
+                return;
+            }
+        }
+        Object [] newObjects = new Object [objects.length + 128];
+        System.arraycopy (objects, 0, newObjects, 0, objects.length);
+        newObjects [objects.length] = object;
+        objects = newObjects;
+        Error [] newErrors = new Error [errors.length + 128];
+        System.arraycopy (errors, 0, newErrors, 0, errors.length);
+        newErrors [errors.length] = new Error ();
+        errors = newErrors;
+    }
+}
+
+/**
+ * Releases any internal resources back to the operating
+ * system and clears all fields except the device handle.
+ * <p>
+ * When a device is destroyed, resources that were acquired
+ * on behalf of the programmer need to be returned to the
+ * operating system.  For example, if the device allocated a
+ * font to be used as the system font, this font would be
+ * freed in <code>release</code>.  Also,to assist the garbage
+ * collector and minimize the amount of memory that is not
+ * reclaimed when the programmer keeps a reference to a
+ * disposed device, all fields except the handle are zero'd.
+ * The handle is needed by <code>destroy</code>.
+ * </p>
+ * This method is called before <code>destroy</code>.
+ * </p><p>
+ * If subclasses reimplement this method, they must
+ * call the <code>super</code> implementation.
+ * </p>
+ *
+ * @see #dispose
+ * @see #destroy
+ */
+protected void release () {
+    COLOR_BLACK = COLOR_DARK_RED = COLOR_DARK_GREEN = COLOR_DARK_YELLOW = COLOR_DARK_BLUE =
+    COLOR_DARK_MAGENTA = COLOR_DARK_CYAN = COLOR_GRAY = COLOR_DARK_GRAY = COLOR_RED =
+    COLOR_GREEN = COLOR_YELLOW = COLOR_BLUE = COLOR_MAGENTA = COLOR_CYAN = COLOR_WHITE = null;
+}
+
+/**
+ * If the underlying window system supports printing warning messages
+ * to the console, setting warnings to <code>false</code> prevents these
+ * messages from being printed. If the argument is <code>true</code> then
+ * message printing is not blocked.
+ *
+ * @param warnings <code>true</code>if warnings should be printed, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setWarnings (bool warnings) {
+    checkDevice ();
+    this.warnings = warnings;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/DeviceData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.DeviceData;
+
+import dwt.dwthelper.utils;
+
+
+public class DeviceData {
+    /*
+    * Debug fields - may not be honoured
+    * on some DWT platforms.
+    */
+    public bool debug;
+    public bool tracking;
+    public Error [] errors;
+    public Object [] objects;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Drawable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Drawable;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * Implementers of <code>Drawable</code> can have a graphics context (GC)
+ * created for them, and then they can be drawn on by sending messages to
+ * their associated GC. DWT images, and device objects such as the Display
+ * device and the Printer device, are drawables.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the DWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by DWT. It should never be
+ * referenced from application code.
+ * </p>
+ * 
+ * @see Device
+ * @see Image
+ * @see GC
+ */
+public interface Drawable {
+
+/**  
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Drawable</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+ 
+public int /*long*/ internal_new_GC (GCData data);
+
+/**  
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Drawable</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param handle the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int /*long*/ handle, GCData data);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Font.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Font;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSString;
+
+/**
+ * Instances of this class manage operating system resources that
+ * define how text looks when it is displayed. Fonts may be constructed
+ * by providing a device and either name, size and style information
+ * or a <code>FontData</code> object which encapsulates this data.
+ * <p>
+ * Application code must explicitly invoke the <code>Font.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see FontData
+ */
+public final class Font extends Resource {
+
+    /**
+     * the handle to the OS font resource
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public NSFont handle;
+    
+Font(Device device) {
+    super(device);
+}
+
+/**  
+ * Constructs a new font given a device and font data
+ * which describes the desired font's appearance.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fd the FontData that describes the desired font (must not be null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ */
+public Font(Device device, FontData fd) {
+    super(device);
+    if (fd is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    init(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName);
+    init();
+}
+
+/**  
+ * Constructs a new font given a device and an array
+ * of font data which describes the desired font's
+ * appearance.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fds the array of FontData that describes the desired font (must not be null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
+ *    <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public Font(Device device, FontData[] fds) {
+    super(device);
+    if (fds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (fds.length is 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    for (int i=0; i<fds.length; i++) {
+        if (fds[i] is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    FontData fd = fds[0];
+    init(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName);
+    init();
+}
+
+/**  
+ * Constructs a new font given a device, a font name,
+ * the height of the desired font in points, and a font
+ * style.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param name the name of the font (must not be null)
+ * @param height the font height in points
+ * @param style a bit or combination of NORMAL, BOLD, ITALIC
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
+ * </ul>
+ */
+public Font(Device device, String name, int height, int style) {
+    super(device);
+    init(name, height, style, null);
+    init();
+}
+
+/*public*/ Font(Device device, String name, float height, int style) {
+    super(device);
+    init(name, height, style, null);
+    init();
+}
+
+void destroy() {
+    handle.release();
+    handle = null;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals(Object object) {
+    if (object is this) return true;
+    if (!(object instanceof Font)) return false;
+    Font font = (Font)object;
+    return handle is font.handle;
+}
+
+/**
+ * Returns an array of <code>FontData</code>s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however, 
+ * a <code>Font</code> object <em>may</em> be composed of multiple X 
+ * fonts. To support this case, we return an array of font data objects.
+ *
+ * @return an array of font data objects describing the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontData[] getFontData() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSString family = handle.familyName();
+    char[] buffer1 = new char[family.length()];
+    family.getCharacters_(buffer1);
+    String name = new String(buffer1);
+    NSString str = handle.fontName();
+    char[] buffer = new char[str.length()];
+    str.getCharacters_(buffer);
+    String nsName = new String(buffer);
+    int style = DWT.NORMAL;
+    if (nsName.indexOf("Italic") !is -1) style |= DWT.ITALIC;
+    if (nsName.indexOf("Bold") !is -1) style |= DWT.BOLD;
+    FontData data = new FontData(name, handle.pointSize(), style);
+    data.nsName = nsName;
+    return new FontData[]{data};
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new font.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Font</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the font
+ * @param style the style for the font
+ * @param size the size for the font
+ * 
+ * @private
+ */
+public static Font cocoa_new(Device device, NSFont handle) {
+    Font font = new Font(device);
+    font.handle = handle;
+    return font;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+    return handle !is null ? handle.id : 0;
+}
+
+void init(String name, float height, int style, String nsName) {
+    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (nsName !is null) {
+        handle = NSFont.static_fontWithName_size_(NSString.stringWith(nsName), height);
+    } else {
+        nsName = name;
+        if ((style & DWT.BOLD) !is 0) nsName += " Bold";
+        if ((style & DWT.ITALIC) !is 0) nsName += " Italic";
+        handle = NSFont.static_fontWithName_size_(NSString.stringWith(nsName), height);
+        if (handle is null && (style & DWT.ITALIC) !is 0) {
+            nsName = name;
+            if ((style & DWT.BOLD) !is 0) nsName += " Bold";
+            handle = NSFont.static_fontWithName_size_(NSString.stringWith(nsName), height);
+        }
+        if (handle is null && (style & DWT.BOLD) !is 0) {
+            nsName = name;
+            handle = NSFont.static_fontWithName_size_(NSString.stringWith(nsName), height);
+        }
+    }
+    if (handle is null) {
+        handle = device.systemFont.handle;
+    }
+    handle.retain();
+}
+
+/**
+ * Returns <code>true</code> if the font has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the font.
+ * When a font has been disposed, it is an error to
+ * invoke any other method using the font.
+ *
+ * @return <code>true</code> when the font is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "Font {*DISPOSED*}";
+    return "Font {" + handle + "}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/FontData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,448 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.FontData;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+
+/**
+ * Instances of this class describe operating system fonts.
+ * <p>
+ * For platform-independent behaviour, use the get and set methods
+ * corresponding to the following properties:
+ * <dl>
+ * <dt>height</dt><dd>the height of the font in points</dd>
+ * <dt>name</dt><dd>the face name of the font, which may include the foundry</dd>
+ * <dt>style</dt><dd>A bitwise combination of NORMAL, ITALIC and BOLD</dd>
+ * </dl>
+ * If extra, platform-dependent functionality is required:
+ * <ul>
+ * <li>On <em>Windows</em>, the data member of the <code>FontData</code>
+ * corresponds to a Windows <code>LOGFONT</code> structure whose fields
+ * may be retrieved and modified.</li>
+ * <li>On <em>X</em>, the fields of the <code>FontData</code> correspond
+ * to the entries in the font's XLFD name and may be retrieved and modified.
+ * </ul>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ *
+ * @see Font
+ */
+public final class FontData {
+    /**
+     * the font name
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public String name;
+
+    /**
+     * The height of the font data in points
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public float height;
+
+    /**
+     * the font style
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public int style;
+
+    /**
+     * the NSFont font name
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public String nsName;
+
+    /**
+     * The locales of the font
+     */
+    String lang, country, variant;
+    
+/**  
+ * Constructs a new uninitialized font data.
+ */
+public FontData () {
+    this("", 12, DWT.NORMAL);
+}
+
+/**
+ * Constructs a new FontData given a string representation
+ * in the form generated by the <code>FontData.toString</code>
+ * method.
+ * <p>
+ * Note that the representation varies between platforms,
+ * and a FontData can only be created from a string that was 
+ * generated on the same platform.
+ * </p>
+ *
+ * @param string the string representation of a <code>FontData</code> (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description</li>
+ * </ul>
+ *
+ * @see #toString
+ */
+public FontData(String string) {
+    if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    int start = 0;
+    int end = string.indexOf('|');
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    String version1 = string.substring(start, end);
+    try {
+        if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
+    } catch (NumberFormatException e) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    String name = string.substring(start, end);
+    
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    float height = 0;
+    try {
+        height = Float.parseFloat(string.substring(start, end));
+    } catch (NumberFormatException e) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int style = 0;
+    try {
+        style = Integer.parseInt(string.substring(start, end));
+    } catch (NumberFormatException e) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+
+    start = end + 1;
+    end = string.indexOf('|', start);
+    setName(name);
+    setHeight(height);
+    setStyle(style);
+    if (end is -1) return;
+    String platform = string.substring(start, end);
+
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) return;
+    String version2 = string.substring(start, end);
+
+    if (platform.equals("COCOA") && version2.equals("1")) {
+        start = end + 1;
+        end = string.length();
+        if (start < end) nsName = string.substring(start, end);
+    }
+}
+
+/**  
+ * Constructs a new font data given a font name,
+ * the height of the desired font in points, 
+ * and a font style.
+ *
+ * @param name the name of the font (must not be null)
+ * @param height the font height in points
+ * @param style a bit or combination of NORMAL, BOLD, ITALIC
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ */
+public FontData(String name, int height, int style) {
+    setName(name);
+    setHeight(height);
+    setStyle(style);
+}
+
+/*public*/ FontData(String name, float height, int style) {
+    setName(name);
+    setHeight(height);
+    setStyle(style);
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof FontData)) return false;
+    FontData data = (FontData)object;
+    return name.equals(data.name) && height is data.height && style is data.style;
+}
+
+/**
+ * Returns the height of the receiver in points.
+ *
+ * @return the height of this FontData
+ *
+ * @see #setHeight(int)
+ */
+public int getHeight() {
+    return (int)height;
+}
+
+/*public*/ float getHeightF() {
+    return height;
+}
+
+/**
+ * Returns the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms where there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ * 
+ * @return the <code>String</code> representing a Locale object
+ * @since 3.0
+ */
+public String getLocale () {
+    StringBuffer buffer = new StringBuffer ();
+    char sep = '_';
+    if (lang !is null) {
+        buffer.append (lang);
+        buffer.append (sep);
+    }
+    if (country !is null) {
+        buffer.append (country);
+        buffer.append (sep);
+    }
+    if (variant !is null) {
+        buffer.append (variant);
+    }
+    
+    String result = buffer.toString ();
+    int length = result.length ();
+    if (length > 0) {
+        if (result.charAt (length - 1) is sep) {
+            result = result.substring (0, length - 1);
+        }
+    } 
+    return result;
+}
+
+/**
+ * Returns the name of the receiver.
+ * On platforms that support font foundries, the return value will
+ * be the foundry followed by a dash ("-") followed by the face name.
+ *
+ * @return the name of this <code>FontData</code>
+ *
+ * @see #setName
+ */
+public String getName() {
+    return name;
+}
+
+/**
+ * Returns the style of the receiver which is a bitwise OR of 
+ * one or more of the <code>DWT</code> constants NORMAL, BOLD
+ * and ITALIC.
+ *
+ * @return the style of this <code>FontData</code>
+ * 
+ * @see #setStyle
+ */
+public int getStyle() {
+    return style;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode () {
+    return name.hashCode() ^ getHeight() ^ style;
+}
+
+/**
+ * Sets the height of the receiver. The parameter is
+ * specified in terms of points, where a point is one
+ * seventy-second of an inch.
+ *
+ * @param height the height of the <code>FontData</code>
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * 
+ * @see #getHeight
+ */
+public void setHeight(int height) {
+    if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    this.height = height;
+}
+
+/*public*/ void setHeight(float height) {
+    if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    this.height = height;
+}
+
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms where there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ * 
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
+ */
+public void setLocale(String locale) {
+    lang = country = variant = null;
+    if (locale !is null) {
+        char sep = '_';
+        int length = locale.length();
+        int firstSep, secondSep;
+        
+        firstSep = locale.indexOf(sep);
+        if (firstSep is -1) {
+            firstSep = secondSep = length;
+        } else {
+            secondSep = locale.indexOf(sep, firstSep + 1);
+            if (secondSep is -1) secondSep = length;
+        }
+        if (firstSep > 0) lang = locale.substring(0, firstSep);
+        if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+        if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+    }   
+}
+
+/**
+ * Sets the name of the receiver.
+ * <p>
+ * Some platforms support font foundries. On these platforms, the name
+ * of the font specified in setName() may have one of the following forms:
+ * <ol>
+ * <li>a face name (for example, "courier")</li>
+ * <li>a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")</li>
+ * </ol>
+ * In either case, the name returned from getName() will include the
+ * foundry.
+ * </p>
+ * <p>
+ * On platforms that do not support font foundries, only the face name
+ * (for example, "courier") is used in <code>setName()</code> and 
+ * <code>getName()</code>.
+ * </p>
+ *
+ * @param name the name of the font data (must not be null)
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
+ * </ul>
+ *
+ * @see #getName
+ */
+public void setName(String name) {
+    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    this.name = name;
+    nsName = null;
+}
+
+/**
+ * Sets the style of the receiver to the argument which must
+ * be a bitwise OR of one or more of the <code>DWT</code> 
+ * constants NORMAL, BOLD and ITALIC.  All other style bits are
+ * ignored.
+ *
+ * @param style the new style for this <code>FontData</code>
+ *
+ * @see #getStyle
+ */
+public void setStyle(int style) {
+    this.style = style;
+    nsName = null;
+}
+
+/**
+ * Returns a string representation of the receiver which is suitable
+ * for constructing an equivalent instance using the 
+ * <code>FontData(String)</code> constructor.
+ *
+ * @return a string representation of the FontData
+ *
+ * @see FontData
+ */
+public String toString() {
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("1|");
+    buffer.append(getName());
+    buffer.append("|");
+    buffer.append(getHeightF());
+    buffer.append("|");
+    buffer.append(getStyle());
+    buffer.append("|");
+    buffer.append("COCOA|1|");
+    if (nsName !is null) buffer.append(nsName);
+    return buffer.toString();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/FontMetrics.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.FontMetrics;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * Instances of this class provide measurement information
+ * about fonts including ascent, descent, height, leading
+ * space between rows, and average character width.
+ * <code>FontMetrics</code> are obtained from <code>GC</code>s
+ * using the <code>getFontMetrics()</code> method.
+ *
+ * @see GC#getFontMetrics
+ */
+public final class FontMetrics {
+    int ascent, descent, averageCharWidth, leading, height;
+
+FontMetrics() {
+}
+
+public static FontMetrics cocoa_new(int ascent, int descent, int averageCharWidth, int leading, int height) {
+    FontMetrics fontMetrics = new FontMetrics();
+    fontMetrics.ascent = ascent;
+    fontMetrics.descent = descent;
+    fontMetrics.averageCharWidth = averageCharWidth;
+    fontMetrics.leading = leading;
+    fontMetrics.height = height;
+    return fontMetrics;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof FontMetrics)) return false;
+    FontMetrics metrics = (FontMetrics)object;
+    return ascent is metrics.ascent && descent is metrics.descent &&
+        averageCharWidth is metrics.averageCharWidth && leading is metrics.leading &&
+        height is metrics.height;
+}
+
+/**
+ * Returns the ascent of the font described by the receiver. A
+ * font's <em>ascent</em> is the distance from the baseline to the 
+ * top of actual characters, not including any of the leading area,
+ * measured in pixels.
+ *
+ * @return the ascent of the font
+ */
+public int getAscent() {
+    return ascent;
+}
+
+/**
+ * Returns the average character width, measured in pixels,
+ * of the font described by the receiver.
+ *
+ * @return the average character width of the font
+ */
+public int getAverageCharWidth() {
+    return averageCharWidth;
+}
+
+/**
+ * Returns the descent of the font described by the receiver. A
+ * font's <em>descent</em> is the distance from the baseline to the
+ * bottom of actual characters, not including any of the leading area,
+ * measured in pixels.
+ *
+ * @return the descent of the font
+ */
+public int getDescent() {
+    return descent;
+}
+
+/**
+ * Returns the height of the font described by the receiver, 
+ * measured in pixels. A font's <em>height</em> is the sum of
+ * its ascent, descent and leading area.
+ *
+ * @return the height of the font
+ *
+ * @see #getAscent
+ * @see #getDescent
+ * @see #getLeading
+ */
+public int getHeight() {
+    return height;
+}
+
+/**
+ * Returns the leading area of the font described by the
+ * receiver. A font's <em>leading area</em> is the space
+ * above its ascent which may include accents or other marks.
+ *
+ * @return the leading space of the font
+ */
+public int getLeading() {
+    return leading;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+    return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/GC.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,3424 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.GC;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSAffineTransformStruct;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSGradient;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Class <code>GC</code> is where all of the drawing capabilities that are 
+ * supported by DWT are located. Instances are used to draw on either an 
+ * <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * </dl>
+ * 
+ * <p>
+ * The DWT drawing coordinate system is the two-dimensional space with the origin
+ * (0,0) at the top left corner of the drawing area and with (x,y) values increasing
+ * to the right and downward respectively.
+ * </p>
+ * 
+ * <p>
+ * Application code must explicitly invoke the <code>GC.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required. This is <em>particularly</em>
+ * important on Windows95 and Windows98 where the operating system has a limited
+ * number of device contexts available.
+ * </p>
+ * 
+ * <p>
+ * Note: Only one of LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified.
+ * </p>
+ *
+ * @see dwt.events.PaintEvent
+ */
+public final class GC extends Resource {
+    /**
+     * the handle to the OS device context
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public NSGraphicsContext handle;
+    
+    Drawable drawable;
+    GCData data;
+
+    static final int TAB_COUNT = 32;
+
+    final static int FOREGROUND = 1 << 0;
+    final static int BACKGROUND = 1 << 1;
+    final static int FONT = 1 << 2;
+    final static int LINE_STYLE = 1 << 3;
+    final static int LINE_CAP = 1 << 4;
+    final static int LINE_JOIN = 1 << 5;
+    final static int LINE_WIDTH = 1 << 6;
+    final static int LINE_MITERLIMIT = 1 << 7;
+    final static int FOREGROUND_FILL = 1 << 8;
+    final static int DRAW_OFFSET = 1 << 9;
+    final static int CLIPPING = 1 << 10;
+    final static int TRANSFORM = 1 << 11;
+    final static int DRAW = CLIPPING | TRANSFORM | FOREGROUND | LINE_WIDTH | LINE_STYLE  | LINE_CAP  | LINE_JOIN | LINE_MITERLIMIT | DRAW_OFFSET;
+    final static int FILL = CLIPPING | TRANSFORM | BACKGROUND;
+
+    static final float[] LINE_DOT = new float[]{1, 1};
+    static final float[] LINE_DASH = new float[]{3, 1};
+    static final float[] LINE_DASHDOT = new float[]{3, 1, 1, 1};
+    static final float[] LINE_DASHDOTDOT = new float[]{3, 1, 1, 1, 1, 1};
+    static final float[] LINE_DOT_ZERO = new float[]{3, 3};
+    static final float[] LINE_DASH_ZERO = new float[]{18, 6};
+    static final float[] LINE_DASHDOT_ZERO = new float[]{9, 6, 3, 6};
+    static final float[] LINE_DASHDOTDOT_ZERO = new float[]{9, 3, 3, 3, 3, 3};
+
+GC() {
+}
+
+/**  
+ * Constructs a new instance of this class which has been
+ * configured to draw on the specified drawable. Sets the
+ * foreground color, background color and font in the GC
+ * to match those in the drawable.
+ * <p>
+ * You must dispose the graphics context when it is no longer required. 
+ * </p>
+ * @param drawable the drawable to draw on
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the drawable is null</li>
+ *    <li>ERROR_NULL_ARGUMENT - if there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT
+ *          - if the drawable is an image that is not a bitmap or an icon
+ *          - if the drawable is an image or printer that is already selected
+ *            into another graphics context</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li>
+ * </ul>
+ */
+public GC(Drawable drawable) {
+    this(drawable, 0);
+}
+
+/**  
+ * Constructs a new instance of this class which has been
+ * configured to draw on the specified drawable. Sets the
+ * foreground color, background color and font in the GC
+ * to match those in the drawable.
+ * <p>
+ * You must dispose the graphics context when it is no longer required. 
+ * </p>
+ * 
+ * @param drawable the drawable to draw on
+ * @param style the style of GC to construct
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the drawable is null</li>
+ *    <li>ERROR_NULL_ARGUMENT - if there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT
+ *          - if the drawable is an image that is not a bitmap or an icon
+ *          - if the drawable is an image or printer that is already selected
+ *            into another graphics context</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li>
+ * </ul>
+ *  
+ * @since 2.1.2
+ */
+public GC(Drawable drawable, int style) {
+    if (drawable is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    GCData data = new GCData();
+    data.style = checkStyle(style);
+    int contextId = drawable.internal_new_GC(data);
+    Device device = data.device;
+    if (device is null) device = Device.getDevice();
+    if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    this.device = data.device = device;
+    init(drawable, data, contextId);
+    init();
+}
+
+static int checkStyle (int style) {
+    if ((style & DWT.LEFT_TO_RIGHT) !is 0) style &= ~DWT.RIGHT_TO_LEFT;
+    return style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT);
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new graphics context.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>GC</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param drawable the Drawable for the receiver.
+ * @param data the data for the receiver.
+ *
+ * @return a new <code>GC</code>
+ *
+ * @private
+ */
+public static GC cocoa_new(Drawable drawable, GCData data) {
+    GC gc = new GC();
+    int context = drawable.internal_new_GC(data);
+    gc.device = data.device;
+    gc.init(drawable, data, context);
+    return gc;
+}
+
+/**  
+ * Invokes platform specific functionality to wrap a graphics context.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>GC</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param context the Quartz context.
+ * @param data the data for the receiver.
+ *
+ * @return a new <code>GC</code>
+ */
+public static GC carbon_new(int context, GCData data) {
+    GC gc = new GC();
+    gc.device = data.device;
+    gc.init(null, data, context);
+    return gc;
+}
+
+void checkGC (int mask) {
+    if ((data.state & CLIPPING) is 0 || (data.state & TRANSFORM) is 0) {
+        handle.restoreGraphicsState();
+        handle.saveGraphicsState();
+        if (data.clipPath !is null) data.clipPath.addClip();
+        if (data.transform !is null) data.transform.concat();
+        mask &= ~(TRANSFORM | CLIPPING);
+        data.state |= TRANSFORM | CLIPPING;
+        data.state &= ~(BACKGROUND | FOREGROUND);
+    }
+
+    int state = data.state;
+    if ((state & mask) is mask) return;
+    state = (state ^ mask) & mask;  
+    data.state |= mask;
+    
+    if ((state & FOREGROUND) !is 0) {
+        Pattern pattern = data.foregroundPattern;
+        if (pattern !is null) {
+            if (pattern.color !is null) pattern.color.setStroke();
+        } else {
+            float[] color = data.foreground;
+            NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f).setStroke();
+        }
+    }
+    if ((state & FOREGROUND_FILL) !is 0) {
+        Pattern pattern = data.foregroundPattern;
+        if (pattern !is null) {
+            if (pattern.color !is null) pattern.color.setFill();
+        } else {
+            float[] color = data.foreground;
+            NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f).setFill();
+        }
+        data.state &= ~BACKGROUND;
+    }
+    if ((state & BACKGROUND) !is 0) {
+        Pattern pattern = data.backgroundPattern;
+        if (pattern !is null) {
+            if (pattern.color !is null) pattern.color.setFill();
+        } else {
+            float[] color = data.background;
+            NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f).setFill();
+        }
+        data.state &= ~FOREGROUND_FILL;
+    }
+    NSBezierPath path = data.path;
+    if ((state & LINE_WIDTH) !is 0) {
+        path.setLineWidth(data.lineWidth is 0 ?  1 : data.lineWidth);
+        switch (data.lineStyle) {
+            case DWT.LINE_DOT:
+            case DWT.LINE_DASH:
+            case DWT.LINE_DASHDOT:
+            case DWT.LINE_DASHDOTDOT:
+                state |= LINE_STYLE;
+        }
+    }
+    if ((state & LINE_STYLE) !is 0) {
+        float[] dashes = null;
+        float width = data.lineWidth;
+        switch (data.lineStyle) {
+            case DWT.LINE_SOLID: break;
+            case DWT.LINE_DASH: dashes = width !is 0 ? LINE_DASH : LINE_DASH_ZERO; break;
+            case DWT.LINE_DOT: dashes = width !is 0 ? LINE_DOT : LINE_DOT_ZERO; break;
+            case DWT.LINE_DASHDOT: dashes = width !is 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
+            case DWT.LINE_DASHDOTDOT: dashes = width !is 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
+            case DWT.LINE_CUSTOM: dashes = data.lineDashes; break;
+        }
+        if (dashes !is null) {
+            float[] lengths = new float[dashes.length];
+            for (int i = 0; i < lengths.length; i++) {
+                lengths[i] = width is 0 || data.lineStyle is DWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width;
+            }
+            path.setLineDash(lengths, lengths.length, data.lineDashesOffset);
+        } else {
+            path.setLineDash(null, 0, 0);
+        }
+    }
+    if ((state & LINE_MITERLIMIT) !is 0) {
+        path.setMiterLimit(data.lineMiterLimit);
+    }
+    if ((state & LINE_JOIN) !is 0) {
+        int joinStyle = 0;
+        switch (data.lineJoin) {
+            case DWT.JOIN_MITER: joinStyle = OS.NSMiterLineJoinStyle; break;
+            case DWT.JOIN_ROUND: joinStyle = OS.NSRoundLineJoinStyle; break;
+            case DWT.JOIN_BEVEL: joinStyle = OS.NSBevelLineJoinStyle; break;
+        }
+        path.setLineJoinStyle(joinStyle);
+    }
+    if ((state & LINE_CAP) !is 0) {
+        int capStyle = 0;
+        switch (data.lineCap) {
+            case DWT.CAP_ROUND: capStyle = OS.NSRoundLineCapStyle; break;
+            case DWT.CAP_FLAT: capStyle = OS.NSButtLineCapStyle; break;
+            case DWT.CAP_SQUARE: capStyle = OS.NSSquareLineCapStyle; break;
+        }
+        path.setLineCapStyle(capStyle);
+    }
+    if ((state & DRAW_OFFSET) !is 0) {
+        data.drawXOffset = data.drawYOffset = 0;
+        NSSize size = new NSSize();
+        size.width = size.height = 1;
+        if (data.transform !is null) {
+            size = data.transform.transformSize(size);
+        }
+        float scaling = size.width;
+        if (scaling < 0) scaling = -scaling;
+        float strokeWidth = data.lineWidth * scaling;
+        if (strokeWidth is 0 || ((int)strokeWidth % 2) is 1) {
+            data.drawXOffset = 0.5f / scaling;
+        }
+        scaling = size.height;
+        if (scaling < 0) scaling = -scaling;
+        strokeWidth = data.lineWidth * scaling;
+        if (strokeWidth is 0 || ((int)strokeWidth % 2) is 1) {
+            data.drawYOffset = 0.5f / scaling;
+        }
+    }
+}
+
+/**
+ * Copies a rectangular area of the receiver at the specified
+ * position into the image, which must be of type <code>DWT.BITMAP</code>.
+ *
+ * @param image the image to copy into
+ * @param x the x coordinate in the receiver of the area to be copied
+ * @param y the y coordinate in the receiver of the area to be copied
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image is not a bitmap or has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void copyArea(Image image, int x, int y) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (image.type !is DWT.BITMAP || image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+//  if (data.image !is null) {
+//      copyArea(image, x, y, data.image.handle);
+//  } else if (data.control !is 0) {
+//      int imageHandle = image.handle;
+//      int width = OS.CGImageGetWidth(imageHandle);
+//      int height = OS.CGImageGetHeight(imageHandle);
+//      int window = OS.GetControlOwner(data.control);
+//      Rect srcRect = new Rect ();
+//      CGPoint pt = new CGPoint ();
+//      int[] contentView = new int[1];
+//      OS.HIViewFindByID(OS.HIViewGetRoot(window), OS.kHIViewWindowContentID(), contentView);
+//      OS.HIViewConvertPoint (pt, data.control, contentView[0]);
+//      x += (int) pt.x;
+//      y += (int) pt.y;
+//      Rect inset = data.insetRect;
+//      x -= inset.left;
+//      y -= inset.top;
+//      srcRect.left = (short)x;
+//      srcRect.top = (short)y;
+//      srcRect.right = (short)(x + width);
+//      srcRect.bottom = (short)(y + height);
+//      Rect destRect = new Rect();
+//      destRect.right = (short)width;
+//      destRect.bottom = (short)height;
+//      int bpl = width * 4;
+//      int[] gWorld = new int[1];
+//      int port = OS.GetWindowPort(window);        
+//      OS.NewGWorldFromPtr(gWorld, OS.k32ARGBPixelFormat, destRect, 0, 0, 0, image.data, bpl);
+//      OS.CopyBits(OS.GetPortBitMapForCopyBits(port), OS.GetPortBitMapForCopyBits(gWorld[0]), srcRect, destRect, (short)OS.srcCopy, 0);            
+//      OS.DisposeGWorld(gWorld [0]);
+//  } else if (data.window !is 0) {
+//      int imageHandle = image.handle;
+//      CGRect rect = new CGRect();
+//      rect.x = x;
+//      rect.y = y;
+//      rect.width = OS.CGImageGetWidth(imageHandle);
+//      rect.height = OS.CGImageGetHeight(imageHandle);
+//      int[] displays = new int[16];
+//      int[] count = new int[1];
+//      if (OS.CGGetDisplaysWithRect(rect, displays.length, displays, count) !is 0) return;
+//      for (int i = 0; i < count[0]; i++) {
+//          int display = displays[i];
+//          int address = OS.CGDisplayBaseAddress(display);
+//          if (address !is 0) {
+//              int width = OS.CGDisplayPixelsWide(display);
+//              int height = OS.CGDisplayPixelsHigh(display);
+//              int bpr = OS.CGDisplayBytesPerRow(display);
+//              int bpp = OS.CGDisplayBitsPerPixel(display);
+//              int bps = OS.CGDisplayBitsPerSample(display);
+//              int bitmapInfo = OS.kCGImageAlphaNoneSkipFirst;
+//              switch (bpp) {
+//                  case 16: bitmapInfo |= OS.kCGBitmapByteOrder16Host; break;
+//                  case 32: bitmapInfo |= OS.kCGBitmapByteOrder32Host; break;
+//              }
+//              int srcImage = 0;
+//              if (OS.__BIG_ENDIAN__() && OS.VERSION >= 0x1040) {
+//                  int context = OS.CGBitmapContextCreate(address, width, height, bps, bpr, data.device.colorspace, bitmapInfo);
+//                  srcImage = OS.CGBitmapContextCreateImage(context);
+//                  OS.CGContextRelease(context);
+//              } else {
+//                  int provider = OS.CGDataProviderCreateWithData(0, address, bpr * height, 0);
+//                  srcImage = OS.CGImageCreate(width, height, bps, bpp, bpr, data.device.colorspace, bitmapInfo, provider, null, true, 0);
+//                  OS.CGDataProviderRelease(provider);
+//              }
+//              copyArea(image, x, y, srcImage);
+//              if (srcImage !is 0) OS.CGImageRelease(srcImage);
+//          }
+//      }
+//  }   
+}
+
+void copyArea (Image image, int x, int y, int srcImage) {
+    if (srcImage is 0) return;
+//  int imageHandle = image.handle;
+//  int bpc = OS.CGImageGetBitsPerComponent(imageHandle);
+//  int width = OS.CGImageGetWidth(imageHandle);
+//  int height = OS.CGImageGetHeight(imageHandle);
+//  int bpr = OS.CGImageGetBytesPerRow(imageHandle);
+//  int alphaInfo = OS.CGImageGetAlphaInfo(imageHandle);
+//  int context = OS.CGBitmapContextCreate(image.data, width, height, bpc, bpr, data.device.colorspace, alphaInfo);
+//  if (context !is 0) {
+//      CGRect rect = new CGRect();
+//      rect.x = -x;
+//      rect.y = y;
+//      rect.width = OS.CGImageGetWidth(srcImage);
+//      rect.height = OS.CGImageGetHeight(srcImage);
+//      OS.CGContextTranslateCTM(context, 0, -(rect.height - height));
+//      OS.CGContextDrawImage(context, rect, srcImage);
+//      OS.CGContextRelease(context);
+//  }
+}
+
+/**
+ * Copies a rectangular area of the receiver at the source
+ * position onto the receiver at the destination position.
+ *
+ * @param srcX the x coordinate in the receiver of the area to be copied
+ * @param srcY the y coordinate in the receiver of the area to be copied
+ * @param width the width of the area to copy
+ * @param height the height of the area to copy
+ * @param destX the x coordinate in the receiver of the area to copy to
+ * @param destY the y coordinate in the receiver of the area to copy to
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
+    copyArea(srcX, srcY, width, height, destX, destY, true);
+}
+/**
+ * Copies a rectangular area of the receiver at the source
+ * position onto the receiver at the destination position.
+ *
+ * @param srcX the x coordinate in the receiver of the area to be copied
+ * @param srcY the y coordinate in the receiver of the area to be copied
+ * @param width the width of the area to copy
+ * @param height the height of the area to copy
+ * @param destX the x coordinate in the receiver of the area to copy to
+ * @param destY the y coordinate in the receiver of the area to copy to
+ * @param paint if <code>true</code> paint events will be generated for old and obscured areas
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, bool paint) {
+//  if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+//  if (data.updateClip) setCGClipping();
+//  if (width <= 0 || height <= 0) return;
+//  int deltaX = destX - srcX, deltaY = destY - srcY;
+//  if (deltaX is 0 && deltaY is 0) return;
+//  if (data.image !is null) {
+//      OS.CGContextSaveGState(handle);
+//      OS.CGContextScaleCTM(handle, 1, -1);
+//      OS.CGContextTranslateCTM(handle, 0, -(height + 2 * destY));
+//      CGRect rect = new CGRect();
+//      rect.x = destX;
+//      rect.y = destY;
+//      rect.width = width;
+//      rect.height = height;
+//      int h = OS.CGImageGetHeight(data.image.handle);
+//      int bpr = OS.CGImageGetBytesPerRow(data.image.handle);
+//      int provider = OS.CGDataProviderCreateWithData(0, data.image.data, bpr * h, 0);
+//      if (provider !is 0) {
+//          int colorspace = device.colorspace;
+//          int img = OS.CGImageCreate(width, height, 8, 32, bpr, colorspace, OS.kCGImageAlphaNoneSkipFirst, provider, null, true, 0);
+//          OS.CGDataProviderRelease(provider);
+//          OS.CGContextDrawImage(handle, rect, img);
+//          OS.CGImageRelease(img);
+//      }
+//      OS.CGContextRestoreGState(handle);
+//      return;
+//  }
+//  if (data.control !is 0) {
+//      int port = data.port;
+//      int window = OS.GetControlOwner(data.control);
+//      if (port is 0) port = OS.GetWindowPort(window);
+//
+//      /* Calculate src and dest rectangles/regions */
+//      Rect rect = new Rect();
+//      OS.GetControlBounds(data.control, rect);
+//      int convertX = 0, convertY = 0;
+//      CGPoint pt = new CGPoint ();
+//      int[] contentView = new int[1];
+//      OS.HIViewFindByID(OS.HIViewGetRoot(window), OS.kHIViewWindowContentID(), contentView);
+//      OS.HIViewConvertPoint(pt, OS.HIViewGetSuperview(data.control), contentView[0]);
+//      convertX = rect.left + (int) pt.x;
+//      convertY = rect.top + (int) pt.y;
+//      rect.left += (int) pt.x;
+//      rect.top += (int) pt.y;
+//      rect.right += (int) pt.x;
+//      rect.bottom += (int) pt.y;
+//      Rect srcRect = new Rect();
+//      int left = rect.left + srcX;
+//      int top = rect.top + srcY;
+//      OS.SetRect(srcRect, (short)left, (short)top, (short)(left + width), (short)(top + height));
+//      int srcRgn = OS.NewRgn();
+//      OS.RectRgn(srcRgn, srcRect);
+//      OS.SectRect(rect, srcRect, srcRect);
+//      Rect destRect = new Rect ();
+//      OS.SetRect(destRect, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom);
+//      OS.OffsetRect(destRect, (short)deltaX, (short)deltaY);
+//      int destRgn = OS.NewRgn();
+//      OS.RectRgn(destRgn, destRect);
+//      
+//      /* Copy bits with appropriated clipping region */
+//      if (!OS.EmptyRect(srcRect)) {
+//          if (data.visibleRgn is 0 || OS.RectInRgn(srcRect, data.visibleRgn)) {
+//              int clipRgn = data.visibleRgn;
+//              if (data.clipRgn !is 0) {
+//                  clipRgn = OS.NewRgn();
+//                  OS.SectRgn(data.clipRgn, data.visibleRgn, clipRgn);
+//              }
+//  
+//              /*
+//              * Feature in the Macintosh.  ScrollRect() only copies bits
+//              * that are inside the specified rectangle.  This means that
+//              * it is not possible to copy non overlaping bits without
+//              * copying the bits in between the source and destination
+//              * rectangles.  The fix is to check if the source and
+//              * destination rectangles are disjoint and use CopyBits()
+//              * instead.
+//              */
+//              if (!OS.EmptyRgn(clipRgn)) {
+//                  bool disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
+//                  if (!disjoint && (deltaX is 0 || deltaY is 0)) {
+//                      int[] currentPort = new int[1];
+//                      OS.GetPort(currentPort);
+//                      OS.SetPort(port);
+//                      int oldClip = OS.NewRgn();
+//                      OS.GetClip(oldClip);
+//                      OS.SetClip(clipRgn);
+//                      OS.UnionRect(srcRect, destRect, rect);
+//                      OS.ScrollRect(rect, (short)deltaX, (short)deltaY, 0);
+//                      OS.SetClip(oldClip);
+//                      OS.DisposeRgn(oldClip);
+//                      OS.SetPort(currentPort[0]);
+//                  } else {
+//                      int portBitMap = OS.GetPortBitMapForCopyBits (port);
+//                      OS.CopyBits(portBitMap, portBitMap, srcRect, destRect, (short)OS.srcCopy, clipRgn);
+//                      OS.QDFlushPortBuffer(port, destRgn);
+//                  }
+//              }
+//              
+//              if (clipRgn !is data.visibleRgn) OS.DisposeRgn(clipRgn);
+//          }
+//      }
+//      
+//      /* Invalidate src and obscured areas */
+//      if (paint) {
+//          int invalRgn = OS.NewRgn();
+//          OS.DiffRgn(srcRgn, data.visibleRgn, invalRgn);
+//          OS.OffsetRgn(invalRgn, (short)deltaX, (short)deltaY);
+//          OS.DiffRgn(srcRgn, destRgn, srcRgn);
+//          OS.UnionRgn(srcRgn, invalRgn, invalRgn);
+//          OS.SectRgn(data.visibleRgn, invalRgn, invalRgn);
+//          OS.OffsetRgn(invalRgn, (short)-convertX, (short)-convertY);
+//          OS.HIViewSetNeedsDisplayInRegion(data.control, invalRgn, true);
+//          OS.DisposeRgn(invalRgn);
+//      }
+//      
+//      /* Dispose src and dest regions */
+//      OS.DisposeRgn(destRgn);
+//      OS.DisposeRgn(srcRgn);
+//  }
+}
+
+NSAttributedString createString(String string, int flags) {
+    NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
+    float[] foreground = data.foreground;
+    NSColor color = NSColor.colorWithDeviceRed(foreground[0], foreground[1], foreground[2], data.alpha / 255f);
+    dict.setObject(color, OS.NSForegroundColorAttributeName());
+    dict.setObject(data.font.handle, OS.NSFontAttributeName());
+    if ((flags & DWT.DRAW_TRANSPARENT) is 0) {
+        float[] background = data.background;
+        color = NSColor.colorWithDeviceRed(background[0], background[1], background[2], data.alpha / 255f);
+        dict.setObject(color, OS.NSBackgroundColorAttributeName());
+    }
+    int length = string.length();
+    char[] chars = new char[length];
+    string.getChars(0, length, chars, 0);
+//  int breakCount = 0;
+//  int[] breaks = null;
+//  if ((flags & (DWT.DRAW_MNEMONIC | DWT.DRAW_DELIMITER)) !is 0) {
+//      int i=0, j=0;
+//      while (i < chars.length) {
+//          char c = chars [j++] = chars [i++];
+//          switch (c) {
+//              case '&': {
+//                  if ((flags & DWT.DRAW_MNEMONIC) !is 0) {
+//                      if (i is chars.length) {continue;}
+//                      if (chars [i] is '&') {i++; continue;}
+//                      j--;
+//                  }
+//                  break;
+//              }
+//              case '\r':
+//              case '\n': {
+//                  if ((flags & DWT.DRAW_DELIMITER) !is 0) {
+//                      if (c is '\r' && i !is chars.length && chars[i] is '\n') i++;
+//                      j--;
+//                      if (breaks is null) {
+//                          breaks = new int[4];
+//                      } else if (breakCount is breaks.length) {
+//                          int[] newBreaks = new int[breaks.length + 4];
+//                          System.arraycopy(breaks, 0, newBreaks, 0, breaks.length);
+//                          breaks = newBreaks;
+//                      }
+//                      breaks[breakCount++] = j;
+//                  }
+//                  break;
+//              }
+//          }
+//      }
+//      length = j;
+//  }
+    NSString str = NSString.stringWithCharacters(chars, length);
+    return ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict);
+}
+
+void destroy() {
+    /* Free resources */
+    Image image = data.image;
+    if (image !is null) {
+        image.memGC = null;
+        image.createAlpha();
+    }
+    if (data.clipPath !is null) data.clipPath.release();
+    if (data.transform !is null) data.transform.release();
+    if (data.inverseTransform !is null) data.inverseTransform.release();
+    data.path = data.clipPath = null;
+    data.transform = data.inverseTransform = null;
+    
+    /* Dispose the GC */
+    if (drawable !is null) drawable.internal_dispose_GC(handle.id, data);
+    handle.restoreGraphicsState();
+    handle.release();
+
+    drawable = null;
+    data.image = null;
+    data = null;
+    handle = null;
+}
+
+/**
+ * Draws the outline of a circular or elliptical arc 
+ * within the specified rectangular area.
+ * <p>
+ * The resulting arc begins at <code>startAngle</code> and extends  
+ * for <code>arcAngle</code> degrees, using the current color.
+ * Angles are interpreted such that 0 degrees is at the 3 o'clock
+ * position. A positive value indicates a counter-clockwise rotation
+ * while a negative value indicates a clockwise rotation.
+ * </p><p>
+ * The center of the arc is the center of the rectangle whose origin 
+ * is (<code>x</code>, <code>y</code>) and whose size is specified by the 
+ * <code>width</code> and <code>height</code> arguments. 
+ * </p><p>
+ * The resulting arc covers an area <code>width + 1</code> pixels wide
+ * by <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper-left corner of the arc to be drawn
+ * @param y the y coordinate of the upper-left corner of the arc to be drawn
+ * @param width the width of the arc to be drawn
+ * @param height the height of the arc to be drawn
+ * @param startAngle the beginning angle
+ * @param arcAngle the angular extent of the arc, relative to the start angle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    if (width < 0) {
+        x = x + width;
+        width = -width;
+    }
+    if (height < 0) {
+        y = y + height;
+        height = -height;
+    }
+    if (width is 0 || height is 0 || arcAngle is 0) return;
+    handle.saveGraphicsState();
+    NSAffineTransform transform = NSAffineTransform.transform();
+    float xOffset = data.drawXOffset, yOffset = data.drawYOffset;
+    transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f);
+    transform.scaleXBy(width / 2f, height / 2f);
+    NSBezierPath path = data.path;
+    NSPoint center = new NSPoint();
+    float sAngle = -startAngle;
+    float eAngle = -(startAngle + arcAngle);
+    path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_(center, 1, sAngle,  eAngle, arcAngle>0);
+    path.transformUsingAffineTransform(transform);
+    path.stroke();
+    path.removeAllPoints();
+    handle.restoreGraphicsState();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws a rectangle, based on the specified arguments, which has
+ * the appearance of the platform's <em>focus rectangle</em> if the
+ * platform supports such a notion, and otherwise draws a simple
+ * rectangle in the receiver's foreground color.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void drawFocus(int x, int y, int width, int height) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(CLIPPING | TRANSFORM);
+//  int[] metric = new int[1];
+//  OS.GetThemeMetric(OS.kThemeMetricFocusRectOutset, metric);
+//  CGRect rect = new CGRect ();
+//  rect.x = x + metric[0];
+//  rect.y = y + metric[0];
+//  rect.width = width - metric[0] * 2;
+//  rect.height = height - metric[0] * 2;
+//  OS.HIThemeDrawFocusRect(rect, true, handle, OS.kHIThemeOrientationNormal);
+//  flush();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/**
+ * Draws the given image in the receiver at the specified
+ * coordinates.
+ *
+ * @param image the image to draw
+ * @param x the x coordinate of where to draw
+ * @param y the y coordinate of where to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of the image</li>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ */
+public void drawImage(Image image, int x, int y) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ *    <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ */
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (srcWidth is 0 || srcHeight is 0 || destWidth is 0 || destHeight is 0) return;
+    if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+}
+
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) {
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(CLIPPING | TRANSFORM);
+    NSImage imageHandle = srcImage.handle;
+    NSSize size = imageHandle.size();
+    int imgWidth = (int)size.width;
+    int imgHeight = (int)size.height;
+    if (simple) {
+        srcWidth = destWidth = imgWidth;
+        srcHeight = destHeight = imgHeight;
+    } else {
+        simple = srcX is 0 && srcY is 0 &&
+            srcWidth is destWidth && destWidth is imgWidth &&
+            srcHeight is destHeight && destHeight is imgHeight;
+        if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
+            NSGraphicsContext.setCurrentContext(context);
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+    if (srcImage.memGC !is null) srcImage.createAlpha();
+    handle.saveGraphicsState();
+    NSAffineTransform transform = NSAffineTransform.transform();
+    transform.scaleXBy(1, -1);
+    transform.translateXBy(0, -(destHeight + 2 * destY));
+    transform.concat();
+    NSRect srcRect = new NSRect();
+    srcRect.x = srcX;
+    srcRect.y = srcY;
+    srcRect.width = srcWidth;
+    srcRect.height = srcHeight;
+    NSRect destRect = new NSRect();
+    destRect.x = destX;
+    destRect.y = destY;
+    destRect.width = destWidth;
+    destRect.height = destHeight;
+    imageHandle.drawInRect(destRect, srcRect, OS.NSCompositeSourceOver, 1);
+    handle.restoreGraphicsState();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws a line, using the foreground color, between the points 
+ * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
+ *
+ * @param x1 the first point's x coordinate
+ * @param y1 the first point's y coordinate
+ * @param x2 the second point's x coordinate
+ * @param y2 the second point's y coordinate
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawLine(int x1, int y1, int x2, int y2) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    NSBezierPath path = data.path;
+    NSPoint pt = new NSPoint();
+    pt.x = x1 + data.drawXOffset;
+    pt.y = y1 + data.drawYOffset;
+    path.moveToPoint(pt);
+    pt.x = x2 + data.drawXOffset;
+    pt.y = y2 + data.drawYOffset;
+    path.lineToPoint(pt);
+    path.stroke();
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws the outline of an oval, using the foreground color,
+ * within the specified rectangular area.
+ * <p>
+ * The result is a circle or ellipse that fits within the 
+ * rectangle specified by the <code>x</code>, <code>y</code>, 
+ * <code>width</code>, and <code>height</code> arguments. 
+ * </p><p> 
+ * The oval covers an area that is <code>width + 1</code> 
+ * pixels wide and <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper left corner of the oval to be drawn
+ * @param y the y coordinate of the upper left corner of the oval to be drawn
+ * @param width the width of the oval to be drawn
+ * @param height the height of the oval to be drawn
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawOval(int x, int y, int width, int height) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    if (width < 0) {
+        x = x + width;
+        width = -width;
+    }
+    if (height < 0) {
+        y = y + height;
+        height = -height;
+    }
+    NSBezierPath path = data.path;
+    NSRect rect = new NSRect();
+    rect.x = x + data.drawXOffset;
+    rect.y = y + data.drawXOffset;
+    rect.width = width;
+    rect.height = height;
+    path.appendBezierPathWithOvalInRect(rect);
+    path.stroke();
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws the path described by the parameter.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param path the path to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Path
+ * 
+ * @since 3.1
+ */
+public void drawPath(Path path) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    handle.saveGraphicsState();
+    NSAffineTransform transform = NSAffineTransform.transform();
+    transform.translateXBy(data.drawXOffset, data.drawYOffset);
+    transform.concat();
+    NSBezierPath drawPath = data.path;
+    drawPath.appendBezierPath(path.handle);
+    drawPath.stroke();
+    drawPath.removeAllPoints();
+    handle.restoreGraphicsState();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws a pixel, using the foreground color, at the specified
+ * point (<code>x</code>, <code>y</code>).
+ * <p>
+ * Note that the receiver's line attributes do not affect this
+ * operation.
+ * </p>
+ *
+ * @param x the point's x coordinate
+ * @param y the point's y coordinate
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *  
+ * @since 3.0
+ */
+public void drawPoint(int x, int y) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(FOREGROUND_FILL);
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = 1;
+    rect.height = 1;
+    NSBezierPath path = data.path;
+    path.appendBezierPathWithRect(rect);
+    path.fill();
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws the closed polygon which is defined by the specified array
+ * of integer coordinates, using the receiver's foreground color. The array 
+ * contains alternating x and y values which are considered to represent
+ * points which are the vertices of the polygon. Lines are drawn between
+ * each consecutive pair, and between the first pair and last pair in the
+ * array.
+ *
+ * @param pointArray an array of alternating x and y values which are the vertices of the polygon
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawPolygon(int[] pointArray) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    if (pointArray.length < 4) return;
+    float xOffset = data.drawXOffset, yOffset = data.drawYOffset;
+    NSBezierPath path = data.path;
+    NSPoint pt = new NSPoint();
+    pt.x = pointArray[0] + xOffset;
+    pt.y = pointArray[1] + yOffset;
+    path.moveToPoint(pt);
+    int end = pointArray.length / 2 * 2;
+    for (int i = 2; i < end; i+=2) {
+        pt.x = pointArray[i] + xOffset;
+        pt.y = pointArray[i+1] + yOffset;
+        path.lineToPoint(pt);
+    }
+    path.closePath();
+    path.stroke();
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws the polyline which is defined by the specified array
+ * of integer coordinates, using the receiver's foreground color. The array 
+ * contains alternating x and y values which are considered to represent
+ * points which are the corners of the polyline. Lines are drawn between
+ * each consecutive pair, but not between the first pair and last pair in
+ * the array.
+ *
+ * @param pointArray an array of alternating x and y values which are the corners of the polyline
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawPolyline(int[] pointArray) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    if (pointArray.length < 4) return;
+    float xOffset = data.drawXOffset, yOffset = data.drawYOffset;
+    NSBezierPath path = data.path;
+    NSPoint pt = new NSPoint();
+    pt.x = pointArray[0] + xOffset;
+    pt.y = pointArray[1] + yOffset;
+    path.moveToPoint(pt);
+    int end = pointArray.length / 2 * 2;
+    for (int i = 2; i < end; i+=2) {
+        pt.x = pointArray[i] + xOffset;
+        pt.y = pointArray[i+1] + yOffset;
+        path.lineToPoint(pt);
+    }
+    path.stroke();
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws the outline of the rectangle specified by the arguments,
+ * using the receiver's foreground color. The left and right edges
+ * of the rectangle are at <code>x</code> and <code>x + width</code>. 
+ * The top and bottom edges are at <code>y</code> and <code>y + height</code>. 
+ *
+ * @param x the x coordinate of the rectangle to be drawn
+ * @param y the y coordinate of the rectangle to be drawn
+ * @param width the width of the rectangle to be drawn
+ * @param height the height of the rectangle to be drawn
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRectangle(int x, int y, int width, int height) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    if (width < 0) {
+        x = x + width;
+        width = -width;
+    }
+    if (height < 0) {
+        y = y + height;
+        height = -height;
+    }
+    NSRect rect = new NSRect();
+    rect.x = x + data.drawXOffset;
+    rect.y = y + data.drawYOffset;
+    rect.width = width;
+    rect.height = height;
+    NSBezierPath path = data.path;
+    path.appendBezierPathWithRect(rect);
+    path.stroke();
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws the outline of the specified rectangle, using the receiver's
+ * foreground color. The left and right edges of the rectangle are at
+ * <code>rect.x</code> and <code>rect.x + rect.width</code>. The top 
+ * and bottom edges are at <code>rect.y</code> and 
+ * <code>rect.y + rect.height</code>. 
+ *
+ * @param rect the rectangle to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRectangle(Rectangle rect) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    drawRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
+/** 
+ * Draws the outline of the round-cornered rectangle specified by 
+ * the arguments, using the receiver's foreground color. The left and
+ * right edges of the rectangle are at <code>x</code> and <code>x + width</code>. 
+ * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
+ * The <em>roundness</em> of the corners is specified by the 
+ * <code>arcWidth</code> and <code>arcHeight</code> arguments, which
+ * are respectively the width and height of the ellipse used to draw
+ * the corners.
+ *
+ * @param x the x coordinate of the rectangle to be drawn
+ * @param y the y coordinate of the rectangle to be drawn
+ * @param width the width of the rectangle to be drawn
+ * @param height the height of the rectangle to be drawn
+ * @param arcWidth the width of the arc
+ * @param arcHeight the height of the arc
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(DRAW);
+    if (arcWidth is 0 || arcHeight is 0) {
+        drawRectangle(x, y, width, height);
+        NSGraphicsContext.setCurrentContext(context);
+        return;
+    }
+    NSBezierPath path = data.path;
+    NSRect rect = new NSRect();
+    rect.x = x + data.drawXOffset;
+    rect.y = y + data.drawYOffset;
+    rect.width = width;
+    rect.height = height;
+    path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
+    path.stroke();
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. No tab expansion or carriage return processing
+ * will be performed. The background of the rectangular area where
+ * the string is being drawn will be filled with the receiver's
+ * background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawString (String string, int x, int y) {
+    drawString(string, x, y, false);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. No tab expansion or carriage return processing
+ * will be performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the string is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawString(String string, int x, int y, bool isTransparent) {
+    drawText(string, x, y, isTransparent ? DWT.DRAW_TRANSPARENT : 0);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. The background of the rectangular area where
+ * the text is being drawn will be filled with the receiver's
+ * background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText(String string, int x, int y) {
+    drawText(string, x, y, DWT.DRAW_DELIMITER | DWT.DRAW_TAB);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText(String string, int x, int y, bool isTransparent) {
+    int flags = DWT.DRAW_DELIMITER | DWT.DRAW_TAB;
+    if (isTransparent) flags |= DWT.DRAW_TRANSPARENT;
+    drawText(string, x, y, flags);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion, line delimiter and mnemonic
+ * processing are performed according to the specified flags. If
+ * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ * <p>
+ * The parameter <code>flags</code> may be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * </p>
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param flags the flags specifying how to process the text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText (String string, int x, int y, int flags) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(CLIPPING | TRANSFORM | FONT | FOREGROUND_FILL);
+    NSAttributedString str = createString(string, flags);
+    if (data.paintRect is null) {
+        handle.saveGraphicsState();
+        NSAffineTransform transform = NSAffineTransform.transform();
+        transform.scaleXBy(1, -1);
+        transform.translateXBy(0, -(str.size().height + 2 * y));
+        transform.concat();
+    }
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    str.drawAtPoint(pt);
+    str.release();
+    if (data.paintRect is null) {
+        handle.restoreGraphicsState();
+    }
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals(Object object) {
+    if (object is this) return true;
+    if (!(object instanceof GC)) return false;
+    return handle is ((GC)object).handle;
+}
+
+/**
+ * Fills the interior of a circular or elliptical arc within
+ * the specified rectangular area, with the receiver's background
+ * color.
+ * <p>
+ * The resulting arc begins at <code>startAngle</code> and extends  
+ * for <code>arcAngle</code> degrees, using the current color.
+ * Angles are interpreted such that 0 degrees is at the 3 o'clock
+ * position. A positive value indicates a counter-clockwise rotation
+ * while a negative value indicates a clockwise rotation.
+ * </p><p>
+ * The center of the arc is the center of the rectangle whose origin 
+ * is (<code>x</code>, <code>y</code>) and whose size is specified by the 
+ * <code>width</code> and <code>height</code> arguments. 
+ * </p><p>
+ * The resulting arc covers an area <code>width + 1</code> pixels wide
+ * by <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper-left corner of the arc to be filled
+ * @param y the y coordinate of the upper-left corner of the arc to be filled
+ * @param width the width of the arc to be filled
+ * @param height the height of the arc to be filled
+ * @param startAngle the beginning angle
+ * @param arcAngle the angular extent of the arc, relative to the start angle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawArc
+ */
+public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(FILL);
+    if (width < 0) {
+        x = x + width;
+        width = -width;
+    }
+    if (height < 0) {
+        y = y + height;
+        height = -height;
+    }
+    if (width is 0 || height is 0 || arcAngle is 0) return;
+    handle.saveGraphicsState();
+    NSAffineTransform transform = NSAffineTransform.transform();
+    float xOffset = data.drawXOffset, yOffset = data.drawYOffset;
+    transform.translateXBy(x + xOffset + width / 2f, y + yOffset + height / 2f);
+    transform.scaleXBy(width / 2f, height / 2f);
+    NSBezierPath path = data.path;
+    NSPoint center = new NSPoint();
+    path.moveToPoint(center);
+    float sAngle = -startAngle;
+    float eAngle = -(startAngle + arcAngle);
+    path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_(center, 1, sAngle,  eAngle, arcAngle>0);
+    path.closePath();
+    path.transformUsingAffineTransform(transform);
+    path.fill();
+    path.removeAllPoints();
+    handle.restoreGraphicsState();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/**
+ * Fills the interior of the specified rectangle with a gradient
+ * sweeping from left to right or top to bottom progressing
+ * from the receiver's foreground color to its background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled, may be negative
+ *        (inverts direction of gradient if horizontal)
+ * @param height the height of the rectangle to be filled, may be negative
+ *        (inverts direction of gradient if vertical)
+ * @param vertical if true sweeps from top to bottom, else 
+ *        sweeps from left to right
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void fillGradientRectangle(int x, int y, int width, int height, bool vertical) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(CLIPPING | TRANSFORM);
+    if ((width is 0) || (height is 0)) return;
+
+    RGB backgroundRGB, foregroundRGB;
+    backgroundRGB = getBackground().getRGB();
+    foregroundRGB = getForeground().getRGB();
+
+    RGB fromRGB, toRGB;
+    fromRGB = foregroundRGB;
+    toRGB   = backgroundRGB;
+    bool swapColors = false;
+    if (width < 0) {
+        x += width; width = -width;
+        if (! vertical) swapColors = true;
+    }
+    if (height < 0) {
+        y += height; height = -height;
+        if (vertical) swapColors = true;
+    }
+    if (swapColors) {
+        fromRGB = backgroundRGB;
+        toRGB   = foregroundRGB;
+    }
+    if (fromRGB.equals(toRGB)) {
+        fillRectangle(x, y, width, height);
+    } else {
+        NSColor startingColor = NSColor.colorWithDeviceRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f);
+        NSColor endingColor = NSColor.colorWithDeviceRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f);
+        NSGradient gradient = ((NSGradient)new NSGradient().alloc()).initWithStartingColor(startingColor, endingColor);
+        NSRect rect = new NSRect();
+        rect.x = x;
+        rect.y = y;
+        rect.width = width;
+        rect.height = height;
+        gradient.drawInRect_angle_(rect, vertical ? 90 : 0);
+        gradient.release();
+    }
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Fills the interior of an oval, within the specified
+ * rectangular area, with the receiver's background
+ * color.
+ *
+ * @param x the x coordinate of the upper left corner of the oval to be filled
+ * @param y the y coordinate of the upper left corner of the oval to be filled
+ * @param width the width of the oval to be filled
+ * @param height the height of the oval to be filled
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawOval
+ */
+public void fillOval(int x, int y, int width, int height) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(FILL);
+    if (width < 0) {
+        x = x + width;
+        width = -width;
+    }
+    if (height < 0) {
+        y = y + height;
+        height = -height;
+    }
+    NSBezierPath path = data.path;
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
+    path.appendBezierPathWithOvalInRect(rect);
+    Pattern pattern = data.backgroundPattern;
+    if (pattern !is null && pattern.gradient !is null) {
+        fillPattern(path, pattern);
+    } else {
+        path.fill();
+    }
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+void fillPattern(NSBezierPath path, Pattern pattern) {
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    path.addClip();
+    pattern.gradient.drawFromPoint(pattern.pt1, pattern.pt2, OS.NSGradientDrawsAfterEndingLocation | OS.NSGradientDrawsBeforeStartingLocation);
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Fills the path described by the parameter.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ *
+ * @param path the path to fill
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Path
+ * 
+ * @since 3.1
+ */
+public void fillPath(Path path) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(FILL);
+    NSBezierPath drawPath = data.path;
+    drawPath.appendBezierPath(path.handle);
+    Pattern pattern = data.backgroundPattern;
+    if (pattern !is null && pattern.gradient !is null) {
+        fillPattern(drawPath, pattern);
+    } else {
+        drawPath.fill();
+    }
+    drawPath.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Fills the interior of the closed polygon which is defined by the
+ * specified array of integer coordinates, using the receiver's
+ * background color. The array contains alternating x and y values
+ * which are considered to represent points which are the vertices of
+ * the polygon. Lines are drawn between each consecutive pair, and
+ * between the first pair and last pair in the array.
+ *
+ * @param pointArray an array of alternating x and y values which are the vertices of the polygon
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawPolygon    
+ */
+public void fillPolygon(int[] pointArray) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(FILL);
+    if (pointArray.length < 4) return;
+    NSBezierPath path = data.path;
+    NSPoint pt = new NSPoint();
+    pt.x = pointArray[0];
+    pt.y = pointArray[1];
+    path.moveToPoint(pt);
+    int end = pointArray.length / 2 * 2;
+    for (int i = 2; i < end; i+=2) {
+        pt.x = pointArray[i];
+        pt.y = pointArray[i+1];
+        path.lineToPoint(pt);
+    }
+    path.closePath();
+    Pattern pattern = data.backgroundPattern;
+    if (pattern !is null && pattern.gradient !is null) {
+        fillPattern(path, pattern);
+    } else {
+        path.fill();
+    }
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Fills the interior of the rectangle specified by the arguments,
+ * using the receiver's background color. 
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled
+ * @param height the height of the rectangle to be filled
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void fillRectangle(int x, int y, int width, int height) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(FILL);
+    if (width < 0) {
+        x = x + width;
+        width = -width;
+    }
+    if (height < 0) {
+        y = y + height;
+        height = -height;
+    }
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
+    NSBezierPath path = data.path;
+    path.appendBezierPathWithRect(rect);
+    Pattern pattern = data.backgroundPattern;
+    if (pattern !is null && pattern.gradient !is null) {
+        fillPattern(path, pattern);
+    } else {
+        path.fill();
+    }
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+/** 
+ * Fills the interior of the specified rectangle, using the receiver's
+ * background color. 
+ *
+ * @param rect the rectangle to be filled
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void fillRectangle(Rectangle rect) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    fillRectangle(rect.x, rect.y, rect.width, rect.height);
+}
+
+/** 
+ * Fills the interior of the round-cornered rectangle specified by 
+ * the arguments, using the receiver's background color. 
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled
+ * @param height the height of the rectangle to be filled
+ * @param arcWidth the width of the arc
+ * @param arcHeight the height of the arc
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRoundRectangle
+ */
+public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSGraphicsContext context = NSGraphicsContext.currentContext();
+    NSGraphicsContext.setCurrentContext(handle);
+    checkGC(FILL);
+    if (arcWidth is 0 || arcHeight is 0) {
+        fillRectangle(x, y, width, height);
+        return;
+    }
+    NSBezierPath path = data.path;
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
+    path.appendBezierPathWithRoundedRect(rect, arcWidth, arcHeight);
+    Pattern pattern = data.backgroundPattern;
+    if (pattern !is null && pattern.gradient !is null) {
+        fillPattern(path, pattern);
+    } else {
+        path.fill();
+    }
+    path.removeAllPoints();
+    NSGraphicsContext.setCurrentContext(context);
+}
+
+void flush () {
+}
+
+/**
+ * Returns the <em>advance width</em> of the specified character in
+ * the font which is currently selected into the receiver.
+ * <p>
+ * The advance width is defined as the horizontal distance the cursor
+ * should move after printing the character in the selected font.
+ * </p>
+ *
+ * @param ch the character to measure
+ * @return the distance in the x direction to move past the character before painting the next
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getAdvanceWidth(char ch) {   
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    //NOT DONE
+    return stringExtent(new String(new char[]{ch})).x;
+}
+
+/** 
+ * Returns the background color.
+ *
+ * @return the receiver's background color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getBackground() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return Color.cocoa_new (data.device, data.background);
+}
+
+/** 
+ * Returns the background pattern. The default value is
+ * <code>null</code>.
+ *
+ * @return the receiver's background pattern
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * 
+ * @since 3.1
+ */
+public Pattern getBackgroundPattern() { 
+    if (handle is null) DWT.error(DWT.ERROR_WIDGET_DISPOSED);
+    return data.backgroundPattern;  
+}
+
+/**
+ * Returns <code>true</code> if receiver is using the operating system's
+ * advanced graphics subsystem.  Otherwise, <code>false</code> is returned
+ * to indicate that normal graphics are in use.
+ * <p>
+ * Advanced graphics may not be installed for the operating system.  In this
+ * case, <code>false</code> is always returned.  Some operating system have
+ * only one graphics subsystem.  If this subsystem supports advanced graphics,
+ * then <code>true</code> is always returned.  If any graphics operation such
+ * as alpha, antialias, patterns, interpolation, paths, clipping or transformation
+ * has caused the receiver to switch from regular to advanced graphics mode,
+ * <code>true</code> is returned.  If the receiver has been explicitly switched
+ * to advanced mode and this mode is supported, <code>true</code> is returned.
+ * </p>
+ *
+ * @return the advanced value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public bool getAdvanced() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return true;
+}
+
+/**
+ * Returns the receiver's alpha value.
+ *
+ * @return the alpha value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getAlpha() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.alpha;
+}
+
+/**
+ * Returns the receiver's anti-aliasing setting value, which will be
+ * one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code> or
+ * <code>DWT.ON</code>. Note that this controls anti-aliasing for all
+ * <em>non-text drawing</em> operations.
+ *
+ * @return the anti-aliasing setting
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getTextAntialias
+ * 
+ * @since 3.1
+ */
+public int getAntialias() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.antialias;
+}
+
+/**
+ * Returns the width of the specified character in the font
+ * selected into the receiver. 
+ * <p>
+ * The width is defined as the space taken up by the actual
+ * character, not including the leading and tailing whitespace
+ * or overhang.
+ * </p>
+ *
+ * @param ch the character to measure
+ * @return the width of the character
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getCharWidth(char ch) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    //NOT DONE
+    return stringExtent(new String(new char[]{ch})).x;
+}
+
+/** 
+ * Returns the bounding rectangle of the receiver's clipping
+ * region. If no clipping region is set, the return value
+ * will be a rectangle which covers the entire bounds of the
+ * object the receiver is drawing on.
+ *
+ * @return the bounding rectangle of the clipping region
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getClipping() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSRect rect = null;
+    if (data.view !is null) {
+        rect = data.view.bounds();
+    } else {
+        rect = new NSRect();
+        if (data.image !is null) {
+            NSSize size = data.image.handle.size();
+            rect.width = size.width;
+            rect.height = size.height;
+        } else if (data.size !is null) {
+            rect.width = data.size.width;
+            rect.height = data.size.height;
+        }
+    }
+    if (data.paintRect !is null || data.clipPath !is null || data.inverseTransform !is null) {
+        if (data.paintRect !is null) {
+            OS.NSIntersectionRect(rect, rect, data.paintRect);
+        }
+        if (data.clipPath !is null) {
+            NSRect clip = data.clipPath.bounds();
+            OS.NSIntersectionRect(rect, rect, clip);
+        }
+        if (data.inverseTransform !is null && rect.width > 0 && rect.height > 0) {
+            NSPoint pt = new NSPoint();
+            pt.x = rect.x;
+            pt.y = rect.y;
+            NSSize size = new NSSize();
+            size.width = rect.width;
+            size.height = rect.height;
+            pt = data.inverseTransform.transformPoint(pt);
+            size =  data.inverseTransform.transformSize(size);
+            rect.x = pt.x;
+            rect.y = pt.y;
+            rect.width = size.width;
+            rect.height = size.height;
+        }
+    }
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/** 
+ * Sets the region managed by the argument to the current
+ * clipping region of the receiver.
+ *
+ * @param region the region to fill with the clipping region
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the region is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the region is disposed</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void getClipping(Region region) {    
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (region is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    region.subtract(region);
+    NSRect rect = null;
+    if (data.view !is null) {
+        rect = data.view.bounds();
+    } else {
+        rect = new NSRect();
+        if (data.image !is null) {
+            NSSize size = data.image.handle.size();
+            rect.width = size.width;
+            rect.height = size.height;
+        } else if (data.size !is null) {
+            rect.width = data.size.width;
+            rect.height = data.size.height;
+        }
+    }
+    region.add((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+    NSRect paintRect = data.paintRect;
+    if (paintRect !is null) {
+        region.intersect((int)paintRect.x, (int)paintRect.y, (int)paintRect.width, (int)paintRect.height);
+    }
+    if (data.clipPath !is null) {
+        NSBezierPath clip = data.clipPath.bezierPathByFlatteningPath();
+        int count = clip.elementCount();
+        int pointCount = 0;
+        Region clipRgn = new Region(device);
+        int[] pointArray = new int[count * 2];
+        int points = OS.malloc(NSPoint.sizeof);
+        if (points is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        NSPoint pt = new NSPoint();
+        for (int i = 0; i < count; i++) {
+            int element = clip.elementAtIndex_associatedPoints_(i, points);
+            switch (element) {
+                case OS.NSMoveToBezierPathElement:
+                    if (pointCount !is 0) clipRgn.add(pointArray, pointCount);
+                    pointCount = 0;
+                    OS.memmove(pt, points, NSPoint.sizeof);
+                    pointArray[pointCount++] = (int)pt.x;
+                    pointArray[pointCount++] = (int)pt.y;
+                    break;
+                case OS.NSLineToBezierPathElement:
+                    OS.memmove(pt, points, NSPoint.sizeof);
+                    pointArray[pointCount++] = (int)pt.x;
+                    pointArray[pointCount++] = (int)pt.y;
+                    break;
+                case OS.NSClosePathBezierPathElement:
+                    if (pointCount !is 0) clipRgn.add(pointArray, pointCount);
+                    pointCount = 0;
+                    break;
+            }
+        }
+        if (pointCount !is 0) clipRgn.add(pointArray, pointCount);
+        OS.free(points);
+        region.intersect(clipRgn);
+        clipRgn.dispose();
+    }
+    if (data.inverseTransform !is null) {
+        region.convertRgn(data.inverseTransform);
+    }
+}
+
+/** 
+ * Returns the receiver's fill rule, which will be one of
+ * <code>DWT.FILL_EVEN_ODD</code> or <code>DWT.FILL_WINDING</code>.
+ *
+ * @return the receiver's fill rule
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getFillRule() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.fillRule;
+}
+
+/** 
+ * Returns the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getFont() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.font;
+}
+
+/**
+ * Returns a FontMetrics which contains information
+ * about the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return font metrics for the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontMetrics getFontMetrics() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    checkGC(FONT);
+    NSFont font = data.font.handle;
+    int ascent = (int)(0.5f + font.ascender());
+    int descent = (int)(0.5f + (-font.descender() + font.leading()));   
+    String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
+    int averageCharWidth = stringExtent(s).x / s.length();
+    return FontMetrics.cocoa_new(ascent, descent, averageCharWidth, 0, ascent + descent);
+}
+
+/** 
+ * Returns the receiver's foreground color.
+ *
+ * @return the color used for drawing foreground things
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getForeground() {  
+    if (handle is null) DWT.error(DWT.ERROR_WIDGET_DISPOSED);
+    return Color.cocoa_new(data.device, data.foreground);   
+}
+
+/** 
+ * Returns the foreground pattern. The default value is
+ * <code>null</code>.
+ *
+ * @return the receiver's foreground pattern
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * 
+ * @since 3.1
+ */
+public Pattern getForegroundPattern() { 
+    if (handle is null) DWT.error(DWT.ERROR_WIDGET_DISPOSED);
+    return data.foregroundPattern;  
+}
+
+/** 
+ * Returns the GCData.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>GC</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @return the receiver's GCData
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see GCData
+ * 
+ * @since 3.2
+ */
+public GCData getGCData() { 
+    if (handle is null) DWT.error(DWT.ERROR_WIDGET_DISPOSED);
+    return data;    
+}
+
+/** 
+ * Returns the receiver's interpolation setting, which will be one of
+ * <code>DWT.DEFAULT</code>, <code>DWT.NONE</code>, 
+ * <code>DWT.LOW</code> or <code>DWT.HIGH</code>.
+ *
+ * @return the receiver's interpolation setting
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getInterpolation() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    int interpolation = handle.imageInterpolation();
+    switch (interpolation) {
+        case OS.NSImageInterpolationDefault: return DWT.DEFAULT;
+        case OS.NSImageInterpolationNone: return DWT.NONE;
+        case OS.NSImageInterpolationLow: return DWT.LOW;
+        case OS.NSImageInterpolationHigh: return DWT.HIGH;
+    }
+    return DWT.DEFAULT;
+}
+
+/** 
+ * Returns the receiver's line attributes.
+ *
+ * @return the line attributes used for drawing lines
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.3 
+ */
+public LineAttributes getLineAttributes() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    float[] dashes = null;
+    if (data.lineDashes !is null) {
+        dashes = new float[data.lineDashes.length];
+        System.arraycopy(data.lineDashes, 0, dashes, 0, dashes.length);
+    }
+    return new LineAttributes(data.lineWidth, data.lineCap, data.lineJoin, data.lineStyle, dashes, data.lineDashesOffset, data.lineMiterLimit);
+}
+
+/** 
+ * Returns the receiver's line cap style, which will be one
+ * of the constants <code>DWT.CAP_FLAT</code>, <code>DWT.CAP_ROUND</code>,
+ * or <code>DWT.CAP_SQUARE</code>.
+ *
+ * @return the cap style used for drawing lines
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int getLineCap() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.lineCap;
+}
+
+/** 
+ * Returns the receiver's line dash style. The default value is
+ * <code>null</code>.
+ *
+ * @return the line dash style used for drawing lines
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int[] getLineDash() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.lineDashes is null) return null;
+    int[] lineDashes = new int[data.lineDashes.length];
+    for (int i = 0; i < lineDashes.length; i++) {
+        lineDashes[i] = (int)data.lineDashes[i];
+    }
+    return lineDashes;  
+}
+
+/** 
+ * Returns the receiver's line join style, which will be one
+ * of the constants <code>DWT.JOIN_MITER</code>, <code>DWT.JOIN_ROUND</code>,
+ * or <code>DWT.JOIN_BEVEL</code>.
+ *
+ * @return the join style used for drawing lines
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int getLineJoin() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.lineJoin;
+}
+
+/** 
+ * Returns the receiver's line style, which will be one
+ * of the constants <code>DWT.LINE_SOLID</code>, <code>DWT.LINE_DASH</code>,
+ * <code>DWT.LINE_DOT</code>, <code>DWT.LINE_DASHDOT</code> or
+ * <code>DWT.LINE_DASHDOTDOT</code>.
+ *
+ * @return the style used for drawing lines
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineStyle() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.lineStyle;
+}
+
+/** 
+ * Returns the width that will be used when drawing lines
+ * for all of the figure drawing operations (that is,
+ * <code>drawLine</code>, <code>drawRectangle</code>, 
+ * <code>drawPolyline</code>, and so forth.
+ *
+ * @return the receiver's line width 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineWidth() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return (int)data.lineWidth;
+}
+
+/**
+ * Returns the receiver's style information.
+ * <p>
+ * Note that the value which is returned by this method <em>may
+ * not match</em> the value which was provided to the constructor
+ * when the receiver was created. This can occur when the underlying
+ * operating system does not support a particular combination of
+ * requested styles. 
+ * </p>
+ *
+ * @return the style bits
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *   
+ * @since 2.1.2
+ */
+public int getStyle () {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.style;
+}
+
+/**
+ * Returns the receiver's text drawing anti-aliasing setting value,
+ * which will be one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code> or
+ * <code>DWT.ON</code>. Note that this controls anti-aliasing
+ * <em>only</em> for text drawing operations.
+ *
+ * @return the anti-aliasing setting
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getAntialias
+ * 
+ * @since 3.1
+ */
+public int getTextAntialias() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.textAntialias;
+}
+
+/** 
+ * Sets the parameter to the transform that is currently being
+ * used by the receiver.
+ *
+ * @param transform the destination to copy the transform into
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Transform
+ * 
+ * @since 3.1
+ */
+public void getTransform (Transform transform) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (transform is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    NSAffineTransform cmt = data.transform;
+    if (cmt !is null) {
+        NSAffineTransformStruct struct = cmt.transformStruct();
+        transform.handle.setTransformStruct(struct);
+    } else {
+        transform.setElements(1, 0, 0, 1, 0, 0);
+    }
+}
+
+/** 
+ * Returns <code>true</code> if this GC is drawing in the mode
+ * where the resulting color in the destination is the
+ * <em>exclusive or</em> of the color values in the source
+ * and the destination, and <code>false</code> if it is
+ * drawing in the mode where the destination color is being
+ * replaced with the source color value.
+ *
+ * @return <code>true</code> true if the receiver is in XOR mode, and false otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public bool getXORMode() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.xorMode;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #equals
+ */
+public int hashCode() {
+    return handle !is null ? handle.id : 0;
+}
+
+void init(Drawable drawable, GCData data, int context) {
+    if (data.foreground !is null) data.state &= ~(FOREGROUND | FOREGROUND_FILL);
+    if (data.background !is null)  data.state &= ~BACKGROUND;
+    if (data.font !is null) data.state &= ~FONT;
+    data.state &= ~DRAW_OFFSET;
+
+    Image image = data.image;
+    if (image !is null) image.memGC = this;
+    this.drawable = drawable;
+    this.data = data;
+    handle = new NSGraphicsContext(context);
+    handle.retain();
+    handle.saveGraphicsState();
+    data.path = NSBezierPath.bezierPath();
+    data.path.setWindingRule(data.fillRule is DWT.FILL_WINDING ? OS.NSNonZeroWindingRule : OS.NSEvenOddWindingRule);
+    data.path.retain();
+}
+
+/**
+ * Returns <code>true</code> if the receiver has a clipping
+ * region set into it, and <code>false</code> otherwise.
+ * If this method returns false, the receiver will draw on all
+ * available space in the destination. If it returns true, 
+ * it will draw only in the area that is covered by the region
+ * that can be accessed with <code>getClipping(region)</code>.
+ *
+ * @return <code>true</code> if the GC has a clipping region, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public bool isClipped() {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.clipPath !is null;
+}
+
+/**
+ * Returns <code>true</code> if the GC has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the GC.
+ * When a GC has been disposed, it is an error to
+ * invoke any other method using the GC.
+ *
+ * @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+bool isIdentity(float[] transform) {
+    return transform[0] is 1 && transform[1] is 0 && transform[2] is 0
+        && transform[3] is 1 && transform[4] is 0 && transform[5] is 0;
+}
+
+/**
+ * Sets the receiver to always use the operating system's advanced graphics
+ * subsystem for all graphics operations if the argument is <code>true</code>.
+ * If the argument is <code>false</code>, the advanced graphics subsystem is 
+ * no longer used, advanced graphics state is cleared and the normal graphics
+ * subsystem is used from now on.
+ * <p>
+ * Normally, the advanced graphics subsystem is invoked automatically when
+ * any one of the alpha, antialias, patterns, interpolation, paths, clipping
+ * or transformation operations in the receiver is requested.  When the receiver
+ * is switched into advanced mode, the advanced graphics subsystem performs both
+ * advanced and normal graphics operations.  Because the two subsystems are
+ * different, their output may differ.  Switching to advanced graphics before
+ * any graphics operations are performed ensures that the output is consistent.
+ * </p><p>
+ * Advanced graphics may not be installed for the operating system.  In this
+ * case, this operation does nothing.  Some operating system have only one
+ * graphics subsystem, so switching from normal to advanced graphics does
+ * nothing.  However, switching from advanced to normal graphics will always
+ * clear the advanced graphics state, even for operating systems that have
+ * only one graphics subsystem.
+ * </p>
+ *
+ * @param advanced the new advanced graphics state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAlpha
+ * @see #setAntialias
+ * @see #setBackgroundPattern
+ * @see #setClipping(Path)
+ * @see #setForegroundPattern
+ * @see #setLineAttributes
+ * @see #setInterpolation
+ * @see #setTextAntialias
+ * @see #setTransform
+ * @see #getAdvanced
+ * 
+ * @since 3.1
+ */
+public void setAdvanced(bool advanced) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (!advanced) {
+        setAlpha(0xFF);
+        setAntialias(DWT.DEFAULT);
+        setBackgroundPattern(null);
+        setClipping((Rectangle)null);
+        setForegroundPattern(null);
+        setInterpolation(DWT.DEFAULT);
+        setTextAntialias(DWT.DEFAULT);
+        setTransform(null);
+    }
+}
+
+/**
+ * Sets the receiver's alpha value.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * @param alpha the alpha value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setAlpha(int alpha) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    data.alpha = alpha & 0xFF;
+    data.state &= ~(BACKGROUND | FOREGROUND | FOREGROUND_FILL);
+    
+}
+
+/**
+ * Sets the receiver's anti-aliasing value to the parameter, 
+ * which must be one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code>
+ * or <code>DWT.ON</code>. Note that this controls anti-aliasing for all
+ * <em>non-text drawing</em> operations.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ *
+ * @param antialias the anti-aliasing setting
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>DWT.DEFAULT</code>,
+ *                                 <code>DWT.OFF</code> or <code>DWT.ON</code></li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * @see #setTextAntialias
+ * 
+ * @since 3.1
+ */
+public void setAntialias(int antialias) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    bool mode = true;
+    switch (antialias) {
+        case DWT.DEFAULT:
+            /* Printer is off by default */
+//          if (data.window is 0 && data.control is 0 && data.image is null) mode = false;
+            mode = true;
+            break;
+        case DWT.OFF: mode = false; break;
+        case DWT.ON: mode = true; break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    data.antialias = antialias;
+    handle.setShouldAntialias(mode);
+}
+
+/**
+ * Sets the background color. The background color is used
+ * for fill operations and as the background color when text
+ * is drawn.
+ *
+ * @param color the new background color for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setBackground(Color color) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (color is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    data.background = color.handle;
+    data.backgroundPattern = null;
+    data.state &= ~BACKGROUND;
+}
+
+/** 
+ * Sets the background pattern. The default value is <code>null</code>.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param pattern the new background pattern
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setBackgroundPattern(Pattern pattern) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (data.backgroundPattern is pattern) return;
+    data.backgroundPattern = pattern;
+    data.state &= ~BACKGROUND;
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the rectangular area specified
+ * by the arguments.
+ *
+ * @param x the x coordinate of the clipping rectangle
+ * @param y the y coordinate of the clipping rectangle
+ * @param width the width of the clipping rectangle
+ * @param height the height of the clipping rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping(int x, int y, int width, int height) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (width < 0) {
+        x = x + width;
+        width = -width;
+    }
+    if (height < 0) {
+        y = y + height;
+        height = -height;
+    }
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
+    NSBezierPath path = NSBezierPath.bezierPathWithRect(rect);
+    path.retain();
+    setClipping(path);
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the path specified
+ * by the argument.  
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param path the clipping path.
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the path has been disposed</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Path
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setClipping(Path path) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (path !is null && path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    setClipping(new NSBezierPath(path.handle.copy().id));
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the rectangular area specified
+ * by the argument.  Specifying <code>null</code> for the
+ * rectangle reverts the receiver's clipping area to its
+ * original value.
+ *
+ * @param rect the clipping rectangle or <code>null</code>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping(Rectangle rect) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (rect is null) {
+        setClipping((NSBezierPath)null);
+    } else {
+        setClipping(rect.x, rect.y, rect.width, rect.height);
+    }
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the region specified
+ * by the argument.  Specifying <code>null</code> for the
+ * region reverts the receiver's clipping area to its
+ * original value.
+ *
+ * @param region the clipping region or <code>null</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping(Region region) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (region !is null && region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    setClipping(region !is null ? region.getPath() : null);
+}
+
+void setClipping(NSBezierPath path) {
+    if (data.clipPath !is null) {
+        data.clipPath.release();
+        data.clipPath = null;
+    }
+    if (path !is null) {
+        data.clipPath = path;
+        if (data.transform !is null) {
+            data.clipPath.transformUsingAffineTransform(data.transform);
+        }
+    }
+    data.state &= ~CLIPPING;
+}
+
+/** 
+ * Sets the receiver's fill rule to the parameter, which must be one of
+ * <code>DWT.FILL_EVEN_ODD</code> or <code>DWT.FILL_WINDING</code>.
+ *
+ * @param rule the new fill rule
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>DWT.FILL_EVEN_ODD</code>
+ *                                 or <code>DWT.FILL_WINDING</code></li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setFillRule(int rule) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    switch (rule) {
+        case DWT.FILL_WINDING:
+        case DWT.FILL_EVEN_ODD: break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    data.fillRule = rule;
+    data.path.setWindingRule(rule is DWT.FILL_WINDING ? OS.NSNonZeroWindingRule : OS.NSEvenOddWindingRule);
+}
+
+/** 
+ * Sets the font which will be used by the receiver
+ * to draw and measure text to the argument. If the
+ * argument is null, then a default font appropriate
+ * for the platform will be used instead.
+ *
+ * @param font the new font for the receiver, or null to indicate a default font
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setFont(Font font) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (font !is null && font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    data.font = font !is null ? font : data.device.systemFont;
+    data.state &= ~FONT;
+}
+
+/**
+ * Sets the foreground color. The foreground color is used
+ * for drawing operations including when text is drawn.
+ *
+ * @param color the new foreground color for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setForeground(Color color) {    
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (color is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    data.foreground = color.handle;
+    data.foregroundPattern = null;
+    data.state &= ~(FOREGROUND | FOREGROUND_FILL);
+}
+
+/** 
+ * Sets the foreground pattern. The default value is <code>null</code>.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * @param pattern the new foreground pattern
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setForegroundPattern(Pattern pattern) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (data.foregroundPattern is pattern) return;
+    data.foregroundPattern = pattern;
+    data.state &= ~(FOREGROUND | FOREGROUND_FILL);
+}
+
+/** 
+ * Sets the receiver's interpolation setting to the parameter, which
+ * must be one of <code>DWT.DEFAULT</code>, <code>DWT.NONE</code>, 
+ * <code>DWT.LOW</code> or <code>DWT.HIGH</code>.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param interpolation the new interpolation setting
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>DWT.DEFAULT</code>, 
+ *                                 <code>DWT.NONE</code>, <code>DWT.LOW</code> or <code>DWT.HIGH</code>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setInterpolation(int interpolation) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    int quality = 0;
+    switch (interpolation) {
+        case DWT.DEFAULT: quality = OS.NSImageInterpolationDefault; break;
+        case DWT.NONE: quality = OS.NSImageInterpolationNone; break;
+        case DWT.LOW: quality = OS.NSImageInterpolationLow; break;
+        case DWT.HIGH: quality = OS.NSImageInterpolationHigh; break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    handle.setImageInterpolation(quality);
+}
+
+/**
+ * Sets the receiver's line attributes.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * @param attributes the line attributes
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the attributes is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if any of the line attributes is not valid</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see LineAttributes
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.3
+ */
+public void setLineAttributes(LineAttributes attributes) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (attributes is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    int mask = 0;
+    float lineWidth = attributes.width;
+    if (lineWidth !is data.lineWidth) {
+        mask |= LINE_WIDTH | DRAW_OFFSET;
+    }
+    int lineStyle = attributes.style;
+    if (lineStyle !is data.lineStyle) {
+        mask |= LINE_STYLE;
+        switch (lineStyle) {
+            case DWT.LINE_SOLID:
+            case DWT.LINE_DASH:
+            case DWT.LINE_DOT:
+            case DWT.LINE_DASHDOT:
+            case DWT.LINE_DASHDOTDOT:
+                break;
+            case DWT.LINE_CUSTOM:
+                if (attributes.dash is null) lineStyle = DWT.LINE_SOLID;
+                break;
+            default:
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+    int join = attributes.join;
+    if (join !is data.lineJoin) {
+        mask |= LINE_JOIN;
+        switch (join) {
+            case DWT.CAP_ROUND:
+            case DWT.CAP_FLAT:
+            case DWT.CAP_SQUARE:
+                break;
+            default:
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+    int cap = attributes.cap;
+    if (cap !is data.lineCap) {
+        mask |= LINE_CAP;
+        switch (cap) {
+            case DWT.JOIN_MITER:
+            case DWT.JOIN_ROUND:
+            case DWT.JOIN_BEVEL:
+                break;
+            default:
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+    float[] dashes = attributes.dash;
+    float[] lineDashes = data.lineDashes;
+    if (dashes !is null && dashes.length > 0) {
+        bool changed = lineDashes is null || lineDashes.length !is dashes.length;
+        for (int i = 0; i < dashes.length; i++) {
+            float dash = dashes[i];
+            if (dash <= 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            if (!changed && lineDashes[i] !is dash) changed = true;
+        }
+        if (changed) {
+            float[] newDashes = new float[dashes.length];
+            System.arraycopy(dashes, 0, newDashes, 0, dashes.length);
+            dashes = newDashes;
+            mask |= LINE_STYLE;
+        } else {
+            dashes = lineDashes;
+        }
+    } else {
+        if (lineDashes !is null && lineDashes.length > 0) {
+            mask |= LINE_STYLE;
+        } else {
+            dashes = lineDashes;
+        }
+    }
+    float dashOffset = attributes.dashOffset;
+    if (dashOffset !is data.lineDashesOffset) {
+        mask |= LINE_STYLE;     
+    }
+    float miterLimit = attributes.miterLimit;
+    if (miterLimit !is data.lineMiterLimit) {
+        mask |= LINE_MITERLIMIT;        
+    }
+    if (mask is 0) return;
+    data.lineWidth = lineWidth;
+    data.lineStyle = lineStyle;
+    data.lineCap = cap;
+    data.lineJoin = join;
+    data.lineDashes = dashes;
+    data.lineDashesOffset = dashOffset;
+    data.lineMiterLimit = miterLimit;
+    data.state &= ~mask;
+}
+
+/** 
+ * Sets the receiver's line cap style to the argument, which must be one
+ * of the constants <code>DWT.CAP_FLAT</code>, <code>DWT.CAP_ROUND</code>,
+ * or <code>DWT.CAP_SQUARE</code>.
+ *
+ * @param cap the cap style to be used for drawing lines
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void setLineCap(int cap) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.lineCap is cap) return;
+    switch (cap) {
+        case DWT.CAP_ROUND:
+        case DWT.CAP_FLAT:
+        case DWT.CAP_SQUARE:
+            break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    data.lineCap = cap;
+    data.state &= ~LINE_CAP;
+}
+
+/** 
+ * Sets the receiver's line dash style to the argument. The default
+ * value is <code>null</code>. If the argument is not <code>null</code>,
+ * the receiver's line style is set to <code>DWT.LINE_CUSTOM</code>, otherwise
+ * it is set to <code>DWT.LINE_SOLID</code>.
+ *
+ * @param dashes the dash style to be used for drawing lines
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if any of the values in the array is less than or equal 0</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void setLineDash(int[] dashes) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    float[] lineDashes = data.lineDashes;
+    if (dashes !is null && dashes.length > 0) {
+        bool changed = data.lineStyle !is DWT.LINE_CUSTOM || lineDashes is null || lineDashes.length !is dashes.length;
+        for (int i = 0; i < dashes.length; i++) {
+            int dash = dashes[i];
+            if (dash <= 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+            if (!changed && lineDashes[i] !is dash) changed = true;
+        }
+        if (!changed) return;
+        data.lineDashes = new float[dashes.length];
+        for (int i = 0; i < dashes.length; i++) {
+            data.lineDashes[i] = dashes[i];
+        }
+        data.lineStyle = DWT.LINE_CUSTOM;
+    } else {
+        if (data.lineStyle is DWT.LINE_SOLID && (lineDashes is null || lineDashes.length is 0)) return;
+        data.lineDashes = null;
+        data.lineStyle = DWT.LINE_SOLID;
+    }
+    data.state &= ~LINE_STYLE;
+}
+
+/** 
+ * Sets the receiver's line join style to the argument, which must be one
+ * of the constants <code>DWT.JOIN_MITER</code>, <code>DWT.JOIN_ROUND</code>,
+ * or <code>DWT.JOIN_BEVEL</code>.
+ *
+ * @param join the join style to be used for drawing lines
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void setLineJoin(int join) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.lineJoin is join) return;
+    switch (join) {
+        case DWT.JOIN_MITER:
+        case DWT.JOIN_ROUND:
+        case DWT.JOIN_BEVEL:
+            break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    data.lineJoin = join;
+    data.state &= ~LINE_JOIN;
+}
+
+/** 
+ * Sets the receiver's line style to the argument, which must be one
+ * of the constants <code>DWT.LINE_SOLID</code>, <code>DWT.LINE_DASH</code>,
+ * <code>DWT.LINE_DOT</code>, <code>DWT.LINE_DASHDOT</code> or
+ * <code>DWT.LINE_DASHDOTDOT</code>.
+ *
+ * @param lineStyle the style to be used for drawing lines
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setLineStyle(int lineStyle) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.lineStyle is lineStyle) return;
+    switch (lineStyle) {
+        case DWT.LINE_SOLID:
+        case DWT.LINE_DASH:
+        case DWT.LINE_DOT:
+        case DWT.LINE_DASHDOT:
+        case DWT.LINE_DASHDOTDOT:
+            break;
+        case DWT.LINE_CUSTOM:
+            if (data.lineDashes is null) lineStyle = DWT.LINE_SOLID;
+            break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    data.lineStyle = lineStyle;
+    data.state &= ~LINE_STYLE;
+}
+
+/** 
+ * Sets the width that will be used when drawing lines
+ * for all of the figure drawing operations (that is,
+ * <code>drawLine</code>, <code>drawRectangle</code>, 
+ * <code>drawPolyline</code>, and so forth.
+ * <p>
+ * Note that line width of zero is used as a hint to
+ * indicate that the fastest possible line drawing
+ * algorithms should be used. This means that the
+ * output may be different from line width one.
+ * </p>
+ *
+ * @param lineWidth the width of a line
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setLineWidth(int lineWidth) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.lineWidth is lineWidth) return;
+    data.lineWidth = lineWidth;
+    data.state &= ~(LINE_WIDTH | DRAW_OFFSET);  
+}
+
+/** 
+ * If the argument is <code>true</code>, puts the receiver
+ * in a drawing mode where the resulting color in the destination
+ * is the <em>exclusive or</em> of the color values in the source
+ * and the destination, and if the argument is <code>false</code>,
+ * puts the receiver in a drawing mode where the destination color
+ * is replaced with the source color value.
+ * <p>
+ * Note that this mode in fundamentally unsupportable on certain
+ * platforms, notably Carbon (Mac OS X). Clients that want their
+ * code to run on all platforms need to avoid this method.
+ * </p>
+ *
+ * @param xor if <code>true</code>, then <em>xor</em> mode is used, otherwise <em>source copy</em> mode is used
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @deprecated this functionality is not supported on some platforms
+ */
+public void setXORMode(bool xor) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    data.xorMode = xor;
+}
+
+/**
+ * Sets the receiver's text anti-aliasing value to the parameter, 
+ * which must be one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code>
+ * or <code>DWT.ON</code>. Note that this controls anti-aliasing only
+ * for all <em>text drawing</em> operations.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param antialias the anti-aliasing setting
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>DWT.DEFAULT</code>,
+ *                                 <code>DWT.OFF</code> or <code>DWT.ON</code></li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * @see #setAntialias
+ * 
+ * @since 3.1
+ */
+public void setTextAntialias(int antialias) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    switch (antialias) {
+        case DWT.DEFAULT:
+        case DWT.OFF:
+        case DWT.ON:
+            break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    data.textAntialias = antialias;
+}
+
+/**
+ * Sets the transform that is currently being used by the receiver. If
+ * the argument is <code>null</code>, the current transform is set to
+ * the identity transform.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param transform the transform to set
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Transform
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setTransform(Transform transform) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (transform !is null && transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (transform !is null) {
+        if (data.transform !is null) data.transform.release();
+        if (data.inverseTransform !is null) data.inverseTransform.release();
+        data.transform = ((NSAffineTransform)new NSAffineTransform().alloc()).initWithTransform(transform.handle);
+        data.inverseTransform = ((NSAffineTransform)new NSAffineTransform().alloc()).initWithTransform(transform.handle);
+        NSAffineTransformStruct struct = data.inverseTransform.transformStruct();
+        if ((struct.m11 * struct.m22 - struct.m12 * struct.m21) !is 0) {
+            data.inverseTransform.invert();
+        }
+    } else {
+        data.transform = data.inverseTransform = null;
+    }
+    data.state &= ~(TRANSFORM | DRAW_OFFSET);
+}
+
+/**
+ * Returns the extent of the given string. No tab
+ * expansion or carriage return processing will be performed.
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point stringExtent(String string) {
+    return textExtent(string, 0);
+}
+
+/**
+ * Returns the extent of the given string. Tab expansion and
+ * carriage return processing are performed.
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point textExtent(String string) {
+    return textExtent(string, DWT.DRAW_DELIMITER | DWT.DRAW_TAB);
+}
+
+/**
+ * Returns the extent of the given string. Tab expansion, line
+ * delimiter and mnemonic processing are performed according to
+ * the specified flags, which can be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @param flags the flags specifying how to process the text
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point textExtent(String string, int flags) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    checkGC(FONT);
+    NSAttributedString str = createString(string, flags);
+    NSSize size = str.size();
+    return new Point((int)size.width, (int)size.height);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "GC {*DISPOSED*}";
+    return "GC {" + handle + "}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/GCData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.GCData;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSView;
+
+/**
+ * Instances of this class are descriptions of GCs in terms
+ * of unallocated platform-specific data fields.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the public
+ * API for DWT. It is marked public only so that it can be shared
+ * within the packages provided by DWT. It is not available on all
+ * platforms, and should never be called from application code.
+ * </p>
+ */
+public final class GCData {
+    public Device device;
+    public int style, state = -1;
+    public float[] foreground;
+    public float[] background;
+    public Pattern foregroundPattern;
+    public Pattern backgroundPattern;
+    public Font font;
+    public int alpha = 0xFF;
+    public float lineWidth;
+    public int lineStyle = DWT.LINE_SOLID;
+    public int lineCap = DWT.CAP_FLAT;
+    public int lineJoin = DWT.JOIN_MITER;
+    public float lineDashesOffset;
+    public float[] lineDashes;
+    public float lineMiterLimit = 10;
+    public bool xorMode;
+    public int antialias = DWT.DEFAULT;
+    public int textAntialias = DWT.DEFAULT;
+    public int fillRule = DWT.FILL_EVEN_ODD;
+    public int bitmapDataAddress;
+
+    public Image image;
+    
+    public float drawXOffset, drawYOffset;
+    public NSRect paintRect;
+    public NSBezierPath path;
+    public NSAffineTransform transform, inverseTransform;
+    public NSBezierPath clipPath;
+    public NSView view;
+    public NSSize size;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/GlyphMetrics.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.GlyphMetrics;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+
+/**
+ * Instances of this class represent glyph metrics.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see TextStyle
+ * @see TextLayout
+ * 
+ * @since 3.2
+ */
+public final class GlyphMetrics {
+    
+    /**
+     * the ascent of the GlyphMetrics
+     */
+    public int ascent;
+    
+    /**
+     * the descent of the GlyphMetrics
+     */
+    public int descent;
+    
+    /**
+     * the width of the GlyphMetrics
+     */
+    public int width;
+    
+/**
+ * Constructs an instance of this class with the given
+ * ascent, descent and width values.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the ascent, descent or width argument is negative</li>
+ * </ul>
+ */
+public GlyphMetrics(int ascent, int descent, int width) {
+    if (ascent < 0 || descent < 0 || width < 0) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.ascent = ascent;
+    this.descent = descent;
+    this.width = width;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof GlyphMetrics)) return false;
+    GlyphMetrics metrics = (GlyphMetrics)object;
+    return metrics.ascent is ascent && metrics.descent is descent && metrics.width is width;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+    return ascent ^ descent ^ width;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the <code>GlyphMetrics</code>
+ */
+public String toString () {
+    return "GlyphMetrics {" + ascent + ", " + descent + ", " + width + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Image.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,998 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Image;
+
+import dwt.dwthelper.utils;
+
+ 
+import java.io.InputStream;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSBitmapImageRep;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+ 
+/**
+ * Instances of this class are graphics which have been prepared
+ * for display on a specific device. That is, they are ready
+ * to paint using methods such as <code>GC.drawImage()</code>
+ * and display on widgets with, for example, <code>Button.setImage()</code>.
+ * <p>
+ * If loaded from a file format that supports it, an
+ * <code>Image</code> may have transparency, meaning that certain
+ * pixels are specified as being transparent when drawn. Examples
+ * of file formats that support transparency are GIF and PNG.
+ * </p><p>
+ * There are two primary ways to use <code>Images</code>. 
+ * The first is to load a graphic file from disk and create an
+ * <code>Image</code> from it. This is done using an <code>Image</code>
+ * constructor, for example:
+ * <pre>
+ *    Image i = new Image(device, "C:\\graphic.bmp");
+ * </pre>
+ * A graphic file may contain a color table specifying which
+ * colors the image was intended to possess. In the above example,
+ * these colors will be mapped to the closest available color in
+ * DWT. It is possible to get more control over the mapping of
+ * colors as the image is being created, using code of the form:
+ * <pre>
+ *    ImageData data = new ImageData("C:\\graphic.bmp"); 
+ *    RGB[] rgbs = data.getRGBs(); 
+ *    // At this point, rgbs contains specifications of all
+ *    // the colors contained within this image. You may
+ *    // allocate as many of these colors as you wish by
+ *    // using the Color constructor Color(RGB), then
+ *    // create the image:
+ *    Image i = new Image(device, data);
+ * </pre>
+ * <p>
+ * Applications which require even greater control over the image
+ * loading process should use the support provided in class
+ * <code>ImageLoader</code>.
+ * </p><p>
+ * Application code must explicitly invoke the <code>Image.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see Color
+ * @see ImageData
+ * @see ImageLoader
+ */
+public final class Image extends Resource implements Drawable {
+
+    /**
+     * specifies whether the receiver is a bitmap or an icon
+     * (one of <code>DWT.BITMAP</code>, <code>DWT.ICON</code>)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public int type;
+    
+    /**
+     * the handle to the OS image resource
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public NSImage handle;
+    NSBitmapImageRep imageRep;
+    
+    /**
+     * specifies the transparent pixel
+     */
+    int transparentPixel = -1;
+    
+    /**
+     * The GC the image is currently selected in.
+     */
+    GC memGC;
+
+    /**
+     * The alpha data of the image.
+     */
+    byte[] alphaData;
+    
+    /**
+     * The global alpha value to be used for every pixel.
+     */
+    int alpha = -1;
+    
+    /**
+     * The width of the image.
+     */
+    int width = -1;
+    
+    /**
+     * The height of the image.
+     */
+    int height = -1;
+    
+    /**
+     * Specifies the default scanline padding.
+     */
+    static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image(Device device) {
+    super(device);
+}
+
+/**
+ * Constructs an empty instance of this class with the
+ * specified width and height. The result may be drawn upon
+ * by creating a GC and using any of its drawing operations,
+ * as shown in the following example:
+ * <pre>
+ *    Image i = new Image(device, width, height);
+ *    GC gc = new GC(i);
+ *    gc.drawRectangle(0, 0, 50, 50);
+ *    gc.dispose();
+ * </pre>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param width the width of the new image
+ * @param height the height of the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, int width, int height) {
+    super(device);
+    init(width, height);
+    init();
+}
+
+/**
+ * Constructs a new instance of this class based on the
+ * provided image, with an appearance that varies depending
+ * on the value of the flag. The possible flag values are:
+ * <dl>
+ * <dt><b>IMAGE_COPY</b></dt>
+ * <dd>the result is an identical copy of srcImage</dd>
+ * <dt><b>IMAGE_DISABLE</b></dt>
+ * <dd>the result is a copy of srcImage which has a <em>disabled</em> look</dd>
+ * <dt><b>IMAGE_GRAY</b></dt>
+ * <dd>the result is a copy of srcImage which has a <em>gray scale</em> look</dd>
+ * </dl>
+ *
+ * @param device the device on which to create the image
+ * @param srcImage the image to use as the source
+ * @param flag the style, either <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code>
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or is otherwise in an invalid state</li>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the image is not supported</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, Image srcImage, int flag) {
+    super(device);
+    if (srcImage is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (srcImage.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    switch (flag) {
+        case DWT.IMAGE_COPY:
+        case DWT.IMAGE_DISABLE:
+        case DWT.IMAGE_GRAY:
+            break;
+        default:
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    device = this.device;
+    this.type = srcImage.type;
+
+    /* Get source image size */
+    NSSize size = srcImage.handle.size();
+    int width = (int)size.width;
+    int height = (int)size.height;
+    NSBitmapImageRep srcRep = srcImage.imageRep;
+    int bpr = srcRep.bytesPerRow();
+
+    /* Copy transparent pixel and alpha data when necessary */
+    transparentPixel = srcImage.transparentPixel;
+    alpha = srcImage.alpha;
+    if (srcImage.alphaData !is null) {
+        alphaData = new byte[srcImage.alphaData.length];
+        System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length);
+    }
+
+    /* Create the image */
+    handle = (NSImage)new NSImage().alloc();
+    handle = handle.initWithSize(size);
+    NSBitmapImageRep rep = imageRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
+    rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(0, width, height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.samplesPerPixel() is 4, srcRep.isPlanar(), new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, srcRep.bytesPerRow(), srcRep.bitsPerPixel());
+    handle.addRepresentation(rep);
+    
+    int data = rep.bitmapData();
+    OS.memmove(data, srcImage.imageRep.bitmapData(), width * height * 4);
+    if (flag !is DWT.IMAGE_COPY) {
+        
+        /* Apply transformation */
+        switch (flag) {
+            case DWT.IMAGE_DISABLE: {
+                Color zeroColor = device.getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW);
+                RGB zeroRGB = zeroColor.getRGB();
+                byte zeroRed = (byte)zeroRGB.red;
+                byte zeroGreen = (byte)zeroRGB.green;
+                byte zeroBlue = (byte)zeroRGB.blue;
+                Color oneColor = device.getSystemColor(DWT.COLOR_WIDGET_BACKGROUND);
+                RGB oneRGB = oneColor.getRGB();
+                byte oneRed = (byte)oneRGB.red;
+                byte oneGreen = (byte)oneRGB.green;
+                byte oneBlue = (byte)oneRGB.blue;
+                byte[] line = new byte[bpr];
+                for (int y=0; y<height; y++) {
+                    OS.memmove(line, data + (y * bpr), bpr);
+                    int offset = 0;
+                    for (int x=0; x<width; x++) {
+                        int red = line[offset+1] & 0xFF;
+                        int green = line[offset+2] & 0xFF;
+                        int blue = line[offset+3] & 0xFF;
+                        int intensity = red * red + green * green + blue * blue;
+                        if (intensity < 98304) {
+                            line[offset+1] = zeroRed;
+                            line[offset+2] = zeroGreen;
+                            line[offset+3] = zeroBlue;
+                        } else {
+                            line[offset+1] = oneRed;
+                            line[offset+2] = oneGreen;
+                            line[offset+3] = oneBlue;
+                        }
+                        offset += 4;
+                    }
+                    OS.memmove(data + (y * bpr), line, bpr);
+                }
+                break;
+            }
+            case DWT.IMAGE_GRAY: {          
+                byte[] line = new byte[bpr];
+                for (int y=0; y<height; y++) {
+                    OS.memmove(line, data + (y * bpr), bpr);
+                    int offset = 0;
+                    for (int x=0; x<width; x++) {
+                        int red = line[offset+1] & 0xFF;
+                        int green = line[offset+2] & 0xFF;
+                        int blue = line[offset+3] & 0xFF;
+                        byte intensity = (byte)((red+red+green+green+green+green+green+blue) >> 3);
+                        line[offset+1] = line[offset+2] = line[offset+3] = intensity;
+                        offset += 4;
+                    }
+                    OS.memmove(data + (y * bpr), line, bpr);
+                }
+                break;
+            }
+        }
+    }
+    init();
+}
+
+/**
+ * Constructs an empty instance of this class with the
+ * width and height of the specified rectangle. The result
+ * may be drawn upon by creating a GC and using any of its
+ * drawing operations, as shown in the following example:
+ * <pre>
+ *    Image i = new Image(device, boundsRectangle);
+ *    GC gc = new GC(i);
+ *    gc.drawRectangle(0, 0, 50, 50);
+ *    gc.dispose();
+ * </pre>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param bounds a rectangle specifying the image's width and height (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, Rectangle bounds) {
+    super(device);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    init(bounds.width, bounds.height);
+    init();
+}
+
+/**
+ * Constructs an instance of this class from the given
+ * <code>ImageData</code>.
+ *
+ * @param device the device on which to create the image
+ * @param data the image data to create the image from (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the image data is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the ImageData is not supported</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, ImageData data) {
+    super(device);
+    init(data);
+    init();
+}
+
+/**
+ * Constructs an instance of this class, whose type is 
+ * <code>DWT.ICON</code>, from the two given <code>ImageData</code>
+ * objects. The two images must be the same size. Pixel transparency
+ * in either image will be ignored.
+ * <p>
+ * The mask image should contain white wherever the icon is to be visible,
+ * and black wherever the icon is to be transparent. In addition,
+ * the source image should contain black wherever the icon is to be
+ * transparent.
+ * </p>
+ *
+ * @param device the device on which to create the icon
+ * @param source the color data for the icon
+ * @param mask the mask data for the icon
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li>
+ *    <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, ImageData source, ImageData mask) {
+    super(device);
+    if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (mask is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (source.width !is mask.width || source.height !is mask.height) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    mask = ImageData.convertMask(mask);
+    ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data);
+    image.maskPad = mask.scanlinePad;
+    image.maskData = mask.data;
+    init(image);
+}
+
+/**
+ * Constructs an instance of this class by loading its representation
+ * from the specified input stream. Throws an error if an error
+ * occurs while loading the image, or if the result is an image
+ * of an unsupported type.  Application code is still responsible
+ * for closing the input stream.
+ * <p>
+ * This constructor is provided for convenience when loading a single
+ * image only. If the stream contains multiple images, only the first
+ * one will be loaded. To load multiple images, use 
+ * <code>ImageLoader.load()</code>.
+ * </p><p>
+ * This constructor may be used to load a resource as follows:
+ * </p>
+ * <pre>
+ *     static Image loadImage (Display display, Class clazz, String string) {
+ *          InputStream stream = clazz.getResourceAsStream (string);
+ *          if (stream is null) return null;
+ *          Image image = null;
+ *          try {
+ *               image = new Image (display, stream);
+ *          } catch (DWTException ex) {
+ *          } finally {
+ *               try {
+ *                    stream.close ();
+ *               } catch (IOException ex) {}
+ *          }
+ *          return image;
+ *     }
+ * </pre>
+ *
+ * @param device the device on which to create the image
+ * @param stream the input stream to load the image from
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data </li>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the image stream describes an image with an unsupported depth</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, InputStream stream) {
+    super(device);
+    init(new ImageData(stream));
+    init();
+}
+
+/**
+ * Constructs an instance of this class by loading its representation
+ * from the file with the specified name. Throws an error if an error
+ * occurs while loading the image, or if the result is an image
+ * of an unsupported type.
+ * <p>
+ * This constructor is provided for convenience when loading
+ * a single image only. If the specified file contains
+ * multiple images, only the first one will be used.
+ *
+ * @param device the device on which to create the image
+ * @param filename the name of the file to load the image from
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the image file describes an image with an unsupported depth</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, String filename) {
+    super(device);
+    init(new ImageData(filename));
+    init();
+}
+
+void createAlpha () {
+    if (transparentPixel is -1 && alpha is -1 && alphaData is null) return;
+    NSSize size = handle.size();
+    int height = (int)size.height;
+    int bpr = imageRep.bytesPerRow();
+    int dataSize = height * bpr;
+    byte[] srcData = new byte[dataSize];
+    OS.memmove(srcData, imageRep.bitmapData(), dataSize);
+    if (transparentPixel !is -1) {
+        for (int i=0; i<dataSize; i+=4) {
+            int pixel = ((srcData[i+1] & 0xFF) << 16) | ((srcData[i+2] & 0xFF) << 8) | (srcData[i+3] & 0xFF);
+            srcData[i] = (byte)(pixel is transparentPixel ? 0 : 0xFF); 
+        }
+    } else if (alpha !is -1) {
+        byte a = (byte)this.alpha;
+        for (int i=0; i<dataSize; i+=4) {
+            srcData[i] = a;             
+        }
+    } else {
+        int width = (int)size.width;
+        int offset = 0, alphaOffset = 0;
+        for (int y = 0; y<height; y++) {
+            for (int x = 0; x<width; x++) {
+                srcData[offset] = alphaData[alphaOffset];
+                offset += 4;
+                alphaOffset += 1;
+            }
+        }
+    }
+    OS.memmove(imageRep.bitmapData(), srcData, dataSize);
+}
+
+void destroy() {
+    if (memGC !is null) memGC.dispose();
+    if (imageRep !is null) imageRep.release();
+    handle.release();
+    imageRep = null;
+    handle = null;
+    memGC = null;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof Image)) return false;
+    Image image = (Image)object;
+    return device is image.device && handle is image.handle &&
+        transparentPixel is image.transparentPixel;
+}
+
+/**
+ * Returns the color to which to map the transparent pixel, or null if
+ * the receiver has no transparent pixel.
+ * <p>
+ * There are certain uses of Images that do not support transparency
+ * (for example, setting an image into a button or label). In these cases,
+ * it may be desired to simulate transparency by using the background
+ * color of the widget to paint the transparent pixels of the image.
+ * Use this method to check which color will be used in these cases
+ * in place of transparency. This value may be set with setBackground().
+ * <p>
+ *
+ * @return the background color of the image, or null if there is no transparency in the image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getBackground() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (transparentPixel is -1) return null;
+    int red = (transparentPixel >> 16) & 0xFF;
+    int green = (transparentPixel >> 8) & 0xFF;
+    int blue = (transparentPixel >> 0) & 0xFF;
+    return Color.cocoa_new(device, new float[]{red / 255f, green / 255f, blue / 255f, 1});
+}
+
+/**
+ * Returns the bounds of the receiver. The rectangle will always
+ * have x and y values of 0, and the width and height of the
+ * image.
+ *
+ * @return a rectangle specifying the image's bounds
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ */
+public Rectangle getBounds() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (width !is -1 && height !is -1) {
+        return new Rectangle(0, 0, width, height);
+    }
+    NSSize size = handle.size();
+    return new Rectangle(0, 0, width = (int)size.width, height = (int)size.height);
+}
+
+/**
+ * Returns an <code>ImageData</code> based on the receiver
+ * Modifications made to this <code>ImageData</code> will not
+ * affect the Image.
+ *
+ * @return an <code>ImageData</code> containing the image's data and attributes
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
+ */
+public ImageData getImageData() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+
+    NSSize size = handle.size();
+    int width = (int)size.width;
+    int height = (int)size.height;
+    NSBitmapImageRep imageRep = this.imageRep;
+    int bpr = imageRep.bytesPerRow();
+    int bpp = imageRep.bitsPerPixel();
+    int dataSize = height * bpr;
+    byte[] srcData = new byte[dataSize];
+    OS.memmove(srcData, imageRep.bitmapData(), dataSize);
+    
+    PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
+    ImageData data = new ImageData(width, height, bpp, palette);
+    data.data = srcData;
+    data.bytesPerLine = bpr;
+
+    data.transparentPixel = transparentPixel;
+    if (transparentPixel is -1 && type is DWT.ICON) {
+        /* Get the icon mask data */
+        int maskPad = 2;
+        int maskBpl = (((width + 7) / 8) + (maskPad - 1)) / maskPad * maskPad;
+        byte[] maskData = new byte[height * maskBpl];
+        int offset = 0, maskOffset = 0;
+        for (int y = 0; y<height; y++) {
+            for (int x = 0; x<width; x++) {
+                if (srcData[offset] !is 0) {
+                    maskData[maskOffset + (x >> 3)] |= (1 << (7 - (x & 0x7)));
+                } else {
+                    maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
+                }
+                offset += 4;
+            }
+            maskOffset += maskBpl;
+        }
+        data.maskData = maskData;
+        data.maskPad = maskPad;
+    }
+    for (int i = 0; i < srcData.length; i+= 4) {
+        srcData[i] = 0;
+    }
+    data.alpha = alpha;
+    if (alpha is -1 && alphaData !is null) {
+        data.alphaData = new byte[alphaData.length];
+        System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
+    }
+    return data;
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new image.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Image</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param type the type of the image (<code>DWT.BITMAP</code> or <code>DWT.ICON</code>)
+ * @param handle the OS handle for the image
+ * @param data the OS data for the image
+ *
+ * @private
+ */
+public static Image cocoa_new(Device device, int type, NSImage nsImage) {
+    Image image = new Image(device);
+    image.type = type;
+    image.handle = nsImage;
+    NSImageRep rep = nsImage.bestRepresentationForDevice(null);
+    if (rep.isKindOfClass(NSBitmapImageRep.static_class())) { 
+        image.imageRep = new NSBitmapImageRep(rep.id);
+    }
+    return image;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode () {
+    return handle !is null ? handle.id : 0;
+}
+
+void init(int width, int height) {
+    if (width <= 0 || height <= 0) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.type = DWT.BITMAP;
+    this.width = width;
+    this.height = height;
+
+    handle = (NSImage)new NSImage().alloc();
+    NSSize size = new NSSize();
+    size.width = width;
+    size.height = height;
+    handle = handle.initWithSize(size);
+    NSBitmapImageRep rep = imageRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
+    rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(0, width, height, 8, 3, false, false, new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, width * 4, 32);
+    OS.memset(rep.bitmapData(), 0xFF, width * height * 4);
+    handle.addRepresentation(rep);
+//  rep.release();
+}
+
+void init(ImageData image) {
+    if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    this.width = image.width;
+    this.height = image.height;
+    PaletteData palette = image.palette;
+    if (!(((image.depth is 1 || image.depth is 2 || image.depth is 4 || image.depth is 8) && !palette.isDirect) ||
+            ((image.depth is 8) || (image.depth is 16 || image.depth is 24 || image.depth is 32) && palette.isDirect)))
+                DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+    
+    /* Create the image */
+    int dataSize = width * height * 4;
+    
+    /* Initialize data */
+    int bpr = width * 4;
+    byte[] buffer = new byte[dataSize];
+    if (palette.isDirect) {
+        ImageData.blit(ImageData.BLIT_SRC,
+            image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, palette.redMask, palette.greenMask, palette.blueMask,
+            ImageData.ALPHA_OPAQUE, null, 0, 0, 0, 
+            buffer, 32, bpr, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
+            false, false);
+    } else {
+        RGB[] rgbs = palette.getRGBs();
+        int length = rgbs.length;
+        byte[] srcReds = new byte[length];
+        byte[] srcGreens = new byte[length];
+        byte[] srcBlues = new byte[length];
+        for (int i = 0; i < rgbs.length; i++) {
+            RGB rgb = rgbs[i];
+            if (rgb is null) continue;
+            srcReds[i] = (byte)rgb.red;
+            srcGreens[i] = (byte)rgb.green;
+            srcBlues[i] = (byte)rgb.blue;
+        }
+        ImageData.blit(ImageData.BLIT_SRC,
+            image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, srcReds, srcGreens, srcBlues,
+            ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+            buffer, 32, bpr, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
+            false, false);
+    }
+    
+    /* Initialize transparency */
+    int transparency = image.getTransparencyType();
+    bool hasAlpha = transparency !is DWT.TRANSPARENCY_NONE;
+    if (transparency is DWT.TRANSPARENCY_MASK || image.transparentPixel !is -1) {
+        this.type = image.transparentPixel !is -1 ? DWT.BITMAP : DWT.ICON;
+        if (image.transparentPixel !is -1) {
+            int transRed = 0, transGreen = 0, transBlue = 0;
+            if (palette.isDirect) {
+                RGB rgb = palette.getRGB(image.transparentPixel);
+                transRed = rgb.red;
+                transGreen = rgb.green;
+                transBlue = rgb.blue;
+            } else {
+                RGB[] rgbs = palette.getRGBs();
+                if (image.transparentPixel < rgbs.length) {
+                    RGB rgb = rgbs[image.transparentPixel];
+                    transRed = rgb.red;
+                    transGreen = rgb.green;
+                    transBlue = rgb.blue;               
+                }
+            }
+            transparentPixel = transRed << 16 | transGreen << 8 | transBlue;
+        }
+        ImageData maskImage = image.getTransparencyMask();
+        byte[] maskData = maskImage.data;
+        int maskBpl = maskImage.bytesPerLine;
+        int offset = 0, maskOffset = 0;
+        for (int y = 0; y<height; y++) {
+            for (int x = 0; x<width; x++) {
+                buffer[offset] = ((maskData[maskOffset + (x >> 3)]) & (1 << (7 - (x & 0x7)))) !is 0 ? (byte)0xff : 0;
+                offset += 4;
+            }
+            maskOffset += maskBpl;
+        }
+    } else {
+        this.type = DWT.BITMAP;
+        if (image.alpha !is -1) {
+            hasAlpha = true;
+            this.alpha = image.alpha;
+            byte a = (byte)this.alpha;
+            for (int dataIndex=0; dataIndex<buffer.length; dataIndex+=4) {
+                buffer[dataIndex] = a;              
+            }
+        } else if (image.alphaData !is null) {
+            this.alphaData = new byte[image.alphaData.length];
+            System.arraycopy(image.alphaData, 0, this.alphaData, 0, alphaData.length);
+            int offset = 0, alphaOffset = 0;
+            for (int y = 0; y<height; y++) {
+                for (int x = 0; x<width; x++) {
+                    buffer[offset] = alphaData[alphaOffset];
+                    offset += 4;
+                    alphaOffset += 1;
+                }
+            }
+        }
+    }
+    handle = (NSImage)new NSImage().alloc();
+    NSSize size = new NSSize();
+    size.width = width;
+    size.height = height;
+    handle = handle.initWithSize(size);
+    NSBitmapImageRep rep = imageRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
+    rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
+            0, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32);
+    OS.memmove(rep.bitmapData(), buffer, dataSize); 
+    handle.addRepresentation(rep);
+//  rep.release();
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Image</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public int internal_new_GC (GCData data) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (type !is DWT.BITMAP || memGC !is null) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    NSGraphicsContext current = NSGraphicsContext.currentContext();
+    NSBitmapImageRep rep = imageRep;
+    if (imageRep.hasAlpha()) {
+        int bpr = width * 4;
+        rep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
+        int bitmapData = imageRep.bitmapData();
+        if (data.bitmapDataAddress !is 0) OS.free(data.bitmapDataAddress);
+        data.bitmapDataAddress = OS.malloc(4);
+        OS.memmove(data.bitmapDataAddress, new int[] {bitmapData}, 4);
+        rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
+                data.bitmapDataAddress, width, height, 8, 3, false, false, new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat , bpr, 32);
+        rep.autorelease();
+    }
+    NSGraphicsContext context = NSGraphicsContext.graphicsContextWithBitmapImageRep(rep);
+    NSGraphicsContext.setCurrentContext(context);
+    NSAffineTransform transform = NSAffineTransform.transform();
+    NSSize size = handle.size();
+    transform.translateXBy(0, size.height);
+    transform.scaleXBy(1, -1);
+    transform.set();
+    if (data !is null) {
+        int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+        if ((data.style & mask) is 0) {
+            data.style |= DWT.LEFT_TO_RIGHT;
+        }
+        data.device = device;
+        data.background = device.COLOR_WHITE.handle;
+        data.foreground = device.COLOR_BLACK.handle;
+        data.font = device.systemFont;
+        data.image = this;
+    }
+    NSGraphicsContext.setCurrentContext(current);
+    return context.id;
+}
+
+/**  
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Image</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int context, GCData data) {
+    if (data.bitmapDataAddress !is 0) OS.free(data.bitmapDataAddress);
+    data.bitmapDataAddress = 0;
+}
+
+/**
+ * Returns <code>true</code> if the image has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the image.
+ * When an image has been disposed, it is an error to
+ * invoke any other method using the image.
+ *
+ * @return <code>true</code> when the image is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+/**
+ * Sets the color to which to map the transparent pixel.
+ * <p>
+ * There are certain uses of <code>Images</code> that do not support
+ * transparency (for example, setting an image into a button or label).
+ * In these cases, it may be desired to simulate transparency by using
+ * the background color of the widget to paint the transparent pixels
+ * of the image. This method specifies the color that will be used in
+ * these cases. For example:
+ * <pre>
+ *    Button b = new Button();
+ *    image.setBackground(b.getBackground());
+ *    b.setImage(image);
+ * </pre>
+ * </p><p>
+ * The image may be modified by this operation (in effect, the
+ * transparent regions may be filled with the supplied color).  Hence
+ * this operation is not reversible and it is not legal to call
+ * this function twice or with a null argument.
+ * </p><p>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ * </p>
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setBackground(Color color) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (color is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (transparentPixel is -1) return;
+//  byte red = (byte)((transparentPixel >> 16) & 0xFF);
+//  byte green = (byte)((transparentPixel >> 8) & 0xFF);
+//  byte blue = (byte)((transparentPixel >> 0) & 0xFF);
+//  byte newRed = (byte)((int)(color.handle[0] * 255) & 0xFF);
+//  byte newGreen = (byte)((int)(color.handle[1] * 255) & 0xFF);
+//  byte newBlue = (byte)((int)(color.handle[2] * 255) & 0xFF);
+//  int height = OS.CGImageGetHeight(handle);
+//  int bpl = OS.CGImageGetBytesPerRow(handle);
+//  byte[] line = new byte[bpl];
+//  for (int i = 0, offset = 0; i < height; i++, offset += bpl) {
+//      OS.memmove(line, data + offset, bpl);
+//      for (int j = 0; j  < line.length; j += 4) {
+//          if (line[j+ 1] is red && line[j + 2] is green && line[j + 3] is blue) {
+//              line[j + 1] = newRed;
+//              line[j + 2] = newGreen;
+//              line[j + 3] = newBlue;
+//          }
+//      }
+//      OS.memmove(data + offset, line, bpl);
+//  }
+//  transparentPixel = (newRed & 0xFF) << 16 | (newGreen & 0xFF) << 8 | (newBlue & 0xFF);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "Image {*DISPOSED*}";
+    return "Image {" + handle + "}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/ImageData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,3610 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.ImageData;
+
+import dwt.dwthelper.utils;
+
+
+import java.io.InputStream;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.CloneableCompatibility;
+
+/**
+ * Instances of this class are device-independent descriptions
+ * of images. They are typically used as an intermediate format
+ * between loading from or writing to streams and creating an 
+ * <code>Image</code>.
+ * <p>
+ * Note that the public fields <code>x</code>, <code>y</code>, 
+ * <code>disposalMethod</code> and <code>delayTime</code> are
+ * typically only used when the image is in a set of images used
+ * for animation.
+ * </p>
+ *
+ * @see Image
+ * @see ImageLoader
+ */
+
+public final class ImageData implements CloneableCompatibility {
+    
+    /**
+     * The width of the image, in pixels.
+     */
+    public int width;
+
+    /**
+     * The height of the image, in pixels.
+     */
+    public int height;
+
+    /**
+     * The color depth of the image, in bits per pixel.
+     * <p>
+     * Note that a depth of 8 or less does not necessarily
+     * mean that the image is palette indexed, or
+     * conversely that a depth greater than 8 means that
+     * the image is direct color.  Check the associated
+     * PaletteData's isDirect field for such determinations.
+     */
+    public int depth;
+
+    /**
+     * The scanline padding.
+     * <p>
+     * If one scanline of the image is not a multiple of
+     * this number, it will be padded with zeros until it is.
+     * </p>
+     */
+    public int scanlinePad;
+
+    /**
+     * The number of bytes per scanline.
+     * <p>
+     * This is a multiple of the scanline padding.
+     * </p>
+     */
+    public int bytesPerLine;
+
+    /**
+     * The pixel data of the image.
+     * <p>
+     * Note that for 16 bit depth images the pixel data is stored
+     * in least significant byte order; however, for 24bit and
+     * 32bit depth images the pixel data is stored in most
+     * significant byte order.
+     * </p>
+     */
+    public byte[] data;
+
+    /**
+     * The color table for the image.
+     */
+    public PaletteData palette;
+
+    /**
+     * The transparent pixel.
+     * <p>
+     * Pixels with this value are transparent.
+     * </p><p>
+     * The default is -1 which means 'no transparent pixel'.
+     * </p>
+     */
+    public int transparentPixel;
+
+    /**
+     * An icon-specific field containing the data from the icon mask.
+     * <p>
+     * This is a 1 bit bitmap stored with the most significant
+     * bit first.  The number of bytes per scanline is
+     * '((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad'.
+     * </p><p>
+     * The default is null which means 'no transparency mask'.
+     * </p>
+     */
+    public byte[] maskData;
+
+    /**
+     * An icon-specific field containing the scanline pad of the mask.
+     * <p>
+     * If one scanline of the transparency mask is not a
+     * multiple of this number, it will be padded with zeros until
+     * it is.
+     * </p>
+     */
+    public int maskPad;
+    
+    /**
+     * The alpha data of the image.
+     * <p>
+     * Every pixel can have an <em>alpha blending</em> value that
+     * varies from 0, meaning fully transparent, to 255 meaning
+     * fully opaque.  The number of bytes per scanline is
+     * 'width'.
+     * </p>
+     */
+    public byte[] alphaData;
+    
+    /**
+     * The global alpha value to be used for every pixel.
+     * <p>
+     * If this value is set, the <code>alphaData</code> field
+     * is ignored and when the image is rendered each pixel
+     * will be blended with the background an amount
+     * proportional to this value.
+     * </p><p>
+     * The default is -1 which means 'no global alpha value'
+     * </p>
+     */
+    public int alpha;
+
+    /**
+     * The type of file from which the image was read.
+     * 
+     * It is expressed as one of the following values:
+     * <dl>
+     * <dt><code>IMAGE_BMP</code></dt>
+     * <dd>Windows BMP file format, no compression</dd>
+     * <dt><code>IMAGE_BMP_RLE</code></dt>
+     * <dd>Windows BMP file format, RLE compression if appropriate</dd>
+     * <dt><code>IMAGE_GIF</code></dt>
+     * <dd>GIF file format</dd>
+     * <dt><code>IMAGE_ICO</code></dt>
+     * <dd>Windows ICO file format</dd>
+     * <dt><code>IMAGE_JPEG</code></dt>
+     * <dd>JPEG file format</dd>
+     * <dt><code>IMAGE_PNG</code></dt>
+     * <dd>PNG file format</dd>
+     * </dl>
+     */
+    public int type;
+
+    /**
+     * The x coordinate of the top left corner of the image
+     * within the logical screen (this field corresponds to
+     * the GIF89a Image Left Position value).
+     */
+    public int x;
+
+    /**
+     * The y coordinate of the top left corner of the image
+     * within the logical screen (this field corresponds to
+     * the GIF89a Image Top Position value).
+     */
+    public int y;
+
+    /**
+     * A description of how to dispose of the current image
+     * before displaying the next.
+     * 
+     * It is expressed as one of the following values:
+     * <dl>
+     * <dt><code>DM_UNSPECIFIED</code></dt>
+     * <dd>disposal method not specified</dd>
+     * <dt><code>DM_FILL_NONE</code></dt>
+     * <dd>do nothing - leave the image in place</dd>
+     * <dt><code>DM_FILL_BACKGROUND</code></dt>
+     * <dd>fill with the background color</dd>
+     * <dt><code>DM_FILL_PREVIOUS</code></dt>
+     * <dd>restore the previous picture</dd>
+     * </dl>
+     * (this field corresponds to the GIF89a Disposal Method value)
+     */
+    public int disposalMethod;
+
+    /**
+     * The time to delay before displaying the next image
+     * in an animation (this field corresponds to the GIF89a
+     * Delay Time value).
+     */
+    public int delayTime;
+
+    /**
+     * Arbitrary channel width data to 8-bit conversion table.
+     */
+    static final byte[][] ANY_TO_EIGHT = new byte[9][];
+    static {
+        for (int b = 0; b < 9; ++b) {
+            byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
+            if (b is 0) continue;
+            int inc = 0;
+            for (int bit = 0x10000; (bit >>= b) !is 0;) inc |= bit;
+            for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = (byte)(v >> 8);
+        }
+    }
+    static final byte[] ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
+
+    /**
+     * Scaled 8x8 Bayer dither matrix.
+     */
+    static final int[][] DITHER_MATRIX = {
+        { 0xfc0000, 0x7c0000, 0xdc0000, 0x5c0000, 0xf40000, 0x740000, 0xd40000, 0x540000 },
+        { 0x3c0000, 0xbc0000, 0x1c0000, 0x9c0000, 0x340000, 0xb40000, 0x140000, 0x940000 },
+        { 0xcc0000, 0x4c0000, 0xec0000, 0x6c0000, 0xc40000, 0x440000, 0xe40000, 0x640000 },
+        { 0x0c0000, 0x8c0000, 0x2c0000, 0xac0000, 0x040000, 0x840000, 0x240000, 0xa40000 },
+        { 0xf00000, 0x700000, 0xd00000, 0x500000, 0xf80000, 0x780000, 0xd80000, 0x580000 },
+        { 0x300000, 0xb00000, 0x100000, 0x900000, 0x380000, 0xb80000, 0x180000, 0x980000 },
+        { 0xc00000, 0x400000, 0xe00000, 0x600000, 0xc80000, 0x480000, 0xe80000, 0x680000 },
+        { 0x000000, 0x800000, 0x200000, 0xa00000, 0x080000, 0x880000, 0x280000, 0xa80000 }
+    };
+
+/**
+ * Constructs a new, empty ImageData with the given width, height,
+ * depth and palette. The data will be initialized to an (all zero)
+ * array of the appropriate size.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @param depth the depth of the image
+ * @param palette the palette of the image (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the width or height is negative, or if the depth is not
+ *          one of 1, 2, 4, 8, 16, 24 or 32</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the palette is null</li>
+ * </ul>
+ */
+public ImageData(int width, int height, int depth, PaletteData palette) {
+    this(width, height, depth, palette,
+        4, null, 0, null,
+        null, -1, -1, DWT.IMAGE_UNDEFINED,
+        0, 0, 0, 0);
+}
+
+/**
+ * Constructs a new, empty ImageData with the given width, height,
+ * depth, palette, scanlinePad and data.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @param depth the depth of the image
+ * @param palette the palette of the image
+ * @param scanlinePad the padding of each line, in bytes
+ * @param data the data of the image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the width or height is negative, or if the depth is not
+ *          one of 1, 2, 4, 8, 16, 24 or 32, or the data array is too small to contain the image data</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the palette or data is null</li>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the scanlinePad is zero</li>
+ * </ul>
+ */
+public ImageData(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data) {
+    this(width, height, depth, palette,
+        scanlinePad, checkData(data), 0, null,
+        null, -1, -1, DWT.IMAGE_UNDEFINED,
+        0, 0, 0, 0);
+}
+
+/**
+ * Constructs an <code>ImageData</code> loaded from the specified
+ * input stream. Throws an error if an error occurs while loading
+ * the image, or if the image has an unsupported type.  Application
+ * code is still responsible for closing the input stream.
+ * <p>
+ * This constructor is provided for convenience when loading a single
+ * image only. If the stream contains multiple images, only the first
+ * one will be loaded. To load multiple images, use 
+ * <code>ImageLoader.load()</code>.
+ * </p><p>
+ * This constructor may be used to load a resource as follows:
+ * </p>
+ * <pre>
+ *     static ImageData loadImageData (Class clazz, String string) {
+ *          InputStream stream = clazz.getResourceAsStream (string);
+ *          if (stream is null) return null;
+ *          ImageData imageData = null;
+ *          try {
+ *               imageData = new ImageData (stream);
+ *          } catch (DWTException ex) {
+ *          } finally {
+ *               try {
+ *                    stream.close ();
+ *               } catch (IOException ex) {}
+ *          }
+ *          return imageData;
+ *     }
+ * </pre>
+ *
+ * @param stream the input stream to load the image from (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
+ * </ul>
+ *
+ * @see ImageLoader#load(InputStream)
+ */
+public ImageData(InputStream stream) {
+    ImageData[] data = ImageDataLoader.load(stream);
+    if (data.length < 1) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    ImageData i = data[0];
+    setAllFields(
+        i.width,
+        i.height,
+        i.depth,
+        i.scanlinePad,
+        i.bytesPerLine,
+        i.data,
+        i.palette,
+        i.transparentPixel,
+        i.maskData,
+        i.maskPad,
+        i.alphaData,
+        i.alpha,
+        i.type,
+        i.x,
+        i.y,
+        i.disposalMethod,
+        i.delayTime);
+}
+
+/**
+ * Constructs an <code>ImageData</code> loaded from a file with the
+ * specified name. Throws an error if an error occurs loading the
+ * image, or if the image has an unsupported type.
+ * <p>
+ * This constructor is provided for convenience when loading a single
+ * image only. If the file contains multiple images, only the first
+ * one will be loaded. To load multiple images, use 
+ * <code>ImageLoader.load()</code>.
+ * </p>
+ *
+ * @param filename the name of the file to load the image from (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image file contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
+ * </ul>
+ */
+public ImageData(String filename) {
+    ImageData[] data = ImageDataLoader.load(filename);
+    if (data.length < 1) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    ImageData i = data[0];
+    setAllFields(
+        i.width,
+        i.height,
+        i.depth,
+        i.scanlinePad,
+        i.bytesPerLine,
+        i.data,
+        i.palette,
+        i.transparentPixel,
+        i.maskData,
+        i.maskPad,
+        i.alphaData,
+        i.alpha,
+        i.type,
+        i.x,
+        i.y,
+        i.disposalMethod,
+        i.delayTime);
+}
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+ImageData() {
+}
+
+/**
+ * Constructs an image data by giving values for all non-computable fields.
+ * <p>
+ * This method is for internal use, and is not described further.
+ * </p>
+ */
+ImageData(
+    int width, int height, int depth, PaletteData palette,
+    int scanlinePad, byte[] data, int maskPad, byte[] maskData,
+    byte[] alphaData, int alpha, int transparentPixel, int type,
+    int x, int y, int disposalMethod, int delayTime)
+{
+
+    if (palette is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (!(depth is 1 || depth is 2 || depth is 4 || depth is 8
+        || depth is 16 || depth is 24 || depth is 32)) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (width <= 0 || height <= 0) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    if (scanlinePad is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO);
+
+    int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1))
+        / scanlinePad * scanlinePad;
+    
+    /*
+     * When the image is being loaded from a PNG, we need to use the theoretical minimum
+     * number of bytes per line to check whether there is enough data, because the actual
+     * number of bytes per line is calculated based on the given depth, which may be larger
+     * than the actual depth of the PNG.
+     */
+    int minBytesPerLine = type is DWT.IMAGE_PNG ? ((((width + 7) / 8) + 3) / 4) * 4 : bytesPerLine;
+    if (data !is null && data.length < minBytesPerLine * height) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    setAllFields(
+        width,
+        height,
+        depth,
+        scanlinePad,
+        bytesPerLine,
+        data !is null ? data : new byte[bytesPerLine * height],
+        palette,
+        transparentPixel,
+        maskData,
+        maskPad,
+        alphaData,
+        alpha,
+        type,
+        x,
+        y,
+        disposalMethod,
+        delayTime);
+}
+
+/**
+ * Initializes all fields in the receiver. This method must be called
+ * by all public constructors to ensure that all fields are initialized
+ * for a new ImageData object. If a new field is added to the class,
+ * then it must be added to this method.
+ * <p>
+ * This method is for internal use, and is not described further.
+ * </p>
+ */
+void setAllFields(int width, int height, int depth, int scanlinePad,
+    int bytesPerLine, byte[] data, PaletteData palette, int transparentPixel,
+    byte[] maskData, int maskPad, byte[] alphaData, int alpha,
+    int type, int x, int y, int disposalMethod, int delayTime) {
+
+    this.width = width;
+    this.height = height;
+    this.depth = depth;
+    this.scanlinePad = scanlinePad;
+    this.bytesPerLine = bytesPerLine;
+    this.data = data;
+    this.palette = palette;
+    this.transparentPixel = transparentPixel;
+    this.maskData = maskData;
+    this.maskPad = maskPad;
+    this.alphaData = alphaData;
+    this.alpha = alpha;
+    this.type = type;
+    this.x = x;
+    this.y = y;
+    this.disposalMethod = disposalMethod;
+    this.delayTime = delayTime;
+}
+
+/**  
+ * Invokes internal DWT functionality to create a new instance of
+ * this class.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>ImageData</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is subject
+ * to change without notice, and should never be called from
+ * application code.
+ * </p>
+ * <p>
+ * This method is for internal use, and is not described further.
+ * </p>
+ */
+public static ImageData internal_new(
+    int width, int height, int depth, PaletteData palette,
+    int scanlinePad, byte[] data, int maskPad, byte[] maskData,
+    byte[] alphaData, int alpha, int transparentPixel, int type,
+    int x, int y, int disposalMethod, int delayTime)
+{
+    return new ImageData(
+        width, height, depth, palette, scanlinePad, data, maskPad, maskData,
+        alphaData, alpha, transparentPixel, type, x, y, disposalMethod, delayTime);
+}
+
+ImageData colorMaskImage(int pixel) {
+    ImageData mask = new ImageData(width, height, 1, bwPalette(),
+        2, null, 0, null, null, -1, -1, DWT.IMAGE_UNDEFINED,
+        0, 0, 0, 0);
+    int[] row = new int[width];
+    for (int y = 0; y < height; y++) {
+        getPixels(0, y, width, row, 0);
+        for (int i = 0; i < width; i++) {
+            if (pixel !is -1 && row[i] is pixel) {
+                row[i] = 0;
+            } else {
+                row[i] = 1;
+            }
+        }
+        mask.setPixels(0, y, width, row, 0);
+    }
+    return mask;
+}
+
+static byte[] checkData(byte [] data) {
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return data;
+}
+
+/**
+ * Returns a new instance of the same class as the receiver,
+ * whose slots have been filled in with <em>copies</em> of
+ * the values in the slots of the receiver. That is, the
+ * returned object is a <em>deep copy</em> of the receiver.
+ *
+ * @return a copy of the receiver.
+ */
+public Object clone() {
+    byte[] cloneData = new byte[data.length];
+    System.arraycopy(data, 0, cloneData, 0, data.length);
+    byte[] cloneMaskData = null;
+    if (maskData !is null) {
+        cloneMaskData = new byte[maskData.length];
+        System.arraycopy(maskData, 0, cloneMaskData, 0, maskData.length);
+    }
+    byte[] cloneAlphaData = null;
+    if (alphaData !is null) {
+        cloneAlphaData = new byte[alphaData.length];
+        System.arraycopy(alphaData, 0, cloneAlphaData, 0, alphaData.length);
+    }
+    return new ImageData(
+        width,
+        height,
+        depth,
+        palette,
+        scanlinePad,
+        cloneData,
+        maskPad,
+        cloneMaskData,
+        cloneAlphaData,
+        alpha,
+        transparentPixel,
+        type,
+        x,
+        y,
+        disposalMethod,
+        delayTime);
+}
+
+/**
+ * Returns the alpha value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data.
+ *
+ * @param x the x coordinate of the pixel to get the alpha value of
+ * @param y the y coordinate of the pixel to get the alpha value of
+ * @return the alpha value at the given coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if either argument is out of range</li>
+ * </ul>
+ */
+public int getAlpha(int x, int y) {
+    if (x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+
+    if (alphaData is null) return 255;
+    return alphaData[y * width + x] & 0xFF;
+}
+
+/**
+ * Returns <code>getWidth</code> alpha values starting at offset
+ * <code>x</code> in scanline <code>y</code> in the receiver's alpha
+ * data starting at <code>startIndex</code>.
+ *
+ * @param x the x position of the pixel to begin getting alpha values
+ * @param y the y position of the pixel to begin getting alpha values
+ * @param getWidth the width of the data to get
+ * @param alphas the buffer in which to put the alpha values
+ * @param startIndex the offset into the image to begin getting alpha values
+ *
+ * @exception IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ */
+public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) {
+    if (alphas is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (getWidth is 0) return;
+
+    if (alphaData is null) {
+        int endIndex = startIndex + getWidth;
+        for (int i = startIndex; i < endIndex; i++) {
+            alphas[i] = (byte)255;
+        }
+        return;
+    }
+    // may throw an IndexOutOfBoundsException
+    System.arraycopy(alphaData, y * width + x, alphas, startIndex, getWidth);
+}
+
+/**
+ * Returns the pixel value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data.
+ *
+ * @param x the x position of the pixel to get
+ * @param y the y position of the pixel to get
+ * @return the pixel at the given coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if either argument is out of bounds</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public int getPixel(int x, int y) {
+    if (x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int index;
+    int theByte;
+    int mask;
+    switch (depth) {
+        case 32:
+            index = (y * bytesPerLine) + (x * 4);
+            return ((data[index] & 0xFF) << 24) + ((data[index+1] & 0xFF) << 16) +
+                    ((data[index+2] & 0xFF) << 8) + (data[index+3] & 0xFF);
+        case 24:
+            index = (y * bytesPerLine) + (x * 3);
+            return ((data[index] & 0xFF) << 16) + ((data[index+1] & 0xFF) << 8) +
+                (data[index+2] & 0xFF);
+        case 16:
+            index = (y * bytesPerLine) + (x * 2);
+            return ((data[index+1] & 0xFF) << 8) + (data[index] & 0xFF);
+        case 8:
+            index = (y * bytesPerLine) + x ;
+            return data[index] & 0xFF;
+        case 4:
+            index = (y * bytesPerLine) + (x >> 1);
+            theByte = data[index] & 0xFF;
+            if ((x & 0x1) is 0) {
+                return theByte >> 4;
+            } else {
+                return theByte & 0x0F;
+            }
+        case 2:
+            index = (y * bytesPerLine) + (x >> 2);
+            theByte = data[index] & 0xFF;
+            int offset = 3 - (x % 4);
+            mask = 3 << (offset * 2);
+            return (theByte & mask) >> (offset * 2);
+        case 1:
+            index = (y * bytesPerLine) + (x >> 3);
+            theByte = data[index] & 0xFF;
+            mask = 1 << (7 - (x & 0x7));
+            if ((theByte & mask) is 0) {
+                return 0;
+            } else {
+                return 1;
+            }
+    }
+    DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+    return 0;
+}
+
+/**
+ * Returns <code>getWidth</code> pixel values starting at offset
+ * <code>x</code> in scanline <code>y</code> in the receiver's
+ * data starting at <code>startIndex</code>.
+ *
+ * @param x the x position of the first pixel to get
+ * @param y the y position of the first pixel to get
+ * @param getWidth the width of the data to get
+ * @param pixels the buffer in which to put the pixels
+ * @param startIndex the offset into the byte array to begin storing pixels
+ *
+ * @exception IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4 or 8
+ *        (For higher depths, use the int[] version of this method.)</li>
+ * </ul>
+ */
+public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) {
+    if (pixels is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (getWidth is 0) return;
+    int index;
+    int theByte;
+    int mask = 0;
+    int n = getWidth;
+    int i = startIndex;
+    int srcX = x, srcY = y;
+    switch (depth) {
+        case 8:
+            index = (y * bytesPerLine) + x;
+            for (int j = 0; j < getWidth; j++) {
+                pixels[i] = data[index];
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index++;
+                }
+            }
+            return;
+        case 4:
+            index = (y * bytesPerLine) + (x >> 1);
+            if ((x & 0x1) is 1) {
+                theByte = data[index] & 0xFF;
+                pixels[i] = (byte)(theByte & 0x0F);
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index++;
+                }
+            }
+            while (n > 1) {
+                theByte = data[index] & 0xFF;
+                pixels[i] = (byte)(theByte >> 4);
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    pixels[i] = (byte)(theByte & 0x0F);
+                    i++;
+                    n--;
+                    srcX++;
+                    if (srcX >= width) {
+                        srcY++;
+                        index = srcY * bytesPerLine;
+                        srcX = 0;
+                    } else {
+                        index++;
+                    }
+                }
+            }
+            if (n > 0) {
+                theByte = data[index] & 0xFF;
+                pixels[i] = (byte)(theByte >> 4);
+            }
+            return;
+        case 2:
+            index = (y * bytesPerLine) + (x >> 2);
+            theByte = data[index] & 0xFF;
+            int offset;
+            while (n > 0) {
+                offset = 3 - (srcX % 4);
+                mask = 3 << (offset * 2);
+                pixels[i] = (byte)((theByte & mask) >> (offset * 2));
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    if (n > 0) theByte = data[index] & 0xFF;
+                    srcX = 0;
+                } else {
+                    if (offset is 0) {
+                        index++;
+                        theByte = data[index] & 0xFF;
+                    }
+                }
+            }
+            return;
+        case 1:
+            index = (y * bytesPerLine) + (x >> 3);
+            theByte = data[index] & 0xFF;
+            while (n > 0) {
+                mask = 1 << (7 - (srcX & 0x7));
+                if ((theByte & mask) is 0) {
+                    pixels[i] = 0;
+                } else {
+                    pixels[i] = 1;
+                }
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    if (n > 0) theByte = data[index] & 0xFF;
+                    srcX = 0;
+                } else {
+                    if (mask is 1) {
+                        index++;
+                        if (n > 0) theByte = data[index] & 0xFF;
+                    }
+                }
+            }
+            return;
+    }
+    DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Returns <code>getWidth</code> pixel values starting at offset
+ * <code>x</code> in scanline <code>y</code> in the receiver's
+ * data starting at <code>startIndex</code>.
+ *
+ * @param x the x position of the first pixel to get
+ * @param y the y position of the first pixel to get
+ * @param getWidth the width of the data to get
+ * @param pixels the buffer in which to put the pixels
+ * @param startIndex the offset into the buffer to begin storing pixels
+ *
+ * @exception IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) {
+    if (pixels is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (getWidth is 0) return;
+    int index;
+    int theByte;
+    int mask;
+    int n = getWidth;
+    int i = startIndex;
+    int srcX = x, srcY = y;
+    switch (depth) {
+        case 32:
+            index = (y * bytesPerLine) + (x * 4);
+            i = startIndex;
+            for (int j = 0; j < getWidth; j++) {
+                pixels[i] = ((data[index] & 0xFF) << 24) | ((data[index+1] & 0xFF) << 16)
+                    | ((data[index+2] & 0xFF) << 8) | (data[index+3] & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index += 4;
+                }
+            }
+            return;
+        case 24:
+            index = (y * bytesPerLine) + (x * 3);
+            for (int j = 0; j < getWidth; j++) {
+                pixels[i] = ((data[index] & 0xFF) << 16) | ((data[index+1] & 0xFF) << 8)
+                    | (data[index+2] & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index += 3;
+                }
+            }
+            return;
+        case 16:
+            index = (y * bytesPerLine) + (x * 2);
+            for (int j = 0; j < getWidth; j++) {
+                pixels[i] = ((data[index+1] & 0xFF) << 8) + (data[index] & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index += 2;
+                }
+            }
+            return;
+        case 8:
+            index = (y * bytesPerLine) + x;
+            for (int j = 0; j < getWidth; j++) {
+                pixels[i] = data[index] & 0xFF;
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index++;
+                }
+            }
+            return;
+        case 4:
+            index = (y * bytesPerLine) + (x >> 1);
+            if ((x & 0x1) is 1) {
+                theByte = data[index] & 0xFF;
+                pixels[i] = theByte & 0x0F;
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index++;
+                }
+            }
+            while (n > 1) {
+                theByte = data[index] & 0xFF;
+                pixels[i] = theByte >> 4;
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    pixels[i] = theByte & 0x0F;
+                    i++;
+                    n--;
+                    srcX++;
+                    if (srcX >= width) {
+                        srcY++;
+                        index = srcY * bytesPerLine;
+                        srcX = 0;
+                    } else {
+                        index++;
+                    }
+                }
+            }
+            if (n > 0) {
+                theByte = data[index] & 0xFF;
+                pixels[i] = theByte >> 4;
+            }
+            return;
+        case 2:
+            index = (y * bytesPerLine) + (x >> 2);
+            theByte = data[index] & 0xFF;
+            int offset;
+            while (n > 0) {
+                offset = 3 - (srcX % 4);
+                mask = 3 << (offset * 2);
+                pixels[i] = (byte)((theByte & mask) >> (offset * 2));
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    if (n > 0) theByte = data[index] & 0xFF;
+                    srcX = 0;
+                } else {
+                    if (offset is 0) {
+                        index++;
+                        theByte = data[index] & 0xFF;
+                    }
+                }
+            }
+            return;
+        case 1:
+            index = (y * bytesPerLine) + (x >> 3);
+            theByte = data[index] & 0xFF;
+            while (n > 0) {
+                mask = 1 << (7 - (srcX & 0x7));
+                if ((theByte & mask) is 0) {
+                    pixels[i] = 0;
+                } else {
+                    pixels[i] = 1;
+                }
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    if (n > 0) theByte = data[index] & 0xFF;
+                    srcX = 0;
+                } else {
+                    if (mask is 1) {
+                        index++;
+                        if (n > 0) theByte = data[index] & 0xFF;
+                    }
+                }
+            }
+            return;
+    }
+    DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Returns an array of <code>RGB</code>s which comprise the
+ * indexed color table of the receiver, or null if the receiver
+ * has a direct color model.
+ *
+ * @return the RGB values for the image or null if direct color
+ *
+ * @see PaletteData#getRGBs()
+ */
+public RGB[] getRGBs() {
+    return palette.getRGBs();
+}
+
+/**
+ * Returns an <code>ImageData</code> which specifies the
+ * transparency mask information for the receiver. If the
+ * receiver has no transparency or is not an icon, returns
+ * an opaque mask.
+ *
+ * @return the transparency mask
+ */
+public ImageData getTransparencyMask() {
+    if (getTransparencyType() is DWT.TRANSPARENCY_MASK) {
+        return new ImageData(width, height, 1, bwPalette(), maskPad, maskData);
+    } else {
+        return colorMaskImage(transparentPixel);
+    }
+}
+
+/**
+ * Returns the image transparency type, which will be one of
+ * <code>DWT.TRANSPARENCY_NONE</code>, <code>DWT.TRANSPARENCY_MASK</code>,
+ * <code>DWT.TRANSPARENCY_PIXEL</code> or <code>DWT.TRANSPARENCY_ALPHA</code>.
+ *
+ * @return the receiver's transparency type
+ */
+public int getTransparencyType() {
+    if (maskData !is null) return DWT.TRANSPARENCY_MASK;
+    if (transparentPixel !is -1) return DWT.TRANSPARENCY_PIXEL;
+    if (alphaData !is null) return DWT.TRANSPARENCY_ALPHA;
+    return DWT.TRANSPARENCY_NONE;
+}
+
+/**
+ * Returns the byte order of the receiver.
+ * 
+ * @return MSB_FIRST or LSB_FIRST
+ */
+int getByteOrder() {
+    return depth !is 16 ? MSB_FIRST : LSB_FIRST;
+}
+
+/**
+ * Returns a copy of the receiver which has been stretched or
+ * shrunk to the specified size. If either the width or height
+ * is negative, the resulting image will be inverted in the
+ * associated axis.
+ *
+ * @param width the width of the new ImageData
+ * @param height the height of the new ImageData
+ * @return a scaled copy of the image
+ */
+public ImageData scaledTo(int width, int height) {
+    /* Create a destination image with no data */
+    final bool flipX = (width < 0);
+    if (flipX) width = - width;
+    final bool flipY = (height < 0);
+    if (flipY) height = - height;
+
+    ImageData dest = new ImageData(
+        width, height, depth, palette,
+        scanlinePad, null, 0, null,
+        null, -1, transparentPixel, type,
+        x, y, disposalMethod, delayTime);
+
+    /* Scale the image contents */
+    if (palette.isDirect) blit(BLIT_SRC,
+        this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, 0, 0, 0,
+        ALPHA_OPAQUE, null, 0, 0, 0,
+        dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, 0, 0, 0,
+        flipX, flipY);
+    else blit(BLIT_SRC,
+        this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, null, null, null,
+        ALPHA_OPAQUE, null, 0, 0, 0,
+        dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, null, null, null,
+        flipX, flipY);
+    
+    /* Scale the image mask or alpha */
+    if (maskData !is null) {
+        dest.maskPad = this.maskPad;
+        int destBpl = (dest.width + 7) / 8;
+        destBpl = (destBpl + (dest.maskPad - 1)) / dest.maskPad * dest.maskPad;
+        dest.maskData = new byte[destBpl * dest.height];
+        int srcBpl = (this.width + 7) / 8;
+        srcBpl = (srcBpl + (this.maskPad - 1)) / this.maskPad * this.maskPad;
+        blit(BLIT_SRC,
+            this.maskData, 1, srcBpl, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
+            ALPHA_OPAQUE, null, 0, 0, 0,
+            dest.maskData, 1, destBpl, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
+            flipX, flipY);
+    } else if (alpha !is -1) {
+        dest.alpha = this.alpha;
+    } else if (alphaData !is null) {
+        dest.alphaData = new byte[dest.width * dest.height];
+        blit(BLIT_SRC,
+            this.alphaData, 8, this.width, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
+            ALPHA_OPAQUE, null, 0, 0, 0,
+            dest.alphaData, 8, dest.width, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
+            flipX, flipY);
+    }
+    return dest;
+}
+
+/**
+ * Sets the alpha value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data.
+ *
+ * @param x the x coordinate of the alpha value to set
+ * @param y the y coordinate of the alpha value to set
+ * @param alpha the value to set the alpha to
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *  </ul>
+ */
+public void setAlpha(int x, int y, int alpha) {
+    if (x >= width || y >= height || x < 0 || y < 0 || alpha < 0 || alpha > 255)
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    
+    if (alphaData is null) alphaData = new byte[width * height];
+    alphaData[y * width + x] = (byte)alpha; 
+}
+
+/**
+ * Sets the alpha values starting at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data to the
+ * values from the array <code>alphas</code> starting at
+ * <code>startIndex</code>.
+ *
+ * @param x the x coordinate of the pixel to being setting the alpha values
+ * @param y the y coordinate of the pixel to being setting the alpha values
+ * @param putWidth the width of the alpha values to set
+ * @param alphas the alpha values to set
+ * @param startIndex the index at which to begin setting
+ *
+ * @exception IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ */
+public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) {
+    if (alphas is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (putWidth is 0) return;
+    
+    if (alphaData is null) alphaData = new byte[width * height];
+    // may throw an IndexOutOfBoundsException
+    System.arraycopy(alphas, startIndex, alphaData, y * width + x, putWidth);
+}
+
+/**
+ * Sets the pixel value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data.
+ *
+ * @param x the x coordinate of the pixel to set
+ * @param y the y coordinate of the pixel to set
+ * @param pixelValue the value to set the pixel to
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void setPixel(int x, int y, int pixelValue) {
+    if (x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int index;
+    byte theByte;
+    int mask;
+    switch (depth) {
+        case 32:
+            index = (y * bytesPerLine) + (x * 4);
+            data[index]  = (byte)((pixelValue >> 24) & 0xFF);
+            data[index + 1] = (byte)((pixelValue >> 16) & 0xFF);
+            data[index + 2] = (byte)((pixelValue >> 8) & 0xFF);
+            data[index + 3] = (byte)(pixelValue & 0xFF);
+            return;
+        case 24:
+            index = (y * bytesPerLine) + (x * 3);
+            data[index] = (byte)((pixelValue >> 16) & 0xFF);
+            data[index + 1] = (byte)((pixelValue >> 8) & 0xFF);
+            data[index + 2] = (byte)(pixelValue & 0xFF);
+            return;
+        case 16:
+            index = (y * bytesPerLine) + (x * 2);
+            data[index + 1] = (byte)((pixelValue >> 8) & 0xFF);
+            data[index] = (byte)(pixelValue & 0xFF);
+            return;
+        case 8:
+            index = (y * bytesPerLine) + x ;
+            data[index] = (byte)(pixelValue & 0xFF);
+            return;
+        case 4:
+            index = (y * bytesPerLine) + (x >> 1);
+            if ((x & 0x1) is 0) {
+                data[index] = (byte)((data[index] & 0x0F) | ((pixelValue & 0x0F) << 4));
+            } else {
+                data[index] = (byte)((data[index] & 0xF0) | (pixelValue & 0x0F));
+            }
+            return;
+        case 2:
+            index = (y * bytesPerLine) + (x >> 2);
+            theByte = data[index];
+            int offset = 3 - (x % 4);
+            mask = 0xFF ^ (3 << (offset * 2));
+            data[index] = (byte)((data[index] & mask) | (pixelValue << (offset * 2)));
+            return;
+        case 1:
+            index = (y * bytesPerLine) + (x >> 3);
+            theByte = data[index];
+            mask = 1 << (7 - (x & 0x7));
+            if ((pixelValue & 0x1) is 1) {
+                data[index] = (byte)(theByte | mask);
+            } else {
+                data[index] = (byte)(theByte & (mask ^ -1));
+            }
+            return;
+    }
+    DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Sets the pixel values starting at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data to the
+ * values from the array <code>pixels</code> starting at
+ * <code>startIndex</code>.
+ *
+ * @param x the x position of the pixel to set
+ * @param y the y position of the pixel to set
+ * @param putWidth the width of the pixels to set
+ * @param pixels the pixels to set
+ * @param startIndex the index at which to begin setting
+ *
+ * @exception IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8
+ *        (For higher depths, use the int[] version of this method.)</li>
+ * </ul>
+ */
+public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) {
+    if (pixels is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (putWidth is 0) return;
+    int index;
+    int theByte;
+    int mask;
+    int n = putWidth;
+    int i = startIndex;
+    int srcX = x, srcY = y;
+    switch (depth) {
+        case 8:
+            index = (y * bytesPerLine) + x;
+            for (int j = 0; j < putWidth; j++) {
+                data[index] = (byte)(pixels[i] & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index++;
+                }
+            }
+            return;
+        case 4:
+            index = (y * bytesPerLine) + (x >> 1);
+            bool high = (x & 0x1) is 0;
+            while (n > 0) {
+                theByte = pixels[i] & 0x0F;
+                if (high) {
+                    data[index] = (byte)((data[index] & 0x0F) | (theByte << 4));
+                } else {
+                    data[index] = (byte)((data[index] & 0xF0) | theByte);
+                }
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    high = true;
+                    srcX = 0;
+                } else {
+                    if (!high) index++;
+                    high = !high;
+                }
+            }
+            return;
+        case 2:
+            byte [] masks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F };
+            index = (y * bytesPerLine) + (x >> 2);
+            int offset = 3 - (x % 4);
+            while (n > 0) {
+                theByte = pixels[i] & 0x3;
+                data[index] = (byte)((data[index] & masks[offset]) | (theByte << (offset * 2)));
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    offset = 0;
+                    srcX = 0;
+                } else {
+                    if (offset is 0) {
+                        index++;
+                        offset = 3;
+                    } else {
+                        offset--;
+                    }
+                }
+            }
+            return;
+        case 1:
+            index = (y * bytesPerLine) + (x >> 3);
+            while (n > 0) {
+                mask = 1 << (7 - (srcX & 0x7));
+                if ((pixels[i] & 0x1) is 1) {
+                    data[index] = (byte)((data[index] & 0xFF) | mask);
+                } else {
+                    data[index] = (byte)((data[index] & 0xFF) & (mask ^ -1));
+                }
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    if (mask is 1) {
+                        index++;
+                    }
+                }
+            }
+            return;
+    }
+    DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Sets the pixel values starting at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data to the
+ * values from the array <code>pixels</code> starting at
+ * <code>startIndex</code>.
+ *
+ * @param x the x position of the pixel to set
+ * @param y the y position of the pixel to set
+ * @param putWidth the width of the pixels to set
+ * @param pixels the pixels to set
+ * @param startIndex the index at which to begin setting
+ *
+ * @exception IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) {
+    if (pixels is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (putWidth is 0) return;
+    int index;
+    int theByte;
+    int mask;
+    int n = putWidth;
+    int i = startIndex;
+    int pixel;
+    int srcX = x, srcY = y;
+    switch (depth) {
+        case 32:
+            index = (y * bytesPerLine) + (x * 4);
+            for (int j = 0; j < putWidth; j++) {
+                pixel = pixels[i];
+                data[index] = (byte)((pixel >> 24) & 0xFF);
+                data[index + 1] = (byte)((pixel >> 16) & 0xFF);
+                data[index + 2] = (byte)((pixel >> 8) & 0xFF);
+                data[index + 3] = (byte)(pixel & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index += 4;
+                }
+            }
+            return;
+        case 24:
+            index = (y * bytesPerLine) + (x * 3);
+            for (int j = 0; j < putWidth; j++) {
+                pixel = pixels[i];
+                data[index] = (byte)((pixel >> 16) & 0xFF);
+                data[index + 1] = (byte)((pixel >> 8) & 0xFF);
+                data[index + 2] = (byte)(pixel & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index += 3;
+                }
+            }
+            return;
+        case 16:
+            index = (y * bytesPerLine) + (x * 2);
+            for (int j = 0; j < putWidth; j++) {
+                pixel = pixels[i];
+                data[index] = (byte)(pixel & 0xFF);
+                data[index + 1] = (byte)((pixel >> 8) & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index += 2;
+                }
+            }
+            return;
+        case 8:
+            index = (y * bytesPerLine) + x;
+            for (int j = 0; j < putWidth; j++) {
+                data[index] = (byte)(pixels[i] & 0xFF);
+                i++;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    index++;
+                }
+            }
+            return;
+        case 4:
+            index = (y * bytesPerLine) + (x >> 1);
+            bool high = (x & 0x1) is 0;
+            while (n > 0) {
+                theByte = pixels[i] & 0x0F;
+                if (high) {
+                    data[index] = (byte)((data[index] & 0x0F) | (theByte << 4));
+                } else {
+                    data[index] = (byte)((data[index] & 0xF0) | theByte);
+                }
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    high = true;
+                    srcX = 0;
+                } else {
+                    if (!high) index++;
+                    high = !high;
+                }
+            }
+            return;
+        case 2:
+            byte [] masks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F };
+            index = (y * bytesPerLine) + (x >> 2);
+            int offset = 3 - (x % 4);
+            while (n > 0) {
+                theByte = pixels[i] & 0x3;
+                data[index] = (byte)((data[index] & masks[offset]) | (theByte << (offset * 2)));
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    offset = 3;
+                    srcX = 0;
+                } else {
+                    if (offset is 0) {
+                        index++;
+                        offset = 3;
+                    } else {
+                        offset--;
+                    }
+                }
+            }
+            return;
+        case 1:
+            index = (y * bytesPerLine) + (x >> 3);
+            while (n > 0) {
+                mask = 1 << (7 - (srcX & 0x7));
+                if ((pixels[i] & 0x1) is 1) {
+                    data[index] = (byte)((data[index] & 0xFF) | mask);
+                } else {
+                    data[index] = (byte)((data[index] & 0xFF) & (mask ^ -1));
+                }
+                i++;
+                n--;
+                srcX++;
+                if (srcX >= width) {
+                    srcY++;
+                    index = srcY * bytesPerLine;
+                    srcX = 0;
+                } else {
+                    if (mask is 1) {
+                        index++;
+                    }
+                }
+            }
+            return;
+    }
+    DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Returns a palette with 2 colors: black & white.
+ */
+static PaletteData bwPalette() {
+    return new PaletteData(new RGB[] {new RGB(0, 0, 0), new RGB(255, 255, 255)});
+}
+
+/**
+ * Gets the offset of the most significant bit for
+ * the given mask.
+ */
+static int getMSBOffset(int mask) {
+    for (int i = 31; i >= 0; i--) {
+        if (((mask >> i) & 0x1) !is 0) return i + 1;
+    }
+    return 0;
+}
+
+/**
+ * Finds the closest match.
+ */
+static int closestMatch(int depth, byte red, byte green, byte blue, int redMask, int greenMask, int blueMask, byte[] reds, byte[] greens, byte[] blues) {
+    if (depth > 8) {
+        int rshift = 32 - getMSBOffset(redMask);
+        int gshift = 32 - getMSBOffset(greenMask);
+        int bshift = 32 - getMSBOffset(blueMask);
+        return (((red << 24) >>> rshift) & redMask) |
+            (((green << 24) >>> gshift) & greenMask) |
+            (((blue << 24) >>> bshift) & blueMask);
+    }
+    int r, g, b;
+    int minDistance = 0x7fffffff;
+    int nearestPixel = 0;
+    int n = reds.length;
+    for (int j = 0; j < n; j++) {
+        r = (reds[j] & 0xFF) - (red & 0xFF);
+        g = (greens[j] & 0xFF) - (green & 0xFF);
+        b = (blues[j] & 0xFF) - (blue & 0xFF);
+        int distance = r*r + g*g + b*b;
+        if (distance < minDistance) {
+            nearestPixel = j;
+            if (distance is 0) break;
+            minDistance = distance;
+        }
+    }
+    return nearestPixel;
+}
+
+static final ImageData convertMask(ImageData mask) {
+    if (mask.depth is 1) return mask;
+    PaletteData palette = new PaletteData(new RGB[] {new RGB(0, 0, 0), new RGB(255,255,255)});
+    ImageData newMask = new ImageData(mask.width, mask.height, 1, palette);
+    /* Find index of black in mask palette */
+    int blackIndex = 0;
+    RGB[] rgbs = mask.getRGBs();
+    if (rgbs !is null) {
+        while (blackIndex < rgbs.length) {
+            if (rgbs[blackIndex].equals(palette.colors[0])) break;
+            blackIndex++;
+        }
+    }
+    int[] pixels = new int[mask.width];
+    for (int y = 0; y < mask.height; y++) {
+        mask.getPixels(0, y, mask.width, pixels, 0);
+        for (int i = 0; i < pixels.length; i++) {
+            if (pixels[i] is blackIndex) {
+                pixels[i] = 0;
+            } else {
+                pixels[i] = 1;
+            }
+        }
+        newMask.setPixels(0, y, mask.width, pixels, 0);
+    }
+    return newMask;
+}
+
+static final byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) {
+    if (pad is newPad) return data;
+    int stride = (width * depth + 7) / 8;
+    int bpl = (stride + (pad - 1)) / pad * pad; 
+    int newBpl = (stride + (newPad - 1)) / newPad * newPad;
+    byte[] newData = new byte[height * newBpl];
+    int srcIndex = 0, destIndex = 0;
+    for (int y = 0; y < height; y++) {
+        System.arraycopy(data, srcIndex, newData, destIndex, stride);
+        srcIndex += bpl;
+        destIndex += newBpl;
+    }
+    return newData;
+}
+
+/**
+ * Blit operation bits to be OR'ed together to specify the desired operation.
+ */
+static final int
+    BLIT_SRC = 1,     // copy source directly, else applies logic operations
+    BLIT_ALPHA = 2,   // enable alpha blending
+    BLIT_DITHER = 4;  // enable dithering in low color modes
+
+/**
+ * Alpha mode, values 0 - 255 specify global alpha level
+ */
+static final int
+    ALPHA_OPAQUE = 255,           // Fully opaque (ignores any alpha data)
+    ALPHA_TRANSPARENT = 0,        // Fully transparent (ignores any alpha data)
+    ALPHA_CHANNEL_SEPARATE = -1,  // Use alpha channel from separate alphaData
+    ALPHA_CHANNEL_SOURCE = -2,    // Use alpha channel embedded in sourceData
+    ALPHA_MASK_UNPACKED = -3,     // Use transparency mask formed by bytes in alphaData (non-zero is opaque)
+    ALPHA_MASK_PACKED = -4,       // Use transparency mask formed by packed bits in alphaData
+    ALPHA_MASK_INDEX = -5,        // Consider source palette indices transparent if in alphaData array
+    ALPHA_MASK_RGB = -6;          // Consider source RGBs transparent if in RGB888 format alphaData array
+
+/**
+ * Byte and bit order constants.
+ */
+static final int LSB_FIRST = 0;
+static final int MSB_FIRST = 1;
+
+/**
+ * Data types (internal)
+ */
+private static final int
+    // direct / true color formats with arbitrary masks & shifts
+    TYPE_GENERIC_8 = 0,
+    TYPE_GENERIC_16_MSB = 1,
+    TYPE_GENERIC_16_LSB = 2,
+    TYPE_GENERIC_24 = 3,
+    TYPE_GENERIC_32_MSB = 4,
+    TYPE_GENERIC_32_LSB = 5,
+    // palette indexed color formats
+    TYPE_INDEX_8 = 6,
+    TYPE_INDEX_4 = 7,
+    TYPE_INDEX_2 = 8,
+    TYPE_INDEX_1_MSB = 9,
+    TYPE_INDEX_1_LSB = 10;
+
+/**
+ * Blits a direct palette image into a direct palette image.
+ * <p>
+ * Note: When the source and destination depth, order and masks
+ * are pairwise equal and the blitter operation is BLIT_SRC,
+ * the masks are ignored.  Hence when not changing the image
+ * data format, 0 may be specified for the masks.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 8, 16, 24, 32
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 16 or 32
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcRedMask the source red channel mask
+ * @param srcGreenMask the source green channel mask
+ * @param srcBlueMask the source blue channel mask
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 8, 16, 24, 32
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 16 or 32
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destRedMask the destination red channel mask
+ * @param destGreenMask the destination green channel mask
+ * @param destBlueMask the destination blue channel mask
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+    byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+    int srcX, int srcY, int srcWidth, int srcHeight,
+    int srcRedMask, int srcGreenMask, int srcBlueMask,
+    int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+    byte[] destData, int destDepth, int destStride, int destOrder,
+    int destX, int destY, int destWidth, int destHeight,
+    int destRedMask, int destGreenMask, int destBlueMask,
+    bool flipX, bool flipY) {
+    if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode is ALPHA_TRANSPARENT)) return;
+
+    // these should be supplied as params later
+    final int srcAlphaMask = 0, destAlphaMask = 0;
+
+    /*** Prepare scaling data ***/
+    final int dwm1 = destWidth - 1;
+    final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+    final int dhm1 = destHeight - 1;
+    final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+    /*** Prepare source-related data ***/
+    final int sbpp, stype;
+    switch (srcDepth) {
+        case 8:
+            sbpp = 1;
+            stype = TYPE_GENERIC_8;
+            break;
+        case 16:
+            sbpp = 2;
+            stype = (srcOrder is MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+            break;
+        case 24:
+            sbpp = 3;
+            stype = TYPE_GENERIC_24;
+            break;
+        case 32:
+            sbpp = 4;
+            stype = (srcOrder is MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid source type");
+            return;
+    }           
+    int spr = srcY * srcStride + srcX * sbpp;
+
+    /*** Prepare destination-related data ***/
+    final int dbpp, dtype;
+    switch (destDepth) {
+        case 8:
+            dbpp = 1;
+            dtype = TYPE_GENERIC_8;
+            break;
+        case 16:
+            dbpp = 2;
+            dtype = (destOrder is MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+            break;
+        case 24:
+            dbpp = 3;
+            dtype = TYPE_GENERIC_24;
+            break;
+        case 32:
+            dbpp = 4;
+            dtype = (destOrder is MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid destination type");
+            return;
+    }           
+    int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
+    final int dprxi = (flipX) ? -dbpp : dbpp;
+    final int dpryi = (flipY) ? -destStride : destStride;
+
+    /*** Prepare special processing data ***/
+    int apr;
+    if ((op & BLIT_ALPHA) !is 0) {
+        switch (alphaMode) {
+            case ALPHA_MASK_UNPACKED:
+            case ALPHA_CHANNEL_SEPARATE:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_PACKED:
+                if (alphaData is null) alphaMode = 0x10000;
+                alphaStride <<= 3;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_INDEX:
+                //throw new IllegalArgumentException("Invalid alpha type");
+                return;
+            case ALPHA_MASK_RGB:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = 0;
+                break;
+            default:
+                alphaMode = (alphaMode << 16) / 255; // prescale
+            case ALPHA_CHANNEL_SOURCE:
+                apr = 0;
+                break;
+        }
+    } else {
+        alphaMode = 0x10000;
+        apr = 0;
+    }
+
+    /*** Blit ***/
+    int dp = dpr;
+    int sp = spr;
+    if ((alphaMode is 0x10000) && (stype is dtype) &&
+        (srcRedMask is destRedMask) && (srcGreenMask is destGreenMask) &&
+        (srcBlueMask is destBlueMask) && (srcAlphaMask is destAlphaMask)) {
+        /*** Fast blit (straight copy) ***/
+        switch (sbpp) {
+            case 1:
+                for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                    for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                        destData[dp] = srcData[sp];
+                        sp += (sfx >>> 16);
+                    }
+                }
+                break;                  
+            case 2:
+                for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                    for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                        destData[dp] = srcData[sp];
+                        destData[dp + 1] = srcData[sp + 1];
+                        sp += (sfx >>> 16) * 2;
+                    }
+                }
+                break;
+            case 3:
+                for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                    for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                        destData[dp] = srcData[sp];
+                        destData[dp + 1] = srcData[sp + 1];
+                        destData[dp + 2] = srcData[sp + 2];
+                        sp += (sfx >>> 16) * 3;
+                    }
+                }
+                break;
+            case 4:
+                for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                    for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                        destData[dp] = srcData[sp];
+                        destData[dp + 1] = srcData[sp + 1];
+                        destData[dp + 2] = srcData[sp + 2];
+                        destData[dp + 3] = srcData[sp + 3];
+                        sp += (sfx >>> 16) * 4;
+                    }
+                }
+                break;
+        }
+        return;
+    }
+    /*** Comprehensive blit (apply transformations) ***/
+    final int srcRedShift = getChannelShift(srcRedMask);
+    final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
+    final int srcGreenShift = getChannelShift(srcGreenMask);
+    final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
+    final int srcBlueShift = getChannelShift(srcBlueMask);
+    final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
+    final int srcAlphaShift = getChannelShift(srcAlphaMask);
+    final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
+
+    final int destRedShift = getChannelShift(destRedMask);
+    final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
+    final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
+    final int destRedPreShift = 8 - destRedWidth;
+    final int destGreenShift = getChannelShift(destGreenMask);
+    final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
+    final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
+    final int destGreenPreShift = 8 - destGreenWidth;
+    final int destBlueShift = getChannelShift(destBlueMask);
+    final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
+    final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
+    final int destBluePreShift = 8 - destBlueWidth;
+    final int destAlphaShift = getChannelShift(destAlphaMask);
+    final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
+    final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
+    final int destAlphaPreShift = 8 - destAlphaWidth;
+
+    int ap = apr, alpha = alphaMode;
+    int r = 0, g = 0, b = 0, a = 0;
+    int rq = 0, gq = 0, bq = 0, aq = 0;
+    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+            sp = spr += (sfy >>> 16) * srcStride,
+            ap = apr += (sfy >>> 16) * alphaStride,
+            sfy = (sfy & 0xffff) + sfyi,
+            dp = dpr += dpryi) {
+        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+                dp += dprxi,
+                sfx = (sfx & 0xffff) + sfxi) {
+            /*** READ NEXT PIXEL ***/
+            switch (stype) {
+                case TYPE_GENERIC_8: {
+                    final int data = srcData[sp] & 0xff;
+                    sp += (sfx >>> 16);
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_16_MSB: {
+                    final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
+                    sp += (sfx >>> 16) * 2;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_16_LSB: {
+                    final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
+                    sp += (sfx >>> 16) * 2;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_24: {
+                    final int data = (( ((srcData[sp] & 0xff) << 8) |
+                        (srcData[sp + 1] & 0xff)) << 8) |
+                        (srcData[sp + 2] & 0xff);
+                    sp += (sfx >>> 16) * 3;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_32_MSB: {
+                    final int data = (( (( ((srcData[sp] & 0xff) << 8) |
+                        (srcData[sp + 1] & 0xff)) << 8) |
+                        (srcData[sp + 2] & 0xff)) << 8) |
+                        (srcData[sp + 3] & 0xff);
+                    sp += (sfx >>> 16) * 4;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_32_LSB: {
+                    final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
+                        (srcData[sp + 2] & 0xff)) << 8) |
+                        (srcData[sp + 1] & 0xff)) << 8) |
+                        (srcData[sp] & 0xff);
+                    sp += (sfx >>> 16) * 4;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+            }
+
+            /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+            switch (alphaMode) {
+                case ALPHA_CHANNEL_SEPARATE:
+                    alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_CHANNEL_SOURCE:
+                    alpha = (a << 16) / 255;
+                    break;
+                case ALPHA_MASK_UNPACKED:
+                    alpha = (alphaData[ap] !is 0) ? 0x10000 : 0;
+                    ap += (sfx >> 16);
+                    break;                      
+                case ALPHA_MASK_PACKED:
+                    alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_MASK_RGB:
+                    alpha = 0x10000;
+                    for (int i = 0; i < alphaData.length; i += 3) {
+                        if ((r is alphaData[i]) && (g is alphaData[i + 1]) && (b is alphaData[i + 2])) {
+                            alpha = 0x0000;
+                            break;
+                        }
+                    }
+                    break;
+            }
+            if (alpha !is 0x10000) {
+                if (alpha is 0x0000) continue;
+                switch (dtype) {
+                    case TYPE_GENERIC_8: {
+                        final int data = destData[dp] & 0xff;
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_16_MSB: {
+                        final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_16_LSB: {
+                        final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_24: {
+                        final int data = (( ((destData[dp] & 0xff) << 8) |
+                            (destData[dp + 1] & 0xff)) << 8) |
+                            (destData[dp + 2] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_32_MSB: {
+                        final int data = (( (( ((destData[dp] & 0xff) << 8) |
+                            (destData[dp + 1] & 0xff)) << 8) |
+                            (destData[dp + 2] & 0xff)) << 8) |
+                            (destData[dp + 3] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_32_LSB: {
+                        final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
+                            (destData[dp + 2] & 0xff)) << 8) |
+                            (destData[dp + 1] & 0xff)) << 8) |
+                            (destData[dp] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                }
+                // Perform alpha blending
+                a = aq + ((a - aq) * alpha >> 16);
+                r = rq + ((r - rq) * alpha >> 16);
+                g = gq + ((g - gq) * alpha >> 16);
+                b = bq + ((b - bq) * alpha >> 16);
+            }
+
+            /*** WRITE NEXT PIXEL ***/
+            final int data = 
+                (r >>> destRedPreShift << destRedShift) |
+                (g >>> destGreenPreShift << destGreenShift) |
+                (b >>> destBluePreShift << destBlueShift) |
+                (a >>> destAlphaPreShift << destAlphaShift);
+            switch (dtype) {
+                case TYPE_GENERIC_8: {
+                    destData[dp] = (byte) data;
+                } break;
+                case TYPE_GENERIC_16_MSB: {
+                    destData[dp] = (byte) (data >>> 8);
+                    destData[dp + 1] = (byte) (data & 0xff);
+                } break;
+                case TYPE_GENERIC_16_LSB: {
+                    destData[dp] = (byte) (data & 0xff);
+                    destData[dp + 1] = (byte) (data >>> 8);
+                } break;
+                case TYPE_GENERIC_24: {
+                    destData[dp] = (byte) (data >>> 16);
+                    destData[dp + 1] = (byte) (data >>> 8);
+                    destData[dp + 2] = (byte) (data & 0xff);
+                } break;
+                case TYPE_GENERIC_32_MSB: {
+                    destData[dp] = (byte) (data >>> 24);
+                    destData[dp + 1] = (byte) (data >>> 16);
+                    destData[dp + 2] = (byte) (data >>> 8);
+                    destData[dp + 3] = (byte) (data & 0xff);
+                } break;
+                case TYPE_GENERIC_32_LSB: {
+                    destData[dp] = (byte) (data & 0xff);
+                    destData[dp + 1] = (byte) (data >>> 8);
+                    destData[dp + 2] = (byte) (data >>> 16);
+                    destData[dp + 3] = (byte) (data >>> 24);
+                } break;
+            }
+        }
+    }           
+}
+
+/**
+ * Blits an index palette image into an index palette image.
+ * <p>
+ * Note: The source and destination red, green, and blue
+ * arrays may be null if no alpha blending or dither is to be
+ * performed.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 1, 2, 4, 8
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 1
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcReds the source palette red component intensities
+ * @param srcGreens the source palette green component intensities
+ * @param srcBlues the source palette blue component intensities
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 1, 2, 4, 8
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 1
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destReds the destination palette red component intensities
+ * @param destGreens the destination palette green component intensities
+ * @param destBlues the destination palette blue component intensities
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+    byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+    int srcX, int srcY, int srcWidth, int srcHeight,
+    byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
+    int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+    byte[] destData, int destDepth, int destStride, int destOrder,
+    int destX, int destY, int destWidth, int destHeight,
+    byte[] destReds, byte[] destGreens, byte[] destBlues,
+    bool flipX, bool flipY) {
+    if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode is ALPHA_TRANSPARENT)) return;
+
+    /*** Prepare scaling data ***/
+    final int dwm1 = destWidth - 1;
+    final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+    final int dhm1 = destHeight - 1;
+    final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+    /*** Prepare source-related data ***/
+    final int stype;
+    switch (srcDepth) {
+        case 8:
+            stype = TYPE_INDEX_8;
+            break;
+        case 4:
+            srcStride <<= 1;
+            stype = TYPE_INDEX_4;
+            break;
+        case 2:
+            srcStride <<= 2;
+            stype = TYPE_INDEX_2;
+            break;
+        case 1:
+            srcStride <<= 3;
+            stype = (srcOrder is MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid source type");
+            return;     
+    }           
+    int spr = srcY * srcStride + srcX;
+
+    /*** Prepare destination-related data ***/
+    final int dtype;
+    switch (destDepth) {
+        case 8:
+            dtype = TYPE_INDEX_8;
+            break;
+        case 4:
+            destStride <<= 1;
+            dtype = TYPE_INDEX_4;
+            break;
+        case 2:
+            destStride <<= 2;
+            dtype = TYPE_INDEX_2;
+            break;
+        case 1:
+            destStride <<= 3;
+            dtype = (destOrder is MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid source type");
+            return;
+    }           
+    int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
+    final int dprxi = (flipX) ? -1 : 1;
+    final int dpryi = (flipY) ? -destStride : destStride;
+
+    /*** Prepare special processing data ***/
+    int apr;
+    if ((op & BLIT_ALPHA) !is 0) {
+        switch (alphaMode) {
+            case ALPHA_MASK_UNPACKED:
+            case ALPHA_CHANNEL_SEPARATE:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_PACKED:
+                if (alphaData is null) alphaMode = 0x10000;
+                alphaStride <<= 3;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_INDEX:
+            case ALPHA_MASK_RGB:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = 0;
+                break;
+            default:
+                alphaMode = (alphaMode << 16) / 255; // prescale
+            case ALPHA_CHANNEL_SOURCE:
+                apr = 0;
+                break;
+        }
+    } else {
+        alphaMode = 0x10000;
+        apr = 0;
+    }
+    final bool ditherEnabled = (op & BLIT_DITHER) !is 0;
+
+    /*** Blit ***/
+    int dp = dpr;
+    int sp = spr;
+    int ap = apr;
+    int destPaletteSize = 1 << destDepth;
+    if ((destReds !is null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
+    byte[] paletteMapping = null;
+    bool isExactPaletteMapping = true;
+    switch (alphaMode) {
+        case 0x10000:
+            /*** If the palettes and formats are equivalent use a one-to-one mapping ***/
+            if ((stype is dtype) &&
+                (srcReds is destReds) && (srcGreens is destGreens) && (srcBlues is destBlues)) {
+                paletteMapping = ONE_TO_ONE_MAPPING;
+                break;
+            /*** If palettes have not been supplied, supply a suitable mapping ***/
+            } else if ((srcReds is null) || (destReds is null)) {
+                if (srcDepth <= destDepth) {
+                    paletteMapping = ONE_TO_ONE_MAPPING;
+                } else {
+                    paletteMapping = new byte[1 << srcDepth];
+                    int mask = (0xff << destDepth) >>> 8;
+                    for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = (byte)(i & mask);
+                }
+                break;
+            }
+        case ALPHA_MASK_UNPACKED:
+        case ALPHA_MASK_PACKED:
+        case ALPHA_MASK_INDEX:
+        case ALPHA_MASK_RGB:
+            /*** Generate a palette mapping ***/
+            int srcPaletteSize = 1 << srcDepth;
+            paletteMapping = new byte[srcPaletteSize];
+            if ((srcReds !is null) && (srcReds.length < srcPaletteSize)) srcPaletteSize = srcReds.length;
+            for (int i = 0, r, g, b, index; i < srcPaletteSize; ++i) {
+                r = srcReds[i] & 0xff;
+                g = srcGreens[i] & 0xff;
+                b = srcBlues[i] & 0xff;
+                index = 0;
+                int minDistance = 0x7fffffff;
+                for (int j = 0, dr, dg, db, distance; j < destPaletteSize; ++j) {
+                    dr = (destReds[j] & 0xff) - r;
+                    dg = (destGreens[j] & 0xff) - g;
+                    db = (destBlues[j] & 0xff) - b;
+                    distance = dr * dr + dg * dg + db * db;
+                    if (distance < minDistance) {
+                        index = j;
+                        if (distance is 0) break;
+                        minDistance = distance;
+                    }
+                }
+                paletteMapping[i] = (byte)index;
+                if (minDistance !is 0) isExactPaletteMapping = false;
+            }
+            break;
+    }
+    if ((paletteMapping !is null) && (isExactPaletteMapping || ! ditherEnabled)) {
+        if ((stype is dtype) && (alphaMode is 0x10000)) {
+            /*** Fast blit (copy w/ mapping) ***/
+            switch (stype) {
+                case TYPE_INDEX_8:
+                    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                            destData[dp] = paletteMapping[srcData[sp] & 0xff];
+                            sp += (sfx >>> 16);
+                        }
+                    }
+                    break;                  
+                case TYPE_INDEX_4:
+                    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                            final int v;
+                            if ((sp & 1) !is 0) v = paletteMapping[srcData[sp >> 1] & 0x0f];
+                            else v = (srcData[sp >> 1] >>> 4) & 0x0f;
+                            sp += (sfx >>> 16);
+                            if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | v);
+                            else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (v << 4));
+                        }
+                    }
+                    break;
+                case TYPE_INDEX_2:
+                    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                            final int index = paletteMapping[(srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03];
+                            sp += (sfx >>> 16);
+                            final int shift = 6 - (dp & 3) * 2;
+                            destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
+                        }
+                    }
+                    break;                  
+                case TYPE_INDEX_1_MSB:
+                    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                            final int index = paletteMapping[(srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01];
+                            sp += (sfx >>> 16);
+                            final int shift = 7 - (dp & 7);
+                            destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+                        }
+                    }
+                    break;                  
+                case TYPE_INDEX_1_LSB:
+                    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+                        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+                            final int index = paletteMapping[(srcData[sp >> 3] >>> (sp & 7)) & 0x01];
+                            sp += (sfx >>> 16);
+                            final int shift = dp & 7;
+                            destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+                        }
+                    }
+                    break;
+            }
+        } else {
+            /*** Convert between indexed modes using mapping and mask ***/
+            for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+                    sp = spr += (sfy >>> 16) * srcStride,
+                    sfy = (sfy & 0xffff) + sfyi,
+                    dp = dpr += dpryi) {
+                for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+                        dp += dprxi,
+                        sfx = (sfx & 0xffff) + sfxi) {
+                    int index;
+                    /*** READ NEXT PIXEL ***/
+                    switch (stype) {
+                        case TYPE_INDEX_8:
+                            index = srcData[sp] & 0xff;
+                            sp += (sfx >>> 16);
+                            break;                  
+                        case TYPE_INDEX_4:
+                            if ((sp & 1) !is 0) index = srcData[sp >> 1] & 0x0f;
+                            else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+                            sp += (sfx >>> 16);
+                            break;                  
+                        case TYPE_INDEX_2:
+                            index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+                            sp += (sfx >>> 16);
+                            break;                  
+                        case TYPE_INDEX_1_MSB:
+                            index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+                            sp += (sfx >>> 16);
+                            break;                  
+                        case TYPE_INDEX_1_LSB:
+                            index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+                            sp += (sfx >>> 16);
+                            break;
+                        default:
+                            return;
+                    }
+                    /*** APPLY MASK ***/
+                    switch (alphaMode) {
+                        case ALPHA_MASK_UNPACKED: {
+                            final byte mask = alphaData[ap];
+                            ap += (sfx >> 16);
+                            if (mask is 0) continue;
+                        } break;
+                        case ALPHA_MASK_PACKED: {
+                            final int mask = alphaData[ap >> 3] & (1 << (ap & 7));
+                            ap += (sfx >> 16);
+                            if (mask is 0) continue;
+                        } break;
+                        case ALPHA_MASK_INDEX: {
+                            int i = 0;
+                            while (i < alphaData.length) {
+                                if (index is (alphaData[i] & 0xff)) break;
+                            }
+                            if (i < alphaData.length) continue;
+                        } break;
+                        case ALPHA_MASK_RGB: {
+                            final byte r = srcReds[index], g = srcGreens[index], b = srcBlues[index];
+                            int i = 0;
+                            while (i < alphaData.length) {
+                                if ((r is alphaData[i]) && (g is alphaData[i + 1]) && (b is alphaData[i + 2])) break;
+                                i += 3;
+                            }
+                            if (i < alphaData.length) continue;
+                        } break;
+                    }
+                    index = paletteMapping[index] & 0xff;
+            
+                    /*** WRITE NEXT PIXEL ***/
+                    switch (dtype) {
+                        case TYPE_INDEX_8:
+                            destData[dp] = (byte) index;
+                            break;
+                        case TYPE_INDEX_4:
+                            if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | index);
+                            else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (index << 4));
+                            break;                  
+                        case TYPE_INDEX_2: {
+                            final int shift = 6 - (dp & 3) * 2;
+                            destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
+                        } break;                    
+                        case TYPE_INDEX_1_MSB: {
+                            final int shift = 7 - (dp & 7);
+                            destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+                        } break;
+                        case TYPE_INDEX_1_LSB: {
+                            final int shift = dp & 7;
+                            destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+                        } break;                    
+                    }
+                }
+            }
+        }
+        return;
+    }
+        
+    /*** Comprehensive blit (apply transformations) ***/
+    int alpha = alphaMode;
+    int index = 0;
+    int indexq = 0;
+    int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
+    final int[] rerr, gerr, berr;
+    if (ditherEnabled) {
+        rerr = new int[destWidth + 2];
+        gerr = new int[destWidth + 2];
+        berr = new int[destWidth + 2];
+    } else {
+        rerr = null; gerr = null; berr = null;
+    }
+    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+            sp = spr += (sfy >>> 16) * srcStride,
+            ap = apr += (sfy >>> 16) * alphaStride,
+            sfy = (sfy & 0xffff) + sfyi,
+            dp = dpr += dpryi) {
+        int lrerr = 0, lgerr = 0, lberr = 0;
+        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+                dp += dprxi,
+                sfx = (sfx & 0xffff) + sfxi) {
+            /*** READ NEXT PIXEL ***/
+            switch (stype) {
+                case TYPE_INDEX_8:
+                    index = srcData[sp] & 0xff;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_4:
+                    if ((sp & 1) !is 0) index = srcData[sp >> 1] & 0x0f;
+                    else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_2:
+                    index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_1_MSB:
+                    index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_1_LSB:
+                    index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+                    sp += (sfx >>> 16);
+                    break;
+            }
+
+            /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+            int r = srcReds[index] & 0xff, g = srcGreens[index] & 0xff, b = srcBlues[index] & 0xff;
+            switch (alphaMode) {
+                case ALPHA_CHANNEL_SEPARATE:
+                    alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_MASK_UNPACKED:
+                    alpha = (alphaData[ap] !is 0) ? 0x10000 : 0;
+                    ap += (sfx >> 16);
+                    break;                      
+                case ALPHA_MASK_PACKED:
+                    alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
+                    int i = 0;
+                    while (i < alphaData.length) {
+                        if (index is (alphaData[i] & 0xff)) break;
+                    }
+                    if (i < alphaData.length) continue;
+                } break;
+                case ALPHA_MASK_RGB: {
+                    int i = 0;
+                    while (i < alphaData.length) {
+                        if ((r is (alphaData[i] & 0xff)) &&
+                            (g is (alphaData[i + 1] & 0xff)) &&
+                            (b is (alphaData[i + 2] & 0xff))) break;
+                        i += 3;
+                    }
+                    if (i < alphaData.length) continue;
+                } break;
+            }
+            if (alpha !is 0x10000) {
+                if (alpha is 0x0000) continue;
+                switch (dtype) {
+                    case TYPE_INDEX_8:
+                        indexq = destData[dp] & 0xff;
+                        break;
+                    case TYPE_INDEX_4:
+                        if ((dp & 1) !is 0) indexq = destData[dp >> 1] & 0x0f;
+                        else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
+                        break;
+                    case TYPE_INDEX_2:
+                        indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
+                        break;
+                    case TYPE_INDEX_1_MSB:
+                        indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+                        break;
+                    case TYPE_INDEX_1_LSB:
+                        indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+                        break;
+                }
+                // Perform alpha blending
+                final int rq = destReds[indexq] & 0xff;
+                final int gq = destGreens[indexq] & 0xff;
+                final int bq = destBlues[indexq] & 0xff;
+                r = rq + ((r - rq) * alpha >> 16);
+                g = gq + ((g - gq) * alpha >> 16);
+                b = bq + ((b - bq) * alpha >> 16);
+            }
+
+            /*** MAP COLOR TO THE PALETTE ***/
+            if (ditherEnabled) {
+                // Floyd-Steinberg error diffusion
+                r += rerr[dx] >> 4;
+                if (r < 0) r = 0; else if (r > 255) r = 255;
+                g += gerr[dx] >> 4;
+                if (g < 0) g = 0; else if (g > 255) g = 255;
+                b += berr[dx] >> 4;
+                if (b < 0) b = 0; else if (b > 255) b = 255;
+                rerr[dx] = lrerr;
+                gerr[dx] = lgerr;
+                berr[dx] = lberr;
+            }
+            if (r !is lastr || g !is lastg || b !is lastb) {
+                // moving the variable declarations out seems to make the JDK JIT happier...
+                for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
+                    dr = (destReds[j] & 0xff) - r;
+                    dg = (destGreens[j] & 0xff) - g;
+                    db = (destBlues[j] & 0xff) - b;
+                    distance = dr * dr + dg * dg + db * db;
+                    if (distance < minDistance) {
+                        lastindex = j;
+                        if (distance is 0) break;
+                        minDistance = distance;
+                    }
+                }
+                lastr = r; lastg = g; lastb = b;
+            }
+            if (ditherEnabled) {
+                // Floyd-Steinberg error diffusion, cont'd...
+                final int dxm1 = dx - 1, dxp1 = dx + 1;
+                int acc;
+                rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
+                rerr[dx] += acc += lrerr + lrerr;
+                rerr[dxm1] += acc + lrerr + lrerr;
+                gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
+                gerr[dx] += acc += lgerr + lgerr;
+                gerr[dxm1] += acc + lgerr + lgerr;
+                berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
+                berr[dx] += acc += lberr + lberr;
+                berr[dxm1] += acc + lberr + lberr;
+            }
+
+            /*** WRITE NEXT PIXEL ***/
+            switch (dtype) {
+                case TYPE_INDEX_8:
+                    destData[dp] = (byte) lastindex;
+                    break;
+                case TYPE_INDEX_4:
+                    if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
+                    else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
+                    break;
+                case TYPE_INDEX_2: {
+                    final int shift = 6 - (dp & 3) * 2;
+                    destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
+                } break;                    
+                case TYPE_INDEX_1_MSB: {
+                    final int shift = 7 - (dp & 7);
+                    destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+                } break;
+                case TYPE_INDEX_1_LSB: {
+                    final int shift = dp & 7;
+                    destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+                } break;                    
+            }
+        }
+    }
+}
+
+/**
+ * Blits an index palette image into a direct palette image.
+ * <p>
+ * Note: The source and destination masks and palettes must
+ * always be fully specified.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 1, 2, 4, 8
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 1
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcReds the source palette red component intensities
+ * @param srcGreens the source palette green component intensities
+ * @param srcBlues the source palette blue component intensities
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 8, 16, 24, 32
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 16 or 32
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destRedMask the destination red channel mask
+ * @param destGreenMask the destination green channel mask
+ * @param destBlueMask the destination blue channel mask
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+    byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+    int srcX, int srcY, int srcWidth, int srcHeight,
+    byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
+    int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+    byte[] destData, int destDepth, int destStride, int destOrder,
+    int destX, int destY, int destWidth, int destHeight,
+    int destRedMask, int destGreenMask, int destBlueMask,
+    bool flipX, bool flipY) {
+    if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode is ALPHA_TRANSPARENT)) return;
+
+    // these should be supplied as params later
+    final int destAlphaMask = 0;
+
+    /*** Prepare scaling data ***/
+    final int dwm1 = destWidth - 1;
+    final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+    final int dhm1 = destHeight - 1;
+    final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+    /*** Prepare source-related data ***/
+    final int stype;
+    switch (srcDepth) {
+        case 8:
+            stype = TYPE_INDEX_8;
+            break;
+        case 4:
+            srcStride <<= 1;
+            stype = TYPE_INDEX_4;
+            break;
+        case 2:
+            srcStride <<= 2;
+            stype = TYPE_INDEX_2;
+            break;
+        case 1:
+            srcStride <<= 3;
+            stype = (srcOrder is MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid source type");
+            return;
+    }           
+    int spr = srcY * srcStride + srcX;
+
+    /*** Prepare destination-related data ***/
+    final int dbpp, dtype;
+    switch (destDepth) {
+        case 8:
+            dbpp = 1;
+            dtype = TYPE_GENERIC_8;
+            break;
+        case 16:
+            dbpp = 2;
+            dtype = (destOrder is MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+            break;
+        case 24:
+            dbpp = 3;
+            dtype = TYPE_GENERIC_24;
+            break;
+        case 32:
+            dbpp = 4;
+            dtype = (destOrder is MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid destination type");
+            return;
+    }           
+    int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
+    final int dprxi = (flipX) ? -dbpp : dbpp;
+    final int dpryi = (flipY) ? -destStride : destStride;
+
+    /*** Prepare special processing data ***/
+    int apr;
+    if ((op & BLIT_ALPHA) !is 0) {
+        switch (alphaMode) {
+            case ALPHA_MASK_UNPACKED:
+            case ALPHA_CHANNEL_SEPARATE:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_PACKED:
+                if (alphaData is null) alphaMode = 0x10000;
+                alphaStride <<= 3;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_INDEX:
+            case ALPHA_MASK_RGB:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = 0;
+                break;
+            default:
+                alphaMode = (alphaMode << 16) / 255; // prescale
+            case ALPHA_CHANNEL_SOURCE:
+                apr = 0;
+                break;
+        }
+    } else {
+        alphaMode = 0x10000;
+        apr = 0;
+    }
+
+    /*** Comprehensive blit (apply transformations) ***/
+    final int destRedShift = getChannelShift(destRedMask);
+    final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
+    final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
+    final int destRedPreShift = 8 - destRedWidth;
+    final int destGreenShift = getChannelShift(destGreenMask);
+    final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
+    final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
+    final int destGreenPreShift = 8 - destGreenWidth;
+    final int destBlueShift = getChannelShift(destBlueMask);
+    final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
+    final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
+    final int destBluePreShift = 8 - destBlueWidth;
+    final int destAlphaShift = getChannelShift(destAlphaMask);
+    final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
+    final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
+    final int destAlphaPreShift = 8 - destAlphaWidth;
+
+    int dp = dpr;
+    int sp = spr;
+    int ap = apr, alpha = alphaMode;
+    int r = 0, g = 0, b = 0, a = 0, index = 0;
+    int rq = 0, gq = 0, bq = 0, aq = 0;
+    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+            sp = spr += (sfy >>> 16) * srcStride,
+            ap = apr += (sfy >>> 16) * alphaStride,
+            sfy = (sfy & 0xffff) + sfyi,
+            dp = dpr += dpryi) {
+        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+                dp += dprxi,
+                sfx = (sfx & 0xffff) + sfxi) {
+            /*** READ NEXT PIXEL ***/
+            switch (stype) {
+                case TYPE_INDEX_8:
+                    index = srcData[sp] & 0xff;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_4:
+                    if ((sp & 1) !is 0) index = srcData[sp >> 1] & 0x0f;
+                    else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_2:
+                    index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_1_MSB:
+                    index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+                    sp += (sfx >>> 16);
+                    break;
+                case TYPE_INDEX_1_LSB:
+                    index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+                    sp += (sfx >>> 16);
+                    break;
+            }
+
+            /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+            r = srcReds[index] & 0xff;
+            g = srcGreens[index] & 0xff;
+            b = srcBlues[index] & 0xff;
+            switch (alphaMode) {
+                case ALPHA_CHANNEL_SEPARATE:
+                    alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_MASK_UNPACKED:
+                    alpha = (alphaData[ap] !is 0) ? 0x10000 : 0;
+                    ap += (sfx >> 16);
+                    break;                      
+                case ALPHA_MASK_PACKED:
+                    alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
+                    int i = 0;
+                    while (i < alphaData.length) {
+                        if (index is (alphaData[i] & 0xff)) break;
+                    }
+                    if (i < alphaData.length) continue;
+                } break;
+                case ALPHA_MASK_RGB: {
+                    int i = 0;
+                    while (i < alphaData.length) {
+                        if ((r is (alphaData[i] & 0xff)) &&
+                            (g is (alphaData[i + 1] & 0xff)) &&
+                            (b is (alphaData[i + 2] & 0xff))) break;
+                        i += 3;
+                    }
+                    if (i < alphaData.length) continue;
+                } break;
+            }
+            if (alpha !is 0x10000) {
+                if (alpha is 0x0000) continue;
+                switch (dtype) {
+                    case TYPE_GENERIC_8: {
+                        final int data = destData[dp] & 0xff;
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_16_MSB: {
+                        final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_16_LSB: {
+                        final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_24: {
+                        final int data = (( ((destData[dp] & 0xff) << 8) |
+                            (destData[dp + 1] & 0xff)) << 8) |
+                            (destData[dp + 2] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_32_MSB: {
+                        final int data = (( (( ((destData[dp] & 0xff) << 8) |
+                            (destData[dp + 1] & 0xff)) << 8) |
+                            (destData[dp + 2] & 0xff)) << 8) |
+                            (destData[dp + 3] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                    case TYPE_GENERIC_32_LSB: {
+                        final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
+                            (destData[dp + 2] & 0xff)) << 8) |
+                            (destData[dp + 1] & 0xff)) << 8) |
+                            (destData[dp] & 0xff);
+                        rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+                        gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+                        bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+                        aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+                    } break;
+                }
+                // Perform alpha blending
+                a = aq + ((a - aq) * alpha >> 16);
+                r = rq + ((r - rq) * alpha >> 16);
+                g = gq + ((g - gq) * alpha >> 16);
+                b = bq + ((b - bq) * alpha >> 16);
+            }
+
+            /*** WRITE NEXT PIXEL ***/
+            final int data = 
+                (r >>> destRedPreShift << destRedShift) |
+                (g >>> destGreenPreShift << destGreenShift) |
+                (b >>> destBluePreShift << destBlueShift) |
+                (a >>> destAlphaPreShift << destAlphaShift);
+            switch (dtype) {
+                case TYPE_GENERIC_8: {
+                    destData[dp] = (byte) data;
+                } break;
+                case TYPE_GENERIC_16_MSB: {
+                    destData[dp] = (byte) (data >>> 8);
+                    destData[dp + 1] = (byte) (data & 0xff);
+                } break;
+                case TYPE_GENERIC_16_LSB: {
+                    destData[dp] = (byte) (data & 0xff);
+                    destData[dp + 1] = (byte) (data >>> 8);
+                } break;
+                case TYPE_GENERIC_24: {
+                    destData[dp] = (byte) (data >>> 16);
+                    destData[dp + 1] = (byte) (data >>> 8);
+                    destData[dp + 2] = (byte) (data & 0xff);
+                } break;
+                case TYPE_GENERIC_32_MSB: {
+                    destData[dp] = (byte) (data >>> 24);
+                    destData[dp + 1] = (byte) (data >>> 16);
+                    destData[dp + 2] = (byte) (data >>> 8);
+                    destData[dp + 3] = (byte) (data & 0xff);
+                } break;
+                case TYPE_GENERIC_32_LSB: {
+                    destData[dp] = (byte) (data & 0xff);
+                    destData[dp + 1] = (byte) (data >>> 8);
+                    destData[dp + 2] = (byte) (data >>> 16);
+                    destData[dp + 3] = (byte) (data >>> 24);
+                } break;
+            }
+        }
+    }           
+}
+
+/**
+ * Blits a direct palette image into an index palette image.
+ * <p>
+ * Note: The source and destination masks and palettes must
+ * always be fully specified.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 8, 16, 24, 32
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 16 or 32
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcRedMask the source red channel mask
+ * @param srcGreenMask the source green channel mask
+ * @param srcBlueMask the source blue channel mask
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 1, 2, 4, 8
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 1
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destReds the destination palette red component intensities
+ * @param destGreens the destination palette green component intensities
+ * @param destBlues the destination palette blue component intensities
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+    byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+    int srcX, int srcY, int srcWidth, int srcHeight,
+    int srcRedMask, int srcGreenMask, int srcBlueMask,
+    int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+    byte[] destData, int destDepth, int destStride, int destOrder,
+    int destX, int destY, int destWidth, int destHeight,
+    byte[] destReds, byte[] destGreens, byte[] destBlues,
+    bool flipX, bool flipY) {
+    if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode is ALPHA_TRANSPARENT)) return;
+
+    // these should be supplied as params later
+    final int srcAlphaMask = 0;
+
+    /*** Prepare scaling data ***/
+    final int dwm1 = destWidth - 1;
+    final int sfxi = (dwm1 !is 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+    final int dhm1 = destHeight - 1;
+    final int sfyi = (dhm1 !is 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+    /*** Prepare source-related data ***/
+    final int sbpp, stype;
+    switch (srcDepth) {
+        case 8:
+            sbpp = 1;
+            stype = TYPE_GENERIC_8;
+            break;
+        case 16:
+            sbpp = 2;
+            stype = (srcOrder is MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+            break;
+        case 24:
+            sbpp = 3;
+            stype = TYPE_GENERIC_24;
+            break;
+        case 32:
+            sbpp = 4;
+            stype = (srcOrder is MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid source type");
+            return;
+    }           
+    int spr = srcY * srcStride + srcX * sbpp;
+
+    /*** Prepare destination-related data ***/
+    final int dtype;
+    switch (destDepth) {
+        case 8:
+            dtype = TYPE_INDEX_8;
+            break;
+        case 4:
+            destStride <<= 1;
+            dtype = TYPE_INDEX_4;
+            break;
+        case 2:
+            destStride <<= 2;
+            dtype = TYPE_INDEX_2;
+            break;
+        case 1:
+            destStride <<= 3;
+            dtype = (destOrder is MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+            break;
+        default:
+            //throw new IllegalArgumentException("Invalid source type");
+            return;
+    }           
+    int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
+    final int dprxi = (flipX) ? -1 : 1;
+    final int dpryi = (flipY) ? -destStride : destStride;
+
+    /*** Prepare special processing data ***/
+    int apr;
+    if ((op & BLIT_ALPHA) !is 0) {
+        switch (alphaMode) {
+            case ALPHA_MASK_UNPACKED:
+            case ALPHA_CHANNEL_SEPARATE:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_PACKED:
+                if (alphaData is null) alphaMode = 0x10000;
+                alphaStride <<= 3;
+                apr = alphaY * alphaStride + alphaX;
+                break;
+            case ALPHA_MASK_INDEX:
+                //throw new IllegalArgumentException("Invalid alpha type");
+                return;
+            case ALPHA_MASK_RGB:
+                if (alphaData is null) alphaMode = 0x10000;
+                apr = 0;
+                break;
+            default:
+                alphaMode = (alphaMode << 16) / 255; // prescale
+            case ALPHA_CHANNEL_SOURCE:
+                apr = 0;
+                break;
+        }
+    } else {
+        alphaMode = 0x10000;
+        apr = 0;
+    }
+    final bool ditherEnabled = (op & BLIT_DITHER) !is 0;
+
+    /*** Comprehensive blit (apply transformations) ***/
+    final int srcRedShift = getChannelShift(srcRedMask);
+    final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
+    final int srcGreenShift = getChannelShift(srcGreenMask);
+    final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
+    final int srcBlueShift = getChannelShift(srcBlueMask);
+    final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
+    final int srcAlphaShift = getChannelShift(srcAlphaMask);
+    final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
+
+    int dp = dpr;
+    int sp = spr;
+    int ap = apr, alpha = alphaMode;
+    int r = 0, g = 0, b = 0, a = 0;
+    int indexq = 0;
+    int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
+    final int[] rerr, gerr, berr;
+    int destPaletteSize = 1 << destDepth;
+    if ((destReds !is null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
+    if (ditherEnabled) {
+        rerr = new int[destWidth + 2];
+        gerr = new int[destWidth + 2];
+        berr = new int[destWidth + 2];
+    } else {
+        rerr = null; gerr = null; berr = null;
+    }
+    for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+            sp = spr += (sfy >>> 16) * srcStride,
+            ap = apr += (sfy >>> 16) * alphaStride,
+            sfy = (sfy & 0xffff) + sfyi,
+            dp = dpr += dpryi) {
+        int lrerr = 0, lgerr = 0, lberr = 0;
+        for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+                dp += dprxi,
+                sfx = (sfx & 0xffff) + sfxi) {
+            /*** READ NEXT PIXEL ***/
+            switch (stype) {
+                case TYPE_GENERIC_8: {
+                    final int data = srcData[sp] & 0xff;
+                    sp += (sfx >>> 16);
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_16_MSB: {
+                    final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
+                    sp += (sfx >>> 16) * 2;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_16_LSB: {
+                    final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
+                    sp += (sfx >>> 16) * 2;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_24: {
+                    final int data = (( ((srcData[sp] & 0xff) << 8) |
+                        (srcData[sp + 1] & 0xff)) << 8) |
+                        (srcData[sp + 2] & 0xff);
+                    sp += (sfx >>> 16) * 3;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_32_MSB: {
+                    final int data = (( (( ((srcData[sp] & 0xff) << 8) |
+                        (srcData[sp + 1] & 0xff)) << 8) |
+                        (srcData[sp + 2] & 0xff)) << 8) |
+                        (srcData[sp + 3] & 0xff);
+                    sp += (sfx >>> 16) * 4;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+                case TYPE_GENERIC_32_LSB: {
+                    final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
+                        (srcData[sp + 2] & 0xff)) << 8) |
+                        (srcData[sp + 1] & 0xff)) << 8) |
+                        (srcData[sp] & 0xff);
+                    sp += (sfx >>> 16) * 4;
+                    r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+                    g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+                    b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+                    a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+                } break;
+            }
+
+            /*** DO SPECIAL PROCESSING IF REQUIRED ***/
+            switch (alphaMode) {
+                case ALPHA_CHANNEL_SEPARATE:
+                    alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_CHANNEL_SOURCE:
+                    alpha = (a << 16) / 255;
+                    break;
+                case ALPHA_MASK_UNPACKED:
+                    alpha = (alphaData[ap] !is 0) ? 0x10000 : 0;
+                    ap += (sfx >> 16);
+                    break;                      
+                case ALPHA_MASK_PACKED:
+                    alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+                    ap += (sfx >> 16);
+                    break;
+                case ALPHA_MASK_RGB:
+                    alpha = 0x10000;
+                    for (int i = 0; i < alphaData.length; i += 3) {
+                        if ((r is alphaData[i]) && (g is alphaData[i + 1]) && (b is alphaData[i + 2])) {
+                            alpha = 0x0000;
+                            break;
+                        }
+                    }
+                    break;
+            }
+            if (alpha !is 0x10000) {
+                if (alpha is 0x0000) continue;
+                switch (dtype) {
+                    case TYPE_INDEX_8:
+                        indexq = destData[dp] & 0xff;
+                        break;
+                    case TYPE_INDEX_4:
+                        if ((dp & 1) !is 0) indexq = destData[dp >> 1] & 0x0f;
+                        else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
+                        break;
+                    case TYPE_INDEX_2:
+                        indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
+                        break;
+                    case TYPE_INDEX_1_MSB:
+                        indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+                        break;
+                    case TYPE_INDEX_1_LSB:
+                        indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+                        break;
+                }
+                // Perform alpha blending
+                final int rq = destReds[indexq] & 0xff;
+                final int gq = destGreens[indexq] & 0xff;
+                final int bq = destBlues[indexq] & 0xff;
+                r = rq + ((r - rq) * alpha >> 16);
+                g = gq + ((g - gq) * alpha >> 16);
+                b = bq + ((b - bq) * alpha >> 16);
+            }
+
+            /*** MAP COLOR TO THE PALETTE ***/
+            if (ditherEnabled) {
+                // Floyd-Steinberg error diffusion
+                r += rerr[dx] >> 4;
+                if (r < 0) r = 0; else if (r > 255) r = 255;
+                g += gerr[dx] >> 4;
+                if (g < 0) g = 0; else if (g > 255) g = 255;
+                b += berr[dx] >> 4;
+                if (b < 0) b = 0; else if (b > 255) b = 255;
+                rerr[dx] = lrerr;
+                gerr[dx] = lgerr;
+                berr[dx] = lberr;
+            }
+            if (r !is lastr || g !is lastg || b !is lastb) {
+                // moving the variable declarations out seems to make the JDK JIT happier...
+                for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
+                    dr = (destReds[j] & 0xff) - r;
+                    dg = (destGreens[j] & 0xff) - g;
+                    db = (destBlues[j] & 0xff) - b;
+                    distance = dr * dr + dg * dg + db * db;
+                    if (distance < minDistance) {
+                        lastindex = j;
+                        if (distance is 0) break;
+                        minDistance = distance;
+                    }
+                }
+                lastr = r; lastg = g; lastb = b;
+            }
+            if (ditherEnabled) {
+                // Floyd-Steinberg error diffusion, cont'd...
+                final int dxm1 = dx - 1, dxp1 = dx + 1;
+                int acc;
+                rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
+                rerr[dx] += acc += lrerr + lrerr;
+                rerr[dxm1] += acc + lrerr + lrerr;
+                gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
+                gerr[dx] += acc += lgerr + lgerr;
+                gerr[dxm1] += acc + lgerr + lgerr;
+                berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
+                berr[dx] += acc += lberr + lberr;
+                berr[dxm1] += acc + lberr + lberr;
+            }
+
+            /*** WRITE NEXT PIXEL ***/
+            switch (dtype) {
+                case TYPE_INDEX_8:
+                    destData[dp] = (byte) lastindex;
+                    break;
+                case TYPE_INDEX_4:
+                    if ((dp & 1) !is 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
+                    else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
+                    break;
+                case TYPE_INDEX_2: {
+                    final int shift = 6 - (dp & 3) * 2;
+                    destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
+                } break;                    
+                case TYPE_INDEX_1_MSB: {
+                    final int shift = 7 - (dp & 7);
+                    destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+                } break;
+                case TYPE_INDEX_1_LSB: {
+                    final int shift = dp & 7;
+                    destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+                } break;                    
+            }
+        }
+    }
+}
+
+/**
+ * Computes the required channel shift from a mask.
+ */
+static int getChannelShift(int mask) {
+    if (mask is 0) return 0;
+    int i;
+    for (i = 0; ((mask & 1) is 0) && (i < 32); ++i) {
+        mask >>>= 1;
+    }
+    return i;
+}
+
+/**
+ * Computes the required channel width (depth) from a mask.
+ */
+static int getChannelWidth(int mask, int shift) {
+    if (mask is 0) return 0;
+    int i;
+    mask >>>= shift;
+    for (i = shift; ((mask & 1) !is 0) && (i < 32); ++i) {
+        mask >>>= 1;
+    }
+    return i - shift;
+}
+
+/**
+ * Extracts a field from packed RGB data given a mask for that field.
+ */
+static byte getChannelField(int data, int mask) {
+    final int shift = getChannelShift(mask);
+    return ANY_TO_EIGHT[getChannelWidth(mask, shift)][(data & mask) >>> shift];
+}
+
+/**
+ * Creates an ImageData containing one band's worth of a gradient filled
+ * block.  If <code>vertical</code> is true, the band must be tiled
+ * horizontally to fill a region, otherwise it must be tiled vertically.
+ *
+ * @param width the width of the region to be filled
+ * @param height the height of the region to be filled
+ * @param vertical if true sweeps from top to bottom, else
+ *        sweeps from left to right
+ * @param fromRGB the color to start with
+ * @param toRGB the color to end with
+ * @param redBits the number of significant red bits, 0 for palette modes
+ * @param greenBits the number of significant green bits, 0 for palette modes
+ * @param blueBits the number of significant blue bits, 0 for palette modes
+ * @return the new ImageData
+ */
+static ImageData createGradientBand(
+    int width, int height, bool vertical,
+    RGB fromRGB, RGB toRGB,
+    int redBits, int greenBits, int blueBits) {
+    /* Gradients are drawn as tiled bands */
+    final int bandWidth, bandHeight, bitmapDepth;
+    final byte[] bitmapData;
+    final PaletteData paletteData;
+    /* Select an algorithm depending on the depth of the screen */
+    if (redBits !is 0 && greenBits !is 0 && blueBits !is 0) {
+        paletteData = new PaletteData(0x0000ff00, 0x00ff0000, 0xff000000);
+        bitmapDepth = 32;
+        if (redBits >= 8 && greenBits >= 8 && blueBits >= 8) {
+            /* Precise color */
+            final int steps;
+            if (vertical) {
+                bandWidth = 1;
+                bandHeight = height;
+                steps = bandHeight > 1 ? bandHeight - 1 : 1;
+            } else {
+                bandWidth = width;
+                bandHeight = 1;
+                steps = bandWidth > 1 ? bandWidth - 1 : 1;
+            }
+            final int bytesPerLine = bandWidth * 4;
+            bitmapData = new byte[bandHeight * bytesPerLine];
+            buildPreciseGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine);
+            buildPreciseGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine);
+            buildPreciseGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine);
+        } else {
+            /* Dithered color */
+            final int steps;
+            if (vertical) {
+                bandWidth = (width < 8) ? width : 8;
+                bandHeight = height;
+                steps = bandHeight > 1 ? bandHeight - 1 : 1;
+            } else {
+                bandWidth = width;
+                bandHeight = (height < 8) ? height : 8;
+                steps = bandWidth > 1 ? bandWidth - 1 : 1;
+            }
+            final int bytesPerLine = bandWidth * 4;
+            bitmapData = new byte[bandHeight * bytesPerLine];
+            buildDitheredGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine, blueBits);
+            buildDitheredGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine, greenBits);
+            buildDitheredGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine, redBits);         
+        }
+    } else {
+        /* Dithered two tone */
+        paletteData = new PaletteData(new RGB[] { fromRGB, toRGB });
+        bitmapDepth = 8;
+        final int blendi;
+        if (vertical) {
+            bandWidth = (width < 8) ? width : 8;
+            bandHeight = height;
+            blendi = (bandHeight > 1) ? 0x1040000 / (bandHeight - 1) + 1 : 1;
+        } else {
+            bandWidth = width;
+            bandHeight = (height < 8) ? height : 8;
+            blendi = (bandWidth > 1) ? 0x1040000 / (bandWidth - 1) + 1 : 1;
+        }
+        final int bytesPerLine = (bandWidth + 3) & -4;
+        bitmapData = new byte[bandHeight * bytesPerLine];
+        if (vertical) {
+            for (int dy = 0, blend = 0, dp = 0; dy < bandHeight;
+                ++dy, blend += blendi, dp += bytesPerLine) {
+                for (int dx = 0; dx < bandWidth; ++dx) {
+                    bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) <
+                        0x1000000 ? (byte)0 : (byte)1;
+                }
+            }       
+        } else {
+            for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) {
+                for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) {
+                    bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) <
+                        0x1000000 ? (byte)0 : (byte)1;
+                }
+            }
+        }
+    }
+    return new ImageData(bandWidth, bandHeight, bitmapDepth, paletteData, 4, bitmapData);
+}
+
+/* 
+ * Fill in gradated values for a color channel
+ */
+static final void buildPreciseGradientChannel(int from, int to, int steps,
+    int bandWidth, int bandHeight, bool vertical,
+    byte[] bitmapData, int dp, int bytesPerLine) {
+    int val = from << 16;
+    final int inc = ((to << 16) - val) / steps + 1;
+    if (vertical) {
+        for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
+            bitmapData[dp] = (byte)(val >>> 16);
+            val += inc;
+        }
+    } else {
+        for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
+            bitmapData[dp] = (byte)(val >>> 16);
+            val += inc;
+        }
+    }       
+}
+
+/* 
+ * Fill in dithered gradated values for a color channel
+ */
+static final void buildDitheredGradientChannel(int from, int to, int steps,
+    int bandWidth, int bandHeight, bool vertical,
+    byte[] bitmapData, int dp, int bytesPerLine, int bits) {
+    final int mask = 0xff00 >>> bits;
+    int val = from << 16;
+    final int inc = ((to << 16) - val) / steps + 1;
+    if (vertical) {
+        for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
+            for (int dx = 0, dptr = dp; dx < bandWidth; ++dx, dptr += 4) {
+                final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits;
+                int temp = val + thresh;
+                if (temp > 0xffffff) bitmapData[dptr] = -1;
+                else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
+            }
+            val += inc;
+        }
+    } else {
+        for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
+            for (int dy = 0, dptr = dp; dy < bandHeight; ++dy, dptr += bytesPerLine) {
+                final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits;
+                int temp = val + thresh;
+                if (temp > 0xffffff) bitmapData[dptr] = -1;
+                else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
+            }
+            val += inc;
+        }
+    }
+}
+
+/**
+ * Renders a gradient onto a GC.
+ * <p>
+ * This is a GC helper.
+ * </p>
+ *
+ * @param gc the GC to render the gradient onto
+ * @param device the device the GC belongs to
+ * @param x the top-left x coordinate of the region to be filled
+ * @param y the top-left y coordinate of the region to be filled
+ * @param width the width of the region to be filled
+ * @param height the height of the region to be filled
+ * @param vertical if true sweeps from top to bottom, else
+ *        sweeps from left to right
+ * @param fromRGB the color to start with
+ * @param toRGB the color to end with
+ * @param redBits the number of significant red bits, 0 for palette modes
+ * @param greenBits the number of significant green bits, 0 for palette modes
+ * @param blueBits the number of significant blue bits, 0 for palette modes
+ */
+static void fillGradientRectangle(GC gc, Device device,
+    int x, int y, int width, int height, bool vertical,
+    RGB fromRGB, RGB toRGB,
+    int redBits, int greenBits, int blueBits) {
+    /* Create the bitmap and tile it */
+    ImageData band = createGradientBand(width, height, vertical,
+        fromRGB, toRGB, redBits, greenBits, blueBits);
+    Image image = new Image(device, band);
+    if ((band.width is 1) || (band.height is 1)) {
+        gc.drawImage(image, 0, 0, band.width, band.height, x, y, width, height);
+    } else {
+        if (vertical) {
+            for (int dx = 0; dx < width; dx += band.width) {
+                int blitWidth = width - dx;
+                if (blitWidth > band.width) blitWidth = band.width;
+                gc.drawImage(image, 0, 0, blitWidth, band.height, dx + x, y, blitWidth, band.height);
+            }
+        } else {
+            for (int dy = 0; dy < height; dy += band.height) {
+                int blitHeight = height - dy;
+                if (blitHeight > band.height) blitHeight = band.height;
+                gc.drawImage(image, 0, 0, band.width, blitHeight, x, dy + y, band.width, blitHeight);
+            }
+        }
+    }
+    image.dispose();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/ImageDataLoader.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.ImageDataLoader;
+
+import dwt.dwthelper.utils;
+
+import java.io.InputStream;
+
+/**
+ * Internal class that separates ImageData from ImageLoader
+ * to allow removal of ImageLoader from the toolkit.
+ */
+class ImageDataLoader {
+
+    public static ImageData[] load(InputStream stream) {
+        return new ImageLoader().load(stream);
+    }
+
+    public static ImageData[] load(String filename) {
+        return new ImageLoader().load(filename);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/ImageLoader.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,326 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.ImageLoader;
+
+import dwt.dwthelper.utils;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Vector;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.Compatibility;
+import dwt.internal.image.FileFormat;
+
+/**
+ * Instances of this class are used to load images from,
+ * and save images to, a file or stream.
+ * <p>
+ * Currently supported image formats are:
+ * </p><ul>
+ * <li>BMP (Windows or OS/2 Bitmap)</li>
+ * <li>ICO (Windows Icon)</li>
+ * <li>JPEG</li>
+ * <li>GIF</li>
+ * <li>PNG</li>
+ * <li>TIFF</li>
+ * </ul>
+ * <code>ImageLoaders</code> can be used to:
+ * <ul>
+ * <li>load/save single images in all formats</li>
+ * <li>load/save multiple images (GIF/ICO/TIFF)</li>
+ * <li>load/save animated GIF images</li>
+ * <li>load interlaced GIF/PNG images</li>
+ * <li>load progressive JPEG images</li>
+ * </ul>
+ */
+ 
+public class ImageLoader {
+    
+    /**
+     * the array of ImageData objects in this ImageLoader.
+     * This array is read in when the load method is called,
+     * and it is written out when the save method is called
+     */
+    public ImageData[] data;
+    
+    /**
+     * the width of the logical screen on which the images
+     * reside, in pixels (this corresponds to the GIF89a
+     * Logical Screen Width value)
+     */
+    public int logicalScreenWidth;
+
+    /**
+     * the height of the logical screen on which the images
+     * reside, in pixels (this corresponds to the GIF89a
+     * Logical Screen Height value)
+     */
+    public int logicalScreenHeight;
+
+    /**
+     * the background pixel for the logical screen (this 
+     * corresponds to the GIF89a Background Color Index value).
+     * The default is -1 which means 'unspecified background'
+     * 
+     */
+    public int backgroundPixel;
+
+    /**
+     * the number of times to repeat the display of a sequence
+     * of animated images (this corresponds to the commonly-used
+     * GIF application extension for "NETSCAPE 2.0 01").
+     * The default is 1. A value of 0 means 'display repeatedly'
+     */
+    public int repeatCount;
+        
+    /*
+     * the set of ImageLoader event listeners, created on demand
+     */
+    Vector imageLoaderListeners;
+
+/**
+ * Construct a new empty ImageLoader.
+ */
+public ImageLoader() {
+    reset();
+}
+
+/**
+ * Resets the fields of the ImageLoader, except for the
+ * <code>imageLoaderListeners</code> field.
+ */
+void reset() {
+    data = null;
+    logicalScreenWidth = 0;
+    logicalScreenHeight = 0;
+    backgroundPixel = -1;
+    repeatCount = 1;
+}
+
+/**
+ * Loads an array of <code>ImageData</code> objects from the
+ * specified input stream. Throws an error if either an error
+ * occurs while loading the images, or if the images are not
+ * of a supported type. Returns the loaded image data array.
+ *
+ * @param stream the input stream to load the images from
+ * @return an array of <code>ImageData</code> objects loaded from the specified input stream
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
+ * </ul>
+ */
+public ImageData[] load(InputStream stream) {
+    if (stream is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    reset();
+    data = FileFormat.load(stream, this);
+    return data;
+}
+
+/**
+ * Loads an array of <code>ImageData</code> objects from the
+ * file with the specified name. Throws an error if either
+ * an error occurs while loading the images, or if the images are
+ * not of a supported type. Returns the loaded image data array.
+ *
+ * @param filename the name of the file to load the images from
+ * @return an array of <code>ImageData</code> objects loaded from the specified file
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image file contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
+ * </ul>
+ */
+public ImageData[] load(String filename) {
+    if (filename is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    InputStream stream = null;
+    try {
+        stream = Compatibility.newFileInputStream(filename);
+        return load(stream);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    } finally {
+        try {
+            if (stream !is null) stream.close();
+        } catch (IOException e) {
+            // Ignore error
+        }
+    }
+    return null;
+}
+
+/**
+ * Saves the image data in this ImageLoader to the specified stream.
+ * The format parameter can have one of the following values:
+ * <dl>
+ * <dt><code>IMAGE_BMP</code></dt>
+ * <dd>Windows BMP file format, no compression</dd>
+ * <dt><code>IMAGE_BMP_RLE</code></dt>
+ * <dd>Windows BMP file format, RLE compression if appropriate</dd>
+ * <dt><code>IMAGE_GIF</code></dt>
+ * <dd>GIF file format</dd>
+ * <dt><code>IMAGE_ICO</code></dt>
+ * <dd>Windows ICO file format</dd>
+ * <dt><code>IMAGE_JPEG</code></dt>
+ * <dd>JPEG file format</dd>
+ * <dt><code>IMAGE_PNG</code></dt>
+ * <dd>PNG file format</dd>
+ * </dl>
+ *
+ * @param stream the output stream to write the images to
+ * @param format the format to write the images in
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while writing to the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image data contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image data cannot be saved to the requested format</li>
+ * </ul>
+ */
+public void save(OutputStream stream, int format) {
+    if (stream is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    FileFormat.save(stream, format, this);
+}
+
+/**
+ * Saves the image data in this ImageLoader to a file with the specified name.
+ * The format parameter can have one of the following values:
+ * <dl>
+ * <dt><code>IMAGE_BMP</code></dt>
+ * <dd>Windows BMP file format, no compression</dd>
+ * <dt><code>IMAGE_BMP_RLE</code></dt>
+ * <dd>Windows BMP file format, RLE compression if appropriate</dd>
+ * <dt><code>IMAGE_GIF</code></dt>
+ * <dd>GIF file format</dd>
+ * <dt><code>IMAGE_ICO</code></dt>
+ * <dd>Windows ICO file format</dd>
+ * <dt><code>IMAGE_JPEG</code></dt>
+ * <dd>JPEG file format</dd>
+ * <dt><code>IMAGE_PNG</code></dt>
+ * <dd>PNG file format</dd>
+ * </dl>
+ *
+ * @param filename the name of the file to write the images to
+ * @param format the format to write the images in
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while writing to the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image data contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image data cannot be saved to the requested format</li>
+ * </ul>
+ */
+public void save(String filename, int format) {
+    if (filename is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    OutputStream stream = null;
+    try {
+        stream = Compatibility.newFileOutputStream(filename);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    save(stream, format);
+    try {
+        stream.close();
+    } catch (IOException e) {
+    }
+}
+
+/**  
+ * Adds the listener to the collection of listeners who will be
+ * notified when image data is either partially or completely loaded.
+ * <p>
+ * An ImageLoaderListener should be added before invoking
+ * one of the receiver's load methods. The listener's 
+ * <code>imageDataLoaded</code> method is called when image
+ * data has been partially loaded, as is supported by interlaced
+ * GIF/PNG or progressive JPEG images.
+ *
+ * @param listener the listener which should be notified
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @see ImageLoaderListener
+ * @see ImageLoaderEvent
+ */
+public void addImageLoaderListener(ImageLoaderListener listener) {
+    if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    if (imageLoaderListeners is null) {
+        imageLoaderListeners = new Vector();
+    }
+    imageLoaderListeners.addElement(listener);
+}
+
+/**  
+ * Removes the listener from the collection of listeners who will be
+ * notified when image data is either partially or completely loaded.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @see #addImageLoaderListener(ImageLoaderListener)
+ */
+public void removeImageLoaderListener(ImageLoaderListener listener) {
+    if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    if (imageLoaderListeners is null) return;
+    imageLoaderListeners.removeElement(listener);
+}
+
+/**  
+ * Returns <code>true</code> if the receiver has image loader
+ * listeners, and <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if there are <code>ImageLoaderListener</code>s, and <code>false</code> otherwise
+ *
+ * @see #addImageLoaderListener(ImageLoaderListener)
+ * @see #removeImageLoaderListener(ImageLoaderListener)
+ */
+public bool hasListeners() {
+    return imageLoaderListeners !is null && imageLoaderListeners.size() > 0;
+}
+
+/**  
+ * Notifies all image loader listeners that an image loader event
+ * has occurred. Pass the specified event object to each listener.
+ *
+ * @param event the <code>ImageLoaderEvent</code> to send to each <code>ImageLoaderListener</code>
+ */
+public void notifyListeners(ImageLoaderEvent event) {
+    if (!hasListeners()) return;
+    int size = imageLoaderListeners.size();
+    for (int i = 0; i < size; i++) {
+        ImageLoaderListener listener = (ImageLoaderListener) imageLoaderListeners.elementAt(i);
+        listener.imageDataLoaded(event);
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/ImageLoaderEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.ImageLoaderEvent;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of the incremental
+ * loading of image data.
+ * <p>
+ * <b>Notes:</b>
+ * </p><ul>
+ * <li>The number of events which will be sent when loading images
+ * is not constant. It varies by image type, and for JPEG images it 
+ * varies from image to image.</li>
+ * <li>For image sources which contain multiple images, the 
+ * <code>endOfImage</code> flag in the event will be set to true
+ * after each individual image is loaded.</li>
+ * </ul>
+ * 
+ * @see ImageLoader
+ * @see ImageLoaderListener
+ */
+
+public class ImageLoaderEvent extends DWTEventObject {
+    
+    /**
+     * if the <code>endOfImage</code> flag is false, then this is a
+     * partially complete copy of the current <code>ImageData</code>,
+     * otherwise this is a completely loaded <code>ImageData</code>
+     */
+    public ImageData imageData;
+
+    /**
+     * the zero-based count of image data increments -- this is
+     * equivalent to the number of events that have been generated
+     * while loading a particular image
+     */
+    public int incrementCount;
+
+    /**
+     * If this flag is true, then the current image data has been
+     * completely loaded, otherwise the image data is only partially
+     * loaded, and further ImageLoader events will occur unless an
+     * exception is thrown
+     */
+    public bool endOfImage;
+    
+    static final long serialVersionUID = 3257284738325558065L;
+    
+/**
+ * Constructs a new instance of this class given the event source and
+ * the values to store in its fields.
+ *
+ * @param source the ImageLoader that was loading when the event occurred
+ * @param imageData the image data for the event
+ * @param incrementCount the image data increment for the event
+ * @param endOfImage the end of image flag for the event
+ */
+public ImageLoaderEvent(ImageLoader source, ImageData imageData, int incrementCount, bool endOfImage) {
+    super(source);
+    this.imageData = imageData;
+    this.incrementCount = incrementCount;
+    this.endOfImage = endOfImage;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+    return "ImageLoaderEvent {source=" + source + " imageData=" + imageData + " incrementCount=" + incrementCount + " endOfImage=" + endOfImage + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/ImageLoaderListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.ImageLoaderListener;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.DWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the incremental loading of image data. 
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to an image loader using the
+ * <code>addImageLoaderListener</code> method and removed using
+ * the <code>removeImageLoaderListener</code> method. When
+ * image data is either partially or completely loaded, this
+ * method will be invoked.
+ * </p>
+ *
+ * @see ImageLoader
+ * @see ImageLoaderEvent
+ */
+
+public interface ImageLoaderListener extends DWTEventListener {
+
+/**
+ * Sent when image data is either partially or completely loaded.
+ * <p>
+ * The timing of when this method is called varies depending on
+ * the format of the image being loaded.
+ * </p>
+ *
+ * @param e an event containing information about the image loading operation
+ */
+public void imageDataLoaded(ImageLoaderEvent e);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/LineAttributes.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.LineAttributes;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+
+/**
+ * <code>LineAttributes</code> defines a set of line attributes that
+ * can be modified in a GC.
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see GC#getLineAttributes()
+ * @see GC#setLineAttributes(LineAttributes)
+ *  
+ * @since 3.3
+ */
+public class LineAttributes {
+
+    /**
+     * The line width.
+     */
+    public float width;
+
+    /**
+     * The line style.
+     * 
+     * @see dwt.DWT#LINE_CUSTOM
+     * @see dwt.DWT#LINE_DASH
+     * @see dwt.DWT#LINE_DASHDOT
+     * @see dwt.DWT#LINE_DASHDOTDOT
+     * @see dwt.DWT#LINE_DOT
+     * @see dwt.DWT#LINE_SOLID
+     */
+    public int style;
+
+    /**
+     * The line cap style.
+     * 
+     * @see dwt.DWT#CAP_FLAT
+     * @see dwt.DWT#CAP_ROUND
+     * @see dwt.DWT#CAP_SQUARE
+     */
+    public int cap;
+
+    /**
+     * The line join style.
+     * 
+     * @see dwt.DWT#JOIN_BEVEL
+     * @see dwt.DWT#JOIN_MITER
+     * @see dwt.DWT#JOIN_ROUND
+     */
+    public int join;
+
+    /**
+     * The line dash style for DWT.LINE_CUSTOM.
+     */
+    public float[] dash;
+
+    /**
+     * The line dash style offset for DWT.LINE_CUSTOM.
+     */
+    public float dashOffset;
+
+    /**
+     * The line miter limit.
+     */
+    public float miterLimit;
+
+/** 
+ * Create a new line attributes with the specified line width.
+ *
+ * @param width the line width
+ */
+public LineAttributes(float width) {
+    this(width, DWT.CAP_FLAT, DWT.JOIN_MITER, DWT.LINE_SOLID, null, 0, 10);
+}
+    
+/** 
+ * Create a new line attributes with the specified line cap, join and width.
+ *
+ * @param width the line width
+ * @param cap the line cap style
+ * @param join the line join style
+ */
+public LineAttributes(float width, int cap, int join) {
+    this(width, cap, join, DWT.LINE_SOLID, null, 0, 10);
+}
+
+/** 
+ * Create a new line attributes with the specified arguments.
+ *
+ * @param width the line width
+ * @param cap the line cap style
+ * @param join the line join style
+ * @param style the line style
+ * @param dash the line dash style
+ * @param dashOffset the line dash style offset
+ * @param miterLimit the line miter limit
+ */
+public LineAttributes(float width, int cap, int join, int style, float[] dash, float dashOffset, float miterLimit) {
+    this.width = width;
+    this.cap = cap;
+    this.join = join;
+    this.style = style;
+    this.dash = dash;
+    this.dashOffset = dashOffset;
+    this.miterLimit = miterLimit;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/PaletteData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.PaletteData;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+
+/**
+ * Instances of this class describe the color data used by an image.
+ * <p>
+ * Depending on the depth of the image, the PaletteData can take one
+ * of two forms, indicated by the isDirect field:
+ * </p>
+ * <dl>
+ * <dt>
+ * <em>isDirect is false</em>
+ * </dt>
+ * <dd>
+ * If isDirect is <code>false</code>, this palette is an indexed
+ * palette which maps pixel values to RGBs. The actual RGB values
+ * may be retrieved by using the getRGBs() method.
+ * </dd>
+ * <dt>
+ * <em>isDirect is true</em>
+ * </dt>
+ * <dd>
+ * If isDirect is <code>true</code>, this palette is a direct color
+ * palette. Instead of containing RGB values, it contains red,
+ * green and blue mask and shift information which indicates how
+ * the color components may be extracted from a given pixel.
+ * This means that the RGB value is actually encoded in the pixel value.
+ * <p>
+ * In this case, the shift data is the number of bits required to shift
+ * the RGB value to the left in order to align the high bit of the
+ * corresponding mask with the high bit of the first byte. This number
+ * may be negative, so care must be taken when shifting. For example,
+ * with a red mask of 0xFF0000, the red shift would be -16. With a red
+ * mask of 0x1F, the red shift would be 3.
+ * </p>
+ * </dd>
+ * </dl>
+ *
+ * @see Image
+ * @see RGB
+ */
+ 
+public final class PaletteData {
+    
+    /**
+     * true if the receiver is a direct palette, 
+     * and false otherwise
+     */
+    public bool isDirect;
+    
+    /**
+     * the RGB values for an indexed palette, where the
+     * indices of the array correspond to pixel values
+     */
+    public RGB[] colors;
+    
+    /**
+     * the red mask for a direct palette
+     */
+    public int redMask;
+    
+    /**
+     * the green mask for a direct palette
+     */
+    public int greenMask;
+    
+    /**
+     * the blue mask for a direct palette
+     */
+    public int blueMask;
+    
+    /**
+     * the red shift for a direct palette
+     */
+    public int redShift;
+    
+    /**
+     * the green shift for a direct palette
+     */
+    public int greenShift;
+    
+    /**
+     * the blue shift for a direct palette
+     */
+    public int blueShift;
+
+/**
+ * Constructs a new indexed palette given an array of RGB values.
+ *
+ * @param colors the array of <code>RGB</code>s for the palette
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public PaletteData(RGB[] colors) {
+    if (colors is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    this.colors = colors;
+    this.isDirect = false;
+}
+
+/**
+ * Constructs a new direct palette given the red, green and blue masks.
+ *
+ * @param redMask the red mask
+ * @param greenMask the green mask
+ * @param blueMask the blue mask
+ */
+public PaletteData(int redMask, int greenMask, int blueMask) {
+    this.redMask = redMask;
+    this.greenMask = greenMask;
+    this.blueMask = blueMask;
+    this.isDirect = true;
+    this.redShift = shiftForMask(redMask);
+    this.greenShift = shiftForMask(greenMask);
+    this.blueShift = shiftForMask(blueMask);
+}
+
+/**
+ * Returns the pixel value corresponding to the given <code>RGB</code>.
+ *
+ * @param rgb the RGB to get the pixel value for
+ * @return the pixel value for the given RGB
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the RGB is not found in the palette</li>
+ * </ul>
+ */
+public int getPixel(RGB rgb) {
+    if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (isDirect) {
+        int pixel = 0;
+        pixel |= (redShift < 0 ? rgb.red << -redShift : rgb.red >>> redShift) & redMask;
+        pixel |= (greenShift < 0 ? rgb.green << -greenShift : rgb.green >>> greenShift) & greenMask;
+        pixel |= (blueShift < 0 ? rgb.blue << -blueShift : rgb.blue >>> blueShift) & blueMask;
+        return pixel;
+    } else {
+        for (int i = 0; i < colors.length; i++) {
+            if (colors[i].equals(rgb)) return i;
+        }
+        /* The RGB did not exist in the palette */
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        return 0;
+    }
+}
+
+/**
+ * Returns an <code>RGB</code> corresponding to the given pixel value.
+ *
+ * @param pixel the pixel to get the RGB value for
+ * @return the RGB value for the given pixel
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the pixel does not exist in the palette</li>
+ * </ul>
+ */
+public RGB getRGB(int pixel) {
+    if (isDirect) {
+        int r = pixel & redMask;
+        r = (redShift < 0) ? r >>> -redShift : r << redShift;
+        int g = pixel & greenMask;
+        g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+        int b = pixel & blueMask;
+        b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
+        return new RGB(r, g, b);
+    } else {
+        if (pixel < 0 || pixel >= colors.length) {
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+        return colors[pixel];
+    }
+}
+
+/**
+ * Returns all the RGB values in the receiver if it is an
+ * indexed palette, or null if it is a direct palette.
+ *
+ * @return the <code>RGB</code>s for the receiver or null
+ */
+public RGB[] getRGBs() {
+    return colors;
+}
+
+/**
+ * Computes the shift value for a given mask.
+ *
+ * @param mask the mask to compute the shift for
+ * @return the shift amount
+ *
+ * @see PaletteData
+ */
+int shiftForMask(int mask) {
+    for (int i = 31; i >= 0; i--) { 
+        if (((mask >> i) & 0x1) !is 0) return 7 - i;
+    }
+    return 32;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Path.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,569 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Path;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextContainer;
+import dwt.internal.cocoa.NSTextStorage;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class represent paths through the two-dimensional
+ * coordinate system. Paths do not have to be continuous, and can be
+ * described using lines, rectangles, arcs, cubic or quadratic bezier curves,
+ * glyphs, or other paths.
+ * <p>
+ * Application code must explicitly invoke the <code>Path.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <p>
+ * This class requires the operating system's advanced graphics subsystem
+ * which may not be available on some platforms.
+ * </p>
+ * 
+ * @since 3.1
+ */
+public class Path extends Resource {
+    
+    /**
+     * the OS resource for the Path
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public NSBezierPath handle;
+
+/**
+ * Constructs a new empty Path.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the path
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the path could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Path (Device device) {
+    super(device);
+    handle = NSBezierPath.bezierPath();
+    if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
+    handle.retain();
+    handle.moveToPoint(new NSPoint());
+    init();
+}
+
+public Path (Device device, Path path, float flatness) {
+    super(device);
+    if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    flatness = Math.max(0, flatness);
+    if (flatness is 0) {
+        handle = new NSBezierPath(path.handle.copy().id);
+    } else {
+        float defaultFlatness = NSBezierPath.defaultFlatness();
+        NSBezierPath.setDefaultFlatness(flatness);
+        handle = path.handle.bezierPathByFlatteningPath();
+        NSBezierPath.setDefaultFlatness(defaultFlatness);       
+    }
+    if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
+    init();
+}
+
+public Path (Device device, PathData data) {
+    this(device);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    init(data);
+}
+
+/**
+ * Adds to the receiver a circular or elliptical arc that lies within
+ * the specified rectangular area.
+ * <p>
+ * The resulting arc begins at <code>startAngle</code> and extends  
+ * for <code>arcAngle</code> degrees.
+ * Angles are interpreted such that 0 degrees is at the 3 o'clock
+ * position. A positive value indicates a counter-clockwise rotation
+ * while a negative value indicates a clockwise rotation.
+ * </p><p>
+ * The center of the arc is the center of the rectangle whose origin 
+ * is (<code>x</code>, <code>y</code>) and whose size is specified by the 
+ * <code>width</code> and <code>height</code> arguments. 
+ * </p><p>
+ * The resulting arc covers an area <code>width + 1</code> pixels wide
+ * by <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper-left corner of the arc
+ * @param y the y coordinate of the upper-left corner of the arc
+ * @param width the width of the arc
+ * @param height the height of the arc
+ * @param startAngle the beginning angle
+ * @param arcAngle the angular extent of the arc, relative to the start angle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSAffineTransform transform = NSAffineTransform.transform();
+    transform.translateXBy(x + width / 2f, y + height / 2f);
+    transform.scaleXBy(width / 2f, height / 2f);
+    NSBezierPath path = NSBezierPath.bezierPath();
+    NSPoint center = new NSPoint();
+    float sAngle = -startAngle;
+    float eAngle = -(startAngle + arcAngle);
+    path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_(center, 1, sAngle,  eAngle, arcAngle>0);
+    path.transformUsingAffineTransform(transform);
+    handle.appendBezierPath(path);
+}
+
+/**
+ * Adds to the receiver the path described by the parameter.
+ *
+ * @param path the path to add to the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addPath(Path path) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    handle.appendBezierPath(path.handle);
+}
+
+/**
+ * Adds to the receiver the rectangle specified by x, y, width and height.
+ *
+ * @param x the x coordinate of the rectangle to add
+ * @param y the y coordinate of the rectangle to add
+ * @param width the width of the rectangle to add
+ * @param height the height of the rectangle to add
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addRectangle(float x, float y, float width, float height) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
+    handle.appendBezierPathWithRect(rect);
+}
+
+/**
+ * Adds to the receiver the pattern of glyphs generated by drawing
+ * the given string using the given font starting at the point (x, y).
+ *
+ * @param string the text to use
+ * @param x the x coordinate of the starting point
+ * @param y the y coordinate of the starting point
+ * @param font the font to use
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the font is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addString(String string, float x, float y, Font font) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (font is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    NSString str = NSString.stringWith(string);
+    NSTextStorage textStorage = ((NSTextStorage)new NSTextStorage().alloc());
+    textStorage.initWithString_(str);
+    NSLayoutManager layoutManager = (NSLayoutManager)new NSLayoutManager().alloc().init();
+    NSTextContainer textContainer = (NSTextContainer)new NSTextContainer().alloc();
+    NSSize size = new NSSize();
+    size.width = Float.MAX_VALUE;
+    size.height = Float.MAX_VALUE;
+    textContainer.initWithContainerSize(size);
+    textStorage.addLayoutManager(layoutManager);
+    layoutManager.addTextContainer(textContainer);
+    NSRange range = new NSRange();
+    range.length = str.length();
+    textStorage.beginEditing();
+    textStorage.addAttribute(OS.NSFontAttributeName(), font.handle, range);
+    textStorage.endEditing();
+    range = layoutManager.glyphRangeForTextContainer(textContainer);
+    if (range.length !is 0) {
+        int glyphs = OS.malloc(4 * range.length * 2);
+        layoutManager.getGlyphs(glyphs, range);
+        NSBezierPath path = NSBezierPath.bezierPath();
+        NSPoint point = new NSPoint();
+        point.x = x;
+        point.y = y;
+        path.moveToPoint(point);
+        path.appendBezierPathWithGlyphs(glyphs, range.length, font.handle);
+        NSAffineTransform transform = NSAffineTransform.transform();
+        transform.scaleXBy(1, -1);
+        transform.translateXBy(0, -((2*y) + textStorage.size().height));
+        path.transformUsingAffineTransform(transform);
+        OS.free(glyphs);
+        handle.appendBezierPath(path);
+    }
+    textContainer.release();
+    layoutManager.release();
+    textStorage.release();
+}
+
+/**
+ * Closes the current sub path by adding to the receiver a line
+ * from the current point of the path back to the starting point
+ * of the sub path.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void close() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    handle.closePath();
+}
+
+/**
+ * Returns <code>true</code> if the specified point is contained by
+ * the receiver and false otherwise.
+ * <p>
+ * If outline is <code>true</code>, the point (x, y) checked for containment in
+ * the receiver's outline. If outline is <code>false</code>, the point is
+ * checked to see if it is contained within the bounds of the (closed) area
+ * covered by the receiver.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @param gc the GC to use when testing for containment
+ * @param outline controls whether to check the outline or contained area of the path
+ * @return <code>true</code> if the path contains the point and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public bool contains(float x, float y, GC gc, bool outline) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+//  gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH);
+    //TODO outline
+    NSPoint point = new NSPoint();
+    point.x = x;
+    point.y = y;
+    return handle.containsPoint(point);
+}
+
+/**
+ * Adds to the receiver a cubic bezier curve based on the parameters.
+ *
+ * @param cx1 the x coordinate of the first control point of the spline
+ * @param cy1 the y coordinate of the first control of the spline
+ * @param cx2 the x coordinate of the second control of the spline
+ * @param cy2 the y coordinate of the second control of the spline
+ * @param x the x coordinate of the end point of the spline
+ * @param y the y coordinate of the end point of the spline
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    NSPoint ct1 = new NSPoint();
+    ct1.x = cx1;
+    ct1.y = cy1;
+    NSPoint ct2 = new NSPoint();
+    ct2.x = cx2;
+    ct2.y = cy2;
+    handle.curveToPoint(pt, ct1, ct2);
+}
+
+void destroy() {
+    handle.release();
+    handle = null;
+}
+
+/**
+ * Replaces the first four elements in the parameter with values that
+ * describe the smallest rectangle that will completely contain the
+ * receiver (i.e. the bounding box).
+ *
+ * @param bounds the array to hold the result
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the bounding box</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void getBounds(float[] bounds) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (bounds.length < 4) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    NSRect rect = handle.controlPointBounds();
+    bounds[0] = rect.x;
+    bounds[1] = rect.y;
+    bounds[2] = rect.width;
+    bounds[3] = rect.height;
+}
+
+/**
+ * Replaces the first two elements in the parameter with values that
+ * describe the current point of the path.
+ *
+ * @param point the array to hold the result
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the end point</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void getCurrentPoint(float[] point) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (point is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (point.length < 2) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    NSPoint pt = handle.currentPoint();
+    point[0] = pt.x;
+    point[1] = pt.y;
+}
+
+/**
+ * Returns a device independent representation of the receiver.
+ * 
+ * @return the PathData for the receiver
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see PathData
+ */
+public PathData getPathData() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    int count = handle.elementCount();
+    int pointCount = 0, typeCount = 0;
+    byte[] types = new byte[count];
+    float[] pointArray = new float[count * 6];
+    int points = OS.malloc(3 * NSPoint.sizeof);
+    if (points is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    NSPoint pt = new NSPoint();
+    for (int i = 0; i < count; i++) {
+        int element = handle.elementAtIndex_associatedPoints_(i, points);
+        switch (element) {
+            case OS.NSMoveToBezierPathElement:
+                types[typeCount++] = DWT.PATH_MOVE_TO;
+                OS.memmove(pt, points, NSPoint.sizeof);
+                pointArray[pointCount++] = (int)pt.x;
+                pointArray[pointCount++] = (int)pt.y;
+                break;
+            case OS.NSLineToBezierPathElement:
+                types[typeCount++] = DWT.PATH_LINE_TO;
+                OS.memmove(pt, points, NSPoint.sizeof);
+                pointArray[pointCount++] = (int)pt.x;
+                pointArray[pointCount++] = (int)pt.y;
+                break;
+            case OS.NSCurveToBezierPathElement:
+                types[typeCount++] = DWT.PATH_CUBIC_TO;
+                OS.memmove(pt, points, NSPoint.sizeof);
+                pointArray[pointCount++] = (int)pt.x;
+                pointArray[pointCount++] = (int)pt.y;
+                OS.memmove(pt, points + NSPoint.sizeof, NSPoint.sizeof);
+                pointArray[pointCount++] = (int)pt.x;
+                pointArray[pointCount++] = (int)pt.y;
+                OS.memmove(pt, points + NSPoint.sizeof + NSPoint.sizeof, NSPoint.sizeof);
+                pointArray[pointCount++] = (int)pt.x;
+                pointArray[pointCount++] = (int)pt.y;
+                break;
+            case OS.NSClosePathBezierPathElement:
+                types[typeCount++] = DWT.PATH_CLOSE;
+                break;
+        }
+    }
+    OS.free(points);
+    if (pointCount !is pointArray.length) {
+        float[] temp = new float[pointCount];
+        System.arraycopy(pointArray, 0, temp, 0, pointCount);
+        pointArray = temp;
+    }
+    PathData data = new PathData();
+    data.types = types;
+    data.points = pointArray;
+    return data;
+}
+
+void init(PathData data) {
+    byte[] types = data.types;
+    float[] points = data.points;
+    for (int i = 0, j = 0; i < types.length; i++) {
+        switch (types[i]) {
+            case DWT.PATH_MOVE_TO:
+                moveTo(points[j++], points[j++]);
+                break;
+            case DWT.PATH_LINE_TO:
+                lineTo(points[j++], points[j++]);
+                break;
+            case DWT.PATH_CUBIC_TO:
+                cubicTo(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]);
+                break;
+            case DWT.PATH_QUAD_TO:
+                quadTo(points[j++], points[j++], points[j++], points[j++]);
+                break;
+            case DWT.PATH_CLOSE:
+                close();
+                break;
+            default:
+                dispose();
+                DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+}
+
+/**
+ * Returns <code>true</code> if the Path has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the Path.
+ * When a Path has been disposed, it is an error to
+ * invoke any other method using the Path.
+ *
+ * @return <code>true</code> when the Path is disposed, and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+/**
+ * Adds to the receiver a line from the current point to
+ * the point specified by (x, y).
+ *
+ * @param x the x coordinate of the end of the line to add
+ * @param y the y coordinate of the end of the line to add
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void lineTo(float x, float y) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    handle.lineToPoint(pt);
+}
+
+/**
+ * Sets the current point of the receiver to the point
+ * specified by (x, y). Note that this starts a new
+ * sub path.
+ *
+ * @param x the x coordinate of the new end point
+ * @param y the y coordinate of the new end point
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void moveTo(float x, float y) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    handle.moveToPoint(pt);
+
+}
+
+/**
+ * Adds to the receiver a quadratic curve based on the parameters.
+ *
+ * @param cx the x coordinate of the control point of the spline
+ * @param cy the y coordinate of the control point of the spline
+ * @param x the x coordinate of the end point of the spline
+ * @param y the y coordinate of the end point of the spline
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void quadTo(float cx, float cy, float x, float y) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    NSPoint ct = new NSPoint();
+    ct.x = cx;
+    ct.y = cy;
+    handle.curveToPoint(pt, ct, ct);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "Path {*DISPOSED*}";
+    return "Path {" + handle + "}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/PathData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.PathData;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * Instances of this class describe device-independent paths.
+ *
+ * @see Path
+ * 
+ * @since 3.1
+ */
+public final class PathData {
+    
+    /**
+     * The type of each point. 
+     */
+    public byte[] types;
+    
+    /**
+     * The points of a path.
+     */
+    public float[] points;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Pattern.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Pattern;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSGradient;
+import dwt.internal.cocoa.NSPoint;
+
+/**
+ * Instances of this class represent patterns to use while drawing. Patterns
+ * can be specified either as bitmaps or gradients.
+ * <p>
+ * Application code must explicitly invoke the <code>Pattern.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <p>
+ * This class requires the operating system's advanced graphics subsystem
+ * which may not be available on some platforms.
+ * </p>
+ * 
+ * @since 3.1
+ */
+public class Pattern extends Resource {
+    NSColor color;
+    NSGradient gradient;
+    NSPoint pt1, pt2;
+    Image image;
+    float[] color1, color2;
+    int alpha1, alpha2;
+
+/**
+ * Constructs a new Pattern given an image. Drawing with the resulting
+ * pattern will cause the image to be tiled over the resulting area.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the pattern
+ * @param image the image that the pattern will draw
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device, or the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the pattern could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Pattern(Device device, Image image) {
+    super(device);
+    if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    this.image = image;
+    color = NSColor.colorWithPatternImage(image.handle);
+    color.retain();
+    init();
+}
+
+/**
+ * Constructs a new Pattern that represents a linear, two color
+ * gradient. Drawing with the pattern will cause the resulting area to be
+ * tiled with the gradient specified by the arguments.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the pattern
+ * @param x1 the x coordinate of the starting corner of the gradient
+ * @param y1 the y coordinate of the starting corner of the gradient
+ * @param x2 the x coordinate of the ending corner of the gradient
+ * @param y2 the y coordinate of the ending corner of the gradient
+ * @param color1 the starting color of the gradient
+ * @param color2 the ending color of the gradient
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device, 
+ *                              or if either color1 or color2 is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either color1 or color2 has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the pattern could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, Color color2) {
+    this(device, x1, y1, x2, y2, color1, 0xFF, color2, 0xFF);
+}
+/**
+ * Constructs a new Pattern that represents a linear, two color
+ * gradient. Drawing with the pattern will cause the resulting area to be
+ * tiled with the gradient specified by the arguments.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the pattern
+ * @param x1 the x coordinate of the starting corner of the gradient
+ * @param y1 the y coordinate of the starting corner of the gradient
+ * @param x2 the x coordinate of the ending corner of the gradient
+ * @param y2 the y coordinate of the ending corner of the gradient
+ * @param color1 the starting color of the gradient
+ * @param alpha1 the starting alpha value of the gradient
+ * @param color2 the ending color of the gradient
+ * @param alpha2 the ending alpha value of the gradient
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device, 
+ *                              or if either color1 or color2 is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either color1 or color2 has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the pattern could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ * 
+ * @since 3.2
+ */
+public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) {
+    super(device);
+    if (color1 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (color1.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (color2 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (color2.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    pt1 = new NSPoint();
+    pt2 = new NSPoint();
+    pt1.x = x1;
+    pt1.y = y1;
+    pt2.x = x2;
+    pt2.y = y2;
+    this.color1 = color1.handle;
+    this.color2 = color2.handle;
+    this.alpha1 = alpha1;
+    this.alpha2 = alpha2;
+    NSColor start = NSColor.colorWithDeviceRed(color1.handle[0], color1.handle[1], color1.handle[2], alpha1 / 255f);
+    NSColor end = NSColor.colorWithDeviceRed(color2.handle[0], color2.handle[1], color2.handle[2], alpha2 / 255f);
+    gradient = ((NSGradient)new NSGradient().alloc()).initWithStartingColor(start, end);
+    init();
+}
+
+void destroy() {
+    if (color !is null) color.release();
+    color = null;
+    if (gradient !is null) gradient.release();
+    gradient = null;
+    image = null;
+    color1 = color2 = null;
+}
+
+/**
+ * Returns <code>true</code> if the Pattern has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the Pattern.
+ * When a Pattern has been disposed, it is an error to
+ * invoke any other method using the Pattern.
+ *
+ * @return <code>true</code> when the Pattern is disposed, and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return device is null;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString() {
+    if (isDisposed()) return "Pattern {*DISPOSED*}";
+    return "Pattern {" + (color !is null ? color.id : gradient.id) + "}";
+}
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Point.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Point;
+
+import dwt.dwthelper.utils;
+
+import dwt.internal.SerializableCompatibility;
+
+/**
+ * Instances of this class represent places on the (x, y)
+ * coordinate plane.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Rectangle
+ */
+
+public final class Point implements SerializableCompatibility {
+    
+    /**
+     * the x coordinate of the point
+     */
+    public int x;
+    
+    /**
+     * the y coordinate of the point
+     */
+    public int y;
+    
+    static final long serialVersionUID = 3257002163938146354L;
+    
+/**
+ * Constructs a new point with the given x and y coordinates.
+ *
+ * @param x the x coordinate of the new point
+ * @param y the y coordinate of the new point
+ */
+public Point (int x, int y) {
+    this.x = x;
+    this.y = y;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof Point)) return false;
+    Point p = (Point)object;
+    return (p.x is this.x) && (p.y is this.y);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+    return x ^ y;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the point
+ */
+public String toString () {
+    return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/RGB.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.RGB;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.SerializableCompatibility;
+
+/**
+ * Instances of this class are descriptions of colors in
+ * terms of the primary additive color model (red, green and
+ * blue). A color may be described in terms of the relative
+ * intensities of these three primary colors. The brightness
+ * of each color is specified by a value in the range 0 to 255,
+ * where 0 indicates no color (blackness) and 255 indicates
+ * maximum intensity.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Color
+ */
+
+public final class RGB implements SerializableCompatibility {
+    
+    /**
+     * the red component of the RGB
+     */
+    public int red;
+    
+    /**
+     * the green component of the RGB
+     */
+    public int green;
+    
+    /**
+     * the blue component of the RGB
+     */
+    public int blue;
+    
+    static final long serialVersionUID = 3258415023461249074L;
+    
+/**
+ * Constructs an instance of this class with the given
+ * red, green and blue values.
+ *
+ * @param red the red component of the new instance
+ * @param green the green component of the new instance
+ * @param blue the blue component of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
+ * </ul>
+ */
+public RGB(int red, int green, int blue) {
+    if ((red > 255) || (red < 0) ||
+        (green > 255) || (green < 0) ||
+        (blue > 255) || (blue < 0))
+            DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    this.red = red;
+    this.green = green;
+    this.blue = blue;
+}
+
+/**
+* Constructs an instance of this class with the given
+* hue, saturation, and brightness.
+*
+* @param hue the hue value for the HSB color (from 0 to 360)
+* @param saturation the saturation value for the HSB color (from 0 to 1)
+* @param brightness the brightness value for the HSB color (from 0 to 1)
+*
+* @exception IllegalArgumentException <ul>
+*    <li>ERROR_INVALID_ARGUMENT - if the hue is not between 0 and 360 or
+*    the saturation or brightness is not between 0 and 1</li>
+* </ul>
+* 
+* @since 3.2
+*/
+public RGB(float hue, float saturation, float brightness) {
+    if (hue < 0 || hue > 360 || saturation < 0 || saturation > 1 || 
+        brightness < 0 || brightness > 1) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    float r, g, b;
+    if (saturation is 0) {
+        r = g = b = brightness; 
+    } else {
+        if (hue is 360) hue = 0;
+        hue /= 60;  
+        int i = (int)hue;
+        float f = hue - i;
+        float p = brightness * (1 - saturation);
+        float q = brightness * (1 - saturation * f);
+        float t = brightness * (1 - saturation * (1 - f));
+        switch(i) {
+            case 0:
+                r = brightness;
+                g = t;
+                b = p;
+                break;
+            case 1:
+                r = q;
+                g = brightness;
+                b = p;
+                break;
+            case 2:
+                r = p;
+                g = brightness;
+                b = t;
+                break;
+            case 3:
+                r = p;
+                g = q;
+                b = brightness;
+                break;
+            case 4:
+                r = t;
+                g = p;
+                b = brightness;
+                break;
+            case 5:
+            default:
+                r = brightness;
+                g = p;
+                b = q;
+                break;
+        }
+    }
+    red = (int)(r * 255 + 0.5);
+    green = (int)(g * 255 + 0.5);
+    blue = (int)(b * 255 + 0.5);    
+}
+
+/**
+ * Returns the hue, saturation, and brightness of the color.
+ * 
+ * @return color space values in float format (hue, saturation, brightness)
+ *
+ * @since 3.2
+ */
+public float[] getHSB() {   
+    float r = red / 255f;
+    float g = green / 255f;
+    float b = blue / 255f;
+    float max = Math.max(Math.max(r, g), b);
+    float min = Math.min(Math.min(r, g), b);
+    float delta = max - min;
+    float hue = 0;
+    float brightness = max;
+    float saturation = max is 0 ? 0 : (max - min) / max;
+    if (delta !is 0) {
+        if (r is max) {
+            hue = (g  - b) / delta;
+        } else {
+            if (g is max) {
+                hue = 2 + (b - r) / delta;  
+            } else {
+                hue = 4 + (r - g) / delta;
+            }
+        }
+        hue *= 60;
+        if (hue < 0) hue += 360;
+    }
+    return new float[] {hue, saturation, brightness};
+}   
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public bool equals(Object object) {
+    if (object is this) return true;
+    if (!(object instanceof RGB)) return false;
+    RGB rgb = (RGB)object;
+    return (rgb.red is this.red) && (rgb.green is this.green) && (rgb.blue is this.blue);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode() {
+    return (blue << 16) | (green << 8) | red;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the <code>RGB</code>
+ */
+public String toString() {
+    return "RGB {" + red + ", " + green + ", " + blue + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Rectangle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Rectangle;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.SerializableCompatibility;
+
+/**
+ * Instances of this class represent rectangular areas in an
+ * (x, y) coordinate system. The top left corner of the rectangle
+ * is specified by its x and y values, and the extent of the
+ * rectangle is specified by its width and height.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Point
+ */
+
+public final class Rectangle implements SerializableCompatibility {
+    
+    /**
+     * the x coordinate of the rectangle
+     */
+    public int x;
+    
+    /**
+     * the y coordinate of the rectangle
+     */
+    public int y;
+    
+    /**
+     * the width of the rectangle
+     */
+    public int width;
+    
+    /**
+     * the height of the rectangle
+     */
+    public int height;
+
+    static final long serialVersionUID = 3256439218279428914L;
+    
+/**
+ * Construct a new instance of this class given the 
+ * x, y, width and height values.
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ */
+public Rectangle (int x, int y, int width, int height) {
+    this.x = x;
+    this.y = y;
+    this.width = width;
+    this.height = height;
+}
+
+/**
+ * Destructively replaces the x, y, width and height values
+ * in the receiver with ones which represent the union of the
+ * rectangles specified by the receiver and the given rectangle.
+ * <p>
+ * The union of two rectangles is the smallest single rectangle
+ * that completely covers both of the areas covered by the two
+ * given rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public void add (Rectangle rect) {
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    int left = x < rect.x ? x : rect.x;
+    int top = y < rect.y ? y : rect.y;
+    int lhs = x + width;
+    int rhs = rect.x + rect.width;
+    int right = lhs > rhs ? lhs : rhs;
+    lhs = y + height;
+    rhs = rect.y + rect.height;
+    int bottom = lhs > rhs ? lhs : rhs;
+    x = left;  y = top;  width = right - left;  height = bottom - top;
+}
+
+/**
+ * Returns <code>true</code> if the point specified by the
+ * arguments is inside the area specified by the receiver,
+ * and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
+ */
+public bool contains (int x, int y) {
+    return (x >= this.x) && (y >= this.y) && ((x - this.x) < width) && ((y - this.y) < height);
+}
+
+/**
+ * Returns <code>true</code> if the given point is inside the
+ * area specified by the receiver, and <code>false</code>
+ * otherwise.
+ *
+ * @param pt the point to test for containment
+ * @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public bool contains (Point pt) {
+    if (pt is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return contains(pt.x, pt.y);
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof Rectangle)) return false;
+    Rectangle r = (Rectangle)object;
+    return (r.x is this.x) && (r.y is this.y) && (r.width is this.width) && (r.height is this.height);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+    return x ^ y ^ width ^ height;
+}
+
+/**
+ * Destructively replaces the x, y, width and height values
+ * in the receiver with ones which represent the intersection of the
+ * rectangles specified by the receiver and the given rectangle.
+ *
+ * @param rect the rectangle to intersect with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * 
+ * since 3.0
+ */
+public void intersect (Rectangle rect) {
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (this is rect) return;
+    int left = x > rect.x ? x : rect.x;
+    int top = y > rect.y ? y : rect.y;
+    int lhs = x + width;
+    int rhs = rect.x + rect.width;
+    int right = lhs < rhs ? lhs : rhs;
+    lhs = y + height;
+    rhs = rect.y + rect.height;
+    int bottom = lhs < rhs ? lhs : rhs;
+    x = right < left ? 0 : left;
+    y = bottom < top ? 0 : top;
+    width = right < left ? 0 : right - left;
+    height = bottom < top ? 0 : bottom - top;
+}
+
+/**
+ * Returns a new rectangle which represents the intersection
+ * of the receiver and the given rectangle. 
+ * <p>
+ * The intersection of two rectangles is the rectangle that
+ * covers the area which is contained within both rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to intersect with the receiver
+ * @return the intersection of the receiver and the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public Rectangle intersection (Rectangle rect) {
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (this is rect) return new Rectangle (x, y, width, height);
+    int left = x > rect.x ? x : rect.x;
+    int top = y > rect.y ? y : rect.y;
+    int lhs = x + width;
+    int rhs = rect.x + rect.width;
+    int right = lhs < rhs ? lhs : rhs;
+    lhs = y + height;
+    rhs = rect.y + rect.height;
+    int bottom = lhs < rhs ? lhs : rhs;
+    return new Rectangle (
+        right < left ? 0 : left,
+        bottom < top ? 0 : top,
+        right < left ? 0 : right - left,
+        bottom < top ? 0 : bottom - top);
+}
+
+/**
+ * Returns <code>true</code> if the rectangle described by the
+ * arguments intersects with the receiver and <code>false</code>
+ * otherwise.
+ * <p>
+ * Two rectangles intersect if the area of the rectangle
+ * representing their intersection is not empty.
+ * </p>
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ *
+ * @see #intersection(Rectangle)
+ * @see #isEmpty()
+ * 
+ * @since 3.0
+ */
+public bool intersects (int x, int y, int width, int height) {
+    return (x < this.x + this.width) && (y < this.y + this.height) &&
+        (x + width > this.x) && (y + height > this.y);
+}
+
+/**
+ * Returns <code>true</code> if the given rectangle intersects
+ * with the receiver and <code>false</code> otherwise.
+ * <p>
+ * Two rectangles intersect if the area of the rectangle
+ * representing their intersection is not empty.
+ * </p>
+ *
+ * @param rect the rectangle to test for intersection
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ *
+ * @see #intersection(Rectangle)
+ * @see #isEmpty()
+ */
+public bool intersects (Rectangle rect) {
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return rect is this || intersects (rect.x, rect.y, rect.width, rect.height);
+}
+        
+/**
+ * Returns <code>true</code> if the receiver does not cover any
+ * area in the (x, y) coordinate plane, and <code>false</code> if
+ * the receiver does cover some area in the plane.
+ * <p>
+ * A rectangle is considered to <em>cover area</em> in the 
+ * (x, y) coordinate plane if both its width and height are 
+ * non-zero.
+ * </p>
+ *
+ * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
+ */
+public bool isEmpty () {
+    return (width <= 0) || (height <= 0);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the rectangle
+ */
+public String toString () {
+    return "Rectangle {" + x + ", " + y + ", " + width + ", " + height + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+}
+
+/**
+ * Returns a new rectangle which represents the union of
+ * the receiver and the given rectangle.
+ * <p>
+ * The union of two rectangles is the smallest single rectangle
+ * that completely covers both of the areas covered by the two
+ * given rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to perform union with
+ * @return the union of the receiver and the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ *
+ * @see #add(Rectangle)
+ */
+public Rectangle union (Rectangle rect) {
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    int left = x < rect.x ? x : rect.x;
+    int top = y < rect.y ? y : rect.y;
+    int lhs = x + width;
+    int rhs = rect.x + rect.width;
+    int right = lhs > rhs ? lhs : rhs;
+    lhs = y + height;
+    rhs = rect.y + rect.height;
+    int bottom = lhs > rhs ? lhs : rhs;
+    return new Rectangle (left, top, right - left, bottom - top);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Region.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,683 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Region;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.Callback;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class represent areas of an x-y coordinate
+ * system that are aggregates of the areas covered by a number
+ * of polygons.
+ * <p>
+ * Application code must explicitly invoke the <code>Region.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ */
+public final class Region extends Resource {
+    /**
+     * the OS resource for the region
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public int handle;
+
+/**
+ * Constructs a new empty region.
+ * 
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
+ * </ul>
+ */
+public Region() {
+    this(null);
+}
+
+/**
+ * Constructs a new empty region.
+ * <p>
+ * You must dispose the region when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the region
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
+ * </ul>
+ *
+ * @see #dispose
+ * 
+ * @since 3.0
+ */
+public Region(Device device) {
+    super(device);
+    handle = OS.NewRgn();
+    if (handle is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    init();
+}
+
+Region(Device device, int handle) {
+    super(device);
+    this.handle = handle;
+}
+
+/**
+ * Adds the given polygon to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param pointArray points that describe the polygon to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+*
+ */
+public void add (int[] pointArray) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    add(pointArray, pointArray.length);
+}
+    
+void add(int[] pointArray, int count) {
+    if (count <= 2) return;
+    int polyRgn = OS.NewRgn();
+    OS.OpenRgn();
+    OS.MoveTo((short)pointArray[0], (short)pointArray[1]);
+    for (int i = 1; i < count / 2; i++) {
+        OS.LineTo((short)pointArray[2 * i], (short)pointArray[2 * i + 1]);
+    }
+    OS.LineTo((short)pointArray[0], (short)pointArray[1]);
+    OS.CloseRgn(polyRgn);
+    OS.UnionRgn(handle, polyRgn, handle);
+    OS.DisposeRgn(polyRgn);
+}
+
+/**
+ * Adds the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param rect the rectangle to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void add(Rectangle rect) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (rect.width < 0 || rect.height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    add (rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Adds the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width coordinate of the rectangle
+ * @param height the height coordinate of the rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void add(int x, int y, int width, int height) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int rectRgn = OS.NewRgn();
+    short[] r = new short[4];
+    OS.SetRect(r, (short)x, (short)y, (short)(x + width),(short)(y + height));
+    OS.RectRgn(rectRgn, r);
+    OS.UnionRgn(handle, rectRgn, handle);
+    OS.DisposeRgn(rectRgn);
+}
+
+/**
+ * Adds all of the polygons which make up the area covered
+ * by the argument to the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @param region the region to merge
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void add(Region region) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (region is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    OS.UnionRgn(handle, region.handle, handle);
+}
+
+/**
+ * Returns <code>true</code> if the point specified by the
+ * arguments is inside the area specified by the receiver,
+ * and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public bool contains(int x, int y) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    short[] point = new short[]{(short)x, (short)y};
+    return OS.PtInRgn(point, handle);
+}
+
+/**
+ * Returns <code>true</code> if the given point is inside the
+ * area specified by the receiver, and <code>false</code>
+ * otherwise.
+ *
+ * @param pt the point to test for containment
+ * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public bool contains(Point pt) {
+    if (pt is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return contains(pt.x, pt.y);
+}
+
+NSAffineTransform transform;
+void convertRgn(NSAffineTransform transform) {
+    int newRgn = OS.NewRgn();
+    Callback callback = new Callback(this, "convertRgn", 4);
+    int proc = callback.getAddress();
+    if (proc is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+    this.transform = transform;
+    OS.QDRegionToRects(handle, OS.kQDParseRegionFromTopLeft, proc, newRgn);
+    this.transform = null;
+    callback.dispose();
+    OS.CopyRgn(newRgn, handle);
+    OS.DisposeRgn(newRgn);
+}
+
+int convertRgn(int message, int rgn, int r, int newRgn) {
+    if (message is OS.kQDRegionToRectsMsgParse) {
+        short[] rect = new short[4];
+        OS.memmove(rect, r, rect.length * 2);
+        NSPoint point = new NSPoint(); 
+        int polyRgn = OS.NewRgn();
+        OS.OpenRgn();
+        point.x = rect[1];
+        point.y = rect[0];
+        point = transform.transformPoint(point);
+        short startX, startY;
+        OS.MoveTo(startX = (short)point.x, startY = (short)point.y);
+        point.x = rect[3];
+        point.y = rect[0];
+        point = transform.transformPoint(point);
+        OS.LineTo((short)Math.round(point.x), (short)point.y);
+        point.x = rect[3];
+        point.y = rect[2];
+        point = transform.transformPoint(point);
+        OS.LineTo((short)Math.round(point.x), (short)Math.round(point.y));
+        point.x = rect[1];
+        point.y = rect[2];
+        point = transform.transformPoint(point);
+        OS.LineTo((short)point.x, (short)Math.round(point.y));
+        OS.LineTo(startX, startY);
+        OS.CloseRgn(polyRgn);
+        OS.UnionRgn(newRgn, polyRgn, newRgn);
+        OS.DisposeRgn(polyRgn);
+    }
+    return 0;
+}
+
+void destroy() {
+    OS.DisposeRgn(handle);
+    handle = 0;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public bool equals(Object object) {
+    if (this is object) return true;
+    if (!(object instanceof Region)) return false;
+    Region region = (Region)object;
+    return handle is region.handle;
+}
+
+/**
+ * Returns a rectangle which represents the rectangular
+ * union of the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @return a bounding rectangle for the region
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#union
+ */
+public Rectangle getBounds() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    short[] bounds = new short[4];
+    OS.GetRegionBounds(handle, bounds);
+    int width = bounds[3] - bounds[1];
+    int height = bounds[2] - bounds[0];
+    return new Rectangle(bounds[1], bounds[0], width, height);
+}
+
+NSBezierPath getPath() {
+    Callback callback = new Callback(this, "regionToRects", 4);
+    if (callback.getAddress() is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
+    NSBezierPath path = NSBezierPath.bezierPath();
+    path.retain();
+    OS.QDRegionToRects(handle, OS.kQDParseRegionFromTopLeft, callback.getAddress(), path.id);
+    callback.dispose();
+    if (path.isEmpty()) path.appendBezierPathWithRect(new NSRect());
+    return path;
+}
+
+NSPoint pt = new NSPoint();
+short[] rect = new short[4];
+int regionToRects(int message, int rgn, int r, int path) {
+    if (message is OS.kQDRegionToRectsMsgParse) {
+        OS.memmove(rect, r, rect.length * 2);
+        pt.x = rect[1];
+        pt.y = rect[0];
+        OS.objc_msgSend(path, OS.sel_moveToPoint_1, pt);
+        pt.x = rect[3];
+        OS.objc_msgSend(path, OS.sel_lineToPoint_1, pt);
+        pt.x = rect[3];
+        pt.y = rect[2];
+        OS.objc_msgSend(path, OS.sel_lineToPoint_1, pt);
+        pt.x = rect[1];
+        OS.objc_msgSend(path, OS.sel_lineToPoint_1, pt);
+        OS.objc_msgSend(path, OS.sel_closePath);
+    }
+    return 0;
+}
+
+public static Region carbon_new(Device device, int handle) {
+    return new Region(device, handle);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+    return handle;
+}
+
+/**
+ * Intersects the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param rect the rectangle to intersect with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void intersect(Rectangle rect) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    intersect (rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Intersects the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width coordinate of the rectangle
+ * @param height the height coordinate of the rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void intersect(int x, int y, int width, int height) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int rectRgn = OS.NewRgn();
+    short[] r = new short[4];
+    OS.SetRect(r, (short)x, (short)y, (short)(x + width),(short)(y + height));
+    OS.RectRgn(rectRgn, r);
+    OS.SectRgn(handle, rectRgn, handle);
+    OS.DisposeRgn(rectRgn);
+}
+
+/**
+ * Intersects all of the polygons which make up the area covered
+ * by the argument to the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @param region the region to intersect
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void intersect(Region region) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (region is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    OS.SectRgn(handle, region.handle, handle);
+}
+
+/**
+ * Returns <code>true</code> if the rectangle described by the
+ * arguments intersects with any of the polygons the receiver
+ * maintains to describe its area, and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#intersects(Rectangle)
+ */
+public bool intersects (int x, int y, int width, int height) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    short[] r = new short[4];
+    OS.SetRect(r, (short)x, (short)y, (short)(x + width),(short)(y + height));
+    return OS.RectInRgn(rect, handle);
+}
+
+/**
+ * Returns <code>true</code> if the given rectangle intersects
+ * with any of the polygons the receiver maintains to describe
+ * its area and <code>false</code> otherwise.
+ *
+ * @param rect the rectangle to test for intersection
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#intersects(Rectangle)
+ */
+public bool intersects(Rectangle rect) {
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return intersects(rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Returns <code>true</code> if the region has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the region.
+ * When a region has been disposed, it is an error to
+ * invoke any other method using the region.
+ *
+ * @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver does not cover any
+ * area in the (x, y) coordinate plane, and <code>false</code> if
+ * the receiver does cover some area in the plane.
+ *
+ * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public bool isEmpty() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return OS.EmptyRgn(handle);
+}
+
+/**
+ * Subtracts the given polygon from the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param pointArray points that describe the polygon to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void subtract (int[] pointArray) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (pointArray.length < 2) return;
+    int polyRgn = OS.NewRgn();
+    OS.OpenRgn();
+    OS.MoveTo((short)pointArray[0], (short)pointArray[1]);
+    for (int i = 1; i < pointArray.length / 2; i++) {
+        OS.LineTo((short)pointArray[2 * i], (short)pointArray[2 * i + 1]);
+    }
+    OS.LineTo((short)pointArray[0], (short)pointArray[1]);
+    OS.CloseRgn(polyRgn);
+    OS.DiffRgn(handle, polyRgn, handle);
+    OS.DisposeRgn(polyRgn);
+}
+
+/**
+ * Subtracts the given rectangle from the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param rect the rectangle to subtract from the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void subtract(Rectangle rect) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    subtract (rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Subtracts the given rectangle from the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width coordinate of the rectangle
+ * @param height the height coordinate of the rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void subtract(int x, int y, int width, int height) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (width < 0 || height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int rectRgn = OS.NewRgn();
+    short[] r = new short[4];
+    OS.SetRect(r, (short)x, (short)y, (short)(x + width),(short)(y + height));
+    OS.RectRgn(rectRgn, r);
+    OS.DiffRgn(handle, rectRgn, handle);
+    OS.DisposeRgn(rectRgn);
+}
+
+/**
+ * Subtracts all of the polygons which make up the area covered
+ * by the argument from the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @param region the region to subtract
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void subtract(Region region) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (region is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    OS.DiffRgn(handle, region.handle, handle);
+}
+
+/**
+ * Translate all of the polygons the receiver maintains to describe
+ * its area by the specified point.
+ *
+ * @param x the x coordinate of the point to translate
+ * @param y the y coordinate of the point to translate
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void translate (int x, int y) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    OS.OffsetRgn (handle, (short)x, (short)y);
+}
+
+/**
+ * Translate all of the polygons the receiver maintains to describe
+ * its area by the specified point.
+ *
+ * @param pt the point to translate
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void translate (Point pt) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pt is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    translate (pt.x, pt.y);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "Region {*DISPOSED*}";
+    return "Region {" + handle + "}";
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Resource.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Resource;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+
+/**
+ * This class is the abstract superclass of all graphics resource objects.  
+ * Resources created by the application must be disposed.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation. However, it has not been marked
+ * final to allow those outside of the DWT development team to implement
+ * patched versions of the class in order to get around specific
+ * limitations in advance of when those limitations can be addressed
+ * by the team.  Any class built using subclassing to access the internals
+ * of this class will likely fail to compile or run between releases and
+ * may be strongly platform specific. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the workings of the
+ * hierarchy. No support is provided for user-written classes which are
+ * implemented as subclasses of this class.
+ * </p>
+ *
+ * @see #dispose
+ * @see #isDisposed
+ * 
+ * @since 3.1
+ */
+public abstract class Resource {
+    
+    /**
+     * the device where this resource was created
+     */
+    Device device;
+
+Resource() {
+}
+
+Resource(Device device) {
+    if (device is null) device = Device.getDevice();
+    if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    this.device = device;
+}
+
+void destroy() {
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * this resource. Applications must dispose of all resources
+ * which they allocate.
+ */
+public void dispose() {
+    if (device is null) return;
+    if (device.isDisposed()) return;
+    destroy();
+    if (device.tracking) device.dispose_Object(this);
+    device = null;
+}
+
+/**
+ * Returns the <code>Device</code> where this resource was
+ * created.
+ *
+ * @return <code>Device</code> the device of the receiver
+ * 
+ * @since 3.2
+ */
+public Device getDevice() {
+    Device device = this.device;
+    if (device is null || isDisposed ()) DWT.error (DWT.ERROR_GRAPHIC_DISPOSED);
+    return device;
+}
+
+void init() {
+    if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Returns <code>true</code> if the resource has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the resource.
+ * When a resource has been disposed, it is an error to
+ * invoke any other method using the resource.
+ *
+ * @return <code>true</code> when the resource is disposed and <code>false</code> otherwise
+ */
+public abstract bool isDisposed();
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/TextLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1450 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.TextLayout;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSMutableParagraphStyle;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextContainer;
+import dwt.internal.cocoa.NSTextStorage;
+import dwt.internal.cocoa.OS;
+
+/**
+ * <code>TextLayout</code> is a graphic object that represents
+ * styled text.
+ * <p>
+ * Instances of this class provide support for drawing, cursor
+ * navigation, hit testing, text wrapping, alignment, tab expansion
+ * line breaking, etc.  These are aspects required for rendering internationalized text.
+ * </p><p>
+ * Application code must explicitly invoke the <code>TextLayout#dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * 
+ *  @since 3.0
+ */
+public final class TextLayout extends Resource {
+    
+    NSTextStorage textStorage;
+    NSLayoutManager layoutManager;
+    NSTextContainer textContainer;
+    Font font;
+    String text;
+    StyleItem[] styles;
+    int spacing, ascent, descent, indent;
+    bool justify;
+    int alignment;
+    int[] tabs;
+    int[] segments;
+    int wrapWidth;
+    int orientation;
+    
+    int[] lineOffsets;
+    NSRect[] lineBounds;
+
+    static class StyleItem {
+        TextStyle style;
+        int start;
+
+        public String toString () {
+            return "StyleItem {" + start + ", " + style + "}";
+        }
+    }
+
+//  static final int TAB_COUNT = 32;
+//  static final char ZWS = '\u200B';
+//  
+//  static final int UNDERLINE_IME_INPUT = 1 << 16;
+//  static final int UNDERLINE_IME_TARGET_CONVERTED = 2 << 16;
+//  static final int UNDERLINE_IME_CONVERTED = 3 << 16;
+    
+/**  
+ * Constructs a new instance of this class on the given device.
+ * <p>
+ * You must dispose the text layout when it is no longer required. 
+ * </p>
+ * 
+ * @param device the device on which to allocate the text layout
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public TextLayout (Device device) {
+    super(device);
+    wrapWidth = ascent = descent = -1;
+    alignment = DWT.LEFT;
+    orientation = DWT.LEFT_TO_RIGHT;
+    text = "";
+    styles = new StyleItem[2];
+    styles[0] = new StyleItem();
+    styles[1] = new StyleItem();
+    init();
+}
+
+void checkLayout() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+}
+
+void computeRuns() {
+    if (textStorage !is null) return;
+    NSString str = NSString.stringWith(text);
+    textStorage = ((NSTextStorage)new NSTextStorage().alloc());
+    textStorage.initWithString_(str);
+    layoutManager = (NSLayoutManager)new NSLayoutManager().alloc().init();
+    textContainer = (NSTextContainer)new NSTextContainer().alloc();
+    NSSize size = new NSSize();
+    size.width = wrapWidth !is -1 ? wrapWidth : Float.MAX_VALUE;
+    size.height = Float.MAX_VALUE;
+    textContainer.initWithContainerSize(size);
+    textStorage.addLayoutManager(layoutManager);
+    layoutManager.addTextContainer(textContainer);
+    
+    textStorage.beginEditing();
+    Font defaultFont = font !is null ? font : device.systemFont;
+    NSRange range = new NSRange();
+    range.length = str.length();
+    textStorage.addAttribute(OS.NSFontAttributeName(), defaultFont.handle, range);
+    
+    NSMutableParagraphStyle paragraph = (NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init();
+    int align = OS.NSLeftTextAlignment;
+    if (justify) {
+        align = OS.NSJustifiedTextAlignment;
+    } else {
+        switch (alignment) {
+            case DWT.CENTER:
+                align = OS.NSCenterTextAlignment;
+                break;
+            case DWT.RIGHT:
+                align = OS.NSRightTextAlignment;
+        }
+    }
+    paragraph.setAlignment(align);
+    paragraph.setLineSpacing(spacing);
+    paragraph.setFirstLineHeadIndent(indent);
+    
+    //TODO tabs ascend descent wrap
+    
+    textStorage.addAttribute(OS.NSParagraphStyleAttributeName(), paragraph, range);
+    paragraph.release();
+    
+    int textLength = str.length();
+    for (int i = 0; i < styles.length - 1; i++) {
+        StyleItem run = styles[i];
+        if (run.style is null) continue;
+        TextStyle style = run.style;        
+        range.location = textLength !is 0 ? translateOffset(run.start) : 0;
+        range.length = translateOffset(styles[i + 1].start) - range.location;
+        Font font = style.font;
+        if (font !is null) {
+            textStorage.addAttribute(OS.NSFontAttributeName(), font.handle, range);
+        }
+        Color foreground = style.foreground;
+        if (foreground !is null) {
+            NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
+            textStorage.addAttribute(OS.NSForegroundColorAttributeName(), color, range);
+        }
+        Color background = style.background;
+        if (background !is null) {
+            NSColor color = NSColor.colorWithDeviceRed(background.handle[0], background.handle[1], background.handle[2], 1);
+            textStorage.addAttribute(OS.NSBackgroundColorAttributeName(), color, range);
+        }
+        if (style.strikeout) {
+            textStorage.addAttribute(OS.NSStrikethroughStyleAttributeName(), NSNumber.numberWithInt(OS.NSUnderlineStyleSingle), range);
+            Color strikeColor = style.strikeoutColor;
+            if (strikeColor !is null) {
+                NSColor color = NSColor.colorWithDeviceRed(strikeColor.handle[0], strikeColor.handle[1], strikeColor.handle[2], 1);
+                textStorage.addAttribute(OS.NSStrikethroughColorAttributeName(), color, range);
+            }
+        }
+        if (style.underline) {
+            //TODO - IME - thick
+            int underlineStyle = 0;
+            switch (style.underlineStyle) {
+                case DWT.UNDERLINE_SINGLE:
+                    underlineStyle = OS.NSUnderlineStyleSingle;
+                    break;
+                case DWT.UNDERLINE_DOUBLE:
+                    underlineStyle = OS.NSUnderlineStyleDouble;
+                    break;
+            }
+            if (underlineStyle !is 0) {
+                textStorage.addAttribute(OS.NSUnderlineStyleAttributeName(), NSNumber.numberWithInt(underlineStyle), range);
+                Color underlineColor = style.underlineColor;
+                if (underlineColor !is null) {
+                    NSColor color = NSColor.colorWithDeviceRed(underlineColor.handle[0], underlineColor.handle[1], underlineColor.handle[2], 1);
+                    textStorage.addAttribute(OS.NSUnderlineColorAttributeName(), color, range);
+                }
+            }
+        }
+        if (style.rise !is 0) {
+            textStorage.addAttribute(OS.NSBaselineOffsetAttributeName(), NSNumber.numberWithInt(style.rise), range);
+        }
+        if (style.metrics !is null) {
+            //TODO
+        }
+    }
+    textStorage.endEditing();
+    
+    textContainer.setLineFragmentPadding(0);    
+    layoutManager.glyphRangeForTextContainer(textContainer);
+    
+    int numberOfLines, index, numberOfGlyphs = layoutManager.numberOfGlyphs();
+    int rangePtr = OS.malloc(NSRange.sizeof);
+    NSRange lineRange = new NSRange();
+    for (numberOfLines = 0, index = 0; index < numberOfGlyphs; numberOfLines++){
+        layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_(index, rangePtr, true);
+        OS.memmove(lineRange, rangePtr, NSRange.sizeof);
+        index = lineRange.location + lineRange.length;
+    }
+    if (numberOfLines is 0) numberOfLines++;
+    int[] offsets = new int[numberOfLines + 1];
+    NSRect[] bounds = new NSRect[numberOfLines];
+    for (numberOfLines = 0, index = 0; index < numberOfGlyphs; numberOfLines++){
+        bounds[numberOfLines] = layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_(index, rangePtr, true);
+        OS.memmove(lineRange, rangePtr, NSRange.sizeof);
+        offsets[numberOfLines] = lineRange.location;
+        index = lineRange.location + lineRange.length;
+    }
+    if (numberOfLines is 0) {
+        Font font = this.font !is null ? this.font : device.systemFont;
+        NSFont nsFont = font.handle;
+        bounds[0] = new NSRect();
+        bounds[0].height = Math.max(layoutManager.defaultLineHeightForFont(nsFont), ascent + descent);
+    }
+    OS.free(rangePtr);
+    offsets[numberOfLines] = textStorage.length();
+    this.lineOffsets = offsets;
+    this.lineBounds = bounds;
+}
+
+void destroy() {
+    freeRuns();
+    font = null;
+    text = null;
+    styles = null;
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ * 
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ * </ul>
+ */
+public void draw(GC gc, int x, int y) {
+    draw(gc, x, y, -1, -1, null, null);
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ * 
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param selectionStart the offset where the selections starts, or -1 indicating no selection
+ * @param selectionEnd the offset where the selections ends, or -1 indicating no selection
+ * @param selectionForeground selection foreground, or NULL to use the system default color
+ * @param selectionBackground selection background, or NULL to use the system default color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ * </ul>
+ */
+public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
+    draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ * <p>
+ * The parameter <code>flags</code> can include one of <code>DWT.DELIMITER_SELECTION</code>
+ * or <code>DWT.FULL_SELECTION</code> to specify the selection behavior on all lines except
+ * for the last line, and can also include <code>DWT.LAST_LINE_SELECTION</code> to extend
+ * the specified selection behavior to the last line.
+ * </p>
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param selectionStart the offset where the selections starts, or -1 indicating no selection
+ * @param selectionEnd the offset where the selections ends, or -1 indicating no selection
+ * @param selectionForeground selection foreground, or NULL to use the system default color
+ * @param selectionBackground selection background, or NULL to use the system default color
+ * @param flags drawing options
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {
+    checkLayout ();
+    computeRuns();
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (selectionForeground !is null && selectionForeground.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (selectionBackground !is null && selectionBackground.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    gc.checkGC(GC.CLIPPING | GC.TRANSFORM | GC.FOREGROUND);
+//  float[] foreground = gc.data.foreground;
+//  NSColor color = NSColor.colorWithDeviceRed(foreground[0], foreground[1], foreground[2], foreground[3]);
+//  textStorage.setForegroundColor(color);
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    NSRange range = new NSRange();
+    range.length = layoutManager.numberOfGlyphs();
+    bool hasSelection = selectionStart <= selectionEnd && selectionStart !is -1 && selectionEnd !is -1;
+    NSRange selectionRange = null;
+    if (hasSelection) {
+        selectionRange = new NSRange();
+        selectionRange.location = selectionStart;
+        selectionRange.length = selectionEnd - selectionStart + 1;
+        if (selectionBackground is null) selectionBackground = device.getSystemColor(DWT.COLOR_LIST_SELECTION);
+        NSColor selectionColor = NSColor.colorWithDeviceRed(selectionBackground.handle[0], selectionBackground.handle[1], selectionBackground.handle[2], selectionBackground.handle[3]);
+        layoutManager.addTemporaryAttribute(OS.NSBackgroundColorAttributeName, selectionColor, selectionRange);
+    }
+    //TODO draw selection for flags (LAST_LINE_SELECTION and FULL_SELECTION)
+    if (range.length > 0) {
+        layoutManager.drawBackgroundForGlyphRange(range, pt);
+        layoutManager.drawGlyphsForGlyphRange(range, pt);
+    }
+    if (selectionRange !is null) {
+        layoutManager.removeTemporaryAttribute(OS.NSBackgroundColorAttributeName, selectionRange);
+    }
+}
+
+void freeRuns() {
+    if (textStorage is null) return;
+    if (textStorage !is null) {
+        textStorage.release();
+    }
+    if (layoutManager !is null) {
+        layoutManager.release();
+    }
+    if (textContainer !is null) {
+        textContainer.release();
+    }
+    textStorage = null;
+    layoutManager = null;
+    textContainer = null;
+}
+
+/** 
+ * Returns the receiver's horizontal text alignment, which will be one
+ * of <code>DWT.LEFT</code>, <code>DWT.CENTER</code> or
+ * <code>DWT.RIGHT</code>.
+ *
+ * @return the alignment used to positioned text horizontally
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getAlignment() {
+    checkLayout();
+    return alignment;
+}
+
+/**
+ * Returns the ascent of the receiver.
+ *
+ * @return the ascent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getDescent()
+ * @see #setDescent(int)
+ * @see #setAscent(int)
+ * @see #getLineMetrics(int)
+ */
+public int getAscent () {
+    checkLayout();  
+    return ascent;
+}
+
+/**
+ * Returns the bounds of the receiver.
+ * 
+ * @return the bounds of the receiver
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getBounds() {
+    checkLayout();
+    computeRuns();
+    NSRect rect = layoutManager.usedRectForTextContainer(textContainer);
+    if (wrapWidth !is -1) rect.width = wrapWidth;
+    if (text.length() is 0) {
+        Font font = this.font !is null ? this.font : device.systemFont;
+        NSFont nsFont = font.handle;
+        rect.height = Math.max(rect.height, layoutManager.defaultLineHeightForFont(nsFont));
+    }
+    rect.height = Math.max(rect.height, ascent + descent);
+    return new Rectangle(0, 0, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns the bounds for the specified range of characters. The
+ * bounds is the smallest rectangle that encompasses all characters
+ * in the range. The start and end offsets are inclusive and will be
+ * clamped if out of range.
+ * 
+ * @param start the start offset
+ * @param end the end offset
+ * @return the bounds of the character range
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getBounds(int start, int end) {
+    checkLayout();
+    computeRuns();
+    int length = text.length();
+    if (length is 0) return new Rectangle(0, 0, 0, 0);
+    if (start > end) return new Rectangle(0, 0, 0, 0);
+    start = Math.min(Math.max(0, start), length - 1);
+    end = Math.min(Math.max(0, end), length - 1);
+    start = translateOffset(start);
+    end = translateOffset(end);
+    NSRange range = new NSRange();
+    range.location = layoutManager.glyphIndexForCharacterAtIndex(start);
+    range.length = layoutManager.glyphIndexForCharacterAtIndex(end + 1) - range.location;
+    NSRect rect = layoutManager.boundingRectForGlyphRange(range, textContainer);
+    return new Rectangle((int)rect.x, (int)rect.y, (int)Math.ceil(rect.width), (int)Math.ceil(rect.height));
+}
+
+/**
+ * Returns the descent of the receiver.
+ *
+ * @return the descent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getAscent()
+ * @see #setAscent(int)
+ * @see #setDescent(int)
+ * @see #getLineMetrics(int)
+ */
+public int getDescent () {
+    checkLayout();  
+    return descent;
+}
+
+/** 
+ * Returns the default font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getFont () {
+    checkLayout();
+    return font;
+}
+
+/**
+* Returns the receiver's indent.
+*
+* @return the receiver's indent
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+* </ul>
+* 
+* @since 3.2
+*/
+public int getIndent () {
+    checkLayout();  
+    return indent;
+}
+
+/**
+* Returns the receiver's justification.
+*
+* @return the receiver's justification
+* 
+* @exception DWTException <ul>
+*    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+* </ul>
+* 
+* @since 3.2
+*/
+public bool getJustify () {
+    checkLayout();
+    return justify;
+}
+
+/**
+ * Returns the embedding level for the specified character offset. The
+ * embedding level is usually used to determine the directionality of a
+ * character in bidirectional text.
+ * 
+ * @param offset the character offset
+ * @return the embedding level
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the character offset is out of range</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ */
+public int getLevel(int offset) {
+    checkLayout();
+    computeRuns();
+    int length = text.length();
+    if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+    offset = translateOffset(offset);   
+    int level = 0;
+    //TODO
+    return level;
+}
+
+/**
+ * Returns the line offsets.  Each value in the array is the
+ * offset for the first character in a line except for the last
+ * value, which contains the length of the text.
+ * 
+ * @return the line offsets
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int[] getLineOffsets() {
+    checkLayout ();
+    computeRuns();
+    int[] offsets = new int[lineOffsets.length];
+    for (int i = 0; i < offsets.length; i++) {
+        offsets[i] = untranslateOffset(lineOffsets[i]);
+    }
+    return offsets;
+}
+
+/**
+ * Returns the index of the line that contains the specified
+ * character offset.
+ * 
+ * @param offset the character offset
+ * @return the line index
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the character offset is out of range</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineIndex(int offset) {
+    checkLayout ();
+    computeRuns();
+    int length = text.length();
+    if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+    offset = translateOffset(offset);
+    for (int line=0; line<lineOffsets.length - 1; line++) {
+        if (lineOffsets[line + 1] > offset) {
+            return line;
+        }
+    }
+    return lineBounds.length - 1;
+}
+
+/**
+ * Returns the bounds of the line for the specified line index.
+ * 
+ * @param lineIndex the line index
+ * @return the line bounds 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the line index is out of range</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getLineBounds(int lineIndex) {
+    checkLayout();
+    computeRuns();
+    if (!(0 <= lineIndex && lineIndex < lineBounds.length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+    NSRect rect = lineBounds[lineIndex];
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns the receiver's line count. This includes lines caused
+ * by wrapping.
+ *
+ * @return the line count
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineCount() {
+    checkLayout ();
+    computeRuns();  
+    return lineOffsets.length - 1;
+}
+
+/**
+ * Returns the font metrics for the specified line index.
+ * 
+ * @param lineIndex the line index
+ * @return the font metrics 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the line index is out of range</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontMetrics getLineMetrics (int lineIndex) {
+    checkLayout ();
+    computeRuns();
+    int lineCount = getLineCount();
+    if (!(0 <= lineIndex && lineIndex < lineCount)) DWT.error(DWT.ERROR_INVALID_RANGE);
+    int length = text.length();
+    if (length is 0) {
+        Font font = this.font !is null ? this.font : device.systemFont;
+        NSFont nsFont = font.handle;
+        int ascent = (int)(0.5f + nsFont.ascender());
+        int descent = (int)(0.5f + (-nsFont.descender() + nsFont.leading()));   
+        ascent = Math.max(ascent, this.ascent);
+        descent = Math.max(descent, this.descent);
+        return FontMetrics.cocoa_new(ascent, descent, 0, 0, ascent + descent);
+    }
+    Rectangle rect = getLineBounds(lineIndex);
+    int baseline = (int)layoutManager.typesetter().baselineOffsetInLayoutManager(layoutManager, getLineOffsets()[lineIndex]);
+    return FontMetrics.cocoa_new(rect.height - baseline, baseline, 0, 0, rect.height);
+}
+
+/**
+ * Returns the location for the specified character offset. The
+ * <code>trailing</code> argument indicates whether the offset
+ * corresponds to the leading or trailing edge of the cluster.
+ * 
+ * @param offset the character offset
+ * @param trailing the trailing flag
+ * @return the location of the character offset
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getOffset(Point, int[])
+ * @see #getOffset(int, int, int[])
+ */
+public Point getLocation(int offset, bool trailing) {
+    checkLayout();
+    computeRuns();
+    int length = text.length();
+    if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+    if (length is 0) return new Point(0, 0);
+    offset = translateOffset(offset);
+    int glyphIndex = layoutManager.glyphIndexForCharacterAtIndex(offset);
+    NSRect rect = layoutManager.lineFragmentUsedRectForGlyphAtIndex_effectiveRange_(glyphIndex, 0);
+    NSPoint point = layoutManager.locationForGlyphAtIndex(glyphIndex);
+    if (trailing) {
+        NSRange range = new NSRange();
+        range.location = glyphIndex;
+        range.length = 1;
+        NSRect bounds = layoutManager.boundingRectForGlyphRange(range, textContainer);
+        point.x += bounds.width;
+    }
+    return new Point((int)point.x, (int)rect.y);
+}
+
+/**
+ * Returns the next offset for the specified offset and movement
+ * type.  The movement is one of <code>DWT.MOVEMENT_CHAR</code>, 
+ * <code>DWT.MOVEMENT_CLUSTER</code>, <code>DWT.MOVEMENT_WORD</code>,
+ * <code>DWT.MOVEMENT_WORD_END</code> or <code>DWT.MOVEMENT_WORD_START</code>.
+ * 
+ * @param offset the start offset
+ * @param movement the movement type 
+ * @return the next offset
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the offset is out of range</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getPreviousOffset(int, int)
+ */
+public int getNextOffset (int offset, int movement) {
+    return _getOffset(offset, movement, true);
+}
+
+int _getOffset (int offset, int movement, bool forward) {
+    checkLayout();
+    computeRuns();
+    int length = text.length();
+    if (!(0 <= offset && offset <= length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+    if (length is 0) return 0;
+    offset = translateOffset(offset);
+    switch (movement) {
+        case DWT.MOVEMENT_CLUSTER://TODO cluster
+        case DWT.MOVEMENT_CHAR: {
+            if (forward) {
+                offset++;
+            } else {
+                offset--;
+            }
+            return untranslateOffset(offset);
+        }
+        case DWT.MOVEMENT_WORD: {
+            return untranslateOffset(textStorage.nextWordFromIndex(offset, forward));
+        }
+        case DWT.MOVEMENT_WORD_END: {
+            NSRange range = textStorage.doubleClickAtIndex(length is offset ? length - 1 : offset);
+            return untranslateOffset(range.location + range.length);
+        }
+        case DWT.MOVEMENT_WORD_START: {
+            NSRange range = textStorage.doubleClickAtIndex(length is offset ? length - 1 : offset);
+            return untranslateOffset(range.location);
+        }
+        default:
+            break;
+    }
+    return -1;
+}
+
+/**
+ * Returns the character offset for the specified point.  
+ * For a typical character, the trailing argument will be filled in to 
+ * indicate whether the point is closer to the leading edge (0) or
+ * the trailing edge (1).  When the point is over a cluster composed 
+ * of multiple characters, the trailing argument will be filled with the 
+ * position of the character in the cluster that is closest to
+ * the point.
+ * 
+ * @param point the point
+ * @param trailing the trailing buffer
+ * @return the character offset
+ *  
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the trailing length is less than <code>1</code></li>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getLocation(int, bool)
+ */
+public int getOffset(Point point, int[] trailing) {
+    checkLayout();
+    computeRuns();
+    if (point is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return getOffset(point.x, point.y, trailing);
+}
+
+/**
+ * Returns the character offset for the specified point.  
+ * For a typical character, the trailing argument will be filled in to 
+ * indicate whether the point is closer to the leading edge (0) or
+ * the trailing edge (1).  When the point is over a cluster composed 
+ * of multiple characters, the trailing argument will be filled with the 
+ * position of the character in the cluster that is closest to
+ * the point.
+ * 
+ * @param x the x coordinate of the point
+ * @param y the y coordinate of the point
+ * @param trailing the trailing buffer
+ * @return the character offset
+ *  
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the trailing length is less than <code>1</code></li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getLocation(int, bool)
+ */
+public int getOffset(int x, int y, int[] trailing) {
+    checkLayout();
+    computeRuns();
+    if (trailing !is null && trailing.length < 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int length = text.length();
+    if (length is 0) return 0;
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    float[] partialFration = new float[1];
+    int glyphIndex = layoutManager.glyphIndexForPoint_inTextContainer_fractionOfDistanceThroughGlyph_(pt, textContainer, partialFration);
+    int offset = layoutManager.characterIndexForGlyphAtIndex(glyphIndex);
+    if (trailing !is null) trailing[0] = Math.round(partialFration[0]);
+    return Math.min(untranslateOffset(offset), length - 1);
+}
+
+/**
+ * Returns the orientation of the receiver.
+ *
+ * @return the orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getOrientation() {
+    checkLayout();
+    return orientation;
+}
+
+/**
+ * Returns the previous offset for the specified offset and movement
+ * type.  The movement is one of <code>DWT.MOVEMENT_CHAR</code>, 
+ * <code>DWT.MOVEMENT_CLUSTER</code> or <code>DWT.MOVEMENT_WORD</code>,
+ * <code>DWT.MOVEMENT_WORD_END</code> or <code>DWT.MOVEMENT_WORD_START</code>.
+ * 
+ * @param offset the start offset
+ * @param movement the movement type 
+ * @return the previous offset
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the offset is out of range</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getNextOffset(int, int)
+ */
+public int getPreviousOffset (int index, int movement) {
+    return _getOffset(index, movement, false);
+}
+
+/**
+ * Gets the ranges of text that are associated with a <code>TextStyle</code>.
+ *
+ * @return the ranges, an array of offsets representing the start and end of each
+ * text style. 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getStyles()
+ * 
+ * @since 3.2
+ */
+public int[] getRanges () {
+    checkLayout();
+    int[] result = new int[styles.length * 2];
+    int count = 0;
+    for (int i=0; i<styles.length - 1; i++) {
+        if (styles[i].style !is null) {
+            result[count++] = styles[i].start;
+            result[count++] = styles[i + 1].start - 1;
+        }
+    }
+    if (count !is result.length) {
+        int[] newResult = new int[count];
+        System.arraycopy(result, 0, newResult, 0, count);
+        result = newResult;
+    }
+    return result;
+}
+
+/**
+ * Returns the text segments offsets of the receiver.
+ *
+ * @return the text segments offsets
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int[] getSegments() {
+    checkLayout();
+    return segments;
+}
+
+/**
+ * Returns the line spacing of the receiver.
+ *
+ * @return the line spacing
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getSpacing () {
+    checkLayout();  
+    return spacing;
+}
+
+/**
+ * Gets the style of the receiver at the specified character offset.
+ *
+ * @param offset the text offset
+ * @return the style or <code>null</code> if not set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the character offset is out of range</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public TextStyle getStyle (int offset) {
+    checkLayout();
+    int length = text.length();
+    if (!(0 <= offset && offset < length)) DWT.error(DWT.ERROR_INVALID_RANGE);
+    for (int i=1; i<styles.length; i++) {
+        StyleItem item = styles[i];
+        if (item.start > offset) {
+            return styles[i - 1].style;
+        }
+    }
+    return null;
+}
+
+/**
+ * Gets all styles of the receiver.
+ *
+ * @return the styles
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getRanges()
+ * 
+ * @since 3.2
+ */
+public TextStyle[] getStyles () {
+    checkLayout();
+    TextStyle[] result = new TextStyle[styles.length];
+    int count = 0;
+    for (int i=0; i<styles.length; i++) {
+        if (styles[i].style !is null) {
+            result[count++] = styles[i].style;
+        }
+    }
+    if (count !is result.length) {
+        TextStyle[] newResult = new TextStyle[count];
+        System.arraycopy(result, 0, newResult, 0, count);
+        result = newResult;
+    }
+    return result;
+}
+
+/**
+ * Returns the tab list of the receiver.
+ *
+ * @return the tab list
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int[] getTabs() {
+    checkLayout();
+    return tabs;
+}
+
+/**
+ * Gets the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public String getText () {
+    checkLayout ();
+    return text;
+}
+
+/**
+ * Returns the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getWidth () {
+    checkLayout();
+    return wrapWidth;
+}
+
+/**
+ * Returns <code>true</code> if the text layout has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the text layout.
+ * When a text layout has been disposed, it is an error to
+ * invoke any other method using the text layout.
+ * </p>
+ *
+ * @return <code>true</code> when the text layout is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed () {
+    return device is null;
+}
+
+/**
+ * Sets the text alignment for the receiver. The alignment controls
+ * how a line of text is positioned horizontally. The argument should
+ * be one of <code>DWT.LEFT</code>, <code>DWT.RIGHT</code> or <code>DWT.CENTER</code>.
+ * <p>
+ * The default alignment is <code>DWT.LEFT</code>.  Note that the receiver's
+ * width must be set in order to use <code>DWT.RIGHT</code> or <code>DWT.CENTER</code>
+ * alignment.
+ * </p>
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setWidth(int)
+ */
+public void setAlignment (int alignment) {
+    checkLayout();
+    int mask = DWT.LEFT | DWT.CENTER | DWT.RIGHT;
+    alignment &= mask;
+    if (alignment is 0) return;
+    if ((alignment & DWT.LEFT) !is 0) alignment = DWT.LEFT;
+    if ((alignment & DWT.RIGHT) !is 0) alignment = DWT.RIGHT;
+    if (this.alignment is alignment) return;
+    freeRuns();
+    this.alignment = alignment;
+}
+
+/**
+ * Sets the ascent of the receiver. The ascent is distance in pixels
+ * from the baseline to the top of the line and it is applied to all
+ * lines. The default value is <code>-1</code> which means that the
+ * ascent is calculated from the line fonts.
+ *
+ * @param ascent the new ascent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the ascent is less than <code>-1</code></li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setDescent(int)
+ * @see #getLineMetrics(int)
+ */
+public void setAscent (int ascent) {
+    checkLayout ();
+    if (ascent < -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (this.ascent is ascent) return;
+    freeRuns();
+    this.ascent = ascent;
+}
+
+/**
+ * Sets the descent of the receiver. The descent is distance in pixels
+ * from the baseline to the bottom of the line and it is applied to all
+ * lines. The default value is <code>-1</code> which means that the
+ * descent is calculated from the line fonts.
+ *
+ * @param descent the new descent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the descent is less than <code>-1</code></li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAscent(int)
+ * @see #getLineMetrics(int)
+ */
+public void setDescent (int descent) {
+    checkLayout ();
+    if (descent < -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (this.descent is descent) return;
+    freeRuns();
+    this.descent = descent;
+}
+
+/** 
+ * Sets the default font which will be used by the receiver
+ * to draw and measure text. If the
+ * argument is null, then a default font appropriate
+ * for the platform will be used instead. Note that a text
+ * style can override the default font.
+ *
+ * @param font the new font for the receiver, or null to indicate a default font
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+    checkLayout ();
+    if (font !is null && font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    Font oldFont = this.font;
+    if (oldFont is font) return;
+    this.font = font;
+    if (oldFont !is null && oldFont.equals(font)) return;
+    freeRuns();
+}
+
+/**
+ * Sets the indent of the receiver. This indent it applied of the first line of 
+ * each paragraph.  
+ *
+ * @param indent new indent
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setIndent (int indent) {
+    checkLayout ();
+    if (indent < 0) return;
+    if (this.indent is indent) return;
+    freeRuns();
+    this.indent = indent;
+}
+
+/**
+ * Sets the justification of the receiver. Note that the receiver's
+ * width must be set in order to use justification. 
+ *
+ * @param justify new justify
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setJustify (bool justify) {
+    checkLayout ();
+    if (justify is this.justify) return;
+    freeRuns();
+    this.justify = justify;
+}
+
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of <code>DWT.LEFT_TO_RIGHT</code> or <code>DWT.RIGHT_TO_LEFT</code>.
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setOrientation(int orientation) {
+    checkLayout();
+    int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+    orientation &= mask;
+    if (orientation is 0) return;
+    if ((orientation & DWT.LEFT_TO_RIGHT) !is 0) orientation = DWT.LEFT_TO_RIGHT;
+    if (this.orientation is orientation) return;
+    this.orientation = orientation;
+    freeRuns();
+}
+
+/**
+ * Sets the offsets of the receiver's text segments. Text segments are used to
+ * override the default behaviour of the bidirectional algorithm.
+ * Bidirectional reordering can happen within a text segment but not 
+ * between two adjacent segments.
+ * <p>
+ * Each text segment is determined by two consecutive offsets in the 
+ * <code>segments</code> arrays. The first element of the array should 
+ * always be zero and the last one should always be equals to length of
+ * the text.
+ * </p>
+ * 
+ * @param segments the text segments offset
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setSegments(int[] segments) {
+    checkLayout();
+    if (this.segments is null && segments is null) return;
+    if (this.segments !is null && segments !isnull) {
+        if (this.segments.length is segments.length) {
+            int i;
+            for (i = 0; i <segments.length; i++) {
+                if (this.segments[i] !is segments[i]) break;
+            }
+            if (i is segments.length) return;
+        }
+    }
+    freeRuns();
+    this.segments = segments;
+}
+
+/**
+ * Sets the line spacing of the receiver.  The line spacing
+ * is the space left between lines.
+ *
+ * @param spacing the new line spacing 
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the spacing is negative</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setSpacing (int spacing) {
+    checkLayout();
+    if (spacing < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (this.spacing is spacing) return;
+    freeRuns();
+    this.spacing = spacing;
+}
+
+/**
+ * Sets the style of the receiver for the specified range.  Styles previously
+ * set for that range will be overwritten.  The start and end offsets are
+ * inclusive and will be clamped if out of range.
+ * 
+ * @param style the style
+ * @param start the start offset
+ * @param end the end offset
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setStyle (TextStyle style, int start, int end) {
+    checkLayout();
+    int length = text.length();
+    if (length is 0) return;
+    if (start > end) return;
+    start = Math.min(Math.max(0, start), length - 1);
+    end = Math.min(Math.max(0, end), length - 1);
+    int low = -1;
+    int high = styles.length;
+    while (high - low > 1) {
+        int index = (high + low) / 2;
+        if (styles[index + 1].start > start) {
+            high = index;
+        } else {
+            low = index;
+        }
+    }
+    if (0 <= high && high < styles.length) {
+        StyleItem item = styles[high];
+        if (item.start is start && styles[high + 1].start - 1 is end) {
+            if (style is null) {
+                if (item.style is null) return;
+            } else {
+                if (style.equals(item.style)) return;
+            }
+        }
+    }
+    freeRuns();
+    int modifyStart = high;
+    int modifyEnd = modifyStart;
+    while (modifyEnd < styles.length) {
+        if (styles[modifyEnd + 1].start > end) break;
+        modifyEnd++;
+    }
+    if (modifyStart is modifyEnd) {
+        int styleStart = styles[modifyStart].start; 
+        int styleEnd = styles[modifyEnd + 1].start - 1;
+        if (styleStart is start && styleEnd is end) {
+            styles[modifyStart].style = style;
+            return;
+        }
+        if (styleStart !is start && styleEnd !is end) {
+            StyleItem[] newStyles = new StyleItem[styles.length + 2];
+            System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1);
+            StyleItem item = new StyleItem();
+            item.start = start;
+            item.style = style;
+            newStyles[modifyStart + 1] = item;  
+            item = new StyleItem();
+            item.start = end + 1;
+            item.style = styles[modifyStart].style;
+            newStyles[modifyStart + 2] = item;
+            System.arraycopy(styles, modifyEnd + 1, newStyles, modifyEnd + 3, styles.length - modifyEnd - 1);
+            styles = newStyles;
+            return;
+        }
+    }
+    if (start is styles[modifyStart].start) modifyStart--;
+    if (end is styles[modifyEnd + 1].start - 1) modifyEnd++;
+    int newLength = styles.length + 1 - (modifyEnd - modifyStart - 1);
+    StyleItem[] newStyles = new StyleItem[newLength];
+    System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1); 
+    StyleItem item = new StyleItem();
+    item.start = start;
+    item.style = style;
+    newStyles[modifyStart + 1] = item;
+    styles[modifyEnd].start = end + 1;
+    System.arraycopy(styles, modifyEnd, newStyles, modifyStart + 2, styles.length - modifyEnd);
+    styles = newStyles;
+}
+
+/**
+ * Sets the receiver's tab list. Each value in the tab list specifies
+ * the space in pixels from the origin of the text layout to the respective
+ * tab stop.  The last tab stop width is repeated continuously.
+ * 
+ * @param tabs the new tab list
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setTabs(int[] tabs) {
+    checkLayout();
+    if (this.tabs is null && tabs is null) return;
+    if (this.tabs !is null && tabs !isnull) {
+        if (this.tabs.length is tabs.length) {
+            int i;
+            for (i = 0; i < tabs.length; i++) {
+                if (this.tabs[i] !is tabs[i]) break;
+            }
+            if (i is tabs.length) return;
+        }
+    }
+    freeRuns();
+    this.tabs = tabs;
+}
+
+/**
+ * Sets the receiver's text.
+ *
+ * @param text the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setText (String text) {
+    checkLayout ();
+    if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (text.equals(this.text)) return;
+    freeRuns();
+    this.text = text;
+    styles = new StyleItem[2];
+    styles[0] = new StyleItem();
+    styles[1] = new StyleItem();
+    styles[styles.length - 1].start = text.length();
+}
+
+/**
+ * Sets the line width of the receiver, which determines how
+ * text should be wrapped and aligned. The default value is
+ * <code>-1</code> which means wrapping is disabled.
+ *
+ * @param width the new width 
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the width is <code>0</code> or less than <code>-1</code></li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAlignment(int)
+ */
+public void setWidth (int width) {
+    checkLayout();
+    if (width < -1 || width is 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (this.wrapWidth is width) return;
+    freeRuns();
+    this.wrapWidth = width;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    if (isDisposed()) return "TextLayout {*DISPOSED*}";
+    return "TextLayout {" + text + "}";
+}
+
+/*
+ *  Translate a client offset to an internal offset
+ */
+int translateOffset (int offset) {
+    return offset;
+}
+
+/*
+ *  Translate an internal offset to a client offset
+ */
+int untranslateOffset (int offset) {
+    return offset;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/TextStyle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.TextStyle;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+
+/**
+ * <code>TextStyle</code> defines a set of styles that can be applied
+ * to a range of text.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see TextLayout
+ * @see Font
+ * @see Color
+ *  
+ * @since 3.0
+ */
+public class TextStyle {
+
+    /**
+     * the font of the style
+     */
+    public Font font;
+
+    /**
+     * the foreground of the style
+     */
+    public Color foreground;
+
+    /**
+     * the background of the style
+     */
+    public Color background;
+
+    /**
+     * the underline flag of the style. The default underline
+     * style is <code>DWT.UNDERLINE_SINGLE</code>.
+     * 
+     * 
+     * @since 3.1
+     */ 
+    public bool underline;
+    
+    /**
+     * the underline color of the style
+     * 
+     * @since 3.4
+     */ 
+    public Color underlineColor;
+
+    /**
+     * the underline style. This style is ignored when
+     * <code>underline</code> is false.
+     * <p> 
+     * This value should be one of <code>DWT.UNDERLINE_SINGLE</code>,
+     * <code>DWT.UNDERLINE_DOUBLE</code>, <code>DWT.UNDERLINE_ERROR</code>,
+     * or <code>DWT.UNDERLINE_SQUIGGLE</code>.
+     * </p>
+     * 
+     * @see DWT#UNDERLINE_SINGLE
+     * @see DWT#UNDERLINE_DOUBLE 
+     * @see DWT#UNDERLINE_ERROR
+     * @see DWT#UNDERLINE_SQUIGGLE
+     * 
+     * @since 3.4
+     */ 
+    public int underlineStyle;
+
+    /**
+     * the strikeout flag of the style
+     * 
+     * @since 3.1
+     */ 
+    public bool strikeout;
+    
+    /**
+     * the strikeout color of the style
+     * 
+     * @since 3.4
+     */ 
+    public Color strikeoutColor;
+    
+    /**
+     * the border style. The default border style is <code>DWT.NONE</code>.
+     * <p> 
+     * This value should be one of <code>DWT.BORDER_SOLID</code>,
+     * <code>DWT.BORDER_DASH</code>,<code>DWT.BORDER_DOT</code> or
+     * <code>DWT.NONE</code>.
+     * </p>
+     * 
+     * @see DWT#BORDER_SOLID
+     * @see DWT#BORDER_DASH 
+     * @see DWT#BORDER_DOT
+     * @see DWT#NONE
+     * 
+     * @since 3.4
+     */ 
+    public int borderStyle;
+    
+    /**
+     * the border color of the style
+     * 
+     * @since 3.4
+     */ 
+    public Color borderColor;
+    
+    /**
+     * the GlyphMetrics of the style
+     * 
+     * @since 3.2
+     */ 
+    public GlyphMetrics metrics;
+    
+    /**
+     * the baseline rise of the style. 
+     * 
+     * @since 3.2
+     */ 
+    public int rise;
+
+/** 
+ * Create an empty text style.
+ *
+ * @since 3.4
+ */
+public TextStyle () {
+}
+    
+/** 
+ * Create a new text style with the specified font, foreground
+ * and background.
+ *
+ * @param font the font of the style, <code>null</code> if none 
+ * @param foreground the foreground color of the style, <code>null</code> if none 
+ * @param background the background color of the style, <code>null</code> if none
+ */
+public TextStyle (Font font, Color foreground, Color background) {
+    if (font !is null && font.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    if (foreground !is null && foreground.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    if (background !is null && background.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);  
+    this.font = font;
+    this.foreground = foreground;
+    this.background = background;
+}
+
+
+/** 
+ * Create a new text style from an existing text style.
+ * 
+ *@param style the style to copy 
+ *
+ * @since 3.4
+ */
+public TextStyle (TextStyle style) {
+    if (style is null) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    font = style.font;
+    foreground = style.foreground;
+    background = style.background;
+    underline = style.underline;
+    underlineColor = style.underlineColor;
+    underlineStyle = style.underlineStyle;
+    strikeout = style.strikeout;
+    strikeoutColor = style.strikeoutColor;
+    borderStyle = style.borderStyle;
+    borderColor = style.borderColor;
+    metrics = style.metrics;
+    rise = style.rise;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public bool equals(Object object) {
+    if (object is this) return true;
+    if (object is null) return false;
+    if (!(object instanceof TextStyle)) return false;
+    TextStyle style = (TextStyle)object;    
+    if (foreground !is null) {
+        if (!foreground.equals(style.foreground)) return false;
+    } else if (style.foreground !is null) return false;
+    if (background !is null) {
+        if (!background.equals(style.background)) return false;
+    } else if (style.background !is null) return false;
+    if (font !is null) {
+        if (!font.equals(style.font)) return false;
+    } else if (style.font !is null) return false;
+    if (metrics !is null || style.metrics !is null) return false;
+    if (underline !is style.underline) return false;
+    if (underlineStyle !is style.underlineStyle) return false;
+    if (borderStyle !is style.borderStyle) return false;
+    if (strikeout !is style.strikeout) return false;
+    if (rise !is style.rise) return false;
+    if (underlineColor !is null) {
+        if (!underlineColor.equals(style.underlineColor)) return false;
+    } else if (style.underlineColor !is null) return false;
+    if (strikeoutColor !is null) {
+        if (!strikeoutColor.equals(style.strikeoutColor)) return false;
+    } else if (style.strikeoutColor !is null) return false;
+    if (underlineStyle !is style.underlineStyle) return false;
+    if (borderColor !is null) {
+        if (!borderColor.equals(style.borderColor)) return false;
+    } else if (style.borderColor !is null) return false;
+    return true;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode() {
+    int hash = 0;
+    if (foreground !is null) hash ^= foreground.hashCode();
+    if (background !is null) hash ^= background.hashCode();  
+    if (font !is null) hash ^= font.hashCode();
+    if (metrics !is null) hash ^= metrics.hashCode();
+    if (underline) hash ^= hash;
+    if (strikeout) hash ^= hash;
+    hash ^= rise;
+    if (underlineColor !is null) hash ^= underlineColor.hashCode();
+    if (strikeoutColor !is null) hash ^= strikeoutColor.hashCode();
+    if (borderColor !is null) hash ^= borderColor.hashCode();
+    hash ^= underlineStyle;
+    return hash;
+}
+
+bool isAdherentBorder(TextStyle style) {
+    if (this is style) return true;
+    if (style is null) return false;
+    if (borderStyle !is style.borderStyle) return false;
+    if (borderColor !is null) {
+        if (!borderColor.equals(style.borderColor)) return false;
+    } else if (style.borderColor !is null) return false;
+    return true;
+}
+
+bool isAdherentUnderline(TextStyle style) {
+    if (this is style) return true;
+    if (style is null) return false;
+    if (underline !is style.underline) return false;
+    if (underlineStyle !is style.underlineStyle) return false;
+    if (underlineColor !is null) {
+        if (!underlineColor.equals(style.underlineColor)) return false;
+    } else if (style.underlineColor !is null) return false;
+    return true;
+}
+
+bool isAdherentStrikeout(TextStyle style) {
+    if (this is style) return true;
+    if (style is null) return false;
+    if (strikeout !is style.strikeout) return false;
+    if (strikeoutColor !is null) {
+        if (!strikeoutColor.equals(style.strikeoutColor)) return false;
+    } else if (style.strikeoutColor !is null) return false;
+    return true;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the <code>TextStyle</code>
+ */
+public String toString () {
+    StringBuffer buffer = new StringBuffer("TextStyle {");
+    int startLength = buffer.length();
+    if (font !is null) {
+        if (buffer.length() > startLength) buffer.append(", ");
+        buffer.append("font=");
+        buffer.append(font);
+    }
+    if (foreground !is null) {
+        if (buffer.length() > startLength) buffer.append(", ");
+        buffer.append("foreground=");
+        buffer.append(foreground);
+    }
+    if (background !is null) {
+        if (buffer.length() > startLength) buffer.append(", ");
+        buffer.append("background=");
+        buffer.append(background);
+    }
+    if (underline) {
+        if (buffer.length() > startLength) buffer.append(", ");
+        buffer.append("underlined");
+    }
+    if (strikeout) {
+        if (buffer.length() > startLength) buffer.append(", ");
+        buffer.append("striked out");
+    }
+    if (rise !is 0) {
+        if (buffer.length() > startLength) buffer.append(", ");
+        buffer.append("rise=");
+        buffer.append(rise);
+    }
+    if (metrics !is null) {
+        if (buffer.length() > startLength) buffer.append(", ");
+        buffer.append("metrics=");
+        buffer.append(metrics);
+    }
+    buffer.append("}");
+    return buffer.toString();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Transform.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.graphics.Transform;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSAffineTransformStruct;
+import dwt.internal.cocoa.NSPoint;
+
+/**
+ * Instances of this class represent transformation matrices for 
+ * points expressed as (x, y) pairs of floating point numbers.
+ * <p>
+ * Application code must explicitly invoke the <code>Transform.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <p>
+ * This class requires the operating system's advanced graphics subsystem
+ * which may not be available on some platforms.
+ * </p>
+ * 
+ * @since 3.1
+ */
+public class Transform extends Resource {
+    /**
+     * the OS resource for the Transform
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public NSAffineTransform handle;
+    
+/**
+ * Constructs a new identity Transform.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the Transform
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Transform (Device device) {
+    this(device, 1, 0, 0, 1, 0, 0);
+}
+
+/**
+ * Constructs a new Transform given an array of elements that represent the 
+ * matrix that describes the transformation.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the Transform
+ * @param elements an array of floats that describe the transformation matrix
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device, or the elements array is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the elements array is too small to hold the matrix values</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Transform(Device device, float[] elements) {
+    this (device, checkTransform(elements)[0], elements[1], elements[2], elements[3], elements[4], elements[5]);
+}
+
+/**
+ * Constructs a new Transform given all of the elements that represent the 
+ * matrix that describes the transformation.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the Transform
+ * @param m11 the first element of the first row of the matrix
+ * @param m12 the second element of the first row of the matrix
+ * @param m21 the first element of the second row of the matrix
+ * @param m22 the second element of the second row of the matrix
+ * @param dx the third element of the first row of the matrix
+ * @param dy the third element of the second row of the matrix
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Transform (Device device, float m11, float m12, float m21, float m22, float dx, float dy) {
+    super(device);
+    handle = NSAffineTransform.transform();
+    if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
+    handle.retain();
+    setElements(m11, m12, m21, m22, dx, dy);
+    init();
+}
+
+static float[] checkTransform(float[] elements) {
+    if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    return elements;
+}
+
+void destroy() {
+    handle.release();
+    handle = null;
+}
+
+/**
+ * Fills the parameter with the values of the transformation matrix
+ * that the receiver represents, in the order {m11, m12, m21, m22, dx, dy}.
+ *
+ * @param elements array to hold the matrix values
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the matrix values</li>
+ * </ul>
+ */
+public void getElements(float[] elements) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    NSAffineTransformStruct struct = handle.transformStruct();
+    elements[0] = struct.m11;
+    elements[1] = struct.m12;
+    elements[2] = struct.m21;
+    elements[3] = struct.m22;
+    elements[4] = struct.tX;
+    elements[5] = struct.tY;
+}
+
+public void identity() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSAffineTransformStruct struct = new NSAffineTransformStruct();
+    struct.m11 = 1;
+    struct.m22 = 1;
+    handle.setTransformStruct(struct);
+}
+
+/**
+ * Modifies the receiver such that the matrix it represents becomes the
+ * the mathematical inverse of the matrix it previously represented. 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_CANNOT_INVERT_MATRIX - if the matrix is not invertible</li>
+ * </ul>
+ */
+public void invert() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSAffineTransformStruct struct = handle.transformStruct();
+    if ((struct.m11 * struct.m22 - struct.m12 * struct.m21) is 0) {
+        DWT.error(DWT.ERROR_CANNOT_INVERT_MATRIX);
+    }
+    handle.invert();
+}
+
+/**
+ * Returns <code>true</code> if the Transform has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the Transform.
+ * When a Transform has been disposed, it is an error to
+ * invoke any other method using the Transform.
+ *
+ * @return <code>true</code> when the Transform is disposed, and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+/**
+ * Returns <code>true</code> if the Transform represents the identity matrix
+ * and false otherwise.
+ *
+ * @return <code>true</code> if the receiver is an identity Transform, and <code>false</code> otherwise
+ */
+public bool isIdentity() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSAffineTransformStruct struct = handle.transformStruct();
+    return struct.m11 is 1 && struct.m12 is 0 && struct.m21 is 0 && struct.m22 is 1 && struct.tX is 0 && struct.tY is 0;
+}
+
+/**
+ * Modifies the receiver such that the matrix it represents becomes the
+ * the result of multiplying the matrix it previously represented by the
+ * argument. 
+ *
+ * @param matrix the matrix to multiply the receiver by
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ */
+public void multiply(Transform matrix) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (matrix is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (matrix.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    handle.prependTransform(matrix.handle);
+}
+
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation rotated by the specified angle.
+ * The angle is specified in degrees and for the identity transform 0 degrees
+ * is at the 3 o'clock position. A positive value indicates a clockwise rotation
+ * while a negative value indicates a counter-clockwise rotation.
+ *
+ * @param angle the angle to rotate the transformation by
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void rotate(float angle) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    handle.rotateByDegrees(angle);
+}
+
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation scaled by (scaleX, scaleY).
+ * 
+ * @param scaleX the amount to scale in the X direction
+ * @param scaleY the amount to scale in the Y direction
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void scale(float scaleX, float scaleY) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    handle.scaleXBy(scaleX, scaleY);
+}
+
+/**
+ * Modifies the receiver to represent a new transformation given all of
+ * the elements that represent the matrix that describes that transformation.
+ * 
+ * @param m11 the first element of the first row of the matrix
+ * @param m12 the second element of the first row of the matrix
+ * @param m21 the first element of the second row of the matrix
+ * @param m22 the second element of the second row of the matrix
+ * @param dx the third element of the first row of the matrix
+ * @param dy the third element of the second row of the matrix
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSAffineTransformStruct struct = new NSAffineTransformStruct();
+    struct.m11 = m11;
+    struct.m12 = m12;
+    struct.m21 = m21;
+    struct.m22 = m22;
+    struct.tX = dx;
+    struct.tY = dy;
+    handle.setTransformStruct(struct);
+}
+
+public void shear(float shearX, float shearY) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    NSAffineTransformStruct struct = new NSAffineTransformStruct();
+    struct.m11 = 1;
+    struct.m12 = shearX;
+    struct.m21 = shearY;
+    struct.m22 = 1;
+    NSAffineTransform matrix = NSAffineTransform.transform();
+    matrix.setTransformStruct(struct);
+    handle.prependTransform(matrix);
+}
+
+/** 
+ * Given an array containing points described by alternating x and y values,
+ * modify that array such that each point has been replaced with the result of
+ * applying the transformation represented by the receiver to that point.
+ *
+ * @param pointArray an array of alternating x and y values to be transformed
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
+ * </ul>    
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void transform(float[] pointArray) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    NSPoint point = new NSPoint();
+    int length = pointArray.length / 2;
+    for (int i = 0, j = 0; i < length; i++, j += 2) {
+        point.x = pointArray[j];
+        point.y = pointArray[j + 1];
+        point = handle.transformPoint(point);
+        pointArray[j] = point.x;                
+        pointArray[j + 1] = point.y;                
+    }
+}
+
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation translated by (offsetX, offsetY).
+ * 
+ * @param offsetX the distance to translate in the X direction
+ * @param offsetY the distance to translate in the Y direction
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void translate(float offsetX, float offsetY) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    handle.translateXBy(offsetX, offsetY);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString() {
+    if (isDisposed()) return "Transform {*DISPOSED*}";
+    float[] elements = new float[6];
+    getElements(elements);
+    return "Transform {" + elements [0] + ", " + elements [1] + ", " +elements [2] + ", " +elements [3] + ", " +elements [4] + ", " +elements [5] + "}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/BidiUtil.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.BidiUtil;
+
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.utils;
+import dwt.graphics.GC;
+import dwt.widgets.Control;
+
+/*
+ * This class is supplied so that the StyledText code that supports bidi text (supported
+ * for win platforms) is not platform dependent.  Bidi text is not implemented on 
+ * emulated platforms.
+ */
+public class BidiUtil
+{
+    // Keyboard language types
+    public static const int KEYBOARD_NON_BIDI = 0;
+    public static const int KEYBOARD_BIDI = 1;
+
+    // bidi rendering input flag constants, not used
+    // on emulated platforms
+    public static const int CLASSIN = 1;
+    public static const int LINKBEFORE = 2;
+    public static const int LINKAFTER = 4;
+
+    // bidi rendering/ordering constants, not used on 
+    // emulated platforms
+    public static const int CLASS_HEBREW = 2;
+    public static const int CLASS_ARABIC = 2;
+    public static const int CLASS_LOCALNUMBER = 4;
+    public static const int CLASS_LATINNUMBER = 5;
+    public static const int REORDER = 0;
+    public static const int LIGATE = 0;
+    public static const int GLYPHSHAPE = 0;
+
+    /*
+     * Not implemented.
+     */
+    public static void addLanguageListener (int /*long*/hwnd,
+            Runnable runnable)
+    {
+    }
+
+    public static void addLanguageListener (Control control, Runnable runnable)
+    {
+    }
+
+    /*
+     * Not implemented.
+     *
+     */
+    public static void drawGlyphs (GC gc, char[] renderBuffer, int[] renderDx,
+            int x, int y)
+    {
+    }
+
+    /*
+     * Bidi not supported on emulated platforms.
+     *
+     */
+    public static bool isBidiPlatform ()
+    {
+        return false;
+    }
+
+    /*
+     * Not implemented.
+     */
+    public static bool isKeyboardBidi ()
+    {
+        return false;
+    }
+
+    /*
+     * Not implemented.
+     */
+    public static int getFontBidiAttributes (GC gc)
+    {
+        return 0;
+    }
+
+    /*
+     *  Not implemented.
+     *
+     */
+    public static void getOrderInfo (GC gc, String text, int[] order,
+            byte[] classBuffer, int flags, int[] offsets)
+    {
+    }
+
+    /*
+     *  Not implemented. Returns null.
+     *
+     */
+    public static char[] getRenderInfo (GC gc, String text, int[] order,
+            byte[] classBuffer, int[] dx, int flags, int[] offsets)
+    {
+        return null;
+    }
+
+    /*
+     * Not implemented. Returns 0.
+     */
+    public static int getKeyboardLanguage ()
+    {
+        return 0;
+    }
+
+    /*
+     * Not implemented.
+     */
+    public static void removeLanguageListener (int /*long*/hwnd)
+    {
+    }
+
+    public static void removeLanguageListener (Control control)
+    {
+    }
+
+    /*
+     * Not implemented.
+     */
+    public static void setKeyboardLanguage (int language)
+    {
+    }
+
+    /*
+     * Not implemented.
+     */
+    public static bool setOrientation (int /*long*/hwnd, int orientation)
+    {
+        return false;
+    }
+
+    public static bool setOrientation (Control control, int orientation)
+    {
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/C.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.C;
+
+public import tango.stdc.stdlib : free, malloc, getenv;
+public import tango.stdc.string : memmove, memset, strlen;
+
+import dwt.dwthelper.utils;
+import dwt.internal.Library;
+import dwt.internal.Platform;
+
+public class C : Platform
+{
+
+    /*static this ()
+    {
+        if ("Linux".opEquals(System.getProperty("os.name")) && "motif".opEquals(
+                Platform.PLATFORM))
+        { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            try
+            {
+                Library.loadLibrary("libXm.so.2", false); //$NON-NLS-1$
+            }
+            catch (Exception ex)
+            {
+            }
+        }
+        
+        Library.loadLibrary("swt"); //$NON-NLS-1$
+    }*/
+    
+    alias tango.stdc.string.memmove MoveMemory;
+
+    //public static final int PTR_SIZEOF = PTR_sizeof();
+
+    //public static final native int PTR_sizeof ();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/Callback.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.Callback;
+
+import dwt.dwthelper.utils;
+import dwt.internal.C;
+
+/**
+ * Instances of this class represent entry points into Java
+ * which can be invoked from operating system level callback
+ * routines.
+ * <p>
+ * IMPORTANT: A callback is only valid when invoked on the
+ * thread which created it. The results are undefined (and
+ * typically bad) when a callback is passed out to the 
+ * operating system (or other code) in such a way that the
+ * callback is called from a different thread.
+ */
+
+public class Callback
+{
+
+    Object object;
+    String method, signature;
+    int argCount;
+    int /*long*/address, errorResult;
+    bool isStatic, isArrayBased;
+
+    static const String PTR_SIGNATURE = C.PTR_SIZEOF is 4 ? "I" : "J"; //$NON-NLS-1$  //$NON-NLS-2$
+    static const String SIGNATURE_0 = getSignature(0);
+    static const String SIGNATURE_1 = getSignature(1);
+    static const String SIGNATURE_2 = getSignature(2);
+    static const String SIGNATURE_3 = getSignature(3);
+    static const String SIGNATURE_4 = getSignature(4);
+    static const String
+            SIGNATURE_N = "([" + PTR_SIGNATURE + ")" + PTR_SIGNATURE; //$NON-NLS-1$  //$NON-NLS-2$
+
+    /**
+     * Constructs a new instance of this class given an object
+     * to send the message to, a string naming the method to
+     * invoke and an argument count. Note that, if the object
+     * is an instance of <code>Class</code> it is assumed that
+     * the method is a static method on that class.
+     *
+     * @param object the object to send the message to
+     * @param method the name of the method to invoke
+     * @param argCount the number of arguments that the method takes
+     */
+    public this (Object object, String method, int argCount)
+    {
+        this(object, method, argCount, false);
+    }
+
+    /**
+     * Constructs a new instance of this class given an object
+     * to send the message to, a string naming the method to
+     * invoke, an argument count and a flag indicating whether
+     * or not the arguments will be passed in an array. Note 
+     * that, if the object is an instance of <code>Class</code>
+     * it is assumed that the method is a static method on that
+     * class.
+     *
+     * @param object the object to send the message to
+     * @param method the name of the method to invoke
+     * @param argCount the number of arguments that the method takes
+     * @param isArrayBased <code>true</code> if the arguments should be passed in an array and false otherwise
+     */
+    public this (Object object, String method, int argCount, bool isArrayBased)
+    {
+        this(object, method, argCount, isArrayBased, 0);
+    }
+
+    /**
+     * Constructs a new instance of this class given an object
+     * to send the message to, a string naming the method to
+     * invoke, an argument count, a flag indicating whether
+     * or not the arguments will be passed in an array and a value
+     * to return when an exception happens. Note that, if
+     * the object is an instance of <code>Class</code>
+     * it is assumed that the method is a static method on that
+     * class.
+     *
+     * @param object the object to send the message to
+     * @param method the name of the method to invoke
+     * @param argCount the number of arguments that the method takes
+     * @param isArrayBased <code>true</code> if the arguments should be passed in an array and false otherwise
+     * @param errorResult the return value if the java code throws an exception
+     */
+    public this (Object object, String method, int argCount, bool isArrayBased,
+            int /*long*/errorResult)
+    {
+
+        /* Set the callback fields */
+        this.object = object;
+        this.method = method;
+        this.argCount = argCount;
+        this.isStatic = cast(ClassInfo) object;
+        this.isArrayBased = isArrayBased;
+        this.errorResult = errorResult;
+
+        /* Inline the common cases */
+        if (isArrayBased)
+        {
+            signature = SIGNATURE_N;
+        }
+        else
+        {
+            switch (argCount)
+            {
+                case 0:
+                    signature = SIGNATURE_0;
+                break; //$NON-NLS-1$
+                case 1:
+                    signature = SIGNATURE_1;
+                break; //$NON-NLS-1$
+                case 2:
+                    signature = SIGNATURE_2;
+                break; //$NON-NLS-1$
+                case 3:
+                    signature = SIGNATURE_3;
+                break; //$NON-NLS-1$
+                case 4:
+                    signature = SIGNATURE_4;
+                break; //$NON-NLS-1$
+                default:
+                    signature = getSignature(argCount);
+            }
+        }
+
+        /* Bind the address */
+        address = bind(this, object, method, signature, argCount, isStatic,
+                isArrayBased, errorResult);
+    }
+
+    /**
+     * Allocates the native level resources associated with the
+     * callback. This method is only invoked from within the
+     * constructor for the argument.
+     *
+     * @param callback the callback to bind
+     * @param object the callback's object
+     * @param method the callback's method
+     * @param signature the callback's method signature
+     * @param argCount the callback's method argument count
+     * @param isStatic whether the callback's method is static
+     * @param isArrayBased whether the callback's method is array based
+     * @param errorResult the callback's error result
+     */
+    static synchronized int /*long*/ bind (Callback callback, Object object, String method, String signature, int argCount, bool isStatic, bool isArrayBased, int /*long*/ errorResult)
+    {
+        
+    }
+    
+    /**
+     * Releases the native level resources associated with the callback,
+     * and removes all references between the callback and
+     * other objects. This helps to prevent (bad) application code
+     * from accidentally holding onto extraneous garbage.
+     */
+    public void dispose ()
+    {
+        if (object is null)
+            return;
+        unbind(this);
+        object = method = signature = null;
+        address = 0;
+    }
+
+    /**
+     * Returns the address of a block of machine code which will
+     * invoke the callback represented by the receiver.
+     *
+     * @return the callback address
+     */
+    public int /*long*/getAddress ()
+    {
+        return address;
+    }
+
+    /**
+     * Returns the DWT platform name.
+     *
+     * @return the platform name of the currently running DWT
+     */
+    //public static native String getPlatform ();
+    /**
+     * Returns the number of times the system has been recursively entered
+     * through a callback.
+     * <p>
+     * Note: This should not be called by application code.
+     * </p>
+     * 
+     * @return the entry count
+     * 
+     * @since 2.1
+     */
+    //public static native int getEntryCount ();
+    static String getSignature (int argCount)
+    {
+        String signature = "("; //$NON-NLS-1$
+        for (int i = 0; i < argCount; i++)
+            signature += PTR_SIGNATURE;
+        signature += ")" + PTR_SIGNATURE; //$NON-NLS-1$
+        return signature;
+    }
+
+    /**
+     * Indicates whether or not callbacks which are triggered at the
+     * native level should cause the messages described by the matching
+     * <code>Callback</code> objects to be invoked. This method is used
+     * to safely shut down DWT when it is run within environments
+     * which can generate spurious events.
+     * <p>
+     * Note: This should not be called by application code.
+     * </p>
+     *
+     * @param enable true if callbacks should be invoked
+     */
+    //public static final native synchronized void setEnabled (bool enable);
+    /**
+     * Returns whether or not callbacks which are triggered at the
+     * native level should cause the messages described by the matching
+     * <code>Callback</code> objects to be invoked. This method is used
+     * to safely shut down DWT when it is run within environments
+     * which can generate spurious events.
+     * <p>
+     * Note: This should not be called by application code.
+     * </p>
+     *
+     * @return true if callbacks should not be invoked
+     */
+    //public static final native synchronized bool getEnabled ();
+    /**
+     * This might be called directly from native code in environments
+     * which can generate spurious events. Check before removing it.
+     *
+     * @deprecated
+     *
+     * @param ignore true if callbacks should not be invoked
+     */
+    static final void ignoreCallbacks (bool ignore)
+    {
+        setEnabled(!ignore);
+    }
+
+    /**
+     * Immediately wipes out all native level state associated
+     * with <em>all</em> callbacks.
+     * <p>
+     * <b>WARNING:</b> This operation is <em>extremely</em> dangerous,
+     * and should never be performed by application code.
+     * </p>
+     */
+    //public static final native synchronized void reset ();
+    /**
+     * Releases the native level resources associated with the callback.
+     *
+     * @see #dispose
+     */
+    //static final native synchronized void unbind (Callback callback);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/CloneableCompatibility.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.CloneableCompatibility;
+
+import dwt.dwthelper.utils;
+
+/**
+ * This interface is the cross-platform version of the
+ * java.lang.Cloneable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * implement CloneableCompatibility instead of java.lang.Cloneable.
+ * </p>
+ * <p>
+ * Note: java.lang.Cloneable is not part of CLDC.
+ * </p>
+ */
+public interface CloneableCompatibility : Cloneable
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/Compatibility.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,418 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.Compatibility;
+
+import Math = tango.math.Math;
+import Character = tango.text.Unicode;
+
+import dwt.DWT;
+
+import dwt.dwthelper.BufferedInputStream;
+import dwt.dwthelper.File;
+import dwt.dwthelper.FileInputStream;
+import dwt.dwthelper.FileOutputStream;
+import dwt.dwthelper.InputStream;
+import dwt.dwthelper.OutputStream;
+import java.text.MessageFormat;
+import dwt.dwthelper.MissingResourceException;
+import dwt.dwthelper.ResourceBundle;
+import dwt.dwthelper.utils;
+import java.util.zip.DeflaterOutputStream;
+import java.util.zip.InflaterInputStream;
+
+
+
+/**
+ * This class is a placeholder for utility methods commonly
+ * used on J2SE platforms but not supported on some J2ME
+ * profiles.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms.
+ * </p>
+ * <p>
+ * IMPORTANT: some of the methods have been modified from their
+ * J2SE parents. Refer to the description of each method for 
+ * specific changes.
+ * </p>
+ * <ul>
+ * <li>Exceptions thrown may differ since J2ME's set of 
+ * exceptions is a subset of J2SE's one.
+ * </li>
+ * <li>The range of the mathematic functions is subject to
+ * change.
+ * </li>        
+ * </ul>
+ */
+public final class Compatibility
+{
+
+    /**
+     * Returns the PI constant as a double.
+     */
+    public static double PI = Math.PI;
+
+    static double toRadians = PI / 180;
+
+    /**
+     * Answers the length of the side adjacent to the given angle
+     * of a right triangle. In other words, it returns the integer
+     * conversion of length * cos (angle).
+     * <p>
+     * IMPORTANT: the j2me version has an additional restriction on
+     * the argument. length must be between -32767 and 32767 (inclusive).
+     * </p>
+     * 
+     * @param angle the angle in degrees
+     * @param length the length of the triangle's hypotenuse
+     * @return the integer conversion of length * cos (angle)
+     */
+    public static int cos (int angle, int length)
+    {
+        return cast(int) (Math.cos(angle * toRadians) * length);
+    }
+
+    /**
+     * Answers the length of the side opposite to the given angle
+     * of a right triangle. In other words, it returns the integer
+     * conversion of length * sin (angle).
+     * <p>
+     * IMPORTANT: the j2me version has an additional restriction on
+     * the argument. length must be between -32767 and 32767 (inclusive).
+     * </p>
+     * 
+     * @param angle the angle in degrees
+     * @param length the length of the triangle's hypotenuse
+     * @return the integer conversion of length * sin (angle)
+     */
+    public static int sin (int angle, int length)
+    {
+        return cast(int) (Math.sin(angle * toRadians) * length);
+    }
+
+    /**
+     * Answers the most negative (i.e. closest to negative infinity)
+     * integer value which is greater than the number obtained by dividing
+     * the first argument p by the second argument q.
+     * 
+     * @param p numerator
+     * @param q denominator (must be different from zero)
+     * @return the ceiling of the rational number p / q.
+     */
+    public static int ceil (int p, int q)
+    {
+        return cast(int) Math.ceil(cast(float) p / q);
+    }
+
+    /**
+     * Answers whether the indicated file exists or not.
+     * 
+     * @param parent the file's parent directory
+     * @param child the file's name
+     * @return true if the file exists
+     */
+    public static bool fileExists (String parent, String child)
+    {
+        return (new File(parent, child)).exists();
+    }
+
+    /**
+     * Answers the most positive (i.e. closest to positive infinity)
+     * integer value which is less than the number obtained by dividing
+     * the first argument p by the second argument q.
+     *
+     * @param p numerator
+     * @param q denominator (must be different from zero)
+     * @return the floor of the rational number p / q.
+     */
+    public static int floor (int p, int q)
+    {
+        return cast(int) Math.floor(cast(double) p / q);
+    }
+
+    /**
+     * Answers the result of rounding to the closest integer the number obtained 
+     * by dividing the first argument p by the second argument q.
+     * <p>
+     * IMPORTANT: the j2me version has an additional restriction on
+     * the arguments. p must be within the range 0 - 32767 (inclusive).
+     * q must be within the range 1 - 32767 (inclusive).
+     * </p>
+     * 
+     * @param p numerator
+     * @param q denominator (must be different from zero)
+     * @return the closest integer to the rational number p / q
+     */
+    public static int round (int p, int q)
+    {
+        return Math.round(cast(float) p / q);
+    }
+
+    /**
+     * Returns 2 raised to the power of the argument.
+     *
+     * @param n an int value between 0 and 30 (inclusive)
+     * @return 2 raised to the power of the argument
+     *
+     * @exception IllegalArgumentException <ul>
+     *    <li>ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)</li>
+     * </ul>
+     */
+    public static int pow2 (int n)
+    {
+        if (n >= 1 && n <= 30)
+            return 2 << (n - 1);
+        else if (n !is 0)
+        {
+            DWT.error(DWT.ERROR_INVALID_RANGE);
+        }
+        return 1;
+    }
+
+    /**
+     * Create an DeflaterOutputStream if such things are supported.
+     * 
+     * @param stream the output stream
+     * @return a deflater stream or <code>null</code>
+     * @exception IOException
+     * 
+     * @since 3.4
+     */
+    public static OutputStream newDeflaterOutputStream (OutputStream stream)
+    {
+        return new DeflaterOutputStream(stream);
+    }
+
+    /**
+     * Open a file if such things are supported.
+     * 
+     * @param filename the name of the file to open
+     * @return a stream on the file if it could be opened.
+     * @exception IOException
+     */
+    public static InputStream newFileInputStream (String filename)
+    {
+        return new FileInputStream(filename);
+    }
+
+    /**
+     * Open a file if such things are supported.
+     * 
+     * @param filename the name of the file to open
+     * @return a stream on the file if it could be opened.
+     * @exception IOException
+     */
+    public static OutputStream newFileOutputStream (String filename)
+    {
+        return new FileOutputStream(filename);
+    }
+
+    /**
+     * Create an InflaterInputStream if such things are supported.
+     * 
+     * @param stream the input stream
+     * @return a inflater stream or <code>null</code>
+     * @exception IOException
+     * 
+     * @since 3.3
+     */
+    public static InputStream newInflaterInputStream (InputStream stream)
+    {
+        return new BufferedInputStream(new InflaterInputStream(stream));
+    }
+
+    /**
+     * Answers whether the character is a letter.
+     *
+     * @param c the character
+     * @return true when the character is a letter
+     */
+    public static bool isLetter (char c)
+    {
+        return Character.isLetter(c);
+    }
+
+    /**
+     * Answers whether the character is a letter or a digit.
+     *
+     * @param c the character
+     * @return true when the character is a letter or a digit
+     */
+    public static bool isLetterOrDigit (char c)
+    {
+        return Character.isLetterOrDigit(c);
+    }
+
+    /**
+     * Answers whether the character is a Unicode space character.
+     *
+     * @param c  the character
+     * @return true when the character is a Unicode space character
+     */
+    public static bool isSpaceChar (char c)
+    {
+        return Character.isSpace(c);
+    }
+
+    /**
+     * Answers whether the character is a whitespace character.
+     *
+     * @param c the character to test
+     * @return true if the character is whitespace
+     */
+    public static bool isWhitespace (char c)
+    {
+        return Character.isWhitespace(c);
+    }
+
+    /**
+     * Execute a program in a separate platform process if the
+     * underlying platform support this.
+     * <p>
+     * The new process inherits the environment of the caller.
+     * </p>
+     *
+     * @param prog the name of the program to execute
+     *
+     * @exception IOException
+     *  if the program cannot be executed
+     * @exception SecurityException
+     *  if the current SecurityManager disallows program execution
+     */
+    public static void exec (String prog)
+    {
+        //Runtime.getRuntime().exec(prog);
+    }
+
+    /**
+     * Execute progArray[0] in a separate platform process if the
+     * underlying platform support this.
+     * <p>
+     * The new process inherits the environment of the caller.
+     * <p>
+     *
+     * @param progArray array containing the program to execute and its arguments
+     *
+     * @exception IOException
+     *  if the program cannot be executed
+     * @exception   SecurityException
+     *  if the current SecurityManager disallows program execution
+     */
+    public static void exec (String[] progArray)
+    {
+        Runtime.getRuntime().exec(progArray);
+    }
+
+    private static ResourceBundle msgs = null;
+
+    /**
+     * Returns the NLS'ed message for the given argument. This is only being
+     * called from DWT.
+     * 
+     * @param key the key to look up
+     * @return the message for the given key
+     * 
+     * @see DWT#getMessage(String)
+     */
+    public static String getMessage (String key)
+    {
+        String answer = key;
+
+        if (key is null)
+        {
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        }
+        if (msgs is null)
+        {
+            try
+            {
+                msgs = ResourceBundle.getBundle("dwt.internal.SWTMessages"); //$NON-NLS-1$
+            }
+            catch (MissingResourceException ex)
+            {
+                answer = key + " (no resource bundle)"; //$NON-NLS-1$
+            }
+        }
+        if (msgs !is null)
+        {
+            try
+            {
+                answer = msgs.getString(key);
+            }
+            catch (MissingResourceException ex2)
+            {
+            }
+        }
+        return answer;
+    }
+
+    public static String getMessage (String key, Object[] args)
+    {
+        String answer = key;
+
+        if (key is null || args is null)
+        {
+            DWT.error(DWT.ERROR_NULL_ARGUMENT);
+        }
+        if (msgs is null)
+        {
+            try
+            {
+                msgs = ResourceBundle.getBundle("dwt.internal.SWTMessages"); //$NON-NLS-1$
+            }
+            catch (MissingResourceException ex)
+            {
+                answer = key + " (no resource bundle)"; //$NON-NLS-1$
+            }
+        }
+        if (msgs !is null)
+        {
+            try
+            {
+                MessageFormat formatter = new MessageFormat("");
+                formatter.applyPattern(msgs.getString(key));
+                answer = formatter.format(args);
+            }
+            catch (MissingResourceException ex2)
+            {
+            }
+        }
+        return answer;
+    }
+
+    /**
+     * Interrupt the current thread. 
+     * <p>
+     * Note that this is not available on CLDC.
+     * </p>
+     */
+    public static void interrupt ()
+    {
+        Thread.currentThread().interrupt();
+    }
+
+    /**
+     * Compares two instances of class String ignoring the case of the
+     * characters and answers if they are equal.
+     *
+     * @param s1 string
+     * @param s2 string
+     * @return true if the two instances of class String are equal
+     */
+    public static bool equalsIgnoreCase (String s1, String s2)
+    {
+        return s1.equalsIgnoreCase(s2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/DWTEventListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.DWTEventListener;
+
+import dwt.dwthelper.utils;
+
+/**
+ * This interface is the cross-platform version of the
+ * java.util.EventListener interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * implement DWTEventListener instead of java.util.EventListener.
+ * </p>
+ * <p>
+ * Note: java.util.EventListener is not part of CDC and CLDC.
+ * </p>
+ */
+public interface DWTEventListener : EventListener
+{
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/DWTEventObject.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.DWTEventObject;
+
+import dwt.dwthelper.utils;
+
+import java.util.EventObject;
+
+/**
+ * This class is the cross-platform version of the
+ * java.util.EventObject class.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * extend DWTEventObject instead of java.util.EventObject.
+ * </p>
+ * <p>
+ * Note: java.util.EventObject is not part of CDC and CLDC.
+ * </p>
+ */
+public class DWTEventObject : EventObject
+{
+
+    static const long serialVersionUID = 3258125873411470903L;
+
+    /**
+     * Constructs a new instance of this class.
+     *
+     * @param source the object which fired the event
+     */
+    public this (Object source)
+    {
+        super(source);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/LONG.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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 <benoit@tionex.de>
+ *******************************************************************************/
+module dwt.internal.LONG;
+
+import dwt.dwthelper.utils;
+
+public class LONG
+{
+    public int /*long*/value;
+
+    public this (int /*long*/value)
+    {
+        this.value = value;
+    }
+
+    public override int opEquals (Object object)
+    {
+        if (object is this)
+            return true;
+        
+        if (auto obj = cast(LONG) object)
+            return obj.value is this.value;
+        
+        return false;
+    }
+
+    public override hash_t toHash ()
+    {
+        return /*64*/value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/Library.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ * 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 <benoit@tionex.de>
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.Library;
+
+import tango.util.Convert;
+
+import dwt.dwthelper.utils;
+
+//do it here, so it can be evaluated at compile time
+//this saves a static ctor.
+private int buildSWT_VERSION (int major, int minor)
+{
+    return major * 1000 + minor;
+}
+
+public class Library
+{
+
+    /* DWT Version - Mmmm (M=major, mmm=minor) */
+
+    /**
+     * DWT Major version number (must be >= 0)
+     */
+    static const int MAJOR_VERSION = 3;
+
+    /**
+     * DWT Minor version number (must be in the range 0..999)
+     */
+    static const int MINOR_VERSION = 440;
+
+    /**
+     * DWT revision number (must be >= 0)
+     */
+    static const int REVISION = 0;
+
+    /**
+     * The JAVA and DWT versions
+     */
+    //public static const int JAVA_VERSION;
+    public static const int SWT_VERSION = .buildSWT_VERSION(MAJOR_VERSION,
+            MINOR_VERSION);
+
+    version (darwin)
+        static const String SEPARATOR = "\n";
+    
+    else
+        static assert(false, "Only Mac OS X supported for this port");
+
+    static int parseVersion (String aVersion)
+    {
+        if (aVersion == null)
+            return 0;
+        int major = 0, minor = 0, micro = 0;
+        int length = aVersion.length, index = 0, start = 0;
+        bool isDigit (char c)
+        {
+            return c >= '0' && c <= '9';
+        }
+        while (index < length && isDigit(aVersion[index]))
+            index++;
+        try
+        {
+            if (start < length)
+                major = to!(int)(aVersion[start .. index]);
+        }
+        catch (ConversionException e)
+        {
+        }
+        start = ++index;
+        while (index < length && isDigit(aVersion[index]))
+            index++;
+        try
+        {
+            if (start < length)
+                minor = to!(int)(aVersion[start .. index]);
+        }
+        catch (ConversionException e)
+        {
+        }
+        start = ++index;
+        while (index < length && isDigit(aVersion[index]))
+            index++;
+        try
+        {
+            if (start < length)
+                micro = to!(int)(aVersion[start .. index]);
+        }
+        catch (ConversionException e)
+        {
+        }
+        return buildJAVA_VERSION(major, minor, micro);
+    }
+
+    /**
+     * Returns the Java version number as an integer.
+     * 
+     * @param major
+     * @param minor
+     * @param micro
+     * @return the version
+     */
+    public static int buildJAVA_VERSION (int major, int minor, int micro)
+    {
+        return (major << 16) + (minor << 8) + micro;
+    }
+
+    /**
+     * Returns the DWT version number as an integer.
+     * 
+     * @param major
+     * @param minor
+     * @return the version
+     */
+    public static int buildSWT_VERSION (int major, int minor)
+    {
+        return .buildSWT_VERSION(major, minor);
+    }
+/+ PORTING_LEFT
+ static bool extract (String fileName, String mappedName) {
+ FileOutputStream os = null;
+ InputStream is = null;
+ File file = new File(fileName);
+ try {
+ if (!file.exists ()) {
+ is = Library.class.getResourceAsStream ("/" + mappedName); //$NON-NLS-1$
+ if (is !is null) {
+ int read;
+ byte [] buffer = new byte [4096];
+ os = new FileOutputStream (fileName);
+ while ((read = is.read (buffer)) !is -1) {
+ os.write(buffer, 0, read);
+ }
+ os.close ();
+ is.close ();
+ if (!Platform.PLATFORM.equals ("win32")) { //$NON-NLS-1$
+ try {
+ Runtime.getRuntime ().exec (new String []{"chmod", "755", fileName}).waitFor(); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (Throwable e) {}
+ }
+ if (load (fileName)) return true;
+ }
+ }
+ } catch (Throwable e) {
+ try {
+ if (os !is null) os.close ();
+ } catch (IOException e1) {}
+ try {
+ if (is !is null) is.close ();
+ } catch (IOException e1) {}
+ }
+ if (file.exists ()) file.delete ();
+ return false;
+ }
+
+ static bool load (String libName) {
+ try {
+ if (libName.indexOf (SEPARATOR) !is -1) {
+ System.load (libName);
+ } else {
+ System.loadLibrary (libName);
+ }       
+ return true;
+ } catch (UnsatisfiedLinkError e) {}
+ return false;
+ }
+
+ /**
+ * Loads the shared library that matches the version of the
+ * Java code which is currently running.  DWT shared libraries
+ * follow an encoding scheme where the major, minor and revision
+ * numbers are embedded in the library name and this along with
+ * <code>name</code> is used to load the library.  If this fails,
+ * <code>name</code> is used in another attempt to load the library,
+ * this time ignoring the DWT version encoding scheme.
+ *
+ * @param name the name of the library to load
+ */
+ public static void loadLibrary (String name) {
+ loadLibrary (name, true);
+ }
+
+ /**
+ * Loads the shared library that matches the version of the
+ * Java code which is currently running.  DWT shared libraries
+ * follow an encoding scheme where the major, minor and revision
+ * numbers are embedded in the library name and this along with
+ * <code>name</code> is used to load the library.  If this fails,
+ * <code>name</code> is used in another attempt to load the library,
+ * this time ignoring the DWT version encoding scheme.
+ *
+ * @param name the name of the library to load
+ * @param mapName true if the name should be mapped, false otherwise
+ */
+ public static void loadLibrary (String name, bool mapName) {
+ String prop = System.getProperty ("sun.arch.data.model"); //$NON-NLS-1$
+ if (prop is null) prop = System.getProperty ("com.ibm.vm.bitmode"); //$NON-NLS-1$
+ if (prop !is null) {
+ if ("32".equals (prop)) { //$NON-NLS-1$
+ if (0x1FFFFFFFFL is (int /*long*/)0x1FFFFFFFFL) {
+ throw new UnsatisfiedLinkError ("Cannot load 64-bit DWT libraries on 32-bit JVM"); //$NON-NLS-1$
+ }
+ }
+ if ("64".equals (prop)) { //$NON-NLS-1$
+ if (0x1FFFFFFFFL !is (int /*long*/)0x1FFFFFFFFL) {
+ throw new UnsatisfiedLinkError ("Cannot load 32-bit DWT libraries on 64-bit JVM"); //$NON-NLS-1$
+ }       
+ }
+ }
+ 
+ /* Compute the library name and mapped name */
+ String libName1, libName2, mappedName1, mappedName2;
+ if (mapName) {
+ String version = System.getProperty ("swt.version"); //$NON-NLS-1$
+ if (version is null) {
+ version = "" + MAJOR_VERSION; //$NON-NLS-1$
+ /* Force 3 digits in minor version number */
+ if (MINOR_VERSION < 10) {
+ version += "00"; //$NON-NLS-1$
+ } else {
+ if (MINOR_VERSION < 100) version += "0"; //$NON-NLS-1$
+ }
+ version += MINOR_VERSION;       
+ /* No "r" until first revision */
+ if (REVISION > 0) version += "r" + REVISION; //$NON-NLS-1$
+ }
+ libName1 = name + "-" + Platform.PLATFORM + "-" + version;  //$NON-NLS-1$ //$NON-NLS-2$
+ libName2 = name + "-" + Platform.PLATFORM;  //$NON-NLS-1$
+ mappedName1 = System.mapLibraryName (libName1);
+ mappedName2 = System.mapLibraryName (libName2);
+ } else {
+ libName1 = libName2 = mappedName1 = mappedName2 = name;
+ }
+
+ /* Try loading library from swt library path */
+ String path = System.getProperty ("swt.library.path"); //$NON-NLS-1$
+ if (path !is null) {
+ path = new File (path).getAbsolutePath ();
+ if (load (path + SEPARATOR + mappedName1)) return;
+ if (mapName && load (path + SEPARATOR + mappedName2)) return;
+ }
+
+ /* Try loading library from java library path */
+ if (load (libName1)) return;
+ if (mapName && load (libName2)) return;
+ 
+ /* Try loading library from the tmp directory if swt library path is not specified */
+ if (path is null) {
+ path = System.getProperty ("java.io.tmpdir"); //$NON-NLS-1$
+ path = new File (path).getAbsolutePath ();
+ if (load (path + SEPARATOR + mappedName1)) return;
+ if (mapName && load (path + SEPARATOR + mappedName2)) return;
+ }
+ 
+ /* Try extracting and loading library from jar */
+ if (path !is null) {
+ if (extract (path + SEPARATOR + mappedName1, mappedName1)) return;
+ if (mapName && extract (path + SEPARATOR + mappedName2, mappedName2)) return;
+ }
+ 
+ /* Failed to find the library */
+ throw new UnsatisfiedLinkError ("no " + libName1 + " or " + libName2 + " in swt.library.path, java.library.path or the jar file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ +/
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/Lock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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 <benoit@tionex.de>
+ *******************************************************************************/
+module dwt.internal.Lock;
+
+import tango.core.Thread;
+import tango.core.sync.Mutex;
+import tango.core.sync.Condition;
+import tango.core.Exception;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Instance of this represent a recursive monitor.
+ */
+public class Lock
+{
+    int count, waitCount;
+    Thread owner;
+    Mutex mutex;
+    Condition cond;
+
+    public this ()
+    {
+        mutex = new Mutex;
+        cond = new Condition(mutex);
+    }
+
+    /**
+     * Locks the monitor and returns the lock count. If
+     * the lock is owned by another thread, wait until
+     * the lock is released.
+     *
+     * @return the lock count
+     */
+    public int lock ()
+    {
+        synchronized (mutex)
+        {
+            Thread current = Thread.getThis();
+            if (owner !is current)
+            {
+                waitCount++;
+                while (count > 0)
+                {
+                    try
+                    {
+                        cond.wait();
+                    }
+                    catch (SyncException e)
+                    {
+                    /* Wait forever, just like synchronized blocks */
+                    }
+                }
+                --waitCount;
+                owner = current;
+            }
+            return ++count;
+        }
+    }
+
+    /**
+     * Unlocks the monitor. If the current thread is not
+     * the monitor owner, do nothing.
+     */
+    public void unlock ()
+    {
+        synchronized (mutex)
+        {
+            Thread current = Thread.getThis();
+            if (owner is current)
+            {
+                if (--count is 0)
+                {
+                    owner = null;
+                    if (waitCount > 0)
+                        cond.notifyAll();
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/Platform.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.Platform;
+
+import dwt.dwthelper.utils;
+
+public class Platform
+{
+    public static const char[] PLATFORM = "cocoa"; //$NON-NLS-1$
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/SerializableCompatibility.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.SerializableCompatibility;
+
+import dwt.dwthelper.utils;
+
+interface Serializable{}
+
+/**
+ * This interface is the cross-platform version of the
+ * java.io.Serializable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * implement SerializableCompatibility instead of
+ * java.io.Serializable.
+ * </p>
+ * <p>
+ * Note: java.io.Serializable is not part of CLDC.
+ * </p>
+ */
+public interface SerializableCompatibility : Serializable
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/callback.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.c.callback;
+
+import dwt.internal.Callback;
+
+alias size_t SWT_PTR;
+
+struct CALLBACK_DATA 
+{
+    Callback callback;
+    jmethodID methodID;
+    Object object;
+    bool isStatic;
+    bool isArrayBased; 
+    int argCount;
+    SWT_PTR errorResult;
+}
+
+bool USE_ASSEMBLER = false;
+
+version (X86)
+    bool USE_ASSEMBLER = true;
+
+private
+{
+    CALLBACK_DATA callbackData[MAX_CALLBACKS];
+    int callbackEnabled = 1;
+    int callbackEntryCount = 0;
+    int initialized = 0;
+}
+
+
+SWT_PTR callback(int index, ...);
+
+static if (USE_ASSEMBLER)
+{
+    version (Win32){}
+    else version (Win32_WCE){}
+    else
+        import tango.stdc.posix.sys.mman;
+
+    ubyte* callbackCode = null;
+    int CALLBACK_THUNK_SIZE = 64;
+}
+
+SWT_PTR Java_org_eclipse_swt_internal_Callback_bind (JNIEnv* env, jclass that,
+        jobject callbackObject, jobject object, jstring method,
+        jstring signature, jint argCount, jboolean isStatic,
+        jboolean isArrayBased, SWT_PTR errorResult)
+{
+    int i;
+    jmethodID mid = null;
+    jclass javaClass = that;
+    const char* methodString = null;
+    const char* sigString = null;
+
+    if (jvm == null)
+        (*env).GetJavaVM(env, &jvm);
+
+    if (!initialized)
+    {
+        memset(&callbackData, 0, sizeof(callbackData));
+        initialized = 1;
+    }
+    
+    if (method)
+        methodString = cast(/*const*/char*) (*env).GetStringUTFChars(env,
+                method, null);
+    
+    if (signature)
+        sigString = cast(/*const*/char*) (*env).GetStringUTFChars(env,
+                signature, null);
+    
+    if (object && methodString && sigString)
+    {
+        if (isStatic)
+        {
+            mid = (*env).GetStaticMethodID(env, object, methodString, sigString);
+        }
+        else
+        {
+            javaClass = (*env).GetObjectClass(env, object);
+            mid = (*env).GetMethodID(env, javaClass, methodString, sigString);
+        }
+    }
+    
+    if (method && methodString)
+        (*env).ReleaseStringUTFChars(env, method, methodString);
+    
+    if (signature && sigString)
+        (*env).ReleaseStringUTFChars(env, signature, sigString);
+    
+    if (mid == 0)
+        goto fail;
+    
+    for (i = 0; i < MAX_CALLBACKS; i++)
+    {
+        if (!callbackData[i].callback)
+        {
+            if ((callbackData[i].callback = (*env).NewGlobalRef(env,
+                    callbackObject)) == null)
+                goto fail;
+            
+            if ((callbackData[i].object = (*env).NewGlobalRef(env, object)) == null)
+                goto fail;
+            
+            callbackData[i].isStatic = isStatic;
+            callbackData[i].isArrayBased = isArrayBased;
+            callbackData[i].argCount = argCount;
+            callbackData[i].errorResult = errorResult;
+            callbackData[i].methodID = mid;
+
+            static if (!USE_ASSEMBLER)
+                return cast(SWT_PTR) fnx_array[argCount][i];
+
+            {
+                int j = 0, k, pad = 0;
+                ubyte* code;
+                
+                if (callbackCode == null)
+                {
+                    version (Win32)
+                    {
+                        callbackCode = VirtualAlloc(null,
+                                CALLBACK_THUNK_SIZE * MAX_CALLBACKS,
+                                MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+                        if (callbackCode == null)
+                            return 0;
+                    }
+
+                    else version (Win32_WCE)
+                    {
+                        callbackCode = VirtualAlloc(null,
+                                CALLBACK_THUNK_SIZE * MAX_CALLBACKS,
+                                MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+                        if (callbackCode == null)
+                            return 0;
+                    }
+
+                    else
+                    {
+                        callbackCode = mmap(null,
+                                CALLBACK_THUNK_SIZE * MAX_CALLBACKS,
+                                PROT_EXEC | PROT_READ | PROT_WRITE,
+                                MAP_PRIVATE | MAP_ANON, -1, 0);
+                        if (callbackCode == MAP_FAILED)
+                            return 0;
+                    }
+                }
+                code = cast(ubyte*) (callbackCode + (i * CALLBACK_THUNK_SIZE));
+
+                //PUSH EBP - 1 byte
+                code[j++] = 0x55;
+
+                //MOV EBP,ESP - 2 bytes
+                code[j++] = 0x8b;
+                code[j++] = 0xec;
+
+                version (darwin)
+                {
+                    /* darwin calling conventions require that the stack be aligned on a 16-byte boundary. */
+                    k = (argCount + 3) * sizeof(SWT_PTR);
+                    pad = ((k + 15) & ~15) - k;
+                    if (pad > 0)
+                    {
+                        //SUB ESP,pad - 3 bytes
+                        code[j++] = 0x83;
+                        code[j++] = 0xec;
+                        code[j++] = pad;
+                    }
+                }
+
+                // 3*argCount bytes
+                for (k = (argCount + 1) * sizeof(SWT_PTR); k >= sizeof(SWT_PTR) * 2; k -= sizeof(
+                        SWT_PTR))
+                {
+                    //PUSH SS:[EBP+k]
+                    code[j++] = 0xff;
+                    code[j++] = 0x75;
+                    code[j++] = k;
+                }
+
+                if (i > 127)
+                {
+                    //PUSH i - 5 bytes
+                    code[j++] = 0x68;
+                    code[j++] = ((i >> 0) & 0xFF);
+                    code[j++] = ((i >> 8) & 0xFF);
+                    code[j++] = ((i >> 16) & 0xFF);
+                    code[j++] = ((i >> 24) & 0xFF);
+                }
+                else
+                {
+                    //PUSH i - 2 bytes
+                    code[j++] = 0x6a;
+                    code[j++] = i;
+                }
+
+                //MOV EAX callback - 1 + sizeof(SWT_PTR) bytes
+                code[j++] = 0xb8;
+                (cast(SWT_PTR*) &code[j])[0] = cast(SWT_PTR) &callback;
+                j += sizeof(SWT_PTR);
+
+                //CALL EAX - 2 bytes
+                code[j++] = 0xff;
+                code[j++] = 0xd0;
+
+                //ADD ESP,(argCount + 1) * sizeof(SWT_PTR) - 3 bytes
+                code[j++] = 0x83;
+                code[j++] = 0xc4;
+
+                version (darwin)
+                    code[j++] = cast(ubyte) (pad + ((argCount + 1) * sizeof(
+                            SWT_PTR)));
+                else
+                    code[j++] = cast(ubyte) ((argCount + 1) * sizeof(SWT_PTR));
+
+                //POP EBP - 1 byte
+                code[j++] = 0x5d;
+
+                version (Win32)
+                {
+                    // RETN argCount * sizeof(SWT_PTR) - 3 bytes
+                    code[j++] = 0xc2;
+                    code[j++] = cast(ubyte) (argCount * sizeof(SWT_PTR));
+                    code[j++] = 0x00;
+                }
+
+                else version (Win32_WCE)
+                {
+                    // RETN argCount * sizeof(SWT_PTR) - 3 bytes
+                    code[j++] = 0xc2;
+                    code[j++] = cast(ubyte) (argCount * sizeof(SWT_PTR));
+                    code[j++] = 0x00;
+                }
+
+                else
+                {
+                    // RETN - 1 byte
+                    code[j++] = 0xc3;
+                }
+
+                if (j > CALLBACK_THUNK_SIZE)
+                {
+                    jclass
+                            errorClass = (*env).FindClass(env,
+                                    "java/lang/Error");
+                    (*env).ThrowNew(env, errorClass, "Callback thunk overflow");
+                }
+
+                return cast(SWT_PTR) code;
+            }
+        }
+    }
+    
+    fail:
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/carboncore/MacTypes.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,87 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.c.carboncore.MacTypes;
+
+/********************************************************************************
+
+ Base integer types for all target OS's and CPU's
+
+ UInt8            8-bit unsigned integer 
+ SInt8            8-bit signed integer
+ UInt16          16-bit uinteger 
+ SInt16          16-bit signed integer           
+ UInt32          32-bit uinteger 
+ SInt32          32-bit signed integer   
+ UInt64          64-bit uinteger 
+ SInt64          64-bit integer   
+
+ *********************************************************************************/
+alias ubyte UInt8;
+alias byte SInt8;
+alias ushort UInt16;
+alias short SInt16;
+alias uint UInt32;
+alias int SInt32;
+alias ulong UInt64;
+alias long SInt64;
+
+alias byte uint8_t;
+
+/********************************************************************************
+
+ Higher level basic types
+
+ OSErr                   16-bit result error code
+ OSStatus                32-bit result error code
+ LogicalAddress          Address in the clients virtual address space
+ ConstLogicalAddress     Address in the clients virtual address space that will only be read
+ PhysicalAddress         Real address as used on the hardware bus
+ BytePtr                 Pointer to an array of bytes
+ ByteCount               The size of an array of bytes
+ ByteOffset              An offset into an array of bytes
+ ItemCount               32-bit iteration count
+ OptionBits              Standard 32-bit set of bit flags
+ PBVersion               ?
+ Duration                32-bit millisecond timer for drivers
+ AbsoluteTime            64-bit clock
+ ScriptCode              A particular set of written characters (e.g. Roman vs Cyrillic) and their encoding
+ LangCode                A particular language (e.g. English), as represented using a particular ScriptCode
+ RegionCode              Designates a language as used in a particular region (e.g. British vs American
+ English) together with other region-dependent characteristics (e.g. date format)
+ FourCharCode            A 32-bit value made by packing four 1 byte characters together
+ OSType                  A FourCharCode used in the OS and file system (e.g. creator)
+ ResType                 A FourCharCode used to tag resources (e.g. 'DLOG')
+ 
+ *********************************************************************************/
+alias SInt16 OSErr;
+alias SInt32 OSStatus;
+alias void* LogicalAddress;
+alias /*const*/void* ConstLogicalAddress;
+alias void* PhysicalAddress;
+alias UInt8* BytePtr;
+alias uint ByteCount;
+alias uint ByteOffset;
+alias SInt32 Duration;
+alias UnsignedWide AbsoluteTime;
+alias UInt32 OptionBits;
+alias uint ItemCount;
+alias UInt32 PBVersion;
+alias SInt16 ScriptCode;
+alias SInt16 LangCode;
+alias SInt16 RegionCode;
+alias UInt32 FourCharCode;
+alias FourCharCode OSType;
+alias FourCharCode ResType;
+alias OSType* OSTypePtr;
+alias ResType* ResTypePtr;
+
+struct UnsignedWide
+{
+    UInt32 hi;
+    UInt32 lo;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/qd/Quickdraw.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,52 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.c.qd.Quickdraw;
+
+public
+{
+    import dwt.internal.c.qd.QuickdrawTypes;
+    import dwt.internal.c.carboncore.MacTypes;
+}
+
+import bindings = dwt.internal.c.qd.bindings;
+
+struct Rect
+{
+    short top;
+    short left;
+    short bottom;
+    short right;
+}
+
+alias int QDRegionParseDirection;
+
+template Quickdraw ()
+{
+    alias bindings.RegionToRectsProcPtr RegionToRectsProcPtr;
+    
+    alias bindings.RegionToRectsUPP RegionToRectsUPP;
+    
+    alias bindings.NewRgn NewRgn;
+    alias bindings.RectRgn RectRgn;
+    alias bindings.OpenRgn OpenRgn;
+    alias bindings.OffsetRgn OffsetRgn;
+    alias bindings.MoveTo NewRgMoveTon;
+    alias bindings.LineTo LineTo;
+    alias bindings.UnionRgn UnionRgn;
+    alias bindings.CloseRgn CloseRgn;
+    alias bindings.DisposeRgn DisposeRgn;
+    alias bindings.PtInRgn PtInRgn;
+    alias bindings.GetRegioinBounds GetRegioinBounds;
+    alias bindings.SectRgn SectRgn;
+    alias bindings.EmptyRgn EmptyRgn;
+    alias bindings.DiffRgn DiffRgn;
+    alias bindings.RectInRgn RectInRgn;
+    alias bindings.QDRegionToRects QDRegionToRects;
+    alias bindings.CopyRgn CopyRgn;
+    alias bindings.SetRect SetRect;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/qd/QuickdrawTypes.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,29 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.c.qd.QuickdrawTypes;
+
+import dwt.internal.c.qd.Quickdraw;
+
+struct MacRegion
+{
+    ushort rgnSize; /* size in bytes; don't rely on it */
+    Rect rgnBBox; /* enclosing rectangle; in Carbon use GetRegionBounds */
+}
+
+struct Point
+{
+    short v;
+    short h;
+}
+
+alias MacRegion Region;
+alias MacRegion* RgnPtr;
+alias RgnPtr* RgnHandle;
+
+alias bool Boolean;
+alias bool BOOL;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/qd/bindings.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,37 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.c.qd.bindings;
+
+import dwt.internal.c.qd.QuickdrawTypes;
+import dwt.internal.c.qd.Quickdraw;
+import dwt.internal.objc.runtime;
+
+
+alias extern (C) OSStatus* delegate (UInt16 message, RgnHandle rgn, /*const*/Rect* rect, void* refCon) RegionToRectsProcPtr;
+alias RegionToRectsProcPtr RegionToRectsUPP;
+
+extern (C):
+
+RgnHandle NewRgn ();
+void RectRgn (RgnHandle rgn, /*const*/Rect* r);
+void OpenRgn ();
+void OffsetRgn (RgnHandle rgn, short dh, short dv);
+void MoveTo (short h, short v);
+void LineTo (short h, short v);
+void UnionRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
+void CloseRgn (RgnHandle dstRgn);
+void DisposeRgn (RgnHandle rgn);
+Boolean PtInRgn (Point pt, RgnHandle rgn);
+Rect* GetRegioinBounds (RgnHandle region, Rect* bounds);
+void SectRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
+Boolean EmptyRgn (RgnHandle rgn);
+void DiffRgn (RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
+Boolean RectInRgn (/*const*/Rect* r, RgnHandle rgn);
+OSStatus QDRegionToRects (RgnHandle rgn, QDRegionParseDirection dir, RegionToRectsUPP proc, void* userData);
+void CopyRgn (RgnHandle srcRgn, RgnHandle dstRgn);
+void SetRect (Rect* r, short left, short top, short right, short bottom);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/c/swt.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+ 
+/**
+ * swt.h
+ *
+ * This file contains the global macro declarations for the
+ * SWT library.
+ *
+ */
+module dwt.internal.c.swt;
+
+alias size_t SWT_PTR;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CFNumberFormatter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,35 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 31, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.CFNumberFormatter;
+
+enum
+{
+    kCFNumberFormatterPadBeforePrefix = 0,
+    kCFNumberFormatterPadAfterPrefix = 1,
+    kCFNumberFormatterPadBeforeSuffix = 2,
+    kCFNumberFormatterPadAfterSuffix = 3
+}
+
+enum CFNumberFormatterRoundingMode
+{
+    kCFNumberFormatterRoundCeiling = 0,
+    kCFNumberFormatterRoundFloor = 1,
+    kCFNumberFormatterRoundDown = 2,
+    kCFNumberFormatterRoundUp = 3,
+    kCFNumberFormatterRoundHalfEven = 4,
+    kCFNumberFormatterRoundHalfDown = 5,
+    kCFNumberFormatterRoundHalfUp = 6
+}
+
+alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundCeiling kCFNumberFormatterRoundCeiling;
+alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundFloor kCFNumberFormatterRoundFloor;
+alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundDown kCFNumberFormatterRoundDown;
+alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundUp kCFNumberFormatterRoundUp;
+alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundHalfEven kCFNumberFormatterRoundHalfEven;
+alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundHalfDown kCFNumberFormatterRoundHalfDown;
+alias CFNumberFormatterRoundingMode.kCFNumberFormatterRoundHalfUp kCFNumberFormatterRoundHalfUp;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CFPropertyList.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,28 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 28, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.CFPropertyList;
+
+enum CFPropertyListFormat {
+    kCFPropertyListOpenStepFormat = 1,
+    kCFPropertyListXMLFormat_v1_0 = 100,
+    kCFPropertyListBinaryFormat_v1_0 = 200
+}
+
+alias CFPropertyListFormat.kCFPropertyListOpenStepFormat kCFPropertyListOpenStepFormat;
+alias CFPropertyListFormat.kCFPropertyListXMLFormat_v1_0 kCFPropertyListXMLFormat_v1_0;
+alias CFPropertyListFormat.kCFPropertyListBinaryFormat_v1_0 kCFPropertyListBinaryFormat_v1_0;
+
+enum CFPropertyListMutabilityOptions {
+    kCFPropertyListImmutable = 0,
+    kCFPropertyListMutableContainers = 1,
+    kCFPropertyListMutableContainersAndLeaves = 2
+}
+
+alias CFPropertyListMutabilityOptions.kCFPropertyListImmutable kCFPropertyListImmutable;
+alias CFPropertyListMutabilityOptions.kCFPropertyListMutableContainers kCFPropertyListMutableContainers;
+alias CFPropertyListMutabilityOptions.kCFPropertyListMutableContainersAndLeaves kCFPropertyListMutableContainersAndLeaves;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CFRunLoopRef.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,10 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 4, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.CFRunLoopRef;
+
+alias void** CFRunLoopRef;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CGBase.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,23 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 23, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.CGBase;
+
+version (X86_64)
+    alias double CGFloat;
+
+else version (PPC64)
+    alias double CGFloat;
+
+else version (X86)
+    alias float CGFloat;
+
+else version (PPC)
+    alias float CGFloat;
+
+else
+    pragma(msg, "CGFloat is Unimplemented");
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CGColorSpace.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,11 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 26, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.CGColorSpace;
+
+alias void* CGColorSpace;
+alias CGColorSpace* CGColorSpaceRef;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CGEventTypes.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,10 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 22, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.CGEventTypes;
+
+alias void* CGEventRef;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CGFloat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,23 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 23, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.CGFloat;
+
+version (X86_64)
+    alias double CGFloat;
+
+else version (PPC64)
+    alias double CGFloat;
+
+else version (X86)
+    alias float CGFloat;
+
+else version (PPC)
+    alias float CGFloat;
+
+else
+    pragma(msg, "CGFloat is unimplemented");
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CGPoint.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.CGPoint;
+
+import dwt.internal.cocoa.CGFloat;
+
+struct CGPoint {
+    CGFloat x;
+    CGFloat y;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CGRect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.CGRect;
+
+import dwt.internal.cocoa.CGPoint;
+import dwt.internal.cocoa.CGSize;
+
+struct CGRect {
+    CGPoint origin;
+    CGSize size;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CGSize.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.CGSize;
+
+import dwt.internal.cocoa.CGFloat;
+
+struct CGSize {
+    CGFloat width;
+    CGFloat height;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CIColor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.CIColor;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class CIColor : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public CIColor initWithColor (NSColor color)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithColor_1, color !is null ? color.id : null);
+        return result !is null ? this : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/CIImage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.CIImage;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSBitmapImageRep;
+import dwt.internal.cocoa.NSImage : NSCompositingOperation;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import objc = dwt.internal.objc.runtime;
+
+public class CIImage : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void drawAtPoint (NSPoint point, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawAtPoint_1fromRect_1operation_1fraction_1, point, fromRect, op, delta);
+    }
+
+    public void drawInRect (NSRect rect, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInRect_1fromRect_1operation_1fraction_1, rect, fromRect, op, delta);
+    }
+
+    public CIImage initWithBitmapImageRep (NSBitmapImageRep bitmapImageRep)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBitmapImageRep_1, bitmapImageRep !is null ? bitmapImageRep.id : null);
+        return result !is null ? this : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/DOMDocument.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.DOMDocument;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.WebFrame;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.objc : id;
+
+public class DOMDocument : NSObject {
+
+    public this () {
+        super();
+    }
+
+    public this (objc.id id) {
+        super(id);
+    }
+
+    //  public NSURL URLWithAttributeString(NSString String) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_URLWithAttributeString_1, String !is null ? String.id : 0);
+    //      return result !is 0 ? new NSURL(result) : null;
+    //  }
+
+    //  public DOMNode adoptNode(DOMNode source) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_adoptNode_1, source !is null ? source.id : 0);
+    //      return result !is 0 ? new DOMNode(result) : null;
+    //  }
+
+    //  public DOMAttr createAttribute(NSString name) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createAttribute_1, name !is null ? name.id : 0);
+    //      return result !is 0 ? new DOMAttr(result) : null;
+    //  }
+
+    //  public DOMAttr createAttributeNS__(NSString createAttributeNS, NSString ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createAttributeNS_1_1, createAttributeNS !is null ? createAttributeNS.id : 0,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMAttr(result) : null;
+    //  }
+
+    //  public DOMAttr createAttributeNS_qualifiedName_(NSString namespaceURI, NSString qualifiedName) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createAttributeNS_1qualifiedName_1, namespaceURI !is null ? namespaceURI.id : 0, qualifiedName !is null ? qualifiedName.id : 0);
+    //      return result !is 0 ? new DOMAttr(result) : null;
+    //  }
+
+    //  public DOMCDATASection createCDATASection(NSString data) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createCDATASection_1, data !is null ? data.id : 0);
+    //      return result !is 0 ? new DOMCDATASection(result) : null;
+    //  }
+
+    //  public DOMCSSStyleDeclaration createCSSStyleDeclaration() {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createCSSStyleDeclaration);
+    //      return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+    //  }
+
+    //  public DOMComment createComment(NSString data) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createComment_1, data !is null ? data.id : 0);
+    //      return result !is 0 ? new DOMComment(result) : null;
+    //  }
+
+    //  public DOMDocumentFragment createDocumentFragment() {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createDocumentFragment);
+    //      return result !is 0 ? new DOMDocumentFragment(result) : null;
+    //  }
+
+    //  public DOMElement createElement(NSString tagName) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createElement_1, tagName !is null ? tagName.id : 0);
+    //      return result !is 0 ? new DOMElement(result) : null;
+    //  }
+
+    //  public DOMElement createElementNS__(NSString createElementNS, NSString ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createElementNS_1_1, createElementNS !is null ? createElementNS.id : 0,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMElement(result) : null;
+    //  }
+
+    //  public DOMElement createElementNS_qualifiedName_(NSString namespaceURI, NSString qualifiedName) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createElementNS_1qualifiedName_1, namespaceURI !is null ? namespaceURI.id : 0, qualifiedName !is null ? qualifiedName.id : 0);
+    //      return result !is 0 ? new DOMElement(result) : null;
+    //  }
+
+    //  public DOMEntityReference createEntityReference(NSString name) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createEntityReference_1, name !is null ? name.id : 0);
+    //      return result !is 0 ? new DOMEntityReference(result) : null;
+    //  }
+
+    //  public DOMEvent createEvent(NSString eventType) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createEvent_1, eventType !is null ? eventType.id : 0);
+    //      return result !is 0 ? new DOMEvent(result) : null;
+    //  }
+
+    //  public DOMXPathExpression createExpression__(NSString createExpression, id  ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createExpression_1_1, createExpression !is null ? createExpression.id : 0,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMXPathExpression(result) : null;
+    //  }
+
+    //  public DOMXPathExpression createExpression_resolver_(NSString expression, id  resolver) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createExpression_1resolver_1, expression !is null ? expression.id : 0, resolver !is null ? resolver.id : 0);
+    //      return result !is 0 ? new DOMXPathExpression(result) : null;
+    //  }
+
+    //  public id  createNSResolver(DOMNode nodeResolver) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createNSResolver_1, nodeResolver !is null ? nodeResolver.id : 0);
+    //      return result !is 0 ? new id (result) : null;
+    //  }
+
+    //  public DOMNodeIterator createNodeIterator____(DOMNode createNodeIterator, int , id  , bool ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createNodeIterator_1_1_1_1, createNodeIterator !is null ? createNodeIterator.id : 0, ,  !is null ? .id : 0, );
+    //      return result !is 0 ? new DOMNodeIterator(result) : null;
+    //  }
+
+    //  public DOMNodeIterator createNodeIterator_whatToShow_filter_expandEntityReferences_(DOMNode root, int whatToShow, id  filter, bool expandEntityReferences) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createNodeIterator_1whatToShow_1filter_1expandEntityReferences_1, root !is null ? root.id : 0, whatToShow, filter !is null ? filter.id : 0, expandEntityReferences);
+    //      return result !is 0 ? new DOMNodeIterator(result) : null;
+    //  }
+
+    //  public DOMProcessingInstruction createProcessingInstruction__(NSString createProcessingInstruction, NSString ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createProcessingInstruction_1_1, createProcessingInstruction !is null ? createProcessingInstruction.id : 0,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMProcessingInstruction(result) : null;
+    //  }
+
+    //  public DOMProcessingInstruction createProcessingInstruction_data_(NSString target, NSString data) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createProcessingInstruction_1data_1, target !is null ? target.id : 0, data !is null ? data.id : 0);
+    //      return result !is 0 ? new DOMProcessingInstruction(result) : null;
+    //  }
+
+    //  public DOMRange createRange() {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createRange);
+    //      return result !is 0 ? new DOMRange(result) : null;
+    //  }
+
+    //  public DOMText createTextNode(NSString data) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createTextNode_1, data !is null ? data.id : 0);
+    //      return result !is 0 ? new DOMText(result) : null;
+    //  }
+
+    //  public DOMTreeWalker createTreeWalker____(DOMNode createTreeWalker, int , id  , bool ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createTreeWalker_1_1_1_1, createTreeWalker !is null ? createTreeWalker.id : 0, ,  !is null ? .id : 0, );
+    //      return result !is 0 ? new DOMTreeWalker(result) : null;
+    //  }
+
+    //  public DOMTreeWalker createTreeWalker_whatToShow_filter_expandEntityReferences_(DOMNode root, int whatToShow, id  filter, bool expandEntityReferences) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_createTreeWalker_1whatToShow_1filter_1expandEntityReferences_1, root !is null ? root.id : 0, whatToShow, filter !is null ? filter.id : 0, expandEntityReferences);
+    //      return result !is 0 ? new DOMTreeWalker(result) : null;
+    //  }
+
+    //  public DOMXPathResult evaluate_____(NSString evaluate, DOMNode , id  , short , DOMXPathResult ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_evaluate_1_1_1_1_1, evaluate !is null ? evaluate.id : 0,  !is null ? .id : 0,  !is null ? .id : 0, ,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMXPathResult(result) : null;
+    //  }
+
+    //  public DOMXPathResult evaluate_contextNode_resolver_type_inResult_(NSString expression, DOMNode contextNode, id  resolver, short type, DOMXPathResult inResult) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_evaluate_1contextNode_1resolver_1type_1inResult_1, expression !is null ? expression.id : 0, contextNode !is null ? contextNode.id : 0, resolver !is null ? resolver.id : 0, type, inResult !is null ? inResult.id : 0);
+    //      return result !is 0 ? new DOMXPathResult(result) : null;
+    //  }
+
+    //  public DOMCSSStyleDeclaration getComputedStyle__(DOMElement getComputedStyle, NSString ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getComputedStyle_1_1, getComputedStyle !is null ? getComputedStyle.id : 0,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+    //  }
+
+    //  public DOMCSSStyleDeclaration getComputedStyle_pseudoElement_(DOMElement element, NSString pseudoElement) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getComputedStyle_1pseudoElement_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0);
+    //      return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+    //  }
+
+    //  public DOMElement getElementById(NSString elementId) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getElementById_1, elementId !is null ? elementId.id : 0);
+    //      return result !is 0 ? new DOMElement(result) : null;
+    //  }
+
+    //  public DOMNodeList getElementsByTagName(NSString tagname) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getElementsByTagName_1, tagname !is null ? tagname.id : 0);
+    //      return result !is 0 ? new DOMNodeList(result) : null;
+    //  }
+
+    //  public DOMNodeList getElementsByTagNameNS__(NSString getElementsByTagNameNS, NSString ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getElementsByTagNameNS_1_1, getElementsByTagNameNS !is null ? getElementsByTagNameNS.id : 0,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMNodeList(result) : null;
+    //  }
+
+    //  public DOMNodeList getElementsByTagNameNS_localName_(NSString namespaceURI, NSString localName) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getElementsByTagNameNS_1localName_1, namespaceURI !is null ? namespaceURI.id : 0, localName !is null ? localName.id : 0);
+    //      return result !is 0 ? new DOMNodeList(result) : null;
+    //  }
+
+    //  public DOMCSSRuleList getMatchedCSSRules_pseudoElement_(DOMElement element, NSString pseudoElement) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getMatchedCSSRules_1pseudoElement_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0);
+    //      return result !is 0 ? new DOMCSSRuleList(result) : null;
+    //  }
+
+    //  public DOMCSSRuleList getMatchedCSSRules_pseudoElement_authorOnly_(DOMElement element, NSString pseudoElement, bool authorOnly) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getMatchedCSSRules_1pseudoElement_1authorOnly_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0, authorOnly);
+    //      return result !is 0 ? new DOMCSSRuleList(result) : null;
+    //  }
+
+    //  public DOMCSSStyleDeclaration getOverrideStyle__(DOMElement getOverrideStyle, NSString ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getOverrideStyle_1_1, getOverrideStyle !is null ? getOverrideStyle.id : 0,  !is null ? .id : 0);
+    //      return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+    //  }
+
+    //  public DOMCSSStyleDeclaration getOverrideStyle_pseudoElement_(DOMElement element, NSString pseudoElement) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_getOverrideStyle_1pseudoElement_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0);
+    //      return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+    //  }
+
+    //  public DOMNode importNode__(DOMNode importNode, bool ) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_importNode_1_1, importNode !is null ? importNode.id : 0, );
+    //      return result !is 0 ? new DOMNode(result) : null;
+    //  }
+
+    //  public DOMNode importNode_deep_(DOMNode importedNode, bool deep) {
+    //      int result = OS.objc_msgSend(this.id, OS.sel_importNode_1deep_1, importedNode !is null ? importedNode.id : 0, deep);
+    //      return result !is 0 ? new DOMNode(result) : null;
+    //  }
+
+    public WebFrame webFrame () {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_webFrame);
+        return result !is null ? new WebFrame(result) : null;
+    }
+
+    /* DOMEventTarget */
+
+    public void addEventListener_listener_useCapture (NSString type, id listener, bool useCapture) {
+        OS.objc_msgSend(this.id, OS.sel_addEventListener_1listener_1useCapture_1, type !is null ? type.id : null,
+                listener !is null ? listener.id : null, useCapture);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/DOMEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.DOMEvent;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.objc : id;
+
+public class DOMEvent : NSObject {
+
+    public this () {
+        super();
+    }
+
+    public this (objc.id id) {
+        super(id);
+    }
+
+    public bool bubbles () {
+        return OS.objc_msgSend(this.id, OS.sel_bubbles) !is null;
+    }
+
+    public bool cancelable () {
+        return OS.objc_msgSend(this.id, OS.sel_cancelable) !is null;
+    }
+
+    public id currentTarget () {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentTarget);
+        return result !is null ? new id(result) : null;
+    }
+
+    public short eventPhase () {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_eventPhase);
+    }
+
+    public void initEvent___ (NSString initEvent, bool canBubbleArg, bool cancelableArg) {
+        OS.objc_msgSend(this.id, OS.sel_initEvent_1_1_1, initEvent !is null ? initEvent.id : null, canBubbleArg, cancelableArg);
+    }
+
+    public void initEvent_canBubbleArg_cancelableArg_ (NSString eventTypeArg, bool canBubbleArg, bool cancelableArg) {
+        OS.objc_msgSend(this.id, OS.sel_initEvent_1canBubbleArg_1cancelableArg_1, eventTypeArg !is null ? eventTypeArg.id : null, canBubbleArg,
+                cancelableArg);
+    }
+
+    public void preventDefault () {
+        OS.objc_msgSend(this.id, OS.sel_preventDefault);
+    }
+
+    public void stopPropagation () {
+        OS.objc_msgSend(this.id, OS.sel_stopPropagation);
+    }
+
+    public id target () {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+    public long timeStamp () {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_timeStamp);
+    }
+
+    public NSString type () {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_type);
+        return result !is null ? new NSString(result) : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/DOMKeyboardEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.DOMKeyboardEvent;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+
+public class DOMKeyboardEvent : NSObject {
+
+    public this () {
+        super();
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public bool altKey () {
+        return OS.objc_msgSend(this.id, OS.sel_altKey) !is 0;
+    }
+
+    public int charCode () {
+        return OS.objc_msgSend(this.id, OS.sel_charCode);
+    }
+
+    public bool ctrlKey () {
+        return OS.objc_msgSend(this.id, OS.sel_ctrlKey) !is 0;
+    }
+
+    public bool getModifierState (NSString keyIdentifierArg) {
+        return OS.objc_msgSend(this.id, OS.sel_getModifierState_1, keyIdentifierArg !is null ? keyIdentifierArg.id : 0) !is 0;
+    }
+
+    public int keyCode () {
+        return OS.objc_msgSend(this.id, OS.sel_keyCode);
+    }
+
+    public int keyLocation () {
+        return OS.objc_msgSend(this.id, OS.sel_keyLocation);
+    }
+
+    public bool metaKey () {
+        return OS.objc_msgSend(this.id, OS.sel_metaKey) !is 0;
+    }
+
+    public void preventDefault () {
+        OS.objc_msgSend(this.id, OS.sel_preventDefault);
+    }
+
+    public bool shiftKey () {
+        return OS.objc_msgSend(this.id, OS.sel_shiftKey) !is 0;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/DOMMouseEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.DOMMouseEvent;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSObject;
+
+public class DOMMouseEvent : NSObject {
+
+    public this () {
+        super();
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public bool altKey () {
+        return OS.objc_msgSend(this.id, OS.sel_altKey) !is 0;
+    }
+
+    public short button () {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_button);
+    }
+
+    public int clientX () {
+        return OS.objc_msgSend(this.id, OS.sel_clientX);
+    }
+
+    public int clientY () {
+        return OS.objc_msgSend(this.id, OS.sel_clientY);
+    }
+
+    public bool ctrlKey () {
+        return OS.objc_msgSend(this.id, OS.sel_ctrlKey) !is 0;
+    }
+
+    public int detail () {
+        return OS.objc_msgSend(this.id, OS.sel_detail);
+    }
+
+    //public void initMouseEvent_______________(NSString initMouseEvent, bool canBubble, bool cancelable, DOMAbstractView view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, short button, id relatedTarget) {
+    //  OS.objc_msgSend(this.id, OS.sel_initMouseEvent_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1, initMouseEvent !is null ? initMouseEvent.id : 0, canBubble, cancelable, view !is null ? view.id : 0, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget !is null ? relatedTarget.id : 0);
+    //}
+
+    //public void initMouseEvent_canBubble_cancelable_view_detail_screenX_screenY_clientX_clientY_ctrlKey_altKey_shiftKey_metaKey_button_relatedTarget_(NSString type, bool canBubble, bool cancelable, DOMAbstractView view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, short button, id  relatedTarget) {
+    //  OS.objc_msgSend(this.id, OS.sel_initMouseEvent_1canBubble_1cancelable_1view_1detail_1screenX_1screenY_1clientX_1clientY_1ctrlKey_1altKey_1shiftKey_1metaKey_1button_1relatedTarget_1, type !is null ? type.id : 0, canBubble, cancelable, view !is null ? view.id : 0, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget !is null ? relatedTarget.id : 0);
+    //}
+
+    public bool metaKey () {
+        return OS.objc_msgSend(this.id, OS.sel_metaKey) !is 0;
+    }
+
+    public id relatedTarget () {
+        int result = OS.objc_msgSend(this.id, OS.sel_relatedTarget);
+        return result !is 0 ? new id(result) : null;
+    }
+
+    public int screenX () {
+        return OS.objc_msgSend(this.id, OS.sel_screenX);
+    }
+
+    public int screenY () {
+        return OS.objc_msgSend(this.id, OS.sel_screenY);
+    }
+
+    public bool shiftKey () {
+        return OS.objc_msgSend(this.id, OS.sel_shiftKey) !is 0;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/DOMWheelEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.DOMWheelEvent;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSObject;
+
+public class DOMWheelEvent : NSObject {
+
+    public this () {
+        super();
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public bool altKey () {
+        return OS.objc_msgSend(this.id, OS.sel_altKey) !is 0;
+    }
+
+    public int clientX () {
+        return OS.objc_msgSend(this.id, OS.sel_clientX);
+    }
+
+    public int clientY () {
+        return OS.objc_msgSend(this.id, OS.sel_clientY);
+    }
+
+    public bool ctrlKey () {
+        return OS.objc_msgSend(this.id, OS.sel_ctrlKey) !is 0;
+    }
+
+    public bool isHorizontal () {
+        return OS.objc_msgSend(this.id, OS.sel_isHorizontal) !is 0;
+    }
+
+    public bool metaKey () {
+        return OS.objc_msgSend(this.id, OS.sel_metaKey) !is 0;
+    }
+
+    public int screenX () {
+        return OS.objc_msgSend(this.id, OS.sel_screenX);
+    }
+
+    public int screenY () {
+        return OS.objc_msgSend(this.id, OS.sel_screenY);
+    }
+
+    public bool shiftKey () {
+        return OS.objc_msgSend(this.id, OS.sel_shiftKey) !is 0;
+    }
+
+    public int wheelDelta () {
+        return OS.objc_msgSend(this.id, OS.sel_wheelDelta);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/IconRef.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,11 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 27, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.IconRef;
+
+alias void* OpaqueIconRef;
+alias OpaqueIconRef* IconRef;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/MacGenerator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,839 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.MacGenerator;
+
+import tango.text.xml.Document;
+
+import dwt.dwthelper.BufferedOutputStream;
+import dwt.dwthelper.FileOutputStream;
+/*import dwt.dwthelper.PrintStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import com.sun.org.apache.xerces.internal.parsers.DOMParser;
+import org.w3c.dom.*;*/
+
+import dwt.dwthelper.utils;
+
+public class MacGenerator {
+    String[] classes;
+    String xml[];
+    String outputDir;
+    
+    //PrintStream output;
+    
+public this(String[] xml) 
+{
+    this.xml = xml; 
+}
+    
+public void print (String str) {
+    /*PrintStream output = this.output;
+    if (output is null) output = System.out;
+    output.print(str);*/
+}
+
+public void println() {
+    /*PrintStream output = this.output;
+    if (output is null) output = System.out;
+    output.println();*/
+}
+
+public void generateConstants()  
+{
+    foreach (str ; xml)
+    {
+        Document document = new Document!(char);
+        document.parse(str);
+        
+        foreach (node ; document.root.children)
+        {
+            if ("constant" == node.name)
+            {
+                Node attribute;
+                
+                print("public static final native int ");
+                
+                foreach (a ; node.attributes)
+                    if (a.name == "name")
+                    {
+                        attribute = a;
+                        break;
+                    }
+                
+                print(attribute.value);
+                print("();");
+                println;
+            }
+        }
+    }
+}
+
+public void generateConstantsMetaData() 
+{
+    foreach (str ; xml)
+    {
+        Document document = new Document!(char);
+        document.parse(str);
+        
+        foreach (node ; document.root.children)
+        {
+            if ("constant" == node.name)
+            {
+                Node attribute;
+                
+                print("OS_");
+                
+                foreach (a ; node.attributes)
+                    if (a.name == "name")
+                    {
+                        attribute = a;
+                        break;
+                    }
+                
+                print(attribute.value);
+                print("=flags=const");
+                println;
+            }
+        }
+    }
+}
+
+public void generateEnums() 
+{
+    foreach (str ; xml)
+    {
+        Document document = new Document!(char);
+        document.parse(str);
+        
+        foreach (node ; document.root.children)
+        {
+            if ("enum" == node.name)
+            {
+                Node attributeName = null;
+                Node attributeValue = null;
+                
+                print("OS_");
+                
+                foreach (a ; node.attributes)
+                    if (a.name == "value")
+                    {
+                        attributeValue = a;
+                        break;
+                    }
+                
+                if (attributeValue !is null)
+                {
+                    print("public static final ");
+                    
+                    if (attributeValue.value.indexOf('.') !is -1)
+                        print("double ");
+                    
+                    else
+                        print("int ");
+                }
+                
+                foreach (a ; node.attributes)
+                    if (a.name == "name")
+                    {
+                        attributeName = a;
+                        break;
+                    }
+                
+                print(attributeName.value);
+                print(" = ");
+                print(attributeValue.value);
+                print(";");
+                println;
+            }
+        }
+    }
+}
+
+bool isStruct(Node node)
+{
+    String code;
+    
+    foreach (a ; node.attributes)
+        if(a.name == "type")
+        {
+            code = a.value;
+            break;
+        }
+
+    return code.startsWith("{");
+}
+
+bool isFloatingPoint(Node node) {
+    NamedNodeMap attributes = node.getAttributes();
+    String code = attributes.getNamedItem("type").getNodeValue();
+    return code.opEquals("f") || code.opEquals("d");
+}
+
+bool isObject(Node node) {
+    NamedNodeMap attributes = node.getAttributes();
+    String code = attributes.getNamedItem("type").getNodeValue();
+    return code.opEquals("@");
+}
+
+bool isBoolean(Node node) {
+    NamedNodeMap attributes = node.getAttributes();
+    String code = attributes.getNamedItem("type").getNodeValue();
+    return code.opEquals("B");
+}
+
+bool getGenerateClass(String className) {
+    if (classes !is null) {
+        for (int i = 0; i < classes.length; i++) {
+            if (className.opEquals(classes[i])) return true;
+        }
+        return false;
+    }
+    return true;
+}
+
+public bool isUnique(Node method, NodeList methods) {
+    String methodName = method.getAttributes().getNamedItem("selector").getNodeValue();
+    int index = methodName.indexOf(":");
+    if (index !is -1) methodName = methodName.substring(0, index);
+    for (int j = 0; j < methods.getLength(); j++) {
+        Node other = methods.item(j);
+        NamedNodeMap attributes = other.getAttributes();
+        Node otherSel = null;
+        if (attributes !is null) otherSel = attributes.getNamedItem("selector");
+        if (other !is method && otherSel !is null) {
+            String otherName = otherSel.getNodeValue();
+            index = otherName.indexOf(":");
+            if (index !is -1) otherName = otherName.substring(0, index);
+            if (methodName.opEquals(otherName)) {
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+public void generateClasses() {
+    for (int x = 0; x < xml.length; x++) {
+        DOMParser parser = new DOMParser();
+        parser.parse(xml[x]);
+        Document document = parser.getDocument();
+        NodeList list = document.getDocumentElement().getChildNodes();
+        for (int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            if ("class".opEquals(node.getLocalName())) {
+                NamedNodeMap attributes = node.getAttributes();
+                String name = attributes.getNamedItem("name").getNodeValue();
+                if (getGenerateClass(name)) {
+                    if (outputDir !is null) {
+                        FileOutputStream  is = new FileOutputStream(outputDir + "/" + name + ".java");
+                        out = new PrintStream(new BufferedOutputStream(is));
+                    }
+                    out("module dwt.internal.cocoa;");
+                    outln();
+                    outln();
+                    out("public class ");
+                    out(name);
+                    if (name.opEquals("NSObject")) {
+                        out(" : id {");
+                    } else {
+                        out(" : NSObject {");
+                    }
+                    outln();
+                    outln();
+                    out("public ");
+                    out(name);
+                    out("() {");
+                    outln();
+                    out("\tsuper();");
+                    outln();
+                    out("}");
+                    outln();
+                    outln();
+                    out("public ");
+                    out(name);
+                    out("(int id) {");
+                    outln();
+                    out("\tsuper(id);");
+                    outln();
+                    out("}");
+                    outln();
+                    outln();
+                    NodeList methods = node.getChildNodes();
+                    for (int j = 0; j < methods.getLength(); j++) {
+                        Node method = methods.item(j);
+                        if ("method".opEquals(method.getLocalName())) {
+                            String sel = method.getAttributes().getNamedItem("selector").getNodeValue();
+                            out("public ");
+                            bool isStatic = method.getAttributes().getNamedItem("class_method") !is null; 
+                            if (isStatic) out("static ");
+                            Node returnNode = getReturnNode(method.getChildNodes());
+                            if (getType(returnNode).opEquals("void")) returnNode = null;
+                            if (returnNode !is null) {
+                                out(getJavaType(returnNode));
+                                out(" ");
+                            } else {
+                                out("void ");
+                            }
+                            String methodName = sel;
+                            if (isUnique(method, methods)) {
+                                int index = methodName.indexOf(":");
+                                if (index !is -1) methodName = methodName.substring(0, index);
+                            } else {
+                                methodName = methodName.replaceAll(":", "_");
+                                if (isStatic) methodName = "static_" + methodName;
+                            }
+                            out(methodName);
+                            out("(");
+                            NodeList params = method.getChildNodes();
+                            bool first = true;
+                            for (int k = 0; k < params.getLength(); k++) {
+                                Node param = params.item(k);
+                                if ("arg".opEquals(param.getLocalName())) {
+                                    NamedNodeMap paramAttributes = param.getAttributes();
+                                    if (!first) out(", ");
+                                    out(getJavaType(param));
+                                    first = false;
+                                    out(" ");
+                                    String paramName = paramAttributes.getNamedItem("name").getNodeValue();
+                                    if (paramName.opEquals("bool")) paramName = "b";
+                                    out(paramName);
+                                }
+                            }
+                            out(") {");
+                            outln();
+                            if (returnNode !is null && isStruct(returnNode)) {
+                                String type = getJavaType(returnNode);
+                                out("\t");
+                                out(type);
+                                out(" result = new ");
+                                out(type);
+                                out("();");
+                                outln();
+                                out("\tOS.objc_msgSend_stret(result, ");
+                            } else if (returnNode !is null && isFloatingPoint(returnNode)) {
+                                String type = getJavaType(returnNode);
+                                out("\treturn ");
+                                if (type.opEquals("float")) out("(float)");
+                                out("OS.objc_msgSend_fpret(");
+                            } else if (returnNode !is null && isObject(returnNode)) {
+                                out("\tint result = OS.objc_msgSend(");
+                            } else {
+                                if (returnNode !is null) {
+                                    out("\treturn ");
+                                    String type = getJavaType(returnNode);
+                                    if (!(type.opEquals("int") || type.opEquals("bool"))) {
+                                        out("(");
+                                        out(type);
+                                        out(")");
+                                    }
+                                } else {
+                                    out("\t");
+                                }
+                                out("OS.objc_msgSend(");
+                            }
+                            if (isStatic) {
+                                out("OS.class_");
+                                out(name);
+                            } else {
+                                out("this.id");
+                            }
+                            out(", OS.");
+                            out(getSelConst(sel));
+                            first = false;
+                            for (int k = 0; k < params.getLength(); k++) {
+                                Node param = params.item(k);
+                                if ("arg".opEquals(param.getLocalName())) {
+                                    NamedNodeMap paramAttributes = param.getAttributes();
+                                    if (!first) out(", ");
+                                    first = false;
+                                    String paramName = paramAttributes.getNamedItem("name").getNodeValue();
+                                    if (paramName.opEquals("bool")) paramName = "b";
+                                    if (isObject(param)) {
+                                        out(paramName);
+                                        out(" !is null ? ");
+                                        out(paramName);
+                                        out(".id : 0");
+                                    } else {
+                                        out(paramName);
+                                    }
+                                }
+                            }
+                            out(")");
+                            if (returnNode !is null && isBoolean(returnNode)) {
+                                out(" !is 0");
+                            }
+                            out(";");
+                            outln();
+                            if (returnNode !is null && isObject(returnNode)) {
+                                if (!isStatic && getJavaType(returnNode).opEquals(name)) {
+                                    out("\treturn result is this.id ? this : (result !is 0 ? new ");
+                                    out(getJavaType(returnNode));
+                                    out("(result) : null);");
+                                } else {
+                                    out("\treturn result !is 0 ? new ");
+                                    out(getJavaType(returnNode));
+                                    out("(result) : null;");
+                                }
+                                outln();
+                            } else if (returnNode !is null && isStruct(returnNode)) {
+                                out("\treturn result;");
+                                outln();
+                            }
+                            out("}");
+                            outln();
+                            outln();
+                        }                   
+                    }               
+                    out("}");
+                    outln();
+                    if (outputDir !is null) {
+                        out.close();
+                        out = null;
+                    }
+                }
+            }
+        }
+    }
+}
+
+public void generateSelectorsConst() {
+    HashSet set = new HashSet();
+    for (int x = 0; x < xml.length; x++) {
+        DOMParser parser = new DOMParser();
+        parser.parse(xml[x]);
+        Document document = parser.getDocument();
+        NodeList list = document.getDocumentElement().getChildNodes();
+        for (int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            if ("class".opEquals(node.getLocalName())) {
+                NamedNodeMap attributes = node.getAttributes();
+                String name = attributes.getNamedItem("name").getNodeValue();
+                if (getGenerateClass(name)) {
+                    NodeList methods = node.getChildNodes();
+                    for (int j = 0; j < methods.getLength(); j++) {
+                        Node method = methods.item(j);
+                        if ("method".opEquals(method.getLocalName())) {
+                            String sel = method.getAttributes().getNamedItem("selector").getNodeValue();
+                            set.add(sel);
+                        }
+                    }
+                }
+            }
+        }
+    }
+    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+        String sel = (String) iterator.next();
+        String selConst = getSelConst(sel);
+        out("public static final int ");
+        out(selConst);
+        out(" = ");
+        out("sel_registerName(\"");
+        out(sel);
+        out("\");");
+        outln();
+    }
+}
+
+public void generateSends() {
+    HashSet set = new HashSet();
+    for (int x = 0; x < xml.length; x++) {
+        DOMParser parser = new DOMParser();
+        parser.parse(xml[x]);
+        Document document = parser.getDocument();
+        NodeList list = document.getDocumentElement().getChildNodes();
+        for (int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            if ("class".opEquals(node.getLocalName())) {
+                NamedNodeMap attributes = node.getAttributes();
+                String name = attributes.getNamedItem("name").getNodeValue();
+                if (getGenerateClass(name)) {
+                    NodeList methods = node.getChildNodes();
+                    for (int j = 0; j < methods.getLength(); j++) {
+                        Node method = methods.item(j);
+                        if ("method".opEquals(method.getLocalName())) {
+                            Node returnNode = getReturnNode(method.getChildNodes());
+                            StringBuffer buffer = new StringBuffer();
+                            buffer.append("public static final native "); 
+                            if (returnNode !is null && isStruct(returnNode)) {
+                                buffer.append("void objc_msgSend_stret(");
+                                buffer.append(getJavaType(returnNode));
+                                buffer.append(" result, ");
+                            } else if (returnNode !is null && isFloatingPoint(returnNode)) {
+                                buffer.append("double objc_msgSend_fpret(");
+                            } else {
+                                buffer.append("int objc_msgSend(");
+                            }
+                            buffer.append("int id, int sel");
+                            NodeList params = method.getChildNodes();
+                            bool first = false;
+                            int count = 0;
+                            for (int k = 0; k < params.getLength(); k++) {
+                                Node param = params.item(k);
+                                if ("arg".opEquals(param.getLocalName())) {
+                                    if (!first) buffer.append(", ");
+                                    if (isStruct(param)) {
+                                        buffer.append(getJavaType(param));
+                                    } else {
+                                        buffer.append(getType(param));
+                                    }
+                                    first = false;
+                                    buffer.append(" arg");
+                                    buffer.append(String.valueOf(count++));
+                                }
+                            }
+                            buffer.append(");");
+                            set.add(buffer.toString());
+                        }
+                    }
+                }
+            }
+        }
+    }
+    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+        out(iterator.next().toString());
+        outln();
+    }
+}
+
+public void generateSendsMetaData() {
+    HashMap set = new HashMap();
+    for (int x = 0; x < xml.length; x++) {
+        DOMParser parser = new DOMParser();
+        parser.parse(xml[x]);
+        Document document = parser.getDocument();
+        NodeList list = document.getDocumentElement().getChildNodes();
+        for (int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            if ("class".opEquals(node.getLocalName())) {
+                NamedNodeMap attributes = node.getAttributes();
+                String name = attributes.getNamedItem("name").getNodeValue();
+                if (getGenerateClass(name)) {
+                    NodeList methods = node.getChildNodes();
+                    for (int j = 0; j < methods.getLength(); j++) {
+                        Node method = methods.item(j);
+                        if ("method".opEquals(method.getLocalName())) {
+                            Node returnNode = getReturnNode(method.getChildNodes());
+                            StringBuffer buffer = new StringBuffer();
+                            if (returnNode !is null && isStruct(returnNode)) {
+                                buffer.append("OS_objc_1msgSend_1stret__");
+                                buffer.append("Lorg_eclipse_swt_internal_cocoa_");
+                                buffer.append(getJavaType(returnNode));
+                                buffer.append("_2");
+                            } else if (returnNode !is null && isFloatingPoint(returnNode)) {
+                                buffer.append("OS_objc_1msgSend_1fpret__");
+                            } else {
+                                buffer.append("OS_objc_1msgSend__");
+                            }
+                            buffer.append("II");
+                            NodeList params = method.getChildNodes();
+                            for (int k = 0; k < params.getLength(); k++) {
+                                Node param = params.item(k);
+                                if ("arg".opEquals(param.getLocalName())) {
+                                    if (isStruct(param)) {
+                                        buffer.append("Lorg_eclipse_swt_internal_cocoa_");
+                                        buffer.append(getJavaType(param));
+                                        buffer.append("_2");
+                                    } else {
+                                        buffer.append(getJNIType(param));
+                                    }
+                                }
+                            }
+                            String key = buffer.toString();
+                            if (set.get(key) is null) set.put(key, method);
+                        }
+                    }
+                }
+            }
+        }
+    }
+    for (Iterator iterator = set.keySet().iterator(); iterator.hasNext();) {
+        String key = iterator.next().toString();
+        out(key);
+        out("=flags=cast");
+        outln();
+        int count = 2;
+        if (key.indexOf("stret") !is -1) {
+            count = 3;
+            out(key);
+            out("_0=");
+            outln();
+            out(key);
+            out("_1=cast=(id)");
+            outln();
+            out(key);
+            out("_2=cast=(SEL)");
+            outln();
+        } else {
+            out(key);
+            out("_0=cast=(id)");
+            outln();
+            out(key);
+            out("_1=cast=(SEL)");
+            outln();
+        }
+        Node method = (Node)set.get(key);
+        NodeList params = method.getChildNodes();
+        for (int k = 0; k < params.getLength(); k++) {
+            Node param = params.item(k);
+            if ("arg".opEquals(param.getLocalName())) {
+                out(key);
+                out("_");
+                out(String.valueOf(count));
+                out("=");
+                if (isStruct(param)) {
+                    out("flags=struct");
+                }
+                outln();
+                count++;
+            }
+        }
+        outln();
+    }
+}
+
+
+String getSelConst(String sel) {
+    return "sel_" + sel.replaceAll(":", "_1");
+}
+
+public void generateClassesConst() {
+    HashSet set = new HashSet();
+    for (int x = 0; x < xml.length; x++) {
+        DOMParser parser = new DOMParser();
+        parser.parse(xml[x]);
+        Document document = parser.getDocument();
+        NodeList list = document.getDocumentElement().getChildNodes();
+        for (int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            if ("class".opEquals(node.getLocalName())) {
+                NamedNodeMap attributes = node.getAttributes();
+                String name = attributes.getNamedItem("name").getNodeValue();
+                if (getGenerateClass(name)) {
+                    set.add(name);
+                }
+            }
+        }
+    }
+    for (Iterator iterator = set.iterator(); iterator.hasNext();) {
+        String cls = (String) iterator.next();
+        String clsConst = "class_" + cls;
+        out("public static final int ");
+        out(clsConst);
+        out(" = ");
+        out("objc_getClass(\"");
+        out(cls);
+        out("\");");
+        outln();
+    }
+}
+
+Node getReturnNode(NodeList list) {
+    for (int j = 0; j < list.getLength(); j++) {
+        Node node = list.item(j);
+        if ("retval".opEquals(node.getLocalName())) {
+            return node;
+        }
+    }
+    return null;
+}
+
+String getType(Node node) {
+    NamedNodeMap attributes = node.getAttributes();
+    String code = attributes.getNamedItem("type").getNodeValue();
+    if (code.opEquals("c")) return "byte";
+    if (code.opEquals("i")) return "int";
+    if (code.opEquals("s")) return "short";
+    if (code.opEquals("l")) return "int";
+    if (code.opEquals("q")) return "long";
+    if (code.opEquals("C")) return "byte";
+    if (code.opEquals("I")) return "int";
+    if (code.opEquals("S")) return "short";
+    if (code.opEquals("L")) return "int";
+    if (code.opEquals("Q")) return "long";
+    if (code.opEquals("f")) return "float";
+    if (code.opEquals("d")) return "double";
+    if (code.opEquals("B")) return "bool";
+    if (code.opEquals("v")) return "void";
+    if (code.opEquals("*")) return "int";
+    if (code.opEquals("@")) return "int";
+    if (code.opEquals("#")) return "int";
+    if (code.opEquals(":")) return "int";
+    if (code.startsWith("^")) return "int";
+    if (code.startsWith("[")) return "BAD " + code;
+    if (code.startsWith("{")) {     
+        return attributes.getNamedItem("declared_type").getNodeValue();
+    }
+    if (code.startsWith("(")) return "BAD " + code;
+    return "BAD " + code;
+}
+String getJNIType(Node node) {
+    NamedNodeMap attributes = node.getAttributes();
+    String code = attributes.getNamedItem("type").getNodeValue();
+    if (code.opEquals("c")) return "B";
+    if (code.opEquals("i")) return "I";
+    if (code.opEquals("s")) return "S";
+    if (code.opEquals("l")) return "I";
+    if (code.opEquals("q")) return "J";
+    if (code.opEquals("C")) return "B";
+    if (code.opEquals("I")) return "I";
+    if (code.opEquals("S")) return "S";
+    if (code.opEquals("L")) return "I";
+    if (code.opEquals("Q")) return "J";
+    if (code.opEquals("f")) return "F";
+    if (code.opEquals("d")) return "D";
+    if (code.opEquals("B")) return "Z";
+    if (code.opEquals("v")) return "V";
+    if (code.opEquals("*")) return "I";
+    if (code.opEquals("@")) return "I";
+    if (code.opEquals("#")) return "I";
+    if (code.opEquals(":")) return "I";
+    if (code.startsWith("^")) return "I";
+    if (code.startsWith("[")) return "BAD " + code;
+    if (code.startsWith("{")) {     
+        return "BAD " + code;
+    }
+    if (code.startsWith("(")) return "BAD " + code;
+    return "BAD " + code;
+}
+
+String getJavaType(Node node) {
+    NamedNodeMap attributes = node.getAttributes();
+    String code = attributes.getNamedItem("type").getNodeValue();
+    if (code.opEquals("c")) return "byte";
+    if (code.opEquals("i")) return "int";
+    if (code.opEquals("s")) return "short";
+    if (code.opEquals("l")) return "int";
+    if (code.opEquals("q")) return "long";
+    if (code.opEquals("C")) return "byte";
+    if (code.opEquals("I")) return "int";
+    if (code.opEquals("S")) return "short";
+    if (code.opEquals("L")) return "int";
+    if (code.opEquals("Q")) return "long";
+    if (code.opEquals("f")) return "float";
+    if (code.opEquals("d")) return "double";
+    if (code.opEquals("B")) return "bool";
+    if (code.opEquals("v")) return "void";
+    if (code.opEquals("*")) return "int";
+    if (code.opEquals("@")) {
+        String type = attributes.getNamedItem("declared_type").getNodeValue();
+        int index = type.indexOf('*');
+        if (index !is -1) type = type.substring(0, index);
+        index = type.indexOf('<');
+        if (index !is -1) type = type.substring(0, index);
+        return type;
+    }
+    if (code.opEquals("#")) return "int";
+    if (code.opEquals(":")) return "int";
+    if (code.startsWith("^")) return "int";
+    if (code.startsWith("[")) return "BAD " + code;
+    if (code.startsWith("{")) {     
+        return attributes.getNamedItem("declared_type").getNodeValue();
+    }
+    if (code.startsWith("(")) return "BAD " + code;
+    return "BAD " + code;
+}
+
+public void generateFunctions() {
+    for (int x = 0; x < xml.length; x++) {
+        DOMParser parser = new DOMParser();
+        parser.parse(xml[x]);
+        Document document = parser.getDocument();
+        NodeList list = document.getDocumentElement().getChildNodes();
+        for (int i = 0; i < list.getLength(); i++) {
+            Node node = list.item(i);
+            if ("function".opEquals(node.getLocalName())) {
+                NamedNodeMap attributes = node.getAttributes();
+                String name = attributes.getNamedItem("name").getNodeValue();
+                out("public static final native ");
+                Node returnNode = getReturnNode(node.getChildNodes());
+                if (returnNode !is null) {
+                    out(getType(returnNode));
+                    out(" ");
+                } else {
+                    out("void ");
+                }
+                out(name);
+                out("(");
+                NodeList params = node.getChildNodes();
+                bool first = true;
+                for (int j = 0; j < params.getLength(); j++) {
+                    Node param = params.item(j);
+                    if ("arg".opEquals(param.getLocalName())) {
+                        NamedNodeMap paramAttributes = param.getAttributes();
+                        if (!first) out(", ");
+                        out(getType(param));
+                        first = false;
+                        out(" ");
+                        out(paramAttributes.getNamedItem("name").getNodeValue());
+                    }
+                }
+                out(");");
+                outln();
+            }
+        }
+    }
+}
+
+public void generateOS() {
+    out("/** Classes */");
+    outln();
+    generateClassesConst();
+    outln();
+    out("/** Selectors */");
+    outln();
+    generateSelectorsConst();
+    outln();
+    out("/** Constants */");
+    outln();
+    generateEnums();
+    outln();
+    out("/** Globals */");
+    outln();
+    generateConstants();
+    outln();
+    out("/** Functions */");
+    outln();
+    generateFunctions();
+    outln();
+    out("/** Sends */");
+    outln();
+    generateSends();
+}
+
+public void generateMetadata() {
+    generateConstantsMetaData();
+    generateSendsMetaData();
+}
+
+public void setClasses(String[] classes) {
+    this.classes = classes;
+}
+
+public void setOutputDir(String dir) {
+    this.outputDir = dir;
+}
+
+public static void main(String[] args) {
+    MacGenerator gen = new MacGenerator(args);
+//  gen.setClasses(new String[]{
+//      "NSURL",
+//  });
+    gen.setOutputDir("/Users/adclabs/Desktop/workspace/dwt/Eclipse DWT PI/cocoa/org/eclipse/swt/internal/cocoa");
+//  gen.generateOS();
+//  gen.generateMetadata();
+    gen.generateClasses();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSATSTypesetter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSATSTypesetter;
+
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSTypesetter;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSATSTypesetter : NSTypesetter
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSRect lineFragmentRectForProposedRect (NSRect proposedRect, objc.id remainingRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_lineFragmentRectForProposedRect_1remainingRect_1, proposedRect, remainingRect);
+        return result;
+    }
+
+    public static id sharedTypesetter ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSATSTypesetter, OS.sel_sharedTypesetter);
+        return result !is null ? new id(result) : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSActionCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSActionCell;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSActionCell : NSCell
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.SEL action ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_action);
+    }
+
+    public NSView controlView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_controlView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public double doubleValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+    }
+
+    public float floatValue ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatValue);
+    }
+
+    public int intValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_intValue);
+    }
+
+    public int integerValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_integerValue);
+    }
+
+    public void setAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, aSelector);
+    }
+
+    public void setAlignment (objc.id mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlignment_1, mode);
+    }
+
+    public void setBezeled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezeled_1, flag);
+    }
+
+    public void setBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBordered_1, flag);
+    }
+
+    public void setControlView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlView_1, view !is null ? view.id : null);
+    }
+
+    public void setEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, flag);
+    }
+
+    public void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloatingPointFormat_1left_1right_1, autoRange, leftDigits, rightDigits);
+    }
+
+    public void setFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setObjectValue (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectValue_1, obj !is null ? obj.id : null);
+    }
+
+    public void setTag (NSInteger anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTag_1, anInt);
+    }
+
+    public void setTarget (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, anObject !is null ? anObject.id : null);
+    }
+
+    public NSString StringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_StringValue);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger tag ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tag);
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAffineTransform.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAffineTransform;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSAffineTransformStruct;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAffineTransform : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void appendTransform (NSAffineTransform transform)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendTransform_1, transform !is null ? transform.id : null);
+    }
+
+    public NSAffineTransform initWithTransform (NSAffineTransform transform)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTransform_1, transform !is null ? transform.id : null);
+        return result !is null ? this : null;
+    }
+
+    public void invert ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invert);
+    }
+
+    public void set ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_set);
+    }
+
+    public void concat ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_concat);
+    }
+
+    public void prependTransform (NSAffineTransform transform)
+    {
+        OS.objc_msgSend(this.id, OS.sel_prependTransform_1, transform !is null ? transform.id : null);
+    }
+
+    public void rotateByDegrees (CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rotateByDegrees_1, angle);
+    }
+
+    public void rotateByRadians (CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rotateByRadians_1, angle);
+    }
+
+    public void scaleBy (CGFloat scale)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scaleBy_1, scale);
+    }
+
+    public void scaleXBy (CGFloat scaleX, CGFloat scaleY)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scaleXBy_1yBy_1, scaleX, scaleY);
+    }
+
+    public void setTransformStruct (NSAffineTransformStruct transformStruct)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTransformStruct_1, transformStruct);
+    }
+
+    public static NSAffineTransform transform ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAffineTransform, OS.sel_transform);
+        return result !is null ? new NSAffineTransform(result) : null;
+    }
+
+    public NSPoint transformPoint (NSPoint aPoint)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_transformPoint_1, aPoint);
+        return result;
+    }
+
+    public NSSize transformSize (NSSize aSize)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_transformSize_1, aSize);
+        return result;
+    }
+
+    public NSAffineTransformStruct transformStruct ()
+    {
+        NSAffineTransformStruct result = new NSAffineTransformStruct();
+        OS.objc_msgSend_stret(result, this.id, OS.sel_transformStruct);
+        return result;
+    }
+
+    public void translateXBy (CGFloat deltaX, CGFloat deltaY)
+    {
+        OS.objc_msgSend(this.id, OS.sel_translateXBy_1yBy_1, deltaX, deltaY);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAffineTransformStruct.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAffineTransformStruct;
+
+struct NSAffineTransformStruct {
+    float m11, m12, m21, m22;
+    float tX, tY;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAlert.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAlert;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSButton;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import objc = dwt.internal.objc.runtime;
+
+alias NSUInteger NSAlertStyle;
+
+public class NSAlert : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSButton addButtonWithTitle (NSString title)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addButtonWithTitle_1, title !is null ? title.id : null);
+        return result !is null  ? new NSButton(result) : null;
+    }
+
+    public NSAlertStyle alertStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_alertStyle);
+    }
+
+    public static NSAlert alertWithError (NSError error)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAlert, OS.sel_alertWithError_1, error !is null ? error.id : null);
+        return result !is null ? new NSAlert(result) : null;
+    }
+
+    public static NSAlert alertWithMessageText (NSString message, NSString defaultButton, NSString alternateButton, NSString otherButton,
+            NSString informativeTextWithFormat)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAlert,
+                OS.sel_alertWithMessageText_1defaultButton_1alternateButton_1otherButton_1informativeTextWithFormat_1,
+                message !is null ? message.id : null, defaultButton !is null ? defaultButton.id : null,
+                alternateButton !is null ? alternateButton.id : null, otherButton !is null ? otherButton.id : null,
+                informativeTextWithFormat !is null ? informativeTextWithFormat.id : null);
+        return result !is null ? new NSAlert(result) : null;
+    }
+
+    public void beginSheetModalForWindow (NSWindow window, id delegatee, objc.SEL didEndSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginSheetModalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1, window !is null ? window.id : null,
+                delegatee !is null ? delegatee.id : null, didEndSelector, contextInfo);
+    }
+
+    public NSArray buttons ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_buttons);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString helpAnchor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_helpAnchor);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSImage icon ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_icon);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSString informativeText ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_informativeText);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void layout ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_layout);
+    }
+
+    public NSString messageText ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_messageText);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger runModal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModal);
+    }
+
+    public void setAccessoryView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, view !is null ? view.id : null);
+    }
+
+    public void setAlertStyle (NSAlertStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlertStyle_1, style);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setHelpAnchor (NSString anchor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHelpAnchor_1, anchor !is null ? anchor.id : nullnull);
+    }
+
+    public void setIcon (NSImage icon)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIcon_1, icon !is null ? icon.id : null);
+    }
+
+    public void setInformativeText (NSString informativeText)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInformativeText_1, informativeText !is null ? informativeText.id : null);
+    }
+
+    public void setMessageText (NSString messageText)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMessageText_1, messageText !is null ? messageText.id : null);
+    }
+
+    public void setShowsHelp (bool showsHelp)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsHelp_1, showsHelp);
+    }
+
+    public void setShowsSuppressionButton (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsSuppressionButton_1, flag);
+    }
+
+    public bool showsHelp ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsHelp) !is null;
+    }
+
+    public bool showsSuppressionButton ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsSuppressionButton) !is null;
+    }
+
+    public NSButton suppressionButton ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_suppressionButton);
+        return result !is null ? new NSButton(result) : null;
+    }
+
+    public id window ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_window);
+        return result !is null ? new id(result) : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAnimation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAnimation;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias float NSAnimationProgress;
+alias NSUInteger NSAnimationCurve;
+alias NSUInteger NSAnimationBlockingMode;
+
+public class NSAnimation : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addProgressMark (NSAnimationProgress progressMark)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addProgressMark_1, progressMark);
+    }
+
+    public objc.id animationBlockingMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_animationBlockingMode);
+    }
+
+    public objc.id animationCurve ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_animationCurve);
+    }
+
+    public void clearStartAnimation ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_clearStartAnimation);
+    }
+
+    public void clearStopAnimation ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_clearStopAnimation);
+    }
+
+    public NSAnimationProgress currentProgress ()
+    {
+        return cast(NSAnimationProgress) OS.objc_msgSend_fpret(this.id, OS.sel_currentProgress);
+    }
+
+    public float currentValue ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_currentValue);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public double duration ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_duration);
+    }
+
+    public float frameRate ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_frameRate);
+    }
+
+    public NSAnimation initWithDuration (NSTimeInterval duration, NSAnimationCurve animationCurve)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDuration_1animationCurve_1, duration, animationCurve);
+        return result !is null ? this : null;
+    }
+
+    public bool isAnimating ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAnimating) !is null;
+    }
+
+    public NSArray progressMarks ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_progressMarks);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void removeProgressMark (NSAnimationProgress progressMark)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeProgressMark_1, progressMark);
+    }
+
+    public NSArray runLoopModesForAnimating ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_runLoopModesForAnimating);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setAnimationBlockingMode (NSAnimationBlockingMode animationBlockingMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAnimationBlockingMode_1, animationBlockingMode);
+    }
+
+    public void setAnimationCurve (NSAnimationCurve curve)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAnimationCurve_1, curve);
+    }
+
+    public void setCurrentProgress (NSAnimationProgress progress)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrentProgress_1, progress);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDuration (double duration)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDuration_1, duration);
+    }
+
+    public void setFrameRate (float framesPerSecond)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameRate_1, framesPerSecond);
+    }
+
+    public void setProgressMarks (NSArray progressMarks)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setProgressMarks_1, progressMarks !is null ? progressMarks.id : null);
+    }
+
+    public void startAnimation ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_startAnimation);
+    }
+
+    public void startWhenAnimation (NSAnimation animation, NSAnimationProgress startProgress)
+    {
+        OS.objc_msgSend(this.id, OS.sel_startWhenAnimation_1reachesProgress_1, animation !is null ? animation.id : null, startProgress);
+    }
+
+    public void stopAnimation ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopAnimation);
+    }
+
+    public void stopWhenAnimation (NSAnimation animation, NSAnimationProgress stopProgress)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopWhenAnimation_1reachesProgress_1, animation !is null ? animation.id : null, stopProgress);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAnimationContext.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAnimationContext;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAnimationContext : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static void beginGrouping ()
+    {
+        OS.objc_msgSend(OS.class_NSAnimationContext, OS.sel_beginGrouping);
+    }
+
+    public static NSAnimationContext currentContext ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAnimationContext, OS.sel_currentContext);
+        return result !is null ? new NSAnimationContext(result) : null;
+    }
+
+    public double duration ()
+    {
+        return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_duration);
+    }
+
+    public static void endGrouping ()
+    {
+        OS.objc_msgSend(OS.class_NSAnimationContext, OS.sel_endGrouping);
+    }
+
+    public void setDuration (double duration)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDuration_1, duration);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAppleEventDescriptor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAppleEventDescriptor;
+
+import dwt.internal.c.carboncore.MacTypes : FourCharCode;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import objc = dwt.internal.objc.runtime;
+
+alias FourCharCode AEKeyword;
+
+public class NSAppleEventDescriptor : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.id aeDesc ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_aeDesc);
+    }
+
+    public static NSAppleEventDescriptor appleEventWithEventClass (objc.id eventClass, objc.id eventID, NSAppleEventDescriptor targetDescriptor,
+            short returnID, objc.id transactionID)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor,
+                OS.sel_appleEventWithEventClass_1eventID_1targetDescriptor_1returnID_1transactionID_1, eventClass, eventID,
+                targetDescriptor !is null ? targetDescriptor.id : null, returnID, transactionID);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSAppleEventDescriptor attributeDescriptorForKeyword (objc.id keyword)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributeDescriptorForKeyword_1, keyword);
+        return result is this.id ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
+    }
+
+    public bool boolValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_boolValue) !is null;
+    }
+
+    public NSAppleEventDescriptor coerceToDescriptorType (objc.id descriptorType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_coerceToDescriptorType_1, descriptorType);
+        return result is this.id ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
+    }
+
+    public NSData data ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_data);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSAppleEventDescriptor descriptorAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptorAtIndex_1, index);
+        return result is this.id ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
+    }
+
+    public NSAppleEventDescriptor descriptorForKeyword (objc.id keyword)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptorForKeyword_1, keyword);
+        return result is this.id ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
+    }
+
+    public objc.id descriptorType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_descriptorType);
+    }
+
+    public static NSAppleEventDescriptor descriptorWithBoolean (bool b)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithBoolean_1, b);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public static NSAppleEventDescriptor static_descriptorWithDescriptorType_bytes_length_ (objc.id descriptorType, /*const*/void* bytes, NSUInteger byteCount)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithDescriptorType_1bytes_1length_1, descriptorType, bytes,
+                byteCount);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public static NSAppleEventDescriptor static_descriptorWithDescriptorType_data_ (objc.id descriptorType, NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithDescriptorType_1data_1, descriptorType,
+                data !is null ? data.id : 0);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public static NSAppleEventDescriptor descriptorWithEnumCode (objc.id enumerator)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithEnumCode_1, enumerator);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public static NSAppleEventDescriptor descriptorWithInt32 (int signedInt)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithInt32_1, signedInt);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public static NSAppleEventDescriptor descriptorWithString (NSString str)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithString_1, str !is null ? str.id : 0);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public static NSAppleEventDescriptor descriptorWithTypeCode (objc.id typeCode)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_descriptorWithTypeCode_1, typeCode);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public objc.id enumCodeValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_enumCodeValue);
+    }
+
+    public objc.id eventClass ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_eventClass);
+    }
+
+    public objc.id eventID ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_eventID);
+    }
+
+    public NSAppleEventDescriptor initListDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initListDescriptor);
+        return result !is null ? this : null;
+    }
+
+    public NSAppleEventDescriptor initRecordDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initRecordDescriptor);
+        return result !is null ? this : null;
+    }
+
+    public NSAppleEventDescriptor initWithAEDescNoCopy (objc.id aeDesc)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithAEDescNoCopy_1, aeDesc);
+        return result !is null ? this : null;
+    }
+
+    public NSAppleEventDescriptor initWithDescriptorType_bytes_length_ (objc.id descriptorType, /*const*/void* bytes, NSUInteger byteCount)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDescriptorType_1bytes_1length_1, descriptorType, bytes, byteCount);
+        return result !is null ? this : null;
+    }
+
+    public NSAppleEventDescriptor initWithDescriptorType_data_ (objc.id descriptorType, NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDescriptorType_1data_1, descriptorType, data !is null ? data.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSAppleEventDescriptor initWithEventClass (objc.id eventClass, objc.id eventID, NSAppleEventDescriptor targetDescriptor, objc.id returnID,
+            objc.id transactionID)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithEventClass_1eventID_1targetDescriptor_1returnID_1transactionID_1, eventClass,
+                eventID, targetDescriptor !is null ? targetDescriptor.id : null, returnID, transactionID);
+        return result !is null ? this : null;
+    }
+
+    public void insertDescriptor (NSAppleEventDescriptor descriptor, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertDescriptor_1atIndex_1, descriptor !is null ? descriptor.id : null, index);
+    }
+
+    public int int32Value ()
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_int32Value);
+    }
+
+    public AEKeyword keywordForDescriptorAtIndex (NSInteger index)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_keywordForDescriptorAtIndex_1, index);
+    }
+
+    public static NSAppleEventDescriptor listDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_listDescriptor);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public static NSAppleEventDescriptor nullDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_nullDescriptor);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSInteger numberOfItems ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfItems);
+    }
+
+    public NSAppleEventDescriptor paramDescriptorForKeyword (objc.id keyword)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_paramDescriptorForKeyword_1, keyword);
+        return result is this.id ? this : (result !is null ? new NSAppleEventDescriptor(result) : null);
+    }
+
+    public static NSAppleEventDescriptor recordDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventDescriptor, OS.sel_recordDescriptor);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public void removeDescriptorAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeDescriptorAtIndex_1, index);
+    }
+
+    public void removeDescriptorWithKeyword (objc.id keyword)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeDescriptorWithKeyword_1, keyword);
+    }
+
+    public void removeParamDescriptorWithKeyword (objc.id keyword)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeParamDescriptorWithKeyword_1, keyword);
+    }
+
+    public short returnID ()
+    {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_returnID);
+    }
+
+    public void setAttributeDescriptor (NSAppleEventDescriptor descriptor, objc.id keyword)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributeDescriptor_1forKeyword_1, descriptor !is null ? descriptor.id : null, keyword);
+    }
+
+    public void setDescriptor (NSAppleEventDescriptor descriptor, objc.id keyword)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDescriptor_1forKeyword_1, descriptor !is null ? descriptor.id : null, keyword);
+    }
+
+    public void setParamDescriptor (NSAppleEventDescriptor descriptor, objc.id keyword)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParamDescriptor_1forKeyword_1, descriptor !is null ? descriptor.id : null, keyword);
+    }
+
+    public NSString StringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_StringValue);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public objc.id transactionID ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_transactionID);
+    }
+
+    public objc.id typeCodeValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_typeCodeValue);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAppleEventManager.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAppleEventManager;
+
+import dwt.internal.cocoa.NSAppleEventDescriptor;
+import dwt.internal.cocoa.NSObject;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAppleEventManager : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSAppleEventDescriptor appleEventForSuspensionID (objc.id suspensionID)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_appleEventForSuspensionID_1, suspensionID);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSAppleEventDescriptor currentAppleEvent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentAppleEvent);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSAppleEventDescriptor currentReplyAppleEvent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentReplyAppleEvent);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public short dispatchRawAppleEvent (objc.id theAppleEvent, objc.id theReply, objc.id handlerRefCon)
+    {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_dispatchRawAppleEvent_1withRawReply_1handlerRefCon_1, theAppleEvent, theReply,
+                handlerRefCon);
+    }
+
+    public void removeEventHandlerForEventClass (objc.id eventClass, objc.id eventID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeEventHandlerForEventClass_1andEventID_1, eventClass, eventID);
+    }
+
+    public NSAppleEventDescriptor replyAppleEventForSuspensionID (objc.id suspensionID)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_replyAppleEventForSuspensionID_1, suspensionID);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public void resumeWithSuspensionID (objc.id suspensionID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resumeWithSuspensionID_1, suspensionID);
+    }
+
+    public void setCurrentAppleEventAndReplyEventWithSuspensionID (objc.id suspensionID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrentAppleEventAndReplyEventWithSuspensionID_1, suspensionID);
+    }
+
+    public void setEventHandler (id handler, objc.id handleEventSelector, objc.id eventClass, objc.id eventID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEventHandler_1andSelector_1forEventClass_1andEventID_1, handler !is null ? handler.id : null,
+                handleEventSelector, eventClass, eventID);
+    }
+
+    public static NSAppleEventManager sharedAppleEventManager ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAppleEventManager, OS.sel_sharedAppleEventManager);
+        return result !is null ? new NSAppleEventManager(result) : null;
+    }
+
+    public objc.id suspendCurrentAppleEvent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_suspendCurrentAppleEvent);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAppleScript.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAppleScript;
+
+import dwt.internal.cocoa.NSAppleEventDescriptor;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAppleScript : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool compileAndReturnError (objc.id** errorInfo)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compileAndReturnError_1, errorInfo) !is null;
+    }
+
+    public NSAppleEventDescriptor executeAndReturnError (objc.id** errorInfo)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_executeAndReturnError_1, errorInfo);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSAppleEventDescriptor executeAppleEvent (NSAppleEventDescriptor event, objc.id** errorInfo)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_executeAppleEvent_1error_1, event !is null ? event.id : null, errorInfo);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSAppleScript initWithContentsOfURL (NSURL url, objc.id** errorInfo)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1error_1, url !is null ? url.id : null, errorInfo);
+        return result !is null ? this : null;
+    }
+
+    public NSAppleScript initWithSource (NSString source)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSource_1, source !is null ? source.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isCompiled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isCompiled) !is null;
+    }
+
+    public NSString source ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_source);
+        return result !is null ? new NSString(result) : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSApplication.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,487 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSApplication;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSDockTile;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSException;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSResponder;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSApplication : NSResponder
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void abortModal ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_abortModal);
+    }
+
+    public void activateContextHelpMode (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_activateContextHelpMode_1, sender !is null ? sender.id : null);
+    }
+
+    public void activateIgnoringOtherApps (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_activateIgnoringOtherApps_1, flag);
+    }
+
+    public void addWindowsItem (NSWindow win, NSString aString, bool isFilename)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addWindowsItem_1title_1filename_1, win !is null ? win.id : null, aString !is null ? aString.id : null,
+                isFilename);
+    }
+
+    public NSImage applicationIconImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_applicationIconImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public void arrangeInFront (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_arrangeInFront_1, sender !is null ? sender.id : null);
+    }
+
+    public objc.id beginModalSessionForWindow_ (NSWindow theWindow)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_beginModalSessionForWindow_1, theWindow !is null ? theWindow.id : null);
+    }
+
+    public objc.id beginModalSessionForWindow_relativeToWindow_ (NSWindow theWindow, NSWindow docWindow)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_beginModalSessionForWindow_1relativeToWindow_1, theWindow !is null ? theWindow.id : null,
+                docWindow !is null ? docWindow.id : null);
+    }
+
+    public void beginSheet (NSWindow sheet, NSWindow docWindow, id modalDelegate, objc.id didEndSelector, objc.id contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginSheet_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1, sheet !is null ? sheet.id : null,
+                docWindow !is null ? docWindow.id : null, modalDelegate !is null ? modalDelegate.id : null, didEndSelector, contextInfo);
+    }
+
+    public void cancelUserAttentionRequest (objc.id request)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelUserAttentionRequest_1, request);
+    }
+
+    public void changeWindowsItem (NSWindow win, NSString aString, bool isFilename)
+    {
+        OS.objc_msgSend(this.id, OS.sel_changeWindowsItem_1title_1filename_1, win !is null ? win.id : null, aString !is null ? aString.id : null,
+                isFilename);
+    }
+
+    public NSGraphicsContext context ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_context);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public NSEvent currentEvent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentEvent);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public void deactivate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_deactivate);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static void detachDrawingThread (objc.id selector, id target, id argument)
+    {
+        OS.objc_msgSend(OS.class_NSApplication, OS.sel_detachDrawingThread_1toTarget_1withObject_1, selector, target !is null ? target.id : null,
+                argument !is null ? argument.id : null);
+    }
+
+    public void discardEventsMatchingMask (NSUInteger mask, NSEvent lastEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_discardEventsMatchingMask_1beforeEvent_1, mask, lastEvent !is null ? lastEvent.id : null);
+    }
+
+    public NSDockTile dockTile ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dockTile);
+        return result !is null ? new NSDockTile(result) : null;
+    }
+
+    public void endModalSession (objc.id session)
+    {
+        OS.objc_msgSend(this.id, OS.sel_endModalSession_1, session);
+    }
+
+    public void endSheet_ (NSWindow sheet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_endSheet_1, sheet !is null ? sheet.id : null);
+    }
+
+    public void endSheet_returnCode_ (NSWindow sheet, NSInteger returnCode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_endSheet_1returnCode_1, sheet !is null ? sheet.id : null, returnCode);
+    }
+
+    public void finishLaunching ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_finishLaunching);
+    }
+
+    public void hide (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_hide_1, sender !is null ? sender.id : null);
+    }
+
+    public void hideOtherApplications (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_hideOtherApplications_1, sender !is null ? sender.id : null);
+    }
+
+    public bool isActive ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isActive) !is null;
+    }
+
+    public bool isHidden ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHidden) !is null;
+    }
+
+    public bool isRunning ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRunning) !is null;
+    }
+
+    public NSWindow keyWindow ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyWindow);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public NSMenu mainMenu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mainMenu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSWindow mainWindow ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mainWindow);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public NSWindow makeWindowsPerform (objc.id aSelector, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeWindowsPerform_1inOrder_1, aSelector, flag);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public void miniaturizeAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_miniaturizeAll_1, sender !is null ? sender.id : null);
+    }
+
+    public NSWindow modalWindow ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_modalWindow);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public NSEvent nextEventMatchingMask (NSUInteger mask, NSDate expiration, NSString mode, bool deqFlag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextEventMatchingMask_1untilDate_1inMode_1dequeue_1, mask,
+                expiration !is null ? expiration.id : null, mode !is null ? mode.id : null, deqFlag);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public void orderFrontCharacterPalette (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontCharacterPalette_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontColorPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontColorPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontStandardAboutPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontStandardAboutPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontStandardAboutPanelWithOptions (NSDictionary optionsDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontStandardAboutPanelWithOptions_1, optionsDictionary !is null ? optionsDictionary.id : null);
+    }
+
+    public NSArray orderedDocuments ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_orderedDocuments);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray orderedWindows ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_orderedWindows);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void postEvent (NSEvent event, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postEvent_1atStart_1, event !is null ? event.id : null, flag);
+    }
+
+    public void preventWindowOrdering ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_preventWindowOrdering);
+    }
+
+    public void registerServicesMenuSendTypes (NSArray sendTypes, NSArray returnTypes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerServicesMenuSendTypes_1returnTypes_1, sendTypes !is null ? sendTypes.id : null,
+                returnTypes !is null ? returnTypes.id : null);
+    }
+
+    public void removeWindowsItem (NSWindow win)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeWindowsItem_1, win !is null ? win.id : null);
+    }
+
+    public void replyToApplicationShouldTerminate (bool shouldTerminate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replyToApplicationShouldTerminate_1, shouldTerminate);
+    }
+
+    public void replyToOpenOrPrint (objc.id reply)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replyToOpenOrPrint_1, reply);
+    }
+
+    public void reportException (NSException theException)
+    {
+        OS.objc_msgSend(this.id, OS.sel_reportException_1, theException !is null ? theException.id : null);
+    }
+
+    public NSInteger requestUserAttention (objc.id requestType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_requestUserAttention_1, requestType);
+    }
+
+    public void run ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_run);
+    }
+
+    public objc.id runModalForWindow_ (NSWindow theWindow)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModalForWindow_1, theWindow !is null ? theWindow.id : null);
+    }
+
+    public objc.id runModalForWindow_relativeToWindow_ (NSWindow theWindow, NSWindow docWindow)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModalForWindow_1relativeToWindow_1, theWindow !is null ? theWindow.id : null,
+                docWindow !is null ? docWindow.id : null);
+    }
+
+    public objc.id runModalSession (objc.id session)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModalSession_1, session);
+    }
+
+    public void runPageLayout (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runPageLayout_1, sender !is null ? sender.id : null);
+    }
+
+    public bool sendAction (objc.id theAction, id theTarget, id sender)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendAction_1to_1from_1, theAction, theTarget !is null ? theTarget.id : null,
+                sender !is null ? sender.id : null) !is null;
+    }
+
+    public void sendEvent (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sendEvent_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public NSMenu servicesMenu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_servicesMenu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public id servicesProvider ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_servicesProvider);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setApplicationIconImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setApplicationIconImage_1, image !is null ? image.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setMainMenu (NSMenu aMenu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMainMenu_1, aMenu !is null ? aMenu.id : null);
+    }
+
+    public void setServicesMenu (NSMenu aMenu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setServicesMenu_1, aMenu !is null ? aMenu.id : null);
+    }
+
+    public void setServicesProvider (id provider)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setServicesProvider_1, provider !is null ? provider.id : null);
+    }
+
+    public void setWindowsMenu (NSMenu aMenu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindowsMenu_1, aMenu !is null ? aMenu.id : null);
+    }
+
+    public void setWindowsNeedUpdate (bool needUpdate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindowsNeedUpdate_1, needUpdate);
+    }
+
+    public static NSApplication sharedApplication ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSApplication, OS.sel_sharedApplication);
+        return result !is null ? new NSApplication(result) : null;
+    }
+
+    public void showHelp (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showHelp_1, sender !is null ? sender.id : null);
+    }
+
+    public void stop (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stop_1, sender !is null ? sender.id : null);
+    }
+
+    public void stopModal ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopModal);
+    }
+
+    public void stopModalWithCode (NSInteger returnCode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopModalWithCode_1, returnCode);
+    }
+
+    public id targetForAction_ (objc.SEL theAction)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_targetForAction_1, theAction);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id targetForAction_to_from_ (objc.SEL theAction, id theTarget, id sender)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_targetForAction_1to_1from_1, theAction, theTarget !is null ? theTarget.id : null,
+                sender !is null ? sender.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void terminate (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_terminate_1, sender !is null ? sender.id : null);
+    }
+
+    public bool tryToPerform (objc.SEL anAction, id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryToPerform_1with_1, anAction, anObject !is null ? anObject.id : null) !is null;
+    }
+
+    public void unhide (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unhide_1, sender !is null ? sender.id : null);
+    }
+
+    public void unhideAllApplications (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unhideAllApplications_1, sender !is null ? sender.id : null);
+    }
+
+    public void unhideWithoutActivation ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_unhideWithoutActivation);
+    }
+
+    public void updateWindows ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateWindows);
+    }
+
+    public void updateWindowsItem (NSWindow win)
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateWindowsItem_1, win !is null ? win.id : null);
+    }
+
+    public id validRequestorForSendType (NSString sendType, NSString returnType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_validRequestorForSendType_1returnType_1, sendType !is null ? sendType.id : null,
+                returnType !is null ? returnType.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSWindow windowWithWindowNumber (NSInteger windowNum)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowWithWindowNumber_1, windowNum);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public NSArray windows ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windows);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSMenu windowsMenu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowsMenu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSArchiver.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSArchiver;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSMutableData;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSArchiver : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static bool archiveRootObject (id rootObject, NSString path)
+    {
+        return OS.objc_msgSend(OS.class_NSArchiver, OS.sel_archiveRootObject_1toFile_1, rootObject !is null ? rootObject.id : null,
+                path !is null ? path.id : null) !is null;
+    }
+
+    public static NSData archivedDataWithRootObject (id rootObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArchiver, OS.sel_archivedDataWithRootObject_1, rootObject !is null ? rootObject.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSMutableData archiverData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_archiverData);
+        return result !is null ? new NSMutableData(result) : null;
+    }
+
+    public NSString classNameEncodedForTrueClassName (NSString trueName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_classNameEncodedForTrueClassName_1, trueName !is null ? trueName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void encodeClassName (NSString trueName, NSString inArchiveName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeClassName_1intoClassName_1, trueName !is null ? trueName.id : null,
+                inArchiveName !is null ? inArchiveName.id : null);
+    }
+
+    public void encodeConditionalObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeConditionalObject_1, object !is null ? object.id : null);
+    }
+
+    public void encodeRootObject (id rootObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeRootObject_1, rootObject !is null ? rootObject.id : null);
+    }
+
+    public NSArchiver initForWritingWithMutableData (NSMutableData mdata)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initForWritingWithMutableData_1, mdata !is null ? mdata.id : null);
+        return result !is null ? this : null;
+    }
+
+    public void replaceObject (id object, id newObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceObject_1withObject_1, object !is null ? object.id : null, newObject !is null ? newObject.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSArray.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,342 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSArray;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSArray : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObserver_forKeyPath_options_context_ (NSObject observer, NSString keyPath, objc.id options, objc.id context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
+                keyPath !is null ? keyPath.id : null, options, context);
+    }
+
+    public void addObserver_toObjectsAtIndexes_forKeyPath_options_context_ (NSObject observer, NSIndexSet indexes, NSString keyPath, objc.id options,
+            objc.id context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1toObjectsAtIndexes_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
+                indexes !is null ? indexes.id : null, keyPath !is null ? keyPath.id : null, options, context);
+    }
+
+    public static id array ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_array);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray arrayByAddingObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayByAddingObject_1, anObject !is null ? anObject.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray arrayByAddingObjectsFromArray (NSArray otherArray)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayByAddingObjectsFromArray_1, otherArray !is null ? otherArray.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public static id arrayWithArray (NSArray array)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithArray_1, array !is null ? array.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id arrayWithContentsOfFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id arrayWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id arrayWithObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObject_1, anObject !is null ? anObject.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_arrayWithObjects_ (id arrayWithObjects)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1, arrayWithObjects !is null ? arrayWithObjects.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_arrayWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1count_1, objects, cnt);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString componentsJoinedByString (NSString separator)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_componentsJoinedByString_1, separator !is null ? separator.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool containsObject (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsObject_1, anObject !is null ? anObject.id : null) !is null;
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithLocale_ (id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithLocale_indent_ (id locale, objc.id level)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1indent_1, locale !is null ? locale.id : null, level);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray filteredArrayUsingPredicate (NSPredicate predicate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_filteredArrayUsingPredicate_1, predicate !is null ? predicate.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public id firstObjectCommonWithArray (NSArray otherArray)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_firstObjectCommonWithArray_1, otherArray !is null ? otherArray.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void getObjects_ (objc.id objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getObjects_1, objects);
+    }
+
+    public void getObjects_range_ (objc.id objects, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getObjects_1range_1, objects, range);
+    }
+
+    public NSUInteger indexOfObject_ (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public NSUInteger indexOfObject_inRange_ (id anObject, NSRange range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObject_1inRange_1, anObject !is null ? anObject.id : null, range);
+    }
+
+    public NSUInteger indexOfObjectIdenticalTo_ (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObjectIdenticalTo_1, anObject !is null ? anObject.id : null);
+    }
+
+    public NSUInteger indexOfObjectIdenticalTo_inRange_ (id anObject, NSRange range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id : null, range);
+    }
+
+    public NSArray initWithArray_ (NSArray array)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithArray_1, array !is null ? array.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSArray initWithArray_copyItems_ (NSArray array, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithArray_1copyItems_1, array !is null ? array.id : null, flag);
+        return result !is null ? this : null;
+    }
+
+    public NSArray initWithContentsOfFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSArray initWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSArray initWithObjects_ (id initWithObjects)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1, initWithObjects !is null ? initWithObjects.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSArray initWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1count_1, objects, cnt);
+        return result !is null ? this : null;
+    }
+
+    public bool isEqualToArray (NSArray otherArray)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToArray_1, otherArray !is null ? otherArray.id : null) !is null;
+    }
+
+    public id lastObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lastObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void makeObjectsPerformSelector_ (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1, aSelector);
+    }
+
+    public void makeObjectsPerformSelector_withObject_ (objc.SEL aSelector, id argument)
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1withObject_1, aSelector, argument !is null ? argument.id : null);
+    }
+
+    public objc.id objectAtIndex (NSUInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectAtIndex_1, index);
+        return result;
+    //  return result !is null ? new id(result) : null;
+    }
+
+    public NSEnumerator objectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public NSArray objectsAtIndexes (NSIndexSet indexes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsAtIndexes_1, indexes !is null ? indexes.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray pathsMatchingExtensions (NSArray filterTypes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsMatchingExtensions_1, filterTypes !is null ? filterTypes.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public void removeObserver_forKeyPath_ (NSObject observer, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void removeObserver_fromObjectsAtIndexes_forKeyPath_ (NSObject observer, NSIndexSet indexes, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1fromObjectsAtIndexes_1forKeyPath_1, observer !is null ? observer.id : null,
+                indexes !is null ? indexes.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public NSEnumerator reverseObjectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_reverseObjectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public void setValue (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public NSData sortedArrayHint ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayHint);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray sortedArrayUsingFunction_context_ (objc.id comparator, objc.id context)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingFunction_1context_1, comparator, context);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray sortedArrayUsingFunction_context_hint_ (objc.id comparator, objc.id context, NSData hint)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingFunction_1context_1hint_1, comparator, context,
+                hint !is null ? hint.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray sortedArrayUsingSelector (objc.id comparator)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingSelector_1, comparator);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray subarrayWithRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subarrayWithRange_1, range);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public id valueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool writeToFile (NSString path, bool useAuxiliaryFile)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1, path !is null ? path.id : null, useAuxiliaryFile) !is null;
+    }
+
+    public bool writeToURL (NSURL url, bool atomically)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1atomically_1, url !is null ? url.id : null, atomically) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSArrayController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,306 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSArrayController;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObjectController;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSArrayController : NSObjectController
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void add (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_add_1, sender !is null ? sender.id : null);
+    }
+
+    public void addObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObject_1,
+                object !is null ? object.id : null);
+    }
+
+    public void addObjects (NSArray objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObjects_1,
+                objects !is null ? objects.id : null);
+    }
+
+    public bool addSelectedObjects (NSArray objects)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_addSelectedObjects_1,
+                objects !is null ? objects.id : null) !is null;
+    }
+
+    public bool addSelectionIndexes (NSIndexSet indexes)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_addSelectionIndexes_1,
+                indexes !is null ? indexes.id : null) !is null;
+    }
+
+    public bool alwaysUsesMultipleValuesMarker ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_alwaysUsesMultipleValuesMarker) !is null;
+    }
+
+    public NSArray arrangeObjects (NSArray objects)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrangeObjects_1,
+                objects !is null ? objects.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id arrangedObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrangedObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray automaticRearrangementKeyPaths ()
+    {
+        objc.id result = OS.objc_msgSend(this.id,
+                OS.sel_automaticRearrangementKeyPaths);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool automaticallyRearrangesObjects ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_automaticallyRearrangesObjects) !is null;
+    }
+
+    public bool avoidsEmptySelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_avoidsEmptySelection) !is null;
+    }
+
+    public bool canInsert ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canInsert) !is null;
+    }
+
+    public bool canSelectNext ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canSelectNext) !is null;
+    }
+
+    public bool canSelectPrevious ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canSelectPrevious) !is null;
+    }
+
+    public bool clearsFilterPredicateOnInsertion ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_clearsFilterPredicateOnInsertion) !is null;
+    }
+
+    public void didChangeArrangementCriteria ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_didChangeArrangementCriteria);
+    }
+
+    public NSPredicate filterPredicate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_filterPredicate);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public void insert (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insert_1,
+                sender !is null ? sender.id : null);
+    }
+
+    public void insertObject (id object, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertObject_1atArrangedObjectIndex_1,
+                object !is null ? object.id : null, index);
+    }
+
+    public void insertObjects (NSArray objects, NSIndexSet indexes)
+    {
+        OS.objc_msgSend(this.id,
+                OS.sel_insertObjects_1atArrangedObjectIndexes_1,
+                objects !is null ? objects.id : null,
+                indexes !is null ? indexes.id : null);
+    }
+
+    public bool preservesSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preservesSelection) !is null;
+    }
+
+    public void rearrangeObjects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_rearrangeObjects);
+    }
+
+    public void remove (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_remove_1,
+                sender !is null ? sender.id : null);
+    }
+
+    public void removeObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObject_1,
+                object !is null ? object.id : null);
+    }
+
+    public void removeObjectAtArrangedObjectIndex (NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectAtArrangedObjectIndex_1,
+                index);
+    }
+
+    public void removeObjects (NSArray objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjects_1,
+                objects !is null ? objects.id : null);
+    }
+
+    public void removeObjectsAtArrangedObjectIndexes (NSIndexSet indexes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectsAtArrangedObjectIndexes_1,
+                indexes !is null ? indexes.id : null);
+    }
+
+    public bool removeSelectedObjects (NSArray objects)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removeSelectedObjects_1,
+                objects !is null ? objects.id : null) !is null;
+    }
+
+    public bool removeSelectionIndexes (NSIndexSet indexes)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removeSelectionIndexes_1,
+                indexes !is null ? indexes.id : null) !is null;
+    }
+
+    public void selectNext (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectNext_1,
+                sender !is null ? sender.id : null);
+    }
+
+    public void selectPrevious (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectPrevious_1,
+                sender !is null ? sender.id : null);
+    }
+
+    public NSArray selectedObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSUInteger selectionIndex ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectionIndex);
+    }
+
+    public NSIndexSet selectionIndexes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectionIndexes);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public bool selectsInsertedObjects ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectsInsertedObjects) !is null;
+    }
+
+    public void setAlwaysUsesMultipleValuesMarker (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlwaysUsesMultipleValuesMarker_1,
+                flag);
+    }
+
+    public void setAutomaticallyRearrangesObjects (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutomaticallyRearrangesObjects_1,
+                flag);
+    }
+
+    public void setAvoidsEmptySelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAvoidsEmptySelection_1, flag);
+    }
+
+    public void setClearsFilterPredicateOnInsertion (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setClearsFilterPredicateOnInsertion_1,
+                flag);
+    }
+
+    public void setFilterPredicate (NSPredicate filterPredicate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFilterPredicate_1,
+                filterPredicate !is null ? filterPredicate.id : null);
+    }
+
+    public void setPreservesSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreservesSelection_1, flag);
+    }
+
+    public bool setSelectedObjects (NSArray objects)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setSelectedObjects_1,
+                objects !is null ? objects.id : null) !is null;
+    }
+
+    public bool setSelectionIndex (NSUInteger index)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setSelectionIndex_1, index) !is null;
+    }
+
+    public bool setSelectionIndexes (NSIndexSet indexes)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setSelectionIndexes_1,
+                indexes !is null ? indexes.id : null) !is null;
+    }
+
+    public void setSelectsInsertedObjects (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectsInsertedObjects_1, flag);
+    }
+
+    public void setSortDescriptors (NSArray sortDescriptors)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSortDescriptors_1,
+                sortDescriptors !is null ? sortDescriptors.id : null);
+    }
+
+    public NSArray sortDescriptors ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortDescriptors);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAssertionHandler.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAssertionHandler;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAssertionHandler : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSAssertionHandler currentHandler ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSAssertionHandler, OS.sel_currentHandler);
+        return result !is null ? new NSAssertionHandler(result) : null;
+    }
+
+    public void handleFailureInFunction (NSString functionName, NSString fileName, NSInteger line, NSString description)
+    {
+        OS.objc_msgSend(this.id, OS.sel_handleFailureInFunction_1file_1lineNumber_1description_1, functionName !is null ? functionName.id : null,
+                fileName !is null ? fileName.id : null, line, description !is null ? description.id : null);
+    }
+
+    public void handleFailureInMethod (objc.SEL selector, id object, NSString fileName, NSInteger line, NSString description)
+    {
+        OS.objc_msgSend(this.id, OS.sel_handleFailureInMethod_1object_1file_1lineNumber_1description_1, selector, object !is null ? object.id : null,
+                fileName !is null ? fileName.id : null, line, description !is null ? description.id : null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAttributeType.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,36 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSAttributeType;
+
+enum NSAttributeType {
+    NSUndefinedAttributeType = 0,
+    NSInteger16AttributeType = 100,
+    NSInteger32AttributeType = 200,
+    NSInteger64AttributeType = 300,
+    NSDecimalAttributeType = 400,
+    NSDoubleAttributeType = 500,
+    NSFloatAttributeType = 600,
+    NSStringAttributeType = 700,
+    NSBooleanAttributeType = 800,
+    NSDateAttributeType = 900,
+    NSBinaryDataAttributeType = 1000,
+    NSTransformableAttributeType = 1800
+}
+
+alias NSAttributeType.NSUndefinedAttributeType NSUndefinedAttributeType;
+alias NSAttributeType.NSInteger16AttributeType NSInteger16AttributeType;
+alias NSAttributeType.NSInteger32AttributeType NSInteger32AttributeType;
+alias NSAttributeType.NSInteger64AttributeType NSInteger64AttributeType;
+alias NSAttributeType.NSDecimalAttributeType NSDecimalAttributeType;
+alias NSAttributeType.NSDoubleAttributeType NSDoubleAttributeType;
+alias NSAttributeType.NSFloatAttributeType NSFloatAttributeType;
+alias NSAttributeType.NSStringAttributeType NSStringAttributeType;
+alias NSAttributeType.NSBooleanAttributeType NSBooleanAttributeType;
+alias NSAttributeType.NSDateAttributeType NSDateAttributeType;
+alias NSAttributeType.NSBinaryDataAttributeType NSBinaryDataAttributeType;
+alias NSAttributeType.NSTransformableAttributeType NSTransformableAttributeType;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAttributedString.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAttributedString;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAttributedString : NSObject
+{
+    public this ()
+    {
+        this();
+    }
+
+    public this (objc.id id)
+    {
+        this(id);
+    }
+
+    public id attribute_atIndex_effectiveRange_ (NSString attrName, NSUInteger location, objc.id range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute_1atIndex_1effectiveRange_1, attrName !is null ? attrName.id : null, location,
+                range);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id attribute_atIndex_longestEffectiveRange_inRange_ (NSString attrName, NSUInteger location, objc.id range, NSRange rangeLimit)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute_1atIndex_1longestEffectiveRange_1inRange_1,
+                attrName !is null ? attrName.id : null, location, range, rangeLimit);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSAttributedString attributedSubStringFromRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedSubStringFromRange_1, range);
+        return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
+    }
+
+    public NSDictionary attributesAtIndex_effectiveRange_ (int location, objc.id range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_1effectiveRange_1, location, range);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary attributesAtIndex_longestEffectiveRange_inRange_ (NSUInteger location, objc.id range, NSRange rangeLimit)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_1longestEffectiveRange_1inRange_1, location, range, rangeLimit);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSAttributedString initWithAttributedString (NSAttributedString attrStr)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithAttributedString_1, attrStr !is null ? attrStr.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSAttributedString initWithString_ (NSString str)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, str !is null ? str.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSAttributedString initWithString_attributes_ (NSString str, NSDictionary attrs)
+    {
+        objc.id
+                result = OS.objc_msgSend(this.id, OS.sel_initWithString_1attributes_1, str !is null ? str.id : null, attrs !is null ? attrs.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isEqualToAttributedString (NSAttributedString other)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToAttributedString_1, other !is null ? other.id : null) !is null;
+    }
+
+    public NSUInteger length ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_length);
+    }
+
+    public NSString String ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_String);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSSize size ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_size);
+        return result;
+    }
+
+    public void drawAtPoint (NSPoint pt)
+    {
+        OS.objc_msgSend(id, OS.sel_drawAtPoint_, pt);
+    }
+
+    public void drawInRect (NSRect rect)
+    {
+        OS.objc_msgSend(id, OS.sel_drawInRect_1, rect);
+    }
+
+    public void drawInRect (NSRect rect, objc.id options)
+    {
+        OS.objc_msgSend(id, OS.sel_drawInRect_1, rect, options);
+    }
+
+    public NSUInteger nextWordFromIndex (NSUInteger index, bool forward)
+    {
+        return OS.objc_msgSend(id, OS.sel_nextWordFromIndex_1forward_1, index, forward);
+    }
+
+    public NSRange doubleClickAtIndex (NSUInteger index)
+    {
+        NSRange result;
+        OS.objc_msgSend_struct(result, id, OS.sel_doubleClickAtIndex_1, index);
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAutoreleasePool.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAutoreleasePool;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAutoreleasePool : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static void static_addObject_ (id anObject)
+    {
+        OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_addObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void addObject_ (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public static NSUInteger autoreleasedObjectCount ()
+    {
+        return OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_autoreleasedObjectCount);
+    }
+
+    public void drain ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_drain);
+    }
+
+    public static void enableFreedObjectCheck (bool enable)
+    {
+        OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_enableFreedObjectCheck_1, enable);
+    }
+
+    public static void enableRelease (bool enable)
+    {
+        OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_enableRelease_1, enable);
+    }
+
+    public static NSUInteger poolCountHighWaterMark ()
+    {
+        return OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_poolCountHighWaterMark);
+    }
+
+    public static NSUInteger poolCountHighWaterResolution ()
+    {
+        return OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_poolCountHighWaterResolution);
+    }
+
+    public static void resetTotalAutoreleasedObjects ()
+    {
+        OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_resetTotalAutoreleasedObjects);
+    }
+
+    public static void setPoolCountHighWaterMark (NSUInteger count)
+    {
+        OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_setPoolCountHighWaterMark_1, count);
+    }
+
+    public static void setPoolCountHighWaterResolution (NSUInteger res)
+    {
+        OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_setPoolCountHighWaterResolution_1, res);
+    }
+
+    public static void showPools ()
+    {
+        OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_showPools);
+    }
+
+    public static NSUInteger topAutoreleasePoolCount ()
+    {
+        return OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_topAutoreleasePoolCount);
+    }
+
+    public static NSUInteger totalAutoreleasedObjects ()
+    {
+        return OS.objc_msgSend(OS.class_NSAutoreleasePool, OS.sel_totalAutoreleasedObjects);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSBezierPath.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,419 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSBezierPath;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSBezierPathElement
+{
+    NSMoveToBezierPathElement,
+    NSLineToBezierPathElement,
+    NSCurveToBezierPathElement,
+    NSClosePathBezierPathElement
+}
+
+public class NSBezierPath : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addClip ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_addClip);
+    }
+
+    public void appendBezierPath (NSBezierPath path)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPath_1, path !is null ? path.id : null);
+    }
+
+    public void appendBezierPathWithArcFromPoint (NSPoint point1, NSPoint point2, CGFloat radius)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcFromPoint_1toPoint_1radius_1, point1, point2, radius);
+    }
+
+    public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_ (NSPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1, center, radius, startAngle, endAngle);
+    }
+
+    public void appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_ (NSPoint center, CGFloat radius, CGFloat startAngle,
+            CGFloat endAngle, bool clockwise)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1clockwise_1, center, radius, startAngle,
+                endAngle, clockwise);
+    }
+
+    public void appendBezierPathWithGlyph (objc.id glyph, NSFont font)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyph_1inFont_1, glyph, font !is null ? font.id : null);
+    }
+
+    public void appendBezierPathWithGlyphs (objc.id glyphs, NSInteger count, NSFont font)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithGlyphs_1count_1inFont_1, glyphs, count, font !is null ? font.id : null);
+    }
+
+    public void appendBezierPathWithOvalInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithOvalInRect_1, rect);
+    }
+
+    public void appendBezierPathWithPackedGlyphs (objc.id packedGlyphs)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithPackedGlyphs_1, packedGlyphs);
+    }
+
+    public void appendBezierPathWithPoints (objc.id points, NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithPoints_1count_1, points, count);
+    }
+
+    public void appendBezierPathWithRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRect_1, rect);
+    }
+
+    public void appendBezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius);
+    }
+
+    public static NSBezierPath bezierPath ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPath);
+        return result !is null ? new NSBezierPath(result) : null;
+    }
+
+    public NSBezierPath bezierPathByFlatteningPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bezierPathByFlatteningPath);
+        return result is this.id ? this : (result !is null ? new NSBezierPath(result) : null);
+    }
+
+    public NSBezierPath bezierPathByReversingPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bezierPathByReversingPath);
+        return result is this.id ? this : (result !is null ? new NSBezierPath(result) : null);
+    }
+
+    public static NSBezierPath bezierPathWithOvalInRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithOvalInRect_1, rect);
+        return result !is null ? new NSBezierPath(result) : null;
+    }
+
+    public static NSBezierPath bezierPathWithRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRect_1, rect);
+        return result !is null ? new NSBezierPath(result) : null;
+    }
+
+    public static NSBezierPath bezierPathWithRoundedRect (NSRect rect, CGFloat xRadius, CGFloat yRadius)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_bezierPathWithRoundedRect_1xRadius_1yRadius_1, rect, xRadius, yRadius);
+        return result !is null ? new NSBezierPath(result) : null;
+    }
+
+    public NSRect bounds ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_bounds);
+        return result;
+    }
+
+    public bool cachesBezierPath ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_cachesBezierPath) !is null;
+    }
+
+    public static void clipRect (NSRect rect)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_clipRect_1, rect);
+    }
+
+    public void closePath ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_closePath);
+    }
+
+    public bool containsPoint (NSPoint point)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsPoint_1, point) !is null;
+    }
+
+    public NSRect controlPointBounds ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_controlPointBounds);
+        return result;
+    }
+
+    public NSPoint currentPoint ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_currentPoint);
+        return result;
+    }
+
+    public void curveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2)
+    {
+        OS.objc_msgSend(this.id, OS.sel_curveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2);
+    }
+
+    public static CGFloat defaultFlatness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultFlatness);
+    }
+
+    public static objc.id defaultLineCapStyle ()
+    {
+        return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineCapStyle);
+    }
+
+    public static objc.id defaultLineJoinStyle ()
+    {
+        return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultLineJoinStyle);
+    }
+
+    public static CGFloat defaultLineWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultLineWidth);
+    }
+
+    public static CGFloat defaultMiterLimit ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSBezierPath, OS.sel_defaultMiterLimit);
+    }
+
+    public static objc.id defaultWindingRule ()
+    {
+        return OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_defaultWindingRule);
+    }
+
+    public static void drawPackedGlyphs (/*const*/char* packedGlyphs, NSPoint point)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_drawPackedGlyphs_1atPoint_1, packedGlyphs, point);
+    }
+
+    public objc.id elementAtIndex_ (NSInteger index)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_elementAtIndex_1, index);
+    }
+
+    public NSBezierPathElement elementAtIndex_associatedPoints_ (NSInteger index, NSPointArray points)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_elementAtIndex_1associatedPoints_1, index, points);
+    }
+
+    public NSInteger elementCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_elementCount);
+    }
+
+    public void fill ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_fill);
+    }
+
+    public static void fillRect (NSRect rect)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_fillRect_1, rect);
+    }
+
+    public CGFloat flatness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_flatness);
+    }
+
+    public void getLineDash (CGFloat* pattern, NSInteger* count, CGFloat* phase)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getLineDash_1count_1phase_1, pattern, count, phase);
+    }
+
+    public bool isEmpty ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEmpty) !is null;
+    }
+
+    public objc.id lineCapStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lineCapStyle);
+    }
+
+    public objc.id lineJoinStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lineJoinStyle);
+    }
+
+    public void lineToPoint (NSPoint point)
+    {
+        OS.objc_msgSend(this.id, OS.sel_lineToPoint_1, point);
+    }
+
+    public CGFloat lineWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineWidth);
+    }
+
+    public CGFloat miterLimit ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_miterLimit);
+    }
+
+    public void moveToPoint (NSPoint point)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveToPoint_1, point);
+    }
+
+    public void relativeCurveToPoint (NSPoint endPoint, NSPoint controlPoint1, NSPoint controlPoint2)
+    {
+        OS.objc_msgSend(this.id, OS.sel_relativeCurveToPoint_1controlPoint1_1controlPoint2_1, endPoint, controlPoint1, controlPoint2);
+    }
+
+    public void relativeLineToPoint (NSPoint point)
+    {
+        OS.objc_msgSend(this.id, OS.sel_relativeLineToPoint_1, point);
+    }
+
+    public void relativeMoveToPoint (NSPoint point)
+    {
+        OS.objc_msgSend(this.id, OS.sel_relativeMoveToPoint_1, point);
+    }
+
+    public void removeAllPoints ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllPoints);
+    }
+
+    public void setAssociatedPoints (NSPointArray points, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAssociatedPoints_1atIndex_1, points, index);
+    }
+
+    public void setCachesBezierPath (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCachesBezierPath_1, flag);
+    }
+
+    public void setClip ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setClip);
+    }
+
+    public static void setDefaultFlatness (CGFloat flatness)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultFlatness_1, flatness);
+    }
+
+    public static void setDefaultLineCapStyle (objc.id lineCapStyle)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineCapStyle_1, lineCapStyle);
+    }
+
+    public static void setDefaultLineJoinStyle (objc.id lineJoinStyle)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineJoinStyle_1, lineJoinStyle);
+    }
+
+    public static void setDefaultLineWidth (CGFloat lineWidth)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultLineWidth_1, lineWidth);
+    }
+
+    public static void setDefaultMiterLimit (CGFloat limit)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultMiterLimit_1, limit);
+    }
+
+    public static void setDefaultWindingRule (objc.id windingRule)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_setDefaultWindingRule_1, windingRule);
+    }
+
+    public void setFlatness (CGFloat flatness)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFlatness_1, flatness);
+    }
+
+    public void setLineCapStyle (objc.id lineCapStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineCapStyle_1, lineCapStyle);
+    }
+
+    public void setLineDash (/*const*/CGFloat* pattern, NSInteger count, CGFloat phase)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineDash_1count_1phase_1, pattern, count, phase);
+    }
+
+    public void setLineJoinStyle (objc.id lineJoinStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineJoinStyle_1, lineJoinStyle);
+    }
+
+    public void setLineWidth (CGFloat lineWidth)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineWidth_1, lineWidth);
+    }
+
+    public void setMiterLimit (CGFloat miterLimit)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMiterLimit_1, miterLimit);
+    }
+
+    public void setWindingRule (objc.id windingRule)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindingRule_1, windingRule);
+    }
+
+    public void stroke ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stroke);
+    }
+
+    public static void strokeLineFromPoint (NSPoint point1, NSPoint point2)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeLineFromPoint_1toPoint_1, point1, point2);
+    }
+
+    public static void strokeRect (NSRect rect)
+    {
+        OS.objc_msgSend(OS.class_NSBezierPath, OS.sel_strokeRect_1, rect);
+    }
+
+    public void transformUsingAffineTransform (NSAffineTransform transform)
+    {
+        OS.objc_msgSend(this.id, OS.sel_transformUsingAffineTransform_1, transform !is null ? transform.id : null);
+    }
+
+    public objc.id windingRule ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_windingRule);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSBitmapImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,283 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSBitmapImageRep;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTIFFCompression
+{
+    NSTIFFCompressionNone = 1,
+    NSTIFFCompressionCCITTFAX3 = 3,
+    NSTIFFCompressionCCITTFAX4 = 4,
+    NSTIFFCompressionLZW = 5,
+    NSTIFFCompressionJPEG = 6,
+    NSTIFFCompressionNEXT = 32766,
+    NSTIFFCompressionPackBits = 32773,
+    NSTIFFCompressionOldJPEG = 32865
+}
+
+enum NSBitmapFormat
+{
+    NSAlphaFirstBitmapFormat = 1 << 0,
+    NSAlphaNonpremultipliedBitmapFormat = 1 << 1,
+    NSFloatingPointSamplesBitmapFormat = 1 << 2
+}
+
+public class NSBitmapImageRep : NSImageRep
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.id CGImage ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_CGImage);
+    }
+
+    public NSData TIFFRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentation);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public static NSData static_TIFFRepresentationOfImageRepsInArray_ (NSArray array)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1, array !is null ? array.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public static NSData static_TIFFRepresentationOfImageRepsInArray_usingCompression_factor_ (NSArray array, objc.id comp, float factor)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1usingCompression_1factor_1,
+                array !is null ? array.id : null, comp, factor);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData TIFFRepresentationUsingCompression (objc.id comp, float factor)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentationUsingCompression_1factor_1, comp, factor);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public objc.id bitmapData ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bitmapData);
+    }
+
+    public objc.id bitmapFormat ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bitmapFormat);
+    }
+
+    public NSInteger bitsPerPixel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bitsPerPixel);
+    }
+
+    public NSInteger bytesPerPlane ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bytesPerPlane);
+    }
+
+    public NSInteger bytesPerRow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bytesPerRow);
+    }
+
+    public bool canBeCompressedUsing (objc.id compression)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canBeCompressedUsing_1, compression) !is null;
+    }
+
+    public NSColor colorAtX (NSInteger x, NSInteger y)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorAtX_1y_1, x, y);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void colorizeByMappingGray (CGFloat midPoint, NSColor midPointColor, NSColor shadowColor, NSColor lightColor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_colorizeByMappingGray_1toColor_1blackMapping_1whiteMapping_1, midPoint,
+                midPointColor !is null ? midPointColor.id : null, shadowColor !is null ? shadowColor.id : null,
+                lightColor !is null ? lightColor.id : null);
+    }
+
+    public void getBitmapDataPlanes (objc.id data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getBitmapDataPlanes_1, data);
+    }
+
+    public void getCompression (NSTIFFCompression* compression, float* factor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getCompression_1factor_1, compression, factor);
+    }
+
+    public void getPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getPixel_1atX_1y_1, p, x, y);
+    }
+
+    public static void getTIFFCompressionTypes (/*const*/NSTIFFCompression** list, NSInteger* numTypes)
+    {
+        OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_getTIFFCompressionTypes_1count_1, list, numTypes);
+    }
+
+    public static id imageRepWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSArray imageRepsWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepsWithData_1, data !is null ? data.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSInteger incrementalLoadFromData (NSData data, bool complete)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_incrementalLoadFromData_1complete_1, data !is null ? data.id : null, complete);
+    }
+
+    public NSBitmapImageRep initForIncrementalLoad ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initForIncrementalLoad);
+        return result !is null ? this : null;
+    }
+
+    public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_ (
+            ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName,
+            NSBitmapFormat bitmapFormat, NSInteger rBytes, NSInteger pBits)
+    {
+        objc.id
+                result = OS.objc_msgSend(
+                        this.id,
+                        OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bitmapFormat_1bytesPerRow_1bitsPerPixel_1,
+                        planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, bitmapFormat, rBytes,
+                        pBits);
+        return result !is null ? this : null;
+    }
+
+    public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ (
+            ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, NSInteger rBytes, NSInteger pBits)
+    {
+        objc.id
+                result = OS.objc_msgSend(
+                        this.id,
+                        OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bytesPerRow_1bitsPerPixel_1,
+                        planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, rBytes, pBits);
+        return result !is null ? this : null;
+    }
+
+    public NSBitmapImageRep initWithCGImage (objc.id cgImage)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCGImage_1, cgImage);
+        return result !is null ? this : null;
+    }
+
+    public NSBitmapImageRep initWithCIImage (CIImage ciImage)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCIImage_1, ciImage !is null ? ciImage.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSBitmapImageRep initWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSBitmapImageRep initWithFocusedViewRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFocusedViewRect_1, rect);
+        return result !is null ? this : null;
+    }
+
+    public bool isPlanar ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isPlanar) !is null;
+    }
+
+    public static NSString localizedNameForTIFFCompressionType (objc.id compression)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_localizedNameForTIFFCompressionType_1, compression);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger numberOfPlanes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfPlanes);
+    }
+
+    public static NSData representationOfImageRepsInArray (NSArray imageReps, objc.id storageType, NSDictionary properties)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_representationOfImageRepsInArray_1usingType_1properties_1,
+                imageReps !is null ? imageReps.id : null, storageType, properties !is null ? properties.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData representationUsingType (objc.id storageType, NSDictionary properties)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representationUsingType_1properties_1, storageType,
+                properties !is null ? properties.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSInteger samplesPerPixel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_samplesPerPixel);
+    }
+
+    public void setColor (NSColor color, NSInteger x, NSInteger y)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColor_1atX_1y_1, color !is null ? color.id : null, x, y);
+    }
+
+    public void setCompression (NSTIFFCompression compression, float factor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCompression_1factor_1, compression, factor);
+    }
+
+    public void setPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPixel_1atX_1y_1, p, x, y);
+    }
+
+    public void setProperty (NSString property, id value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setProperty_1withValue_1, property !is null ? property.id : null, value !is null ? value.id : null);
+    }
+
+    public id valueForProperty (NSString property)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForProperty_1, property !is null ? property.id : null);
+        return result !is null ? new id(result) : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSBox.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSBox;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSUInteger NSBoxType;
+
+enum
+{
+    NSBoxPrimary = 0,
+    NSBoxSecondary = 1,
+    NSBoxSeparator = 2,
+    NSBoxOldStyle = 3,
+    NSBoxCustom = 4
+}
+
+enum NSTitlePosition
+{
+    NSNoTitle = 0,
+    NSAboveTop = 1,
+    NSAtTop = 2,
+    NSBelowTop = 3,
+    NSAboveBottom = 4,
+    NSAtBottom = 5,
+    NSBelowBottom = 6
+}
+
+public class NSBox : NSView
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSColor borderColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_borderColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSRect borderRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_borderRect);
+        return result;
+    }
+
+    public NSBorderType borderType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_borderType);
+    }
+
+    public CGFloat borderWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_borderWidth);
+    }
+
+    public NSBoxType boxType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_boxType);
+    }
+
+    public NSView contentView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSSize contentViewMargins ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentViewMargins);
+        return result;
+    }
+
+    public CGFloat cornerRadius ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_cornerRadius);
+    }
+
+    public NSColor fillColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fillColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public bool isTransparent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTransparent) !is null;
+    }
+
+    public void setBorderColor (NSColor borderColor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBorderColor_1, borderColor !is null ? borderColor.id : null);
+    }
+
+    public void setBorderType (NSBorderType aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBorderType_1, aType);
+    }
+
+    public void setBorderWidth (CGFloat borderWidth)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBorderWidth_1, borderWidth);
+    }
+
+    public void setBoxType (NSBoxType boxType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBoxType_1, boxType);
+    }
+
+    public void setContentView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setContentViewMargins (NSSize offsetSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentViewMargins_1, offsetSize);
+    }
+
+    public void setCornerRadius (CGFloat cornerRadius)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCornerRadius_1, cornerRadius);
+    }
+
+    public void setFillColor (NSColor fillColor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFillColor_1, fillColor !is null ? fillColor.id : null);
+    }
+
+    public void setFrameFromContentFrame (NSRect contentFrame)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameFromContentFrame_1, contentFrame);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setTitlePosition (NSTitlePosition aPosition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitlePosition_1, aPosition);
+    }
+
+    public void setTitleWithMnemonic (NSString StringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id : null);
+    }
+
+    public void setTransparent (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTransparent_1, flag);
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSCell titleCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleCell);
+        return result !is null ? new NSCell(result) : null;
+    }
+
+    public NSFont titleFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleFont);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSTitlePosition titlePosition ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_titlePosition);
+    }
+
+    public NSRect titleRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_titleRect);
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSBrowser.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,552 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSBrowser;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMatrix;
+import dwt.internal.cocoa.NSPoint : NSPointPointer;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScroller;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSBrowser : NSControl
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsArrowKeys ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsArrowKeys) !is null;
+    }
+
+    public void addColumn ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_addColumn);
+    }
+
+    public bool allowsBranchSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsBranchSelection) !is null;
+    }
+
+    public bool allowsEmptySelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsEmptySelection) !is null;
+    }
+
+    public bool allowsMultipleSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsMultipleSelection) !is null;
+    }
+
+    public bool allowsTypeSelect ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsTypeSelect) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public bool canDragRowsWithIndexes (NSIndexSet rowIndexes, NSInteger column, NSEvent event)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canDragRowsWithIndexes_1inColumn_1withEvent_1, rowIndexes !is null ? rowIndexes.id : null, column,
+                event !is null ? event.id : null) !is null;
+    }
+
+    public static objc.Class cellClass ()
+    {
+        return OS.objc_msgSend(OS.class_NSBrowser, OS.sel_cellClass);
+    }
+
+    public id cellPrototype ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cellPrototype);
+        return result !is null ? new id(result) : null;
+    }
+
+    public CGFloat columnContentWidthForColumnWidth (CGFloat columnWidth)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_columnContentWidthForColumnWidth_1, columnWidth);
+    }
+
+    public NSInteger columnOfMatrix (NSMatrix matrix)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_columnOfMatrix_1, matrix !is null ? matrix.id : null);
+    }
+
+    public objc.id columnResizingType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_columnResizingType);
+    }
+
+    public CGFloat columnWidthForColumnContentWidth (CGFloat columnContentWidth)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_columnWidthForColumnContentWidth_1, columnContentWidth);
+    }
+
+    public NSString columnsAutosaveName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_columnsAutosaveName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void displayAllColumns ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayAllColumns);
+    }
+
+    public void displayColumn (NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayColumn_1, column);
+    }
+
+    public void doClick (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_doClick_1, sender !is null ? sender.id : null);
+    }
+
+    public void doDoubleClick (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_doDoubleClick_1, sender !is null ? sender.id : null);
+    }
+
+    public SEL doubleAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_doubleAction);
+    }
+
+    public NSImage draggingImageForRowsWithIndexes (NSIndexSet rowIndexes, NSInteger column, NSEvent event, NSPointPointer dragImageOffset)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_draggingImageForRowsWithIndexes_1inColumn_1withEvent_1offset_1,
+                rowIndexes !is null ? rowIndexes.id : null, column, event !is null ? event.id : null, dragImageOffset);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public void drawTitleOfColumn (NSInteger column, NSRect aRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawTitleOfColumn_1inRect_1, column, aRect);
+    }
+
+    public NSInteger firstVisibleColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_firstVisibleColumn);
+    }
+
+    public NSRect frameOfColumn (NSInteger column)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frameOfColumn_1, column);
+        return result;
+    }
+
+    public NSRect frameOfInsideOfColumn (NSInteger column)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frameOfInsideOfColumn_1, column);
+        return result;
+    }
+
+    public bool hasHorizontalScroller ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasHorizontalScroller) !is null;
+    }
+
+    public bool isLoaded ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLoaded) !is null;
+    }
+
+    public bool isTitled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTitled) !is null;
+    }
+
+    public NSInteger lastColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lastColumn);
+    }
+
+    public NSInteger lastVisibleColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lastVisibleColumn);
+    }
+
+    public void loadColumnZero ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_loadColumnZero);
+    }
+
+    public id loadedCellAtRow (NSInteger row, NSInteger col)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_loadedCellAtRow_1column_1, row, col);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.Class matrixClass ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_matrixClass);
+    }
+
+    public NSMatrix matrixInColumn (NSInteger column)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_matrixInColumn_1, column);
+        return result !is null ? new NSMatrix(result) : null;
+    }
+
+    public NSInteger maxVisibleColumns ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_maxVisibleColumns);
+    }
+
+    public CGFloat minColumnWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_minColumnWidth);
+    }
+
+    public NSInteger numberOfVisibleColumns ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfVisibleColumns);
+    }
+
+    public NSString path ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_path);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathSeparator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathSeparator);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathToColumn (NSInteger column)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathToColumn_1, column);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool prefersAllColumnUserResizing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_prefersAllColumnUserResizing) !is null;
+    }
+
+    public void reloadColumn (NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadColumn_1, column);
+    }
+
+    public static void removeSavedColumnsWithAutosaveName (NSString name)
+    {
+        OS.objc_msgSend(OS.class_NSBrowser, OS.sel_removeSavedColumnsWithAutosaveName_1, name !is null ? name.id : null);
+    }
+
+    public bool reusesColumns ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_reusesColumns) !is null;
+    }
+
+    public void scrollColumnToVisible (NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollColumnToVisible_1, column);
+    }
+
+    public void scrollColumnsLeftBy (NSInteger shiftAmount)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollColumnsLeftBy_1, shiftAmount);
+    }
+
+    public void scrollColumnsRightBy (NSInteger shiftAmount)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollColumnsRightBy_1, shiftAmount);
+    }
+
+    public void scrollViaScroller (NSScroller sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollViaScroller_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectAll_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectRow (NSInteger row, NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectRow_1inColumn_1, row, column);
+    }
+
+    public void selectRowIndexes (NSIndexSet indexes, NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectRowIndexes_1inColumn_1, indexes !is null ? indexes.id : null, column);
+    }
+
+    public id selectedCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id selectedCellInColumn (NSInteger column)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedCellInColumn_1, column);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray selectedCells ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedCells);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSInteger selectedColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectedColumn);
+    }
+
+    public NSInteger selectedRowInColumn (NSInteger column)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectedRowInColumn_1, column);
+    }
+
+    public NSIndexSet selectedRowIndexesInColumn (NSInteger column)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedRowIndexesInColumn_1, column);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public bool sendAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendAction) !is null;
+    }
+
+    public bool sendsActionOnArrowKeys ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendsActionOnArrowKeys) !is null;
+    }
+
+    public bool separatesColumns ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_separatesColumns) !is null;
+    }
+
+    public void setAcceptsArrowKeys (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAcceptsArrowKeys_1, flag);
+    }
+
+    public void setAllowsBranchSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsBranchSelection_1, flag);
+    }
+
+    public void setAllowsEmptySelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsEmptySelection_1, flag);
+    }
+
+    public void setAllowsMultipleSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsMultipleSelection_1, flag);
+    }
+
+    public void setAllowsTypeSelect (bool value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsTypeSelect_1, value);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    //public void setCellClass(Class factoryId) {
+    //  OS.objc_msgSend(this.id, OS.sel_setCellClass_1, factoryId);
+    //}
+
+    public void setCellPrototype (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCellPrototype_1, aCell !is null ? aCell.id : null);
+    }
+
+    public void setColumnResizingType (objc.id columnResizingType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColumnResizingType_1, columnResizingType);
+    }
+
+    public void setColumnsAutosaveName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColumnsAutosaveName_1, name !is null ? name.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDoubleAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleAction_1, aSelector);
+    }
+
+    public void setDraggingSourceOperationMask (objc.id mask, bool isLocal)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDraggingSourceOperationMask_1forLocal_1, mask, isLocal);
+    }
+
+    public void setHasHorizontalScroller (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasHorizontalScroller_1, flag);
+    }
+
+    public void setLastColumn (NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLastColumn_1, column);
+    }
+
+    public void setMatrixClass (Class factoryId)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMatrixClass_1, factoryId);
+    }
+
+    public void setMaxVisibleColumns (NSInteger columnCount)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxVisibleColumns_1, columnCount);
+    }
+
+    public void setMinColumnWidth (CGFloat columnWidth)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinColumnWidth_1, columnWidth);
+    }
+
+    public bool setPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public void setPathSeparator (NSString newString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPathSeparator_1, newString !is null ? newString.id : null);
+    }
+
+    public void setPrefersAllColumnUserResizing (bool prefersAllColumnResizing)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrefersAllColumnUserResizing_1, prefersAllColumnResizing);
+    }
+
+    public void setReusesColumns (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReusesColumns_1, flag);
+    }
+
+    public void setSendsActionOnArrowKeys (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSendsActionOnArrowKeys_1, flag);
+    }
+
+    public void setSeparatesColumns (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSeparatesColumns_1, flag);
+    }
+
+    public void setTakesTitleFromPreviousColumn (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTakesTitleFromPreviousColumn_1, flag);
+    }
+
+    public void setTitle (NSString aString, NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1ofColumn_1, aString !is null ? aString.id : null, column);
+    }
+
+    public void setTitled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitled_1, flag);
+    }
+
+    public void setWidth (CGFloat columnWidth, NSInteger columnIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWidth_1ofColumn_1, columnWidth, columnIndex);
+    }
+
+    public bool takesTitleFromPreviousColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_takesTitleFromPreviousColumn) !is null;
+    }
+
+    public void tile ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_tile);
+    }
+
+    public NSRect titleFrameOfColumn (NSInteger column)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_titleFrameOfColumn_1, column);
+        return result;
+    }
+
+    public CGFloat titleHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_titleHeight);
+    }
+
+    public NSString titleOfColumn (NSInteger column)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleOfColumn_1, column);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void updateScroller ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateScroller);
+    }
+
+    public void validateVisibleColumns ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_validateVisibleColumns);
+    }
+
+    public CGFloat widthOfColumn (NSInteger column)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_widthOfColumn_1, column);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSBrowserCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSBrowserCell;
+
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSBrowserCell : NSCell
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSImage alternateImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_alternateImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public static NSImage branchImage ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBrowserCell, OS.sel_branchImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSColor highlightColorInView (NSView controlView)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightColorInView_1, controlView !is null ? controlView.id : null);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSImage highlightedBranchImage ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBrowserCell, OS.sel_highlightedBranchImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public bool isLeaf ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLeaf) !is null;
+    }
+
+    public bool isLoaded ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLoaded) !is null;
+    }
+
+    public void reset ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reset);
+    }
+
+    public void set ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_set);
+    }
+
+    public void setAlternateImage (NSImage newAltImage)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateImage_1, newAltImage !is null ? newAltImage.id : null);
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setLeaf (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLeaf_1, flag);
+    }
+
+    public void setLoaded (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLoaded_1, flag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSBundle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,283 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSBundle;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSBundle : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSArray allBundles ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allBundles);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray allFrameworks ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allFrameworks);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString builtInPlugInsPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_builtInPlugInsPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSBundle bundleForClass (objc.Class aClass)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleForClass_1, aClass);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public NSString bundleIdentifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bundleIdentifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString bundlePath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bundlePath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSBundle bundleWithIdentifier (NSString identifier)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithIdentifier_1, identifier !is null ? identifier.id : null);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public static NSBundle bundleWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public objc.Class classNamed (NSString className)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_classNamed_1, className !is null ? className.id : null);
+    }
+
+    public NSString developmentLocalization ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_developmentLocalization);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray executableArchitectures ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_executableArchitectures);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString executablePath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_executablePath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary infoDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_infoDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSBundle initWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPath_1, path !is null ? path.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isLoaded ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLoaded) !is null;
+    }
+
+    //public bool load() {
+    //  return OS.objc_msgSend(this.id, OS.sel_load) !is null;
+    //}
+
+    public bool loadAndReturnError (objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_loadAndReturnError_1, error) !is null;
+    }
+
+    public NSArray localizations ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizations);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSDictionary localizedInfoDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedInfoDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString localizedStringForKey (NSString key, NSString value, NSString tableName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedStringForKey_1value_1table_1, key !is null ? key.id : null,
+                value !is null ? value.id : null, tableName !is null ? tableName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSBundle mainBundle ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_mainBundle);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public id objectForInfoDictionaryKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForInfoDictionaryKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString pathForAuxiliaryExecutable (NSString executableName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForAuxiliaryExecutable_1, executableName !is null ? executableName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathForResource_ofType_ (NSString name, NSString ext)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1, name !is null ? name.id : null, ext !is null ? ext.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString subpath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id : null,
+                ext !is null ? ext.id : null, subpath !is null ? subpath.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString static_pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString bundlePath)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id : null,
+                ext !is null ? ext.id : null, bundlePath !is null ? bundlePath.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString pathForResource_ofType_inDirectory_forLocalization_ (NSString name, NSString ext, NSString subpath, NSString localizationName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1inDirectory_1forLocalization_1, name !is null ? name.id : null,
+                ext !is null ? ext.id : null, subpath !is null ? subpath.id : null, localizationName !is null ? localizationName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSArray static_pathsForResourcesOfType_inDirectory_ (NSString ext, NSString bundlePath)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id : null,
+                bundlePath !is null ? bundlePath.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray pathsForResourcesOfType_inDirectory_ (NSString ext, NSString subpath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id : null,
+                subpath !is null ? subpath.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray pathsForResourcesOfType_inDirectory_forLocalization_ (NSString ext, NSString subpath, NSString localizationName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsForResourcesOfType_1inDirectory_1forLocalization_1, ext !is null ? ext.id : null,
+                subpath !is null ? subpath.id : null, localizationName !is null ? localizationName.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray preferredLocalizations ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_preferredLocalizations);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray static_preferredLocalizationsFromArray_ (NSArray localizationsArray)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1,
+                localizationsArray !is null ? localizationsArray.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray static_preferredLocalizationsFromArray_forPreferences_ (NSArray localizationsArray, NSArray preferencesArray)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1forPreferences_1,
+                localizationsArray !is null ? localizationsArray.id : null, preferencesArray !is null ? preferencesArray.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool preflightAndReturnError (objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preflightAndReturnError_1, error) !is null;
+    }
+
+    public objc.Class principalClass ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_principalClass);
+    }
+
+    public NSString privateFrameworksPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_privateFrameworksPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString resourcePath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resourcePath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString sharedFrameworksPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sharedFrameworksPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString sharedSupportPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sharedSupportPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool unload ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_unload) !is null;
+    }
+
+    public static bool loadNibFile (id fileName, id dict, id zone)
+    {
+        return OS.objc_msgSend(OS.class_NSBundle, OS.sel_loadNibFile_1externalNameTable_1withZone_1, fileName.id, dict.id, 0) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSButton.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSButton;
+
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSSound;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSButton : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool allowsMixedState ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsMixedState) !is null;
+    }
+
+    public NSImage alternateImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_alternateImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSString alternateTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_alternateTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSAttributedString attributedAlternateTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedAlternateTitle);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSAttributedString attributedTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedTitle);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public objc.id bezelStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bezelStyle);
+    }
+
+    public void getPeriodicDelay (float* delay, float* interval)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getPeriodicDelay_1interval_1, delay, interval);
+    }
+
+    public void highlight (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_highlight_1, flag);
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public objc.id imagePosition ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imagePosition);
+    }
+
+    public bool isBordered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBordered) !is null;
+    }
+
+    public bool isTransparent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTransparent) !is null;
+    }
+
+    public NSString keyEquivalent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEquivalent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger keyEquivalentModifierMask ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_keyEquivalentModifierMask);
+    }
+
+    public bool performKeyEquivalent (NSEvent key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performKeyEquivalent_1, key !is null ? key.id : null) !is null;
+    }
+
+    public void setAllowsMixedState (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsMixedState_1, flag);
+    }
+
+    public void setAlternateImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateImage_1, image !is null ? image.id : null);
+    }
+
+    public void setAlternateTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setAttributedAlternateTitle (NSAttributedString obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedAlternateTitle_1, obj !is null ? obj.id : null);
+    }
+
+    public void setAttributedTitle (NSAttributedString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setBezelStyle (objc.id bezelStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezelStyle_1, bezelStyle);
+    }
+
+    public void setBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBordered_1, flag);
+    }
+
+    public void setButtonType (objc.id aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setButtonType_1, aType);
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setImagePosition (objc.id aPosition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImagePosition_1, aPosition);
+    }
+
+    public void setKeyEquivalent (NSString charCode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalent_1, charCode !is null ? charCode.id : null);
+    }
+
+    public void setKeyEquivalentModifierMask (NSUInteger mask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalentModifierMask_1, mask);
+    }
+
+    public void setNextState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNextState);
+    }
+
+    public void setPeriodicDelay (float delay, float interval)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPeriodicDelay_1interval_1, delay, interval);
+    }
+
+    public void setShowsBorderOnlyWhileMouseInside (bool show)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsBorderOnlyWhileMouseInside_1, show);
+    }
+
+    public void setSound (NSSound aSound)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSound_1, aSound !is null ? aSound.id : null);
+    }
+
+    public void setState (NSInteger value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setState_1, value);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleWithMnemonic (NSString StringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id : null);
+    }
+
+    public void setTransparent (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTransparent_1, flag);
+    }
+
+    public bool showsBorderOnlyWhileMouseInside ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsBorderOnlyWhileMouseInside) !is null;
+    }
+
+    public NSSound sound ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sound);
+        return result !is null ? new NSSound(result) : null;
+    }
+
+    public NSInteger state ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_state);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSButtonCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSButtonCell;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSound;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSButtonCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSImage alternateImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_alternateImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSString alternateMnemonic ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_alternateMnemonic);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger alternateMnemonicLocation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_alternateMnemonicLocation);
+    }
+
+    public NSString alternateTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_alternateTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSAttributedString attributedAlternateTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedAlternateTitle);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSAttributedString attributedTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedTitle);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public objc.id bezelStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bezelStyle);
+    }
+
+    public void drawBezelWithFrame (NSRect frame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawBezelWithFrame_1inView_1, frame, controlView !is null ? controlView.id : null);
+    }
+
+    public void drawImage (NSImage image, NSRect frame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawImage_1withFrame_1inView_1, image !is null ? image.id : null, frame,
+                controlView !is null ? controlView.id : null);
+    }
+
+    public NSRect drawTitle (NSAttributedString title, NSRect frame, NSView controlView)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_drawTitle_1withFrame_1inView_1, title !is null ? title.id : null, frame,
+                controlView !is null ? controlView.id : null);
+        return result;
+    }
+
+    public void getPeriodicDelay (float* delay, float* interval)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getPeriodicDelay_1interval_1, delay, interval);
+    }
+
+    public objc.id gradientType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_gradientType);
+    }
+
+    public NSInteger highlightsBy ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_highlightsBy);
+    }
+
+    public bool imageDimsWhenDisabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageDimsWhenDisabled) !is null;
+    }
+
+    public objc.id imagePosition ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imagePosition);
+    }
+
+    public objc.id imageScaling ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageScaling);
+    }
+
+    public bool isOpaque ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOpaque) !is null;
+    }
+
+    public bool isTransparent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTransparent) !is null;
+    }
+
+    public NSString keyEquivalent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEquivalent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSFont keyEquivalentFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEquivalentFont);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSUInteger keyEquivalentModifierMask ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_keyEquivalentModifierMask);
+    }
+
+    public void mouseEntered (NSEvent event)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseEntered_1, event !is null ? event.id : null);
+    }
+
+    public void mouseExited (NSEvent event)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseExited_1, event !is null ? event.id : null);
+    }
+
+    public void performClick (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performClick_1, sender !is null ? sender.id : null);
+    }
+
+    public void setAlternateImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateImage_1, image !is null ? image.id : null);
+    }
+
+    public void setAlternateMnemonicLocation (NSUInteger location)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateMnemonicLocation_1, location);
+    }
+
+    public void setAlternateTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setAlternateTitleWithMnemonic (NSString StringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id : null);
+    }
+
+    public void setAttributedAlternateTitle (NSAttributedString obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedAlternateTitle_1, obj !is null ? obj.id : null);
+    }
+
+    public void setAttributedTitle (NSAttributedString obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedTitle_1, obj !is null ? obj.id : null);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBezelStyle (objc.id bezelStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezelStyle_1, bezelStyle);
+    }
+
+    public void setButtonType (objc.id aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setButtonType_1, aType);
+    }
+
+    public void setFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setGradientType (objc.id type)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGradientType_1, type);
+    }
+
+    public void setHighlightsBy (NSInteger aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHighlightsBy_1, aType);
+    }
+
+    public void setImageDimsWhenDisabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageDimsWhenDisabled_1, flag);
+    }
+
+    public void setImagePosition (objc.id aPosition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImagePosition_1, aPosition);
+    }
+
+    public void setImageScaling (objc.id scaling)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageScaling_1, scaling);
+    }
+
+    public void setKeyEquivalent (NSString aKeyEquivalent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalent_1, aKeyEquivalent !is null ? aKeyEquivalent.id : null);
+    }
+
+    public void setKeyEquivalentFont_ (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalentFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setKeyEquivalentFont_size_ (NSString fontName, CGFloat fontSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalentFont_1size_1, fontName !is null ? fontName.id : null, fontSize);
+    }
+
+    public void setKeyEquivalentModifierMask (NSUInteger mask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalentModifierMask_1, mask);
+    }
+
+    public void setPeriodicDelay (float delay, float interval)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPeriodicDelay_1interval_1, delay, interval);
+    }
+
+    public void setShowsBorderOnlyWhileMouseInside (bool show)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsBorderOnlyWhileMouseInside_1, show);
+    }
+
+    public void setShowsStateBy (NSInteger aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsStateBy_1, aType);
+    }
+
+    public void setSound (NSSound aSound)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSound_1, aSound !is null ? aSound.id : null);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleWithMnemonic (NSString StringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id : null);
+    }
+
+    public void setTransparent (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTransparent_1, flag);
+    }
+
+    public bool showsBorderOnlyWhileMouseInside ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsBorderOnlyWhileMouseInside) !is null;
+    }
+
+    public NSInteger showsStateBy ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsStateBy);
+    }
+
+    public NSSound sound ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sound);
+        return result !is null ? new NSSound(result) : null;
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCIImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCIImageRep;
+
+import dwt.internal.cocoa.CIImage;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCIImageRep : NSImageRep
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public CIImage CIImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_CIImage);
+        return result !is null ? new CIImage(result) : null;
+    }
+
+    public static id imageRepWithCIImage (CIImage image)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCIImageRep, OS.sel_imageRepWithCIImage_1, image !is null ? image.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSCIImageRep initWithCIImage (CIImage image)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCIImage_1, image !is null ? image.id : null);
+        return result !is null ? this : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCachedImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCachedImageRep;
+
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCachedImageRep : NSImageRep
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSCachedImageRep initWithSize (NSSize size, objc.id depth, bool flag, bool alpha)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSize_1depth_1separate_1alpha_1, size, depth, flag, alpha);
+        return result !is null ? this : null;
+    }
+
+    public NSCachedImageRep initWithWindow (NSWindow win, NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithWindow_1rect_1, win !is null ? win.id : null, rect);
+        return result !is null ? this : null;
+    }
+
+    public NSRect rect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rect);
+        return result;
+    }
+
+    public NSWindow window ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_window);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCachedURLResponse.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCachedURLResponse;
+
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSURLResponse;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCachedURLResponse : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData data ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_data);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSCachedURLResponse initWithResponse_data_ (NSURLResponse response, NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithResponse_1data_1, response !is null ? response.id : null,
+                data !is null ? data.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSCachedURLResponse initWithResponse_data_userInfo_storagePolicy_ (NSURLResponse response, NSData data, NSDictionary userInfo,
+            objc.id storagePolicy)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithResponse_1data_1userInfo_1storagePolicy_1, response !is null ? response.id : null,
+                data !is null ? data.id : null, userInfo !is null ? userInfo.id : null, storagePolicy);
+        return result !is null ? this : null;
+    }
+
+    public NSURLResponse response ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_response);
+        return result !is null ? new NSURLResponse(result) : null;
+    }
+
+    public objc.id storagePolicy ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_storagePolicy);
+    }
+
+    public NSDictionary userInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_userInfo);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCalendar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCalendar;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDateComponents;
+import dwt.internal.cocoa.NSLocale;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTimeZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCalendar : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static id autoupdatingCurrentCalendar ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCalendar, OS.sel_autoupdatingCurrentCalendar);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString calendarIdentifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_calendarIdentifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDateComponents components_fromDate_ (NSUInteger unitFlags, NSDate date)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_components_1fromDate_1, unitFlags, date !is null ? date.id : null);
+        return result !is null ? new NSDateComponents(result) : null;
+    }
+
+    public NSDateComponents components_fromDate_toDate_options_ (NSUInteger unitFlags, NSDate startingDate, NSDate resultDate, NSUInteger opts)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_components_1fromDate_1toDate_1options_1, unitFlags,
+                startingDate !is null ? startingDate.id : null, resultDate !is null ? resultDate.id : null, opts);
+        return result !is null ? new NSDateComponents(result) : null;
+    }
+
+    public static id currentCalendar ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCalendar, OS.sel_currentCalendar);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDate dateByAddingComponents (NSDateComponents comps, NSDate date, NSUInteger opts)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateByAddingComponents_1toDate_1options_1, comps !is null ? comps.id : null,
+                date !is null ? date.id : null, opts);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSDate dateFromComponents (NSDateComponents comps)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateFromComponents_1, comps !is null ? comps.id : null);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSUInteger firstWeekday ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_firstWeekday);
+    }
+
+    public NSCalendar initWithCalendarIdentifier (NSString ident)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCalendarIdentifier_1, ident !is null ? ident.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSLocale locale ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_locale);
+        return result !is null ? new NSLocale(result) : null;
+    }
+
+    public NSRange maximumRangeOfUnit (objc.id unit)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_maximumRangeOfUnit_1, unit);
+        return result;
+    }
+
+    public NSUInteger minimumDaysInFirstWeek ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_minimumDaysInFirstWeek);
+    }
+
+    public NSRange minimumRangeOfUnit (objc.id unit)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_minimumRangeOfUnit_1, unit);
+        return result;
+    }
+
+    public NSUInteger ordinalityOfUnit (objc.id smaller, objc.id larger, NSDate date)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_ordinalityOfUnit_1inUnit_1forDate_1, smaller, larger, date !is null ? date.id : null);
+    }
+
+    public NSRange rangeOfUnit_inUnit_forDate_ (objc.id smaller, objc.id larger, NSDate date)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfUnit_1inUnit_1forDate_1, smaller, larger, date !is null ? date.id : null);
+        return result;
+    }
+
+    public bool rangeOfUnit_startDate_interval_forDate_ (objc.id unit, objc.id datep, objc.id tip, NSDate date)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rangeOfUnit_1startDate_1interval_1forDate_1, unit, datep, tip, date !is null ? date.id : null) !is null;
+    }
+
+    public void setFirstWeekday (NSUInteger weekday)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFirstWeekday_1, weekday);
+    }
+
+    public void setLocale (NSLocale locale)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocale_1, locale !is null ? locale.id : null);
+    }
+
+    public void setMinimumDaysInFirstWeek (NSUInteger mdw)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinimumDaysInFirstWeek_1, mdw);
+    }
+
+    public void setTimeZone (NSTimeZone tz)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeZone_1, tz !is null ? tz.id : null);
+    }
+
+    public NSTimeZone timeZone ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCalendarDate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCalendarDate;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTimeZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCalendarDate : NSDate
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSCalendarDate calendarDate ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_calendarDate);
+        return result !is null ? new NSCalendarDate(result) : null;
+    }
+
+    public NSString calendarFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_calendarFormat);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSCalendarDate dateByAddingYears (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateByAddingYears_1months_1days_1hours_1minutes_1seconds_1, year, month, day, hour, minute,
+                second);
+        return result is this.id ? this : (result !is null ? new NSCalendarDate(result) : null);
+    }
+
+    public static id static_dateWithString_calendarFormat_ (NSString description, NSString format)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithString_1calendarFormat_1,
+                description !is null ? description.id : null, format !is null ? format.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dateWithString_calendarFormat_locale_ (NSString description, NSString format, id locale)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithString_1calendarFormat_1locale_1,
+                description !is null ? description.id : null, format !is null ? format.id : null, locale !is null ? locale.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSCalendarDate dateWithYear (NSInteger year, NSInteger month, NSInteger day, NSInteger hour, NSInteger minute, NSInteger second, NSTimeZone aTimeZone)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCalendarDate, OS.sel_dateWithYear_1month_1day_1hour_1minute_1second_1timeZone_1, year, month,
+                day, hour, minute, second, aTimeZone !is null ? aTimeZone.id : null);
+        return result !is null ? new NSCalendarDate(result) : null;
+    }
+
+    public NSInteger dayOfCommonEra ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dayOfCommonEra);
+    }
+
+    public NSInteger dayOfMonth ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dayOfMonth);
+    }
+
+    public NSInteger dayOfWeek ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dayOfWeek);
+    }
+
+    public NSInteger dayOfYear ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dayOfYear);
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithCalendarFormat_ (NSString format)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithCalendarFormat_1, format !is null ? format.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithCalendarFormat_locale_ (NSString format, id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithCalendarFormat_1locale_1, format !is null ? format.id : null,
+                locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithLocale (id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger hourOfDay ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hourOfDay);
+    }
+
+    public NSCalendarDate initWithString_ (NSString description)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, description !is null ? description.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSCalendarDate initWithString_calendarFormat_ (NSString description, NSString format)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1calendarFormat_1, description !is null ? description.id : null,
+                format !is null ? format.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSCalendarDate initWithString_calendarFormat_locale_ (NSString description, NSString format, id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1calendarFormat_1locale_1, description !is null ? description.id : null,
+                format !is null ? format.id : null, locale !is null ? locale.id : null);
+        return result !is null ? this : null;
+    }
+
+    public id initWithYear (NSInteger year, NSUInteger month, NSUInteger day, NSUInteger hour, NSUInteger minute, NSUInteger second, NSTimeZone aTimeZone)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithYear_1month_1day_1hour_1minute_1second_1timeZone_1, year, month, day, hour, minute,
+                second, aTimeZone !is null ? aTimeZone.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger minuteOfHour ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_minuteOfHour);
+    }
+
+    public NSInteger monthOfYear ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_monthOfYear);
+    }
+
+    public NSInteger secondOfMinute ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_secondOfMinute);
+    }
+
+    public void setCalendarFormat (NSString format)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCalendarFormat_1, format !is null ? format.id : null);
+    }
+
+    public void setTimeZone (NSTimeZone aTimeZone)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeZone_1, aTimeZone !is null ? aTimeZone.id : null);
+    }
+
+    public NSTimeZone timeZone ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+    public NSInteger yearOfCommonEra ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_yearOfCommonEra);
+    }
+
+    public void years (NSInteger* yp, NSInteger* mop, NSInteger* dp, NSInteger* hp, NSInteger* mip, NSInteger* sp, NSCalendarDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_years_1months_1days_1hours_1minutes_1seconds_1sinceDate_1, yp, mop, dp, hp, mip, sp,
+                date !is null ? date.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,868 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCell;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSFormatter;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+/*alias NSUInteger NSControlSize;*/
+
+enum NSControlSize : NSUInteger
+{
+    NSRegularControlSize,
+    NSSmallControlSize,
+    NSMiniControlSize
+}
+
+alias NSControlSize.NSRegularControlSize NSRegularControlSize;
+alias NSControlSize.NSSmallControlSize NSSmallControlSize;
+alias NSControlSize.NSMiniControlSize NSMiniControlSize;
+
+/*alias NSUInteger NSCellAttribute;*/
+
+enum NSCellAttribute : NSUInteger
+{
+    NSCellDisabled = 0,
+    NSCellState = 1,
+    NSPushInCell = 2,
+    NSCellEditable = 3,
+    NSChangeGrayCell = 4,
+    NSCellHighlighted = 5,
+    NSCellLightsByContents = 6,
+    NSCellLightsByGray = 7,
+    NSChangeBackgroundCell = 8,
+    NSCellLightsByBackground = 9,
+    NSCellIsBordered = 10,
+    NSCellHasOverlappingImage = 11,
+    NSCellHasImageHorizontal = 12,
+    NSCellHasImageOnLeftOrBottom = 13,
+    NSCellChangesContents = 14,
+    NSCellIsInsetButton = 15,
+    NSCellAllowsMixedState = 16
+}
+
+alias NSCellAttribute.NSCellDisabled NSCellDisabled;
+alias NSCellAttribute.NSCellState NSCellState;
+alias NSCellAttribute.NSPushInCell NSPushInCell;
+alias NSCellAttribute.NSCellEditable NSCellEditable;
+alias NSCellAttribute.NSChangeGrayCell NSChangeGrayCell;
+alias NSCellAttribute.NSCellHighlighted NSCellHighlighted;
+alias NSCellAttribute.NSCellLightsByContents NSCellLightsByContents;
+alias NSCellAttribute.NSCellLightsByGray NSCellLightsByGray;
+alias NSCellAttribute.NSChangeBackgroundCell NSChangeBackgroundCell;
+alias NSCellAttribute.NSCellLightsByBackground NSCellLightsByBackground;
+alias NSCellAttribute.NSCellIsBordered NSCellIsBordered;
+alias NSCellAttribute.NSCellHasOverlappingImage NSCellHasOverlappingImage;
+alias NSCellAttribute.NSCellHasImageHorizontal NSCellHasImageHorizontal;
+alias NSCellAttribute.NSCellHasImageOnLeftOrBottom NSCellHasImageOnLeftOrBottom;
+alias NSCellAttribute.NSCellChangesContents NSCellChangesContents;
+alias NSCellAttribute.NSCellIsInsetButton NSCellIsInsetButton;
+alias NSCellAttribute.NSCellAllowsMixedState NSCellAllowsMixedState;
+
+enum NSControlTint : NSUInteger
+{
+    NSDefaultControlTint = 0,
+    NSBlueControlTint = 1,
+    NSGraphiteControlTint = 6,
+    NSClearControlTint = 7
+}
+
+alias NSControlTint.NSDefaultControlTint NSDefaultControlTint;
+alias NSControlTint.NSBlueControlTint NSBlueControlTint;
+alias NSControlTint.NSGraphiteControlTint NSGraphiteControlTint;
+alias NSControlTint.NSClearControlTint NSClearControlTint;
+
+public class NSCell : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsFirstResponder) !is null;
+    }
+
+    public objc.SEL action ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_action);
+    }
+
+    public objc.id alignment ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_alignment);
+    }
+
+    public bool allowsEditingTextAttributes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsEditingTextAttributes) !is null;
+    }
+
+    public bool allowsMixedState ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsMixedState) !is null;
+    }
+
+    public bool allowsUndo ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsUndo) !is null;
+    }
+
+    public NSAttributedString attributedStringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedStringValue);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public objc.id backgroundStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_backgroundStyle);
+    }
+
+    public objc.id baseWritingDirection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_baseWritingDirection);
+    }
+
+    public void calcDrawInfo (NSRect aRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_calcDrawInfo_1, aRect);
+    }
+
+    public NSInteger cellAttribute (objc.id aParameter)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_cellAttribute_1, aParameter);
+    }
+
+    public NSSize cellSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_cellSize);
+        return result;
+    }
+
+    public NSSize cellSizeForBounds (NSRect aRect)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_cellSizeForBounds_1, aRect);
+        return result;
+    }
+
+    public objc.id compare (id otherCell)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compare_1, otherCell !is null ? otherCell.id : null);
+    }
+
+    public bool continueTracking (NSPoint lastPoint, NSPoint currentPoint, NSView controlView)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_continueTracking_1at_1inView_1, lastPoint, currentPoint, controlView !is null ? controlView.id : null) !is null;
+    }
+
+    public objc.id controlSize ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_controlSize);
+    }
+
+    public objc.id controlTint ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_controlTint);
+    }
+
+    public NSView controlView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_controlView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public static objc.id defaultFocusRingType ()
+    {
+        return OS.objc_msgSend(OS.class_NSCell, OS.sel_defaultFocusRingType);
+    }
+
+    public static NSMenu defaultMenu ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCell, OS.sel_defaultMenu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public double doubleValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+    }
+
+    public void drawInteriorWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInteriorWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public void drawWithExpansionFrame (NSRect cellFrame, NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawWithExpansionFrame_1inView_1, cellFrame, view !is null ? view.id : null);
+    }
+
+    public void drawWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public NSRect drawingRectForBounds (NSRect theRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_drawingRectForBounds_1, theRect);
+        return result;
+    }
+
+    public void editWithFrame (NSRect aRect, NSView controlView, NSText textObj, id anObject, NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_editWithFrame_1inView_1editor_1delegate_1event_1, aRect, controlView !is null ? controlView.id : null,
+                textObj !is null ? textObj.id : null, anObject !is null ? anObject.id : null, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void endEditing (NSText textObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_endEditing_1, textObj !is null ? textObj.id : null);
+    }
+
+    public NSInteger entryType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_entryType);
+    }
+
+    public NSRect expansionFrameWithFrame (NSRect cellFrame, NSView view)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_expansionFrameWithFrame_1inView_1, cellFrame, view !is null ? view.id : null);
+        return result;
+    }
+
+    public float floatValue ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatValue);
+    }
+
+    public objc.id focusRingType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_focusRingType);
+    }
+
+    public NSFont font ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public id formatter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_formatter);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void getPeriodicDelay (float* delay, float* interval)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getPeriodicDelay_1interval_1, delay, interval);
+    }
+
+    public bool hasValidObjectValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasValidObjectValue) !is null;
+    }
+
+    public void highlight (bool flag, NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_highlight_1withFrame_1inView_1, flag, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public NSColor highlightColorWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightColorWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSUInteger hitTestForEvent (NSEvent event, NSRect cellFrame, NSView controlView)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hitTestForEvent_1inRect_1ofView_1, event !is null ? event.id : null, cellFrame,
+                controlView !is null ? controlView.id : null);
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSRect imageRectForBounds (NSRect theRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_imageRectForBounds_1, theRect);
+        return result;
+    }
+
+    public bool importsGraphics ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_importsGraphics) !is null;
+    }
+
+    public NSCell initImageCell (NSImage image)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initImageCell_1, image !is null ? image.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSCell initTextCell (NSString aString)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initTextCell_1, aString !is null ? aString.id : null);
+        return result !is null ? this : null;
+    }
+
+    public int intValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_intValue);
+    }
+
+    public int integerValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_integerValue);
+    }
+
+    public objc.id interiorBackgroundStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_interiorBackgroundStyle);
+    }
+
+    public bool isBezeled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBezeled) !is null;
+    }
+
+    public bool isBordered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBordered) !is null;
+    }
+
+    public bool isContinuous ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isContinuous) !is null;
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public bool isEntryAcceptable (NSString aString)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEntryAcceptable_1, aString !is null ? aString.id : null) !is null;
+    }
+
+    public bool isHighlighted ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHighlighted) !is null;
+    }
+
+    public bool isOpaque ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOpaque) !is null;
+    }
+
+    public bool isScrollable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isScrollable) !is null;
+    }
+
+    public bool isSelectable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectable) !is null;
+    }
+
+    public NSString keyEquivalent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEquivalent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public objc.id lineBreakMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lineBreakMode);
+    }
+
+    public NSMenu menu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSMenu menuForEvent (NSEvent event, NSRect cellFrame, NSView view)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuForEvent_1inRect_1ofView_1, event !is null ? event.id : null, cellFrame,
+                view !is null ? view.id : null);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSString mnemonic ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mnemonic);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger mnemonicLocation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mnemonicLocation);
+    }
+
+    public NSInteger mouseDownFlags ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mouseDownFlags);
+    }
+
+    public NSInteger nextState ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_nextState);
+    }
+
+    public id objectValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void performClick (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performClick_1, sender !is null ? sender.id : null);
+    }
+
+    public static bool prefersTrackingUntilMouseUp ()
+    {
+        return OS.objc_msgSend(OS.class_NSCell, OS.sel_prefersTrackingUntilMouseUp) !is null;
+    }
+
+    public bool refusesFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_refusesFirstResponder) !is null;
+    }
+
+    public id representedObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void resetCursorRect (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resetCursorRect_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public void selectWithFrame (NSRect aRect, NSView controlView, NSText textObj, id anObject, NSInteger selStart, NSInteger selLength)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectWithFrame_1inView_1editor_1delegate_1start_1length_1, aRect,
+                controlView !is null ? controlView.id : null, textObj !is null ? textObj.id : null, anObject !is null ? anObject.id : null, selStart,
+                selLength);
+    }
+
+    public NSInteger sendActionOn (NSInteger mask)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendActionOn_1, mask);
+    }
+
+    public bool sendsActionOnEndEditing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendsActionOnEndEditing) !is null;
+    }
+
+    public void setAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, aSelector);
+    }
+
+    public void setAlignment (objc.id mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlignment_1, mode);
+    }
+
+    public void setAllowsEditingTextAttributes (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsEditingTextAttributes_1, flag);
+    }
+
+    public void setAllowsMixedState (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsMixedState_1, flag);
+    }
+
+    public void setAllowsUndo (bool allowsUndo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsUndo_1, allowsUndo);
+    }
+
+    public void setAttributedStringValue (NSAttributedString obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedStringValue_1, obj !is null ? obj.id : null);
+    }
+
+    public void setBackgroundStyle (objc.id style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundStyle_1, style);
+    }
+
+    public void setBaseWritingDirection (objc.id writingDirection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBaseWritingDirection_1, writingDirection);
+    }
+
+    public void setBezeled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezeled_1, flag);
+    }
+
+    public void setBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBordered_1, flag);
+    }
+
+    public void setCellAttribute (NSCellAttribute aParameter, NSInteger value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCellAttribute_1to_1, aParameter, value);
+    }
+
+    public void setContinuous (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContinuous_1, flag);
+    }
+
+    public void setControlSize (objc.id size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlSize_1, size);
+    }
+
+    public void setControlTint (objc.id controlTint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlTint_1, controlTint);
+    }
+
+    public void setControlView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlView_1, view !is null ? view.id : null);
+    }
+
+    public void setDoubleValue (double aDouble)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleValue_1, aDouble);
+    }
+
+    public void setEditable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag);
+    }
+
+    public void setEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, flag);
+    }
+
+    public void setEntryType (NSInteger aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEntryType_1, aType);
+    }
+
+    public void setFloatValue (float aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloatValue_1, aFloat);
+    }
+
+    public void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloatingPointFormat_1left_1right_1, autoRange, leftDigits, rightDigits);
+    }
+
+    public void setFocusRingType (objc.id focusRingType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFocusRingType_1, focusRingType);
+    }
+
+    public void setFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setFormatter (NSFormatter newFormatter)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormatter_1, newFormatter !is null ? newFormatter.id : null);
+    }
+
+    public void setHighlighted (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHighlighted_1, flag);
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setImportsGraphics (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImportsGraphics_1, flag);
+    }
+
+    public void setIntValue (int anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntValue_1, anInt);
+    }
+
+    public void setIntegerValue (int anInteger)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntegerValue_1, anInteger);
+    }
+
+    public void setLineBreakMode (objc.id mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineBreakMode_1, mode);
+    }
+
+    public void setMenu (NSMenu aMenu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1, aMenu !is null ? aMenu.id : null);
+    }
+
+    public void setMnemonicLocation (NSUInteger location)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMnemonicLocation_1, location);
+    }
+
+    public void setNextState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNextState);
+    }
+
+    public void setObjectValue (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectValue_1, obj !is null ? obj.id : null);
+    }
+
+    public void setRefusesFirstResponder (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRefusesFirstResponder_1, flag);
+    }
+
+    public void setRepresentedObject (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRepresentedObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setScrollable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScrollable_1, flag);
+    }
+
+    public void setSelectable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectable_1, flag);
+    }
+
+    public void setSendsActionOnEndEditing (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSendsActionOnEndEditing_1, flag);
+    }
+
+    public void setShowsFirstResponder (bool showFR)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsFirstResponder_1, showFR);
+    }
+
+    public void setState (NSInteger value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setState_1, value);
+    }
+
+    public void setStringValue (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStringValue_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTag (NSInteger anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTag_1, anInt);
+    }
+
+    public void setTarget (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleWithMnemonic (NSString StringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id : null);
+    }
+
+    public void setTruncatesLastVisibleLine (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTruncatesLastVisibleLine_1, flag);
+    }
+
+    public void setType (objc.id aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setType_1, aType);
+    }
+
+    public NSText setUpFieldEditorAttributes (NSText textObj)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_setUpFieldEditorAttributes_1, textObj !is null ? textObj.id : null);
+        return result !is null ? new NSText(result) : null;
+    }
+
+    public void setWraps (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWraps_1, flag);
+    }
+
+    public bool showsFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsFirstResponder) !is null;
+    }
+
+    public bool startTrackingAt (NSPoint startPoint, NSView controlView)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_startTrackingAt_1inView_1, startPoint, controlView !is null ? controlView.id : null) !is null;
+    }
+
+    public NSInteger state ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_state);
+    }
+
+    public void stopTracking (NSPoint lastPoint, NSPoint stopPoint, NSView controlView, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopTracking_1at_1inView_1mouseIsUp_1, lastPoint, stopPoint, controlView !is null ? controlView.id : null,
+                flag);
+    }
+
+    public NSString StringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_StringValue);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger tag ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tag);
+    }
+
+    public void takeDoubleValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeDoubleValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeFloatValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeFloatValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeIntValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeIntValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeIntegerValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeIntegerValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeObjectValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeObjectValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeStringValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeStringValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSRect titleRectForBounds (NSRect theRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_titleRectForBounds_1, theRect);
+        return result;
+    }
+
+    public bool trackMouse (NSEvent theEvent, NSRect cellFrame, NSView controlView, bool flag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_trackMouse_1inRect_1ofView_1untilMouseUp_1, theEvent !is null ? theEvent.id : null, cellFrame,
+                controlView !is null ? controlView.id : null, flag) !is null;
+    }
+
+    public bool truncatesLastVisibleLine ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_truncatesLastVisibleLine) !is null;
+    }
+
+    public objc.id type ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_type);
+    }
+
+    public bool wantsNotificationForMarkedText ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_wantsNotificationForMarkedText) !is null;
+    }
+
+    public bool wraps ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_wraps) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCharacterSet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCharacterSet;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCharacterSet : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static id alphanumericCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_alphanumericCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSData bitmapRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bitmapRepresentation);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public static id capitalizedLetterCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_capitalizedLetterCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool characterIsMember (short aCharacter)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_characterIsMember_1, aCharacter) !is null;
+    }
+
+    public static id characterSetWithBitmapRepresentation (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithBitmapRepresentation_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id characterSetWithCharactersInString (NSString aString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithCharactersInString_1, aString !is null ? aString.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id characterSetWithContentsOfFile (NSString fName)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithContentsOfFile_1, fName !is null ? fName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id characterSetWithRange (NSRange aRange)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_characterSetWithRange_1, aRange);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id controlCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_controlCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id decimalDigitCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_decimalDigitCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id decomposableCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_decomposableCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool hasMemberInPlane (byte thePlane)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasMemberInPlane_1, thePlane) !is null;
+    }
+
+    public static id illegalCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_illegalCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSCharacterSet invertedSet ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_invertedSet);
+        return result is this.id ? this : (result !is null ? new NSCharacterSet(result) : null);
+    }
+
+    public bool isSupersetOfSet (NSCharacterSet theOtherSet)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSupersetOfSet_1, theOtherSet !is null ? theOtherSet.id : null) !is null;
+    }
+
+    public static id letterCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_letterCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool longCharacterIsMember (dchar theLongChar)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_longCharacterIsMember_1, theLongChar) !is null;
+    }
+
+    public static id lowercaseLetterCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_lowercaseLetterCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id newlineCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_newlineCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id nonBaseCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_nonBaseCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id punctuationCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_punctuationCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id symbolCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_symbolCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id uppercaseLetterCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_uppercaseLetterCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id whitespaceAndNewlineCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_whitespaceAndNewlineCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id whitespaceCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCharacterSet, OS.sel_whitespaceCharacterSet);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSClassDescription.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSClassDescription;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSClassDescription : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray attributeKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributeKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSClassDescription classDescriptionForClass (objc.Class aClass)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSClassDescription, OS.sel_classDescriptionForClass_1, aClass);
+        return result !is null ? new NSClassDescription(result) : null;
+    }
+
+    public static void invalidateClassDescriptionCache ()
+    {
+        OS.objc_msgSend(OS.class_NSClassDescription, OS.sel_invalidateClassDescriptionCache);
+    }
+
+    public NSString inverseForRelationshipKey (NSString relationshipKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_inverseForRelationshipKey_1, relationshipKey !is null ? relationshipKey.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static void registerClassDescription (NSClassDescription description, objc.Class aClass)
+    {
+        OS.objc_msgSend(OS.class_NSClassDescription, OS.sel_registerClassDescription_1forClass_1, description !is null ? description.id : null,
+                aClass);
+    }
+
+    public NSArray toManyRelationshipKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toManyRelationshipKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray toOneRelationshipKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toOneRelationshipKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSClipView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSClipView;
+
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSCursor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSNotification;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSClipView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool autoscroll (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoscroll_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSPoint constrainScrollPoint (NSPoint newOrigin)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_constrainScrollPoint_1, newOrigin);
+        return result;
+    }
+
+    public bool copiesOnScroll ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_copiesOnScroll) !is null;
+    }
+
+    public NSCursor documentCursor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public NSRect documentRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_documentRect);
+        return result;
+    }
+
+    public id documentView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentView);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRect documentVisibleRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_documentVisibleRect);
+        return result;
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public void scrollToPoint (NSPoint newOrigin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollToPoint_1, newOrigin);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setCopiesOnScroll (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCopiesOnScroll_1, flag);
+    }
+
+    public void setDocumentCursor (NSCursor anObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocumentCursor_1, anObj !is null ? anObj.id : null);
+    }
+
+    public void setDocumentView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocumentView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void viewBoundsChanged (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewBoundsChanged_1, notification !is null ? notification.id : null);
+    }
+
+    public void viewFrameChanged (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewFrameChanged_1, notification !is null ? notification.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCloneCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCloneCommand;
+
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCloneCommand : NSScriptCommand
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptObjectSpecifier keySpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keySpecifier);
+        return result !is 0 ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReceiversSpecifier_1, receiversRef !is null ? receiversRef.id : 0);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCloseCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCloseCommand;
+
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSSaveOptions
+{
+    NSSaveOptionsYes = 0,
+    NSSaveOptionsNo,
+    NSSaveOptionsAsk
+}
+
+alias NSSaveOptions.NSSaveOptionsYes NSSaveOptionsYes;
+alias NSSaveOptions.NSSaveOptionsNo NSSaveOptionsNo;
+alias NSSaveOptions.NSSaveOptionsAsk NSSaveOptionsAsk;
+
+public class NSCloseCommand : NSScriptCommand
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSSaveOptions saveOptions ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_saveOptions);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCoder.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,340 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCoder;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCoder : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool allowsKeyedCoding ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsKeyedCoding) !is null;
+    }
+
+    public bool containsValueForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsValueForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public void decodeArrayOfObjCType (/*const*/char* itemType, NSUInteger count, void* array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_decodeArrayOfObjCType_1count_1at_1, itemType, count, array);
+    }
+
+    public bool decodeBoolForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeBoolForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public byte* decodeBytesForKey (NSString key, NSUInteger lengthp)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeBytesForKey_1returnedLength_1, key !is null ? key.id : null, lengthp);
+    }
+
+    public void* decodeBytesWithReturnedLength (NSUInteger lengthp)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeBytesWithReturnedLength_1, lengthp);
+    }
+
+    public NSData decodeDataObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decodeDataObject);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public double decodeDoubleForKey (NSString key)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_decodeDoubleForKey_1, key !is null ? key.id : null);
+    }
+
+    public float decodeFloatForKey (NSString key)
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_decodeFloatForKey_1, key !is null ? key.id : null);
+    }
+
+    public int decodeInt32ForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeInt32ForKey_1, key !is null ? key.id : null);
+    }
+
+    public long decodeInt64ForKey (NSString key)
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_decodeInt64ForKey_1, key !is null ? key.id : null);
+    }
+
+    public int decodeIntForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeIntForKey_1, key !is null ? key.id : null);
+    }
+
+    public int decodeIntegerForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeIntegerForKey_1, key !is null ? key.id : null);
+    }
+
+    public id decodeNXObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decodeNXObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id decodeObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decodeObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id decodeObjectForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decodeObjectForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSPoint decodePoint ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decodePoint);
+        return result;
+    }
+
+    public NSPoint decodePointForKey (NSString key)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decodePointForKey_1, key !is null ? key.id : null);
+        return result;
+    }
+
+    public id decodePropertyList ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decodePropertyList);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRect decodeRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decodeRect);
+        return result;
+    }
+
+    public NSRect decodeRectForKey (NSString key)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decodeRectForKey_1, key !is null ? key.id : null);
+        return result;
+    }
+
+    public NSSize decodeSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decodeSize);
+        return result;
+    }
+
+    public NSSize decodeSizeForKey (NSString key)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decodeSizeForKey_1, key !is null ? key.id : null);
+        return result;
+    }
+
+    public void decodeValueOfObjCType (/*const*/char* type, void* data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_decodeValueOfObjCType_1at_1, type, data);
+    }
+
+    public void decodeValuesOfObjCTypes (/*const*/char* decodeValuesOfObjCTypes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_decodeValuesOfObjCTypes_1, decodeValuesOfObjCTypes);
+    }
+
+    public void encodeArrayOfObjCType (/*const*/char* type, NSUInteger count, void* array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeArrayOfObjCType_1count_1at_1, type, count, array);
+    }
+
+    public void encodeBool (bool boolv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeBool_1forKey_1, boolv, key !is null ? key.id : null);
+    }
+
+    public void encodeBycopyObject (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeBycopyObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void encodeByrefObject (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeByrefObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void encodeBytes_length_ (void* byteaddr, NSUInteger length)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeBytes_1length_1, byteaddr.ptr, length);
+    }
+
+    public void encodeBytes_length_forKey_ (byte* bytesp, NSUInteger lenv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeBytes_1length_1forKey_1, bytesp, lenv, key !is null ? key.id : null);
+    }
+
+    public void encodeConditionalObject_ (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeConditionalObject_1, object !is null ? object.id : null);
+    }
+
+    public void encodeConditionalObject_forKey_ (id objv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeConditionalObject_1forKey_1, objv !is null ? objv.id : null, key !is null ? key.id : null);
+    }
+
+    public void encodeDataObject (NSData data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeDataObject_1, data !is null ? data.id : null);
+    }
+
+    public void encodeDouble (double realv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeDouble_1forKey_1, realv, key !is null ? key.id : null);
+    }
+
+    public void encodeFloat (float realv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeFloat_1forKey_1, realv, key !is null ? key.id : null);
+    }
+
+    public void encodeInt32 (int intv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeInt32_1forKey_1, intv, key !is null ? key.id : null);
+    }
+
+    public void encodeInt64 (long intv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeInt64_1forKey_1, intv, key !is null ? key.id : null);
+    }
+
+    public void encodeInt (int intv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeInt_1forKey_1, intv, key !is null ? key.id : null);
+    }
+
+    public void encodeInteger (int intv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeInteger_1forKey_1, intv, key !is null ? key.id : null);
+    }
+
+    public void encodeNXObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeNXObject_1, object !is null ? object.id : null);
+    }
+
+    public void encodeObject_ (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeObject_1, object !is null ? object.id : null);
+    }
+
+    public void encodeObject_forKey_ (id objv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeObject_1forKey_1, objv !is null ? objv.id : null, key !is null ? key.id : null);
+    }
+
+    public void encodePoint_ (NSPoint point)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodePoint_1, point);
+    }
+
+    public void encodePoint_forKey_ (NSPoint point, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodePoint_1forKey_1, point, key !is null ? key.id : null);
+    }
+
+    public void encodePropertyList (id aPropertyList)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodePropertyList_1, aPropertyList !is null ? aPropertyList.id : null);
+    }
+
+    public void encodeRect_ (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeRect_1, rect);
+    }
+
+    public void encodeRect_forKey_ (NSRect rect, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeRect_1forKey_1, rect, key !is null ? key.id : null);
+    }
+
+    public void encodeRootObject (id rootObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeRootObject_1, rootObject !is null ? rootObject.id : null);
+    }
+
+    public void encodeSize_ (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeSize_1, size);
+    }
+
+    public void encodeSize_forKey_ (NSSize size, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeSize_1forKey_1, size, key !is null ? key.id : null);
+    }
+
+    public void encodeValueOfObjCType (/*const*/char* type, void* addr)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeValueOfObjCType_1at_1, type, addr);
+    }
+
+    public void encodeValuesOfObjCTypes (/*const*/char* encodeValuesOfObjCTypes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeValuesOfObjCTypes_1, encodeValuesOfObjCTypes);
+    }
+
+    public objc.id objectZone ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_objectZone);
+    }
+
+    public void setObjectZone (objc.id zone)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectZone_1, zone);
+    }
+
+    public uint systemVersion ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_systemVersion);
+    }
+
+    public NSInteger versionForClassName (NSString className)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_versionForClassName_1, className !is null ? className.id : null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCollectionView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCollectionView;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCollectionViewItem;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCollectionView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool allowsMultipleSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsMultipleSelection) !is null;
+    }
+
+    public NSArray backgroundColors ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColors);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray content ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_content);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool isFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFirstResponder) !is null;
+    }
+
+    public bool isSelectable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectable) !is null;
+    }
+
+    public NSCollectionViewItem itemPrototype ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemPrototype);
+        return result !is null ? new NSCollectionViewItem(result) : null;
+    }
+
+    public NSSize maxItemSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_maxItemSize);
+        return result;
+    }
+
+    public NSUInteger maxNumberOfColumns ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_maxNumberOfColumns);
+    }
+
+    public NSUInteger maxNumberOfRows ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_maxNumberOfRows);
+    }
+
+    public NSSize minItemSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_minItemSize);
+        return result;
+    }
+
+    public NSCollectionViewItem newItemForRepresentedObject (id object)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_newItemForRepresentedObject_1, object !is null ? object.id : null);
+        return result !is null ? new NSCollectionViewItem(result) : null;
+    }
+
+    public NSIndexSet selectionIndexes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectionIndexes);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public void setAllowsMultipleSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsMultipleSelection_1, flag);
+    }
+
+    public void setBackgroundColors (NSArray colors)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColors_1, colors !is null ? colors.id : null);
+    }
+
+    public void setContent (NSArray content)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContent_1, content !is null ? content.id : null);
+    }
+
+    public void setItemPrototype (NSCollectionViewItem prototype)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setItemPrototype_1, prototype !is null ? prototype.id : null);
+    }
+
+    public void setMaxItemSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxItemSize_1, size);
+    }
+
+    public void setMaxNumberOfColumns (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxNumberOfColumns_1, number);
+    }
+
+    public void setMaxNumberOfRows (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxNumberOfRows_1, number);
+    }
+
+    public void setMinItemSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinItemSize_1, size);
+    }
+
+    public void setSelectable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectable_1, flag);
+    }
+
+    public void setSelectionIndexes (NSIndexSet indexes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectionIndexes_1, indexes !is null ? indexes.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCollectionViewItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCollectionViewItem;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCollectionView;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCollectionViewItem : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSCollectionView collectionView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_collectionView);
+        return result !is null ? new NSCollectionView(result) : null;
+    }
+
+    public bool isSelected ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelected) !is null;
+    }
+
+    public id representedObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setRepresentedObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRepresentedObject_1, object !is null ? object.id : null);
+    }
+
+    public void setSelected (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelected_1, flag);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSColor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,622 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSColor;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSColorSpace;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSColor : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public CGFloat alphaComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_alphaComponent);
+    }
+
+    public static NSColor alternateSelectedControlColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_alternateSelectedControlColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor alternateSelectedControlTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_alternateSelectedControlTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor blackColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_blackColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat blackComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_blackComponent);
+    }
+
+    public NSColor blendedColorWithFraction (CGFloat fraction, NSColor color)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_blendedColorWithFraction_1ofColor_1, fraction, color !is null ? color.id : null);
+        return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+    }
+
+    public static NSColor blueColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_blueColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat blueComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_blueComponent);
+    }
+
+    public CGFloat brightnessComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_brightnessComponent);
+    }
+
+    public static NSColor brownColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_brownColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSString catalogNameComponent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_catalogNameComponent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSColor clearColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_clearColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorForControlTint (objc.id controlTint)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorForControlTint_1, controlTint);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorFromPasteboard (NSPasteboard pasteBoard)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorFromPasteboard_1, pasteBoard !is null ? pasteBoard.id : null);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSString colorNameComponent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorNameComponent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSColorSpace colorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public NSString colorSpaceName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorSpaceName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSColor colorUsingColorSpace (NSColorSpace space)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorUsingColorSpace_1, space !is null ? space.id : null);
+        return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+    }
+
+    public NSColor colorUsingColorSpaceName_ (NSString colorSpace)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorUsingColorSpaceName_1, colorSpace !is null ? colorSpace.id : null);
+        return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+    }
+
+    public NSColor colorUsingColorSpaceName_device_ (NSString colorSpace, NSDictionary deviceDescription)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorUsingColorSpaceName_1device_1, colorSpace !is null ? colorSpace.id : null,
+                deviceDescription !is null ? deviceDescription.id : null);
+        return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+    }
+
+    public NSColor colorWithAlphaComponent (CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorWithAlphaComponent_1, alpha);
+        return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+    }
+
+    public static NSColor colorWithCIColor (CIColor color)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCIColor_1, color !is null ? color.id : null);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithCalibratedHue (CGFloat hue, CGFloat saturation, CGFloat brightness, CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCalibratedHue_1saturation_1brightness_1alpha_1, hue, saturation,
+                brightness, alpha);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithCalibratedRed (CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCalibratedRed_1green_1blue_1alpha_1, red, green, blue, alpha);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithCalibratedWhite (CGFloat white, CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCalibratedWhite_1alpha_1, white, alpha);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithCatalogName (NSString listName, NSString colorName)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithCatalogName_1colorName_1, listName !is null ? listName.id : null,
+                colorName !is null ? colorName.id : null);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithColorSpace (NSColorSpace space, /*const*/CGFloat* components, NSInteger numberOfComponents)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithColorSpace_1components_1count_1, space !is null ? space.id : null,
+                components, numberOfComponents);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithDeviceCyan (CGFloat cyan, CGFloat magenta, CGFloat yellow, CGFloat black, CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceCyan_1magenta_1yellow_1black_1alpha_1, cyan, magenta, yellow, black,
+                alpha);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithDeviceHue (CGFloat hue, CGFloat saturation, CGFloat brightness, CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceHue_1saturation_1brightness_1alpha_1, hue, saturation, brightness,
+                alpha);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithDeviceRed (CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceRed_1green_1blue_1alpha_1, red, green, blue, alpha);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithDeviceWhite (CGFloat white, CGFloat alpha)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithDeviceWhite_1alpha_1, white, alpha);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor colorWithPatternImage (NSImage image)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_colorWithPatternImage_1, image !is null ? image.id : null);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSArray controlAlternatingRowBackgroundColors ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlAlternatingRowBackgroundColors);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSColor controlBackgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlBackgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor controlColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor controlDarkShadowColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlDarkShadowColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor controlHighlightColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlHighlightColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor controlLightHighlightColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlLightHighlightColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor controlShadowColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlShadowColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor controlTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_controlTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static objc.id currentControlTint ()
+    {
+        return OS.objc_msgSend(OS.class_NSColor, OS.sel_currentControlTint);
+    }
+
+    public static NSColor cyanColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_cyanColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat cyanComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_cyanComponent);
+    }
+
+    public static NSColor darkGrayColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_darkGrayColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor disabledControlTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_disabledControlTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void drawSwatchInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawSwatchInRect_1, rect);
+    }
+
+    public void getComponents (CGFloat[] components)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getComponents_1, components);
+    }
+
+    public void getCyan (CGFloat* cyan, CGFloat* magenta, CGFloat* yellow, CGFloat* black, CGFloat* alpha)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getCyan_1magenta_1yellow_1black_1alpha_1, cyan, magenta, yellow, black, alpha);
+    }
+
+    public void getHue (CGFloat* hue, CGFloat* saturation, CGFloat* brightness, CGFloat* alpha)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getHue_1saturation_1brightness_1alpha_1, hue, saturation, brightness, alpha);
+    }
+
+    public void getRed (CGFloat* red, CGFloat* green, CGFloat* blue, CGFloat* alpha)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getRed_1green_1blue_1alpha_1, red, green, blue, alpha);
+    }
+
+    public void getWhite (CGFloat* white, CGFloat* alpha)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getWhite_1alpha_1, white, alpha);
+    }
+
+    public static NSColor grayColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_grayColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor greenColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_greenColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat greenComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_greenComponent);
+    }
+
+    public static NSColor gridColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_gridColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor headerColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_headerColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor headerTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_headerTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor highlightColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_highlightColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSColor highlightWithLevel (CGFloat val)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightWithLevel_1, val);
+        return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+    }
+
+    public CGFloat hueComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_hueComponent);
+    }
+
+    public static bool ignoresAlpha ()
+    {
+        return OS.objc_msgSend(OS.class_NSColor, OS.sel_ignoresAlpha) !is null;
+    }
+
+    public static NSColor keyboardFocusIndicatorColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_keyboardFocusIndicatorColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor knobColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_knobColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor lightGrayColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_lightGrayColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSString localizedCatalogNameComponent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedCatalogNameComponent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString localizedColorNameComponent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedColorNameComponent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSColor magentaColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_magentaColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat magentaComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_magentaComponent);
+    }
+
+    public NSInteger numberOfComponents ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfComponents);
+    }
+
+    public static NSColor orangeColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_orangeColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSImage patternImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_patternImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public static NSColor purpleColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_purpleColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor redColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_redColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat redComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_redComponent);
+    }
+
+    public CGFloat saturationComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_saturationComponent);
+    }
+
+    public static NSColor scrollBarColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_scrollBarColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor secondarySelectedControlColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_secondarySelectedControlColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor selectedControlColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedControlColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor selectedControlTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedControlTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor selectedKnobColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedKnobColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor selectedMenuItemColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedMenuItemColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor selectedMenuItemTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedMenuItemTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor selectedTextBackgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedTextBackgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor selectedTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_selectedTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void set ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_set);
+    }
+
+    public void setFill ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFill);
+    }
+
+    public static void setIgnoresAlpha (bool flag)
+    {
+        OS.objc_msgSend(OS.class_NSColor, OS.sel_setIgnoresAlpha_1, flag);
+    }
+
+    public void setStroke ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStroke);
+    }
+
+    public static NSColor shadowColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_shadowColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSColor shadowWithLevel (CGFloat val)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shadowWithLevel_1, val);
+        return result is this.id ? this : (result !is null ? new NSColor(result) : null);
+    }
+
+    public static NSColor textBackgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_textBackgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor textColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_textColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor whiteColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_whiteColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat whiteComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_whiteComponent);
+    }
+
+    public static NSColor windowBackgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowBackgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor windowFrameColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowFrameColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public static NSColor windowFrameTextColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_windowFrameTextColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void writeToPasteboard (NSPasteboard pasteBoard)
+    {
+        OS.objc_msgSend(this.id, OS.sel_writeToPasteboard_1, pasteBoard !is null ? pasteBoard.id : null);
+    }
+
+    public static NSColor yellowColor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColor, OS.sel_yellowColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public CGFloat yellowComponent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_yellowComponent);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSColorList.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSColorList;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSColorList : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray allKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray availableColorLists ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorList, OS.sel_availableColorLists);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSColorList colorListNamed (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorList, OS.sel_colorListNamed_1, name !is null ? name.id : null);
+        return result !is null ? new NSColorList(result) : null;
+    }
+
+    public NSColor colorWithKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorWithKey_1, key !is null ? key.id : null);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSColorList initWithName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1, name !is null ? name.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSColorList initWithName_fromFile_ (NSString name, NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1fromFile_1, name !is null ? name.id : null, path !is null ? path.id : null);
+        return result !is null ? this : null;
+    }
+
+    public void insertColor (NSColor color, NSString key, NSUInteger loc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertColor_1key_1atIndex_1, color !is null ? color.id : null, key !is null ? key.id : null, loc);
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void removeColorWithKey (NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeColorWithKey_1, key !is null ? key.id : null);
+    }
+
+    public void removeFile ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFile);
+    }
+
+    public void setColor (NSColor color, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColor_1forKey_1, color !is null ? color.id : null, key !is null ? key.id : null);
+    }
+
+    public bool writeToFile (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1, path !is null ? path.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSColorPanel.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSColorPanel;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSColorList;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPanel;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSInteger NSColorPanelMode;
+
+public class NSColorPanel : NSPanel
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public CGFloat alpha ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_alpha);
+    }
+
+    public void attachColorList (NSColorList colorList)
+    {
+        OS.objc_msgSend(this.id, OS.sel_attachColorList_1, colorList !is null ? colorList.id : null);
+    }
+
+    public NSColor color ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_color);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void detachColorList (NSColorList colorList)
+    {
+        OS.objc_msgSend(this.id, OS.sel_detachColorList_1, colorList !is null ? colorList.id : null);
+    }
+
+    public static bool dragColor (NSColor color, NSEvent theEvent, NSView sourceView)
+    {
+        return OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_dragColor_1withEvent_1fromView_1, color !is null ? color.id : null,
+                theEvent !is null ? theEvent.id : null, sourceView !is null ? sourceView.id : null) !is null;
+    }
+
+    public bool isContinuous ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isContinuous) !is null;
+    }
+
+    public objc.id mode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mode);
+    }
+
+    public void setAccessoryView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, aSelector);
+    }
+
+    public void setColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColor_1, color !is null ? color.id : null);
+    }
+
+    public void setContinuous (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContinuous_1, flag);
+    }
+
+    public void setMode (objc.id mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMode_1, mode);
+    }
+
+    public static void setPickerMask (NSUInteger mask)
+    {
+        OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_setPickerMask_1, mask);
+    }
+
+    public static void setPickerMode (NSColorPanelMode mode)
+    {
+        OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_setPickerMode_1, mode);
+    }
+
+    public void setShowsAlpha (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsAlpha_1, flag);
+    }
+
+    public void setTarget (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, anObject !is null ? anObject.id : null);
+    }
+
+    public static NSColorPanel sharedColorPanel ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanel);
+        return result !is null ? new NSColorPanel(result) : null;
+    }
+
+    public static bool sharedColorPanelExists ()
+    {
+        return OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanelExists) !is null;
+    }
+
+    public bool showsAlpha ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsAlpha) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSColorPicker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSColorPicker;
+
+import dwt.internal.cocoa.NSButtonCell;
+import dwt.internal.cocoa.NSColorList;
+import dwt.internal.cocoa.NSColorPanel;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSColorPicker : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void attachColorList (NSColorList colorList)
+    {
+        OS.objc_msgSend(this.id, OS.sel_attachColorList_1, colorList !is null ? colorList.id : null);
+    }
+
+    public NSString buttonToolTip ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_buttonToolTip);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSColorPanel colorPanel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorPanel);
+        return result !is null ? new NSColorPanel(result) : null;
+    }
+
+    public void detachColorList (NSColorList colorList)
+    {
+        OS.objc_msgSend(this.id, OS.sel_detachColorList_1, colorList !is null ? colorList.id : null);
+    }
+
+    public NSColorPicker initWithPickerMask (NSUInteger mask, NSColorPanel owningColorPanel)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPickerMask_1colorPanel_1, mask,
+                owningColorPanel !is null ? owningColorPanel.id : null);
+        return result !is null ? this : null;
+    }
+
+    public void insertNewButtonImage (NSImage newButtonImage, NSButtonCell buttonCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertNewButtonImage_1in_1, newButtonImage !is null ? newButtonImage.id : null,
+                buttonCell !is null ? buttonCell.id : null);
+    }
+
+    public NSSize minContentSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_minContentSize);
+        return result;
+    }
+
+    public NSImage provideNewButtonImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_provideNewButtonImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public void setMode (objc.id mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMode_1, mode);
+    }
+
+    public void viewSizeChanged (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewSizeChanged_1, sender !is null ? sender.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSColorSpace.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSColorSpace;
+
+import dwt.internal.cocoa.CGColorSpace;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSInteger NSColorSpaceModel;
+
+enum
+{
+    NSUnknownColorSpaceModel = -1,
+    NSGrayColorSpaceModel,
+    NSRGBColorSpaceModel,
+    NSCMYKColorSpaceModel,
+    NSLABColorSpaceModel,
+    NSDeviceNColorSpaceModel,
+    NSIndexedColorSpaceModel,
+    NSPatternColorSpaceModel
+}
+
+public class NSColorSpace : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.id CGColorSpace ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_CGColorSpace);
+    }
+
+    public NSData ICCProfileData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_ICCProfileData);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public static NSColorSpace adobeRGB1998ColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_adobeRGB1998ColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public NSColorSpaceModel colorSpaceModel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_colorSpaceModel);
+    }
+
+    public void* colorSyncProfile ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_colorSyncProfile);
+    }
+
+    public static NSColorSpace deviceCMYKColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_deviceCMYKColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public static NSColorSpace deviceGrayColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_deviceGrayColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public static NSColorSpace deviceRGBColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_deviceRGBColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public static NSColorSpace genericCMYKColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_genericCMYKColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public static NSColorSpace genericGrayColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_genericGrayColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public static NSColorSpace genericRGBColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_genericRGBColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public NSColorSpace initWithCGColorSpace (CGColorSpaceRef cgColorSpace)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCGColorSpace_1, cgColorSpace);
+        return result !is null ? this : null;
+    }
+
+    public NSColorSpace initWithColorSyncProfile (void* prof)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithColorSyncProfile_1, prof);
+        return result !is null ? this : null;
+    }
+
+    public NSColorSpace initWithICCProfileData (NSData iccData)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithICCProfileData_1, iccData !is null ? iccData.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSString localizedName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger numberOfColorComponents ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfColorComponents);
+    }
+
+    public static NSColorSpace sRGBColorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSColorSpace, OS.sel_sRGBColorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSColorWell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSColorWell;
+
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSColorWell : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void activate (bool exclusive)
+    {
+        OS.objc_msgSend(this.id, OS.sel_activate_1, exclusive);
+    }
+
+    public NSColor color ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_color);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void deactivate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_deactivate);
+    }
+
+    public void drawWellInside (NSRect insideRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawWellInside_1, insideRect);
+    }
+
+    public bool isActive ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isActive) !is null;
+    }
+
+    public bool isBordered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBordered) !is null;
+    }
+
+    public void setBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBordered_1, flag);
+    }
+
+    public void setColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColor_1, color !is null ? color.id : null);
+    }
+
+    public void takeColorFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeColorFrom_1, sender !is null ? sender.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSComboBox.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSComboBox;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSTextField;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSComboBox : NSTextField
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addItemWithObjectValue (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public void addItemsWithObjectValues (NSArray objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemsWithObjectValues_1, objects !is null ? objects.id : null);
+    }
+
+    public bool completes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_completes) !is null;
+    }
+
+    public id dataSource ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataSource);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void deselectItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deselectItemAtIndex_1, index);
+    }
+
+    public bool hasVerticalScroller ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasVerticalScroller) !is null;
+    }
+
+    public NSInteger indexOfItemWithObjectValue (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public NSInteger indexOfSelectedItem ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem);
+    }
+
+    public void insertItemWithObjectValue (id object, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertItemWithObjectValue_1atIndex_1, object !is null ? object.id : null, index);
+    }
+
+    public NSSize intercellSpacing ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_intercellSpacing);
+        return result;
+    }
+
+    public bool isButtonBordered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isButtonBordered) !is null;
+    }
+
+    public CGFloat itemHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_itemHeight);
+    }
+
+    public objc.id itemObjectValueAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemObjectValueAtIndex_1, index);
+        return result !is null ? result : null;
+    }
+
+    public void noteNumberOfItemsChanged ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteNumberOfItemsChanged);
+    }
+
+    public NSInteger numberOfItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfItems);
+    }
+
+    public NSInteger numberOfVisibleItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfVisibleItems);
+    }
+
+    public id objectValueOfSelectedItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValueOfSelectedItem);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray objectValues ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValues);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void reloadData ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadData);
+    }
+
+    public void removeAllItems ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllItems);
+    }
+
+    public void removeItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index);
+    }
+
+    public void removeItemWithObjectValue (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public void scrollItemAtIndexToTop (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollItemAtIndexToTop_1, index);
+    }
+
+    public void scrollItemAtIndexToVisible (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollItemAtIndexToVisible_1, index);
+    }
+
+    public void selectItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_1, index);
+    }
+
+    public void selectItemWithObjectValue (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public void setButtonBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setButtonBordered_1, flag);
+    }
+
+    public void setCompletes (bool completes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCompletes_1, completes);
+    }
+
+    public void setDataSource (id aSource)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDataSource_1, aSource !is null ? aSource.id : null);
+    }
+
+    public void setHasVerticalScroller (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasVerticalScroller_1, flag);
+    }
+
+    public void setIntercellSpacing (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntercellSpacing_1, aSize);
+    }
+
+    public void setItemHeight (CGFloat itemHeight)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setItemHeight_1, itemHeight);
+    }
+
+    public void setNumberOfVisibleItems (NSInteger visibleItems)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfVisibleItems_1, visibleItems);
+    }
+
+    public void setUsesDataSource (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesDataSource_1, flag);
+    }
+
+    public bool usesDataSource ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesDataSource) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSComboBoxCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSComboBoxCell;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSComboBoxCell : NSTextFieldCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addItemWithObjectValue (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public void addItemsWithObjectValues (NSArray objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemsWithObjectValues_1, objects !is null ? objects.id : null);
+    }
+
+    public NSString completedString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_completedString_1, string !is null ? string.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool completes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_completes) !is null;
+    }
+
+    public id dataSource ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataSource);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void deselectItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deselectItemAtIndex_1, index);
+    }
+
+    public bool hasVerticalScroller ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasVerticalScroller) !is null;
+    }
+
+    public NSInteger indexOfItemWithObjectValue (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public NSInteger indexOfSelectedItem ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem);
+    }
+
+    public void insertItemWithObjectValue (id object, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertItemWithObjectValue_1atIndex_1, object !is null ? object.id : null, index);
+    }
+
+    public NSSize intercellSpacing ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_intercellSpacing);
+        return result;
+    }
+
+    public bool isButtonBordered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isButtonBordered) !is null;
+    }
+
+    public CGFloat itemHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_itemHeight);
+    }
+
+    public id itemObjectValueAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemObjectValueAtIndex_1, index);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void noteNumberOfItemsChanged ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteNumberOfItemsChanged);
+    }
+
+    public NSInteger numberOfItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfItems);
+    }
+
+    public NSInteger numberOfVisibleItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfVisibleItems);
+    }
+
+    public id objectValueOfSelectedItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValueOfSelectedItem);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray objectValues ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValues);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void reloadData ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadData);
+    }
+
+    public void removeAllItems ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllItems);
+    }
+
+    public void removeItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index);
+    }
+
+    public void removeItemWithObjectValue (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public void scrollItemAtIndexToTop (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollItemAtIndexToTop_1, index);
+    }
+
+    public void scrollItemAtIndexToVisible (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollItemAtIndexToVisible_1, index);
+    }
+
+    public void selectItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_1, index);
+    }
+
+    public void selectItemWithObjectValue (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemWithObjectValue_1, object !is null ? object.id : null);
+    }
+
+    public void setButtonBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setButtonBordered_1, flag);
+    }
+
+    public void setCompletes (bool completes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCompletes_1, completes);
+    }
+
+    public void setDataSource (id aSource)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDataSource_1, aSource !is null ? aSource.id : null);
+    }
+
+    public void setHasVerticalScroller (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasVerticalScroller_1, flag);
+    }
+
+    public void setIntercellSpacing (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntercellSpacing_1, aSize);
+    }
+
+    public void setItemHeight (CGFloat itemHeight)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setItemHeight_1, itemHeight);
+    }
+
+    public void setNumberOfVisibleItems (NSInteger visibleItems)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfVisibleItems_1, visibleItems);
+    }
+
+    public void setUsesDataSource (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesDataSource_1, flag);
+    }
+
+    public bool usesDataSource ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesDataSource) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSComparisonPredicate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSComparisonPredicate;
+
+import dwt.internal.cocoa.NSExpression;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSComparisonPredicateModifier
+{
+    NSDirectPredicateModifier = 0,
+    NSAllPredicateModifier,
+    NSAnyPredicateModifier,
+}
+
+alias NSComparisonPredicateModifier.NSDirectPredicateModifier NSDirectPredicateModifier;
+alias NSComparisonPredicateModifier.NSAllPredicateModifier NSAllPredicateModifier;
+alias NSComparisonPredicateModifier.NSAnyPredicateModifier NSAnyPredicateModifier;
+
+public class NSComparisonPredicate : NSPredicate
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.id comparisonPredicateModifier ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_comparisonPredicateModifier);
+    }
+
+    public objc.SEL customSelector ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_customSelector);
+    }
+
+    public NSComparisonPredicate initWithLeftExpression_rightExpression_customSelector_ (NSExpression lhs, NSExpression rhs, objc.SEL selector)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLeftExpression_1rightExpression_1customSelector_1, lhs !is null ? lhs.id : null,
+                rhs !is null ? rhs.id : null, selector);
+        return result !is null ? this : null;
+    }
+
+    public NSComparisonPredicate initWithLeftExpression_rightExpression_modifier_type_options_ (NSExpression lhs, NSExpression rhs, objc.id modifier,
+            objc.id type, NSUInteger options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLeftExpression_1rightExpression_1modifier_1type_1options_1,
+                lhs !is null ? lhs.id : null, rhs !is null ? rhs.id : null, modifier, type, options);
+        return result !is null ? this : null;
+    }
+
+    public NSExpression leftExpression ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_leftExpression);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public NSUInteger options ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_options);
+    }
+
+    public objc.id predicateOperatorType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_predicateOperatorType);
+    }
+
+    public static NSPredicate static_predicateWithLeftExpression_rightExpression_customSelector_ (NSExpression lhs, NSExpression rhs,
+            objc.SEL selector)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSComparisonPredicate, OS.sel_predicateWithLeftExpression_1rightExpression_1customSelector_1,
+                lhs !is null ? lhs.id : null, rhs !is null ? rhs.id : null, selector);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public static NSPredicate static_predicateWithLeftExpression_rightExpression_modifier_type_options_ (NSExpression lhs, NSExpression rhs,
+            objc.id modifier, objc.id type, NSUInteger options)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSComparisonPredicate,
+                OS.sel_predicateWithLeftExpression_1rightExpression_1modifier_1type_1options_1, lhs !is null ? lhs.id : null,
+                rhs !is null ? rhs.id : null, modifier, type, options);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public NSExpression rightExpression ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rightExpression);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSComparisonResult.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,19 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 28, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSComparisonResult;
+
+enum NSComparisonResult
+{
+    NSOrderedAscending = -1,
+    NSOrderedSame,
+    NSOrderedDescending
+}
+
+alias NSComparisonResult.NSOrderedAscending NSOrderedAscending;
+alias NSComparisonResult.NSOrderedSame NSOrderedSame;
+alias NSComparisonResult.NSOrderedDescending NSOrderedDescending;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCompoundPredicate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCompoundPredicate;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCompoundPredicate : NSPredicate
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSPredicate andPredicateWithSubpredicates (NSArray subpredicates)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCompoundPredicate, OS.sel_andPredicateWithSubpredicates_1,
+                subpredicates !is null ? subpredicates.id : null);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public objc.id compoundPredicateType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compoundPredicateType);
+    }
+
+    public id initWithType (objc.id type, NSArray subpredicates)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithType_1subpredicates_1, type, subpredicates !is null ? subpredicates.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSPredicate notPredicateWithSubpredicate (NSPredicate predicate)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCompoundPredicate, OS.sel_notPredicateWithSubpredicate_1,
+                predicate !is null ? predicate.id : null);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public static NSPredicate orPredicateWithSubpredicates (NSArray subpredicates)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCompoundPredicate, OS.sel_orPredicateWithSubpredicates_1,
+                subpredicates !is null ? subpredicates.id : null);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public NSArray subpredicates ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subpredicates);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCondition.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCondition;
+
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCondition : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void broadcast ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_broadcast);
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setName (NSString n)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setName_1, n !is null ? n.id : null);
+    }
+
+    public void signal ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_signal);
+    }
+
+    //public void wait() {
+    //  OS.objc_msgSend(this.id, OS.sel_wait);
+    //}
+
+    public bool waitUntilDate (NSDate limit)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_waitUntilDate_1, limit !is null ? limit.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSConditionLock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSConditionLock;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSConditionLock : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger condition ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_condition);
+    }
+
+    public id initWithCondition (NSInteger condition)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCondition_1, condition);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool lockBeforeDate (NSDate limit)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lockBeforeDate_1, limit !is null ? limit.id : null) !is null;
+    }
+
+    public void lockWhenCondition_ (NSInteger condition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_lockWhenCondition_1, condition);
+    }
+
+    public bool lockWhenCondition_beforeDate_ (NSInteger condition, NSDate limit)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lockWhenCondition_1beforeDate_1, condition, limit !is null ? limit.id : null) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setName (NSString n)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setName_1, n !is null ? n.id : null);
+    }
+
+    public bool tryLock ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryLock) !is null;
+    }
+
+    public bool tryLockWhenCondition (NSInteger condition)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryLockWhenCondition_1, condition) !is null;
+    }
+
+    public void unlockWithCondition (NSInteger condition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unlockWithCondition_1, condition);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSConnection.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSConnection;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSConnection;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSDistantObject;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSPortNameServer;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSConnection : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addRequestMode (NSString rmode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addRequestMode_1, rmode !is null ? rmode.id : null);
+    }
+
+    public void addRunLoop (NSRunLoop runloop)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addRunLoop_1, runloop !is null ? runloop.id : null);
+    }
+
+    public static NSArray allConnections ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_allConnections);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static id connectionWithReceivePort (NSPort receivePort, NSPort sendPort)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_connectionWithReceivePort_1sendPort_1,
+                receivePort !is null ? receivePort.id : null, sendPort !is null ? sendPort.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_connectionWithRegisteredName_host_ (NSString name, NSString hostName)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_connectionWithRegisteredName_1host_1, name !is null ? name.id : null,
+                hostName !is null ? hostName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_connectionWithRegisteredName_host_usingNameServer_ (NSString name, NSString hostName, NSPortNameServer server)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_connectionWithRegisteredName_1host_1usingNameServer_1,
+                name !is null ? name.id : null, hostName !is null ? hostName.id : null, server !is null ? server.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id currentConversation ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_currentConversation);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSConnection defaultConnection ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_defaultConnection);
+        return result !is null ? new NSConnection(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void enableMultipleThreads ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_enableMultipleThreads);
+    }
+
+    public bool independentConversationQueueing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_independentConversationQueueing) !is null;
+    }
+
+    public id initWithReceivePort (NSPort receivePort, NSPort sendPort)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithReceivePort_1sendPort_1, receivePort !is null ? receivePort.id : null,
+                sendPort !is null ? sendPort.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void invalidate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidate);
+    }
+
+    public bool isValid ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isValid) !is null;
+    }
+
+    public NSArray localObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool multipleThreadsEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_multipleThreadsEnabled) !is null;
+    }
+
+    public NSPort receivePort ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_receivePort);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public bool registerName_ (NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_registerName_1, name !is null ? name.id : null) !is null;
+    }
+
+    public bool registerName_withNameServer_ (NSString name, NSPortNameServer server)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_registerName_1withNameServer_1, name !is null ? name.id : null, server !is null ? server.id : null) !is null;
+    }
+
+    public NSArray remoteObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_remoteObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void removeRequestMode (NSString rmode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeRequestMode_1, rmode !is null ? rmode.id : null);
+    }
+
+    public void removeRunLoop (NSRunLoop runloop)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeRunLoop_1, runloop !is null ? runloop.id : null);
+    }
+
+    public double replyTimeout ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_replyTimeout);
+    }
+
+    public NSArray requestModes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_requestModes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public double requestTimeout ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_requestTimeout);
+    }
+
+    public id rootObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rootObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDistantObject rootProxy ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rootProxy);
+        return result !is null ? new NSDistantObject(result) : null;
+    }
+
+    public static NSDistantObject static_rootProxyForConnectionWithRegisteredName_host_ (NSString name, NSString hostName)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_rootProxyForConnectionWithRegisteredName_1host_1,
+                name !is null ? name.id : null, hostName !is null ? hostName.id : null);
+        return result !is null ? new NSDistantObject(result) : null;
+    }
+
+    public static NSDistantObject static_rootProxyForConnectionWithRegisteredName_host_usingNameServer_ (NSString name, NSString hostName,
+            NSPortNameServer server)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_rootProxyForConnectionWithRegisteredName_1host_1usingNameServer_1,
+                name !is null ? name.id : null, hostName !is null ? hostName.id : null, server !is null ? server.id : null);
+        return result !is null ? new NSDistantObject(result) : null;
+    }
+
+    public void runInNewThread ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_runInNewThread);
+    }
+
+    public NSPort sendPort ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sendPort);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public static id static_serviceConnectionWithName_rootObject_ (NSString name, id root)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_serviceConnectionWithName_1rootObject_1, name !is null ? name.id : null,
+                root !is null ? root.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_serviceConnectionWithName_rootObject_usingNameServer_ (NSString name, id root, NSPortNameServer server)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSConnection, OS.sel_serviceConnectionWithName_1rootObject_1usingNameServer_1,
+                name !is null ? name.id : null, root !is null ? root.id : null, server !is null ? server.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setIndependentConversationQueueing (bool yorn)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIndependentConversationQueueing_1, yorn);
+    }
+
+    public void setReplyTimeout (double ti)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReplyTimeout_1, ti);
+    }
+
+    public void setRequestTimeout (double ti)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRequestTimeout_1, ti);
+    }
+
+    public void setRootObject (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRootObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public NSDictionary statistics ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_statistics);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSControl.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,371 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSControl;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSFormatter;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import obj = dwt.internal.objc.runtime;
+
+public class NSControl : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool abortEditing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_abortEditing) !is null;
+    }
+
+    public objc.SEL action ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_action);
+    }
+
+    public objc.id alignment ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_alignment);
+    }
+
+    public NSAttributedString attributedStringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedStringValue);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public objc.id baseWritingDirection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_baseWritingDirection);
+    }
+
+    public void calcSize ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_calcSize);
+    }
+
+    public objc.id cell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cell);
+        return result !is null ? result : null;
+    }
+
+    public static objc.Class cellClass ()
+    {
+        return OS.objc_msgSend(OS.class_NSControl, OS.sel_cellClass);
+    }
+
+    public NSText currentEditor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentEditor);
+        return result !is null ? new NSText(result) : null;
+    }
+
+    public double doubleValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+    }
+
+    public void drawCell (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawCell_1, aCell !is null ? aCell.id : null);
+    }
+
+    public void drawCellInside (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawCellInside_1, aCell !is null ? aCell.id : null);
+    }
+
+    public float floatValue ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatValue);
+    }
+
+    public NSFont font ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public id formatter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_formatter);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool ignoresMultiClick ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_ignoresMultiClick) !is null;
+    }
+
+    public int intValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_intValue);
+    }
+
+    public int integerValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_integerValue);
+    }
+
+    public bool isContinuous ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isContinuous) !is null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public void mouseDown (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseDown_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public id objectValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void performClick (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performClick_1, sender !is null ? sender.id : null);
+    }
+
+    public bool refusesFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_refusesFirstResponder) !is null;
+    }
+
+    public void selectCell (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectCell_1, aCell !is null ? aCell.id : null);
+    }
+
+    public id selectedCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger selectedTag ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectedTag);
+    }
+
+    public bool sendAction (objc.SEL theAction, id theTarget)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendAction_1to_1, theAction, theTarget !is null ? theTarget.id : null) !is null;
+    }
+
+    public NSInteger sendActionOn (NSInteger mask)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendActionOn_1, mask);
+    }
+
+    public void setAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, aSelector);
+    }
+
+    public void setAlignment (objc.id mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlignment_1, mode);
+    }
+
+    public void setAttributedStringValue (NSAttributedString obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedStringValue_1, obj !is null ? obj.id : null);
+    }
+
+    public void setBaseWritingDirection (objc.id writingDirection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBaseWritingDirection_1, writingDirection);
+    }
+
+    public void setCell (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCell_1, aCell !is null ? aCell.id : null);
+    }
+
+    public static void setCellClass (objc.Class factoryId)
+    {
+        OS.objc_msgSend(OS.class_NSControl, OS.sel_setCellClass_1, factoryId);
+    }
+
+    public void setContinuous (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContinuous_1, flag);
+    }
+
+    public void setDoubleValue (double aDouble)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleValue_1, aDouble);
+    }
+
+    public void setEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, flag);
+    }
+
+    public void setFloatValue (float aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloatValue_1, aFloat);
+    }
+
+    public void setFloatingPointFormat (bool autoRange, NSUInteger leftDigits, NSUInteger rightDigits)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloatingPointFormat_1left_1right_1, autoRange, leftDigits, rightDigits);
+    }
+
+    public void setFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setFormatter (NSFormatter newFormatter)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormatter_1, newFormatter !is null ? newFormatter.id : null);
+    }
+
+    public void setIgnoresMultiClick (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIgnoresMultiClick_1, flag);
+    }
+
+    public void setIntValue (int anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntValue_1, anInt);
+    }
+
+    public void setIntegerValue (int anInteger)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntegerValue_1, anInteger);
+    }
+
+    public void setNeedsDisplay ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsDisplay);
+    }
+
+    public void setObjectValue (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectValue_1, obj !is null ? obj.id : null);
+    }
+
+    public void setRefusesFirstResponder (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRefusesFirstResponder_1, flag);
+    }
+
+    public void setStringValue (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStringValue_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTag (NSInteger anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTag_1, anInt);
+    }
+
+    public void setTarget (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public NSString stringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringValue);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger tag ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tag);
+    }
+
+    public void takeDoubleValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeDoubleValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeFloatValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeFloatValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeIntValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeIntValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeIntegerValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeIntegerValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeObjectValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeObjectValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public void takeStringValueFrom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeStringValueFrom_1, sender !is null ? sender.id : null);
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void updateCell (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateCell_1, aCell !is null ? aCell.id : null);
+    }
+
+    public void updateCellInside (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateCellInside_1, aCell !is null ? aCell.id : null);
+    }
+
+    public void validateEditing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_validateEditing);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSController;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSController : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool commitEditing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_commitEditing) !is null;
+    }
+
+    public void commitEditingWithDelegate (id delegatee, bool didCommitSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_commitEditingWithDelegate_1didCommitSelector_1contextInfo_1, delegatee !is null ? delegatee.id : null,
+                didCommitSelector, contextInfo);
+    }
+
+    public void discardEditing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_discardEditing);
+    }
+
+    public bool isEditing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditing) !is null;
+    }
+
+    public void objectDidBeginEditing (id editor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_objectDidBeginEditing_1, editor !is null ? editor.id : null);
+    }
+
+    public void objectDidEndEditing (id editor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_objectDidEndEditing_1, editor !is null ? editor.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCountedSet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCountedSet;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMutableSet;
+import dwt.internal.cocoa.NSSet;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCountedSet : NSMutableSet
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObject_1, object !is null ? object.id : null);
+    }
+
+    public NSUInteger countForObject (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_countForObject_1, object !is null ? object.id : null);
+    }
+
+    public NSCountedSet initWithSet (NSSet set)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSet_1, set !is null ? set.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSEnumerator objectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public void removeObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObject_1, object !is null ? object.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCreateCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCreateCommand;
+
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCreateCommand : NSScriptCommand
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptClassDescription createClassDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_createClassDescription);
+        return result !is null ? new NSScriptClassDescription(result) : null;
+    }
+
+    public NSDictionary resolvedKeyDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resolvedKeyDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCursor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCursor;
+
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCursor : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSCursor IBeamCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_IBeamCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor arrowCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_arrowCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor closedHandCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_closedHandCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor crosshairCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_crosshairCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor currentCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_currentCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor disappearingItemCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_disappearingItemCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static void hide ()
+    {
+        OS.objc_msgSend(OS.class_NSCursor, OS.sel_hide);
+    }
+
+    public NSPoint hotSpot ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_hotSpot);
+        return result;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSCursor initWithImage_foregroundColorHint_backgroundColorHint_hotSpot_ (NSImage newImage, NSColor fg, NSColor bg, NSPoint hotSpot)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithImage_1foregroundColorHint_1backgroundColorHint_1hotSpot_1,
+                newImage !is null ? newImage.id : null, fg !is null ? fg.id : null, bg !is null ? bg.id : null, hotSpot);
+        return result !is null ? this : null;
+    }
+
+    public NSCursor initWithImage_hotSpot_ (NSImage newImage, NSPoint aPoint)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithImage_1hotSpot_1, newImage !is null ? newImage.id : null, aPoint);
+        return result !is null ? this : null;
+    }
+
+    public bool isSetOnMouseEntered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSetOnMouseEntered) !is null;
+    }
+
+    public bool isSetOnMouseExited ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSetOnMouseExited) !is null;
+    }
+
+    public void mouseEntered (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseEntered_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void mouseExited (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseExited_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public static NSCursor openHandCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_openHandCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor pointingHandCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_pointingHandCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public void pop ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_pop);
+    }
+
+    public static void static_pop ()
+    {
+        OS.objc_msgSend(OS.class_NSCursor, OS.sel_pop);
+    }
+
+    public void push ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_push);
+    }
+
+    public static NSCursor resizeDownCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeDownCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor resizeLeftCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeLeftCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor resizeLeftRightCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeLeftRightCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor resizeRightCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeRightCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor resizeUpCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeUpCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public static NSCursor resizeUpDownCursor ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_resizeUpDownCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public void set ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_set);
+    }
+
+    public static void setHiddenUntilMouseMoves (bool flag)
+    {
+        OS.objc_msgSend(OS.class_NSCursor, OS.sel_setHiddenUntilMouseMoves_1, flag);
+    }
+
+    public void setOnMouseEntered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOnMouseEntered_1, flag);
+    }
+
+    public void setOnMouseExited (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOnMouseExited_1, flag);
+    }
+
+    public static void unhide ()
+    {
+        OS.objc_msgSend(OS.class_NSCursor, OS.sel_unhide);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSCustomImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSCustomImageRep;
+
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSCustomImageRep : NSImageRep
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.SEL drawSelector ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawSelector);
+    }
+
+    public NSCustomImageRep initWithDrawSelector (objc.SEL aMethod, id anObject)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDrawSelector_1delegate_1, aMethod, anObject !is null ? anObject.id : null);
+        return result !is null ? this : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSData;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSData : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void* bytes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bytes);
+    }
+
+    public static id data ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_data);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dataWithBytes (/*const*/void* bytes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytes_1length_1, bytes, length);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dataWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1, bytes, length);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dataWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dataWithContentsOfFile_ (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dataWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfFile_1options_1error_1, path !is null ? path.id : null,
+                readOptionsMask, errorPtr);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dataWithContentsOfMappedFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfMappedFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dataWithContentsOfURL_ (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dataWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1options_1error_1, url !is null ? url.id : null,
+                readOptionsMask, errorPtr);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dataWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void getBytes_ (void* buffer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getBytes_1, buffer);
+    }
+
+    public void getBytes_length_ (void* buffer, NSUInteger length)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getBytes_1length_1, buffer, length);
+    }
+
+    public void getBytes_range_ (void* buffer, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getBytes_1range_1, buffer, range);
+    }
+
+    public NSData initWithBytes (void* bytes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytes_1length_1, bytes, length);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytesNoCopy_1length_1, bytes, length);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithContentsOfFile_ (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1options_1error_1, path !is null ? path.id : null, readOptionsMask,
+                errorPtr);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithContentsOfMappedFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfMappedFile_1, path !is null ? path.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithContentsOfURL_ (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1options_1error_1, url !is null ? url.id : null, readOptionsMask,
+                errorPtr);
+        return result !is null ? this : null;
+    }
+
+    public NSData initWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isEqualToData (NSData other)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToData_1, other !is null ? other.id : null) !is null;
+    }
+
+    public NSUInteger length ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_length);
+    }
+
+    public NSData subdataWithRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subdataWithRange_1, range);
+        return result is this.id ? this : (result !is null ? new NSData(result) : null);
+    }
+
+    public bool writeToFile_atomically_ (NSString path, bool useAuxiliaryFile)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1, path !is null ? path.id : null, useAuxiliaryFile) !is null;
+    }
+
+    public bool writeToFile_options_error_ (NSString path, NSUInteger writeOptionsMask, objc.id** errorPtr)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1options_1error_1, path !is null ? path.id : null, writeOptionsMask, errorPtr) !is null;
+    }
+
+    public bool writeToURL_atomically_ (NSURL url, bool atomically)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1atomically_1, url !is null ? url.id : null, atomically) !is null;
+    }
+
+    public bool writeToURL_options_error_ (NSURL url, NSUInteger writeOptionsMask, objc.id** errorPtr)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1options_1error_1, url !is null ? url.id : null, writeOptionsMask, errorPtr) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDate;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCalendarDate;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTimeZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias double NSTimeInterval;
+
+public class NSDate : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id addTimeInterval (double seconds)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addTimeInterval_1, seconds);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.id compare (NSDate other)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compare_1, other !is null ? other.id : null);
+    }
+
+    public static NSDate date ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_date);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSCalendarDate dateWithCalendarFormat (NSString format, NSTimeZone aTimeZone)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateWithCalendarFormat_1timeZone_1, format !is null ? format.id : null,
+                aTimeZone !is null ? aTimeZone.id : null);
+        return result !is null ? new NSCalendarDate(result) : null;
+    }
+
+    public static id static_dateWithNaturalLanguageString_ (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithNaturalLanguageString_1, string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dateWithNaturalLanguageString_locale_ (NSString string, id locale)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithNaturalLanguageString_1locale_1, string !is null ? string.id : null,
+                locale !is null ? locale.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dateWithString (NSString aString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithString_1, aString !is null ? aString.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dateWithTimeIntervalSince1970 (double secs)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSince1970_1, secs);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSDate dateWithTimeIntervalSinceNow (double secs)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSinceNow_1, secs);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public static id dateWithTimeIntervalSinceReferenceDate (double secs)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_dateWithTimeIntervalSinceReferenceDate_1, secs);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithCalendarFormat (NSString format, NSTimeZone aTimeZone, id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithCalendarFormat_1timeZone_1locale_1, format !is null ? format.id : null,
+                aTimeZone !is null ? aTimeZone.id : null, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithLocale (id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSDate distantFuture ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_distantFuture);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public static NSDate distantPast ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDate, OS.sel_distantPast);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSDate earlierDate (NSDate anotherDate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_earlierDate_1, anotherDate !is null ? anotherDate.id : null);
+        return result is this.id ? this : (result !is null ? new NSDate(result) : null);
+    }
+
+    public NSDate initWithString (NSString description)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, description !is null ? description.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSDate initWithTimeInterval (double secsToBeAdded, NSDate anotherDate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTimeInterval_1sinceDate_1, secsToBeAdded,
+                anotherDate !is null ? anotherDate.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSDate initWithTimeIntervalSinceNow (double secsToBeAddedToNow)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTimeIntervalSinceNow_1, secsToBeAddedToNow);
+        return result !is null ? this : null;
+    }
+
+    public NSDate initWithTimeIntervalSinceReferenceDate (double secsToBeAdded)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTimeIntervalSinceReferenceDate_1, secsToBeAdded);
+        return result !is null ? this : null;
+    }
+
+    public bool isEqualToDate (NSDate otherDate)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToDate_1, otherDate !is null ? otherDate.id : null) !is null;
+    }
+
+    public NSDate laterDate (NSDate anotherDate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_laterDate_1, anotherDate !is null ? anotherDate.id : null);
+        return result is this.id ? this : (result !is null ? new NSDate(result) : null);
+    }
+
+    public double timeIntervalSince1970 ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSince1970);
+    }
+
+    public double timeIntervalSinceDate (NSDate anotherDate)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSinceDate_1, anotherDate !is null ? anotherDate.id : null);
+    }
+
+    public double timeIntervalSinceNow ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSinceNow);
+    }
+
+    public static double static_timeIntervalSinceReferenceDate ()
+    {
+        return OS.objc_msgSend_fpret(OS.class_NSDate, OS.sel_timeIntervalSinceReferenceDate);
+    }
+
+    public double timeIntervalSinceReferenceDate ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_timeIntervalSinceReferenceDate);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDateComponents.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDateComponents;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDateComponents : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger day ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_day);
+    }
+
+    public NSInteger era ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_era);
+    }
+
+    public NSInteger hour ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hour);
+    }
+
+    public NSInteger minute ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_minute);
+    }
+
+    public NSInteger month ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_month);
+    }
+
+    public NSInteger second ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_second);
+    }
+
+    public void setDay (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDay_1, v);
+    }
+
+    public void setEra (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEra_1, v);
+    }
+
+    public void setHour (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHour_1, v);
+    }
+
+    public void setMinute (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinute_1, v);
+    }
+
+    public void setMonth (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMonth_1, v);
+    }
+
+    public void setSecond (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSecond_1, v);
+    }
+
+    public void setWeek (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWeek_1, v);
+    }
+
+    public void setWeekday (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWeekday_1, v);
+    }
+
+    public void setWeekdayOrdinal (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWeekdayOrdinal_1, v);
+    }
+
+    public void setYear (NSInteger v)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setYear_1, v);
+    }
+
+    public NSInteger week ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_week);
+    }
+
+    public NSInteger weekday ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_weekday);
+    }
+
+    public NSInteger weekdayOrdinal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_weekdayOrdinal);
+    }
+
+    public NSInteger year ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_year);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDateFormatter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,423 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDateFormatter;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCalendar;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSFormatter;
+import dwt.internal.cocoa.NSLocale;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTimeZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDateFormatter : NSFormatter
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString AMSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_AMSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString PMSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_PMSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool allowsNaturalLanguage ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsNaturalLanguage) !is null;
+    }
+
+    public NSCalendar calendar ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_calendar);
+        return result !is null ? new NSCalendar(result) : null;
+    }
+
+    public NSString dateFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateFormat);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDate dateFromString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateFromString_1, string !is null ? string.id : null);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public objc.id dateStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dateStyle);
+    }
+
+    public NSDate defaultDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public static objc.id defaultFormatterBehavior ()
+    {
+        return OS.objc_msgSend(OS.class_NSDateFormatter, OS.sel_defaultFormatterBehavior);
+    }
+
+    public NSArray eraSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_eraSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public objc.id formatterBehavior ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_formatterBehavior);
+    }
+
+    public bool generatesCalendarDates ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_generatesCalendarDates) !is null;
+    }
+
+    public bool getObjectValue (objc.id* obj, NSString string, NSRange* rangep, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getObjectValue_1forString_1range_1error_1, obj, string !is null ? string.id : null, rangep, error) !is null;
+    }
+
+    public NSDate gregorianStartDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_gregorianStartDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public id initWithDateFormat (NSString format, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDateFormat_1allowNaturalLanguage_1, format !is null ? format.id : null, flag);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isLenient ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLenient) !is null;
+    }
+
+    public NSLocale locale ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_locale);
+        return result !is null ? new NSLocale(result) : null;
+    }
+
+    public NSArray longEraSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_longEraSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray monthSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_monthSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray quarterSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_quarterSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setAMSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAMSymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setCalendar (NSCalendar calendar)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCalendar_1, calendar !is null ? calendar.id : null);
+    }
+
+    public void setDateFormat (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDateFormat_1, string !is null ? string.id : null);
+    }
+
+    public void setDateStyle (objc.id style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDateStyle_1, style);
+    }
+
+    public void setDefaultDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultDate_1, date !is null ? date.id : null);
+    }
+
+    public static void setDefaultFormatterBehavior (objc.id behavior)
+    {
+        OS.objc_msgSend(OS.class_NSDateFormatter, OS.sel_setDefaultFormatterBehavior_1, behavior);
+    }
+
+    public void setEraSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEraSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setFormatterBehavior (objc.id behavior)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormatterBehavior_1, behavior);
+    }
+
+    public void setGeneratesCalendarDates (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGeneratesCalendarDates_1, b);
+    }
+
+    public void setGregorianStartDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGregorianStartDate_1, date !is null ? date.id : null);
+    }
+
+    public void setLenient (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLenient_1, b);
+    }
+
+    public void setLocale (NSLocale locale)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocale_1, locale !is null ? locale.id : null);
+    }
+
+    public void setLongEraSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLongEraSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setMonthSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMonthSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setPMSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPMSymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setQuarterSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setQuarterSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setShortMonthSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShortMonthSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setShortQuarterSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShortQuarterSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setShortStandaloneMonthSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShortStandaloneMonthSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setShortStandaloneQuarterSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShortStandaloneQuarterSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setShortStandaloneWeekdaySymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShortStandaloneWeekdaySymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setShortWeekdaySymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShortWeekdaySymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setStandaloneMonthSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStandaloneMonthSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setStandaloneQuarterSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStandaloneQuarterSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setStandaloneWeekdaySymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStandaloneWeekdaySymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setTimeStyle (objc.id style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeStyle_1, style);
+    }
+
+    public void setTimeZone (NSTimeZone tz)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeZone_1, tz !is null ? tz.id : null);
+    }
+
+    public void setTwoDigitStartDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTwoDigitStartDate_1, date !is null ? date.id : null);
+    }
+
+    public void setVeryShortMonthSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVeryShortMonthSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setVeryShortStandaloneMonthSymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVeryShortStandaloneMonthSymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setVeryShortStandaloneWeekdaySymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVeryShortStandaloneWeekdaySymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setVeryShortWeekdaySymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVeryShortWeekdaySymbols_1, array !is null ? array.id : null);
+    }
+
+    public void setWeekdaySymbols (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWeekdaySymbols_1, array !is null ? array.id : null);
+    }
+
+    public NSArray shortMonthSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shortMonthSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray shortQuarterSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shortQuarterSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray shortStandaloneMonthSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shortStandaloneMonthSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray shortStandaloneQuarterSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shortStandaloneQuarterSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray shortStandaloneWeekdaySymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shortStandaloneWeekdaySymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray shortWeekdaySymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shortWeekdaySymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray standaloneMonthSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standaloneMonthSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray standaloneQuarterSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standaloneQuarterSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray standaloneWeekdaySymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standaloneWeekdaySymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString stringFromDate (NSDate date)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringFromDate_1, date !is null ? date.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public objc.id timeStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_timeStyle);
+    }
+
+    public NSTimeZone timeZone ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+    public NSDate twoDigitStartDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_twoDigitStartDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSArray veryShortMonthSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_veryShortMonthSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray veryShortStandaloneMonthSymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_veryShortStandaloneMonthSymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray veryShortStandaloneWeekdaySymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_veryShortStandaloneWeekdaySymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray veryShortWeekdaySymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_veryShortWeekdaySymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray weekdaySymbols ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_weekdaySymbols);
+        return result !is null ? new NSArray(result) : null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDatePicker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDatePicker;
+
+import dwt.internal.cocoa.NSCalendar;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSLocale;
+import dwt.internal.cocoa.NSTimeZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDatePicker : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSCalendar calendar ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_calendar);
+        return result !is null ? new NSCalendar(result) : null;
+    }
+
+    public objc.id datePickerElements ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_datePickerElements);
+    }
+
+    public objc.id datePickerMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_datePickerMode);
+    }
+
+    public objc.id datePickerStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_datePickerStyle);
+    }
+
+    public NSDate dateValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateValue);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public bool isBezeled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBezeled) !is null;
+    }
+
+    public bool isBordered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBordered) !is null;
+    }
+
+    public NSLocale locale ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_locale);
+        return result !is null ? new NSLocale(result) : null;
+    }
+
+    public NSDate maxDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_maxDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSDate minDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_minDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBezeled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezeled_1, flag);
+    }
+
+    public void setBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBordered_1, flag);
+    }
+
+    public void setCalendar (NSCalendar newCalendar)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCalendar_1, newCalendar !is null ? newCalendar.id : null);
+    }
+
+    public void setDatePickerElements (objc.id elementFlags)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDatePickerElements_1, elementFlags);
+    }
+
+    public void setDatePickerMode (objc.id newMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDatePickerMode_1, newMode);
+    }
+
+    public void setDatePickerStyle (objc.id newStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDatePickerStyle_1, newStyle);
+    }
+
+    public void setDateValue (NSDate newStartDate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDateValue_1, newStartDate !is null ? newStartDate.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setLocale (NSLocale newLocale)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocale_1, newLocale !is null ? newLocale.id : null);
+    }
+
+    public void setMaxDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxDate_1, date !is null ? date.id : null);
+    }
+
+    public void setMinDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinDate_1, date !is null ? date.id : null);
+    }
+
+    public void setTextColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextColor_1, color !is null ? color.id : null);
+    }
+
+    public void setTimeInterval (double newTimeInterval)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeInterval_1, newTimeInterval);
+    }
+
+    public void setTimeZone (NSTimeZone newTimeZone)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeZone_1, newTimeZone !is null ? newTimeZone.id : null);
+    }
+
+    public NSColor textColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public double timeInterval ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_timeInterval);
+    }
+
+    public NSTimeZone timeZone ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDatePickerCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDatePickerCell;
+
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSCalendar;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSLocale;
+import dwt.internal.cocoa.NSTimeZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDatePickerCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSCalendar calendar ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_calendar);
+        return result !is null ? new NSCalendar(result) : null;
+    }
+
+    public objc.id datePickerElements ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_datePickerElements);
+    }
+
+    public objc.id datePickerMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_datePickerMode);
+    }
+
+    public objc.id datePickerStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_datePickerStyle);
+    }
+
+    public NSDate dateValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dateValue);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public NSLocale locale ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_locale);
+        return result !is null ? new NSLocale(result) : null;
+    }
+
+    public NSDate maxDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_maxDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSDate minDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_minDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setCalendar (NSCalendar newCalendar)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCalendar_1, newCalendar !is null ? newCalendar.id : null);
+    }
+
+    public void setDatePickerElements (objc.id elementFlags)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDatePickerElements_1, elementFlags);
+    }
+
+    public void setDatePickerMode (objc.id newMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDatePickerMode_1, newMode);
+    }
+
+    public void setDatePickerStyle (objc.id newStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDatePickerStyle_1, newStyle);
+    }
+
+    public void setDateValue (NSDate newStartDate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDateValue_1, newStartDate !is null ? newStartDate.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setLocale (NSLocale newLocale)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocale_1, newLocale !is null ? newLocale.id : null);
+    }
+
+    public void setMaxDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxDate_1, date !is null ? date.id : null);
+    }
+
+    public void setMinDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinDate_1, date !is null ? date.id : null);
+    }
+
+    public void setTextColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextColor_1, color !is null ? color.id : null);
+    }
+
+    public void setTimeInterval (double newTimeInterval)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeInterval_1, newTimeInterval);
+    }
+
+    public void setTimeZone (NSTimeZone newTimeZone)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeZone_1, newTimeZone !is null ? newTimeZone.id : null);
+    }
+
+    public NSColor textColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public double timeInterval ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_timeInterval);
+    }
+
+    public NSTimeZone timeZone ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_timeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDecimal.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDecimal;
+
+//import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.NSInteger;
+
+struct NSDecimal
+{
+    uint _exponent;
+    uint _length;
+    uint _isNegative;
+    uint _isCompact;
+    uint _reserved;
+    /*ushort[OS.NSDecimalMaxSize]*/ushort* _mantissa;
+}
+
+enum NSCalculationError : NSUInteger
+{
+    NSCalculationNoError = 0,
+    NSCalculationLossOfPrecision, // Result lost precision
+    NSCalculationUnderflow, // Result became 0
+    NSCalculationOverflow, // Result exceeds possible representation
+    NSCalculationDivideByZero
+}
+
+alias NSCalculationError.NSCalculationNoError NSCalculationNoError;
+alias NSCalculationError.NSCalculationLossOfPrecision NSCalculationLossOfPrecision;
+alias NSCalculationError.NSCalculationUnderflow NSCalculationUnderflow;
+alias NSCalculationError.NSCalculationOverflow NSCalculationOverflow;
+alias NSCalculationError.NSCalculationDivideByZero NSCalculationDivideByZero;
+
+enum NSRoundingMode : NSUInteger
+{
+    NSRoundPlain, // Round up on a tie
+    NSRoundDown, // Always down == truncate
+    NSRoundUp, // Always up
+    NSRoundBankers // on a tie round so last digit is even
+}
+
+alias NSRoundingMode.NSRoundPlain NSRoundPlain;
+alias NSRoundingMode.NSRoundDown NSRoundDown;
+alias NSRoundingMode.NSRoundUp NSRoundUp;
+alias NSRoundingMode.NSRoundBankers NSRoundBankers;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDecimalNumber.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDecimalNumber;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSComparisonResult;
+import dwt.internal.cocoa.NSDecimal;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDecimalNumber : NSNumber
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSComparisonResult compare (NSNumber decimalNumber)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_compare_1, decimalNumber !is null ? decimalNumber.id : null);
+    }
+
+    public NSDecimalNumber decimalNumberByAdding_ (NSDecimalNumber decimalNumber)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByAdding_1, decimalNumber !is null ? decimalNumber.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByAdding_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByAdding_1withBehavior_1, decimalNumber !is null ? decimalNumber.id : null,
+                behavior !is null ? behavior.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByDividingBy_ (NSDecimalNumber decimalNumber)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByDividingBy_1, decimalNumber !is null ? decimalNumber.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByDividingBy_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByDividingBy_1withBehavior_1, decimalNumber !is null ? decimalNumber.id : null,
+                behavior !is null ? behavior.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByMultiplyingBy_ (NSDecimalNumber decimalNumber)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingBy_1, decimalNumber !is null ? decimalNumber.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByMultiplyingBy_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingBy_1withBehavior_1,
+                decimalNumber !is null ? decimalNumber.id : null, behavior !is null ? behavior.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByMultiplyingByPowerOf10_ (short power)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingByPowerOf10_1, power);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByMultiplyingByPowerOf10_withBehavior_ (short power, id behavior)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingByPowerOf10_1withBehavior_1, power,
+                behavior !is null ? behavior.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByRaisingToPower_ (NSUInteger power)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByRaisingToPower_1, power);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByRaisingToPower_withBehavior_ (uint power, id behavior)
+    {
+        objc.id
+                result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByRaisingToPower_1withBehavior_1, power, behavior !is null ? behavior.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberByRoundingAccordingToBehavior (id behavior)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByRoundingAccordingToBehavior_1, behavior !is null ? behavior.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberBySubtracting_ (NSDecimalNumber decimalNumber)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberBySubtracting_1, decimalNumber !is null ? decimalNumber.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public NSDecimalNumber decimalNumberBySubtracting_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberBySubtracting_1withBehavior_1,
+                decimalNumber !is null ? decimalNumber.id : null, behavior !is null ? behavior.id : null);
+        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
+    }
+
+    public static NSDecimalNumber decimalNumberWithDecimal (NSDecimal dcm)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithDecimal_1, dcm);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public static NSDecimalNumber decimalNumberWithMantissa (long mantissa, short exponent, bool flag)
+    {
+        objc.id
+                result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithMantissa_1exponent_1isNegative_1, mantissa, exponent, flag);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public static NSDecimalNumber static_decimalNumberWithString_ (NSString numberValue)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithString_1, numberValue !is null ? numberValue.id : null);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public static NSDecimalNumber static_decimalNumberWithString_locale_ (NSString numberValue, id locale)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithString_1locale_1,
+                numberValue !is null ? numberValue.id : null, locale !is null ? locale.id : null);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public NSDecimal decimalValue ()
+    {
+        NSDecimal result = new NSDecimal();
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decimalValue);
+        return result;
+    }
+
+    public static id defaultBehavior ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_defaultBehavior);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString descriptionWithLocale (id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public double doubleValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+    }
+
+    public id initWithDecimal (NSDecimal dcm)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDecimal_1, dcm);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithMantissa (ulong mantissa, short exponent, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMantissa_1exponent_1isNegative_1, mantissa, exponent, flag);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithString_ (NSString numberValue)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, numberValue !is null ? numberValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithString_locale_ (NSString numberValue, id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1locale_1, numberValue !is null ? numberValue.id : null,
+                locale !is null ? locale.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSDecimalNumber maximumDecimalNumber ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_maximumDecimalNumber);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public static NSDecimalNumber minimumDecimalNumber ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_minimumDecimalNumber);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public static NSDecimalNumber notANumber ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_notANumber);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public /*const char* */byte* objCType ()
+    {
+        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_objCType);
+    }
+
+    public static NSDecimalNumber one ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_one);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public static void setDefaultBehavior (id behavior)
+    {
+        OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_setDefaultBehavior_1, behavior !is null ? behavior.id : null);
+    }
+
+    public static NSDecimalNumber zero ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_zero);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDecimalNumberHandler.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDecimalNumberHandler;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDecimalNumberHandler : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static id decimalNumberHandlerWithRoundingMode (objc.id roundingMode, short scale, bool exact, bool overflow, bool underflow,
+            bool divideByZero)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumberHandler,
+                OS.sel_decimalNumberHandlerWithRoundingMode_1scale_1raiseOnExactness_1raiseOnOverflow_1raiseOnUnderflow_1raiseOnDivideByZero_1,
+                roundingMode, scale, exact, overflow, underflow, divideByZero);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id defaultDecimalNumberHandler ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumberHandler, OS.sel_defaultDecimalNumberHandler);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithRoundingMode (objc.id roundingMode, short scale, bool exact, bool overflow, bool underflow, bool divideByZero)
+    {
+        objc.id result = OS.objc_msgSend(this.id,
+                OS.sel_initWithRoundingMode_1scale_1raiseOnExactness_1raiseOnOverflow_1raiseOnUnderflow_1raiseOnDivideByZero_1, roundingMode, scale,
+                exact, overflow, underflow, divideByZero);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDeleteCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDeleteCommand;
+
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDeleteCommand : NSScriptCommand
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptObjectSpecifier keySpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keySpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReceiversSpecifier_1, receiversRef !is null ? receiversRef.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDictionary.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,330 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDictionary;
+
+
+import dwt.internal.c.carboncore.MacTypes : OSType;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+public class NSDictionary : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray allKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray allKeysForObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allKeysForObject_1, anObject !is null ? anObject.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray allValues ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allValues);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionInStringsFileFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionInStringsFileFormat);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithLocale_ (id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithLocale_indent_ (id locale, NSUInteger level)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1indent_1, locale !is null ? locale.id : null, level);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id dictionary ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionary);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dictionaryWithContentsOfFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dictionaryWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dictionaryWithDictionary (NSDictionary dict)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithDictionary_1, dict !is null ? dict.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dictionaryWithObject (id object, id key)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObject_1forKey_1, object !is null ? object.id : null,
+                key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dictionaryWithObjects_forKeys_ (NSArray objects, NSArray keys)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjects_1forKeys_1, objects !is null ? objects.id : null,
+                keys !is null ? keys.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_dictionaryWithObjects_forKeys_count_ (objc.id* objects, objc.id* keys, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjects_1forKeys_1count_1, objects, keys, cnt);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dictionaryWithObjectsAndKeys (id dictionaryWithObjectsAndKeys)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjectsAndKeys_1,
+                dictionaryWithObjectsAndKeys !is null ? dictionaryWithObjectsAndKeys.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDate fileCreationDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileCreationDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public bool fileExtensionHidden ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileExtensionHidden) !is null;
+    }
+
+    public NSNumber fileGroupOwnerAccountID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileGroupOwnerAccountID);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public NSString fileGroupOwnerAccountName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileGroupOwnerAccountName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public OSType fileHFSCreatorCode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileHFSCreatorCode);
+    }
+
+    public OSType fileHFSTypeCode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileHFSTypeCode);
+    }
+
+    public bool fileIsAppendOnly ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileIsAppendOnly) !is null;
+    }
+
+    public bool fileIsImmutable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileIsImmutable) !is null;
+    }
+
+    public NSDate fileModificationDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileModificationDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSNumber fileOwnerAccountID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileOwnerAccountID);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public NSString fileOwnerAccountName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileOwnerAccountName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger filePosixPermissions ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_filePosixPermissions);
+    }
+
+    public ulong fileSize ()
+    {
+        return cast(ulong) OS.objc_msgSend(this.id, OS.sel_fileSize);
+    }
+
+    public NSUInteger fileSystemFileNumber ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileSystemFileNumber);
+    }
+
+    public NSInteger fileSystemNumber ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileSystemNumber);
+    }
+
+    public NSString fileType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void getObjects (objc.id* objects, objc.id* keys)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getObjects_1andKeys_1, objects, keys);
+    }
+
+    public id initWithContentsOfFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithDictionary_ (NSDictionary otherDictionary)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDictionary_1, otherDictionary !is null ? otherDictionary.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithDictionary_copyItems_ (NSDictionary otherDictionary, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDictionary_1copyItems_1, otherDictionary !is null ? otherDictionary.id : null, flag);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithObjects_forKeys_ (NSArray objects, NSArray keys)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1forKeys_1, objects !is null ? objects.id : null,
+                keys !is null ? keys.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithObjects_forKeys_count_ (objc.id* objects, objc.id* keys, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1forKeys_1count_1, objects, keys, cnt);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithObjectsAndKeys (id initWithObjectsAndKeys)
+    {
+        objc.id
+                result = OS.objc_msgSend(this.id, OS.sel_initWithObjectsAndKeys_1, initWithObjectsAndKeys !is null ? initWithObjectsAndKeys.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isEqualToDictionary (NSDictionary otherDictionary)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToDictionary_1, otherDictionary !is null ? otherDictionary.id : null) !is null;
+    }
+
+    public NSEnumerator keyEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public NSArray keysSortedByValueUsingSelector (objc.SEL comparator)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keysSortedByValueUsingSelector_1, comparator);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSEnumerator objectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public id objectForKey (id aKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_1, aKey !is null ? aKey.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray objectsForKeys (NSArray keys, id marker)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsForKeys_1notFoundMarker_1, keys !is null ? keys.id : null,
+                marker !is null ? marker.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id valueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool writeToFile (NSString path, bool useAuxiliaryFile)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1, path !is null ? path.id : null, useAuxiliaryFile) !is null;
+    }
+
+    public bool writeToURL (NSURL url, bool atomically)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1atomically_1, url !is null ? url.id : null, atomically) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDictionaryController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDictionaryController;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSArrayController;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDictionaryController : NSArrayController
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray excludedKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_excludedKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray includedKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_includedKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString initialKey ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initialKey);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initialValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initialValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary localizedKeyDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedKeyDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString localizedKeyTable ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedKeyTable);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id newObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_newObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setExcludedKeys (NSArray keys)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setExcludedKeys_1, keys !is null ? keys.id : null);
+    }
+
+    public void setIncludedKeys (NSArray keys)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIncludedKeys_1, keys !is null ? keys.id : null);
+    }
+
+    public void setInitialKey (NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInitialKey_1, key !is null ? key.id : null);
+    }
+
+    public void setInitialValue (id value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInitialValue_1, value !is null ? value.id : null);
+    }
+
+    public void setLocalizedKeyDictionary (NSDictionary dictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocalizedKeyDictionary_1, dictionary !is null ? dictionary.id : null);
+    }
+
+    public void setLocalizedKeyTable (NSString stringsFileName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocalizedKeyTable_1, stringsFileName !is null ? stringsFileName.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDirectoryEnumerator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDirectoryEnumerator;
+
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDirectoryEnumerator : NSEnumerator
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSDictionary directoryAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_directoryAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary fileAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void skipDescendents ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_skipDescendents);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDistantObject.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDistantObject;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSConnection;
+import dwt.internal.cocoa.NSProxy;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDistantObject : NSProxy
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSConnection connectionForProxy ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_connectionForProxy);
+        return result !is null ? new NSConnection(result) : null;
+    }
+
+    public id initWithLocal (id target, NSConnection connection)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLocal_1connection_1, target !is null ? target.id : null,
+                connection !is null ? connection.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithTarget (id target, NSConnection connection)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTarget_1connection_1, target !is null ? target.id : null,
+                connection !is null ? connection.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSDistantObject proxyWithLocal (id target, NSConnection connection)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDistantObject, OS.sel_proxyWithLocal_1connection_1, target !is null ? target.id : null,
+                connection !is null ? connection.id : null);
+        return result !is null ? new NSDistantObject(result) : null;
+    }
+
+    public static NSDistantObject proxyWithTarget (id target, NSConnection connection)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDistantObject, OS.sel_proxyWithTarget_1connection_1, target !is null ? target.id : null,
+                connection !is null ? connection.id : null);
+        return result !is null ? new NSDistantObject(result) : null;
+    }
+
+//PUBLIC VOID SETPROTOCOLFORPROXY(PROTOCOL PROTO) {
+//  OS.OBJC_MSGSEND(THIS.ID, OS.SEL_SETPROTOCOLFORPROXY_1, PROTO !is NULL ? PROTO.ID : null);
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDistantObjectRequest.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDistantObjectRequest;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSConnection;
+import dwt.internal.cocoa.NSException;
+import dwt.internal.cocoa.NSInvocation;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDistantObjectRequest : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSConnection connection ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_connection);
+        return result !is null ? new NSConnection(result) : null;
+    }
+
+    public id conversation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_conversation);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInvocation invocation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_invocation);
+        return result !is null ? new NSInvocation(result) : null;
+    }
+
+    public void replyWithException (NSException exception)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replyWithException_1, exception !is null ? exception.id : null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDistributedLock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDistributedLock;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDistributedLock : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void breakLock ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_breakLock);
+    }
+
+    public id initWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDate lockDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lockDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public static NSDistributedLock lockWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDistributedLock, OS.sel_lockWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSDistributedLock(result) : null;
+    }
+
+    public bool tryLock ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryLock) !is null;
+    }
+
+    public void unlock ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_unlock);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDistributedNotificationCenter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDistributedNotificationCenter;
+
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSNotificationCenter;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDistributedNotificationCenter : NSNotificationCenter
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObserver_selector_name_object_ (id observer, objc.SEL aSelector, NSString aName, NSString anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1selector_1name_1object_1, observer !is null ? observer.id : null, aSelector,
+                aName !is null ? aName.id : null, anObject !is null ? anObject.id : null);
+    }
+
+    public void addObserver_selector_name_object_suspensionBehavior_ (id observer, objc.SEL selector, NSString name, NSString object,
+            objc.id suspensionBehavior)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1selector_1name_1object_1suspensionBehavior_1, observer !is null ? observer.id : null, selector,
+                name !is null ? name.id : null, object !is null ? object.id : null, suspensionBehavior);
+    }
+
+    public static NSNotificationCenter defaultCenter ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDistributedNotificationCenter, OS.sel_defaultCenter);
+        return result !is null ? new NSNotificationCenter(result) : null;
+    }
+
+    public static NSDistributedNotificationCenter notificationCenterForType (NSString notificationCenterType)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDistributedNotificationCenter, OS.sel_notificationCenterForType_1,
+                notificationCenterType !is null ? notificationCenterType.id : null);
+        return result !is null ? new NSDistributedNotificationCenter(result) : null;
+    }
+
+    public void postNotificationName_object_ (NSString aName, NSString anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postNotificationName_1object_1, aName !is null ? aName.id : null, anObject !is null ? anObject.id : null);
+    }
+
+    public void postNotificationName_object_userInfo_ (NSString aName, NSString anObject, NSDictionary aUserInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postNotificationName_1object_1userInfo_1, aName !is null ? aName.id : null,
+                anObject !is null ? anObject.id : null, aUserInfo !is null ? aUserInfo.id : null);
+    }
+
+    public void postNotificationName_object_userInfo_deliverImmediately_ (NSString name, NSString object, NSDictionary userInfo,
+            bool deliverImmediately)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postNotificationName_1object_1userInfo_1deliverImmediately_1, name !is null ? name.id : null,
+                object !is null ? object.id : null, userInfo !is null ? userInfo.id : null, deliverImmediately);
+    }
+
+    public void postNotificationName_object_userInfo_options_ (NSString name, NSString object, NSDictionary userInfo, NSUInteger options)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postNotificationName_1object_1userInfo_1options_1, name !is null ? name.id : null,
+                object !is null ? object.id : null, userInfo !is null ? userInfo.id : null, options);
+    }
+
+    public void removeObserver (id observer, NSString aName, NSString anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1name_1object_1, observer !is null ? observer.id : null, aName !is null ? aName.id : null,
+                anObject !is null ? anObject.id : null);
+    }
+
+    public void setSuspended (bool suspended)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSuspended_1, suspended);
+    }
+
+    public bool suspended ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_suspended) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDockTile.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDockTile;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDockTile : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString badgeLabel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_badgeLabel);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSView contentView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public void display ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_display);
+    }
+
+    public id owner ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_owner);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setBadgeLabel (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBadgeLabel_1, string !is null ? string.id : null);
+    }
+
+    public void setContentView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentView_1, view !is null ? view.id : null);
+    }
+
+    public void setShowsApplicationBadge (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsApplicationBadge_1, flag);
+    }
+
+    public bool showsApplicationBadge ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsApplicationBadge) !is null;
+    }
+
+    public NSSize size ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_size);
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDocument.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,655 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDocument;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCloseCommand;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSFileWrapper;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPageLayout;
+import dwt.internal.cocoa.NSPrintInfo;
+import dwt.internal.cocoa.NSPrintOperation;
+import dwt.internal.cocoa.NSSavePanel;
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSUndoManager;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.NSWindowController;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSSaveOperationType
+{
+    NSSaveOperation = 0,
+    NSSaveAsOperation = 1,
+    NSSaveToOperation = 2,
+    NSAutosaveOperation = 3
+}
+
+alias NSSaveOperationType.NSSaveOperation NSSaveOperation;
+alias NSSaveOperationType.NSSaveAsOperation NSSaveAsOperation;
+alias NSSaveOperationType.NSSaveToOperation NSSaveToOperation;
+alias NSSaveOperationType.NSAutosaveOperation NSAutosaveOperation;;
+
+public class NSDocument : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addWindowController (NSWindowController windowController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addWindowController_1, windowController !is null ? windowController.id : null);
+    }
+
+    public void autosaveDocumentWithDelegate (id delegatee, objc.SEL didAutosaveSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_autosaveDocumentWithDelegate_1didAutosaveSelector_1contextInfo_1, delegatee !is null ? delegatee.id : null,
+                didAutosaveSelector, contextInfo);
+    }
+
+    public NSURL autosavedContentsFileURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_autosavedContentsFileURL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public NSString autosavingFileType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_autosavingFileType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void canCloseDocumentWithDelegate (id delegatee, objc.SEL shouldCloseSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_canCloseDocumentWithDelegate_1shouldCloseSelector_1contextInfo_1, delegatee !is null ? delegatee.id : null,
+                shouldCloseSelector, contextInfo);
+    }
+
+    public void close ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_close);
+    }
+
+    public NSData dataOfType (NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataOfType_1error_1, typeName !is null ? typeName.id : null, outError);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData dataRepresentationOfType (NSString type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataRepresentationOfType_1, type !is null ? type.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSString displayName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary fileAttributesToWriteToFile (NSString fullDocumentPath, NSString documentTypeName, objc.id saveOperationType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileAttributesToWriteToFile_1ofType_1saveOperation_1,
+                fullDocumentPath !is null ? fullDocumentPath.id : null, documentTypeName !is null ? documentTypeName.id : null, saveOperationType);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary fileAttributesToWriteToURL (NSURL absoluteURL, NSString typeName, objc.id saveOperation, NSURL absoluteOriginalContentsURL,
+            objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileAttributesToWriteToURL_1ofType_1forSaveOperation_1originalContentsURL_1error_1,
+                absoluteURL !is null ? absoluteURL.id : null, typeName !is null ? typeName.id : null, saveOperation,
+                absoluteOriginalContentsURL !is null ? absoluteOriginalContentsURL.id : null, outError);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDate fileModificationDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileModificationDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSString fileName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString fileNameExtensionForType (NSString typeName, objc.id saveOperation)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileNameExtensionForType_1saveOperation_1, typeName !is null ? typeName.id : null,
+                saveOperation);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool fileNameExtensionWasHiddenInLastRunSavePanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileNameExtensionWasHiddenInLastRunSavePanel) !is null;
+    }
+
+    public NSString fileType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString fileTypeFromLastRunSavePanel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileTypeFromLastRunSavePanel);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSURL fileURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileURL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public NSFileWrapper fileWrapperOfType (NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileWrapperOfType_1error_1, typeName !is null ? typeName.id : null, outError);
+        return result !is null ? new NSFileWrapper(result) : null;
+    }
+
+    public NSFileWrapper fileWrapperRepresentationOfType (NSString type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileWrapperRepresentationOfType_1, type !is null ? type.id : null);
+        return result !is null ? new NSFileWrapper(result) : null;
+    }
+
+    public id handleCloseScriptCommand (NSCloseCommand command)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_handleCloseScriptCommand_1, command !is null ? command.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id handlePrintScriptCommand (NSScriptCommand command)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_handlePrintScriptCommand_1, command !is null ? command.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id handleSaveScriptCommand (NSScriptCommand command)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_handleSaveScriptCommand_1, command !is null ? command.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool hasUnautosavedChanges ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasUnautosavedChanges) !is null;
+    }
+
+    public bool hasUndoManager ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasUndoManager) !is null;
+    }
+
+    public NSDocument initForURL (NSURL absoluteDocumentURL, NSURL absoluteDocumentContentsURL, NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initForURL_1withContentsOfURL_1ofType_1error_1,
+                absoluteDocumentURL !is null ? absoluteDocumentURL.id : null,
+                absoluteDocumentContentsURL !is null ? absoluteDocumentContentsURL.id : null, typeName !is null ? typeName.id : null, outError);
+        return result !is null ? this : null;
+    }
+
+    public NSDocument initWithContentsOfFile (NSString absolutePath, NSString typeName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1ofType_1, absolutePath !is null ? absolutePath.id : null,
+                typeName !is null ? typeName.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSDocument initWithContentsOfURL_ofType_ (NSURL absoluteURL, NSString typeName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1ofType_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSDocument initWithContentsOfURL_ofType_error_ (NSURL absoluteURL, NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1ofType_1error_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null, outError);
+        return result !is null ? this : null;
+    }
+
+    public NSDocument initWithType (NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithType_1error_1, typeName !is null ? typeName.id : null, outError);
+        return result !is null ? this : null;
+    }
+
+    public bool isDocumentEdited ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDocumentEdited) !is null;
+    }
+
+    public static bool isNativeType (NSString type)
+    {
+        return OS.objc_msgSend(OS.class_NSDocument, OS.sel_isNativeType_1, type !is null ? type.id : null) !is null;
+    }
+
+    public bool keepBackupFile ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_keepBackupFile) !is null;
+    }
+
+    public NSString lastComponentOfFileName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lastComponentOfFileName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool loadDataRepresentation (NSData data, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_loadDataRepresentation_1ofType_1, data !is null ? data.id : null, type !is null ? type.id : null) !is null;
+    }
+
+    public bool loadFileWrapperRepresentation (NSFileWrapper wrapper, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_loadFileWrapperRepresentation_1ofType_1, wrapper !is null ? wrapper.id : null,
+                type !is null ? type.id : null) !is null;
+    }
+
+    public void makeWindowControllers ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeWindowControllers);
+    }
+
+    public NSScriptObjectSpecifier objectSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectSpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public bool preparePageLayout (NSPageLayout pageLayout)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preparePageLayout_1, pageLayout !is null ? pageLayout.id : null) !is null;
+    }
+
+    public bool prepareSavePanel (NSSavePanel savePanel)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_prepareSavePanel_1, savePanel !is null ? savePanel.id : null) !is null;
+    }
+
+    public bool presentError_ (NSError error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_presentError_1, error !is null ? error.id : null) !is null;
+    }
+
+    public void presentError_modalForWindow_delegatee_didPresentSelector_contextInfo_ (NSError error, NSWindow window, id delegatee,
+            objc.SEL didPresentSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_presentError_1modalForWindow_1delegatee_1didPresentSelector_1contextInfo_1, error !is null ? error.id : null,
+                window !is null ? window.id : null, delegatee !is null ? delegatee.id : null, didPresentSelector, contextInfo);
+    }
+
+    public void printDocument (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_printDocument_1, sender !is null ? sender.id : null);
+    }
+
+    public void printDocumentWithSettings (NSDictionary printSettings, bool showPrintPanel, id delegatee, objc.SEL didPrintSelector,
+            void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_printDocumentWithSettings_1showPrintPanel_1delegatee_1didPrintSelector_1contextInfo_1,
+                printSettings !is null ? printSettings.id : null, showPrintPanel, delegatee !is null ? delegatee.id : null, didPrintSelector,
+                contextInfo);
+    }
+
+    public NSPrintInfo printInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printInfo);
+        return result !is null ? new NSPrintInfo(result) : null;
+    }
+
+    public NSPrintOperation printOperationWithSettings (NSDictionary printSettings, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printOperationWithSettings_1error_1, printSettings !is null ? printSettings.id : null,
+                outError);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public void printShowingPrintPanel (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_printShowingPrintPanel_1, flag);
+    }
+
+    public bool readFromData (NSData data, NSString typeName, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readFromData_1ofType_1error_1, data !is null ? data.id : null, typeName !is null ? typeName.id : null,
+                outError) !is null;
+    }
+
+    public bool readFromFile (NSString fileName, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readFromFile_1ofType_1, fileName !is null ? fileName.id : null, type !is null ? type.id : null) !is null;
+    }
+
+    public bool readFromFileWrapper (NSFileWrapper fileWrapper, NSString typeName, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readFromFileWrapper_1ofType_1error_1, fileWrapper !is null ? fileWrapper.id : null,
+                typeName !is null ? typeName.id : null, outError) !is null;
+    }
+
+    public bool readFromURL_ofType_ (NSURL url, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readFromURL_1ofType_1, url !is null ? url.id : null, type !is null ? type.id : null) !is null;
+    }
+
+    public bool readFromURL_ofType_error_ (NSURL absoluteURL, NSString typeName, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readFromURL_1ofType_1error_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null, outError) !is null;
+    }
+
+    public static NSArray readableTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDocument, OS.sel_readableTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void removeWindowController (NSWindowController windowController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeWindowController_1, windowController !is null ? windowController.id : null);
+    }
+
+    public void revertDocumentToSaved (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_revertDocumentToSaved_1, sender !is null ? sender.id : null);
+    }
+
+    public bool revertToContentsOfURL (NSURL absoluteURL, NSString typeName, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_revertToContentsOfURL_1ofType_1error_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null, outError) !is null;
+    }
+
+    public bool revertToSavedFromFile (NSString fileName, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_revertToSavedFromFile_1ofType_1, fileName !is null ? fileName.id : null,
+                type !is null ? type.id : null) !is null;
+    }
+
+    public bool revertToSavedFromURL (NSURL url, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_revertToSavedFromURL_1ofType_1, url !is null ? url.id : null, type !is null ? type.id : null) !is null;
+    }
+
+    public NSInteger runModalPageLayoutWithPrintInfo_ (NSPrintInfo printInfo)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModalPageLayoutWithPrintInfo_1, printInfo !is null ? printInfo.id : null);
+    }
+
+    public void runModalPageLayoutWithPrintInfo_delegatee_didRunSelector_contextInfo_ (NSPrintInfo printInfo, id delegatee, objc.SEL didRunSelector,
+            void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runModalPageLayoutWithPrintInfo_1delegatee_1didRunSelector_1contextInfo_1,
+                printInfo !is null ? printInfo.id : null, delegatee !is null ? delegatee.id : null, didRunSelector, contextInfo);
+    }
+
+    public void runModalPrintOperation (NSPrintOperation printOperation, id delegatee, objc.SEL didRunSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runModalPrintOperation_1delegatee_1didRunSelector_1contextInfo_1,
+                printOperation !is null ? printOperation.id : null, delegatee !is null ? delegatee.id : null, didRunSelector, contextInfo);
+    }
+
+    public void runModalSavePanelForSaveOperation (objc.id saveOperation, id delegatee, objc.SEL didSaveSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runModalSavePanelForSaveOperation_1delegatee_1didSaveSelector_1contextInfo_1, saveOperation,
+                delegatee !is null ? delegatee.id : null, didSaveSelector, contextInfo);
+    }
+
+    public void runPageLayout (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runPageLayout_1, sender !is null ? sender.id : null);
+    }
+
+    public void saveDocument (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveDocument_1, sender !is null ? sender.id : null);
+    }
+
+    public void saveDocumentAs (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveDocumentAs_1, sender !is null ? sender.id : null);
+    }
+
+    public void saveDocumentTo (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveDocumentTo_1, sender !is null ? sender.id : null);
+    }
+
+    public void saveDocumentWithDelegate (id delegatee, objc.SEL didSaveSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveDocumentWithDelegate_1didSaveSelector_1contextInfo_1, delegatee !is null ? delegatee.id : null,
+                didSaveSelector, contextInfo);
+    }
+
+    public void saveToFile (NSString fileName, objc.id saveOperation, id delegatee, objc.SEL didSaveSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveToFile_1saveOperation_1delegatee_1didSaveSelector_1contextInfo_1, fileName !is null ? fileName.id : null,
+                saveOperation, delegatee !is null ? delegatee.id : null, didSaveSelector, contextInfo);
+    }
+
+    public void saveToURL_ofType_forSaveOperation_delegatee_didSaveSelector_contextInfo_ (NSURL absoluteURL, NSString typeName,
+            objc.id saveOperation, id delegatee, objc.SEL didSaveSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveToURL_1ofType_1forSaveOperation_1delegatee_1didSaveSelector_1contextInfo_1,
+                absoluteURL !is null ? absoluteURL.id : null, typeName !is null ? typeName.id : null, saveOperation,
+                delegatee !is null ? delegatee.id : null, didSaveSelector, contextInfo);
+    }
+
+    public bool saveToURL_ofType_forSaveOperation_error_ (NSURL absoluteURL, NSString typeName, objc.id saveOperation, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_saveToURL_1ofType_1forSaveOperation_1error_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null, saveOperation, outError) !is null;
+    }
+
+    public void setAutosavedContentsFileURL (NSURL absoluteURL)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosavedContentsFileURL_1, absoluteURL !is null ? absoluteURL.id : null);
+    }
+
+    public void setFileModificationDate (NSDate modificationDate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFileModificationDate_1, modificationDate !is null ? modificationDate.id : null);
+    }
+
+    public void setFileName (NSString fileName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFileName_1, fileName !is null ? fileName.id : null);
+    }
+
+    public void setFileType (NSString typeName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFileType_1, typeName !is null ? typeName.id : null);
+    }
+
+    public void setFileURL (NSURL absoluteURL)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFileURL_1, absoluteURL !is null ? absoluteURL.id : null);
+    }
+
+    public void setHasUndoManager (bool hasUndoManager)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasUndoManager_1, hasUndoManager);
+    }
+
+    public void setLastComponentOfFileName (NSString str)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLastComponentOfFileName_1, str !is null ? str.id : null);
+    }
+
+    public void setPrintInfo (NSPrintInfo printInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrintInfo_1, printInfo !is null ? printInfo.id : null);
+    }
+
+    public void setUndoManager (NSUndoManager undoManager)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUndoManager_1, undoManager !is null ? undoManager.id : null);
+    }
+
+    public void setWindow (NSWindow window)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindow_1, window !is null ? window.id : null);
+    }
+
+    public bool shouldChangePrintInfo (NSPrintInfo newPrintInfo)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldChangePrintInfo_1, newPrintInfo !is null ? newPrintInfo.id : null) !is null;
+    }
+
+    public void shouldCloseWindowController (NSWindowController windowController, id delegatee, objc.SEL shouldCloseSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_shouldCloseWindowController_1delegatee_1shouldCloseSelector_1contextInfo_1,
+                windowController !is null ? windowController.id : null, delegatee !is null ? delegatee.id : null, shouldCloseSelector, contextInfo);
+    }
+
+    public bool shouldRunSavePanelWithAccessoryView ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldRunSavePanelWithAccessoryView) !is null;
+    }
+
+    public void showWindows ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_showWindows);
+    }
+
+    public NSUndoManager undoManager ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_undoManager);
+        return result !is null ? new NSUndoManager(result) : null;
+    }
+
+    public void updateChangeCount (objc.id change)
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateChangeCount_1, change);
+    }
+
+    public bool validateUserInterfaceItem (id anItem)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_validateUserInterfaceItem_1, anItem !is null ? anItem.id : null) !is null;
+    }
+
+    public NSError willPresentError (NSError error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_willPresentError_1, error !is null ? error.id : null);
+        return result !is null ? new NSError(result) : null;
+    }
+
+    public void windowControllerDidLoadNib (NSWindowController windowController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_windowControllerDidLoadNib_1, windowController !is null ? windowController.id : null);
+    }
+
+    public void windowControllerWillLoadNib (NSWindowController windowController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_windowControllerWillLoadNib_1, windowController !is null ? windowController.id : null);
+    }
+
+    public NSArray windowControllers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowControllers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSWindow windowForSheet ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowForSheet);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public NSString windowNibName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowNibName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSArray writableTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDocument, OS.sel_writableTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray writableTypesForSaveOperation (objc.id saveOperation)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_writableTypesForSaveOperation_1, saveOperation);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool writeSafelyToURL (NSURL absoluteURL, NSString typeName, objc.id saveOperation, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeSafelyToURL_1ofType_1forSaveOperation_1error_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null, saveOperation, outError) !is null;
+    }
+
+    public bool writeToFile_ofType_ (NSString fileName, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1ofType_1, fileName !is null ? fileName.id : null, type !is null ? type.id : null) !is null;
+    }
+
+    public bool writeToFile_ofType_originalFile_saveOperation_ (NSString fullDocumentPath, NSString documentTypeName,
+            NSString fullOriginalDocumentPath, objc.id saveOperationType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1ofType_1originalFile_1saveOperation_1,
+                fullDocumentPath !is null ? fullDocumentPath.id : null, documentTypeName !is null ? documentTypeName.id : null,
+                fullOriginalDocumentPath !is null ? fullOriginalDocumentPath.id : null, saveOperationType) !is null;
+    }
+
+    public bool writeToURL_ofType_ (NSURL url, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1ofType_1, url !is null ? url.id : null, type !is null ? type.id : null) !is null;
+    }
+
+    public bool writeToURL_ofType_error_ (NSURL absoluteURL, NSString typeName, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1ofType_1error_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null, outError) !is null;
+    }
+
+    public bool writeToURL_ofType_forSaveOperation_originalContentsURL_error_ (NSURL absoluteURL, NSString typeName, objc.id saveOperation,
+            NSURL absoluteOriginalContentsURL, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1ofType_1forSaveOperation_1originalContentsURL_1error_1,
+                absoluteURL !is null ? absoluteURL.id : null, typeName !is null ? typeName.id : null, saveOperation,
+                absoluteOriginalContentsURL !is null ? absoluteOriginalContentsURL.id : null, outError) !is null;
+    }
+
+    public bool writeWithBackupToFile (NSString fullDocumentPath, NSString documentTypeName, objc.id saveOperationType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeWithBackupToFile_1ofType_1saveOperation_1,
+                fullDocumentPath !is null ? fullDocumentPath.id : null, documentTypeName !is null ? documentTypeName.id : null, saveOperationType) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDocumentController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDocumentController;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDocument;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSOpenPanel;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDocumentController : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray URLsFromRunningOpenPanel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URLsFromRunningOpenPanel);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void addDocument (NSDocument document)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addDocument_1, document !is null ? document.id : null);
+    }
+
+    public double autosavingDelay ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_autosavingDelay);
+    }
+
+    public void clearRecentDocuments (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_clearRecentDocuments_1, sender !is null ? sender.id : null);
+    }
+
+    public void closeAllDocumentsWithDelegate (id delegatee, objc.id didCloseAllSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_closeAllDocumentsWithDelegate_1didCloseAllSelector_1contextInfo_1, delegatee !is null ? delegatee.id : null,
+                didCloseAllSelector, contextInfo);
+    }
+
+    public NSString currentDirectory ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentDirectory);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id currentDocument ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentDocument);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString defaultType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString displayNameForType (NSString typeName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayNameForType_1, typeName !is null ? typeName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public Class documentClassForType (NSString typeName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_documentClassForType_1, typeName !is null ? typeName.id : null);
+    }
+
+    public NSArray documentClassNames ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentClassNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id documentForFileName (NSString fileName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentForFileName_1, fileName !is null ? fileName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id documentForURL (NSURL absoluteURL)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentForURL_1, absoluteURL !is null ? absoluteURL.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id documentForWindow (NSWindow window)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentForWindow_1, window !is null ? window.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray documents ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documents);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray fileExtensionsFromType (NSString typeName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileExtensionsFromType_1, typeName !is null ? typeName.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray fileNamesFromRunningOpenPanel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileNamesFromRunningOpenPanel);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool hasEditedDocuments ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasEditedDocuments) !is null;
+    }
+
+    public id makeDocumentForURL (NSURL absoluteDocumentURL, NSURL absoluteDocumentContentsURL, NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeDocumentForURL_1withContentsOfURL_1ofType_1error_1,
+                absoluteDocumentURL !is null ? absoluteDocumentURL.id : null,
+                absoluteDocumentContentsURL !is null ? absoluteDocumentContentsURL.id : null, typeName !is null ? typeName.id : null, outError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id makeDocumentWithContentsOfFile (NSString fileName, NSString type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeDocumentWithContentsOfFile_1ofType_1, fileName !is null ? fileName.id : null,
+                type !is null ? type.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id makeDocumentWithContentsOfURL_ofType_ (NSURL url, NSString type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeDocumentWithContentsOfURL_1ofType_1, url !is null ? url.id : null,
+                type !is null ? type.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id makeDocumentWithContentsOfURL_ofType_error_ (NSURL absoluteURL, NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeDocumentWithContentsOfURL_1ofType_1error_1,
+                absoluteURL !is null ? absoluteURL.id : null, typeName !is null ? typeName.id : null, outError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id makeUntitledDocumentOfType_ (NSString type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeUntitledDocumentOfType_1, type !is null ? type.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id makeUntitledDocumentOfType_error_ (NSString typeName, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeUntitledDocumentOfType_1error_1, typeName !is null ? typeName.id : null, outError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger maximumRecentDocumentCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_maximumRecentDocumentCount);
+    }
+
+    public void newDocument (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_newDocument_1, sender !is null ? sender.id : null);
+    }
+
+    public void noteNewRecentDocument (NSDocument document)
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteNewRecentDocument_1, document !is null ? document.id : null);
+    }
+
+    public void noteNewRecentDocumentURL (NSURL absoluteURL)
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteNewRecentDocumentURL_1, absoluteURL !is null ? absoluteURL.id : null);
+    }
+
+    public void openDocument (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_openDocument_1, sender !is null ? sender.id : null);
+    }
+
+    public id openDocumentWithContentsOfFile (NSString fileName, bool display)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_openDocumentWithContentsOfFile_1display_1, fileName !is null ? fileName.id : null, display);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id openDocumentWithContentsOfURL_display_ (NSURL url, bool display)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_openDocumentWithContentsOfURL_1display_1, url !is null ? url.id : null, display);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id openDocumentWithContentsOfURL_display_error_ (NSURL absoluteURL, bool displayDocument, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_openDocumentWithContentsOfURL_1display_1error_1,
+                absoluteURL !is null ? absoluteURL.id : null, displayDocument, outError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id openUntitledDocumentAndDisplay (bool displayDocument, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_openUntitledDocumentAndDisplay_1error_1, displayDocument, outError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id openUntitledDocumentOfType (NSString type, bool display)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_openUntitledDocumentOfType_1display_1, type !is null ? type.id : null, display);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool presentError_ (NSError error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_presentError_1, error !is null ? error.id : null) !is null;
+    }
+
+    public void presentError_modalForWindow_delegatee_didPresentSelector_contextInfo_ (NSError error, NSWindow window, id delegatee,
+            objc.SEL didPresentSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_presentError_1modalForWindow_1delegatee_1didPresentSelector_1contextInfo_1, error !is null ? error.id : null,
+                window !is null ? window.id : null, delegatee !is null ? delegatee.id : null, didPresentSelector, contextInfo);
+    }
+
+    public NSArray recentDocumentURLs ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_recentDocumentURLs);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void removeDocument (NSDocument document)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeDocument_1, document !is null ? document.id : null);
+    }
+
+    public bool reopenDocumentForURL (NSURL absoluteDocumentURL, NSURL absoluteDocumentContentsURL, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_reopenDocumentForURL_1withContentsOfURL_1error_1,
+                absoluteDocumentURL !is null ? absoluteDocumentURL.id : null,
+                absoluteDocumentContentsURL !is null ? absoluteDocumentContentsURL.id : null, outError) !is null;
+    }
+
+    public void reviewUnsavedDocumentsWithAlertTitle (NSString title, bool cancellable, id delegatee, objc.SEL didReviewAllSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_reviewUnsavedDocumentsWithAlertTitle_1cancellable_1delegatee_1didReviewAllSelector_1contextInfo_1,
+                title !is null ? title.id : null, cancellable, delegatee !is null ? delegatee.id : null, didReviewAllSelector, contextInfo);
+    }
+
+    public NSInteger runModalOpenPanel (NSOpenPanel openPanel, NSArray types)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModalOpenPanel_1forTypes_1, openPanel !is null ? openPanel.id : null,
+                types !is null ? types.id : null);
+    }
+
+    public void saveAllDocuments (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveAllDocuments_1, sender !is null ? sender.id : null);
+    }
+
+    public void setAutosavingDelay (double autosavingDelay)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosavingDelay_1, autosavingDelay);
+    }
+
+    public void setShouldCreateUI (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldCreateUI_1, flag);
+    }
+
+    public static id sharedDocumentController ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSDocumentController, OS.sel_sharedDocumentController);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool shouldCreateUI ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldCreateUI) !is null;
+    }
+
+    public NSString typeForContentsOfURL (NSURL inAbsoluteURL, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_typeForContentsOfURL_1error_1, inAbsoluteURL !is null ? inAbsoluteURL.id : null, outError);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString typeFromFileExtension (NSString fileNameExtensionOrHFSFileType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_typeFromFileExtension_1,
+                fileNameExtensionOrHFSFileType !is null ? fileNameExtensionOrHFSFileType.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool validateUserInterfaceItem (id anItem)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_validateUserInterfaceItem_1, anItem !is null ? anItem.id : null) !is null;
+    }
+
+    public NSError willPresentError (NSError error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_willPresentError_1, error !is null ? error.id : null);
+        return result !is null ? new NSError(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDragOperation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,30 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSDragOperation;
+
+enum NSDragOperation : uint {
+    NSDragOperationNone = 0,
+    NSDragOperationCopy = 1,
+    NSDragOperationLink = 2,
+    NSDragOperationGeneric = 4,
+    NSDragOperationPrivate = 8,
+    NSDragOperationAll_Obsolete = 15,
+    NSDragOperationMove = 16,
+    NSDragOperationDelete = 32,
+    NSDragOperationEvery = uint.max /*UINT_MAX*/
+}
+
+alias NSDragOperation.NSDragOperationNone NSDragOperationNone;
+alias NSDragOperation.NSDragOperationCopy NSDragOperationCopy;
+alias NSDragOperation.NSDragOperationLink NSDragOperationLink;
+alias NSDragOperation.NSDragOperationGeneric NSDragOperationGeneric;
+alias NSDragOperation.NSDragOperationPrivate NSDragOperationPrivate;
+alias NSDragOperation.NSDragOperationAll_Obsolete NSDragOperationAll_Obsolete;
+alias NSDragOperation.NSDragOperationMove NSDragOperationMove;
+alias NSDragOperation.NSDragOperationDelete NSDragOperationDelete;
+alias NSDragOperation.NSDragOperationEvery NSDragOperationEvery;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSDrawer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSDrawer;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSResponder;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+//import dwt.internal.objc.foundation.NSGeometry;
+import objc = dwt.internal.objc.runtime;
+
+public class NSDrawer : NSResponder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void close ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_close);
+    }
+
+    public void close_ (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_close_1, sender !is null ? sender.id : null);
+    }
+
+    public NSSize contentSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentSize);
+        return result;
+    }
+
+    public NSView contentView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRectEdge edge ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_edge);
+    }
+
+    public NSDrawer initWithContentSize (NSSize contentSize, NSRectEdge edge)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentSize_1preferredEdge_1, contentSize, edge);
+        return result !is null ? this : null;
+    }
+
+    public CGFloat leadingOffset ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_leadingOffset);
+    }
+
+    public NSSize maxContentSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_maxContentSize);
+        return result;
+    }
+
+    public NSSize minContentSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_minContentSize);
+        return result;
+    }
+
+    public void open ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_open);
+    }
+
+    public void open_ (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_open_1, sender !is null ? sender.id : null);
+    }
+
+    public void openOnEdge (NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_openOnEdge_1, edge);
+    }
+
+    public NSWindow parentWindow ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parentWindow);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public NSRectEdge preferredEdge ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preferredEdge);
+    }
+
+    public void setContentSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentSize_1, size);
+    }
+
+    public void setContentView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setLeadingOffset (CGFloat offset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLeadingOffset_1, offset);
+    }
+
+    public void setMaxContentSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxContentSize_1, size);
+    }
+
+    public void setMinContentSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinContentSize_1, size);
+    }
+
+    public void setParentWindow (NSWindow parent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParentWindow_1, parent !is null ? parent.id : null);
+    }
+
+    public void setPreferredEdge (NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreferredEdge_1, edge);
+    }
+
+    public void setTrailingOffset (CGFloat offset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTrailingOffset_1, offset);
+    }
+
+    public NSInteger state ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_state);
+    }
+
+    public void toggle (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggle_1, sender !is null ? sender.id : null);
+    }
+
+    public CGFloat trailingOffset ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_trailingOffset);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSEPSImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSEPSImageRep;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSEPSImageRep : NSImageRep
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData EPSRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_EPSRepresentation);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSRect boundingBox ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundingBox);
+        return result;
+    }
+
+    public static id imageRepWithData (NSData epsData)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSEPSImageRep, OS.sel_imageRepWithData_1, epsData !is null ? epsData.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithData (NSData epsData)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, epsData !is null ? epsData.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void prepareGState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_prepareGState);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSEnumerator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSEnumerator;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+struct NSFastEnumerationState
+{
+    uint state;
+    objc.id* itemsPtr;
+    uint* mutationsPtr;
+    /*unsigned long extra[5];*/ uint* extra;
+}
+
+public class NSEnumerator : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray allObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id nextObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextObject);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSError.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSError;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSError : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger code ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_code);
+    }
+
+    public NSString domain ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_domain);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id errorWithDomain (NSString domain, NSInteger code, NSDictionary dict)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSError, OS.sel_errorWithDomain_1code_1userInfo_1, domain !is null ? domain.id : null, code,
+                dict !is null ? dict.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithDomain (NSString domain, NSInteger code, NSDictionary dict)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDomain_1code_1userInfo_1, domain !is null ? domain.id : null, code,
+                dict !is null ? dict.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString localizedDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedDescription);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString localizedFailureReason ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedFailureReason);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray localizedRecoveryOptions ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedRecoveryOptions);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString localizedRecoverySuggestion ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedRecoverySuggestion);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id recoveryAttempter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_recoveryAttempter);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary userInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_userInfo);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSEvent.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,390 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSEvent;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.CGEventTypes;
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTrackingArea;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSEventType
+{
+    NSLeftMouseDown = 1,
+    NSLeftMouseUp = 2,
+    NSRightMouseDown = 3,
+    NSRightMouseUp = 4,
+    NSMouseMoved = 5,
+    NSLeftMouseDragged = 6,
+    NSRightMouseDragged = 7,
+    NSMouseEntered = 8,
+    NSMouseExited = 9,
+    NSKeyDown = 10,
+    NSKeyUp = 11,
+    NSFlagsChanged = 12,
+    NSAppKitDefined = 13,
+    NSSystemDefined = 14,
+    NSApplicationDefined = 15,
+    NSPeriodic = 16,
+    NSCursorUpdate = 17,
+    NSScrollWheel = 22,
+    NSTabletPoint = 23,
+    NSTabletProximity = 24,
+    NSOtherMouseDown = 25,
+    NSOtherMouseUp = 26,
+    NSOtherMouseDragged = 27
+}
+
+enum NSPointingDeviceType
+{
+    NSUnknownPointingDevice = NX_TABLET_POINTER_UNKNOWN,
+    NSPenPointingDevice = NX_TABLET_POINTER_PEN,
+    NSCursorPointingDevice = NX_TABLET_POINTER_CURSOR,
+    NSEraserPointingDevice = NX_TABLET_POINTER_ERASER
+}
+
+public class NSEvent : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public CGEventRef CGEvent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_CGEvent);
+    }
+
+    public NSInteger absoluteX ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_absoluteX);
+    }
+
+    public NSInteger absoluteY ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_absoluteY);
+    }
+
+    public NSInteger absoluteZ ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_absoluteZ);
+    }
+
+    public NSUInteger buttonMask ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_buttonMask);
+    }
+
+    public NSInteger buttonNumber ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_buttonNumber);
+    }
+
+    public NSUInteger capabilityMask ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_capabilityMask);
+    }
+
+    public NSString characters ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_characters);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString charactersIgnoringModifiers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_charactersIgnoringModifiers);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger clickCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_clickCount);
+    }
+
+    public NSGraphicsContext context ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_context);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public NSInteger data1 ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_data1);
+    }
+
+    public NSInteger data2 ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_data2);
+    }
+
+    public CGFloat deltaX ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaX);
+    }
+
+    public CGFloat deltaY ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaY);
+    }
+
+    public CGFloat deltaZ ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_deltaZ);
+    }
+
+    public NSUInteger deviceID ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_deviceID);
+    }
+
+    public static NSEvent enterExitEventWithType (objc.id type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum,
+            NSGraphicsContext context, NSInteger eNum, NSInteger tNum, void* data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSEvent,
+                OS.sel_enterExitEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1trackingNumber_1userData_1,
+                type, location, flags, time, wNum, context !is null ? context.id : null, eNum, tNum, data);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public NSInteger eventNumber ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_eventNumber);
+    }
+
+    public /*const*/void* eventRef ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_eventRef);
+    }
+
+    public static NSEvent eventWithCGEvent (CGEvent cgEvent)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_eventWithCGEvent_1, cgEvent);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public static NSEvent eventWithEventRef (/*const*/void* eventRef)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSEvent, OS.sel_eventWithEventRef_1, eventRef);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public bool isARepeat ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isARepeat) !is null;
+    }
+
+    public bool isEnteringProximity ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnteringProximity) !is null;
+    }
+
+    public static bool isMouseCoalescingEnabled ()
+    {
+        return OS.objc_msgSend(OS.class_NSEvent, OS.sel_isMouseCoalescingEnabled) !is null;
+    }
+
+    public short keyCode ()
+    {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_keyCode);
+    }
+
+    public static NSEvent keyEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum,
+            NSGraphicsContext context, NSString keys, NSString ukeys, bool flag, short code)
+    {
+        objc.id
+                result = OS.objc_msgSend(
+                        OS.class_NSEvent,
+                        OS.sel_keyEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1characters_1charactersIgnoringModifiers_1isARepeat_1keyCode_1,
+                        type, location, flags, time, wNum, context !is null ? context.id : null, keys !is null ? keys.id : null,
+                        ukeys !is null ? ukeys.id : null, flag, code);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public NSPoint locationInWindow ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_locationInWindow);
+        return result;
+    }
+
+    public NSUInteger modifierFlags ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_modifierFlags);
+    }
+
+    public static NSEvent mouseEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum,
+            NSGraphicsContext context, NSInteger eNum, NSInteger cNum, float pressure)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSEvent,
+                OS.sel_mouseEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1clickCount_1pressure_1, type,
+                location, flags, time, wNum, context !is null ? context.id : null, eNum, cNum, pressure);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public static NSPoint mouseLocation ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, OS.class_NSEvent, OS.sel_mouseLocation);
+        return result;
+    }
+
+    public static NSEvent otherEventWithType (NSEventType type, NSPoint location, NSUInteger flags, NSTimeInterval time, NSInteger wNum, NSGraphicsContext context,
+            short subtype, NSInteger d1, NSInteger d2)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSEvent,
+                OS.sel_otherEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1subtype_1data1_1data2_1, type, location, flags,
+                time, wNum, context !is null ? context.id : null, subtype, d1, d2);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public NSUInteger pointingDeviceID ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pointingDeviceID);
+    }
+
+    public NSUInteger pointingDeviceSerialNumber ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pointingDeviceSerialNumber);
+    }
+
+    public NSPointingDeviceType pointingDeviceType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pointingDeviceType);
+    }
+
+    public float pressure ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_pressure);
+    }
+
+    public float rotation ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_rotation);
+    }
+
+    public static void setMouseCoalescingEnabled (bool flag)
+    {
+        OS.objc_msgSend(OS.class_NSEvent, OS.sel_setMouseCoalescingEnabled_1, flag);
+    }
+
+    public static void startPeriodicEventsAfterDelay (double delay, double period)
+    {
+        OS.objc_msgSend(OS.class_NSEvent, OS.sel_startPeriodicEventsAfterDelay_1withPeriod_1, delay, period);
+    }
+
+    public static void stopPeriodicEvents ()
+    {
+        OS.objc_msgSend(OS.class_NSEvent, OS.sel_stopPeriodicEvents);
+    }
+
+    public short subtype ()
+    {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_subtype);
+    }
+
+    public NSUInteger systemTabletID ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_systemTabletID);
+    }
+
+    public NSUInteger tabletID ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tabletID);
+    }
+
+    public float tangentialPressure ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_tangentialPressure);
+    }
+
+    public NSPoint tilt ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_tilt);
+        return result;
+    }
+
+    public NSTimeInterval timestamp ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_timestamp);
+    }
+
+    public NSTrackingArea trackingArea ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_trackingArea);
+        return result !is null ? new NSTrackingArea(result) : null;
+    }
+
+    public NSInteger trackingNumber ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_trackingNumber);
+    }
+
+    public NSEventType type ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_type);
+    }
+
+    public long uniqueID ()
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_uniqueID);
+    }
+
+    public void* userData ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_userData);
+    }
+
+    public id vendorDefined ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_vendorDefined);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger vendorID ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_vendorID);
+    }
+
+    public NSUInteger vendorPointingDeviceType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_vendorPointingDeviceType);
+    }
+
+    public NSWindow window ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_window);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public NSInteger windowNumber ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_windowNumber);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSException.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSException;
+
+import tango.stdc.stdarg : va_list;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSException : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray callStackReturnAddresses ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_callStackReturnAddresses);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSException exceptionWithName (NSString name, NSString reason, NSDictionary userInfo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSException, OS.sel_exceptionWithName_1reason_1userInfo_1, name !is null ? name.id : null,
+                reason !is null ? reason.id : null, userInfo !is null ? userInfo.id : null);
+        return result !is null ? new NSException(result) : null;
+    }
+
+    public id initWithName (NSString aName, NSString aReason, NSDictionary aUserInfo)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1reason_1userInfo_1, aName !is null ? aName.id : null,
+                aReason !is null ? aReason.id : null, aUserInfo !is null ? aUserInfo.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void raise ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_raise);
+    }
+
+    public static void static_raise_format_ (NSString name, NSString format)
+    {
+        OS.objc_msgSend(OS.class_NSException, OS.sel_raise_1format_1, name !is null ? name.id : null, format !is null ? format.id : null);
+    }
+
+    public static void static_raise_format_arguments_ (NSString name, NSString format, va_list argList)
+    {
+        OS.objc_msgSend(OS.class_NSException, OS.sel_raise_1format_1arguments_1, name !is null ? name.id : null, format !is null ? format.id : null,
+                argList);
+    }
+
+    public NSString reason ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_reason);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary userInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_userInfo);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSExpression.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSExpression;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSExpressionType
+{
+    NSConstantValueExpressionType = 0,
+    NSEvaluatedObjectExpressionType,
+    NSVariableExpressionType,
+    NSKeyPathExpressionType,
+    NSFunctionExpressionType,
+    NSAggregateExpressionType,
+    NSSubqueryExpressionType,
+    NSUnionSetExpressionType,
+    NSIntersectSetExpressionType,
+    NSMinusSetExpressionType
+}
+
+public class NSExpression : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray arguments ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arguments);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id collection ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_collection);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id constantValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_constantValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSExpression expressionForAggregate (NSArray subexpressions)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForAggregate_1, subexpressions !is null ? subexpressions.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForConstantValue (id obj)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForConstantValue_1, obj !is null ? obj.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForEvaluatedObject ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForEvaluatedObject);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression static_expressionForFunction_arguments_ (NSString name, NSArray parameters)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForFunction_1arguments_1, name !is null ? name.id : null,
+                parameters !is null ? parameters.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression static_expressionForFunction_selectorName_arguments_ (NSExpression target, NSString name, NSArray parameters)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForFunction_1selectorName_1arguments_1,
+                target !is null ? target.id : null, name !is null ? name.id : null, parameters !is null ? parameters.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForIntersectSet (NSExpression left, NSExpression right)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForIntersectSet_1with_1, left !is null ? left.id : null,
+                right !is null ? right.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForKeyPath (NSString keyPath)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForKeyPath_1, keyPath !is null ? keyPath.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForMinusSet (NSExpression left, NSExpression right)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForMinusSet_1with_1, left !is null ? left.id : null,
+                right !is null ? right.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForSubquery (NSExpression expression, NSString variable, id predicate)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForSubquery_1usingIteratorVariable_1predicate_1,
+                expression !is null ? expression.id : null, variable !is null ? variable.id : null, predicate !is null ? predicate.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForUnionSet (NSExpression left, NSExpression right)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForUnionSet_1with_1, left !is null ? left.id : null,
+                right !is null ? right.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public static NSExpression expressionForVariable (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSExpression, OS.sel_expressionForVariable_1, string !is null ? string.id : null);
+        return result !is null ? new NSExpression(result) : null;
+    }
+
+    public NSExpressionType expressionType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_expressionType);
+    }
+
+    public id expressionValueWithObject (id object, NSMutableDictionary context)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_expressionValueWithObject_1context_1, object !is null ? object.id : null,
+                context !is null ? context.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString functionn ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_function);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initWithExpressionType (NSExpressionType type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithExpressionType_1, type);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString keyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSExpression leftExpression ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_leftExpression);
+        return result is this.id ? this : (result !is null ? new NSExpression(result) : null);
+    }
+
+    public NSExpression operand ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_operand);
+        return result is this.id ? this : (result !is null ? new NSExpression(result) : null);
+    }
+
+    public NSPredicate predicate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_predicate);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public NSExpression rightExpression ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rightExpression);
+        return result is this.id ? this : (result !is null ? new NSExpression(result) : null);
+    }
+
+    public NSString variable ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_variable);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFileHandle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFileHandle;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSFileHandle : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void acceptConnectionInBackgroundAndNotify ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_acceptConnectionInBackgroundAndNotify);
+    }
+
+    public void acceptConnectionInBackgroundAndNotifyForModes (NSArray modes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_acceptConnectionInBackgroundAndNotifyForModes_1, modes !is null ? modes.id : null);
+    }
+
+    public NSData availableData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableData);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void closeFile ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_closeFile);
+    }
+
+    public int fileDescriptor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileDescriptor);
+    }
+
+    public static id fileHandleForReadingAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleForReadingAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id fileHandleForUpdatingAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleForUpdatingAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id fileHandleForWritingAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleForWritingAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id fileHandleWithNullDevice ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithNullDevice);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id fileHandleWithStandardError ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithStandardError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id fileHandleWithStandardInput ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithStandardInput);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id fileHandleWithStandardOutput ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileHandle, OS.sel_fileHandleWithStandardOutput);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithFileDescriptor_ (int fd)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFileDescriptor_1, fd);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithFileDescriptor_closeOnDealloc_ (int fd, bool closeopt)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFileDescriptor_1closeOnDealloc_1, fd, closeopt);
+        return result !is null ? new id(result) : null;
+    }
+
+    public long offsetInFile ()
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_offsetInFile);
+    }
+
+    public NSData readDataOfLength (NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_readDataOfLength_1, length);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData readDataToEndOfFile ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_readDataToEndOfFile);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void readInBackgroundAndNotify ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_readInBackgroundAndNotify);
+    }
+
+    public void readInBackgroundAndNotifyForModes (NSArray modes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_readInBackgroundAndNotifyForModes_1, modes !is null ? modes.id : null);
+    }
+
+    public void readToEndOfFileInBackgroundAndNotify ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_readToEndOfFileInBackgroundAndNotify);
+    }
+
+    public void readToEndOfFileInBackgroundAndNotifyForModes (NSArray modes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_readToEndOfFileInBackgroundAndNotifyForModes_1, modes !is null ? modes.id : null);
+    }
+
+    public long seekToEndOfFile ()
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_seekToEndOfFile);
+    }
+
+    public void seekToFileOffset (long offset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_seekToFileOffset_1, offset);
+    }
+
+    public void synchronizeFile ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_synchronizeFile);
+    }
+
+    public void truncateFileAtOffset (long offset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_truncateFileAtOffset_1, offset);
+    }
+
+    public void waitForDataInBackgroundAndNotify ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_waitForDataInBackgroundAndNotify);
+    }
+
+    public void waitForDataInBackgroundAndNotifyForModes (NSArray modes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_waitForDataInBackgroundAndNotifyForModes_1, modes !is null ? modes.id : null);
+    }
+
+    public void writeData (NSData data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_writeData_1, data !is null ? data.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFileManager.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFileManager;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSDirectoryEnumerator;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSFileManager : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSDictionary attributesOfFileSystemForPath (NSString path, objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesOfFileSystemForPath_1error_1, path !is null ? path.id : null, error);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary attributesOfItemAtPath (NSString path, objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesOfItemAtPath_1error_1, path !is null ? path.id : null, error);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public bool changeCurrentDirectoryPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_changeCurrentDirectoryPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool changeFileAttributes (NSDictionary attributes, NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_changeFileAttributes_1atPath_1, attributes !is null ? attributes.id : null,
+                path !is null ? path.id : null) !is null;
+    }
+
+    public NSArray componentsToDisplayForPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_componentsToDisplayForPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSData contentsAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentsAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public bool contentsEqualAtPath (NSString path1, NSString path2)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_contentsEqualAtPath_1andPath_1, path1 !is null ? path1.id : null, path2 !is null ? path2.id : null) !is null;
+    }
+
+    public NSArray contentsOfDirectoryAtPath (NSString path, objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentsOfDirectoryAtPath_1error_1, path !is null ? path.id : null, error);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool copyItemAtPath (NSString srcPath, NSString dstPath, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_copyItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id : null,
+                dstPath !is null ? dstPath.id : null, error) !is null;
+    }
+
+    public bool copyPath (NSString src, NSString dest, id handler)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_copyPath_1toPath_1handler_1, src !is null ? src.id : null, dest !is null ? dest.id : null,
+                handler !is null ? handler.id : null) !is null;
+    }
+
+    public bool createDirectoryAtPath_attributes_ (NSString path, NSDictionary attributes)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_createDirectoryAtPath_1attributes_1, path !is null ? path.id : null,
+                attributes !is null ? attributes.id : null) !is null;
+    }
+
+    public bool createDirectoryAtPath_withIntermediateDirectories_attributes_error_ (NSString path, bool createIntermediates,
+            NSDictionary attributes, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_createDirectoryAtPath_1withIntermediateDirectories_1attributes_1error_1,
+                path !is null ? path.id : null, createIntermediates, attributes !is null ? attributes.id : null, error) !is null;
+    }
+
+    public bool createFileAtPath (NSString path, NSData data, NSDictionary attr)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_createFileAtPath_1contents_1attributes_1, path !is null ? path.id : null,
+                data !is null ? data.id : null, attr !is null ? attr.id : null) !is null;
+    }
+
+    public bool createSymbolicLinkAtPath_pathContent_ (NSString path, NSString otherpath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_createSymbolicLinkAtPath_1pathContent_1, path !is null ? path.id : null,
+                otherpath !is null ? otherpath.id : null) !is null;
+    }
+
+    public bool createSymbolicLinkAtPath_withDestinationPath_error_ (NSString path, NSString destPath, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_createSymbolicLinkAtPath_1withDestinationPath_1error_1, path !is null ? path.id : null,
+                destPath !is null ? destPath.id : null, error) !is null;
+    }
+
+    public NSString currentDirectoryPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentDirectoryPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSFileManager defaultManager ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFileManager, OS.sel_defaultManager);
+        return result !is null ? new NSFileManager(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString destinationOfSymbolicLinkAtPath (NSString path, objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_destinationOfSymbolicLinkAtPath_1error_1, path !is null ? path.id : null, error);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray directoryContentsAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_directoryContentsAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString displayNameAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayNameAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDirectoryEnumerator enumeratorAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_enumeratorAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSDirectoryEnumerator(result) : null;
+    }
+
+    public NSDictionary fileAttributesAtPath (NSString path, bool yorn)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileAttributesAtPath_1traverseLink_1, path !is null ? path.id : null, yorn);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public bool fileExistsAtPath_ (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileExistsAtPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool fileExistsAtPath_isDirectory_ (NSString path, bool* isDirectory)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileExistsAtPath_1isDirectory_1, path !is null ? path.id : null, isDirectory) !is null;
+    }
+
+    public NSDictionary fileSystemAttributesAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileSystemAttributesAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public /*const*/char* fileSystemRepresentationWithPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileSystemRepresentationWithPath_1, path !is null ? path.id : null);
+    }
+
+    public bool isDeletableFileAtPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDeletableFileAtPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool isExecutableFileAtPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExecutableFileAtPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool isReadableFileAtPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isReadableFileAtPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool isWritableFileAtPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isWritableFileAtPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool linkItemAtPath (NSString srcPath, NSString dstPath, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_linkItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id : null,
+                dstPath !is null ? dstPath.id : null, error) !is null;
+    }
+
+    public bool linkPath (NSString src, NSString dest, id handler)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_linkPath_1toPath_1handler_1, src !is null ? src.id : null, dest !is null ? dest.id : null,
+                handler !is null ? handler.id : null) !is null;
+    }
+
+    public bool moveItemAtPath (NSString srcPath, NSString dstPath, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_moveItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id : null,
+                dstPath !is null ? dstPath.id : null, error) !is null;
+    }
+
+    public bool movePath (NSString src, NSString dest, id handler)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_movePath_1toPath_1handler_1, src !is null ? src.id : null, dest !is null ? dest.id : null,
+                handler !is null ? handler.id : null) !is null;
+    }
+
+    public NSString pathContentOfSymbolicLinkAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathContentOfSymbolicLinkAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool removeFileAtPath (NSString path, id handler)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removeFileAtPath_1handler_1, path !is null ? path.id : null, handler !is null ? handler.id : null) !is null;
+    }
+
+    public bool removeItemAtPath (NSString path, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removeItemAtPath_1error_1, path !is null ? path.id : null, error) !is null;
+    }
+
+    public bool setAttributes (NSDictionary attributes, NSString path, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setAttributes_1ofItemAtPath_1error_1, attributes !is null ? attributes.id : null,
+                path !is null ? path.id : null, error) !is null;
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public NSString stringWithFileSystemRepresentation (/*const*/char* str, NSUInteger len)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringWithFileSystemRepresentation_1length_1, str, len);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray subpathsAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subpathsAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray subpathsOfDirectoryAtPath (NSString path, objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subpathsOfDirectoryAtPath_1error_1, path !is null ? path.id : null, error);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFileWrapper.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFileWrapper;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSFileWrapper;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSFileWrapper : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString addFileWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addFileWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString addFileWrapper (NSFileWrapper doc)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addFileWrapper_1, doc !is null ? doc.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString addRegularFileWithContents (NSData data, NSString filename)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addRegularFileWithContents_1preferredFilename_1, data !is null ? data.id : null,
+                filename !is null ? filename.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString addSymbolicLinkWithDestination (NSString path, NSString filename)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addSymbolicLinkWithDestination_1preferredFilename_1, path !is null ? path.id : null,
+                filename !is null ? filename.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary fileAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary fileWrappers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileWrappers);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString filename ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_filename);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSImage icon ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_icon);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public id initDirectoryWithFileWrappers (NSDictionary docs)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initDirectoryWithFileWrappers_1, docs !is null ? docs.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initRegularFileWithContents (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initRegularFileWithContents_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initSymbolicLinkWithDestination (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initSymbolicLinkWithDestination_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithSerializedRepresentation (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSerializedRepresentation_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isDirectory ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDirectory) !is null;
+    }
+
+    public bool isRegularFile ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRegularFile) !is null;
+    }
+
+    public bool isSymbolicLink ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSymbolicLink) !is null;
+    }
+
+    public NSString keyForFileWrapper (NSFileWrapper doc)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyForFileWrapper_1, doc !is null ? doc.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool needsToBeUpdatedFromPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_needsToBeUpdatedFromPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public NSString preferredFilename ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_preferredFilename);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSData regularFileContents ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_regularFileContents);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void removeFileWrapper (NSFileWrapper doc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFileWrapper_1, doc !is null ? doc.id : null);
+    }
+
+    public NSData serializedRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_serializedRepresentation);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void setFileAttributes (NSDictionary attributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFileAttributes_1, attributes !is null ? attributes.id : null);
+    }
+
+    public void setFilename (NSString filename)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFilename_1, filename !is null ? filename.id : null);
+    }
+
+    public void setIcon (NSImage icon)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIcon_1, icon !is null ? icon.id : null);
+    }
+
+    public void setPreferredFilename (NSString filename)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreferredFilename_1, filename !is null ? filename.id : null);
+    }
+
+    public NSString symbolicLinkDestination ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_symbolicLinkDestination);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool updateFromPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_updateFromPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool writeToFile (NSString path, bool atomicFlag, bool updateFilenamesFlag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1updateFilenames_1, path !is null ? path.id : null, atomicFlag,
+                updateFilenamesFlag) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFocusRingType.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,18 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 6, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSFocusRingType;
+
+enum NSFocusRingType {
+    NSFocusRingTypeDefault = 0,
+    NSFocusRingTypeNone = 1,
+    NSFocusRingTypeExterior = 2
+}
+
+alias NSFocusRingType.NSFocusRingTypeDefault NSFocusRingTypeDefault;
+alias NSFocusRingType.NSFocusRingTypeNone NSFocusRingTypeNone;
+alias NSFocusRingType.NSFocusRingTypeExterior NSFocusRingTypeExterior;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFont.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,474 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFont;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCharacterSet;
+import dwt.internal.cocoa.NSCell : NSControlSize;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSFontDescriptor;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+//import dwt.internal.objc.foundation.NSGeometry;
+import objc = dwt.internal.objc.runtime;
+
+alias uint NSGlyph;
+
+enum NSMultibyteGlyphPacking
+{
+    NSNativeShortGlyphPacking = 5
+}
+
+enum NSGlyphRelation
+{
+    NSGlyphBelow = 1,
+    NSGlyphAbove = 2
+}
+
+enum NSFontRenderingMode
+{
+    NSFontDefaultRenderingMode = 0,
+    NSFontAntialiasedRenderingMode = 1,
+    NSFontIntegerAdvancementsRenderingMode = 2,
+    NSFontAntialiasedIntegerAdvancementsRenderingMode = 3
+}
+
+public class NSFont : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSSize advancementForGlyph (NSGlyph ag)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_advancementForGlyph_1, ag);
+        return result;
+    }
+
+    public NSDictionary afmDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_afmDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public CGFloat ascender ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_ascender);
+    }
+
+    public static NSFont boldSystemFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_boldSystemFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSRect boundingRectForFont ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundingRectForFont);
+        return result;
+    }
+
+    public NSRect boundingRectForGlyph (NSGlyph aGlyph)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundingRectForGlyph_1, aGlyph);
+        return result;
+    }
+
+    public CGFloat capHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_capHeight);
+    }
+
+    public static NSFont controlContentFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_controlContentFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSCharacterSet coveredCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_coveredCharacterSet);
+        return result !is null ? new NSCharacterSet(result) : null;
+    }
+
+    public CGFloat defaultLineHeightForFont ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_defaultLineHeightForFont);
+    }
+
+    public CGFloat descender ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_descender);
+    }
+
+    public NSString displayName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString encodingScheme ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_encodingScheme);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString familyName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_familyName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSFontDescriptor fontDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptor);
+        return result !is null ? new NSFontDescriptor(result) : null;
+    }
+
+    public NSString fontName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSFont static_fontWithDescriptor_size_ (NSFontDescriptor fontDescriptor, CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithDescriptor_1size_1, fontDescriptor !is null ? fontDescriptor.id : null,
+                fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static NSFont static_fontWithDescriptor_textTransform_ (NSFontDescriptor fontDescriptor, NSAffineTransform textTransform)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithDescriptor_1textTransform_1,
+                fontDescriptor !is null ? fontDescriptor.id : null, textTransform !is null ? textTransform.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static NSFont static_fontWithName_matrix_ (NSString fontName, CGFloat fontMatrix)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithName_1matrix_1, fontName !is null ? fontName.id : null, fontMatrix);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static NSFont static_fontWithName_size_ (NSString fontName, CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_fontWithName_1size_1, fontName !is null ? fontName.id : null, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public void getAdvancements_forGlyphs_count_ (NSSizeArray advancements, /*const*/NSGlyph* glyphs, NSUInteger glyphCount)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getAdvancements_1forGlyphs_1count_1, advancements, glyphs, glyphCount);
+    }
+
+    public void getAdvancements_forPackedGlyphs_length_ (NSSizeArray advancements, /*const*/void* packedGlyphs, NSUInteger length)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getAdvancements_1forPackedGlyphs_1length_1, advancements, packedGlyphs, length);
+    }
+
+    public void getBoundingRects (NSRectArray bounds, /*const*/NSGlyph* glyphs, NSUInteger glyphCount)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getBoundingRects_1forGlyphs_1count_1, bounds, glyphs, glyphCount);
+    }
+
+    public bool glyphIsEncoded (NSGlyph aGlyph)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphIsEncoded_1, aGlyph) !is null;
+    }
+
+    public NSMultibyteGlyphPacking glyphPacking ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphPacking);
+    }
+
+    public NSGlyph glyphWithName (NSString aName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphWithName_1, aName !is null ? aName.id : null);
+    }
+
+    public bool isBaseFont ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBaseFont) !is null;
+    }
+
+    public bool isFixedPitch ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFixedPitch) !is null;
+    }
+
+    public CGFloat italicAngle ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_italicAngle);
+    }
+
+    public static NSFont labelFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_labelFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static CGFloat labelFontSize ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_labelFontSize);
+    }
+
+    public CGFloat leading ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_leading);
+    }
+
+    public /*const*/CGFloat* matrix ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_matrix);
+    }
+
+    public NSSize maximumAdvancement ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_maximumAdvancement);
+        return result;
+    }
+
+    public static NSFont menuBarFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_menuBarFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static NSFont menuFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_menuFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static NSFont messageFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_messageFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSStringEncoding mostCompatibleStringEncoding ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mostCompatibleStringEncoding);
+    }
+
+    public NSUInteger numberOfGlyphs ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfGlyphs);
+    }
+
+    public static NSFont paletteFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_paletteFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public CGFloat pointSize ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_pointSize);
+    }
+
+    public NSPoint positionOfGlyph_forCharacter_struckOverRect_ (NSGlyph aGlyph, short aChar, NSRect aRect)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_positionOfGlyph_1forCharacter_1struckOverRect_1, aGlyph, aChar, aRect);
+        return result;
+    }
+
+    public NSPoint positionOfGlyph_precededByGlyph_isNominal_ (NSGlyph curGlyph, NSGlyph prevGlyph, bool* nominal)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_positionOfGlyph_1precededByGlyph_1isNominal_1, curGlyph, prevGlyph, nominal);
+        return result;
+    }
+
+    public NSPoint positionOfGlyph_struckOverGlyph_metricsExist_ (NSGlyph curGlyph, NSGlyph prevGlyph, bool* exist)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_positionOfGlyph_1struckOverGlyph_1metricsExist_1, curGlyph, prevGlyph, exist);
+        return result;
+    }
+
+    public NSPoint positionOfGlyph_struckOverRect_metricsExist_ (NSGlyph aGlyph, NSRect aRect, bool* exist)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_positionOfGlyph_1struckOverRect_1metricsExist_1, aGlyph, aRect, exist);
+        return result;
+    }
+
+    public NSPoint positionOfGlyph_withRelation_toBaseGlyph_totalAdvancement_metricsExist_ (NSGlyph thisGlyph, NSGlyphRelation rel,
+            NSGlyph baseGlyph, NSSizePointer adv, bool* exist)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_positionOfGlyph_1withRelation_1toBaseGlyph_1totalAdvancement_1metricsExist_1, thisGlyph, rel,
+                baseGlyph, adv, exist);
+        return result;
+    }
+
+    public NSInteger positionsForCompositeSequence (NSGlyph* someGlyphs, NSInteger numGlyphs, NSPointArray points)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_positionsForCompositeSequence_1numberOfGlyphs_1pointArray_1, someGlyphs, numGlyphs, points);
+    }
+
+    public static NSArray preferredFontNames ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_preferredFontNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSFont printerFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printerFont);
+        return result is this.id ? this : (result !is null ? new NSFont(result) : null);
+    }
+
+    public NSFontRenderingMode renderingMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_renderingMode);
+    }
+
+    public NSFont screenFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_screenFont);
+        return result is this.id ? this : (result !is null ? new NSFont(result) : null);
+    }
+
+    public NSFont screenFontWithRenderingMode (NSFontRenderingMode renderingMode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_screenFontWithRenderingMode_1, renderingMode);
+        return result is this.id ? this : (result !is null ? new NSFont(result) : null);
+    }
+
+    public void set ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_set);
+    }
+
+    public void setInContext (NSGraphicsContext graphicsContext)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInContext_1, graphicsContext !is null ? graphicsContext.id : null);
+    }
+
+    public static void setPreferredFontNames (NSArray fontNameArray)
+    {
+        OS.objc_msgSend(OS.class_NSFont, OS.sel_setPreferredFontNames_1, fontNameArray !is null ? fontNameArray.id : null);
+    }
+
+    public static void setUserFixedPitchFont (NSFont aFont)
+    {
+        OS.objc_msgSend(OS.class_NSFont, OS.sel_setUserFixedPitchFont_1, aFont !is null ? aFont.id : null);
+    }
+
+    public static void setUserFont (NSFont aFont)
+    {
+        OS.objc_msgSend(OS.class_NSFont, OS.sel_setUserFont_1, aFont !is null ? aFont.id : null);
+    }
+
+    public static CGFloat smallSystemFontSize ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_smallSystemFontSize);
+    }
+
+    public static NSFont systemFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_systemFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static CGFloat systemFontSize ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_systemFontSize);
+    }
+
+    public static CGFloat systemFontSizeForControlSize (NSControlSize controlSize)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSFont, OS.sel_systemFontSizeForControlSize_1, controlSize);
+    }
+
+    public NSAffineTransform textTransform ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textTransform);
+        return result !is null ? new NSAffineTransform(result) : null;
+    }
+
+    public static NSFont titleBarFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_titleBarFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static NSFont toolTipsFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_toolTipsFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public CGFloat underlinePosition ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_underlinePosition);
+    }
+
+    public CGFloat underlineThickness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_underlineThickness);
+    }
+
+    public static void useFont (NSString fontName)
+    {
+        OS.objc_msgSend(OS.class_NSFont, OS.sel_useFont_1, fontName !is null ? fontName.id : null);
+    }
+
+    public static NSFont userFixedPitchFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_userFixedPitchFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public static NSFont userFontOfSize (CGFloat fontSize)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFont, OS.sel_userFontOfSize_1, fontSize);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public CGFloat widthOfString (NSString string)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_widthOfString_1, string !is null ? string.id : null);
+    }
+
+    public CGFloat xHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_xHeight);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFontDescriptor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFontDescriptor;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSSet;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias uint NSFontSymbolicTraits; 
+
+public class NSFontDescriptor : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSDictionary fontAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSFontDescriptor fontDescriptorByAddingAttributes (NSDictionary attributes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptorByAddingAttributes_1, attributes !is null ? attributes.id : null);
+        return result is this.id ? this : (result !is null ? new NSFontDescriptor(result) : null);
+    }
+
+    public NSFontDescriptor fontDescriptorWithFace (NSString newFace)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptorWithFace_1, newFace !is null ? newFace.id : null);
+        return result is this.id ? this : (result !is null ? new NSFontDescriptor(result) : null);
+    }
+
+    public NSFontDescriptor fontDescriptorWithFamily (NSString newFamily)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptorWithFamily_1, newFamily !is null ? newFamily.id : null);
+        return result is this.id ? this : (result !is null ? new NSFontDescriptor(result) : null);
+    }
+
+    public static NSFontDescriptor fontDescriptorWithFontAttributes (NSDictionary attributes)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFontDescriptor, OS.sel_fontDescriptorWithFontAttributes_1,
+                attributes !is null ? attributes.id : null);
+        return result !is null ? new NSFontDescriptor(result) : null;
+    }
+
+    public NSFontDescriptor fontDescriptorWithMatrix (NSAffineTransform matrix)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptorWithMatrix_1, matrix !is null ? matrix.id : null);
+        return result is this.id ? this : (result !is null ? new NSFontDescriptor(result) : null);
+    }
+
+    public static NSFontDescriptor static_fontDescriptorWithName_matrix_ (NSString fontName, NSAffineTransform matrix)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFontDescriptor, OS.sel_fontDescriptorWithName_1matrix_1, fontName !is null ? fontName.id : null,
+                matrix !is null ? matrix.id : null);
+        return result !is null ? new NSFontDescriptor(result) : null;
+    }
+
+    public static NSFontDescriptor static_fontDescriptorWithName_size_ (NSString fontName, CGFloat size)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFontDescriptor, OS.sel_fontDescriptorWithName_1size_1, fontName !is null ? fontName.id : null,
+                size);
+        return result !is null ? new NSFontDescriptor(result) : null;
+    }
+
+    public NSFontDescriptor fontDescriptorWithSize (CGFloat newPointSize)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptorWithSize_1, newPointSize);
+        return result is this.id ? this : (result !is null ? new NSFontDescriptor(result) : null);
+    }
+
+    public NSFontDescriptor fontDescriptorWithSymbolicTraits (NSFontSymbolicTraits symbolicTraits)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptorWithSymbolicTraits_1, symbolicTraits);
+        return result is this.id ? this : (result !is null ? new NSFontDescriptor(result) : null);
+    }
+
+    public id initWithFontAttributes (NSDictionary attributes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFontAttributes_1, attributes !is null ? attributes.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSFontDescriptor matchingFontDescriptorWithMandatoryKeys (NSSet mandatoryKeys)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_matchingFontDescriptorWithMandatoryKeys_1, mandatoryKeys !is null ? mandatoryKeys.id : null);
+        return result is this.id ? this : (result !is null ? new NSFontDescriptor(result) : null);
+    }
+
+    public NSArray matchingFontDescriptorsWithMandatoryKeys (NSSet mandatoryKeys)
+    {
+        objc.id
+                result = OS.objc_msgSend(this.id, OS.sel_matchingFontDescriptorsWithMandatoryKeys_1, mandatoryKeys !is null ? mandatoryKeys.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSAffineTransform matrix ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_matrix);
+        return result !is null ? new NSAffineTransform(result) : null;
+    }
+
+    public id objectForKey (NSString anAttribute)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_1, anAttribute !is null ? anAttribute.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public CGFloat pointSize ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_pointSize);
+    }
+
+    public NSString postscriptName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_postscriptName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSFontSymbolicTraits symbolicTraits ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_symbolicTraits);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFontManager.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,341 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFontManager;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSFontDescriptor;
+import dwt.internal.cocoa.NSFontPanel;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias uint NSFontTraitMask;
+
+enum NSFontAction
+{
+    NSNoFontChangeAction = 0,
+    NSViaPanelFontAction = 1,
+    NSAddTraitFontAction = 2,
+    NSSizeUpFontAction = 3,
+    NSSizeDownFontAction = 4,
+    NSHeavierFontAction = 5,
+    NSLighterFontAction = 6,
+    NSRemoveTraitFontAction = 7
+}
+
+public class NSFontManager : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.SEL action ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_action);
+    }
+
+    public bool addCollection (NSString collectionName, NSInteger collectionOptions)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_addCollection_1options_1, collectionName !is null ? collectionName.id : null, collectionOptions) !is null;
+    }
+
+    public void addFontDescriptors (NSArray descriptors, NSString collectionName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addFontDescriptors_1toCollection_1, descriptors !is null ? descriptors.id : null,
+                collectionName !is null ? collectionName.id : null);
+    }
+
+    public void addFontTrait (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addFontTrait_1, sender !is null ? sender.id : null);
+    }
+
+    public NSArray availableFontFamilies ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFontFamilies);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray availableFontNamesMatchingFontDescriptor (NSFontDescriptor descriptor)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFontNamesMatchingFontDescriptor_1, descriptor !is null ? descriptor.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray availableFontNamesWithTraits (NSFontTraitMask someTraits)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFontNamesWithTraits_1, someTraits);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray availableFonts ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableFonts);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray availableMembersOfFontFamily (NSString fam)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableMembersOfFontFamily_1, fam !is null ? fam.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray collectionNames ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_collectionNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSDictionary convertAttributes (NSDictionary attributes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertAttributes_1, attributes !is null ? attributes.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSFont convertFont_ (NSFont fontObj)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertFont_1, fontObj !is null ? fontObj.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSFont convertFont_toFace_ (NSFont fontObj, NSString typeface)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertFont_1toFace_1, fontObj !is null ? fontObj.id : null,
+                typeface !is null ? typeface.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSFont convertFont_toFamily_ (NSFont fontObj, NSString family)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertFont_1toFamily_1, fontObj !is null ? fontObj.id : null,
+                family !is null ? family.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSFont convertFont_toHaveTrait_ (NSFont fontObj, NSFontTraitMask trait)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertFont_1toHaveTrait_1, fontObj !is null ? fontObj.id : null, trait);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSFont convertFont_toNotHaveTrait_ (NSFont fontObj, NSFontTraitMask trait)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertFont_1toNotHaveTrait_1, fontObj !is null ? fontObj.id : null, trait);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSFont convertFont_toSize_ (NSFont fontObj, CGFloat size)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertFont_1toSize_1, fontObj !is null ? fontObj.id : null, size);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSFontTraitMask convertFontTraits (NSFontTraitMask traits)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_convertFontTraits_1, traits);
+    }
+
+    public NSFont convertWeight (bool upFlag, NSFont fontObj)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_convertWeight_1ofFont_1, upFlag, fontObj !is null ? fontObj.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSFontAction currentFontAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_currentFontAction);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray fontDescriptorsInCollection (NSString collectionNames)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontDescriptorsInCollection_1, collectionNames !is null ? collectionNames.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSMenu fontMenu (bool create)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontMenu_1, create);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public bool fontNamed (NSString fName, NSFontTraitMask someTraits)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fontNamed_1hasTraits_1, fName !is null ? fName.id : null, someTraits) !is null;
+    }
+
+    public NSFontPanel fontPanel (bool create)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontPanel_1, create);
+        return result !is null ? new NSFontPanel(result) : null;
+    }
+
+    public NSFont fontWithFamily (NSString family, NSFontTraitMask traits, NSInteger weight, GCFloat size)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fontWithFamily_1traits_1weight_1size_1, family !is null ? family.id : null, traits, weight,
+                size);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public bool isMultiple ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMultiple) !is null;
+    }
+
+    public NSString localizedNameForFamily (NSString family, NSString faceKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedNameForFamily_1face_1, family !is null ? family.id : null,
+                faceKey !is null ? faceKey.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void modifyFont (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_modifyFont_1, sender !is null ? sender.id : null);
+    }
+
+    public void modifyFontViaPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_modifyFontViaPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontFontPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontFontPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontStylesPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontStylesPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public bool removeCollection (NSString collectionName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removeCollection_1, collectionName !is null ? collectionName.id : null) !is null;
+    }
+
+    public void removeFontDescriptor (NSFontDescriptor descriptor, NSString collection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFontDescriptor_1fromCollection_1, descriptor !is null ? descriptor.id : null,
+                collection !is null ? collection.id : null);
+    }
+
+    public void removeFontTrait (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFontTrait_1, sender !is null ? sender.id : null);
+    }
+
+    public NSFont selectedFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedFont);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public bool sendAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendAction) !is null;
+    }
+
+    public void setAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, aSelector);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, flag);
+    }
+
+    public static void setFontManagerFactory (Class factoryId)
+    {
+        OS.objc_msgSend(OS.class_NSFontManager, OS.sel_setFontManagerFactory_1, factoryId);
+    }
+
+    public void setFontMenu (NSMenu newMenu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFontMenu_1, newMenu !is null ? newMenu.id : null);
+    }
+
+    public static void setFontPanelFactory (Class factoryId)
+    {
+        OS.objc_msgSend(OS.class_NSFontManager, OS.sel_setFontPanelFactory_1, factoryId);
+    }
+
+    public void setSelectedAttributes (NSDictionary attributes, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedAttributes_1isMultiple_1, attributes !is null ? attributes.id : null, flag);
+    }
+
+    public void setSelectedFont (NSFont fontObj, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedFont_1isMultiple_1, fontObj !is null ? fontObj.id : null, flag);
+    }
+
+    public void setTarget (id aTarget)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, aTarget !is null ? aTarget.id : null);
+    }
+
+    public static NSFontManager sharedFontManager ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFontManager, OS.sel_sharedFontManager);
+        return result !is null ? new NSFontManager(result) : null;
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSFontTraitMask traitsOfFont (NSFont fontObj)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_traitsOfFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public NSInteger weightOfFont (NSFont fontObj)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_weightOfFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFontPanel.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFontPanel;
+
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSPanel;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSFontPanel : NSPanel
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public NSFont panelConvertFont (NSFont fontObj)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_panelConvertFont_1, fontObj !is null ? fontObj.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public void reloadDefaultFontFamilies ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadDefaultFontFamilies);
+    }
+
+    public void setAccessoryView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, flag);
+    }
+
+    public void setPanelFont (NSFont fontObj, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPanelFont_1isMultiple_1, fontObj !is null ? fontObj.id : null, flag);
+    }
+
+    public static NSFontPanel sharedFontPanel ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSFontPanel, OS.sel_sharedFontPanel);
+        return result !is null ? new NSFontPanel(result) : null;
+    }
+
+    public static bool sharedFontPanelExists ()
+    {
+        return OS.objc_msgSend(OS.class_NSFontPanel, OS.sel_sharedFontPanelExists) !is null;
+    }
+
+    public bool worksWhenModal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_worksWhenModal) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSForm.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSForm;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSFormCell;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMatrix;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText : NSTextAlignment, NSWritingDirection;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSForm : NSMatrix
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSFormCell addEntry (NSString title)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addEntry_1, title !is null ? title.id : null);
+        return result !is null ? new NSFormCell(result) : null;
+    }
+
+    public id cellAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cellAtIndex_1, index);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void drawCellAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawCellAtIndex_1, index);
+    }
+
+    public NSInteger indexOfCellWithTag (NSInteger aTag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfCellWithTag_1, aTag);
+    }
+
+    public NSInteger indexOfSelectedItem ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem);
+    }
+
+    public NSFormCell insertEntry (NSString title, int index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_insertEntry_1atIndex_1, title !is null ? title.id : null, index);
+        return result !is null ? new NSFormCell(result) : null;
+    }
+
+    public void removeEntryAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeEntryAtIndex_1, index);
+    }
+
+    public void selectTextAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectTextAtIndex_1, index);
+    }
+
+    public void setBezeled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezeled_1, flag);
+    }
+
+    public void setBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBordered_1, flag);
+    }
+
+    public void setEntryWidth (CGFloat width)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEntryWidth_1, width);
+    }
+
+    public void setFrameSize (NSSize newSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameSize_1, newSize);
+    }
+
+    public void setInterlineSpacing (CGFloat spacing)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInterlineSpacing_1, spacing);
+    }
+
+    public void setTextAlignment (NSInteger mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAlignment_1, mode);
+    }
+
+    public void setTextBaseWritingDirection (NSWritingDirection writingDirection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextBaseWritingDirection_1, writingDirection);
+    }
+
+    public void setTextFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setTitleAlignment (NSTextAlignment mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleAlignment_1, mode);
+    }
+
+    public void setTitleBaseWritingDirection (NSWritingDirection writingDirection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleBaseWritingDirection_1, writingDirection);
+    }
+
+    public void setTitleFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFormCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFormCell;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSText : NSTextAlignment, NSWritingDirection;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSFormCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSAttributedString attributedTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedTitle);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public bool isOpaque ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOpaque) !is null;
+    }
+
+    public NSAttributedString placeholderAttributedString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_placeholderAttributedString);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSString placeholderString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_placeholderString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setAttributedTitle (NSAttributedString obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedTitle_1, obj !is null ? obj.id : null);
+    }
+
+    public void setPlaceholderAttributedString (NSAttributedString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaceholderAttributedString_1, string !is null ? string.id : null);
+    }
+
+    public void setPlaceholderString (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaceholderString_1, string !is null ? string.id : null);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleAlignment (NSTextAlignment mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleAlignment_1, mode);
+    }
+
+    public void setTitleBaseWritingDirection (NSWritingDirection writingDirection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleBaseWritingDirection_1, writingDirection);
+    }
+
+    public void setTitleFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public void setTitleWidth (CGFloat width)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWidth_1, width);
+    }
+
+    public void setTitleWithMnemonic (NSString stringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithMnemonic_1, stringWithAmpersand !is null ? stringWithAmpersand.id : null);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSTextAlignment titleAlignment ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_titleAlignment);
+    }
+
+    public NSWritingDirection titleBaseWritingDirection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_titleBaseWritingDirection);
+    }
+
+    public NSFont titleFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleFont);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public CGFloat titleWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_titleWidth);
+    }
+
+    public CGFloat titleWidth_ (NSSize aSize)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_titleWidth_1, aSize);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSFormatter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSFormatter;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSFormatter : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSAttributedString attributedStringForObjectValue (id obj, NSDictionary attrs)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedStringForObjectValue_1withDefaultAttributes_1, obj !is null ? obj.id : null,
+                attrs !is null ? attrs.id : null);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSString editingStringForObjectValue (id obj)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_editingStringForObjectValue_1, obj !is null ? obj.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool getObjectValue (objc.id* obj, NSString str, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getObjectValue_1forString_1errorDescription_1, obj, str !is null ? str.id : null, error) !is null;
+    }
+
+    public bool isPartialStringValid_newEditingString_errorDescription_ (NSString partialString, objc.id** newString, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isPartialStringValid_1newEditingString_1errorDescription_1,
+                partialString !is null ? partialString.id : null, newString, error) !is null;
+    }
+
+    public bool isPartialStringValid_proposedSelectedRange_originalString_originalSelectedRange_errorDescription_ (objc.id** partialStringPtr,
+            NSRangePointer proposedSelRangePtr, NSString origString, NSRange origSelRange, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id,
+                OS.sel_isPartialStringValid_1proposedSelectedRange_1originalString_1originalSelectedRange_1errorDescription_1, partialStringPtr,
+                proposedSelRangePtr, origString !is null ? origString.id : null, origSelRange, error) !is null;
+    }
+
+    public NSString stringForObjectValue (id obj)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringForObjectValue_1, obj !is null ? obj.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSGarbageCollector.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSGarbageCollector;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSGarbageCollector : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void collectExhaustively ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_collectExhaustively);
+    }
+
+    public void collectIfNeeded ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_collectIfNeeded);
+    }
+
+    public static id defaultCollector ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGarbageCollector, OS.sel_defaultCollector);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void disable ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_disable);
+    }
+
+    public void disableCollectorForPointer (void* ptr)
+    {
+        OS.objc_msgSend(this.id, OS.sel_disableCollectorForPointer_1, ptr);
+    }
+
+    public void enable ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_enable);
+    }
+
+    public void enableCollectorForPointer (void* ptr)
+    {
+        OS.objc_msgSend(this.id, OS.sel_enableCollectorForPointer_1, ptr);
+    }
+
+    public bool isCollecting ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isCollecting) !is null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public NSZone zone ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_zone);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSGlyphGenerator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSGlyphGenerator;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSGlyphGenerator : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void generateGlyphsForGlyphStorage (id glyphStorage, NSUInteger nChars, NSUInteger* glyphIndex, NSUInteger* charIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_generateGlyphsForGlyphStorage_1desiredNumberOfCharacters_1glyphIndex_1characterIndex_1,
+                glyphStorage !is null ? glyphStorage.id : null, nChars, glyphIndex, charIndex);
+    }
+
+    public static id sharedGlyphGenerator ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGlyphGenerator, OS.sel_sharedGlyphGenerator);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSGlyphInfo.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSGlyphInfo;
+
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSCharacterCollection
+{
+    NSIdentityMappingCharacterCollection = 0,
+    NSAdobeCNS1CharacterCollection = 1,
+    NSAdobeGB1CharacterCollection = 2,
+    NSAdobeJapan1CharacterCollection = 3,
+    NSAdobeJapan2CharacterCollection = 4,
+    NSAdobeKorea1CharacterCollection = 5,
+}
+
+public class NSGlyphInfo : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSCharacterCollection characterCollection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_characterCollection);
+    }
+
+    public NSUInteger characterIdentifier ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_characterIdentifier);
+    }
+
+    public static NSGlyphInfo glyphInfoWithCharacterIdentifier (NSUInteger cid, NSCharacterCollection characterCollection, NSString theString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGlyphInfo, OS.sel_glyphInfoWithCharacterIdentifier_1collection_1baseString_1, cid,
+                characterCollection, theString !is null ? theString.id : null);
+        return result !is null ? new NSGlyphInfo(result) : null;
+    }
+
+    public static NSGlyphInfo glyphInfoWithGlyph (NSGlyph glyph, NSFont font, NSString theString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGlyphInfo, OS.sel_glyphInfoWithGlyph_1forFont_1baseString_1, glyph,
+                font !is null ? font.id : null, theString !is null ? theString.id : null);
+        return result !is null ? new NSGlyphInfo(result) : null;
+    }
+
+    public static NSGlyphInfo glyphInfoWithGlyphName (NSString glyphName, NSFont font, NSString theString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGlyphInfo, OS.sel_glyphInfoWithGlyphName_1forFont_1baseString_1,
+                glyphName !is null ? glyphName.id : null, font !is null ? font.id : null, theString !is null ? theString.id : null);
+        return result !is null ? new NSGlyphInfo(result) : null;
+    }
+
+    public NSString glyphName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_glyphName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSGradient.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSGradient;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSColorSpace;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSUInteger NSGradientDrawingOptions;
+
+public class NSGradient : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSColorSpace colorSpace ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorSpace);
+        return result !is null ? new NSColorSpace(result) : null;
+    }
+
+    public void drawFromCenter (NSPoint startCenter, CGFloat startRadius, NSPoint endCenter, CGFloat endRadius, NSGradientDrawingOptions options)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawFromCenter_1radius_1toCenter_1radius_1options_1, startCenter, startRadius, endCenter, endRadius, options);
+    }
+
+    public void drawFromPoint (NSPoint startingPoint, NSPoint endingPoint, NSGradientDrawingOptions options)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawFromPoint_1toPoint_1options_1, startingPoint, endingPoint, options);
+    }
+
+    public void drawInBezierPath_angle_ (NSBezierPath path, CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInBezierPath_1angle_1, path !is null ? path.id : null, angle);
+    }
+
+    public void drawInBezierPath_relativeCenterPosition_ (NSBezierPath path, NSPoint relativeCenterPosition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInBezierPath_1relativeCenterPosition_1, path !is null ? path.id : null, relativeCenterPosition);
+    }
+
+    public void drawInRect_angle_ (NSRect rect, CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInRect_1angle_1, rect, angle);
+    }
+
+    public void drawInRect_relativeCenterPosition_ (NSRect rect, NSPoint relativeCenterPosition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInRect_1relativeCenterPosition_1, rect, relativeCenterPosition);
+    }
+
+    public void getColor (objc.id** color, CGFloat* location, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getColor_1location_1atIndex_1, color, location, index);
+    }
+
+    public NSGradient initWithColors_ (NSArray colorArray)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithColors_1, colorArray !is null ? colorArray.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSGradient initWithColors_atLocations_colorSpace_ (NSArray colorArray, /*const*/CGFloat* locations, NSColorSpace colorSpace)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithColors_1atLocations_1colorSpace_1, colorArray !is null ? colorArray.id : null,
+                locations, colorSpace !is null ? colorSpace.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSGradient initWithColorsAndLocations (NSColor initWithColorsAndLocations)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithColorsAndLocations_1,
+                initWithColorsAndLocations !is null ? initWithColorsAndLocations.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSGradient initWithStartingColor (NSColor startingColor, NSColor endingColor)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithStartingColor_1endingColor_1, startingColor !is null ? startingColor.id : null,
+                endingColor !is null ? endingColor.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSColor interpolatedColorAtLocation (CGFloat location)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_interpolatedColorAtLocation_1, location);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSInteger numberOfColorStops ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfColorStops);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSGraphicsContext.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSGraphicsContext;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSBitmapImageRep;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSImage : NSCompositingOperation;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSInteger NSColorRenderingIntent;
+
+enum
+{
+    NSColorRenderingIntentDefault,
+    NSColorRenderingIntentAbsoluteColorimetric,
+    NSColorRenderingIntentRelativeColorimetric,
+    NSColorRenderingIntentPerceptual,
+    NSColorRenderingIntentSaturation
+}
+
+enum NSImageInterpolation
+{
+    NSImageInterpolationDefault,
+    NSImageInterpolationNone,
+    NSImageInterpolationLow,
+    NSImageInterpolationHigh
+}
+
+public class NSGraphicsContext : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    //public CIContext CIContext() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_CIContext);
+    //  return result !is null ? new CIContext(result) : null;
+    //}
+
+    public NSDictionary attributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSColorRenderingIntent colorRenderingIntent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_colorRenderingIntent);
+    }
+
+    public NSCompositingOperation compositingOperation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compositingOperation);
+    }
+
+    public static NSGraphicsContext currentContext ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_currentContext);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static bool currentContextDrawingToScreen ()
+    {
+        return OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_currentContextDrawingToScreen) !is null;
+    }
+
+    public void flushGraphics ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushGraphics);
+    }
+
+    public id focusStack ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_focusStack);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithAttributes (NSDictionary attributes)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithAttributes_1,
+                attributes !is null ? attributes.id : null);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithBitmapImageRep (NSBitmapImageRep bitmapRep)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithBitmapImageRep_1,
+                bitmapRep !is null ? bitmapRep.id : null);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithGraphicsPort (void* graphicsPort, bool initialFlippedState)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithGraphicsPort_1flipped_1, graphicsPort,
+                initialFlippedState);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static NSGraphicsContext graphicsContextWithWindow (NSWindow window)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_graphicsContextWithWindow_1, window !is null ? window.id : null);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public void* graphicsPort ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_graphicsPort);
+    }
+
+    public NSImageInterpolation imageInterpolation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageInterpolation);
+    }
+
+    public bool isDrawingToScreen ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDrawingToScreen) !is null;
+    }
+
+    public bool isFlipped ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
+    }
+
+    public NSPoint patternPhase ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_patternPhase);
+        return result;
+    }
+
+    public void restoreGraphicsState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_restoreGraphicsState);
+    }
+
+    public static void static_restoreGraphicsState ()
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_restoreGraphicsState);
+    }
+
+    public void saveGraphicsState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveGraphicsState);
+    }
+
+    public static void static_saveGraphicsState ()
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_saveGraphicsState);
+    }
+
+    public void setColorRenderingIntent (NSColorRenderingIntent renderingIntent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColorRenderingIntent_1, renderingIntent);
+    }
+
+    public void setCompositingOperation (NSCompositingOperation operation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCompositingOperation_1, operation);
+    }
+
+    public static void setCurrentContext (NSGraphicsContext context)
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_setCurrentContext_1, context !is null ? context.id : null);
+    }
+
+    public void setFocusStack (id stack)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFocusStack_1, stack !is null ? stack.id : null);
+    }
+
+    public static void setGraphicsState (NSInteger gState)
+    {
+        OS.objc_msgSend(OS.class_NSGraphicsContext, OS.sel_setGraphicsState_1, gState);
+    }
+
+    public void setImageInterpolation (NSImageInterpolation interpolation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageInterpolation_1, interpolation);
+    }
+
+    public void setPatternPhase (NSPoint phase)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPatternPhase_1, phase);
+    }
+
+    public void setShouldAntialias (bool antialias)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldAntialias_1, antialias);
+    }
+
+    public bool shouldAntialias ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldAntialias) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHTTPCookie.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHTTPCookie;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSHTTPCookie : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString comment ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_comment);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSURL commentURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commentURL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public static id cookieWithProperties (NSDictionary properties)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHTTPCookie, OS.sel_cookieWithProperties_1, properties !is null ? properties.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSArray cookiesWithResponseHeaderFields (NSDictionary headerFields, NSURL URL)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHTTPCookie, OS.sel_cookiesWithResponseHeaderFields_1forURL_1,
+                headerFields !is null ? headerFields.id : null, URL !is null ? URL.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString domain ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_domain);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDate expiresDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_expiresDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public id initWithProperties (NSDictionary properties)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithProperties_1, properties !is null ? properties.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isSecure ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSecure) !is null;
+    }
+
+    public bool isSessionOnly ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSessionOnly) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString path ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_path);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray portList ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portList);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSDictionary properties ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_properties);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public static NSDictionary requestHeaderFieldsWithCookies (NSArray cookies)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHTTPCookie, OS.sel_requestHeaderFieldsWithCookies_1, cookies !is null ? cookies.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString value ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_value);
+        return result !is null ? new NSString(result) : null;
+    }
+
+//public NSUInteger version() {
+//  return OS.objc_msgSend(this.id, OS.sel_version);
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHTTPCookieStorage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHTTPCookieStorage;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSHTTPCookie;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSHTTPCookieAcceptPolicy
+{
+    NSHTTPCookieAcceptPolicyAlways,
+    NSHTTPCookieAcceptPolicyNever,
+    NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain
+}
+
+public class NSHTTPCookieStorage : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSHTTPCookieAcceptPolicy cookieAcceptPolicy ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_cookieAcceptPolicy);
+    }
+
+    public NSArray cookies ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cookies);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray cookiesForURL (NSURL URL)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cookiesForURL_1, URL !is null ? URL.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void deleteCookie (NSHTTPCookie cookie)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteCookie_1, cookie !is null ? cookie.id : null);
+    }
+
+    public void setCookie (NSHTTPCookie cookie)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCookie_1, cookie !is null ? cookie.id : null);
+    }
+
+    public void setCookieAcceptPolicy (NSHTTPCookieAcceptPolicy cookieAcceptPolicy)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCookieAcceptPolicy_1, cookieAcceptPolicy);
+    }
+
+    public void setCookies (NSArray cookies, NSURL URL, NSURL mainDocumentURL)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCookies_1forURL_1mainDocumentURL_1, cookies !is null ? cookies.id : null, URL !is null ? URL.id : null,
+                mainDocumentURL !is null ? mainDocumentURL.id : null);
+    }
+
+    public static NSHTTPCookieStorage sharedHTTPCookieStorage ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHTTPCookieStorage, OS.sel_sharedHTTPCookieStorage);
+        return result !is null ? new NSHTTPCookieStorage(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHTTPURLResponse.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHTTPURLResponse;
+
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURLResponse;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSHTTPURLResponse : NSURLResponse
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSDictionary allHeaderFields ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allHeaderFields);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public static NSString localizedStringForStatusCode (NSInteger statusCode)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHTTPURLResponse, OS.sel_localizedStringForStatusCode_1, statusCode);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger statusCode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_statusCode);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHashEnumerator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHashEnumerator;
+
+public class NSHashEnumerator {
+//TODO
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHashTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHashTable;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPointerFunctions;
+import dwt.internal.cocoa.NSSet;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSHashTable : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObject_1, object !is null ? object.id : null);
+    }
+
+    public NSArray allObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id anyObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_anyObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool containsObject (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsObject_1, anObject !is null ? anObject.id : null) !is null;
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public static id hashTableWithOptions (NSPointerFunctionsOptions options)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHashTable, OS.sel_hashTableWithOptions_1, options);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id hashTableWithWeakObjects ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHashTable, OS.sel_hashTableWithWeakObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithOptions (NSPointerFunctionsOptions options, NSUInteger initialCapacity)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithOptions_1capacity_1, options, initialCapacity);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithPointerFunctions (NSPointerFunctions functions, NSUInteger initialCapacity)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPointerFunctions_1capacity_1, functions !is null ? functions.id : null,
+                initialCapacity);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void intersectHashTable (NSHashTable other)
+    {
+        OS.objc_msgSend(this.id, OS.sel_intersectHashTable_1, other !is null ? other.id : null);
+    }
+
+    public bool intersectsHashTable (NSHashTable other)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_intersectsHashTable_1, other !is null ? other.id : null) !is null;
+    }
+
+    public bool isEqualToHashTable (NSHashTable other)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToHashTable_1, other !is null ? other.id : null) !is null;
+    }
+
+    public bool isSubsetOfHashTable (NSHashTable other)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSubsetOfHashTable_1, other !is null ? other.id : null) !is null;
+    }
+
+    public id member (id object)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_member_1, object !is null ? object.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void minusHashTable (NSHashTable other)
+    {
+        OS.objc_msgSend(this.id, OS.sel_minusHashTable_1, other !is null ? other.id : null);
+    }
+
+    public NSEnumerator objectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public NSPointerFunctions pointerFunctions ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pointerFunctions);
+        return result !is null ? new NSPointerFunctions(result) : null;
+    }
+
+    public void removeAllObjects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllObjects);
+    }
+
+    public void removeObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObject_1, object !is null ? object.id : null);
+    }
+
+    public NSSet setRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_setRepresentation);
+        return result !is null ? new NSSet(result) : null;
+    }
+
+    public void unionHashTable (NSHashTable other)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unionHashTable_1, other !is null ? other.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHashTableCallBacks.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHashTableCallBacks;
+
+public class NSHashTableCallBacks {
+//TODO
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHelpManager.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHelpManager;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSHelpManager : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSAttributedString contextHelpForObject (id object)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contextHelpForObject_1, object !is null ? object.id : null);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public void findString (NSString query, NSString book)
+    {
+        OS.objc_msgSend(this.id, OS.sel_findString_1inBook_1, query !is null ? query.id : null, book !is null ? book.id : null);
+    }
+
+    public static bool isContextHelpModeActive ()
+    {
+        return OS.objc_msgSend(OS.class_NSHelpManager, OS.sel_isContextHelpModeActive) !is null;
+    }
+
+    public void openHelpAnchor (NSString anchor, NSString book)
+    {
+        OS.objc_msgSend(this.id, OS.sel_openHelpAnchor_1inBook_1, anchor !is null ? anchor.id : null, book !is null ? book.id : null);
+    }
+
+    public void removeContextHelpForObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeContextHelpForObject_1, object !is null ? object.id : null);
+    }
+
+    public void setContextHelp (NSAttributedString attrString, id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContextHelp_1forObject_1, attrString !is null ? attrString.id : null, object !is null ? object.id : null);
+    }
+
+    public static void setContextHelpModeActive (bool active)
+    {
+        OS.objc_msgSend(OS.class_NSHelpManager, OS.sel_setContextHelpModeActive_1, active);
+    }
+
+    public static NSHelpManager sharedHelpManager ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHelpManager, OS.sel_sharedHelpManager);
+        return result !is null ? new NSHelpManager(result) : null;
+    }
+
+    public bool showContextHelpForObject (id object, NSPoint pt)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showContextHelpForObject_1locationHint_1, object !is null ? object.id : null, pt) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSHost.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSHost;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSHost : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString address ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_address);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray addresses ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addresses);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSHost currentHost ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHost, OS.sel_currentHost);
+        return result !is null ? new NSHost(result) : null;
+    }
+
+    public static void flushHostCache ()
+    {
+        OS.objc_msgSend(OS.class_NSHost, OS.sel_flushHostCache);
+    }
+
+    public static NSHost hostWithAddress (NSString address)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHost, OS.sel_hostWithAddress_1, address !is null ? address.id : null);
+        return result !is null ? new NSHost(result) : null;
+    }
+
+    public static NSHost hostWithName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSHost, OS.sel_hostWithName_1, name !is null ? name.id : null);
+        return result !is null ? new NSHost(result) : null;
+    }
+
+    public bool isEqualToHost (NSHost aHost)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToHost_1, aHost !is null ? aHost.id : null) !is null;
+    }
+
+    public static bool isHostCacheEnabled ()
+    {
+        return OS.objc_msgSend(OS.class_NSHost, OS.sel_isHostCacheEnabled) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray names ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_names);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static void setHostCacheEnabled (bool flag)
+    {
+        OS.objc_msgSend(OS.class_NSHost, OS.sel_setHostCacheEnabled_1, flag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSImage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,440 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSImage;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.IconRef;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSBitmapImageRep : NSTIFFCompression;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSCompositingOperation
+{
+    NSCompositeClear = 0,
+    NSCompositeCopy = 1,
+    NSCompositeSourceOver = 2,
+    NSCompositeSourceIn = 3,
+    NSCompositeSourceOut = 4,
+    NSCompositeSourceAtop = 5,
+    NSCompositeDestinationOver = 6,
+    NSCompositeDestinationIn = 7,
+    NSCompositeDestinationOut = 8,
+    NSCompositeDestinationAtop = 9,
+    NSCompositeXOR = 10,
+    NSCompositePlusDarker = 11,
+    NSCompositeHighlight = 12,
+    NSCompositePlusLighter = 13
+}
+
+enum NSImageCacheMode
+{
+    NSImageCacheDefault,
+    NSImageCacheAlways,
+    NSImageCacheBySize,
+    NSImageCacheNever
+}
+
+public class NSImage : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData TIFFRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentation);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData TIFFRepresentationUsingCompression (NSTIFFCompression comp, float aFloat)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentationUsingCompression_1factor_1, comp, aFloat);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void addRepresentation (NSImageRep imageRep)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addRepresentation_1, imageRep !is null ? imageRep.id : null);
+    }
+
+    public void addRepresentations (NSArray imageReps)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addRepresentations_1, imageReps !is null ? imageReps.id : null);
+    }
+
+    public NSRect alignmentRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_alignmentRect);
+        return result;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSImageRep bestRepresentationForDevice (NSDictionary deviceDescription)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bestRepresentationForDevice_1, deviceDescription !is null ? deviceDescription.id : null);
+        return result !is null ? new NSImageRep(result) : null;
+    }
+
+    public bool cacheDepthMatchesImageDepth ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_cacheDepthMatchesImageDepth) !is null;
+    }
+
+    public NSImageCacheMode cacheMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_cacheMode);
+    }
+
+    public static bool canInitWithPasteboard (NSPasteboard pasteboard)
+    {
+        return OS.objc_msgSend(OS.class_NSImage, OS.sel_canInitWithPasteboard_1, pasteboard !is null ? pasteboard.id : null) !is null;
+    }
+
+    public void cancelIncrementalLoad ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelIncrementalLoad);
+    }
+
+    public void compositeToPoint_fromRect_operation_ (NSPoint point, NSRect rect, NSCompositingOperation op)
+    {
+        OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1fromRect_1operation_1, point, rect, op);
+    }
+
+    public void compositeToPoint_fromRect_operation_fraction_ (NSPoint point, NSRect rect, NSCompositingOperation op, CGFloat delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1fromRect_1operation_1fraction_1, point, rect, op, delta);
+    }
+
+    public void compositeToPoint_operation_ (NSPoint point, NSCompositingOperation op)
+    {
+        OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1operation_1, point, op);
+    }
+
+    public void compositeToPoint_operation_fraction_ (NSPoint point, NSCompositingOperation op, CGFloat delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_compositeToPoint_1operation_1fraction_1, point, op, delta);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void dissolveToPoint_fraction_ (NSPoint point, CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_dissolveToPoint_1fraction_1, point, aFloat);
+    }
+
+    public void dissolveToPoint_fromRect_fraction_ (NSPoint point, NSRect rect, CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_dissolveToPoint_1fromRect_1fraction_1, point, rect, aFloat);
+    }
+
+    public void drawAtPoint (NSPoint point, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawAtPoint_1fromRect_1operation_1fraction_1, point, fromRect, op, delta);
+    }
+
+    public void drawInRect (NSRect rect, NSRect fromRect, NSCompositingOperation op, CGFloat delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInRect_1fromRect_1operation_1fraction_1, rect, fromRect, op, delta);
+    }
+
+    public bool drawRepresentation (NSImageRep imageRep, NSRect rect)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawRepresentation_1inRect_1, imageRep !is null ? imageRep.id : null, rect) !is null;
+    }
+
+    public static NSArray imageFileTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageFileTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static id imageNamed (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageNamed_1, name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSArray imagePasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imagePasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageUnfilteredFileTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageUnfilteredFileTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageUnfilteredPasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageUnfilteredPasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageUnfilteredTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageUnfilteredTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSImage initByReferencingFile (NSString fileName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initByReferencingFile_1, fileName !is null ? fileName.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSImage initByReferencingURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initByReferencingURL_1, url !is null ? url.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSImage initWithContentsOfFile (NSString fileName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, fileName !is null ? fileName.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSImage initWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSImage initWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSImage initWithIconRef (IconRef iconRef)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIconRef_1, iconRef);
+        return result !is null ? this : null;
+    }
+
+    public NSImage initWithPasteboard (NSPasteboard pasteboard)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPasteboard_1, pasteboard !is null ? pasteboard.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSImage initWithSize (NSSize aSize)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSize_1, aSize);
+        return result !is null ? this : null;
+    }
+
+    public bool isCachedSeparately ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isCachedSeparately) !is null;
+    }
+
+    public bool isDataRetained ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDataRetained) !is null;
+    }
+
+    public bool isFlipped ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
+    }
+
+    public bool isTemplate ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTemplate) !is null;
+    }
+
+    public bool isValid ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isValid) !is null;
+    }
+
+    public void lockFocus ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_lockFocus);
+    }
+
+    public void lockFocusOnRepresentation (NSImageRep imageRepresentation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_lockFocusOnRepresentation_1, imageRepresentation !is null ? imageRepresentation.id : null);
+    }
+
+    public bool matchesOnMultipleResolution ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_matchesOnMultipleResolution) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool prefersColorMatch ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_prefersColorMatch) !is null;
+    }
+
+    public void recache ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_recache);
+    }
+
+    public void removeRepresentation (NSImageRep imageRep)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeRepresentation_1, imageRep !is null ? imageRep.id : null);
+    }
+
+    public NSArray representations ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representations);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool scalesWhenResized ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scalesWhenResized) !is null;
+    }
+
+    public void setAlignmentRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlignmentRect_1, rect);
+    }
+
+    public void setBackgroundColor (NSColor aColor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, aColor !is null ? aColor.id : null);
+    }
+
+    public void setCacheDepthMatchesImageDepth (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCacheDepthMatchesImageDepth_1, flag);
+    }
+
+    public void setCacheMode (NSImageCacheMode mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCacheMode_1, mode);
+    }
+
+    public void setCachedSeparately (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCachedSeparately_1, flag);
+    }
+
+    public void setDataRetained (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDataRetained_1, flag);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setFlipped (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFlipped_1, flag);
+    }
+
+    public void setMatchesOnMultipleResolution (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMatchesOnMultipleResolution_1, flag);
+    }
+
+    public bool setName (NSString string)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setName_1, string !is null ? string.id : null) !is null;
+    }
+
+    public void setPrefersColorMatch (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrefersColorMatch_1, flag);
+    }
+
+    public void setScalesWhenResized (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScalesWhenResized_1, flag);
+    }
+
+    public void setSize (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSize_1, aSize);
+    }
+
+    public void setTemplate (bool isTemplate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTemplate_1, isTemplate);
+    }
+
+    public void setUsesEPSOnResolutionMismatch (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesEPSOnResolutionMismatch_1, flag);
+    }
+
+    public NSSize size ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_size);
+        return result;
+    }
+
+    public void unlockFocus ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_unlockFocus);
+    }
+
+    public bool usesEPSOnResolutionMismatch ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesEPSOnResolutionMismatch) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSImageCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSImageCell;
+
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSImageAlignment
+{
+    NSImageAlignCenter = 0,
+    NSImageAlignTop,
+    NSImageAlignTopLeft,
+    NSImageAlignTopRight,
+    NSImageAlignLeft,
+    NSImageAlignBottom,
+    NSImageAlignBottomLeft,
+    NSImageAlignBottomRight,
+    NSImageAlignRight
+}
+
+enum NSImageFrameStyle
+{
+    NSImageFrameNone = 0,
+    NSImageFramePhoto,
+    NSImageFrameGrayBezel,
+    NSImageFrameGroove,
+    NSImageFrameButton
+}
+
+enum NSImageScaling
+{
+    NSScaleProportionally = 0,
+    NSScaleToFit,
+    NSScaleNone
+}
+
+public class NSImageCell : NSCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSImageAlignment imageAlignment ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageAlignment);
+    }
+
+    public NSImageFrameStyle imageFrameStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageFrameStyle);
+    }
+
+    public NSImageScaling imageScaling ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageScaling);
+    }
+
+    public void setImageAlignment (NSImageAlignment newAlign)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageAlignment_1, newAlign);
+    }
+
+    public void setImageFrameStyle (NSImageFrameStyle newStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageFrameStyle_1, newStyle);
+    }
+
+    public void setImageScaling (NSImageScaling newScaling)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageScaling_1, newScaling);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSImageRep;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSImageRep : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger bitsPerSample ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bitsPerSample);
+    }
+
+    public static bool canInitWithData (NSData data)
+    {
+        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_canInitWithData_1, data !is null ? data.id : null) !is null;
+    }
+
+    public static bool canInitWithPasteboard (NSPasteboard pasteboard)
+    {
+        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_canInitWithPasteboard_1, pasteboard !is null ? pasteboard.id : null) !is null;
+    }
+
+    public NSString colorSpaceName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_colorSpaceName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool draw ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_draw) !is null;
+    }
+
+    public bool drawAtPoint (NSPoint point)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawAtPoint_1, point) !is null;
+    }
+
+    public bool drawInRect (NSRect rect)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawInRect_1, rect) !is null;
+    }
+
+    public bool hasAlpha ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasAlpha) !is null;
+    }
+
+    public static NSArray imageFileTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageFileTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imagePasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imagePasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static objc.Class imageRepClassForData (NSData data)
+    {
+        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForData_1, data !is null ? data.id : null);
+    }
+
+    public static objc.Class imageRepClassForFileType (NSString type)
+    {
+        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForFileType_1, type !is null ? type.id : null);
+    }
+
+    public static objc.Class imageRepClassForPasteboardType (NSString type)
+    {
+        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForPasteboardType_1, type !is null ? type.id : null);
+    }
+
+    public static objc.Class imageRepClassForType (NSString type)
+    {
+        return OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepClassForType_1, type !is null ? type.id : null);
+    }
+
+    public static id imageRepWithContentsOfFile (NSString filename)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithContentsOfFile_1, filename !is null ? filename.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id imageRepWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id imageRepWithPasteboard (NSPasteboard pasteboard)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepWithPasteboard_1, pasteboard !is null ? pasteboard.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSArray imageRepsWithContentsOfFile (NSString filename)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithContentsOfFile_1, filename !is null ? filename.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageRepsWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageRepsWithPasteboard (NSPasteboard pasteboard)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageRepsWithPasteboard_1, pasteboard !is null ? pasteboard.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageUnfilteredFileTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredFileTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageUnfilteredPasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredPasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray imageUnfilteredTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_imageUnfilteredTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool isOpaque ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOpaque) !is null;
+    }
+
+    public NSInteger pixelsHigh ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pixelsHigh);
+    }
+
+    public NSInteger pixelsWide ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pixelsWide);
+    }
+
+    public static void registerImageRepClass (objc.Class imageRepClass)
+    {
+        OS.objc_msgSend(OS.class_NSImageRep, OS.sel_registerImageRepClass_1, imageRepClass);
+    }
+
+    public static NSArray registeredImageRepClasses ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSImageRep, OS.sel_registeredImageRepClasses);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setAlpha (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlpha_1, flag);
+    }
+
+    public void setBitsPerSample (NSInteger anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBitsPerSample_1, anInt);
+    }
+
+    public void setColorSpaceName (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColorSpaceName_1, string !is null ? string.id : null);
+    }
+
+    public void setOpaque (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOpaque_1, flag);
+    }
+
+    public void setPixelsHigh (NSInteger anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPixelsHigh_1, anInt);
+    }
+
+    public void setPixelsWide (NSInteger anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPixelsWide_1, anInt);
+    }
+
+    public void setSize (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSize_1, aSize);
+    }
+
+    public NSSize size ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_size);
+        return result;
+    }
+
+    public static void unregisterImageRepClass (objc.Class imageRepClass)
+    {
+        OS.objc_msgSend(OS.class_NSImageRep, OS.sel_unregisterImageRepClass_1, imageRepClass);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSImageView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSImageView;
+
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSImageView : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool allowsCutCopyPaste ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsCutCopyPaste) !is null;
+    }
+
+    public bool animates ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_animates) !is null;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImageAlignment imageAlignment ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageAlignment);
+    }
+
+    public NSImageFrameStyle imageFrameStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageFrameStyle);
+    }
+
+    public NSImageScaling imageScaling ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageScaling);
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public void setAllowsCutCopyPaste (bool allow)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsCutCopyPaste_1, allow);
+    }
+
+    public void setAnimates (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAnimates_1, flag);
+    }
+
+    public void setEditable (bool yn)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, yn);
+    }
+
+    public void setImage (NSImage newImage)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, newImage !is null ? newImage.id : null);
+    }
+
+    public void setImageAlignment (NSImageAlignment newAlign)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageAlignment_1, newAlign);
+    }
+
+    public void setImageFrameStyle (NSImageFrameStyle newStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageFrameStyle_1, newStyle);
+    }
+
+    public void setImageScaling (NSImageScaling newScaling)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageScaling_1, newScaling);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSIndexPath.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSIndexPath;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSComparisonResult;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSIndexPath : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSComparisonResult compare (NSIndexPath otherObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compare_1, otherObject !is null ? otherObject.id : null);
+    }
+
+    public void getIndexes (NSUInteger* indexes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getIndexes_1, indexes);
+    }
+
+    public NSUInteger indexAtPosition (NSUInteger position)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexAtPosition_1, position);
+    }
+
+    public NSIndexPath indexPathByAddingIndex (NSUInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_indexPathByAddingIndex_1, index);
+        return result is this.id ? this : (result !is null ? new NSIndexPath(result) : null);
+    }
+
+    public NSIndexPath indexPathByRemovingLastIndex ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_indexPathByRemovingLastIndex);
+        return result is this.id ? this : (result !is null ? new NSIndexPath(result) : null);
+    }
+
+    public static id indexPathWithIndex (NSUInteger index)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSIndexPath, OS.sel_indexPathWithIndex_1, index);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id indexPathWithIndexes (NSUInteger* indexes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSIndexPath, OS.sel_indexPathWithIndexes_1length_1, indexes, length);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithIndex (NSUInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIndex_1, index);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithIndexes (NSUInteger* indexes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIndexes_1length_1, indexes, length);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger length ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_length);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSIndexSet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSIndexSet;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSIndexSet : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool containsIndex (NSUInteger value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsIndex_1, value) !is null;
+    }
+
+    public bool containsIndexes (NSIndexSet indexSet)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsIndexes_1, indexSet !is null ? indexSet.id : null) !is null;
+    }
+
+    public bool containsIndexesInRange (NSRange range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsIndexesInRange_1, range) !is null;
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public NSUInteger countOfIndexesInRange (NSRange range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_countOfIndexesInRange_1, range);
+    }
+
+    public NSUInteger firstIndex ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_firstIndex);
+    }
+
+    public NSUInteger getIndexes (NSUInteger* indexBuffer, NSUInteger bufferSize, NSRangePointer range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getIndexes_1maxCount_1inIndexRange_1, indexBuffer, bufferSize, range);
+    }
+
+    public NSUInteger indexGreaterThanIndex (NSUInteger value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexGreaterThanIndex_1, value);
+    }
+
+    public NSUInteger indexGreaterThanOrEqualToIndex (NSUInteger value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexGreaterThanOrEqualToIndex_1, value);
+    }
+
+    public NSUInteger indexLessThanIndex (NSUInteger value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexLessThanIndex_1, value);
+    }
+
+    public NSUInteger indexLessThanOrEqualToIndex (NSUInteger value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexLessThanOrEqualToIndex_1, value);
+    }
+
+    public static id indexSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSIndexSet, OS.sel_indexSet);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id indexSetWithIndex (NSUInteger value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSIndexSet, OS.sel_indexSetWithIndex_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id indexSetWithIndexesInRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSIndexSet, OS.sel_indexSetWithIndexesInRange_1, range);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithIndex (NSUInteger value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIndex_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithIndexSet (NSIndexSet indexSet)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIndexSet_1, indexSet !is null ? indexSet.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithIndexesInRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIndexesInRange_1, range);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool intersectsIndexesInRange (NSRange range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_intersectsIndexesInRange_1, range) !is null;
+    }
+
+    public bool isEqualToIndexSet (NSIndexSet indexSet)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToIndexSet_1, indexSet !is null ? indexSet.id : null) !is null;
+    }
+
+    public NSUInteger lastIndex ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lastIndex);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSIndexSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSIndexSpecifier;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSIndexSpecifier : NSScriptObjectSpecifier
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger index ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_index);
+    }
+
+    public id initWithContainerClassDescription (NSScriptClassDescription classDesc, NSScriptObjectSpecifier container, NSString property, NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerClassDescription_1containerSpecifier_1key_1index_1,
+                classDesc !is null ? classDesc.id : null, container !is null ? container.id : null, property !is null ? property.id : null, index);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIndex_1, index);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSInputManager.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSInputManager;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInputServer;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSInputManager : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSInputManager currentInputManager ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSInputManager, OS.sel_currentInputManager);
+        return result !is null ? new NSInputManager(result) : null;
+    }
+
+    public static void cycleToNextInputLanguage (id sender)
+    {
+        OS.objc_msgSend(OS.class_NSInputManager, OS.sel_cycleToNextInputLanguage_1, sender !is null ? sender.id : null);
+    }
+
+    public static void cycleToNextInputServerInLanguage (id sender)
+    {
+        OS.objc_msgSend(OS.class_NSInputManager, OS.sel_cycleToNextInputServerInLanguage_1, sender !is null ? sender.id : null);
+    }
+
+    public bool handleMouseEvent (NSEvent theMouseEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_handleMouseEvent_1, theMouseEvent !is null ? theMouseEvent.id : null) !is null;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSInputManager initWithName (NSString inputServerName, NSString hostName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1host_1, inputServerName !is null ? inputServerName.id : null,
+                hostName !is null ? hostName.id : null);
+        return result is this.id ? this : (result !is null ? new NSInputManager(result) : null);
+    }
+
+    public NSString language ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_language);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString localizedInputManagerName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedInputManagerName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void markedTextAbandoned (id cli)
+    {
+        OS.objc_msgSend(this.id, OS.sel_markedTextAbandoned_1, cli !is null ? cli.id : null);
+    }
+
+    public void markedTextSelectionChanged (NSRange newSel, id cli)
+    {
+        OS.objc_msgSend(this.id, OS.sel_markedTextSelectionChanged_1client_1, newSel, cli !is null ? cli.id : null);
+    }
+
+    public NSInputServer server ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_server);
+        return result !is null ? new NSInputServer(result) : null;
+    }
+
+    public bool wantsToDelayTextChangeNotifications ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_wantsToDelayTextChangeNotifications) !is null;
+    }
+
+    public bool wantsToHandleMouseEvents ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_wantsToHandleMouseEvents) !is null;
+    }
+
+    public bool wantsToInterpretAllKeystrokes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_wantsToInterpretAllKeystrokes) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSInputServer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSInputServer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSInputServer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithDelegate (id aDelegate, NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDelegate_1name_1, aDelegate !is null ? aDelegate.id : null,
+                name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSInputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSInputStream;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSStream;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSInputStream : NSStream
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool getBuffer (ubyte** buffer, NSUInteger* len)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getBuffer_1length_1, buffer, len) !is null;
+    }
+
+    public bool hasBytesAvailable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasBytesAvailable) !is null;
+    }
+
+    public id initWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithFileAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFileAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id inputStreamWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSInputStream, OS.sel_inputStreamWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id inputStreamWithFileAtPath (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSInputStream, OS.sel_inputStreamWithFileAtPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger read (ubyte* buffer, NSUInteger len)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_read_1maxLength_1, buffer, len);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSInteger.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,32 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 23, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSInteger;
+
+version (X86_64) {
+    alias ulong NSUInteger;
+    alias long NSInteger;
+}
+
+else version (PPC64) {
+    alias ulong NSUInteger;
+    alias long NSInteger;
+}
+
+else version (X86) {
+    alias uint NSUInteger;
+    alias int NSInteger;
+}
+
+else version (PPC) {
+    alias uint NSUInteger;
+    alias int NSInteger;
+}
+
+else {
+    pragma(error, "Unsupported architecture");
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSInterfaceStyle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,20 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 4, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSInterfaceStyle;
+
+enum NSInterfaceStyle {
+    NSNoInterfaceStyle = 0,
+    NSNextStepInterfaceStyle = 1,
+    NSWindows95InterfaceStyle = 2,
+    NSMacintoshInterfaceStyle = 3
+}
+
+alias NSInterfaceStyle.NSNoInterfaceStyle NSNoInterfaceStyle;
+alias NSInterfaceStyle.NSNextStepInterfaceStyle NSNextStepInterfaceStyle;
+alias NSInterfaceStyle.NSWindows95InterfaceStyle NSWindows95InterfaceStyle;
+alias NSInterfaceStyle.NSMacintoshInterfaceStyle NSMacintoshInterfaceStyle;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSInvocation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSInvocation;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMethodSignature;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSInvocation : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool argumentsRetained ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_argumentsRetained) !is null;
+    }
+
+    public void getArgument (void* argumentLocation, NSInteger idx)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getArgument_1atIndex_1, argumentLocation, idx);
+    }
+
+    public void getReturnValue (void* retLoc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getReturnValue_1, retLoc);
+    }
+
+    public static NSInvocation invocationWithMethodSignature (NSMethodSignature sig)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSInvocation, OS.sel_invocationWithMethodSignature_1, sig !is null ? sig.id : null);
+        return result !is null ? new NSInvocation(result) : null;
+    }
+
+    public void invoke ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invoke);
+    }
+
+    public void invokeWithTarget (id target)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invokeWithTarget_1, target !is null ? target.id : null);
+    }
+
+    public NSMethodSignature methodSignature ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_methodSignature);
+        return result !is null ? new NSMethodSignature(result) : null;
+    }
+
+    public void retainArguments ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_retainArguments);
+    }
+
+    public objc.SEL selector ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selector);
+    }
+
+    public void setArgument (void* argumentLocation, NSInteger idx)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setArgument_1atIndex_1, argumentLocation, idx);
+    }
+
+    public void setReturnValue (void* retLoc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReturnValue_1, retLoc);
+    }
+
+    public void setSelector (objc.SEL selector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelector_1, selector);
+    }
+
+    public void setTarget (id target)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, target !is null ? target.id : null);
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSInvocationOperation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSInvocationOperation;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInvocation;
+import dwt.internal.cocoa.NSOperation;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSInvocationOperation : NSOperation
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithInvocation (NSInvocation inv)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithInvocation_1, inv !is null ? inv.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithTarget (id target, objc.SEL sel, id arg)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTarget_1selector_1object_1, target !is null ? target.id : null, sel,
+                arg !is null ? arg.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInvocation invocation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_invocation);
+        return result !is null ? new NSInvocation(result) : null;
+    }
+
+    public id result ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_result);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSKeyValueObserving.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,46 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 31, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSKeyValueObserving;
+
+import dwt.internal.cocoa.NSInteger;
+
+enum NSKeyValueObservingOptions : NSUInteger {
+    NSKeyValueObservingOptionNew = 0x01,
+    NSKeyValueObservingOptionOld = 0x02,
+    NSKeyValueObservingOptionInitial = 0x04,
+    NSKeyValueObservingOptionPrior = 0x08
+}
+
+alias NSKeyValueObservingOptions.NSKeyValueObservingOptionNew NSKeyValueObservingOptionNew;
+alias NSKeyValueObservingOptions.NSKeyValueObservingOptionOld NSKeyValueObservingOptionOld;
+alias NSKeyValueObservingOptions.NSKeyValueObservingOptionInitial NSKeyValueObservingOptionInitial;
+alias NSKeyValueObservingOptions.NSKeyValueObservingOptionPrior NSKeyValueObservingOptionPrior;
+
+enum NSKeyValueChange : NSUInteger {
+    NSKeyValueChangeSetting = 1,
+    NSKeyValueChangeInsertion = 2,
+    NSKeyValueChangeRemoval = 3,
+    NSKeyValueChangeReplacement = 4
+}
+
+alias NSKeyValueChange.NSKeyValueChangeSetting NSKeyValueChangeSetting;
+alias NSKeyValueChange.NSKeyValueChangeInsertion NSKeyValueChangeInsertion;
+alias NSKeyValueChange.NSKeyValueChangeRemoval NSKeyValueChangeRemoval;
+alias NSKeyValueChange.NSKeyValueChangeReplacement NSKeyValueChangeReplacement;
+
+enum NSKeyValueSetMutationKind : NSUInteger {
+    NSKeyValueUnionSetMutation = 1,
+    NSKeyValueMinusSetMutation = 2,
+    NSKeyValueIntersectSetMutation = 3,
+    NSKeyValueSetSetMutation = 4
+}
+
+alias NSKeyValueSetMutationKind.NSKeyValueUnionSetMutation NSKeyValueUnionSetMutation;
+alias NSKeyValueSetMutationKind.NSKeyValueMinusSetMutation NSKeyValueMinusSetMutation;
+alias NSKeyValueSetMutationKind.NSKeyValueIntersectSetMutation NSKeyValueIntersectSetMutation;
+alias NSKeyValueSetMutationKind.NSKeyValueSetSetMutation NSKeyValueSetSetMutation;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSKeyedArchiver.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSKeyedArchiver;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCoder;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMutableData;
+import dwt.internal.cocoa.NSPropertyListFormat;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSKeyedArchiver : NSCoder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static bool archiveRootObject (id rootObject, NSString path)
+    {
+        return OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_archiveRootObject_1toFile_1, rootObject !is null ? rootObject.id : null,
+                path !is null ? path.id : null) !is null;
+    }
+
+    public static NSData archivedDataWithRootObject (id rootObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_archivedDataWithRootObject_1, rootObject !is null ? rootObject.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSString classNameForClass_ (objc.Class cls)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_classNameForClass_1, cls);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString static_classNameForClass_ (objc.Class cls)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_classNameForClass_1, cls);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void encodeBool (bool boolv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeBool_1forKey_1, boolv, key !is null ? key.id : null);
+    }
+
+    public void encodeBytes (/*const*/ubyte* bytesp, NSUInteger lenv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeBytes_1length_1forKey_1, bytesp, lenv, key !is null ? key.id : null);
+    }
+
+    public void encodeConditionalObject (id objv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeConditionalObject_1forKey_1, objv !is null ? objv.id : null, key !is null ? key.id : null);
+    }
+
+    public void encodeDouble (double realv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeDouble_1forKey_1, realv, key !is null ? key.id : null);
+    }
+
+    public void encodeFloat (float realv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeFloat_1forKey_1, realv, key !is null ? key.id : null);
+    }
+
+    public void encodeInt32 (int intv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeInt32_1forKey_1, intv, key !is null ? key.id : null);
+    }
+
+    public void encodeInt64 (long intv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeInt64_1forKey_1, intv, key !is null ? key.id : null);
+    }
+
+    public void encodeInt (int intv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeInt_1forKey_1, intv, key !is null ? key.id : null);
+    }
+
+    public void encodeObject (id objv, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeObject_1forKey_1, objv !is null ? objv.id : null, key !is null ? key.id : null);
+    }
+
+    public void finishEncoding ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_finishEncoding);
+    }
+
+    public id initForWritingWithMutableData (NSMutableData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initForWritingWithMutableData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSPropertyListFormat outputFormat ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_outputFormat);
+    }
+
+    public static void static_setClassName_forClass_ (NSString codedName, objc.Class cls)
+    {
+        OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_setClassName_1forClass_1, codedName !is null ? codedName.id : null, cls);
+    }
+
+    public void setClassName_forClass_ (NSString codedName, objc.Class cls)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setClassName_1forClass_1, codedName !is null ? codedName.id : null, cls);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setOutputFormat (NSPropertyListFormat format)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOutputFormat_1, format);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSKeyedUnarchiver.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSKeyedUnarchiver;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCoder;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSKeyedUnarchiver : NSCoder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.Class classForClassName_ (NSString codedName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_classForClassName_1, codedName !is null ? codedName.id : null);
+    }
+
+    public static objc.Class static_classForClassName_ (NSString codedName)
+    {
+        return OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_classForClassName_1, codedName !is null ? codedName.id : null);
+    }
+
+    public bool containsValueForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsValueForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public bool decodeBoolForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeBoolForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public /*const*/ubyte* decodeBytesForKey (NSString key, NSUInteger* lengthp)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeBytesForKey_1returnedLength_1, key !is null ? key.id : null, lengthp);
+    }
+
+    public double decodeDoubleForKey (NSString key)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_decodeDoubleForKey_1, key !is null ? key.id : null);
+    }
+
+    public float decodeFloatForKey (NSString key)
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_decodeFloatForKey_1, key !is null ? key.id : null);
+    }
+
+    public int decodeInt32ForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeInt32ForKey_1, key !is null ? key.id : null);
+    }
+
+    public long decodeInt64ForKey (NSString key)
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_decodeInt64ForKey_1, key !is null ? key.id : null);
+    }
+
+    public int decodeIntForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_decodeIntForKey_1, key !is null ? key.id : null);
+    }
+
+    public id decodeObjectForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decodeObjectForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void finishDecoding ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_finishDecoding);
+    }
+
+    public id initForReadingWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initForReadingWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setClass_forClassName_ (objc.Class cls, NSString codedName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setClass_1forClassName_1, cls, codedName !is null ? codedName.id : null);
+    }
+
+    public static void static_setClass_forClassName_ (objc.Class cls, NSString codedName)
+    {
+        OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_setClass_1forClassName_1, cls, codedName !is null ? codedName.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public static id unarchiveObjectWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_unarchiveObjectWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id unarchiveObjectWithFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_unarchiveObjectWithFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSLayoutManager.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,862 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSLayoutManager;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSGlyphGenerator;
+import dwt.internal.cocoa.NSImageCell : NSImageScaling;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSParagraphStyle;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSRulerView;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextBlock;
+import dwt.internal.cocoa.NSTextContainer;
+import dwt.internal.cocoa.NSTextStorage;
+import dwt.internal.cocoa.NSTextView;
+import dwt.internal.cocoa.NSTypesetter;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSGlyphInscription : NSUInteger
+{
+    NSGlyphInscribeBase = 0,
+    NSGlyphInscribeBelow = 1,
+    NSGlyphInscribeAbove = 2,
+    NSGlyphInscribeOverstrike = 3,
+    NSGlyphInscribeOverBelow = 4
+}
+
+alias NSGlyphInscription.NSGlyphInscribeBase NSGlyphInscribeBase;
+alias NSGlyphInscription.NSGlyphInscribeBelow NSGlyphInscribeBelow;
+alias NSGlyphInscription.NSGlyphInscribeAbove NSGlyphInscribeAbove;
+alias NSGlyphInscription.NSGlyphInscribeOverstrike NSGlyphInscribeOverstrike;
+alias NSGlyphInscription.NSGlyphInscribeOverBelow NSGlyphInscribeOverBelow;
+
+
+
+enum NSTypesetterBehavior : NSInteger
+{
+    NSTypesetterLatestBehavior = -1,
+    NSTypesetterOriginalBehavior = 0,
+    NSTypesetterBehavior_10_2_WithCompatibility = 1,
+    NSTypesetterBehavior_10_2 = 2,
+    NSTypesetterBehavior_10_3 = 3,
+    NSTypesetterBehavior_10_4 = 4
+}
+
+alias NSTypesetterBehavior.NSTypesetterLatestBehavior NSTypesetterLatestBehavior;
+alias NSTypesetterBehavior.NSTypesetterOriginalBehavior NSTypesetterOriginalBehavior;
+alias NSTypesetterBehavior.NSTypesetterBehavior_10_2_WithCompatibility NSTypesetterBehavior_10_2_WithCompatibility;
+alias NSTypesetterBehavior.NSTypesetterBehavior_10_2 NSTypesetterBehavior_10_2;
+alias NSTypesetterBehavior.NSTypesetterBehavior_10_3 NSTypesetterBehavior_10_3;
+alias NSTypesetterBehavior.NSTypesetterBehavior_10_4 NSTypesetterBehavior_10_4;
+
+
+
+public class NSLayoutManager : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addTemporaryAttribute (NSString attrName, id value, NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTemporaryAttribute_1value_1forCharacterRange_1, attrName !is null ? attrName.id : null,
+                value !is null ? value.id : null, charRange);
+    }
+
+    public void addTemporaryAttributes (NSDictionary attrs, NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTemporaryAttributes_1forCharacterRange_1, attrs !is null ? attrs.id : null, charRange);
+    }
+
+    public void addTextContainer (NSTextContainer container)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTextContainer_1, container !is null ? container.id : null);
+    }
+
+    public bool allowsNonContiguousLayout ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsNonContiguousLayout) !is null;
+    }
+
+    public NSSize attachmentSizeForGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_attachmentSizeForGlyphAtIndex_1, glyphIndex);
+        return result;
+    }
+
+    public NSAttributedString attributedString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedString);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public bool backgroundLayoutEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_backgroundLayoutEnabled) !is null;
+    }
+
+    public NSRect boundingRectForGlyphRange (NSRange glyphRange, NSTextContainer container)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundingRectForGlyphRange_1inTextContainer_1, glyphRange,
+                container !is null ? container.id : null);
+        return result;
+    }
+
+    public NSRect boundsRectForTextBlock_atIndex_effectiveRange_ (NSTextBlock block, NSUInteger glyphIndex, NSRangePointer effectiveGlyphRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundsRectForTextBlock_1atIndex_1effectiveRange_1, block !is null ? block.id : null,
+                glyphIndex, effectiveGlyphRange);
+        return result;
+    }
+
+    public NSRect boundsRectForTextBlock_glyphRange_ (NSTextBlock block, NSRange glyphRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundsRectForTextBlock_1glyphRange_1, block !is null ? block.id : null, glyphRange);
+        return result;
+    }
+
+    public NSUInteger characterIndexForGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_characterIndexForGlyphAtIndex_1, glyphIndex);
+    }
+
+    public NSRange characterRangeForGlyphRange (NSRange glyphRange, NSRangePointer actualGlyphRange)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_characterRangeForGlyphRange_1actualGlyphRange_1, glyphRange, actualGlyphRange);
+        return result;
+    }
+
+    public NSImageScaling defaultAttachmentScaling ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_defaultAttachmentScaling);
+    }
+
+    public CGFloat defaultBaselineOffsetForFont (NSFont theFont)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_defaultBaselineOffsetForFont_1, theFont !is null ? theFont.id : null);
+    }
+
+    public CGFloat defaultLineHeightForFont (NSFont theFont)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_defaultLineHeightForFont_1, theFont !is null ? theFont.id : null);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void deleteGlyphsInRange (NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteGlyphsInRange_1, glyphRange);
+    }
+
+    public void drawBackgroundForGlyphRange (NSRange glyphsToShow, NSPoint origin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawBackgroundForGlyphRange_1atPoint_1, glyphsToShow, origin);
+    }
+
+    public void drawGlyphsForGlyphRange (NSRange glyphsToShow, NSPoint origin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawGlyphsForGlyphRange_1atPoint_1, glyphsToShow, origin);
+    }
+
+    public void drawStrikethroughForGlyphRange (NSRange glyphRange, NSInteger strikethroughVal, CGFloat baselineOffset, NSRect lineRect,
+            NSRange lineGlyphRange, NSPoint containerOrigin)
+    {
+        OS.objc_msgSend(
+                this.id,
+                OS.sel_drawStrikethroughForGlyphRange_1strikethroughType_1baselineOffset_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1,
+                glyphRange, strikethroughVal, baselineOffset, lineRect, lineGlyphRange, containerOrigin);
+    }
+
+    public void drawUnderlineForGlyphRange (NSRange glyphRange, NSInteger underlineVal, CGFloat baselineOffset, NSRect lineRect,
+            NSRange lineGlyphRange, NSPoint containerOrigin)
+    {
+        OS.objc_msgSend(this.id,
+                OS.sel_drawUnderlineForGlyphRange_1underlineType_1baselineOffset_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1,
+                glyphRange, underlineVal, baselineOffset, lineRect, lineGlyphRange, containerOrigin);
+    }
+
+    public bool drawsOutsideLineFragmentForGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsOutsideLineFragmentForGlyphAtIndex_1, glyphIndex) !is null;
+    }
+
+    public void ensureGlyphsForCharacterRange (NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ensureGlyphsForCharacterRange_1, charRange);
+    }
+
+    public void ensureGlyphsForGlyphRange (NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ensureGlyphsForGlyphRange_1, glyphRange);
+    }
+
+    public void ensureLayoutForBoundingRect (NSRect bounds, NSTextContainer container)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ensureLayoutForBoundingRect_1inTextContainer_1, bounds, container !is null ? container.id : null);
+    }
+
+    public void ensureLayoutForCharacterRange (NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ensureLayoutForCharacterRange_1, charRange);
+    }
+
+    public void ensureLayoutForGlyphRange (NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ensureLayoutForGlyphRange_1, glyphRange);
+    }
+
+    public void ensureLayoutForTextContainer (NSTextContainer container)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ensureLayoutForTextContainer_1, container !is null ? container.id : null);
+    }
+
+    public NSRect extraLineFragmentRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_extraLineFragmentRect);
+        return result;
+    }
+
+    public NSTextContainer extraLineFragmentTextContainer ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_extraLineFragmentTextContainer);
+        return result !is null ? new NSTextContainer(result) : null;
+    }
+
+    public NSRect extraLineFragmentUsedRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_extraLineFragmentUsedRect);
+        return result;
+    }
+
+    public NSTextView firstTextView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_firstTextView);
+        return result !is null ? new NSTextView(result) : null;
+    }
+
+    public NSUInteger firstUnlaidCharacterIndex ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_firstUnlaidCharacterIndex);
+    }
+
+    public NSUInteger firstUnlaidGlyphIndex ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_firstUnlaidGlyphIndex);
+    }
+
+    public CGFloat fractionOfDistanceThroughGlyphForPoint (NSPoint point, NSTextContainer container)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_fractionOfDistanceThroughGlyphForPoint_1inTextContainer_1, point,
+                container !is null ? container.id : null);
+    }
+
+    public void getFirstUnlaidCharacterIndex (NSUInteger* charIndex, NSUInteger* glyphIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getFirstUnlaidCharacterIndex_1glyphIndex_1, charIndex, glyphIndex);
+    }
+
+    public NSUInteger getGlyphs (NSGlyph* glyphArray, NSRange glyphRange)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getGlyphs_1range_1, glyphArray, glyphRange);
+    }
+
+    public NSUInteger getGlyphsInRange_glyphs_characterIndexes_glyphInscriptions_elasticBits_ (NSRange glyphRange, NSGlyph* glyphBuffer,
+            NSUInteger* charIndexBuffer, NSGlyphInscription* inscribeBuffer, bool* elasticBuffer)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getGlyphsInRange_1glyphs_1characterIndexes_1glyphInscriptions_1elasticBits_1, glyphRange, glyphBuffer,
+                charIndexBuffer, inscribeBuffer, elasticBuffer);
+    }
+
+    public NSUInteger getGlyphsInRange_glyphs_characterIndexes_glyphInscriptions_elasticBits_bidiLevels_ (NSRange glyphRange, NSGlyph* glyphBuffer,
+            NSUInteger* charIndexBuffer, NSGlyphInscription* inscribeBuffer, bool* elasticBuffer, ubyte* bidiLevelBuffer)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getGlyphsInRange_1glyphs_1characterIndexes_1glyphInscriptions_1elasticBits_1bidiLevels_1, glyphRange,
+                glyphBuffer, charIndexBuffer, inscribeBuffer, elasticBuffer, bidiLevelBuffer);
+    }
+
+    public NSUInteger getLineFragmentInsertionPointsForCharacterAtIndex (NSUInteger charIndex, bool aFlag, bool dFlag, CGFloat* positions,
+            NSUInteger* charIndexes)
+    {
+        return OS.objc_msgSend(this.id,
+                OS.sel_getLineFragmentInsertionPointsForCharacterAtIndex_1alternatePositions_1inDisplayOrder_1positions_1characterIndexes_1,
+                charIndex, aFlag, dFlag, positions, charIndexes);
+    }
+
+    public NSGlyph glyphAtIndex_ (NSUInteger glyphIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphAtIndex_1, glyphIndex);
+    }
+
+    public NSGlyph glyphAtIndex_isValidIndex_ (NSUInteger glyphIndex, bool* isValidIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphAtIndex_1isValidIndex_1, glyphIndex, isValidIndex);
+    }
+
+    public NSGlyphGenerator glyphGenerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_glyphGenerator);
+        return result !is null ? new NSGlyphGenerator(result) : null;
+    }
+
+    public NSUInteger glyphIndexForCharacterAtIndex (NSUInteger charIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphIndexForCharacterAtIndex_1, charIndex);
+    }
+
+    public NSUInteger glyphIndexForPoint_inTextContainer_ (NSPoint point, NSTextContainer container)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphIndexForPoint_1inTextContainer_1, point, container !is null ? container.id : null);
+    }
+
+    public NSUInteger glyphIndexForPoint_inTextContainer_fractionOfDistanceThroughGlyph_ (NSPoint point, NSTextContainer container,
+            CGFloat* partialFraction)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_glyphIndexForPoint_1inTextContainer_1fractionOfDistanceThroughGlyph_1, point,
+                container !is null ? container.id : null, partialFraction);
+    }
+
+    public NSRange glyphRangeForBoundingRect (NSRect bounds, NSTextContainer container)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_glyphRangeForBoundingRect_1inTextContainer_1, bounds, container !is null ? container.id : null);
+        return result;
+    }
+
+    public NSRange glyphRangeForBoundingRectWithoutAdditionalLayout (NSRect bounds, NSTextContainer container)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_glyphRangeForBoundingRectWithoutAdditionalLayout_1inTextContainer_1, bounds,
+                container !is null ? container.id : null);
+        return result;
+    }
+
+    public NSRange glyphRangeForCharacterRange (NSRange charRange, NSRangePointer actualCharRange)
+    {
+        NSRange result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_glyphRangeForCharacterRange_1actualCharacterRange_1, charRange, actualCharRange);
+        return result;
+    }
+
+    public NSRange glyphRangeForTextContainer (NSTextContainer container)
+    {
+        NSRange result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_glyphRangeForTextContainer_1, container !is null ? container.id : null);
+        return result;
+    }
+
+    public bool hasNonContiguousLayout ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasNonContiguousLayout) !is null;
+    }
+
+    public float hyphenationFactor ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_hyphenationFactor);
+    }
+
+    public void insertGlyph (NSGlyph glyph, NSUInteger glyphIndex, NSUInteger charIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertGlyph_1atGlyphIndex_1characterIndex_1, glyph, glyphIndex, charIndex);
+    }
+
+    public void insertGlyphs (/*const*/NSGlyph* glyphs, NSUInteger length, NSUInteger glyphIndex, NSUInteger charIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertGlyphs_1length_1forStartingGlyphAtIndex_1characterIndex_1, glyphs, length, glyphIndex, charIndex);
+    }
+
+    public void insertTextContainer (NSTextContainer container, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertTextContainer_1atIndex_1, container !is null ? container.id : null, index);
+    }
+
+    public NSInteger intAttribute (NSInteger attributeTag, NSUInteger glyphIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_intAttribute_1forGlyphAtIndex_1, attributeTag, glyphIndex);
+    }
+
+    public void invalidateDisplayForCharacterRange (NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateDisplayForCharacterRange_1, charRange);
+    }
+
+    public void invalidateDisplayForGlyphRange (NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateDisplayForGlyphRange_1, glyphRange);
+    }
+
+    public void invalidateGlyphsForCharacterRange (NSRange charRange, NSInteger delta, NSRangePointer actualCharRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateGlyphsForCharacterRange_1changeInLength_1actualCharacterRange_1, charRange, delta, actualCharRange);
+    }
+
+    public void invalidateGlyphsOnLayoutInvalidationForGlyphRange (NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateGlyphsOnLayoutInvalidationForGlyphRange_1, glyphRange);
+    }
+
+    public void invalidateLayoutForCharacterRange_actualCharacterRange_ (NSRange charRange, NSRangePointer actualCharRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateLayoutForCharacterRange_1actualCharacterRange_1, charRange, actualCharRange);
+    }
+
+    public void invalidateLayoutForCharacterRange_isSoft_actualCharacterRange_ (NSRange charRange, bool flag, NSRangePointer actualCharRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateLayoutForCharacterRange_1isSoft_1actualCharacterRange_1, charRange, flag, actualCharRange);
+    }
+
+    public bool isValidGlyphIndex (NSUInteger glyphIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isValidGlyphIndex_1, glyphIndex) !is null;
+    }
+
+    public bool layoutManagerOwnsFirstResponderInWindow (NSWindow window)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_layoutManagerOwnsFirstResponderInWindow_1, window !is null ? window.id : null) !is null;
+    }
+
+    public NSUInteger layoutOptions ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_layoutOptions);
+    }
+
+    public NSRect layoutRectForTextBlock_atIndex_effectiveRange_ (NSTextBlock block, NSUInteger glyphIndex, NSRangePointer effectiveGlyphRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_layoutRectForTextBlock_1atIndex_1effectiveRange_1, block !is null ? block.id : null,
+                glyphIndex, effectiveGlyphRange);
+        return result;
+    }
+
+    public NSRect layoutRectForTextBlock_glyphRange_ (NSTextBlock block, NSRange glyphRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_layoutRectForTextBlock_1glyphRange_1, block !is null ? block.id : null, glyphRange);
+        return result;
+    }
+
+    public NSRect lineFragmentRectForGlyphAtIndex_effectiveRange_ (NSUInteger glyphIndex, NSRangePointer effectiveGlyphRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_lineFragmentRectForGlyphAtIndex_1effectiveRange_1, glyphIndex, effectiveGlyphRange);
+        return result;
+    }
+
+    public NSRect lineFragmentRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_ (NSUInteger glyphIndex, NSRangePointer effectiveGlyphRange,
+            bool flag)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_lineFragmentRectForGlyphAtIndex_1effectiveRange_1withoutAdditionalLayout_1, glyphIndex,
+                effectiveGlyphRange, flag);
+        return result;
+    }
+
+    public NSRect lineFragmentUsedRectForGlyphAtIndex_effectiveRange_ (NSUInteger glyphIndex, NSRangePointer effectiveGlyphRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_lineFragmentUsedRectForGlyphAtIndex_1effectiveRange_1, glyphIndex, effectiveGlyphRange);
+        return result;
+    }
+
+    public NSRect lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_ (NSUInteger glyphIndex,
+            NSRangePointer effectiveGlyphRange, bool flag)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_lineFragmentUsedRectForGlyphAtIndex_1effectiveRange_1withoutAdditionalLayout_1, glyphIndex,
+                effectiveGlyphRange, flag);
+        return result;
+    }
+
+    public NSPoint locationForGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_locationForGlyphAtIndex_1, glyphIndex);
+        return result;
+    }
+
+    public bool notShownAttributeForGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_notShownAttributeForGlyphAtIndex_1, glyphIndex) !is null;
+    }
+
+    public NSUInteger numberOfGlyphs ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfGlyphs);
+    }
+
+    public NSRange rangeOfNominallySpacedGlyphsContainingIndex (NSUInteger glyphIndex)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfNominallySpacedGlyphsContainingIndex_1, glyphIndex);
+        return result;
+    }
+
+    public NSRectArray rectArrayForCharacterRange (NSRange charRange, NSRange selCharRange, NSTextContainer container, NSUInteger* rectCount)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rectArrayForCharacterRange_1withinSelectedCharacterRange_1inTextContainer_1rectCount_1, charRange,
+                selCharRange, container !is null ? container.id : null, rectCount);
+    }
+
+    public NSRectArray rectArrayForGlyphRange (NSRange glyphRange, NSRange selGlyphRange, NSTextContainer container, NSUInteger* rectCount)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rectArrayForGlyphRange_1withinSelectedGlyphRange_1inTextContainer_1rectCount_1, glyphRange,
+                selGlyphRange, container !is null ? container.id : null, rectCount);
+    }
+
+    public void removeTemporaryAttribute (NSString attrName, NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeTemporaryAttribute_1forCharacterRange_1, attrName !is null ? attrName.id : null, charRange);
+    }
+
+    public void removeTextContainerAtIndex (NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeTextContainerAtIndex_1, index);
+    }
+
+    public void replaceGlyphAtIndex (NSUInteger glyphIndex, NSGlyph newGlyph)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceGlyphAtIndex_1withGlyph_1, glyphIndex, newGlyph);
+    }
+
+    public void replaceTextStorage (NSTextStorage newTextStorage)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceTextStorage_1, newTextStorage !is null ? newTextStorage.id : null);
+    }
+
+    public NSView rulerAccessoryViewForTextView (NSTextView view, NSParagraphStyle style, NSRulerView ruler, bool isEnabled)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rulerAccessoryViewForTextView_1paragraphStyle_1ruler_1enabled_1,
+                view !is null ? view.id : null, style !is null ? style.id : null, ruler !is null ? ruler.id : null, isEnabled);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSArray rulerMarkersForTextView (NSTextView view, NSParagraphStyle style, NSRulerView ruler)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rulerMarkersForTextView_1paragraphStyle_1ruler_1, view !is null ? view.id : null,
+                style !is null ? style.id : null, ruler !is null ? ruler.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setAllowsNonContiguousLayout (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsNonContiguousLayout_1, flag);
+    }
+
+    public void setAttachmentSize (NSSize attachmentSize, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttachmentSize_1forGlyphRange_1, attachmentSize, glyphRange);
+    }
+
+    public void setBackgroundLayoutEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundLayoutEnabled_1, flag);
+    }
+
+    public void setBoundsRect (NSRect rect, NSTextBlock block, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBoundsRect_1forTextBlock_1glyphRange_1, rect, block !is null ? block.id : null, glyphRange);
+    }
+
+    public void setCharacterIndex (NSUInteger charIndex, NSUInteger glyphIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCharacterIndex_1forGlyphAtIndex_1, charIndex, glyphIndex);
+    }
+
+    public void setDefaultAttachmentScaling (NSImageScaling scaling)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultAttachmentScaling_1, scaling);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDrawsOutsideLineFragment (bool flag, NSUInteger glyphIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsOutsideLineFragment_1forGlyphAtIndex_1, flag, glyphIndex);
+    }
+
+    public void setExtraLineFragmentRect (NSRect fragmentRect, NSRect usedRect, NSTextContainer container)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setExtraLineFragmentRect_1usedRect_1textContainer_1, fragmentRect, usedRect,
+                container !is null ? container.id : null);
+    }
+
+    public void setGlyphGenerator (NSGlyphGenerator glyphGenerator)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGlyphGenerator_1, glyphGenerator !is null ? glyphGenerator.id : null);
+    }
+
+    public void setHyphenationFactor (float factor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHyphenationFactor_1, factor);
+    }
+
+    public void setIntAttribute (NSInteger attributeTag, NSInteger val, NSUInteger glyphIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntAttribute_1value_1forGlyphAtIndex_1, attributeTag, val, glyphIndex);
+    }
+
+    public void setLayoutRect (NSRect rect, NSTextBlock block, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLayoutRect_1forTextBlock_1glyphRange_1, rect, block !is null ? block.id : null, glyphRange);
+    }
+
+    public void setLineFragmentRect (NSRect fragmentRect, NSRange glyphRange, NSRect usedRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineFragmentRect_1forGlyphRange_1usedRect_1, fragmentRect, glyphRange, usedRect);
+    }
+
+    public void setLocation (NSPoint location, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocation_1forStartOfGlyphRange_1, location, glyphRange);
+    }
+
+    public void setLocations (NSPointArray locations, NSUInteger* glyphIndexes, NSUInteger count, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocations_1startingGlyphIndexes_1count_1forGlyphRange_1, locations, glyphIndexes, count, glyphRange);
+    }
+
+    public void setNotShownAttribute (bool flag, NSUInteger glyphIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNotShownAttribute_1forGlyphAtIndex_1, flag, glyphIndex);
+    }
+
+    public void setShowsControlCharacters (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsControlCharacters_1, flag);
+    }
+
+    public void setShowsInvisibleCharacters (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsInvisibleCharacters_1, flag);
+    }
+
+    public void setTemporaryAttributes (NSDictionary attrs, NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTemporaryAttributes_1forCharacterRange_1, attrs !is null ? attrs.id : null, charRange);
+    }
+
+    public void setTextContainer (NSTextContainer container, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextContainer_1forGlyphRange_1, container !is null ? container.id : null, glyphRange);
+    }
+
+    public void setTextStorage (NSTextStorage textStorage)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextStorage_1, textStorage !is null ? textStorage.id : null);
+    }
+
+    public void setTypesetter (NSTypesetter typesetter)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTypesetter_1, typesetter !is null ? typesetter.id : null);
+    }
+
+    public void setTypesetterBehavior (NSTypesetterBehavior theBehavior)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTypesetterBehavior_1, theBehavior);
+    }
+
+    public void setUsesFontLeading (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesFontLeading_1, flag);
+    }
+
+    public void setUsesScreenFonts (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesScreenFonts_1, flag);
+    }
+
+    public void showAttachmentCell (NSCell cell, NSRect rect, NSUInteger attachmentIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showAttachmentCell_1inRect_1characterIndex_1, cell !is null ? cell.id : null, rect, attachmentIndex);
+    }
+
+    public void showPackedGlyphs (byte* glyphs, NSUInteger glyphLen, NSRange glyphRange, NSPoint point, NSFont font, NSColor color,
+            NSSize printingAdjustment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showPackedGlyphs_1length_1glyphRange_1atPoint_1font_1color_1printingAdjustment_1, glyphs, glyphLen,
+                glyphRange, point, font !is null ? font.id : null, color !is null ? color.id : null, printingAdjustment);
+    }
+
+    public bool showsControlCharacters ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsControlCharacters) !is null;
+    }
+
+    public bool showsInvisibleCharacters ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsInvisibleCharacters) !is null;
+    }
+
+    public void strikethroughGlyphRange (NSRange glyphRange, NSInteger strikethroughVal, NSRect lineRect, NSRange lineGlyphRange,
+            NSPoint containerOrigin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_strikethroughGlyphRange_1strikethroughType_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1,
+                glyphRange, strikethroughVal, lineRect, lineGlyphRange, containerOrigin);
+    }
+
+    public NSFont substituteFontForFont (NSFont originalFont)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_substituteFontForFont_1, originalFont !is null ? originalFont.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public id temporaryAttribute_atCharacterIndex_effectiveRange_ (NSString attrName, NSUInteger location, NSRangePointer range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_temporaryAttribute_1atCharacterIndex_1effectiveRange_1,
+                attrName !is null ? attrName.id : null, location, range);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id temporaryAttribute_atCharacterIndex_longestEffectiveRange_inRange_ (NSString attrName, NSUInteger location, NSRangePointer range,
+            NSRange rangeLimit)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_temporaryAttribute_1atCharacterIndex_1longestEffectiveRange_1inRange_1,
+                attrName !is null ? attrName.id : null, location, range, rangeLimit);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary temporaryAttributesAtCharacterIndex_effectiveRange_ (NSUInteger charIndex, NSRangePointer effectiveCharRange)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_temporaryAttributesAtCharacterIndex_1effectiveRange_1, charIndex, effectiveCharRange);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary temporaryAttributesAtCharacterIndex_longestEffectiveRange_inRange_ (NSUInteger location, NSRangePointer range,
+            NSRange rangeLimit)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_temporaryAttributesAtCharacterIndex_1longestEffectiveRange_1inRange_1, location, range,
+                rangeLimit);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void textContainerChangedGeometry (NSTextContainer container)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textContainerChangedGeometry_1, container !is null ? container.id : null);
+    }
+
+    public void textContainerChangedTextView (NSTextContainer container)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textContainerChangedTextView_1, container !is null ? container.id : null);
+    }
+
+    public NSTextContainer textContainerForGlyphAtIndex_effectiveRange_ (NSUInteger glyphIndex, NSRangePointer effectiveGlyphRange)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textContainerForGlyphAtIndex_1effectiveRange_1, glyphIndex, effectiveGlyphRange);
+        return result !is null ? new NSTextContainer(result) : null;
+    }
+
+    public NSTextContainer textContainerForGlyphAtIndex_effectiveRange_withoutAdditionalLayout_ (NSUInteger glyphIndex,
+            NSRangePointer effectiveGlyphRange, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textContainerForGlyphAtIndex_1effectiveRange_1withoutAdditionalLayout_1, glyphIndex,
+                effectiveGlyphRange, flag);
+        return result !is null ? new NSTextContainer(result) : null;
+    }
+
+    public NSArray textContainers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textContainers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSTextStorage textStorage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textStorage);
+        return result !is null ? new NSTextStorage(result) : null;
+    }
+
+    public void textStorage_edited_range_changeInLength_invalidatedRange_ (NSTextStorage str, NSUInteger editedMask, NSRange newCharRange,
+            NSInteger delta, NSRange invalidatedCharRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textStorage_1edited_1range_1changeInLength_1invalidatedRange_1, str !is null ? str.id : null, editedMask,
+                newCharRange, delta, invalidatedCharRange);
+    }
+
+    public NSTextView textViewForBeginningOfSelection ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textViewForBeginningOfSelection);
+        return result !is null ? new NSTextView(result) : null;
+    }
+
+    public NSTypesetter typesetter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_typesetter);
+        return result !is null ? new NSTypesetter(result) : null;
+    }
+
+    public NSTypesetterBehavior typesetterBehavior ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_typesetterBehavior);
+    }
+
+    public void underlineGlyphRange (NSRange glyphRange, NSInteger underlineVal, NSRect lineRect, NSRange lineGlyphRange, NSPoint containerOrigin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_underlineGlyphRange_1underlineType_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1, glyphRange,
+                underlineVal, lineRect, lineGlyphRange, containerOrigin);
+    }
+
+    public NSRect usedRectForTextContainer (NSTextContainer container)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_usedRectForTextContainer_1, container !is null ? container.id : null);
+        return result;
+    }
+
+    public bool usesFontLeading ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesFontLeading) !is null;
+    }
+
+    public bool usesScreenFonts ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesScreenFonts) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSLevelIndicator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSLevelIndicator;
+
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSliderCell : NSTickMarkPosition;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSLevelIndicator : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public double criticalValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_criticalValue);
+    }
+
+    public double maxValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_maxValue);
+    }
+
+    public double minValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_minValue);
+    }
+
+    public NSInteger numberOfMajorTickMarks ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfMajorTickMarks);
+    }
+
+    public NSInteger numberOfTickMarks ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfTickMarks);
+    }
+
+    public NSRect rectOfTickMarkAtIndex (NSInteger index)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfTickMarkAtIndex_1, index);
+        return result;
+    }
+
+    public void setCriticalValue (double criticalValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCriticalValue_1, criticalValue);
+    }
+
+    public void setMaxValue (double maxValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxValue_1, maxValue);
+    }
+
+    public void setMinValue (double minValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinValue_1, minValue);
+    }
+
+    public void setNumberOfMajorTickMarks (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfMajorTickMarks_1, count);
+    }
+
+    public void setNumberOfTickMarks (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfTickMarks_1, count);
+    }
+
+    public void setTickMarkPosition (NSTickMarkPosition position)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTickMarkPosition_1, position);
+    }
+
+    public void setWarningValue (double warningValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWarningValue_1, warningValue);
+    }
+
+    public NSTickMarkPosition tickMarkPosition ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tickMarkPosition);
+    }
+
+    public double tickMarkValueAtIndex (NSInteger index)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_tickMarkValueAtIndex_1, index);
+    }
+
+    public double warningValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_warningValue);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSLevelIndicatorCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSLevelIndicatorCell;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSliderCell : NSTickMarkPosition;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSUInteger NSLevelIndicatorStyle;;
+
+public class NSLevelIndicatorCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public double criticalValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_criticalValue);
+    }
+
+    public id initWithLevelIndicatorStyle (NSLevelIndicatorStyle levelIndicatorStyle)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLevelIndicatorStyle_1, levelIndicatorStyle);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSLevelIndicatorStyle levelIndicatorStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_levelIndicatorStyle);
+    }
+
+    public double maxValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_maxValue);
+    }
+
+    public double minValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_minValue);
+    }
+
+    public NSInteger numberOfMajorTickMarks ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfMajorTickMarks);
+    }
+
+    public NSInteger numberOfTickMarks ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfTickMarks);
+    }
+
+    public NSRect rectOfTickMarkAtIndex (NSInteger index)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfTickMarkAtIndex_1, index);
+        return result;
+    }
+
+    public void setCriticalValue (double criticalValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCriticalValue_1, criticalValue);
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setLevelIndicatorStyle (NSLevelIndicatorStyle levelIndicatorStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLevelIndicatorStyle_1, levelIndicatorStyle);
+    }
+
+    public void setMaxValue (double maxValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxValue_1, maxValue);
+    }
+
+    public void setMinValue (double minValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinValue_1, minValue);
+    }
+
+    public void setNumberOfMajorTickMarks (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfMajorTickMarks_1, count);
+    }
+
+    public void setNumberOfTickMarks (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfTickMarks_1, count);
+    }
+
+    public void setTickMarkPosition (NSTickMarkPosition position)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTickMarkPosition_1, position);
+    }
+
+    public void setWarningValue (double warningValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWarningValue_1, warningValue);
+    }
+
+    public NSTickMarkPosition tickMarkPosition ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tickMarkPosition);
+    }
+
+    public double tickMarkValueAtIndex (NSInteger index)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_tickMarkValueAtIndex_1, index);
+    }
+
+    public double warningValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_warningValue);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSLocale.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSLocale;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSLocale : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSArray ISOCountryCodes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_ISOCountryCodes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray ISOCurrencyCodes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_ISOCurrencyCodes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray ISOLanguageCodes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_ISOLanguageCodes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static id autoupdatingCurrentLocale ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_autoupdatingCurrentLocale);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSArray availableLocaleIdentifiers ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_availableLocaleIdentifiers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSString canonicalLocaleIdentifierFromString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_canonicalLocaleIdentifierFromString_1, string !is null ? string.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSArray commonISOCurrencyCodes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_commonISOCurrencyCodes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSDictionary componentsFromLocaleIdentifier (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_componentsFromLocaleIdentifier_1, string !is null ? string.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public static id currentLocale ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_currentLocale);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString displayNameForKey (id key, id value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayNameForKey_1value_1, key !is null ? key.id : null, value !is null ? value.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initWithLocaleIdentifier (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLocaleIdentifier_1, string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString localeIdentifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localeIdentifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString localeIdentifierFromComponents (NSDictionary dict)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_localeIdentifierFromComponents_1, dict !is null ? dict.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id objectForKey (id key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSArray preferredLanguages ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_preferredLanguages);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static id systemLocale ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSLocale, OS.sel_systemLocale);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSLock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSLock;
+
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSLock : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool lockBeforeDate (NSDate limit)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lockBeforeDate_1, limit !is null ? limit.id : null) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setName (NSString n)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setName_1, n !is null ? n.id : null);
+    }
+
+    public bool tryLock ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryLock) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSLogicalTest.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSLogicalTest;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSScriptWhoseTest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSLogicalTest : NSScriptWhoseTest
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initAndTestWithTests (NSArray subTests)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initAndTestWithTests_1, subTests !is null ? subTests.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initNotTestWithTest (NSScriptWhoseTest subTest)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initNotTestWithTest_1, subTest !is null ? subTest.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initOrTestWithTests (NSArray subTests)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initOrTestWithTests_1, subTests !is null ? subTests.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMachBootstrapServer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMachBootstrapServer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSPortNameServer;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMachBootstrapServer : NSPortNameServer
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSPort portForName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public NSPort portForName_host_ (NSString name, NSString host)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1host_1, name !is null ? name.id : null, host !is null ? host.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public bool registerPort (NSPort port, NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_registerPort_1name_1, port !is null ? port.id : null, name !is null ? name.id : null) !is null;
+    }
+
+    public NSPort servicePortWithName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_servicePortWithName_1, name !is null ? name.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public static id sharedInstance ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMachBootstrapServer, OS.sel_sharedInstance);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMachPort.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMachPort;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMachPort : NSPort
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithMachPort_ (uint machPort)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMachPort_1, machPort);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithMachPort_options_ (uint machPort, NSUInteger f)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMachPort_1options_1, machPort, f);
+        return result !is null ? new id(result) : null;
+    }
+
+    public uint machPort ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_machPort);
+    }
+
+    public static NSPort static_portWithMachPort_ (uint machPort)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMachPort, OS.sel_portWithMachPort_1, machPort);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public static NSPort static_portWithMachPort_options_ (uint machPort, NSUInteger f)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMachPort, OS.sel_portWithMachPort_1options_1, machPort, f);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public void removeFromRunLoop (NSRunLoop runLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFromRunLoop_1forMode_1, runLoop !is null ? runLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void scheduleInRunLoop (NSRunLoop runLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scheduleInRunLoop_1forMode_1, runLoop !is null ? runLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMapEnumerator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMapEnumerator;
+
+import dwt.dwthelper.utils;
+
+public class NSMapEnumerator {
+//TODO
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMapTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMapTable;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPointerFunctions;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMapTable : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public NSDictionary dictionaryRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dictionaryRepresentation);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public id initWithKeyOptions (NSPointerFunctionsOptions keyOptions, NSPointerFunctionsOptions valueOptions, NSUInteger initialCapacity)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithKeyOptions_1valueOptions_1capacity_1, keyOptions, valueOptions, initialCapacity);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithKeyPointerFunctions (NSPointerFunctions keyFunctions, NSPointerFunctions valueFunctions, NSUInteger initialCapacity)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithKeyPointerFunctions_1valuePointerFunctions_1capacity_1,
+                keyFunctions !is null ? keyFunctions.id : null, valueFunctions !is null ? valueFunctions.id : null, initialCapacity);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSEnumerator keyEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public NSPointerFunctions keyPointerFunctions ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyPointerFunctions);
+        return result !is null ? new NSPointerFunctions(result) : null;
+    }
+
+    public static id mapTableWithKeyOptions (NSPointerFunctionsOptions keyOptions, NSPointerFunctionsOptions valueOptions)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMapTable, OS.sel_mapTableWithKeyOptions_1valueOptions_1, keyOptions, valueOptions);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id mapTableWithStrongToStrongObjects ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMapTable, OS.sel_mapTableWithStrongToStrongObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id mapTableWithStrongToWeakObjects ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMapTable, OS.sel_mapTableWithStrongToWeakObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id mapTableWithWeakToStrongObjects ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMapTable, OS.sel_mapTableWithWeakToStrongObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id mapTableWithWeakToWeakObjects ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMapTable, OS.sel_mapTableWithWeakToWeakObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSEnumerator objectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public id objectForKey (id aKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_1, aKey !is null ? aKey.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void removeAllObjects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllObjects);
+    }
+
+    public void removeObjectForKey (id aKey)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectForKey_1, aKey !is null ? aKey.id : null);
+    }
+
+    public void setObject (id anObject, id aKey)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObject_1forKey_1, anObject !is null ? anObject.id : null, aKey !is null ? aKey.id : null);
+    }
+
+    public NSPointerFunctions valuePointerFunctions ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valuePointerFunctions);
+        return result !is null ? new NSPointerFunctions(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMapTableKeyCallBacks.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMapTableKeyCallBacks;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMapTableKeyCallBacks : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMapTableValueCallBacks.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMapTableValueCallBacks;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMapTableValueCallBacks : NSObject
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMatrix.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,556 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMatrix;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSNotification;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSMatrixMode
+{
+    NSRadioModeMatrix = 0,
+    NSHighlightModeMatrix = 1,
+    NSListModeMatrix = 2,
+    NSTrackModeMatrix = 3
+}
+
+alias NSMatrixMode.NSRadioModeMatrix NSRadioModeMatrix;
+alias NSMatrixMode.NSHighlightModeMatrix NSHighlightModeMatrix;
+alias NSMatrixMode.NSListModeMatrix NSListModeMatrix;
+alias NSMatrixMode.NSTrackModeMatrix NSTrackModeMatrix;
+
+public class NSMatrix : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsFirstMouse (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsFirstMouse_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public void addColumn ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_addColumn);
+    }
+
+    public void addColumnWithCells (NSArray newCells)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addColumnWithCells_1, newCells !is null ? newCells.id : null);
+    }
+
+    public void addRow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_addRow);
+    }
+
+    public void addRowWithCells (NSArray newCells)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addRowWithCells_1, newCells !is null ? newCells.id : null);
+    }
+
+    public bool allowsEmptySelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsEmptySelection) !is null;
+    }
+
+    public bool autosizesCells ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autosizesCells) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public id cellAtRow (NSInteger row, NSInteger col)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cellAtRow_1column_1, row, col);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSColor cellBackgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cellBackgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    //public objc.Class cellClass() {
+    //  return OS.objc_msgSend(this.id, OS.sel_cellClass);
+    //}
+
+    public NSRect cellFrameAtRow (NSInteger row, NSInteger col)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_cellFrameAtRow_1column_1, row, col);
+        return result;
+    }
+
+    public NSSize cellSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_cellSize);
+        return result;
+    }
+
+    public id cellWithTag (NSInteger anInt)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cellWithTag_1, anInt);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray cells ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cells);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void deselectAllCells ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_deselectAllCells);
+    }
+
+    public void deselectSelectedCell ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_deselectSelectedCell);
+    }
+
+    public objc.SEL doubleAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_doubleAction);
+    }
+
+    public void drawCellAtRow (NSInteger row, NSInteger col)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawCellAtRow_1column_1, row, col);
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public bool drawsCellBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsCellBackground) !is null;
+    }
+
+    public void getNumberOfRows (NSInteger* rowCount, NSInteger* colCount)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getNumberOfRows_1columns_1, rowCount, colCount);
+    }
+
+    public bool getRow_column_forPoint_ (NSInteger* row, NSInteger* col, NSPoint aPoint)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getRow_1column_1forPoint_1, row, col, aPoint) !is null;
+    }
+
+    public bool getRow_column_ofCell_ (NSInteger* row, NSInteger* col, NSCell aCell)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getRow_1column_1ofCell_1, row, col, aCell !is null ? aCell.id : null) !is null;
+    }
+
+    public void highlightCell (bool flag, NSInteger row, NSInteger col)
+    {
+        OS.objc_msgSend(this.id, OS.sel_highlightCell_1atRow_1column_1, flag, row, col);
+    }
+
+    public id initWithFrame_ (NSRect frameRect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1, frameRect);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithFrame_mode_cellClass_numberOfRows_numberOfColumns_ (NSRect frameRect, NSInteger aMode, objc.Class factoryId,
+            NSInteger rowsHigh, NSInteger colsWide)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1mode_1cellClass_1numberOfRows_1numberOfColumns_1, frameRect, aMode,
+                factoryId, rowsHigh, colsWide);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithFrame_mode_prototype_numberOfRows_numberOfColumns_ (NSRect frameRect, NSInteger aMode, NSCell aCell, NSInteger rowsHigh,
+            NSInteger colsWide)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1mode_1prototype_1numberOfRows_1numberOfColumns_1, frameRect, aMode,
+                aCell !is null ? aCell.id : null, rowsHigh, colsWide);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void insertColumn_ (NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertColumn_1, column);
+    }
+
+    public void insertColumn_withCells_ (NSInteger column, NSArray newCells)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertColumn_1withCells_1, column, newCells !is null ? newCells.id : null);
+    }
+
+    public void insertRow_ (NSInteger row)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertRow_1, row);
+    }
+
+    public void insertRow_withCells_ (NSInteger row, NSArray newCells)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertRow_1withCells_1, row, newCells !is null ? newCells.id : null);
+    }
+
+    public NSSize intercellSpacing ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_intercellSpacing);
+        return result;
+    }
+
+    public bool isAutoscroll ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAutoscroll) !is null;
+    }
+
+    public bool isSelectionByRect ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectionByRect) !is null;
+    }
+
+    public id keyCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSCell makeCellAtRow (NSInteger row, NSInteger col)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_makeCellAtRow_1column_1, row, col);
+        return result !is null ? new NSCell(result) : null;
+    }
+
+    public NSMatrixMode mode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mode);
+    }
+
+    public void mouseDown (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseDown_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public NSInteger mouseDownFlags ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mouseDownFlags);
+    }
+
+    public NSInteger numberOfColumns ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfColumns);
+    }
+
+    public NSInteger numberOfRows ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfRows);
+    }
+
+    public bool performKeyEquivalent (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performKeyEquivalent_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public id prototype ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_prototype);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void putCell (NSCell newCell, NSInteger row, NSInteger col)
+    {
+        OS.objc_msgSend(this.id, OS.sel_putCell_1atRow_1column_1, newCell !is null ? newCell.id : null, row, col);
+    }
+
+    public void removeColumn (NSInteger col)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeColumn_1, col);
+    }
+
+    public void removeRow (NSInteger row)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeRow_1, row);
+    }
+
+    public void renewRows (NSInteger newRows, NSInteger newCols)
+    {
+        OS.objc_msgSend(this.id, OS.sel_renewRows_1columns_1, newRows, newCols);
+    }
+
+    public void resetCursorRects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resetCursorRects);
+    }
+
+    public void scrollCellToVisibleAtRow (NSInteger row, NSInteger col)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollCellToVisibleAtRow_1column_1, row, col);
+    }
+
+    public void selectAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectAll_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectCellAtRow (NSInteger row, NSInteger col)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectCellAtRow_1column_1, row, col);
+    }
+
+    public bool selectCellWithTag (NSInteger anInt)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectCellWithTag_1, anInt) !is null;
+    }
+
+    public void selectText (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectText_1, sender !is null ? sender.id : null);
+    }
+
+    public id selectTextAtRow (NSInteger row, NSInteger col)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectTextAtRow_1column_1, row, col);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id selectedCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray selectedCells ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedCells);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSInteger selectedColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectedColumn);
+    }
+
+    public NSInteger selectedRow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectedRow);
+    }
+
+    public bool sendAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendAction) !is null;
+    }
+
+    public void sendAction_to_forAllCells_ (objc.SEL aSelector, id anObject, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sendAction_1to_1forAllCells_1, aSelector, anObject !is null ? anObject.id : null, flag);
+    }
+
+    public void sendDoubleAction ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sendDoubleAction);
+    }
+
+    public void setAllowsEmptySelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsEmptySelection_1, flag);
+    }
+
+    public void setAutoscroll (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoscroll_1, flag);
+    }
+
+    public void setAutosizesCells (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosizesCells_1, flag);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setCellBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCellBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    //public void setCellClass(objc.Class factoryId) {
+    //  OS.objc_msgSend(this.id, OS.sel_setCellClass_1, factoryId);
+    //}
+
+    public void setCellSize (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCellSize_1, aSize);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDoubleAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleAction_1, aSelector);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setDrawsCellBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsCellBackground_1, flag);
+    }
+
+    public void setIntercellSpacing (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntercellSpacing_1, aSize);
+    }
+
+    public void setKeyCell (NSCell keyCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyCell_1, keyCell !is null ? keyCell.id : null);
+    }
+
+    public void setMode (NSMatrixMode aMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMode_1, aMode);
+    }
+
+    public void setPrototype (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrototype_1, aCell !is null ? aCell.id : null);
+    }
+
+    public void setScrollable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScrollable_1, flag);
+    }
+
+    public void setSelectionByRect (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectionByRect_1, flag);
+    }
+
+    public void setSelectionFrom (NSInteger startPos, NSInteger endPos, NSInteger anchorPos, bool lit)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectionFrom_1to_1anchor_1highlight_1, startPos, endPos, anchorPos, lit);
+    }
+
+    public void setState (NSInteger value, NSInteger row, NSInteger col)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setState_1atRow_1column_1, value, row, col);
+    }
+
+    public void setTabKeyTraversesCells (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTabKeyTraversesCells_1, flag);
+    }
+
+    public void setToolTip (NSString toolTipString, NSCell cell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setToolTip_1forCell_1, toolTipString !is null ? toolTipString.id : null, cell !is null ? cell.id : null);
+    }
+
+    public void setValidateSize (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValidateSize_1, flag);
+    }
+
+    public void sizeToCells ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToCells);
+    }
+
+    public void sortUsingFunction (int* function(objc.id, objc.id, void*) compare, void* context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sortUsingFunction_1context_1, compare, context);
+    }
+
+    public void sortUsingSelector (objc.SEL comparator)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sortUsingSelector_1, comparator);
+    }
+
+    public bool tabKeyTraversesCells ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tabKeyTraversesCells) !is null;
+    }
+
+    public void textDidBeginEditing (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidBeginEditing_1, notification !is null ? notification.id : null);
+    }
+
+    public void textDidChange (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidChange_1, notification !is null ? notification.id : null);
+    }
+
+    public void textDidEndEditing (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidEndEditing_1, notification !is null ? notification.id : null);
+    }
+
+    public bool textShouldBeginEditing (NSText textObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_textShouldBeginEditing_1, textObject !is null ? textObject.id : null) !is null;
+    }
+
+    public bool textShouldEndEditing (NSText textObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_textShouldEndEditing_1, textObject !is null ? textObject.id : null) !is null;
+    }
+
+    public NSString toolTipForCell (NSCell cell)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolTipForCell_1, cell !is null ? cell.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMenu.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,350 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMenu;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMenu : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addItem (NSMenuItem newItem)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItem_1, newItem !is null ? newItem.id : null);
+    }
+
+    public NSMenuItem addItemWithTitle (NSString aString, objc.SEL aSelector, NSString charCode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addItemWithTitle_1action_1keyEquivalent_1, aString !is null ? aString.id : null, aSelector,
+                charCode !is null ? charCode.id : null);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSMenu attachedMenu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedMenu);
+        return result is this.id ? this : (result !is null ? new NSMenu(result) : null);
+    }
+
+    public bool autoenablesItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoenablesItems) !is null;
+    }
+
+    public void cancelTracking ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelTracking);
+    }
+
+    public id contextMenuRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contextMenuRepresentation);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void helpRequested (NSEvent eventPtr)
+    {
+        OS.objc_msgSend(this.id, OS.sel_helpRequested_1, eventPtr !is null ? eventPtr.id : null);
+    }
+
+    public NSMenuItem highlightedItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightedItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSInteger indexOfItem (NSMenuItem index)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItem_1, index !is null ? index.id : null);
+    }
+
+    public NSInteger indexOfItemWithRepresentedObject (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithRepresentedObject_1, object !is null ? object.id : null);
+    }
+
+    public NSInteger indexOfItemWithSubmenu (NSMenu submenu)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithSubmenu_1, submenu !is null ? submenu.id : null);
+    }
+
+    public NSInteger indexOfItemWithTag (NSInteger aTag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTag_1, aTag);
+    }
+
+    public NSInteger indexOfItemWithTarget (id target, objc.SEL actionSelector)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTarget_1andAction_1, target !is null ? target.id : null, actionSelector);
+    }
+
+    public NSInteger indexOfItemWithTitle (NSString aTitle)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTitle_1, aTitle !is null ? aTitle.id : null);
+    }
+
+    public NSMenu initWithTitle (NSString aTitle)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTitle_1, aTitle !is null ? aTitle.id : null);
+        return result !is null ? this : null;
+    }
+
+    public void insertItem (NSMenuItem newItem, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertItem_1atIndex_1, newItem !is null ? newItem.id : null, index);
+    }
+
+    public NSMenuItem insertItemWithTitle (NSString aString, objc.SEL aSelector, NSString charCode, NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_insertItemWithTitle_1action_1keyEquivalent_1atIndex_1, aString !is null ? aString.id : null,
+                aSelector, charCode !is null ? charCode.id : null, index);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public bool isAttached ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAttached) !is null;
+    }
+
+    public bool isTornOff ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTornOff) !is null;
+    }
+
+    public NSArray itemArray ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemArray);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSMenuItem itemAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtIndex_1, index);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public void itemChanged (NSMenuItem item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_itemChanged_1, item !is null ? item.id : null);
+    }
+
+    public NSMenuItem itemWithTag (NSInteger tag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTag_1, tag);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSMenuItem itemWithTitle (NSString aTitle)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTitle_1, aTitle !is null ? aTitle.id : null);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSPoint locationForSubmenu (NSMenu aSubmenu)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_locationForSubmenu_1, aSubmenu !is null ? aSubmenu.id : null);
+        return result;
+    }
+
+    public CGFloat menuBarHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_menuBarHeight);
+    }
+
+    public static bool menuBarVisible ()
+    {
+        return OS.objc_msgSend(OS.class_NSMenu, OS.sel_menuBarVisible) !is null;
+    }
+
+    public bool menuChangedMessagesEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_menuChangedMessagesEnabled) !is null;
+    }
+
+    public id menuRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuRepresentation);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSZone* menuZone ()
+    {
+        return OS.objc_msgSend(OS.class_NSMenu, OS.sel_menuZone);
+    }
+
+    public NSInteger numberOfItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfItems);
+    }
+
+    public void performActionForItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performActionForItemAtIndex_1, index);
+    }
+
+    public bool performKeyEquivalent (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performKeyEquivalent_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public static void static_popUpContextMenu_withEvent_forView_ (NSMenu menu, NSEvent event, NSView view)
+    {
+        OS.objc_msgSend(OS.class_NSMenu, OS.sel_popUpContextMenu_1withEvent_1forView_1, menu !is null ? menu.id : null,
+                event !is null ? event.id : null, view !is null ? view.id : null);
+    }
+
+    public static void static_popUpContextMenu_withEvent_forView_withFont_ (NSMenu menu, NSEvent event, NSView view, NSFont font)
+    {
+        OS.objc_msgSend(OS.class_NSMenu, OS.sel_popUpContextMenu_1withEvent_1forView_1withFont_1, menu !is null ? menu.id : null,
+                event !is null ? event.id : null, view !is null ? view.id : null, font !is null ? font.id : null);
+    }
+
+    public void removeItem (NSMenuItem item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItem_1, item !is null ? item.id : null);
+    }
+
+    public void removeItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index);
+    }
+
+    public void setAutoenablesItems (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoenablesItems_1, flag);
+    }
+
+    public void setContextMenuRepresentation (id menuRep)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContextMenuRepresentation_1, menuRep !is null ? menuRep.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public static void setMenuBarVisible (bool visible)
+    {
+        OS.objc_msgSend(OS.class_NSMenu, OS.sel_setMenuBarVisible_1, visible);
+    }
+
+    public void setMenuChangedMessagesEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenuChangedMessagesEnabled_1, flag);
+    }
+
+    public void setMenuRepresentation (id menuRep)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenuRepresentation_1, menuRep !is null ? menuRep.id : null);
+    }
+
+    public static void setMenuZone (NSZone* aZone)
+    {
+        OS.objc_msgSend(OS.class_NSMenu, OS.sel_setMenuZone_1, aZone);
+    }
+
+    public void setShowsStateColumn (bool showsState)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsStateColumn_1, showsState);
+    }
+
+    public void setSubmenu (NSMenu aMenu, NSMenuItem anItem)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSubmenu_1forItem_1, aMenu !is null ? aMenu.id : null, anItem !is null ? anItem.id : null);
+    }
+
+    public void setSupermenu (NSMenu supermenu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSupermenu_1, supermenu !is null ? supermenu.id : null);
+    }
+
+    public void setTearOffMenuRepresentation (id menuRep)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTearOffMenuRepresentation_1, menuRep !is null ? menuRep.id : null);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public bool showsStateColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsStateColumn) !is null;
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public void submenuAction (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_submenuAction_1, sender !is null ? sender.id : null);
+    }
+
+    public NSMenu supermenu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_supermenu);
+        return result is this.id ? this : (result !is null ? new NSMenu(result) : null);
+    }
+
+    public id tearOffMenuRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tearOffMenuRepresentation);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void update ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_update);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMenuItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMenuItem;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMenuItem : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.SEL action ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_action);
+    }
+
+    public NSAttributedString attributedTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedTitle);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public bool hasSubmenu ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasSubmenu) !is null;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSInteger indentationLevel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indentationLevel);
+    }
+
+    public NSMenuItem initWithTitle (NSString aString, objc.SEL aSelector, NSString charCode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTitle_1action_1keyEquivalent_1, aString !is null ? aString.id : null, aSelector,
+                charCode !is null ? charCode.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isAlternate ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAlternate) !is null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public bool isHidden ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHidden) !is null;
+    }
+
+    public bool isHiddenOrHasHiddenAncestor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHiddenOrHasHiddenAncestor) !is null;
+    }
+
+    public bool isHighlighted ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHighlighted) !is null;
+    }
+
+    public bool isSeparatorItem ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSeparatorItem) !is null;
+    }
+
+    public NSString keyEquivalent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEquivalent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger keyEquivalentModifierMask ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_keyEquivalentModifierMask);
+    }
+
+    public NSMenu menu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSImage mixedStateImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mixedStateImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSString mnemonic ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mnemonic);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger mnemonicLocation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mnemonicLocation);
+    }
+
+    public NSImage offStateImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_offStateImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImage onStateImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_onStateImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public id representedObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSMenuItem separatorItem ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMenuItem, OS.sel_separatorItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public void setAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, aSelector);
+    }
+
+    public void setAlternate (bool isAlternate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternate_1, isAlternate);
+    }
+
+    public void setAttributedTitle (NSAttributedString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedTitle_1, string !is null ? string.id : null);
+    }
+
+    public void setEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, flag);
+    }
+
+    public void setHidden (bool hidden)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHidden_1, hidden);
+    }
+
+    public void setImage (NSImage menuImage)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, menuImage !is null ? menuImage.id : null);
+    }
+
+    public void setIndentationLevel (NSInteger indentationLevel)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIndentationLevel_1, indentationLevel);
+    }
+
+    public void setKeyEquivalent (NSString aKeyEquivalent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalent_1, aKeyEquivalent !is null ? aKeyEquivalent.id : null);
+    }
+
+    public void setKeyEquivalentModifierMask (NSUInteger mask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyEquivalentModifierMask_1, mask);
+    }
+
+    public void setMenu (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1, menu !is null ? menu.id : null);
+    }
+
+    public void setMixedStateImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMixedStateImage_1, image !is null ? image.id : null);
+    }
+
+    public void setMnemonicLocation (NSUInteger location)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMnemonicLocation_1, location);
+    }
+
+    public void setOffStateImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOffStateImage_1, image !is null ? image.id : null);
+    }
+
+    public void setOnStateImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOnStateImage_1, image !is null ? image.id : null);
+    }
+
+    public void setRepresentedObject (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRepresentedObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setState (NSInteger state)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setState_1, state);
+    }
+
+    public void setSubmenu (NSMenu submenu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSubmenu_1, submenu !is null ? submenu.id : null);
+    }
+
+    public void setTag (NSInteger anInt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTag_1, anInt);
+    }
+
+    public void setTarget (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleWithMnemonic (NSString stringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithMnemonic_1, stringWithAmpersand !is null ? stringWithAmpersand.id : null);
+    }
+
+    public void setToolTip (NSString toolTip)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setToolTip_1, toolTip !is null ? toolTip.id : null);
+    }
+
+    public static void setUsesUserKeyEquivalents (bool flag)
+    {
+        OS.objc_msgSend(OS.class_NSMenuItem, OS.sel_setUsesUserKeyEquivalents_1, flag);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public NSInteger state ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_state);
+    }
+
+    public NSMenu submenu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_submenu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSInteger tag ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tag);
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString toolTip ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolTip);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString userKeyEquivalent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_userKeyEquivalent);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static bool usesUserKeyEquivalents ()
+    {
+        return OS.objc_msgSend(OS.class_NSMenuItem, OS.sel_usesUserKeyEquivalents) !is null;
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMenuItemCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMenuItemCell;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSButtonCell;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSMenuView;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMenuItemCell : NSButtonCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void calcSize ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_calcSize);
+    }
+
+    public void drawBorderAndBackgroundWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawBorderAndBackgroundWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public void drawImageWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawImageWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public void drawKeyEquivalentWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawKeyEquivalentWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public void drawSeparatorItemWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawSeparatorItemWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public void drawStateImageWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawStateImageWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public void drawTitleWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawTitleWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public CGFloat imageWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_imageWidth);
+    }
+
+    public NSRect keyEquivalentRectForBounds (NSRect cellFrame)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_keyEquivalentRectForBounds_1, cellFrame);
+        return result;
+    }
+
+    public CGFloat keyEquivalentWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_keyEquivalentWidth);
+    }
+
+    public NSMenuItem menuItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSMenuView menuView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuView);
+        return result !is null ? new NSMenuView(result) : null;
+    }
+
+    public bool needsDisplay ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_needsDisplay) !is null;
+    }
+
+    public bool needsSizing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_needsSizing) !is null;
+    }
+
+    public void setMenuItem (NSMenuItem item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenuItem_1, item !is null ? item.id : null);
+    }
+
+    public void setMenuView (NSMenuView menuView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenuView_1, menuView !is null ? menuView.id : null);
+    }
+
+    public void setNeedsDisplay (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsDisplay_1, flag);
+    }
+
+    public void setNeedsSizing (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsSizing_1, flag);
+    }
+
+    public NSRect stateImageRectForBounds (NSRect cellFrame)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_stateImageRectForBounds_1, cellFrame);
+        return result;
+    }
+
+    public CGFloat stateImageWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_stateImageWidth);
+    }
+
+    public NSInteger tag ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tag);
+    }
+
+    public NSRect titleRectForBounds (NSRect cellFrame)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_titleRectForBounds_1, cellFrame);
+        return result;
+    }
+
+    public CGFloat titleWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_titleWidth);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMenuView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMenuView;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect : NSRectEdge;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMenuView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void attachSubmenuForItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_attachSubmenuForItemAtIndex_1, index);
+    }
+
+    public NSMenu attachedMenu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedMenu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSMenuView attachedMenuView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedMenuView);
+        return result is this.id ? this : (result !is null ? new NSMenuView(result) : null);
+    }
+
+    public void detachSubmenu ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_detachSubmenu);
+    }
+
+    public NSFont font ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSInteger highlightedItemIndex ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_highlightedItemIndex);
+    }
+
+    public CGFloat horizontalEdgePadding ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_horizontalEdgePadding);
+    }
+
+    public CGFloat imageAndTitleOffset ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_imageAndTitleOffset);
+    }
+
+    public CGFloat imageAndTitleWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_imageAndTitleWidth);
+    }
+
+    public NSInteger indexOfItemAtPoint (NSPoint point)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItemAtPoint_1, point);
+    }
+
+    public NSMenuView initAsTearOff ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initAsTearOff);
+        return result !is null ? this : null;
+    }
+
+    public NSRect innerRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_innerRect);
+        return result;
+    }
+
+    public bool isAttached ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAttached) !is null;
+    }
+
+    public bool isHorizontal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHorizontal) !is null;
+    }
+
+    public bool isTornOff ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTornOff) !is null;
+    }
+
+    public void itemAdded (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_itemAdded_1, notification !is null ? notification.id : null);
+    }
+
+    public void itemChanged (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_itemChanged_1, notification !is null ? notification.id : null);
+    }
+
+    public void itemRemoved (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_itemRemoved_1, notification !is null ? notification.id : null);
+    }
+
+    public CGFloat keyEquivalentOffset ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_keyEquivalentOffset);
+    }
+
+    public CGFloat keyEquivalentWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_keyEquivalentWidth);
+    }
+
+    public NSPoint locationForSubmenu (NSMenu aSubmenu)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_locationForSubmenu_1, aSubmenu !is null ? aSubmenu.id : null);
+        return result;
+    }
+
+    public NSMenu menu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public static CGFloat menuBarHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSMenuView, OS.sel_menuBarHeight);
+    }
+
+    public NSMenuItemCell menuItemCellForItemAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuItemCellForItemAtIndex_1, index);
+        return result !is null ? new NSMenuItemCell(result) : null;
+    }
+
+    public bool needsSizing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_needsSizing) !is null;
+    }
+
+    public void performActionWithHighlightingForItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performActionWithHighlightingForItemAtIndex_1, index);
+    }
+
+    public NSRect rectOfItemAtIndex (NSInteger)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfItemAtIndex_1, index);
+        return result;
+    }
+
+    public void setFont (NSFont font)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, font !is null ? font.id : null);
+    }
+
+    public void setHighlightedItemIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHighlightedItemIndex_1, index);
+    }
+
+    public void setHorizontal (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontal_1, flag);
+    }
+
+    public void setHorizontalEdgePadding (CGFloat pad)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontalEdgePadding_1, pad);
+    }
+
+    public void setMenu (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1, menu !is null ? menu.id : null);
+    }
+
+    public void setMenuItemCell (NSMenuItemCell cell, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenuItemCell_1forItemAtIndex_1, cell !is null ? cell.id : null, index);
+    }
+
+    public void setNeedsDisplayForItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsDisplayForItemAtIndex_1, index);
+    }
+
+    public void setNeedsSizing (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsSizing_1, flag);
+    }
+
+    public void setWindowFrameForAttachingToRect (NSRect screenRect, NSScreen screen, NSRectEdge edge, NSInteger selectedItemIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindowFrameForAttachingToRect_1onScreen_1preferredEdge_1popUpSelectedItem_1, screenRect,
+                screen !is null ? screen.id : null, edge, selectedItemIndex);
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public CGFloat stateImageOffset ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_stateImageOffset);
+    }
+
+    public CGFloat stateImageWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_stateImageWidth);
+    }
+
+    public bool trackWithEvent (NSEvent event)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_trackWithEvent_1, event !is null ? event.id : null) !is null;
+    }
+
+    public void update ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_update);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMessagePortNameServer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMessagePortNameServer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSPortNameServer;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMessagePortNameServer : NSPortNameServer
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSPort portForName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public NSPort portForName_host_ (NSString name, NSString host)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1host_1, name !is null ? name.id : null, host !is null ? host.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public static id sharedInstance ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMessagePortNameServer, OS.sel_sharedInstance);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMetadataItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMetadataItem;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMetadataItem : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray attributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id valueForAttribute (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForAttribute_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary valuesForAttributes (NSArray keys)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valuesForAttributes_1, keys !is null ? keys.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMetadataQuery.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMetadataQuery;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMetadataQuery : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void disableUpdates ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_disableUpdates);
+    }
+
+    public void enableUpdates ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_enableUpdates);
+    }
+
+    public NSArray groupedResults ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_groupedResults);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray groupingAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_groupingAttributes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSUInteger indexOfResult (id result)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfResult_1, result !is null ? result.id : null);
+    }
+
+    public bool isGathering ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isGathering) !is null;
+    }
+
+    public bool isStarted ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isStarted) !is null;
+    }
+
+    public bool isStopped ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isStopped) !is null;
+    }
+
+    public NSTimeInterval notificationBatchingInterval ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_notificationBatchingInterval);
+    }
+
+    public NSPredicate predicate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_predicate);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public id resultAtIndex (NSUInteger idx)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resultAtIndex_1, idx);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.id resultCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_resultCount);
+    }
+
+    public NSArray results ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_results);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray searchScopes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_searchScopes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setGroupingAttributes (NSArray attrs)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGroupingAttributes_1, attrs !is null ? attrs.id : null);
+    }
+
+    public void setNotificationBatchingInterval (NSTimeInterval ti)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNotificationBatchingInterval_1, ti);
+    }
+
+    public void setPredicate (NSPredicate predicate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPredicate_1, predicate !is null ? predicate.id : null);
+    }
+
+    public void setSearchScopes (NSArray scopes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSearchScopes_1, scopes !is null ? scopes.id : null);
+    }
+
+    public void setSortDescriptors (NSArray descriptors)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSortDescriptors_1, descriptors !is null ? descriptors.id : null);
+    }
+
+    public void setValueListAttributes (NSArray attrs)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValueListAttributes_1, attrs !is null ? attrs.id : null);
+    }
+
+    public NSArray sortDescriptors ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortDescriptors);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool startQuery ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_startQuery) !is null;
+    }
+
+    public void stopQuery ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopQuery);
+    }
+
+    public NSArray valueListAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueListAttributes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSDictionary valueLists ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueLists);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public id valueOfAttribute (NSString attrName, NSUInteger idx)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueOfAttribute_1forResultAtIndex_1, attrName !is null ? attrName.id : null, idx);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMetadataQueryAttributeValueTuple.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMetadataQueryAttributeValueTuple;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMetadataQueryAttributeValueTuple : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString attribute ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public id value ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_value);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMetadataQueryResultGroup.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMetadataQueryResultGroup;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMetadataQueryResultGroup : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString attribute ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id resultAtIndex (NSUInteger idx)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resultAtIndex_1, idx);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger resultCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_resultCount);
+    }
+
+    public NSArray results ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_results);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray subgroups ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subgroups);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id value ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_value);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMethodSignature.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMethodSignature;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMethodSignature : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSUInteger frameLength ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_frameLength);
+    }
+
+    public /*const*/char* getArgumentTypeAtIndex (NSUInteger idx)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getArgumentTypeAtIndex_1, idx);
+    }
+
+    public bool isOneway ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOneway) !is null;
+    }
+
+    public NSUInteger methodReturnLength ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_methodReturnLength);
+    }
+
+    public /*const*/char* methodReturnType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_methodReturnType);
+    }
+
+    public NSUInteger numberOfArguments ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfArguments);
+    }
+
+    public static NSMethodSignature signatureWithObjCTypes (/*const*/char* types)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMethodSignature, OS.sel_signatureWithObjCTypes_1, types);
+        return result !is null ? new NSMethodSignature(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMoveCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMoveCommand;
+
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMoveCommand : NSScriptCommand
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptObjectSpecifier keySpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keySpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReceiversSpecifier_1, receiversRef !is null ? receiversRef.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMovie.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMovie;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMovie : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void* QTMovie ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_QTMovie);
+    }
+
+    public NSURL URL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public static bool canInitWithPasteboard (NSPasteboard pasteboard)
+    {
+        return OS.objc_msgSend(OS.class_NSMovie, OS.sel_canInitWithPasteboard_1, pasteboard !is null ? pasteboard.id : null) !is null;
+    }
+
+    public NSMovie initWithMovie (void* movie)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMovie_1, movie);
+        return result !is null ? this : null;
+    }
+
+    public NSMovie initWithPasteboard (NSPasteboard pasteboard)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPasteboard_1, pasteboard !is null ? pasteboard.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSMovie initWithURL (NSURL url, bool byRef)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithURL_1byReference_1, url !is null ? url.id : null, byRef);
+        return result !is null ? this : null;
+    }
+
+    public static NSArray movieUnfilteredFileTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMovie, OS.sel_movieUnfilteredFileTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray movieUnfilteredPasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMovie, OS.sel_movieUnfilteredPasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMovieView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMovieView;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMovie;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSUInteger NSQTMovieLoopMode;
+
+public class NSMovieView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void clear (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_clear_1, sender !is null ? sender.id : null);
+    }
+
+    public void copy (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_copy_1, sender !is null ? sender.id : null);
+    }
+
+    public void cut (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cut_1, sender !is null ? sender.id : null);
+    }
+
+    public void deletee (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_delete_1, sender !is null ? sender.id : null);
+    }
+
+    public void gotoBeginning (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_gotoBeginning_1, sender !is null ? sender.id : null);
+    }
+
+    public void gotoEnd (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_gotoEnd_1, sender !is null ? sender.id : null);
+    }
+
+    public void gotoPosterFrame (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_gotoPosterFrame_1, sender !is null ? sender.id : null);
+    }
+
+    public bool isControllerVisible ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isControllerVisible) !is null;
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public bool isMuted ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMuted) !is null;
+    }
+
+    public bool isPlaying ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isPlaying) !is null;
+    }
+
+    public NSQTMovieLoopMode loopMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_loopMode);
+    }
+
+    public NSMovie movie ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_movie);
+        return result !is null ? new NSMovie(result) : null;
+    }
+
+    public void* movieController ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_movieController);
+    }
+
+    public NSRect movieRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_movieRect);
+        return result;
+    }
+
+    public void paste (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_paste_1, sender !is null ? sender.id : null);
+    }
+
+    public bool playsEveryFrame ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_playsEveryFrame) !is null;
+    }
+
+    public bool playsSelectionOnly ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_playsSelectionOnly) !is null;
+    }
+
+    public float rate ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_rate);
+    }
+
+    public void resizeWithMagnification (CGFloat magnification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resizeWithMagnification_1, magnification);
+    }
+
+    public void selectAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectAll_1, sender !is null ? sender.id : null);
+    }
+
+    public void setEditable (bool editable)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, editable);
+    }
+
+    public void setLoopMode (NSQTMovieLoopMode mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLoopMode_1, mode);
+    }
+
+    public void setMovie (NSMovie movie)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMovie_1, movie !is null ? movie.id : null);
+    }
+
+    public void setMuted (bool mute)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMuted_1, mute);
+    }
+
+    public void setPlaysEveryFrame (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaysEveryFrame_1, flag);
+    }
+
+    public void setPlaysSelectionOnly (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaysSelectionOnly_1, flag);
+    }
+
+    public void setRate (float rate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRate_1, rate);
+    }
+
+    public void setVolume (float volume)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVolume_1, volume);
+    }
+
+    public void showController (bool show, bool adjustSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showController_1adjustingSize_1, show, adjustSize);
+    }
+
+    public NSSize sizeForMagnification (CGFloat magnification)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_sizeForMagnification_1, magnification);
+        return result;
+    }
+
+    public void start (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_start_1, sender !is null ? sender.id : null);
+    }
+
+    public void stepBack (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stepBack_1, sender !is null ? sender.id : null);
+    }
+
+    public void stepForward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stepForward_1, sender !is null ? sender.id : null);
+    }
+
+    public void stop (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stop_1, sender !is null ? sender.id : null);
+    }
+
+    public float volume ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_volume);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableArray.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableArray;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableArray : NSArray
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObject (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void addObjectsFromArray (NSArray otherArray)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObjectsFromArray_1, otherArray !is null ? otherArray.id : null);
+    }
+
+    public static id arrayWithCapacity (NSUInteger numItems)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMutableArray, OS.sel_arrayWithCapacity_1, numItems);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void exchangeObjectAtIndex (NSUInteger idx1, NSUInteger idx2)
+    {
+        OS.objc_msgSend(this.id, OS.sel_exchangeObjectAtIndex_1withObjectAtIndex_1, idx1, idx2);
+    }
+
+    public void filterUsingPredicate (NSPredicate predicate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_filterUsingPredicate_1, predicate !is null ? predicate.id : null);
+    }
+
+    public NSMutableArray initWithCapacity (NSUInteger numItems)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCapacity_1, numItems);
+        return result !is null ? this : null;
+    }
+
+    public void insertObject (id anObject, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertObject_1atIndex_1, anObject !is null ? anObject.id : null, index);
+    }
+
+    public void insertObjects (NSArray objects, NSIndexSet indexes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertObjects_1atIndexes_1, objects !is null ? objects.id : null, indexes !is null ? indexes.id : null);
+    }
+
+    public void removeAllObjects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllObjects);
+    }
+
+    public void removeLastObject ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeLastObject);
+    }
+
+    public void removeObject_ (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void removeObject_inRange_ (id anObject, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObject_1inRange_1, anObject !is null ? anObject.id : null, range);
+    }
+
+    public void removeObjectAtIndex (insertObject index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectAtIndex_1, index);
+    }
+
+    public void removeObjectIdenticalTo_ (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectIdenticalTo_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void removeObjectIdenticalTo_inRange_ (id anObject, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id : null, range);
+    }
+
+    public void removeObjectsAtIndexes (NSIndexSet indexes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectsAtIndexes_1, indexes !is null ? indexes.id : null);
+    }
+
+    public void removeObjectsFromIndices (NSUInteger* indices, NSUInteger cnt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectsFromIndices_1numIndices_1, indices, cnt);
+    }
+
+    public void removeObjectsInArray (NSArray otherArray)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectsInArray_1, otherArray !is null ? otherArray.id : null);
+    }
+
+    public void removeObjectsInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectsInRange_1, range);
+    }
+
+    public void replaceObjectAtIndex (NSUInteger index, id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceObjectAtIndex_1withObject_1, index, anObject !is null ? anObject.id : null);
+    }
+
+    public void replaceObjectsAtIndexes (NSIndexSet indexes, NSArray objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceObjectsAtIndexes_1withObjects_1, indexes !is null ? indexes.id : null,
+                objects !is null ? objects.id : null);
+    }
+
+    public void replaceObjectsInRange_withObjectsFromArray_ (NSRange range, NSArray otherArray)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceObjectsInRange_1withObjectsFromArray_1, range, otherArray !is null ? otherArray.id : null);
+    }
+
+    public void replaceObjectsInRange_withObjectsFromArray_range_ (NSRange range, NSArray otherArray, NSRange otherRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceObjectsInRange_1withObjectsFromArray_1range_1, range, otherArray !is null ? otherArray.id : null,
+                otherRange);
+    }
+
+    public void setArray (NSArray otherArray)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setArray_1, otherArray !is null ? otherArray.id : null);
+    }
+
+    public void sortUsingDescriptors (NSArray sortDescriptors)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sortUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id : null);
+    }
+    
+    public void sortUsingFunction (int function (id, id, void*) compare, void* context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sortUsingFunction_1context_1, compare, context);
+    }
+
+    public void sortUsingSelector (objc.SEL comparator)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sortUsingSelector_1, comparator);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableAttributedString.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableAttributedString;
+
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMutableString;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableAttributedString : NSAttributedString
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addAttribute (/*java int*/ /*objc NSString* */ NSString name, id value, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addAttribute_1value_1range_1, name !is null ? name.id : null, value !is null ? value.id : null, range);
+    }
+
+    public void addAttributes (NSDictionary attrs, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addAttributes_1range_1, attrs !is null ? attrs.id : null, range);
+    }
+
+    public void appendAttributedString (NSAttributedString attrString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendAttributedString_1, attrString !is null ? attrString.id : null);
+    }
+
+    public void beginEditing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginEditing);
+    }
+
+    public void deleteCharactersInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteCharactersInRange_1, range);
+    }
+
+    public void endEditing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_endEditing);
+    }
+
+    public void insertAttributedString (NSAttributedString attrString, NSUInteger loc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertAttributedString_1atIndex_1, attrString !is null ? attrString.id : null, loc);
+    }
+
+    public NSMutableString mutableString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableString);
+        return result !is null ? new NSMutableString(result) : null;
+    }
+
+    public void removeAttribute (NSString name, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAttribute_1range_1, name !is null ? name.id : null, range);
+    }
+
+    public void replaceCharactersInRange_withAttributedString_ (NSRange range, NSAttributedString attrString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_1withAttributedString_1, range, attrString !is null ? attrString.id : null);
+    }
+
+    public void replaceCharactersInRange_withString_ (NSRange range, NSString str)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_1withString_1, range, str !is null ? str.id : null);
+    }
+
+    public void setAttributedString (NSAttributedString attrString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedString_1, attrString !is null ? attrString.id : null);
+    }
+
+    public void setAttributes (NSDictionary attrs, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributes_1range_1, attrs !is null ? attrs.id : null, range);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableCharacterSet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableCharacterSet;
+
+import dwt.internal.cocoa.NSCharacterSet;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableCharacterSet : NSCharacterSet
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addCharactersInRange (NSRange aRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addCharactersInRange_1, aRange);
+    }
+
+    public void addCharactersInString (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addCharactersInString_1, aString !is null ? aString.id : null);
+    }
+
+    public void formIntersectionWithCharacterSet (NSCharacterSet otherSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_formIntersectionWithCharacterSet_1, otherSet !is null ? otherSet.id : null);
+    }
+
+    public void formUnionWithCharacterSet (NSCharacterSet otherSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_formUnionWithCharacterSet_1, otherSet !is null ? otherSet.id : null);
+    }
+
+    public void invert ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invert);
+    }
+
+    public void removeCharactersInRange (NSRange aRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeCharactersInRange_1, aRange);
+    }
+
+    public void removeCharactersInString (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeCharactersInString_1, aString !is null ? aString.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableData;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableData : NSData
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void appendBytes (/*const*/void* bytes, NSUInteger length)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendBytes_1length_1, bytes, length);
+    }
+
+    public void appendData (NSData other)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendData_1, other !is null ? other.id : null);
+    }
+
+    public static id dataWithCapacity (NSUInteger aNumItems)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMutableData, OS.sel_dataWithCapacity_1, aNumItems);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id dataWithLength (NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMutableData, OS.sel_dataWithLength_1, length);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void increaseLengthBy (NSUInteger extraLength)
+    {
+        OS.objc_msgSend(this.id, OS.sel_increaseLengthBy_1, extraLength);
+    }
+
+    public NSMutableData initWithCapacity (NSUInteger capacity)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCapacity_1, capacity);
+        return result !is null ? this : null;
+    }
+
+    public NSMutableData initWithLength (NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLength_1, length);
+        return result !is null ? this : null;
+    }
+
+    public void* mutableBytes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mutableBytes);
+    }
+
+    public void replaceBytesInRange_withBytes_ (NSRange range, /*const*/void* bytes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceBytesInRange_1withBytes_1, range, bytes);
+    }
+
+    public void replaceBytesInRange_withBytes_length_ (NSRange range, /*const*/void* replacementBytes, NSUInteger replacementLength)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceBytesInRange_1withBytes_1length_1, range, replacementBytes, replacementLength);
+    }
+
+    public void resetBytesInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resetBytesInRange_1, range);
+    }
+
+    public void setData (NSData data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setData_1, data !is null ? data.id : null);
+    }
+
+    public void setLength (NSUInteger length)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLength_1, length);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableDictionary.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableDictionary;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableDictionary : NSDictionary
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addEntriesFromDictionary (NSDictionary otherDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addEntriesFromDictionary_1, otherDictionary !is null ? otherDictionary.id : null);
+    }
+
+    public static NSMutableDictionary dictionaryWithCapacity (NSUInteger numItems)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMutableDictionary, OS.sel_dictionaryWithCapacity_1, numItems);
+        return result !is null ? new NSMutableDictionary(result) : null;
+    }
+
+    public NSMutableDictionary initWithCapacity (NSUInteger numItems)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCapacity_1, numItems);
+        return result !is null ? this : null;
+    }
+
+    public void removeAllObjects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllObjects);
+    }
+
+    public void removeObjectForKey (id aKey)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectForKey_1, aKey !is null ? aKey.id : null);
+    }
+
+    public void removeObjectsForKeys (NSArray keyArray)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectsForKeys_1, keyArray !is null ? keyArray.id : null);
+    }
+
+    public void setDictionary (NSDictionary otherDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDictionary_1, otherDictionary !is null ? otherDictionary.id : null);
+    }
+
+    public void setObject (id anObject, id aKey)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObject_1forKey_1, anObject !is null ? anObject.id : null, aKey !is null ? aKey.id : null);
+    }
+
+    public void setObject (id anObject, objc.id aKey)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObject_1forKey_1, anObject !is null ? anObject.id : null, aKey);
+    }
+
+    public void setValue (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableIndexSet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableIndexSet;
+
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableIndexSet : NSIndexSet
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addIndex (NSUInteger value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addIndex_1, value);
+    }
+
+    public void addIndexes (NSIndexSet indexSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addIndexes_1, indexSet !is null ? indexSet.id : null);
+    }
+
+    public void addIndexesInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addIndexesInRange_1, range);
+    }
+
+    public void removeAllIndexes ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllIndexes);
+    }
+
+    public void removeIndex (NSUInteger value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeIndex_1, value);
+    }
+
+    public void removeIndexes (NSIndexSet indexSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeIndexes_1, indexSet !is null ? indexSet.id : null);
+    }
+
+    public void removeIndexesInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeIndexesInRange_1, range);
+    }
+
+    public void shiftIndexesStartingAtIndex (NSUInteger index, NSInteger delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_shiftIndexesStartingAtIndex_1by_1, index, delta);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableParagraphStyle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableParagraphStyle;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSParagraphStyle;
+import dwt.internal.cocoa.NSText : NSTextAlignment, NSWritingDirection;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSLineBreakMode
+{
+    NSLineBreakByWordWrapping = 0,
+    NSLineBreakByCharWrapping,
+    NSLineBreakByClipping,
+    NSLineBreakByTruncatingHead,
+    NSLineBreakByTruncatingTail,
+    NSLineBreakByTruncatingMiddle
+}
+
+alias NSLineBreakMode.NSLineBreakByWordWrapping NSLineBreakByWordWrapping;
+alias NSLineBreakMode.NSLineBreakByCharWrapping NSLineBreakByCharWrapping;
+alias NSLineBreakMode.NSLineBreakByClipping NSLineBreakByClipping;
+alias NSLineBreakMode.NSLineBreakByTruncatingHead NSLineBreakByTruncatingHead;
+alias NSLineBreakMode.NSLineBreakByTruncatingTail NSLineBreakByTruncatingTail;
+alias NSLineBreakMode.NSLineBreakByTruncatingMiddle NSLineBreakByTruncatingMiddle;
+
+public class NSMutableParagraphStyle : NSParagraphStyle
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addTabStop (NSTextTab anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTabStop_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void removeTabStop (NSTextTab anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeTabStop_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setAlignment (NSTextAlignment alignment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlignment_1, alignment);
+    }
+
+    public void setBaseWritingDirection (NSWritingDirection writingDirection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBaseWritingDirection_1, writingDirection);
+    }
+
+    public void setDefaultTabInterval (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultTabInterval_1, aFloat);
+    }
+
+    public void setFirstLineHeadIndent (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFirstLineHeadIndent_1, aFloat);
+    }
+
+    public void setHeadIndent (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHeadIndent_1, aFloat);
+    }
+
+    public void setHeaderLevel (NSInteger level)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHeaderLevel_1, level);
+    }
+
+    public void setHyphenationFactor (float aFactor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHyphenationFactor_1, aFactor);
+    }
+
+    public void setLineBreakMode (NSLineBreakMode mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineBreakMode_1, mode);
+    }
+
+    public void setLineHeightMultiple (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineHeightMultiple_1, aFloat);
+    }
+
+    public void setLineSpacing (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineSpacing_1, aFloat);
+    }
+
+    public void setMaximumLineHeight (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaximumLineHeight_1, aFloat);
+    }
+
+    public void setMinimumLineHeight (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinimumLineHeight_1, aFloat);
+    }
+
+    public void setParagraphSpacing (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParagraphSpacing_1, aFloat);
+    }
+
+    public void setParagraphSpacingBefore (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParagraphSpacingBefore_1, aFloat);
+    }
+
+    public void setParagraphStyle (NSParagraphStyle obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParagraphStyle_1, obj !is null ? obj.id : null);
+    }
+
+    public void setTabStops (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTabStops_1, array !is null ? array.id : null);
+    }
+
+    public void setTailIndent (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTailIndent_1, aFloat);
+    }
+
+    public void setTextBlocks (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextBlocks_1, array !is null ? array.id : null);
+    }
+
+    public void setTextLists (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextLists_1, array !is null ? array.id : null);
+    }
+
+    public void setTighteningFactorForTruncation (float aFactor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTighteningFactorForTruncation_1, aFactor);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableSet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableSet;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSSet;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableSet : NSSet
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObject_1, object !is null ? object.id : null);
+    }
+
+    public void addObjectsFromArray (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObjectsFromArray_1, array !is null ? array.id : null);
+    }
+
+    public void filterUsingPredicate (NSPredicate predicate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_filterUsingPredicate_1, predicate !is null ? predicate.id : null);
+    }
+
+    public NSMutableSet initWithCapacity (NSUInteger numItems)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCapacity_1, numItems);
+        return result !is null ? this : null;
+    }
+
+    public void intersectSet (NSSet otherSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_intersectSet_1, otherSet !is null ? otherSet.id : null);
+    }
+
+    public void minusSet (NSSet otherSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_minusSet_1, otherSet !is null ? otherSet.id : null);
+    }
+
+    public void removeAllObjects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllObjects);
+    }
+
+    public void removeObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObject_1, object !is null ? object.id : null);
+    }
+
+    public void setSet (NSSet otherSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSet_1, otherSet !is null ? otherSet.id : null);
+    }
+
+    public static id setWithCapacity (NSUInteger numItems)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMutableSet, OS.sel_setWithCapacity_1, numItems);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void unionSet (NSSet otherSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unionSet_1, otherSet !is null ? otherSet.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableString.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableString;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSMutableString : NSString
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void appendFormat (NSString appendFormat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendFormat_1, appendFormat !is null ? appendFormat.id : null);
+    }
+
+    public void appendString (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_appendString_1, aString !is null ? aString.id : null);
+    }
+
+    public void deleteCharactersInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteCharactersInRange_1, range);
+    }
+
+    public NSMutableString initWithCapacity (NSUInteger capacity)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCapacity_1, capacity);
+        return result !is null ? this : null;
+    }
+
+    public void insertString (NSString aString, NSUInteger loc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertString_1atIndex_1, aString !is null ? aString.id : null, loc);
+    }
+
+    public void replaceCharactersInRange (NSRange range, NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_1withString_1, range, aString !is null ? aString.id : null);
+    }
+
+    public NSUInteger replaceOccurrencesOfString (NSString target, NSString replacement, int options, NSRange searchRange)
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_replaceOccurrencesOfString_1withString_1options_1range_1, target !is null ? target.id : null,
+                replacement !is null ? replacement.id : null, options, searchRange);
+    }
+
+    public void setString (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setString_1, aString !is null ? aString.id : null);
+    }
+
+    public static id stringWithCapacity (NSUInteger capacity)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSMutableString, OS.sel_stringWithCapacity_1, capacity);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSMutableURLRequest.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSMutableURLRequest;
+
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInputStream;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import dwt.internal.objc.runtime;
+
+public class NSMutableURLRequest : NSURLRequest
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addValue (NSString value, NSString field)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addValue_1forHTTPHeaderField_1, value !is null ? value.id : null, field !is null ? field.id : null);
+    }
+
+    public void setAllHTTPHeaderFields (NSDictionary headerFields)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllHTTPHeaderFields_1, headerFields !is null ? headerFields.id : null);
+    }
+
+    public void setCachePolicy (NSURLRequestCachePolicy policy)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCachePolicy_1, policy);
+    }
+
+    public void setHTTPBody (NSData data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHTTPBody_1, data !is null ? data.id : null);
+    }
+
+    public void setHTTPBodyStream (NSInputStream inputStream)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHTTPBodyStream_1, inputStream !is null ? inputStream.id : null);
+    }
+
+    public void setHTTPMethod (NSString method)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHTTPMethod_1, method !is null ? method.id : null);
+    }
+
+    public void setHTTPShouldHandleCookies (bool should)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHTTPShouldHandleCookies_1, should);
+    }
+
+    public void setMainDocumentURL (NSURL URL)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMainDocumentURL_1, URL !is null ? URL.id : null);
+    }
+
+    public void setTimeoutInterval (double seconds)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTimeoutInterval_1, seconds);
+    }
+
+    public void setURL (NSURL URL)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setURL_1, URL !is null ? URL.id : null);
+    }
+
+    public void setValue (NSString value, NSString field)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forHTTPHeaderField_1, value !is null ? value.id : null, field !is null ? field.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNameSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNameSpecifier;
+
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNameSpecifier : NSScriptObjectSpecifier
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithContainerClassDescription (NSScriptClassDescription classDesc, NSScriptObjectSpecifier container, NSString property,
+            NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerClassDescription_1containerSpecifier_1key_1name_1,
+                classDesc !is null ? classDesc.id : null, container !is null ? container.id : null, property !is null ? property.id : null,
+                name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setName_1, name !is null ? name.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNetService.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNetService;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum
+{
+    NSNetServiceNoAutoRename = 1 << 0
+}
+
+alias NSUInteger NSNetServiceOptions;
+
+public class NSNetService : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData TXTRecordData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_TXTRecordData);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSArray addresses ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_addresses);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSData dataFromTXTRecordDictionary (NSDictionary txtDictionary)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNetService, OS.sel_dataFromTXTRecordDictionary_1,
+                txtDictionary !is null ? txtDictionary.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSDictionary dictionaryFromTXTRecordData (NSData txtData)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNetService, OS.sel_dictionaryFromTXTRecordData_1, txtData !is null ? txtData.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString domain ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_domain);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool getInputStream (objc.id** inputStream, objc.id** outputStream)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getInputStream_1outputStream_1, inputStream, outputStream) !is null;
+    }
+
+    public NSString hostName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_hostName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initWithDomain_type_name_ (NSString domain, NSString type, NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDomain_1type_1name_1, domain !is null ? domain.id : null,
+                type !is null ? type.id : null, name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithDomain_type_name_port_ (NSString domain, NSString type, NSString name, int port)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDomain_1type_1name_1port_1, domain !is null ? domain.id : null,
+                type !is null ? type.id : null, name !is null ? name.id : null, port);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger port ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_port);
+    }
+
+    public NSString protocolSpecificInformation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_protocolSpecificInformation);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void publish ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_publish);
+    }
+
+    public void publishWithOptions (NSNetServiceOptions options)
+    {
+        OS.objc_msgSend(this.id, OS.sel_publishWithOptions_1, options);
+    }
+
+    public void removeFromRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFromRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void resolve ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resolve);
+    }
+
+    public void resolveWithTimeout (NSTimeInterval timeout)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resolveWithTimeout_1, timeout);
+    }
+
+    public void scheduleInRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scheduleInRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setProtocolSpecificInformation (NSString specificInformation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setProtocolSpecificInformation_1, specificInformation !is null ? specificInformation.id : null);
+    }
+
+    public bool setTXTRecordData (NSData recordData)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setTXTRecordData_1, recordData !is null ? recordData.id : null) !is null;
+    }
+
+    public void startMonitoring ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_startMonitoring);
+    }
+
+    public void stop ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stop);
+    }
+
+    public void stopMonitoring ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopMonitoring);
+    }
+
+    public NSString type ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_type);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNetServiceBrowser.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNetServiceBrowser;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNetServiceBrowser : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void removeFromRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFromRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void scheduleInRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scheduleInRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void searchForAllDomains ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_searchForAllDomains);
+    }
+
+    public void searchForBrowsableDomains ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_searchForBrowsableDomains);
+    }
+
+    public void searchForRegistrationDomains ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_searchForRegistrationDomains);
+    }
+
+    public void searchForServicesOfType (NSString type, NSString domainString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_searchForServicesOfType_1inDomain_1, type !is null ? type.id : null,
+                domainString !is null ? domainString.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void stop ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stop);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNib.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNib;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSBundle;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNib : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithContentsOfURL (NSURL nibFileURL)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, nibFileURL !is null ? nibFileURL.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithNibNamed (NSString nibName, NSBundle bundle)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithNibNamed_1bundle_1, nibName !is null ? nibName.id : null,
+                bundle !is null ? bundle.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool instantiateNibWithExternalNameTable (NSDictionary externalNameTable)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_instantiateNibWithExternalNameTable_1, externalNameTable !is null ? externalNameTable.id : null) !is null;
+    }
+
+    public bool instantiateNibWithOwner (id owner, objc.id** topLevelObjects)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_instantiateNibWithOwner_1topLevelObjects_1, owner !is null ? owner.id : null, topLevelObjects) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNibConnector.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNibConnector;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNibConnector : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id destination ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_destination);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void establishConnection ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_establishConnection);
+    }
+
+    public NSString label ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_label);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void replaceObject (id oldObject, id newObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceObject_1withObject_1, oldObject !is null ? oldObject.id : null,
+                newObject !is null ? newObject.id : null);
+    }
+
+    public void setDestination (id destination)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDestination_1, destination !is null ? destination.id : null);
+    }
+
+    public void setLabel (NSString label)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLabel_1, label !is null ? label.id : null);
+    }
+
+    public void setSource (id source)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSource_1, source !is null ? source.id : null);
+    }
+
+    public id source ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_source);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNibControlConnector.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNibControlConnector;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNibControlConnector : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void establishConnection ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_establishConnection);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNibOutletConnector.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNibOutletConnector;
+
+import dwt.internal.cocoa.NSNibConnector;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNibOutletConnector : NSNibConnector
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void establishConnection ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_establishConnection);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNotification.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNotification;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.objc.runtime;
+
+public class NSNotification : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id static_notificationWithName_object_ (NSString aName, id anObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNotification, OS.sel_notificationWithName_1object_1, aName !is null ? aName.id : null,
+                anObject !is null ? anObject.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_notificationWithName_object_userInfo_ (NSString aName, id anObject, NSDictionary aUserInfo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNotification, OS.sel_notificationWithName_1object_1userInfo_1, aName !is null ? aName.id : null,
+                anObject !is null ? anObject.id : null, aUserInfo !is null ? aUserInfo.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id object ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_object);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary userInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_userInfo);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNotificationCenter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNotificationCenter;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSNotification;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNotificationCenter : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObserver (id observer, objc.SEL aSelector, NSString aName, id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1selector_1name_1object_1, observer !is null ? observer.id : null, aSelector,
+                aName !is null ? aName.id : null, anObject !is null ? anObject.id : null);
+    }
+
+    public static NSNotificationCenter defaultCenter ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNotificationCenter, OS.sel_defaultCenter);
+        return result !is null ? new NSNotificationCenter(result) : null;
+    }
+
+    public void postNotification (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postNotification_1, notification !is null ? notification.id : null);
+    }
+
+    public void postNotificationName_object_ (NSString aName, id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postNotificationName_1object_1, aName !is null ? aName.id : null, anObject !is null ? anObject.id : null);
+    }
+
+    public void postNotificationName_object_userInfo_ (NSString aName, id anObject, NSDictionary aUserInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postNotificationName_1object_1userInfo_1, aName !is null ? aName.id : null,
+                anObject !is null ? anObject.id : null, aUserInfo !is null ? aUserInfo.id : null);
+    }
+
+    public void removeObserver_ (id observer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1, observer !is null ? observer.id : null);
+    }
+
+    public void removeObserver_name_object_ (id observer, NSString aName, id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1name_1object_1, observer !is null ? observer.id : null, aName !is null ? aName.id : null,
+                anObject !is null ? anObject.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNotificationQueue.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNotificationQueue;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSNotification;
+import dwt.internal.cocoa.NSNotificationCenter;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSPostingStyle
+{
+    NSPostWhenIdle = 1,
+    NSPostASAP = 2,
+    NSPostNow = 3
+}
+
+alias NSPostingStyle.NSPostWhenIdle NSPostWhenIdle;
+alias NSPostingStyle.NSPostASAP NSPostASAP;
+alias NSPostingStyle.NSPostNow NSPostNow;
+
+public class NSNotificationQueue : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static id defaultQueue ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNotificationQueue, OS.sel_defaultQueue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void dequeueNotificationsMatching (NSNotification notification, NSUInteger coalesceMask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_dequeueNotificationsMatching_1coalesceMask_1, notification !is null ? notification.id : null, coalesceMask);
+    }
+
+    public void enqueueNotification_postingStyle_ (NSNotification notification, NSPostingStyle postingStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_enqueueNotification_1postingStyle_1, notification !is null ? notification.id : null, postingStyle);
+    }
+
+    public void enqueueNotification_postingStyle_coalesceMask_forModes_ (NSNotification notification, NSPostingStyle postingStyle, NSUInteger coalesceMask,
+            NSArray modes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_enqueueNotification_1postingStyle_1coalesceMask_1forModes_1, notification !is null ? notification.id : null,
+                postingStyle, coalesceMask, modes !is null ? modes.id : null);
+    }
+
+    public id initWithNotificationCenter (NSNotificationCenter notificationCenter)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithNotificationCenter_1, notificationCenter !is null ? notificationCenter.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNull.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNull;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNull : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSNull null_ ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNull, OS.sel_null);
+        return result !is null ? new NSNull(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNumber.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNumber;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSComparisonResult;
+import dwt.internal.cocoa.NSDecimal;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSValue;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSNumber : NSValue
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool boolValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_boolValue) !is null;
+    }
+
+    public byte charValue ()
+    {
+        return cast(byte) OS.objc_msgSend(this.id, OS.sel_charValue);
+    }
+
+    public NSComparisonResult compare (NSNumber otherNumber)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_compare_1, otherNumber !is null ? otherNumber.id : null);
+    }
+
+    public NSDecimal decimalValue ()
+    {
+        NSDecimal result = new NSDecimal();
+        OS.objc_msgSend_stret(result, this.id, OS.sel_decimalValue);
+        return result;
+    }
+
+    public NSString descriptionWithLocale (id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public double doubleValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+    }
+
+    public float floatValue ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatValue);
+    }
+
+    public id initWithBool (bool value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBool_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithChar (byte value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithChar_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithDouble (double value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDouble_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithFloat (float value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFloat_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithInt (int value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithInt_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithInteger (int value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithInteger_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithLong (int value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLong_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithLongLong (long value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLongLong_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithShort (short value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithShort_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithUnsignedChar (ubyte value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedChar_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithUnsignedInt (uint value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedInt_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithUnsignedInteger (uint value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedInteger_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithUnsignedLong (uint value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedLong_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithUnsignedLongLong (ulong value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedLongLong_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithUnsignedShort (ushort value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedShort_1, value);
+        return result !is null ? new id(result) : null;
+    }
+
+    public int intValue ()
+    {
+        return cast(int)OS.objc_msgSend(this.id, OS.sel_intValue);
+    }
+
+    public int integerValue ()
+    {
+        return cast(int)OS.objc_msgSend(this.id, OS.sel_integerValue);
+    }
+
+    public bool isEqualToNumber (NSNumber number)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToNumber_1, number !is null ? number.id : null) !is null;
+    }
+
+    public long longLongValue ()
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_longLongValue);
+    }
+
+    public int longValue ()
+    {
+        return cast(int)OS.objc_msgSend(this.id, OS.sel_longValue);
+    }
+
+    public static NSNumber numberWithBool (bool value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithBool_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithChar (byte value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithChar_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithDouble (double value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithDouble_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithFloat (float value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithFloat_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithInt (int value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInt_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithInteger (int value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInteger_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithLong (int value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithLong_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithLongLong (long value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithLongLong_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithShort (short value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithShort_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithUnsignedChar (ubyte value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedChar_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithUnsignedInt (uint value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedInt_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithUnsignedInteger (uint value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedInteger_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithUnsignedLong (uint value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedLong_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithUnsignedLongLong (ulong value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedLongLong_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public static NSNumber numberWithUnsignedShort (ushort value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedShort_1, value);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public short shortValue ()
+    {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_shortValue);
+    }
+
+    public NSString stringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringValue);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public ubyte unsignedCharValue ()
+    {
+        return cast(ubyte) OS.objc_msgSend(this.id, OS.sel_unsignedCharValue);
+    }
+
+    public uint unsignedIntValue ()
+    {
+        return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedIntValue);
+    }
+
+    public uint unsignedIntegerValue ()
+    {
+        return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedIntegerValue);
+    }
+
+    public ulong unsignedLongLongValue ()
+    {
+        return cast(ulong) OS.objc_msgSend(this.id, OS.sel_unsignedLongLongValue);
+    }
+
+    public uint unsignedLongValue ()
+    {
+        return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedLongValue);
+    }
+
+    public ushort unsignedShortValue ()
+    {
+        return cast(ushort) OS.objc_msgSend(this.id, OS.sel_unsignedShortValue);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSNumberFormatter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,793 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSNumberFormatter;
+
+import dwt.internal.cocoa.CFNumberFormatter;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSDecimalNumberHandler;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSFormatter;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSLocale;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSNumberFormatterBehavior
+{
+    NSNumberFormatterBehaviorDefault = 0,
+    NSNumberFormatterBehavior10_0 = 1000,
+    NSNumberFormatterBehavior10_4 = 1040,
+}
+
+alias NSNumberFormatterBehavior.NSNumberFormatterBehaviorDefault NSNumberFormatterBehaviorDefault;
+alias NSNumberFormatterBehavior.NSNumberFormatterBehavior10_0 NSNumberFormatterBehavior10_0;
+alias NSNumberFormatterBehavior.NSNumberFormatterBehavior10_4 NSNumberFormatterBehavior10_4;
+
+enum NSNumberFormatterPadPosition
+{
+    NSNumberFormatterPadBeforePrefix = kCFNumberFormatterPadBeforePrefix,
+    NSNumberFormatterPadAfterPrefix = kCFNumberFormatterPadAfterPrefix,
+    NSNumberFormatterPadBeforeSuffix = kCFNumberFormatterPadBeforeSuffix,
+    NSNumberFormatterPadAfterSuffix = kCFNumberFormatterPadAfterSuffix
+}
+
+NSNumberFormatterPadPosition.NSNumberFormatterPadBeforePrefix NSNumberFormatterPadBeforePrefix;
+NSNumberFormatterPadPosition.NSNumberFormatterPadAfterPrefix NSNumberFormatterPadAfterPrefix;
+NSNumberFormatterPadPosition.NSNumberFormatterPadBeforeSuffix NSNumberFormatterPadBeforeSuffix;
+NSNumberFormatterPadPosition.NSNumberFormatterPadAfterSuffix NSNumberFormatterPadAfterSuffix;
+
+enum NSNumberFormatterRoundingMode
+{
+    NSNumberFormatterRoundCeiling = kCFNumberFormatterRoundCeiling,
+    NSNumberFormatterRoundFloor = kCFNumberFormatterRoundFloor,
+    NSNumberFormatterRoundDown = kCFNumberFormatterRoundDown,
+    NSNumberFormatterRoundUp = kCFNumberFormatterRoundUp,
+    NSNumberFormatterRoundHalfEven = kCFNumberFormatterRoundHalfEven,
+    NSNumberFormatterRoundHalfDown = kCFNumberFormatterRoundHalfDown,
+    NSNumberFormatterRoundHalfUp = kCFNumberFormatterRoundHalfUp
+}
+
+alias NSNumberFormatterRoundingMode.NSNumberFormatterRoundCeiling NSNumberFormatterRoundCeiling;
+alias NSNumberFormatterRoundingMode.NSNumberFormatterRoundFloor NSNumberFormatterRoundFloor;
+alias NSNumberFormatterRoundingMode.NSNumberFormatterRoundDown NSNumberFormatterRoundDown;
+alias NSNumberFormatterRoundingMode.NSNumberFormatterRoundUp NSNumberFormatterRoundUp;
+alias NSNumberFormatterRoundingMode.NSNumberFormatterRoundHalfEven NSNumberFormatterRoundHalfEven;
+alias NSNumberFormatterRoundingMode.NSNumberFormatterRoundHalfDown NSNumberFormatterRoundCeiling;
+alias NSNumberFormatterRoundingMode.NSNumberFormatterRoundHalfUp NSNumberFormatterRoundHalfUp;
+
+public class NSNumberFormatter : NSFormatter
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool allowsFloats ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsFloats) !is null;
+    }
+
+    public bool alwaysShowsDecimalSeparator ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_alwaysShowsDecimalSeparator) !is null;
+    }
+
+    public NSAttributedString attributedStringForNil ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedStringForNil);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSAttributedString attributedStringForNotANumber ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedStringForNotANumber);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSAttributedString attributedStringForZero ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedStringForZero);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSString currencyCode ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currencyCode);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString currencyDecimalSeparator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currencyDecimalSeparator);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString currencyGroupingSeparator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currencyGroupingSeparator);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString currencySymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currencySymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString decimalSeparator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalSeparator);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSNumberFormatterBehavior defaultFormatterBehavior ()
+    {
+        return cast(NSNumberFormatterBehavior) OS.objc_msgSend(OS.class_NSNumberFormatter, OS.sel_defaultFormatterBehavior);
+    }
+
+    public NSString exponentSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_exponentSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString format ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_format);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger formatWidth ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_formatWidth);
+    }
+
+    public NSNumberFormatterBehavior formatterBehavior ()
+    {
+        return cast(NSNumberFormatterBehavior) OS.objc_msgSend(this.id, OS.sel_formatterBehavior);
+    }
+
+    public bool generatesDecimalNumbers ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_generatesDecimalNumbers) !is null;
+    }
+
+    public bool getObjectValue (/*out*/objc.id* obj, NSString str, /*inout NSRange* */objc.id* rangep, /*out NSError** */objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getObjectValue_1forString_1range_1error_1, obj, str !is null ? str.id : null, rangep, error) !is null;
+    }
+
+    public NSString groupingSeparator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_groupingSeparator);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger groupingSize ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_groupingSize);
+    }
+
+    public bool hasThousandSeparators ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasThousandSeparators) !is null;
+    }
+
+    public NSString internationalCurrencySymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_internationalCurrencySymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool isLenient ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLenient) !is null;
+    }
+
+    public bool isPartialStringValidationEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isPartialStringValidationEnabled) !is null;
+    }
+
+    public NSLocale locale ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_locale);
+        return result !is null ? new NSLocale(result) : null;
+    }
+
+    public bool localizesFormat ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_localizesFormat) !is null;
+    }
+
+    public NSNumber maximum ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_maximum);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public NSUInteger maximumFractionDigits ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_maximumFractionDigits);
+    }
+
+    public NSUInteger maximumIntegerDigits ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_maximumIntegerDigits);
+    }
+
+    public NSUInteger maximumSignificantDigits ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_maximumSignificantDigits);
+    }
+
+    public NSNumber minimum ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_minimum);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public NSUInteger minimumFractionDigits ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_minimumFractionDigits);
+    }
+
+    public NSUInteger minimumIntegerDigits ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_minimumIntegerDigits);
+    }
+
+    public NSUInteger minimumSignificantDigits ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_minimumSignificantDigits);
+    }
+
+    public NSString minusSign ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_minusSign);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSNumber multiplier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_multiplier);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public NSString negativeFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_negativeFormat);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString negativeInfinitySymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_negativeInfinitySymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString negativePrefix ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_negativePrefix);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString negativeSuffix ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_negativeSuffix);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString nilSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nilSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString notANumberSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_notANumberSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSNumber numberFromString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_numberFromString_1, string !is null ? string.id : null);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public NSNumberFormatterStyle numberStyle ()
+    {
+        return cast(NSNumberFormatterStyle) OS.objc_msgSend(this.id, OS.sel_numberStyle);
+    }
+
+    public NSString paddingCharacter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_paddingCharacter);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSNumberFormatterPadPosition paddingPosition ()
+    {
+        return cast(NSNumberFormatterPadPosition) OS.objc_msgSend(this.id, OS.sel_paddingPosition);
+    }
+
+    public NSString perMillSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_perMillSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString percentSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_percentSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString plusSign ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_plusSign);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString positiveFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_positiveFormat);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString positiveInfinitySymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_positiveInfinitySymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString positivePrefix ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_positivePrefix);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString positiveSuffix ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_positiveSuffix);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDecimalNumberHandler roundingBehavior ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_roundingBehavior);
+        return result !is null ? new NSDecimalNumberHandler(result) : null;
+    }
+
+    public NSNumber roundingIncrement ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_roundingIncrement);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public NSNumberFormatterRoundingMode roundingMode ()
+    {
+        return cast(NSNumberFormatterRoundingMode) OS.objc_msgSend(this.id, OS.sel_roundingMode);
+    }
+
+    public NSUInteger secondaryGroupingSize ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_secondaryGroupingSize);
+    }
+
+    public void setAllowsFloats (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsFloats_1, flag);
+    }
+
+    public void setAlwaysShowsDecimalSeparator (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlwaysShowsDecimalSeparator_1, b);
+    }
+
+    public void setAttributedStringForNil (NSAttributedString newAttributedString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedStringForNil_1, newAttributedString !is null ? newAttributedString.id : null);
+    }
+
+    public void setAttributedStringForNotANumber (NSAttributedString newAttributedString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedStringForNotANumber_1, newAttributedString !is null ? newAttributedString.id : null);
+    }
+
+    public void setAttributedStringForZero (NSAttributedString newAttributedString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedStringForZero_1, newAttributedString !is null ? newAttributedString.id : null);
+    }
+
+    public void setCurrencyCode (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrencyCode_1, string !is null ? string.id : null);
+    }
+
+    public void setCurrencyDecimalSeparator (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrencyDecimalSeparator_1, string !is null ? string.id : null);
+    }
+
+    public void setCurrencyGroupingSeparator (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrencyGroupingSeparator_1, string !is null ? string.id : null);
+    }
+
+    public void setCurrencySymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrencySymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setDecimalSeparator (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDecimalSeparator_1, string !is null ? string.id : null);
+    }
+
+    public static void setDefaultFormatterBehavior (NSNumberFormatterBehavior behavior)
+    {
+        OS.objc_msgSend(OS.class_NSNumberFormatter, OS.sel_setDefaultFormatterBehavior_1, behavior);
+    }
+
+    public void setExponentSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setExponentSymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setFormat (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormat_1, string !is null ? string.id : null);
+    }
+
+    public void setFormatWidth (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormatWidth_1, number);
+    }
+
+    public void setFormatterBehavior (NSNumberFormatterBehavior behavior)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormatterBehavior_1, behavior);
+    }
+
+    public void setGeneratesDecimalNumbers (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGeneratesDecimalNumbers_1, b);
+    }
+
+    public void setGroupingSeparator (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGroupingSeparator_1, string !is null ? string.id : null);
+    }
+
+    public void setGroupingSize (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGroupingSize_1, number);
+    }
+
+    public void setHasThousandSeparators (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasThousandSeparators_1, flag);
+    }
+
+    public void setInternationalCurrencySymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInternationalCurrencySymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setLenient (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLenient_1, b);
+    }
+
+    public void setLocale (NSLocale locale)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocale_1, locale !is null ? locale.id : null);
+    }
+
+    public void setLocalizesFormat (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocalizesFormat_1, flag);
+    }
+
+    public void setMaximum (NSNumber number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaximum_1, number !is null ? number.id : null);
+    }
+
+    public void setMaximumFractionDigits (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaximumFractionDigits_1, number);
+    }
+
+    public void setMaximumIntegerDigits (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaximumIntegerDigits_1, number);
+    }
+
+    public void setMaximumSignificantDigits (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaximumSignificantDigits_1, number);
+    }
+
+    public void setMinimum (NSNumber number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinimum_1, number !is null ? number.id : null);
+    }
+
+    public void setMinimumFractionDigits (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinimumFractionDigits_1, number);
+    }
+
+    public void setMinimumIntegerDigits (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinimumIntegerDigits_1, number);
+    }
+
+    public void setMinimumSignificantDigits (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinimumSignificantDigits_1, number);
+    }
+
+    public void setMinusSign (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinusSign_1, string !is null ? string.id : null);
+    }
+
+    public void setMultiplier (NSNumber number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMultiplier_1, number !is null ? number.id : null);
+    }
+
+    public void setNegativeFormat (NSString format)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNegativeFormat_1, format !is null ? format.id : null);
+    }
+
+    public void setNegativeInfinitySymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNegativeInfinitySymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setNegativePrefix (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNegativePrefix_1, string !is null ? string.id : null);
+    }
+
+    public void setNegativeSuffix (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNegativeSuffix_1, string !is null ? string.id : null);
+    }
+
+    public void setNilSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNilSymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setNotANumberSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNotANumberSymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setNumberStyle (NSNumberFormatterStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberStyle_1, style);
+    }
+
+    public void setPaddingCharacter (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPaddingCharacter_1, string !is null ? string.id : null);
+    }
+
+    public void setPaddingPosition (NSNumberFormatterPadPosition position)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPaddingPosition_1, position);
+    }
+
+    public void setPartialStringValidationEnabled (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPartialStringValidationEnabled_1, b);
+    }
+
+    public void setPerMillSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPerMillSymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setPercentSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPercentSymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setPlusSign (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlusSign_1, string !is null ? string.id : null);
+    }
+
+    public void setPositiveFormat (NSString format)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPositiveFormat_1, format !is null ? format.id : null);
+    }
+
+    public void setPositiveInfinitySymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPositiveInfinitySymbol_1, string !is null ? string.id : null);
+    }
+
+    public void setPositivePrefix (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPositivePrefix_1, string !is null ? string.id : null);
+    }
+
+    public void setPositiveSuffix (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPositiveSuffix_1, string !is null ? string.id : null);
+    }
+
+    public void setRoundingBehavior (NSDecimalNumberHandler newRoundingBehavior)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRoundingBehavior_1, newRoundingBehavior !is null ? newRoundingBehavior.id : null);
+    }
+
+    public void setRoundingIncrement (NSNumber number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRoundingIncrement_1, number !is null ? number.id : null);
+    }
+
+    public void setRoundingMode (NSNumberFormatterRoundingMode mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRoundingMode_1, mode);
+    }
+
+    public void setSecondaryGroupingSize (NSUInteger number)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSecondaryGroupingSize_1, number);
+    }
+
+    public void setTextAttributesForNegativeInfinity (NSDictionary newAttributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAttributesForNegativeInfinity_1, newAttributes !is null ? newAttributes.id : null);
+    }
+
+    public void setTextAttributesForNegativeValues (NSDictionary newAttributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAttributesForNegativeValues_1, newAttributes !is null ? newAttributes.id : null);
+    }
+
+    public void setTextAttributesForNil (NSDictionary newAttributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAttributesForNil_1, newAttributes !is null ? newAttributes.id : null);
+    }
+
+    public void setTextAttributesForNotANumber (NSDictionary newAttributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAttributesForNotANumber_1, newAttributes !is null ? newAttributes.id : null);
+    }
+
+    public void setTextAttributesForPositiveInfinity (NSDictionary newAttributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAttributesForPositiveInfinity_1, newAttributes !is null ? newAttributes.id : null);
+    }
+
+    public void setTextAttributesForPositiveValues (NSDictionary newAttributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAttributesForPositiveValues_1, newAttributes !is null ? newAttributes.id : null);
+    }
+
+    public void setTextAttributesForZero (NSDictionary newAttributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextAttributesForZero_1, newAttributes !is null ? newAttributes.id : null);
+    }
+
+    public void setThousandSeparator (NSString newSeparator)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setThousandSeparator_1, newSeparator !is null ? newSeparator.id : null);
+    }
+
+    public void setUsesGroupingSeparator (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesGroupingSeparator_1, b);
+    }
+
+    public void setUsesSignificantDigits (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesSignificantDigits_1, b);
+    }
+
+    public void setZeroSymbol (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setZeroSymbol_1, string !is null ? string.id : null);
+    }
+
+    public NSString stringFromNumber (NSNumber number)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringFromNumber_1, number !is null ? number.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary textAttributesForNegativeInfinity ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textAttributesForNegativeInfinity);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary textAttributesForNegativeValues ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textAttributesForNegativeValues);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary textAttributesForNil ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textAttributesForNil);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary textAttributesForNotANumber ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textAttributesForNotANumber);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary textAttributesForPositiveInfinity ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textAttributesForPositiveInfinity);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary textAttributesForPositiveValues ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textAttributesForPositiveValues);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary textAttributesForZero ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textAttributesForZero);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString thousandSeparator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_thousandSeparator);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool usesGroupingSeparator ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesGroupingSeparator) !is null;
+    }
+
+    public bool usesSignificantDigits ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesSignificantDigits) !is null;
+    }
+
+    public NSString zeroSymbol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_zeroSymbol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSObject.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1625 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSObject;
+
+import dwt.dwthelper.utils;
+import dwt.internal.c.carboncore.MacTypes : FourCharCode;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArchiver;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCachedURLResponse;
+import dwt.internal.cocoa.NSClassDescription;
+import dwt.internal.cocoa.NSCoder;
+import dwt.internal.cocoa.NSConnection;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSDecimal;
+import dwt.internal.cocoa.NSDecimalNumber;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSDistantObjectRequest;
+import dwt.internal.cocoa.NSEnumerator : NSFastEnumerationState;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSFileManager;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSInvocation;
+import dwt.internal.cocoa.NSKeyedArchiver;
+import dwt.internal.cocoa.NSKeyedUnarchiver;
+import dwt.internal.cocoa.NSKeyValueObserving;
+import dwt.internal.cocoa.NSMetadataItem;
+import dwt.internal.cocoa.NSMetadataQuery;
+import dwt.internal.cocoa.NSMethodSignature;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSMutableSet;
+import dwt.internal.cocoa.NSNetService;
+import dwt.internal.cocoa.NSNetServiceBrowser;
+import dwt.internal.cocoa.NSPortCoder;
+import dwt.internal.cocoa.NSPortMessage;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSSet;
+import dwt.internal.cocoa.NSSpellServer;
+import dwt.internal.cocoa.NSStream;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSThread;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSURLAuthenticationChallenge;
+import dwt.internal.cocoa.NSURLCache : NSURLCacheStoragePolicy;
+import dwt.internal.cocoa.NSURLConnection;
+import dwt.internal.cocoa.NSURLCredential;
+import dwt.internal.cocoa.NSURLDownload;
+import dwt.internal.cocoa.NSURLHandle;
+import dwt.internal.cocoa.NSURLProtocol;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.NSURLResponse;
+import dwt.internal.cocoa.NSXMLParser;
+import dwt.internal.cocoa.NSZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSObject : id
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void URL_resourceDataDidBecomeAvailable_ (NSURL sender, NSData newBytes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URL_1resourceDataDidBecomeAvailable_1, sender !is null ? sender.id : null,
+                newBytes !is null ? newBytes.id : null);
+    }
+
+    public void URL_resourceDidFailLoadingWithReason_ (NSURL sender, NSString reason)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URL_1resourceDidFailLoadingWithReason_1, sender !is null ? sender.id : null,
+                reason !is null ? reason.id : null);
+    }
+
+    public void URLHandle_resourceDataDidBecomeAvailable_ (NSURLHandle sender, NSData newBytes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLHandle_1resourceDataDidBecomeAvailable_1, sender !is null ? sender.id : null,
+                newBytes !is null ? newBytes.id : null);
+    }
+
+    public void URLHandle_resourceDidFailLoadingWithReason_ (NSURLHandle sender, NSString reason)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLHandle_1resourceDidFailLoadingWithReason_1, sender !is null ? sender.id : null,
+                reason !is null ? reason.id : null);
+    }
+
+    public void URLHandleResourceDidBeginLoading (NSURLHandle sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLHandleResourceDidBeginLoading_1, sender !is null ? sender.id : null);
+    }
+
+    public void URLHandleResourceDidCancelLoading (NSURLHandle sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLHandleResourceDidCancelLoading_1, sender !is null ? sender.id : null);
+    }
+
+    public void URLHandleResourceDidFinishLoading (NSURLHandle sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLHandleResourceDidFinishLoading_1, sender !is null ? sender.id : null);
+    }
+
+    public void URLProtocol_cachedResponseIsValid_ (NSURLProtocol protocol, NSCachedURLResponse cachedResponse)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocol_1cachedResponseIsValid_1, protocol !is null ? protocol.id : null,
+                cachedResponse !is null ? cachedResponse.id : null);
+    }
+
+    public void URLProtocol_didCancelAuthenticationChallenge_ (NSURLProtocol protocol, NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocol_1didCancelAuthenticationChallenge_1, protocol !is null ? protocol.id : null,
+                challenge !is null ? challenge.id : null);
+    }
+
+    public void URLProtocol_didFailWithError_ (NSURLProtocol protocol, NSError error)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocol_1didFailWithError_1, protocol !is null ? protocol.id : null, error !is null ? error.id : null);
+    }
+
+    public void URLProtocol_didLoadData_ (NSURLProtocol protocol, NSData data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocol_1didLoadData_1, protocol !is null ? protocol.id : null, data !is null ? data.id : null);
+    }
+
+    public void URLProtocol_didReceiveAuthenticationChallenge_ (NSURLProtocol protocol, NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocol_1didReceiveAuthenticationChallenge_1, protocol !is null ? protocol.id : null,
+                challenge !is null ? challenge.id : null);
+    }
+
+    public void URLProtocol_didReceiveResponse_cacheStoragePolicy_ (NSURLProtocol protocol, NSURLResponse response, NSURLCacheStoragePolicy policy)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocol_1didReceiveResponse_1cacheStoragePolicy_1, protocol !is null ? protocol.id : null,
+                response !is null ? response.id : null, policy);
+    }
+
+    public void URLProtocol_wasRedirectedToRequest_redirectResponse_ (NSURLProtocol protocol, NSURLRequest request, NSURLResponse redirectResponse)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocol_1wasRedirectedToRequest_1redirectResponse_1, protocol !is null ? protocol.id : null,
+                request !is null ? request.id : null, redirectResponse !is null ? redirectResponse.id : null);
+    }
+
+    public void URLProtocolDidFinishLoading (NSURLProtocol protocol)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLProtocolDidFinishLoading_1, protocol !is null ? protocol.id : null);
+    }
+
+    public void URLResourceDidCancelLoading (NSURL sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLResourceDidCancelLoading_1, sender !is null ? sender.id : null);
+    }
+
+    public void URLResourceDidFinishLoading (NSURL sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_URLResourceDidFinishLoading_1, sender !is null ? sender.id : null);
+    }
+
+    public static bool accessInstanceVariablesDirectly ()
+    {
+        return OS.objc_msgSend(OS.class_NSObject, OS.sel_accessInstanceVariablesDirectly) !is null;
+    }
+
+    public void addObserver (NSObject observer, NSString keyPath, NSKeyValueObservingOptions options, void* context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
+                keyPath !is null ? keyPath.id : null, options, context);
+    }
+
+    public NSObject alloc ()
+    {
+        objc.id result = OS.objc_msgSend(cast(objc.id)get_class(), OS.sel_alloc);
+        this.id = result;
+        return result !is null ? this : null;
+    }
+
+    public objc.Class get_class ()
+    {
+        String name = this.classinfo.name;
+        int index = name.lastIndexOf('.');
+        if (index != -1)
+            name = name.substring(index + 1);
+        return cast(objc.Class)OS.objc_getClass(name);
+    }
+
+    public static id allocWithZone (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_allocWithZone_1, zone);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void archiver_didEncodeObject_ (NSKeyedArchiver archiver, id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_archiver_1didEncodeObject_1, archiver !is null ? archiver.id : null, object !is null ? object.id : null);
+    }
+
+    public id archiver_willEncodeObject_ (NSKeyedArchiver archiver, id object)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_archiver_1willEncodeObject_1, archiver !is null ? archiver.id : null,
+                object !is null ? object.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void archiver_willReplaceObject_withObject_ (NSKeyedArchiver archiver, id object, id newObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_archiver_1willReplaceObject_1withObject_1, archiver !is null ? archiver.id : null,
+                object !is null ? object.id : null, newObject !is null ? newObject.id : null);
+    }
+
+    public void archiverDidFinish (NSKeyedArchiver archiver)
+    {
+        OS.objc_msgSend(this.id, OS.sel_archiverDidFinish_1, archiver !is null ? archiver.id : null);
+    }
+
+    public void archiverWillFinish (NSKeyedArchiver archiver)
+    {
+        OS.objc_msgSend(this.id, OS.sel_archiverWillFinish_1, archiver !is null ? archiver.id : null);
+    }
+
+    public bool attemptRecoveryFromError_optionIndex_ (NSError error, NSUInteger recoveryOptionIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_attemptRecoveryFromError_1optionIndex_1, error !is null ? error.id : null, recoveryOptionIndex) !is null;
+    }
+
+    public void attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo_ (NSError error, NSUInteger recoveryOptionIndex, id delegatee,
+            objc.SEL didRecoverSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_attemptRecoveryFromError_1optionIndex_1delegate_1didRecoverSelector_1contextInfo_1,
+                error !is null ? error.id : null, recoveryOptionIndex, delegatee !is null ? delegatee.id : null, didRecoverSelector, contextInfo);
+    }
+
+    public NSArray attributeKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributeKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool authenticateComponents (NSArray components, NSData signature)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_authenticateComponents_1withData_1, components !is null ? components.id : null,
+                signature !is null ? signature.id : null) !is null;
+    }
+
+    public NSData authenticationDataForComponents (NSArray components)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_authenticationDataForComponents_1, components !is null ? components.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public static bool automaticallyNotifiesObserversForKey (NSString key)
+    {
+        return OS.objc_msgSend(OS.class_NSObject, OS.sel_automaticallyNotifiesObserversForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public id autorelease ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_autorelease);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id awakeAfterUsingCoder (NSCoder aDecoder)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_awakeAfterUsingCoder_1, aDecoder !is null ? aDecoder.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void cancelAuthenticationChallenge (NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelAuthenticationChallenge_1, challenge !is null ? challenge.id : null);
+    }
+
+    public static void static_cancelPreviousPerformRequestsWithTarget_ (id aTarget)
+    {
+        OS.objc_msgSend(OS.class_NSObject, OS.sel_cancelPreviousPerformRequestsWithTarget_1, aTarget !is null ? aTarget.id : null);
+    }
+
+    public static void static_cancelPreviousPerformRequestsWithTarget_selector_object_ (id aTarget, objc.SEL aSelector, id anArgument)
+    {
+        OS.objc_msgSend(OS.class_NSObject, OS.sel_cancelPreviousPerformRequestsWithTarget_1selector_1object_1, aTarget !is null ? aTarget.id : null,
+                aSelector, anArgument !is null ? anArgument.id : null);
+    }
+
+    public static objc.Class static_class ()
+    {
+        return cast(objc.Class)OS.objc_msgSend(OS.class_NSObject, OS.sel_class);
+    }
+
+    //public objc.Class class() {
+    //  return OS.objc_msgSend(this.id, OS.sel_class);
+    //}
+
+    public FourCharCode classCode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_classCode);
+    }
+
+    public NSClassDescription classDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_classDescription);
+        return result !is null ? new NSClassDescription(result) : null;
+    }
+
+    public static NSArray classFallbacksForKeyedArchiver ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_classFallbacksForKeyedArchiver);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public objc.Class classForArchiver ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_classForArchiver);
+    }
+
+    public objc.Class classForCoder ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_classForCoder);
+    }
+
+    public objc.Class classForKeyedArchiver ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_classForKeyedArchiver);
+    }
+
+    public static objc.Class classForKeyedUnarchiver ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(OS.class_NSObject, OS.sel_classForKeyedUnarchiver);
+    }
+
+    public objc.Class  classForPortCoder ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_classForPortCoder);
+    }
+
+    public NSString className ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_className);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id coerceValue (id value, NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_coerceValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    //public bool conformsToProtocol_(Protocol aProtocol) {
+    //  return OS.objc_msgSend(this.id, OS.sel_conformsToProtocol_1, aProtocol !is null ? aProtocol.id : null) !is null;
+    //}
+    //
+    //public static bool static_conformsToProtocol_(Protocol protocol) {
+    //  return OS.objc_msgSend(OS.class_NSObject, OS.sel_conformsToProtocol_1, protocol !is null ? protocol.id : null) !is null;
+    //}
+
+    public void connection_didCancelAuthenticationChallenge_ (NSURLConnection connection, NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_connection_1didCancelAuthenticationChallenge_1, connection !is null ? connection.id : null,
+                challenge !is null ? challenge.id : null);
+    }
+
+    public void connection_didFailWithError_ (NSURLConnection connection, NSError error)
+    {
+        OS.objc_msgSend(this.id, OS.sel_connection_1didFailWithError_1, connection !is null ? connection.id : null, error !is null ? error.id : null);
+    }
+
+    public void connection_didReceiveAuthenticationChallenge_ (NSURLConnection connection, NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_connection_1didReceiveAuthenticationChallenge_1, connection !is null ? connection.id : null,
+                challenge !is null ? challenge.id : null);
+    }
+
+    public void connection_didReceiveData_ (NSURLConnection connection, NSData data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_connection_1didReceiveData_1, connection !is null ? connection.id : null, data !is null ? data.id : null);
+    }
+
+    public void connection_didReceiveResponse_ (NSURLConnection connection, NSURLResponse response)
+    {
+        OS.objc_msgSend(this.id, OS.sel_connection_1didReceiveResponse_1, connection !is null ? connection.id : null,
+                response !is null ? response.id : null);
+    }
+
+    public bool connection_handleRequest_ (NSConnection connection, NSDistantObjectRequest doreq)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_connection_1handleRequest_1, connection !is null ? connection.id : null,
+                doreq !is null ? doreq.id : null) !is null;
+    }
+
+    public bool connection_shouldMakeNewConnection_ (NSConnection ancestor, NSConnection conn)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_connection_1shouldMakeNewConnection_1, ancestor !is null ? ancestor.id : null,
+                conn !is null ? conn.id : null) !is null;
+    }
+
+    public NSCachedURLResponse connection_willCacheResponse_ (NSURLConnection connection, NSCachedURLResponse cachedResponse)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_connection_1willCacheResponse_1, connection !is null ? connection.id : null,
+                cachedResponse !is null ? cachedResponse.id : null);
+        return result !is null ? new NSCachedURLResponse(result) : null;
+    }
+
+    public NSURLRequest connection_willSendRequest_redirectResponse_ (NSURLConnection connection, NSURLRequest request, NSURLResponse response)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_connection_1willSendRequest_1redirectResponse_1, connection !is null ? connection.id : null,
+                request !is null ? request.id : null, response !is null ? response.id : null);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public void connectionDidFinishLoading (NSURLConnection connection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_connectionDidFinishLoading_1, connection !is null ? connection.id : null);
+    }
+
+    public void continueWithoutCredentialForAuthenticationChallenge (NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_continueWithoutCredentialForAuthenticationChallenge_1, challenge !is null ? challenge.id : null);
+    }
+
+    public id copy ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_copy);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id copyScriptingValue (id value, NSString key, NSDictionary properties)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_copyScriptingValue_1forKey_1withProperties_1, value !is null ? value.id : null,
+                key !is null ? key.id : null, properties !is null ? properties.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id copyWithZone_ (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_copyWithZone_1, zone);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_copyWithZone_ (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_copyWithZone_1, zone);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, objc.id* stackbuf, NSUInteger len)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_countByEnumeratingWithState_1objects_1count_1, state, stackbuf, len);
+    }
+
+    public id createConversationForConnection (NSConnection conn)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_createConversationForConnection_1, conn !is null ? conn.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void dealloc ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_dealloc);
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString static_description ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary dictionaryWithValuesForKeys (NSArray keys)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dictionaryWithValuesForKeys_1, keys !is null ? keys.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void didChange (NSKeyValueChange changeKind, NSIndexSet indexes, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_didChange_1valuesAtIndexes_1forKey_1, changeKind, indexes !is null ? indexes.id : null,
+                key !is null ? key.id : null);
+    }
+
+    public void didChangeValueForKey_ (NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_didChangeValueForKey_1, key !is null ? key.id : null);
+    }
+
+    public void didChangeValueForKey_withSetMutation_usingObjects_ (NSString key, NSKeyValueSetMutationKind mutationKind, NSSet objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_didChangeValueForKey_1withSetMutation_1usingObjects_1, key !is null ? key.id : null, mutationKind,
+                objects !is null ? objects.id : null);
+    }
+
+    public bool doesContain (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_doesContain_1, object !is null ? object.id : null) !is null;
+    }
+
+    public void doesNotRecognizeSelector (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_doesNotRecognizeSelector_1, aSelector);
+    }
+
+    public void download_decideDestinationWithSuggestedFilename_ (NSURLDownload download, NSString filename)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1decideDestinationWithSuggestedFilename_1, download !is null ? download.id : null,
+                filename !is null ? filename.id : null);
+    }
+
+    public void download_didCancelAuthenticationChallenge_ (NSURLDownload download, NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1didCancelAuthenticationChallenge_1, download !is null ? download.id : null,
+                challenge !is null ? challenge.id : null);
+    }
+
+    public void download_didCreateDestination_ (NSURLDownload download, NSString path)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1didCreateDestination_1, download !is null ? download.id : null, path !is null ? path.id : null);
+    }
+
+    public void download_didFailWithError_ (NSURLDownload download, NSError error)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1didFailWithError_1, download !is null ? download.id : null, error !is null ? error.id : null);
+    }
+
+    public void download_didReceiveAuthenticationChallenge_ (NSURLDownload download, NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1didReceiveAuthenticationChallenge_1, download !is null ? download.id : null,
+                challenge !is null ? challenge.id : null);
+    }
+
+    public void download_didReceiveDataOfLength_ (NSURLDownload download, NSUInteger length)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1didReceiveDataOfLength_1, download !is null ? download.id : null, length);
+    }
+
+    public void download_didReceiveResponse_ (NSURLDownload download, NSURLResponse response)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1didReceiveResponse_1, download !is null ? download.id : null,
+                response !is null ? response.id : null);
+    }
+
+    public bool download_shouldDecodeSourceDataOfMIMEType_ (NSURLDownload download, NSString encodingType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_download_1shouldDecodeSourceDataOfMIMEType_1, download !is null ? download.id : null,
+                encodingType !is null ? encodingType.id : null) !is null;
+    }
+
+    public void download_willResumeWithResponse_fromByte_ (NSURLDownload download, NSURLResponse response, long startingByte)
+    {
+        OS.objc_msgSend(this.id, OS.sel_download_1willResumeWithResponse_1fromByte_1, download !is null ? download.id : null,
+                response !is null ? response.id : null, startingByte);
+    }
+
+    public NSURLRequest download_willSendRequest_redirectResponse_ (NSURLDownload download, NSURLRequest request, NSURLResponse redirectResponse)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_download_1willSendRequest_1redirectResponse_1, download !is null ? download.id : null,
+                request !is null ? request.id : null, redirectResponse !is null ? redirectResponse.id : null);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public void downloadDidBegin (NSURLDownload download)
+    {
+        OS.objc_msgSend(this.id, OS.sel_downloadDidBegin_1, download !is null ? download.id : null);
+    }
+
+    public void downloadDidFinish (NSURLDownload download)
+    {
+        OS.objc_msgSend(this.id, OS.sel_downloadDidFinish_1, download !is null ? download.id : null);
+    }
+
+    public void encodeWithCoder (NSCoder aCoder)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodeWithCoder_1, aCoder !is null ? aCoder.id : null);
+    }
+
+    public NSDecimalNumber exceptionDuringOperation (objc.SEL operation, NSCalculationError error, NSDecimalNumber leftOperand, NSDecimalNumber rightOperand)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_exceptionDuringOperation_1error_1leftOperand_1rightOperand_1, operation, error,
+                leftOperand !is null ? leftOperand.id : null, rightOperand !is null ? rightOperand.id : null);
+        return result !is null ? new NSDecimalNumber(result) : null;
+    }
+
+    public bool fileManager_shouldCopyItemAtPath_toPath_ (NSFileManager fileManager, NSString srcPath, NSString dstPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldCopyItemAtPath_1toPath_1, fileManager !is null ? fileManager.id : null,
+                srcPath !is null ? srcPath.id : null, dstPath !is null ? dstPath.id : null) !is null;
+    }
+
+    public bool fileManager_shouldLinkItemAtPath_toPath_ (NSFileManager fileManager, NSString srcPath, NSString dstPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldLinkItemAtPath_1toPath_1, fileManager !is null ? fileManager.id : null,
+                srcPath !is null ? srcPath.id : null, dstPath !is null ? dstPath.id : null) !is null;
+    }
+
+    public bool fileManager_shouldMoveItemAtPath_toPath_ (NSFileManager fileManager, NSString srcPath, NSString dstPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldMoveItemAtPath_1toPath_1, fileManager !is null ? fileManager.id : null,
+                srcPath !is null ? srcPath.id : null, dstPath !is null ? dstPath.id : null) !is null;
+    }
+
+    public bool fileManager_shouldProceedAfterError_ (NSFileManager fm, NSDictionary errorInfo)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldProceedAfterError_1, fm !is null ? fm.id : null,
+                errorInfo !is null ? errorInfo.id : null) !is null;
+    }
+
+    public bool fileManager_shouldProceedAfterError_copyingItemAtPath_toPath_ (NSFileManager fileManager, NSError error, NSString srcPath,
+            NSString dstPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldProceedAfterError_1copyingItemAtPath_1toPath_1,
+                fileManager !is null ? fileManager.id : null, error !is null ? error.id : null, srcPath !is null ? srcPath.id : null,
+                dstPath !is null ? dstPath.id : null) !is null;
+    }
+
+    public bool fileManager_shouldProceedAfterError_linkingItemAtPath_toPath_ (NSFileManager fileManager, NSError error, NSString srcPath,
+            NSString dstPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldProceedAfterError_1linkingItemAtPath_1toPath_1,
+                fileManager !is null ? fileManager.id : null, error !is null ? error.id : null, srcPath !is null ? srcPath.id : null,
+                dstPath !is null ? dstPath.id : null) !is null;
+    }
+
+    public bool fileManager_shouldProceedAfterError_movingItemAtPath_toPath_ (NSFileManager fileManager, NSError error, NSString srcPath,
+            NSString dstPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldProceedAfterError_1movingItemAtPath_1toPath_1,
+                fileManager !is null ? fileManager.id : null, error !is null ? error.id : null, srcPath !is null ? srcPath.id : null,
+                dstPath !is null ? dstPath.id : null) !is null;
+    }
+
+    public bool fileManager_shouldProceedAfterError_removingItemAtPath_ (NSFileManager fileManager, NSError error, NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldProceedAfterError_1removingItemAtPath_1,
+                fileManager !is null ? fileManager.id : null, error !is null ? error.id : null, path !is null ? path.id : null) !is null;
+    }
+
+    public bool fileManager_shouldRemoveItemAtPath_ (NSFileManager fileManager, NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileManager_1shouldRemoveItemAtPath_1, fileManager !is null ? fileManager.id : null,
+                path !is null ? path.id : null) !is null;
+    }
+
+    public void fileManager_willProcessPath_ (NSFileManager fm, NSString path)
+    {
+        OS.objc_msgSend(this.id, OS.sel_fileManager_1willProcessPath_1, fm !is null ? fm.id : null, path !is null ? path.id : null);
+    }
+
+    public void finalizeXX ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_finalize);
+    }
+
+    public void forwardInvocation (NSInvocation anInvocation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_forwardInvocation_1, anInvocation !is null ? anInvocation.id : null);
+    }
+
+    public void handleMachMessage (void* msg)
+    {
+        OS.objc_msgSend(this.id, OS.sel_handleMachMessage_1, msg);
+    }
+
+    public void handlePortMessage (NSPortMessage message)
+    {
+        OS.objc_msgSend(this.id, OS.sel_handlePortMessage_1, message !is null ? message.id : null);
+    }
+
+    public id handleQueryWithUnboundKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_handleQueryWithUnboundKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void handleTakeValue (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_handleTakeValue_1forUnboundKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public NSUInteger hash ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_hash);
+    }
+
+    public NSArray indicesOfObjectsByEvaluatingObjectSpecifier (NSScriptObjectSpecifier specifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_indicesOfObjectsByEvaluatingObjectSpecifier_1, specifier !is null ? specifier.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSObject init ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_init);
+        return result !is null ? this : null;
+    }
+
+    public NSObject initWithCoder (NSCoder aDecoder)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCoder_1, aDecoder !is null ? aDecoder.id : null);
+        return result !is null ? this : null;
+    }
+
+    public static void initialize ()
+    {
+        OS.objc_msgSend(OS.class_NSObject, OS.sel_initialize);
+    }
+
+    public void insertValue_atIndex_inPropertyWithKey_ (id value, NSUInteger index, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertValue_1atIndex_1inPropertyWithKey_1, value !is null ? value.id : null, index,
+                key !is null ? key.id : null);
+    }
+
+    public void insertValue_inPropertyWithKey_ (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertValue_1inPropertyWithKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public static objc.IMP instanceMethodForSelector (objc.SEL aSelector)
+    {
+        return cast(objc.IMP) OS.objc_msgSend(OS.class_NSObject, OS.sel_instanceMethodForSelector_1, aSelector);
+    }
+
+    public static NSMethodSignature instanceMethodSignatureForSelector (objc.SEL aSelector)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_instanceMethodSignatureForSelector_1, aSelector);
+        return result !is null ? new NSMethodSignature(result) : null;
+    }
+
+    public static bool instancesRespondToSelector (objc.SEL aSelector)
+    {
+        return OS.objc_msgSend(OS.class_NSObject, OS.sel_instancesRespondToSelector_1, aSelector) !is null;
+    }
+
+    public NSString inverseForRelationshipKey (NSString relationshipKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_inverseForRelationshipKey_1, relationshipKey !is null ? relationshipKey.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool isCaseInsensitiveLike (NSString object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isCaseInsensitiveLike_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isEqual (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqual_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isEqualTo (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualTo_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isGreaterThan (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isGreaterThan_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isGreaterThanOrEqualTo (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isGreaterThanOrEqualTo_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isKindOfClass (objc.Class aClass)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isKindOfClass_1, aClass) !is null;
+    }
+
+    public bool isLessThan (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLessThan_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isLessThanOrEqualTo (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLessThanOrEqualTo_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isLike (NSString object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLike_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isMemberOfClass (objc.Class aClass)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMemberOfClass_1, aClass) !is null;
+    }
+
+    public bool isNotEqualTo (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isNotEqualTo_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool isProxy ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isProxy) !is null;
+    }
+
+    public static bool isSubclassOfClass (objc.Class aClass)
+    {
+        return OS.objc_msgSend(OS.class_NSObject, OS.sel_isSubclassOfClass_1, aClass) !is null;
+    }
+
+    public static NSSet keyPathsForValuesAffectingValueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_keyPathsForValuesAffectingValueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new NSSet(result) : null;
+    }
+
+    public static void load ()
+    {
+        OS.objc_msgSend(OS.class_NSObject, OS.sel_load);
+    }
+
+    public void lock ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_lock);
+    }
+
+    public bool makeNewConnection (NSConnection conn, NSConnection ancestor)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_makeNewConnection_1sender_1, conn !is null ? conn.id : null, ancestor !is null ? ancestor.id : null) !is null;
+    }
+
+    public id metadataQuery_replacementObjectForResultObject_ (NSMetadataQuery query, NSMetadataItem result)
+    {
+        objc.id r = OS.objc_msgSend(this.id, OS.sel_metadataQuery_1replacementObjectForResultObject_1, query !is null ? query.id : null,
+                result !is null ? result.id : null);
+        return r !is null ? new id(r) : null;
+    }
+
+    public id metadataQuery_replacementValueForAttribute_value_ (NSMetadataQuery query, NSString attrName, id attrValue)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_metadataQuery_1replacementValueForAttribute_1value_1, query !is null ? query.id : null,
+                attrName !is null ? attrName.id : null, attrValue !is null ? attrValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.IMP methodForSelector (objc.SEL aSelector)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_methodForSelector_1, aSelector);
+    }
+
+    public NSMethodSignature methodSignatureForSelector (objc.SEL aSelector)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_methodSignatureForSelector_1, aSelector);
+        return result !is null ? new NSMethodSignature(result) : null;
+    }
+
+    public NSMutableArray mutableArrayValueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableArrayValueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new NSMutableArray(result) : null;
+    }
+
+    public NSMutableArray mutableArrayValueForKeyPath (NSString keyPath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableArrayValueForKeyPath_1, keyPath !is null ? keyPath.id : null);
+        return result !is null ? new NSMutableArray(result) : null;
+    }
+
+    public id mutableCopy ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableCopy);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id mutableCopyWithZone_ (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableCopyWithZone_1, zone);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_mutableCopyWithZone_ (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_mutableCopyWithZone_1, zone);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSMutableSet mutableSetValueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableSetValueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new NSMutableSet(result) : null;
+    }
+
+    public NSMutableSet mutableSetValueForKeyPath (NSString keyPath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableSetValueForKeyPath_1, keyPath !is null ? keyPath.id : null);
+        return result !is null ? new NSMutableSet(result) : null;
+    }
+
+    public void netService_didNotPublish_ (NSNetService sender, NSDictionary errorDict)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netService_1didNotPublish_1, sender !is null ? sender.id : null, errorDict !is null ? errorDict.id : null);
+    }
+
+    public void netService_didNotResolve_ (NSNetService sender, NSDictionary errorDict)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netService_1didNotResolve_1, sender !is null ? sender.id : null, errorDict !is null ? errorDict.id : null);
+    }
+
+    public void netService_didUpdateTXTRecordData_ (NSNetService sender, NSData data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netService_1didUpdateTXTRecordData_1, sender !is null ? sender.id : null, data !is null ? data.id : null);
+    }
+
+    public void netServiceBrowser_didFindDomain_moreComing_ (NSNetServiceBrowser aNetServiceBrowser, NSString domainString, bool moreComing)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceBrowser_1didFindDomain_1moreComing_1, aNetServiceBrowser !is null ? aNetServiceBrowser.id : null,
+                domainString !is null ? domainString.id : null, moreComing);
+    }
+
+    public void netServiceBrowser_didFindService_moreComing_ (NSNetServiceBrowser aNetServiceBrowser, NSNetService aNetService, bool moreComing)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceBrowser_1didFindService_1moreComing_1, aNetServiceBrowser !is null ? aNetServiceBrowser.id : null,
+                aNetService !is null ? aNetService.id : null, moreComing);
+    }
+
+    public void netServiceBrowser_didNotSearch_ (NSNetServiceBrowser aNetServiceBrowser, NSDictionary errorDict)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceBrowser_1didNotSearch_1, aNetServiceBrowser !is null ? aNetServiceBrowser.id : null,
+                errorDict !is null ? errorDict.id : null);
+    }
+
+    public void netServiceBrowser_didRemoveDomain_moreComing_ (NSNetServiceBrowser aNetServiceBrowser, NSString domainString, bool moreComing)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceBrowser_1didRemoveDomain_1moreComing_1, aNetServiceBrowser !is null ? aNetServiceBrowser.id : null,
+                domainString !is null ? domainString.id : null, moreComing);
+    }
+
+    public void netServiceBrowser_didRemoveService_moreComing_ (NSNetServiceBrowser aNetServiceBrowser, NSNetService aNetService, bool moreComing)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceBrowser_1didRemoveService_1moreComing_1,
+                aNetServiceBrowser !is null ? aNetServiceBrowser.id : null, aNetService !is null ? aNetService.id : null, moreComing);
+    }
+
+    public void netServiceBrowserDidStopSearch (NSNetServiceBrowser aNetServiceBrowser)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceBrowserDidStopSearch_1, aNetServiceBrowser !is null ? aNetServiceBrowser.id : null);
+    }
+
+    public void netServiceBrowserWillSearch (NSNetServiceBrowser aNetServiceBrowser)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceBrowserWillSearch_1, aNetServiceBrowser !is null ? aNetServiceBrowser.id : null);
+    }
+
+    public void netServiceDidPublish (NSNetService sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceDidPublish_1, sender !is null ? sender.id : null);
+    }
+
+    public void netServiceDidResolveAddress (NSNetService sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceDidResolveAddress_1, sender !is null ? sender.id : null);
+    }
+
+    public void netServiceDidStop (NSNetService sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceDidStop_1, sender !is null ? sender.id : null);
+    }
+
+    public void netServiceWillPublish (NSNetService sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceWillPublish_1, sender !is null ? sender.id : null);
+    }
+
+    public void netServiceWillResolve (NSNetService sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_netServiceWillResolve_1, sender !is null ? sender.id : null);
+    }
+
+    //public static id new() {
+    //  objc.id result = OS.objc_msgSend(OS.class_NSObject, OS.sel_new);
+    //  return result !is null ? new id(result) : null;
+    //}
+
+    public id newScriptingObjectOfClass (objc.Class objectClass, NSString key, id contentsValue, NSDictionary properties)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_newScriptingObjectOfClass_1forValueForKey_1withContentsValue_1properties_1, objectClass,
+                key !is null ? key.id : null, contentsValue !is null ? contentsValue.id : null, properties !is null ? properties.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSScriptObjectSpecifier objectSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectSpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public void* observationInfo ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_observationInfo);
+    }
+
+    public void observeValueForKeyPath (NSString keyPath, id object, NSDictionary change, void* context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_observeValueForKeyPath_1ofObject_1change_1context_1, keyPath !is null ? keyPath.id : null,
+                object !is null ? object.id : null, change !is null ? change.id : null, context);
+    }
+
+    public void parser_didEndElement_namespaceURI_qualifiedName_ (NSXMLParser parser, NSString elementName, NSString namespaceURI, NSString qName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1didEndElement_1namespaceURI_1qualifiedName_1, parser !is null ? parser.id : null,
+                elementName !is null ? elementName.id : null, namespaceURI !is null ? namespaceURI.id : null, qName !is null ? qName.id : null);
+    }
+
+    public void parser_didEndMappingPrefix_ (NSXMLParser parser, NSString prefix)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1didEndMappingPrefix_1, parser !is null ? parser.id : null, prefix !is null ? prefix.id : null);
+    }
+
+    public void parser_didStartElement_namespaceURI_qualifiedName_attributes_ (NSXMLParser parser, NSString elementName, NSString namespaceURI,
+            NSString qName, NSDictionary attributeDict)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1didStartElement_1namespaceURI_1qualifiedName_1attributes_1, parser !is null ? parser.id : null,
+                elementName !is null ? elementName.id : null, namespaceURI !is null ? namespaceURI.id : null, qName !is null ? qName.id : null,
+                attributeDict !is null ? attributeDict.id : null);
+    }
+
+    public void parser_didStartMappingPrefix_toURI_ (NSXMLParser parser, NSString prefix, NSString namespaceURI)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1didStartMappingPrefix_1toURI_1, parser !is null ? parser.id : null,
+                prefix !is null ? prefix.id : null, namespaceURI !is null ? namespaceURI.id : null);
+    }
+
+    public void parser_foundAttributeDeclarationWithName_forElement_type_defaultValue_ (NSXMLParser parser, NSString attributeName,
+            NSString elementName, NSString type, NSString defaultValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundAttributeDeclarationWithName_1forElement_1type_1defaultValue_1,
+                parser !is null ? parser.id : null, attributeName !is null ? attributeName.id : null, elementName !is null ? elementName.id : null,
+                type !is null ? type.id : null, defaultValue !is null ? defaultValue.id : null);
+    }
+
+    public void parser_foundCDATA_ (NSXMLParser parser, NSData CDATABlock)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundCDATA_1, parser !is null ? parser.id : null, CDATABlock !is null ? CDATABlock.id : null);
+    }
+
+    public void parser_foundCharacters_ (NSXMLParser parser, NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundCharacters_1, parser !is null ? parser.id : null, string !is null ? string.id : null);
+    }
+
+    public void parser_foundComment_ (NSXMLParser parser, NSString comment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundComment_1, parser !is null ? parser.id : null, comment !is null ? comment.id : null);
+    }
+
+    public void parser_foundElementDeclarationWithName_model_ (NSXMLParser parser, NSString elementName, NSString model)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundElementDeclarationWithName_1model_1, parser !is null ? parser.id : null,
+                elementName !is null ? elementName.id : null, model !is null ? model.id : null);
+    }
+
+    public void parser_foundExternalEntityDeclarationWithName_publicID_systemID_ (NSXMLParser parser, NSString name, NSString publicID,
+            NSString systemID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundExternalEntityDeclarationWithName_1publicID_1systemID_1, parser !is null ? parser.id : null,
+                name !is null ? name.id : null, publicID !is null ? publicID.id : null, systemID !is null ? systemID.id : null);
+    }
+
+    public void parser_foundIgnorableWhitespace_ (NSXMLParser parser, NSString whitespaceString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundIgnorableWhitespace_1, parser !is null ? parser.id : null,
+                whitespaceString !is null ? whitespaceString.id : null);
+    }
+
+    public void parser_foundInternalEntityDeclarationWithName_value_ (NSXMLParser parser, NSString name, NSString value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundInternalEntityDeclarationWithName_1value_1, parser !is null ? parser.id : null,
+                name !is null ? name.id : null, value !is null ? value.id : null);
+    }
+
+    public void parser_foundNotationDeclarationWithName_publicID_systemID_ (NSXMLParser parser, NSString name, NSString publicID, NSString systemID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundNotationDeclarationWithName_1publicID_1systemID_1, parser !is null ? parser.id : null,
+                name !is null ? name.id : null, publicID !is null ? publicID.id : null, systemID !is null ? systemID.id : null);
+    }
+
+    public void parser_foundProcessingInstructionWithTarget_data_ (NSXMLParser parser, NSString target, NSString data)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundProcessingInstructionWithTarget_1data_1, parser !is null ? parser.id : null,
+                target !is null ? target.id : null, data !is null ? data.id : null);
+    }
+
+    public void parser_foundUnparsedEntityDeclarationWithName_publicID_systemID_notationName_ (NSXMLParser parser, NSString name, NSString publicID,
+            NSString systemID, NSString notationName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1foundUnparsedEntityDeclarationWithName_1publicID_1systemID_1notationName_1,
+                parser !is null ? parser.id : null, name !is null ? name.id : null, publicID !is null ? publicID.id : null,
+                systemID !is null ? systemID.id : null, notationName !is null ? notationName.id : null);
+    }
+
+    public void parser_parseErrorOccurred_ (NSXMLParser parser, NSError parseError)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1parseErrorOccurred_1, parser !is null ? parser.id : null, parseError !is null ? parseError.id : null);
+    }
+
+    public NSData parser_resolveExternalEntityName_systemID_ (NSXMLParser parser, NSString name, NSString systemID)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parser_1resolveExternalEntityName_1systemID_1, parser !is null ? parser.id : null,
+                name !is null ? name.id : null, systemID !is null ? systemID.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void parser_validationErrorOccurred_ (NSXMLParser parser, NSError validationError)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parser_1validationErrorOccurred_1, parser !is null ? parser.id : null,
+                validationError !is null ? validationError.id : null);
+    }
+
+    public void parserDidEndDocument (NSXMLParser parser)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parserDidEndDocument_1, parser !is null ? parser.id : null);
+    }
+
+    public void parserDidStartDocument (NSXMLParser parser)
+    {
+        OS.objc_msgSend(this.id, OS.sel_parserDidStartDocument_1, parser !is null ? parser.id : null);
+    }
+
+    public id performSelector_ (objc.SEL aSelector)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_performSelector_1, aSelector);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void performSelector_onThread_withObject_waitUntilDone_ (objc.SEL aSelector, NSThread thr, id arg, bool wait)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelector_1onThread_1withObject_1waitUntilDone_1, aSelector, thr !is null ? thr.id : null,
+                arg !is null ? arg.id : null, wait);
+    }
+
+    public void performSelector_onThread_withObject_waitUntilDone_modes_ (objc.SEL aSelector, NSThread thr, id arg, bool wait, NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelector_1onThread_1withObject_1waitUntilDone_1modes_1, aSelector, thr !is null ? thr.id : null,
+                arg !is null ? arg.id : null, wait, array !is null ? array.id : null);
+    }
+
+    public id performSelector_withObject_ (objc.SEL aSelector, id object)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_performSelector_1withObject_1, aSelector, object !is null ? object.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void performSelector_withObject_afterDelay_ (objc.SEL aSelector, id anArgument, NSTimeInterval delay)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelector_1withObject_1afterDelay_1, aSelector, anArgument !is null ? anArgument.id : null, delay);
+    }
+
+    public void performSelector_withObject_afterDelay_inModes_ (objc.SEL aSelector, id anArgument, NSTimeInterval delay, NSArray modes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelector_1withObject_1afterDelay_1inModes_1, aSelector, anArgument !is null ? anArgument.id : null,
+                delay, modes !is null ? modes.id : null);
+    }
+
+    public id performSelector_withObject_withObject_ (objc.SEL aSelector, id object1, id object2)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_performSelector_1withObject_1withObject_1, aSelector, object1 !is null ? object1.id : null,
+                object2 !is null ? object2.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void performSelectorInBackground (objc.SEL aSelector, id arg)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelectorInBackground_1withObject_1, aSelector, arg !is null ? arg.id : null);
+    }
+
+    public void performSelectorOnMainThread_withObject_waitUntilDone_ (objc.SEL aSelector, id arg, bool wait)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelectorOnMainThread_1withObject_1waitUntilDone_1, aSelector, arg !is null ? arg.id : null, wait);
+    }
+
+    public void performSelectorOnMainThread_withObject_waitUntilDone_modes_ (objc.SEL aSelector, id arg, bool wait, NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelectorOnMainThread_1withObject_1waitUntilDone_1modes_1, aSelector, arg !is null ? arg.id : null,
+                wait, array !is null ? array.id : null);
+    }
+
+    public static void poseAsClass (objc.Class aClass)
+    {
+        OS.objc_msgSend(OS.class_NSObject, OS.sel_poseAsClass_1, aClass);
+    }
+
+    public void release ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_release);
+    }
+
+    public void removeObserver (NSObject observer, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void removeObserver (NSObject observer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1, observer !is null ? observer.id : null);
+    }
+
+    public void removeValueAtIndex (NSUInteger index, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeValueAtIndex_1fromPropertyWithKey_1, index, key !is null ? key.id : null);
+    }
+
+    public void replaceValueAtIndex (NSUInteger index, NSString key, id value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceValueAtIndex_1inPropertyWithKey_1withValue_1, index, key !is null ? key.id : null,
+                value !is null ? value.id : null);
+    }
+
+    public id replacementObjectForArchiver (NSArchiver archiver)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_replacementObjectForArchiver_1, archiver !is null ? archiver.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id replacementObjectForCoder (NSCoder aCoder)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_replacementObjectForCoder_1, aCoder !is null ? aCoder.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id replacementObjectForKeyedArchiver (NSKeyedArchiver archiver)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_replacementObjectForKeyedArchiver_1, archiver !is null ? archiver.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id replacementObjectForPortCoder (NSPortCoder coder)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_replacementObjectForPortCoder_1, coder !is null ? coder.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static bool resolveClassMethod (objc.SEL sel)
+    {
+        return OS.objc_msgSend(OS.class_NSObject, OS.sel_resolveClassMethod_1, sel) !is null;
+    }
+
+    public static bool resolveInstanceMethod (objc.SEL sel)
+    {
+        return OS.objc_msgSend(OS.class_NSObject, OS.sel_resolveInstanceMethod_1, sel) !is null;
+    }
+
+    public bool respondsToSelector (objc.SEL aSelector)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_respondsToSelector_1, aSelector) !is null;
+    }
+
+    public id retain ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_retain);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger retainCount ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_retainCount);
+    }
+
+    public NSRoundingMode roundingMode ()
+    {
+        return cast(NSRoundingMode) OS.objc_msgSend(this.id, OS.sel_roundingMode);
+    }
+
+    public short scale ()
+    {
+        return cast(short) OS.objc_msgSend(this.id, OS.sel_scale);
+    }
+
+    public bool scriptingBeginsWith (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingBeginsWith_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool scriptingContains (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingContains_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool scriptingEndsWith (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingEndsWith_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool scriptingIsEqualTo (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingIsEqualTo_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool scriptingIsGreaterThan (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingIsGreaterThan_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool scriptingIsGreaterThanOrEqualTo (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingIsGreaterThanOrEqualTo_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool scriptingIsLessThan (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingIsLessThan_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool scriptingIsLessThanOrEqualTo (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scriptingIsLessThanOrEqualTo_1, object !is null ? object.id : null) !is null;
+    }
+
+    public NSDictionary scriptingProperties ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_scriptingProperties);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public id scriptingValueForSpecifier (NSScriptObjectSpecifier objectSpecifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_scriptingValueForSpecifier_1, objectSpecifier !is null ? objectSpecifier.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id self ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_self);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static void setKeys (NSArray keys, NSString dependentKey)
+    {
+        OS.objc_msgSend(OS.class_NSObject, OS.sel_setKeys_1triggerChangeNotificationsForDependentKey_1, keys !is null ? keys.id : null,
+                dependentKey !is null ? dependentKey.id : null);
+    }
+
+    public void setNilValueForKey (NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNilValueForKey_1, key !is null ? key.id : null);
+    }
+
+    public void setObservationInfo (void* observationInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObservationInfo_1, observationInfo);
+    }
+
+    public void setScriptingProperties (NSDictionary properties)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScriptingProperties_1, properties !is null ? properties.id : null);
+    }
+
+    public void setValue_forKey_ (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public void setValue_forKeyPath_ (id value, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forKeyPath_1, value !is null ? value.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void setValue_forUndefinedKey_ (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forUndefinedKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public void setValuesForKeysWithDictionary (NSDictionary keyedValues)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValuesForKeysWithDictionary_1, keyedValues !is null ? keyedValues.id : null);
+    }
+
+    public static void setVersion (NSInteger aVersion)
+    {
+        OS.objc_msgSend(OS.class_NSObject, OS.sel_setVersion_1, aVersion);
+    }
+
+    public NSRange spellServer_checkGrammarInString_language_details_ (NSSpellServer sender, NSString stringToCheck, NSString language, objc.id** details)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_spellServer_1checkGrammarInString_1language_1details_1, sender !is null ? sender.id : null,
+                stringToCheck !is null ? stringToCheck.id : null, language !is null ? language.id : null, details);
+        return result;
+    }
+
+    public void spellServer_didForgetWord_inLanguage_ (NSSpellServer sender, NSString word, NSString language)
+    {
+        OS.objc_msgSend(this.id, OS.sel_spellServer_1didForgetWord_1inLanguage_1, sender !is null ? sender.id : null, word !is null ? word.id : null,
+                language !is null ? language.id : null);
+    }
+
+    public void spellServer_didLearnWord_inLanguage_ (NSSpellServer sender, NSString word, NSString language)
+    {
+        OS.objc_msgSend(this.id, OS.sel_spellServer_1didLearnWord_1inLanguage_1, sender !is null ? sender.id : null, word !is null ? word.id : null,
+                language !is null ? language.id : null);
+    }
+
+    public NSRange spellServer_findMisspelledWordInString_language_wordCount_countOnly_ (NSSpellServer sender, NSString stringToCheck,
+            NSString language, int* wordCount, bool countOnly)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_spellServer_1findMisspelledWordInString_1language_1wordCount_1countOnly_1,
+                sender !is null ? sender.id : null, stringToCheck !is null ? stringToCheck.id : null, language !is null ? language.id : null,
+                wordCount, countOnly);
+        return result;
+    }
+
+    public NSArray spellServer_suggestCompletionsForPartialWordRange_inString_language_ (NSSpellServer sender, NSRange range, NSString string,
+            NSString language)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_spellServer_1suggestCompletionsForPartialWordRange_1inString_1language_1,
+                sender !is null ? sender.id : null, range, string !is null ? string.id : null, language !is null ? language.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray spellServer_suggestGuessesForWord_inLanguage_ (NSSpellServer sender, NSString word, NSString language)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_spellServer_1suggestGuessesForWord_1inLanguage_1, sender !is null ? sender.id : null,
+                word !is null ? word.id : null, language !is null ? language.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id storedValueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_storedValueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void stream (NSStream aStream, NSStreamEvent eventCode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stream_1handleEvent_1, aStream !is null ? aStream.id : null, eventCode);
+    }
+
+    public static objc.Class static_superclass ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(OS.class_NSObject, OS.sel_superclass);
+    }
+
+    public objc.Class superclass ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_superclass);
+    }
+
+    public void takeStoredValue (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeStoredValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public void takeValue_forKey_ (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public void takeValue_forKeyPath_ (id value, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeValue_1forKeyPath_1, value !is null ? value.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void takeValuesFromDictionary (NSDictionary properties)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeValuesFromDictionary_1, properties !is null ? properties.id : null);
+    }
+
+    public NSArray toManyRelationshipKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toManyRelationshipKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray toOneRelationshipKeys ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toOneRelationshipKeys);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void unableToSetNilForKey (NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unableToSetNilForKey_1, key !is null ? key.id : null);
+    }
+
+    public objc.Class unarchiver_cannotDecodeObjectOfClassName_originalClasses_ (NSKeyedUnarchiver unarchiver, NSString name, NSArray classNames)
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_unarchiver_1cannotDecodeObjectOfClassName_1originalClasses_1,
+                unarchiver !is null ? unarchiver.id : null, name !is null ? name.id : null, classNames !is null ? classNames.id : null);
+    }
+
+    public id unarchiver_didDecodeObject_ (NSKeyedUnarchiver unarchiver, id object)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_unarchiver_1didDecodeObject_1, unarchiver !is null ? unarchiver.id : null,
+                object !is null ? object.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void unarchiver_willReplaceObject_withObject_ (NSKeyedUnarchiver unarchiver, id object, id newObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unarchiver_1willReplaceObject_1withObject_1, unarchiver !is null ? unarchiver.id : null,
+                object !is null ? object.id : null, newObject !is null ? newObject.id : null);
+    }
+
+    public void unarchiverDidFinish (NSKeyedUnarchiver unarchiver)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unarchiverDidFinish_1, unarchiver !is null ? unarchiver.id : null);
+    }
+
+    public void unarchiverWillFinish (NSKeyedUnarchiver unarchiver)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unarchiverWillFinish_1, unarchiver !is null ? unarchiver.id : null);
+    }
+
+    public void unlock ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_unlock);
+    }
+
+    public void useCredential (NSURLCredential credential, NSURLAuthenticationChallenge challenge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_useCredential_1forAuthenticationChallenge_1, credential !is null ? credential.id : null,
+                challenge !is null ? challenge.id : null);
+    }
+
+    public static bool useStoredAccessor ()
+    {
+        return OS.objc_msgSend(OS.class_NSObject, OS.sel_useStoredAccessor) !is null;
+    }
+
+    public bool validateValue_forKey_error_ (objc.id* ioValue, NSString inKey, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_validateValue_1forKey_1error_1, ioValue, inKey !is null ? inKey.id : null, outError) !is null;
+    }
+
+    public bool validateValue_forKeyPath_error_ (objc.id* ioValue, NSString inKeyPath, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_validateValue_1forKeyPath_1error_1, ioValue, inKeyPath !is null ? inKeyPath.id : null, outError) !is null;
+    }
+
+    public id valueAtIndex (NSUInteger index, NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueAtIndex_1inPropertyWithKey_1, index, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id valueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id valueForKeyPath (NSString keyPath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKeyPath_1, keyPath !is null ? keyPath.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id valueForUndefinedKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForUndefinedKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id valueWithName (NSString name, NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueWithName_1inPropertyWithKey_1, name !is null ? name.id : null,
+                key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id valueWithUniqueID (id uniqueID, NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueWithUniqueID_1inPropertyWithKey_1, uniqueID !is null ? uniqueID.id : null,
+                key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary valuesForKeys (NSArray keys)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valuesForKeys_1, keys !is null ? keys.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public static NSInteger versionn ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(OS.class_NSObject, OS.sel_version);
+    }
+
+    public void willChange (NSKeyValueChange changeKind, NSIndexSet indexes, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_willChange_1valuesAtIndexes_1forKey_1, changeKind, indexes !is null ? indexes.id : null,
+                key !is null ? key.id : null);
+    }
+
+    public void willChangeValueForKey_ (NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_willChangeValueForKey_1, key !is null ? key.id : null);
+    }
+
+    public void willChangeValueForKey_withSetMutation_usingObjects_ (NSString key, NSKeyValueSetMutationKind mutationKind, NSSet objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_willChangeValueForKey_1withSetMutation_1usingObjects_1, key !is null ? key.id : null, mutationKind,
+                objects !is null ? objects.id : null);
+    }
+
+    public NSZone* zone ()
+    {
+        return cast(NSZone*) OS.objc_msgSend(this.id, OS.sel_zone);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSObjectController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSObjectController;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSController;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSObjectController : NSController
+{
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void add (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_add_1, sender !is null ? sender.id : null);
+    }
+
+    public void addObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObject_1, object !is null ? object.id : null);
+    }
+
+    public bool automaticallyPreparesContent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_automaticallyPreparesContent) !is null;
+    }
+
+    public bool canAdd ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canAdd) !is null;
+    }
+
+    public bool canRemove ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canRemove) !is null;
+    }
+
+    public id content ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_content);
+        return result !is null ? new id(result) : null;
+    }
+
+    //public NSFetchRequest defaultFetchRequest() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultFetchRequest);
+    //  return result !is null ? new NSFetchRequest(result) : null;
+    //}
+    
+    public NSString entityName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_entityName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void fetch (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_fetch_1, sender !is null ? sender.id : null);
+    }
+
+    public NSPredicate fetchPredicate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fetchPredicate);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    //
+    //public bool fetchWithRequest(NSFetchRequest fetchRequest, bool merge, objc.id** error) {
+    //  return OS.objc_msgSend(this.id, OS.sel_fetchWithRequest_1merge_1error_1, fetchRequest !is null ? fetchRequest.id : null, merge, error) !is null;
+    //}
+
+    public NSObjectController initWithContent (id content)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContent_1, content !is null ? content.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    //public NSManagedObjectContext managedObjectContext() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_managedObjectContext);
+    //  return result !is null ? new NSManagedObjectContext(result) : null;
+    //}
+
+    public id newObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_newObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.Class objectClass ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_objectClass);
+    }
+
+    public void prepareContent ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_prepareContent);
+    }
+
+    public void remove (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_remove_1, sender !is null ? sender.id : null);
+    }
+
+    public void removeObject (id object)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObject_1, object !is null ? object.id : null);
+    }
+
+    public NSArray selectedObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id selection ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selection);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setAutomaticallyPreparesContent (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutomaticallyPreparesContent_1, flag);
+    }
+
+    public void setContent (id content)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContent_1, content !is null ? content.id : null);
+    }
+
+    public void setEditable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag);
+    }
+
+    public void setEntityName (NSString entityName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEntityName_1, entityName !is null ? entityName.id : null);
+    }
+
+    public void setFetchPredicate (NSPredicate predicate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFetchPredicate_1, predicate !is null ? predicate.id : null);
+    }
+
+    //public void setManagedObjectContext(NSManagedObjectContext managedObjectContext) {
+    //  OS.objc_msgSend(this.id, OS.sel_setManagedObjectContext_1, managedObjectContext !is null ? managedObjectContext.id : null);
+    //}
+
+    public void setObjectClass (objc.Class objectClass)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectClass_1, objectClass);
+    }
+
+    public void setUsesLazyFetching (bool enabled)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesLazyFetching_1, enabled);
+    }
+
+    public bool usesLazyFetching ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesLazyFetching) !is null;
+    }
+
+    public bool validateUserInterfaceItem (id item)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_validateUserInterfaceItem_1, item !is null ? item.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOpenGLContext.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOpenGLContext;
+
+import dwt.internal.cocoa.gl;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSOpenGLPixelBuffer;
+import dwt.internal.cocoa.NSOpenGLPixelFormat;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSOpenGLContextParameter
+{
+    NSOpenGLCPSwapRectangle = 200,
+    NSOpenGLCPSwapRectangleEnable = 201,
+    NSOpenGLCPRasterizationEnable = 221,
+    NSOpenGLCPSwapInterval = 222,
+    NSOpenGLCPSurfaceOrder = 235,
+    NSOpenGLCPSurfaceOpacity = 236,
+    NSOpenGLCPStateValidation = 301
+}
+
+alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangle NSOpenGLCPSwapRectangle;
+alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangleEnable NSOpenGLCPSwapRectangleEnable;
+alias NSOpenGLContextParameter.NSOpenGLCPRasterizationEnable NSOpenGLCPRasterizationEnable;
+alias NSOpenGLContextParameter.NSOpenGLCPSwapInterval NSOpenGLCPSwapInterval;
+alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOrder NSOpenGLCPSurfaceOrder;
+alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOpacity NSOpenGLCPSurfaceOpacity;
+alias NSOpenGLContextParameter.NSOpenGLCPStateValidation NSOpenGLCPStateValidation;
+
+public class NSOpenGLContext : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void* CGLContextObj ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_CGLContextObj);
+    }
+
+    public static void clearCurrentContext ()
+    {
+        OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_clearCurrentContext);
+    }
+
+    public void clearDrawable ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_clearDrawable);
+    }
+
+    public void copyAttributesFromContext (NSOpenGLContext context, GLbitfield mask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_copyAttributesFromContext_1withMask_1, context !is null ? context.id : null, mask);
+    }
+
+    public void createTexture (GLenum target, NSView view, GLenum format)
+    {
+        OS.objc_msgSend(this.id, OS.sel_createTexture_1fromView_1internalFormat_1, target, view !is null ? view.id : null, format);
+    }
+
+    public static NSOpenGLContext currentContext ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_currentContext);
+        return result !is null ? new NSOpenGLContext(result) : null;
+    }
+
+    public GLint currentVirtualScreen ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_currentVirtualScreen);
+    }
+
+    public void flushBuffer ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushBuffer);
+    }
+
+    public void getValues (GLint* vals, NSOpenGLContextParameter param)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getValues_1forParameter_1, vals, param);
+    }
+
+    public NSOpenGLContext initWithFormat (NSOpenGLPixelFormat format, NSOpenGLContext share)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFormat_1shareContext_1, format !is null ? format.id : null,
+                share !is null ? share.id : null);
+        return result !is null ? this : null;
+    }
+
+    public void makeCurrentContext ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeCurrentContext);
+    }
+
+    public NSOpenGLPixelBuffer pixelBuffer ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pixelBuffer);
+        return result !is null ? new NSOpenGLPixelBuffer(result) : null;
+    }
+
+    public GLenum pixelBufferCubeMapFace ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pixelBufferCubeMapFace);
+    }
+
+    public GLint pixelBufferMipMapLevel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pixelBufferMipMapLevel);
+    }
+
+    public void setCurrentVirtualScreen (GLint screen)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrentVirtualScreen_1, screen);
+    }
+
+    public void setFullScreen ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFullScreen);
+    }
+
+    public void setOffScreen (void* baseaddr, GLsizei width, GLsizei height, GLint rowbytes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOffScreen_1width_1height_1rowbytes_1, baseaddr, width, height, rowbytes);
+    }
+
+    public void setPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, GLenum face, GLint level, GLint screen)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPixelBuffer_1cubeMapFace_1mipMapLevel_1currentVirtualScreen_1,
+                pixelBuffer !is null ? pixelBuffer.id : null, face, level, screen);
+    }
+
+    public void setTextureImageToPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, GLenum source)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextureImageToPixelBuffer_1colorBuffer_1, pixelBuffer !is null ? pixelBuffer.id : null, source);
+    }
+
+    public void setValues (/*const*/GLint* vals, NSOpenGLContextParameter param)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValues_1forParameter_1, vals, param);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public void update ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_update);
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOpenGLPixelBuffer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOpenGLPixelBuffer;
+
+import dwt.internal.cocoa.gl;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSOpenGLPixelBuffer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSOpenGLPixelBuffer initWithTextureTarget (GLenum target, GLenum format, GLint maxLevel, GLsizei pixelsWide, GLsizei pixelsHigh)
+    {
+        objc.id result = OS.objc_msgSend(this.id,
+                OS.sel_initWithTextureTarget_1textureInternalFormat_1textureMaxMipMapLevel_1pixelsWide_1pixelsHigh_1, target, format, maxLevel,
+                pixelsWide, pixelsHigh);
+        return result !is null ? this : null;
+    }
+
+    public GLsizei pixelsHigh ()
+    {
+        return cast(GLsizei) OS.objc_msgSend(this.id, OS.sel_pixelsHigh);
+    }
+
+    public GLsizei pixelsWide ()
+    {
+        return cast(GLsizei) OS.objc_msgSend(this.id, OS.sel_pixelsWide);
+    }
+
+    public GLenum textureInternalFormat ()
+    {
+        return cast(GLenum) OS.objc_msgSend(this.id, OS.sel_textureInternalFormat);
+    }
+
+    public GLint textureMaxMipMapLevel ()
+    {
+        return cast(GLint) OS.objc_msgSend(this.id, OS.sel_textureMaxMipMapLevel);
+    }
+
+    public GLenum textureTarget ()
+    {
+        return cast(GLenum) OS.objc_msgSend(this.id, OS.sel_textureTarget);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOpenGLPixelFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOpenGLPixelFormat;
+
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSOpenGLPixelFormatAttribute
+{
+    NSOpenGLPFAAllRenderers = 1,
+    NSOpenGLPFADoubleBuffer = 5,
+    NSOpenGLPFAStereo = 6,
+    NSOpenGLPFAAuxBuffers = 7,
+    NSOpenGLPFAColorSize = 8,
+    NSOpenGLPFAAlphaSize = 11,
+    NSOpenGLPFADepthSize = 12,
+    NSOpenGLPFAStencilSize = 13,
+    NSOpenGLPFAAccumSize = 14,
+    NSOpenGLPFAMinimumPolicy = 51,
+    NSOpenGLPFAMaximumPolicy = 52,
+    NSOpenGLPFAOffScreen = 53,
+    NSOpenGLPFAFullScreen = 54,
+    NSOpenGLPFASampleBuffers = 55,
+    NSOpenGLPFASamples = 56,
+    NSOpenGLPFAAuxDepthStencil = 57,
+    NSOpenGLPFARendererID = 70,
+    NSOpenGLPFASingleRenderer = 71,
+    NSOpenGLPFANoRecovery = 72,
+    NSOpenGLPFAAccelerated = 73,
+    NSOpenGLPFAClosestPolicy = 74,
+    NSOpenGLPFARobust = 75,
+    NSOpenGLPFABackingStore = 76,
+    NSOpenGLPFAMPSafe = 78,
+    NSOpenGLPFAWindow = 80,
+    NSOpenGLPFAMultiScreen = 81,
+    NSOpenGLPFACompliant = 83,
+    NSOpenGLPFAScreenMask = 84,
+    NSOpenGLPFAPixelBuffer = 90,
+    NSOpenGLPFAVirtualScreenCount = 128
+}
+
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAAllRenderers NSOpenGLPFAAllRenderers;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFADoubleBuffer NSOpenGLPFADoubleBuffer;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAStereo NSOpenGLPFAStereo;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAAuxBuffers NSOpenGLPFAAuxBuffers;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAColorSize NSOpenGLPFAColorSize;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAAlphaSize NSOpenGLPFAAlphaSize;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFADepthSize NSOpenGLPFADepthSize;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAStencilSize NSOpenGLPFAStencilSize;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAAccumSize NSOpenGLPFAAccumSize;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAMinimumPolicy NSOpenGLPFAMinimumPolicy;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAMaximumPolicy NSOpenGLPFAMaximumPolicy;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAOffScreen NSOpenGLPFAOffScreen;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAFullScreen NSOpenGLPFAFullScreen;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFASampleBuffers NSOpenGLPFASampleBuffers;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFASamples NSOpenGLPFASamples;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAAuxDepthStencil NSOpenGLPFAAuxDepthStencil;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFARendererID NSOpenGLPFARendererID;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFASingleRenderer NSOpenGLPFASingleRenderer;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFANoRecovery NSOpenGLPFANoRecovery;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAAccelerated NSOpenGLPFAAccelerated;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAClosestPolicy NSOpenGLPFAClosestPolicy;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFARobust NSOpenGLPFARobust;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFABackingStore NSOpenGLPFABackingStore;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAMPSafe NSOpenGLPFAMPSafe;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAWindow NSOpenGLPFAWindow;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAMultiScreen NSOpenGLPFAMultiScreen;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFACompliant NSOpenGLPFACompliant;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAScreenMask NSOpenGLPFAScreenMask;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAPixelBuffer NSOpenGLPFAPixelBuffer;
+alias NSOpenGLPixelFormatAttribute.NSOpenGLPFAVirtualScreenCount NSOpenGLPFAVirtualScreenCount;
+
+public class NSOpenGLPixelFormat : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void* CGLPixelFormatObj ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_CGLPixelFormatObj);
+    }
+
+    public NSData attributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributes);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void getValues (GLint* vals, NSOpenGLPixelFormatAttribute attrib, GLint screen)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getValues_1forAttribute_1forVirtualScreen_1, vals, attrib, screen);
+    }
+
+    public NSOpenGLPixelFormat initWithAttributes (/*const*/NSOpenGLPixelFormatAttribute* attribs)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithAttributes_1, attribs);
+        return result !is null ? this : null;
+    }
+
+    public NSOpenGLPixelFormat initWithData (NSData attribs)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, attribs !is null ? attribs.id : null);
+        return result !is null ? this : null;
+    }
+
+    public GLint numberOfVirtualScreens ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfVirtualScreens);
+    }
+
+    public void setAttributes (NSData attribs)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributes_1, attribs !is null ? attribs.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOpenGLView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOpenGLView;
+
+import dwt.internal.cocoa.NSOpenGLContext;
+import dwt.internal.cocoa.NSOpenGLPixelFormat;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSOpenGLView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void clearGLContext ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_clearGLContext);
+    }
+
+    public static NSOpenGLPixelFormat defaultPixelFormat ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSOpenGLView, OS.sel_defaultPixelFormat);
+        return result !is null ? new NSOpenGLPixelFormat(result) : null;
+    }
+
+    public NSOpenGLView initWithFrame (NSRect frameRect, NSOpenGLPixelFormat format)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1pixelFormat_1, frameRect, format !is null ? format.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSOpenGLContext openGLContext ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_openGLContext);
+        return result !is null ? new NSOpenGLContext(result) : null;
+    }
+
+    public NSOpenGLPixelFormat pixelFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pixelFormat);
+        return result !is null ? new NSOpenGLPixelFormat(result) : null;
+    }
+
+    public void prepareOpenGL ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_prepareOpenGL);
+    }
+
+    public void reshape ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reshape);
+    }
+
+    public void setOpenGLContext (NSOpenGLContext context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOpenGLContext_1, context !is null ? context.id : null);
+    }
+
+    public void setPixelFormat (NSOpenGLPixelFormat pixelFormat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPixelFormat_1, pixelFormat !is null ? pixelFormat.id : null);
+    }
+
+    public void update ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_update);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOpenPanel.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOpenPanel;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSSavePanel;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSOpenPanel : NSSavePanel
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray URLs ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URLs);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool allowsMultipleSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsMultipleSelection) !is null;
+    }
+
+    public void beginForDirectory (NSString path, NSString name, NSArray fileTypes, id delegatee, objc.SEL didEndSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginForDirectory_1file_1types_1modelessDelegate_1didEndSelector_1contextInfo_1,
+                path !is null ? path.id : null, name !is null ? name.id : null, fileTypes !is null ? fileTypes.id : null,
+                delegatee !is null ? delegatee.id : null, didEndSelector, contextInfo);
+    }
+
+    public void beginSheetForDirectory (NSString path, NSString name, NSArray fileTypes, NSWindow docWindow, id delegatee, objc.SEL didEndSelector,
+            void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginSheetForDirectory_1file_1types_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1,
+                path !is null ? path.id : null, name !is null ? name.id : null, fileTypes !is null ? fileTypes.id : null,
+                docWindow !is null ? docWindow.id : null, delegatee !is null ? delegatee.id : null, didEndSelector, contextInfo);
+    }
+
+    public bool canChooseDirectories ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canChooseDirectories) !is null;
+    }
+
+    public bool canChooseFiles ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canChooseFiles) !is null;
+    }
+
+    public NSArray filenames ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_filenames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSOpenPanel openPanel ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSOpenPanel, OS.sel_openPanel);
+        return result !is null ? new NSOpenPanel(result) : null;
+    }
+
+    public bool resolvesAliases ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_resolvesAliases) !is null;
+    }
+
+    public NSInteger runModalForDirectory (NSString path, NSString name, NSArray fileTypes)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModalForDirectory_1file_1types_1, path !is null ? path.id : null, name !is null ? name.id : null,
+                fileTypes !is null ? fileTypes.id : null);
+    }
+
+    public NSInteger runModalForTypes (NSArray fileTypes)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModalForTypes_1, fileTypes !is null ? fileTypes.id : null);
+    }
+
+    public void setAllowsMultipleSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsMultipleSelection_1, flag);
+    }
+
+    public void setCanChooseDirectories (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanChooseDirectories_1, flag);
+    }
+
+    public void setCanChooseFiles (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanChooseFiles_1, flag);
+    }
+
+    public void setResolvesAliases (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setResolvesAliases_1, flag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOperation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOperation;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSInteger NSOperationQueuePriority;
+
+enum
+{
+    NSOperationQueuePriorityVeryLow = -8,
+    NSOperationQueuePriorityLow = -4,
+    NSOperationQueuePriorityNormal = 0,
+    NSOperationQueuePriorityHigh = 4,
+    NSOperationQueuePriorityVeryHigh = 8
+}
+
+public class NSOperation : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addDependency (NSOperation op)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addDependency_1, op !is null ? op.id : null);
+    }
+
+    public void cancel ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancel);
+    }
+
+    public NSArray dependencies ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dependencies);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool isCancelled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isCancelled) !is null;
+    }
+
+    public bool isConcurrent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isConcurrent) !is null;
+    }
+
+    public bool isExecuting ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExecuting) !is null;
+    }
+
+    public bool isFinished ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFinished) !is null;
+    }
+
+    public bool isReady ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isReady) !is null;
+    }
+
+    public void main ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_main);
+    }
+
+    public NSOperationQueuePriority queuePriority ()
+    {
+        return cast(NSOperationQueuePriority) OS.objc_msgSend(this.id, OS.sel_queuePriority);
+    }
+
+    public void removeDependency (NSOperation op)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeDependency_1, op !is null ? op.id : null);
+    }
+
+    public void setQueuePriority (NSOperationQueuePriority p)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setQueuePriority_1, p);
+    }
+
+    public void start ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_start);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOperationQueue.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOperationQueue;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSOperationQueue : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addOperation (NSOperation op)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addOperation_1, op !is null ? op.id : null);
+    }
+
+    public void cancelAllOperations ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelAllOperations);
+    }
+
+    public bool isSuspended ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSuspended) !is null;
+    }
+
+    public NSInteger maxConcurrentOperationCount ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_maxConcurrentOperationCount);
+    }
+
+    public NSArray operations ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_operations);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setMaxConcurrentOperationCount (NSInteger cnt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxConcurrentOperationCount_1, cnt);
+    }
+
+    public void setSuspended (bool b)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSuspended_1, b);
+    }
+
+    public void waitUntilAllOperationsAreFinished ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_waitUntilAllOperationsAreFinished);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOutlineView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOutlineView;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSTableColumn;
+import dwt.internal.cocoa.NSTableView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSOutlineView : NSTableView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool autoresizesOutlineColumn ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoresizesOutlineColumn) !is null;
+    }
+
+    public bool autosaveExpandedItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autosaveExpandedItems) !is null;
+    }
+
+    public void collapseItem_ (id item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_collapseItem_1, item !is null ? item.id : null);
+    }
+
+    public void collapseItem_collapseChildren_ (id item, bool collapseChildren)
+    {
+        OS.objc_msgSend(this.id, OS.sel_collapseItem_1collapseChildren_1, item !is null ? item.id : null, collapseChildren);
+    }
+
+    public void expandItem_ (id item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_expandItem_1, item !is null ? item.id : null);
+    }
+
+    public void expandItem_expandChildren_ (id item, bool expandChildren)
+    {
+        OS.objc_msgSend(this.id, OS.sel_expandItem_1expandChildren_1, item !is null ? item.id : null, expandChildren);
+    }
+
+    public NSRect frameOfOutlineCellAtRow (NSInteger row)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frameOfOutlineCellAtRow_1, row);
+        return result;
+    }
+
+    public bool indentationMarkerFollowsCell ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indentationMarkerFollowsCell) !is null;
+    }
+
+    public CGFloat indentationPerLevel ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_indentationPerLevel);
+    }
+
+    public bool isExpandable (id item)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExpandable_1, item !is null ? item.id : null) !is null;
+    }
+
+    public bool isItemExpanded (id item)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isItemExpanded_1, item !is null ? item.id : null) !is null;
+    }
+
+    public id itemAtRow (NSInteger row)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtRow_1, row);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger levelForItem (id item)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_levelForItem_1, item !is null ? item.id : null);
+    }
+
+    public NSInteger levelForRow (NSInteger row)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_levelForRow_1, row);
+    }
+
+    public NSTableColumn outlineTableColumn ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_outlineTableColumn);
+        return result !is null ? new NSTableColumn(result) : null;
+    }
+
+    public id parentForItem (id item)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parentForItem_1, item !is null ? item.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void reloadItem_ (id item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadItem_1, item !is null ? item.id : null);
+    }
+
+    public void reloadItem_reloadChildren_ (id item, bool reloadChildren)
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadItem_1reloadChildren_1, item !is null ? item.id : null, reloadChildren);
+    }
+
+    public NSInteger rowForItem (id item)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_rowForItem_1, item !is null ? item.id : null);
+    }
+
+    public void setAutoresizesOutlineColumn (bool resize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoresizesOutlineColumn_1, resize);
+    }
+
+    public void setAutosaveExpandedItems (bool save)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosaveExpandedItems_1, save);
+    }
+
+    public void setDropItem (id item, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDropItem_1dropChildIndex_1, item !is null ? item.id : null, index);
+    }
+
+    public void setIndentationMarkerFollowsCell (bool drawInCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIndentationMarkerFollowsCell_1, drawInCell);
+    }
+
+    public void setIndentationPerLevel (CGFloat indentationPerLevel)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIndentationPerLevel_1, indentationPerLevel);
+    }
+
+    public void setOutlineTableColumn (NSTableColumn outlineTableColumn)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOutlineTableColumn_1, outlineTableColumn !is null ? outlineTableColumn.id : null);
+    }
+
+    public bool shouldCollapseAutoExpandedItemsForDeposited (bool deposited)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldCollapseAutoExpandedItemsForDeposited_1, deposited) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOutputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOutputStream;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSStream;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSOutputStream : NSStream
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool hasSpaceAvailable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasSpaceAvailable) !is null;
+    }
+
+    public NSOutputStream initToBuffer (ubyte* buffer, NSUInteger capacity)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initToBuffer_1capacity_1, buffer, capacity);
+        return result !is null ? this : null;
+    }
+
+    public NSOutputStream initToFileAtPath (NSString path, bool shouldAppend)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initToFileAtPath_1append_1, path !is null ? path.id : null, shouldAppend);
+        return result !is null ? this : null;
+    }
+
+    public NSOutputStream initToMemory ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initToMemory);
+        return result !is null ? this : null;
+    }
+
+    public static id outputStreamToBuffer (ubyte* buffer, NSUInteger capacity)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSOutputStream, OS.sel_outputStreamToBuffer_1capacity_1, buffer, capacity);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id outputStreamToFileAtPath (NSString path, bool shouldAppend)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSOutputStream, OS.sel_outputStreamToFileAtPath_1append_1, path !is null ? path.id : null,
+                shouldAppend);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id outputStreamToMemory ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSOutputStream, OS.sel_outputStreamToMemory);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger write (/*const*/ubyte* buffer, NSUInteger len)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_write_1maxLength_1, buffer, len);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPDFImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPDFImageRep;
+
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPDFImageRep : NSImageRep
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData PDFRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_PDFRepresentation);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSRect bounds ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_bounds);
+        return result;
+    }
+
+    public NSInteger currentPage ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_currentPage);
+    }
+
+    public static id imageRepWithData (NSData pdfData)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPDFImageRep, OS.sel_imageRepWithData_1, pdfData !is null ? pdfData.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSPDFImageRep initWithData (NSData pdfData)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, pdfData !is null ? pdfData.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSInteger pageCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pageCount);
+    }
+
+    public void setCurrentPage (NSInteger page)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrentPage_1, page);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPICTImageRep.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPICTImageRep;
+
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSImageRep;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPICTImageRep : NSImageRep
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData PICTRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_PICTRepresentation);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSRect boundingBox ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundingBox);
+        return result;
+    }
+
+    public static id imageRepWithData (NSData pictData)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPICTImageRep, OS.sel_imageRepWithData_1, pictData !is null ? pictData.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSPICTImageRep initWithData (NSData pictData)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, pictData !is null ? pictData.id : null);
+        return result !is null ? this : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPageLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPageLayout;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPageLayout;
+import dwt.internal.cocoa.NSPrintInfo;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSViewController;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPageLayout : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray accessoryControllers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryControllers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public void addAccessoryController (NSViewController accessoryController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addAccessoryController_1, accessoryController !is null ? accessoryController.id : null);
+    }
+
+    public void beginSheetWithPrintInfo (NSPrintInfo printInfo, NSWindow docWindow, id delegatee, objc.SEL didEndSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginSheetWithPrintInfo_1modalForWindow_1delegate_1didEndSelector_1contextInfo_1,
+                printInfo !is null ? printInfo.id : null, docWindow !is null ? docWindow.id : null, delegatee !is null ? delegatee.id : null,
+                didEndSelector, contextInfo);
+    }
+
+    public static NSPageLayout pageLayout ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPageLayout, OS.sel_pageLayout);
+        return result !is null ? new NSPageLayout(result) : null;
+    }
+
+    public NSPrintInfo printInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printInfo);
+        return result !is null ? new NSPrintInfo(result) : null;
+    }
+
+    public void readPrintInfo ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_readPrintInfo);
+    }
+
+    public void removeAccessoryController (NSViewController accessoryController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAccessoryController_1, accessoryController !is null ? accessoryController.id : null);
+    }
+
+    public NSInteger runModal ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModal);
+    }
+
+    public NSInteger runModalWithPrintInfo (NSPrintInfo printInfo)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModalWithPrintInfo_1, printInfo !is null ? printInfo.id : null);
+    }
+
+    public void setAccessoryView (NSView accessoryView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, accessoryView !is null ? accessoryView.id : null);
+    }
+
+    public void writePrintInfo ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_writePrintInfo);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPanel.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPanel;
+
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPanel : NSWindow
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool becomesKeyOnlyIfNeeded ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_becomesKeyOnlyIfNeeded) !is null;
+    }
+
+    public bool isFloatingPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFloatingPanel) !is null;
+    }
+
+    public void setBecomesKeyOnlyIfNeeded (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBecomesKeyOnlyIfNeeded_1, flag);
+    }
+
+    public void setFloatingPanel (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloatingPanel_1, flag);
+    }
+
+    public void setWorksWhenModal (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWorksWhenModal_1, flag);
+    }
+
+    public bool worksWhenModal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_worksWhenModal) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSParagraphStyle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSParagraphStyle;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText : NSTextAlignment;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSLineBreakMode
+{
+    NSLineBreakByWordWrapping = 0,
+    NSLineBreakByCharWrapping,
+    NSLineBreakByClipping,
+    NSLineBreakByTruncatingHead,
+    NSLineBreakByTruncatingTail,
+    NSLineBreakByTruncatingMiddle
+}
+
+alias NSLineBreakMode.NSLineBreakByWordWrapping NSLineBreakByWordWrapping;
+alias NSLineBreakMode.NSLineBreakByCharWrapping NSLineBreakByCharWrapping;
+alias NSLineBreakMode.NSLineBreakByClipping NSLineBreakByClipping;
+alias NSLineBreakMode.NSLineBreakByTruncatingHead NSLineBreakByTruncatingHead;
+alias NSLineBreakMode.NSLineBreakByTruncatingTail NSLineBreakByTruncatingTail;
+alias NSLineBreakMode.NSLineBreakByTruncatingMiddle NSLineBreakByTruncatingMiddle;
+
+public class NSParagraphStyle : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTextAlignment alignment ()
+    {
+        return cast(NSTextAlignment) OS.objc_msgSend(this.id, OS.sel_alignment);
+    }
+
+    public NSWritingDirection baseWritingDirection ()
+    {
+        return cast(NSWritingDirection) OS.objc_msgSend(this.id, OS.sel_baseWritingDirection);
+    }
+
+    public static NSParagraphStyle defaultParagraphStyle ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSParagraphStyle, OS.sel_defaultParagraphStyle);
+        return result !is null ? new NSParagraphStyle(result) : null;
+    }
+
+    public CGFloat defaultTabInterval ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_defaultTabInterval);
+    }
+
+    public static NSWritingDirection defaultWritingDirectionForLanguage (NSString languageName)
+    {
+        return cast(NSWritingDirection) OS.objc_msgSend(OS.class_NSParagraphStyle, OS.sel_defaultWritingDirectionForLanguage_1,
+                languageName !is null ? languageName.id : null);
+    }
+
+    public CGFloat firstLineHeadIndent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_firstLineHeadIndent);
+    }
+
+    public CGFloat headIndent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_headIndent);
+    }
+
+    public NSInteger headerLevel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_headerLevel);
+    }
+
+    public float hyphenationFactor ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_hyphenationFactor);
+    }
+
+    public NSLineBreakMode lineBreakMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lineBreakMode);
+    }
+
+    public CGFloat lineHeightMultiple ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineHeightMultiple);
+    }
+
+    public CGFloat lineSpacing ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineSpacing);
+    }
+
+    public CGFloat maximumLineHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_maximumLineHeight);
+    }
+
+    public CGFloat minimumLineHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_minimumLineHeight);
+    }
+
+    public CGFloat paragraphSpacing ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_paragraphSpacing);
+    }
+
+    public CGFloat paragraphSpacingBefore ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_paragraphSpacingBefore);
+    }
+
+    public NSArray tabStops ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tabStops);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public CGFloat tailIndent ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_tailIndent);
+    }
+
+    public NSArray textBlocks ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textBlocks);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray textLists ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textLists);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public float tighteningFactorForTruncation ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_tighteningFactorForTruncation);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPasteboard.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPasteboard;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSFileWrapper;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPasteboard : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger addTypes (NSArray newTypes, id newOwner)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_addTypes_1owner_1, newTypes !is null ? newTypes.id : null, newOwner !is null ? newOwner.id : null);
+    }
+
+    public NSString availableTypeFromArray (NSArray types)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableTypeFromArray_1, types !is null ? types.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger changeCount ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_changeCount);
+    }
+
+    public NSData dataForType (NSString dataType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataForType_1, dataType !is null ? dataType.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSInteger declareTypes (NSArray newTypes, id newOwner)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_declareTypes_1owner_1, newTypes !is null ? newTypes.id : null, newOwner !is null ? newOwner.id : null);
+    }
+
+    public static NSPasteboard generalPasteboard ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_generalPasteboard);
+        return result !is null ? new NSPasteboard(result) : null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSPasteboard pasteboardByFilteringData (NSData data, NSString type)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringData_1ofType_1, data !is null ? data.id : null,
+                type !is null ? type.id : null);
+        return result !is null ? new NSPasteboard(result) : null;
+    }
+
+    public static NSPasteboard pasteboardByFilteringFile (NSString filename)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringFile_1, filename !is null ? filename.id : null);
+        return result !is null ? new NSPasteboard(result) : null;
+    }
+
+    public static NSPasteboard pasteboardByFilteringTypesInPasteboard (NSPasteboard pboard)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringTypesInPasteboard_1, pboard !is null ? pboard.id : null);
+        return result !is null ? new NSPasteboard(result) : null;
+    }
+
+    public static NSPasteboard pasteboardWithName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardWithName_1, name !is null ? name.id : null);
+        return result !is null ? new NSPasteboard(result) : null;
+    }
+
+    public static NSPasteboard pasteboardWithUniqueName ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardWithUniqueName);
+        return result !is null ? new NSPasteboard(result) : null;
+    }
+
+    public id propertyListForType (NSString dataType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyListForType_1, dataType !is null ? dataType.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString readFileContentsType (NSString type, NSString filename)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_readFileContentsType_1toFile_1, type !is null ? type.id : null,
+                filename !is null ? filename.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSFileWrapper readFileWrapper ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_readFileWrapper);
+        return result !is null ? new NSFileWrapper(result) : null;
+    }
+
+    public void releaseGlobally ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_releaseGlobally);
+    }
+
+    public bool setData (NSData data, NSString dataType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setData_1forType_1, data !is null ? data.id : null, dataType !is null ? dataType.id : null) !is null;
+    }
+
+    public bool setPropertyList (id plist, NSString dataType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setPropertyList_1forType_1, plist !is null ? plist.id : null, dataType !is null ? dataType.id : null) !is null;
+    }
+
+    public bool setString (NSString string, NSString dataType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setString_1forType_1, string !is null ? string.id : null, dataType !is null ? dataType.id : null) !is null;
+    }
+
+    public NSString stringForType (NSString dataType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringForType_1, dataType !is null ? dataType.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray types ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_types);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray typesFilterableTo (NSString type)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_typesFilterableTo_1, type !is null ? type.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool writeFileContents (NSString filename)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeFileContents_1, filename !is null ? filename.id : null) !is null;
+    }
+
+    public bool writeFileWrapper (NSFileWrapper wrapper)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeFileWrapper_1, wrapper !is null ? wrapper.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPathCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPathCell;
+
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSCell : NSControlSize;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPathComponentCell;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum
+{
+    NSPathStyleStandard,
+    NSPathStyleNavigationBar,
+    NSPathStylePopUp,
+}
+
+alias NSInteger NSPathStyle;
+
+public class NSPathCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSURL URL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public NSArray allowedTypes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allowedTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSPathComponentCell clickedPathComponentCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_clickedPathComponentCell);
+        return result !is null ? new NSPathComponentCell(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.SEL doubleAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_doubleAction);
+    }
+
+    public void mouseEntered (NSEvent event, NSRect frame, NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseEntered_1withFrame_1inView_1, event !is null ? event.id : null, frame, view !is null ? view.id : null);
+    }
+
+    public void mouseExited (NSEvent event, NSRect frame, NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseExited_1withFrame_1inView_1, event !is null ? event.id : null, frame, view !is null ? view.id : null);
+    }
+
+    public NSPathComponentCell pathComponentCellAtPoint (NSPoint point, NSRect frame, NSView view)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathComponentCellAtPoint_1withFrame_1inView_1, point, frame, view !is null ? view.id : null);
+        return result !is null ? new NSPathComponentCell(result) : null;
+    }
+
+    public static objc.Class pathComponentCellClass ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(OS.class_NSPathCell, OS.sel_pathComponentCellClass);
+    }
+
+    public NSArray pathComponentCells ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathComponentCells);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSPathStyle pathStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pathStyle);
+    }
+
+    public NSAttributedString placeholderAttributedString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_placeholderAttributedString);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSString placeholderString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_placeholderString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSRect rectOfPathComponentCell (NSPathComponentCell cell, NSRect frame, NSView view)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfPathComponentCell_1withFrame_1inView_1, cell !is null ? cell.id : null, frame,
+                view !is null ? view.id : null);
+        return result;
+    }
+
+    public void setAllowedTypes (NSArray allowedTypes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowedTypes_1, allowedTypes !is null ? allowedTypes.id : null);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setControlSize (NSControlSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlSize_1, size);
+    }
+
+    public void setDelegate (id value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, value !is null ? value.id : null);
+    }
+
+    public void setDoubleAction (objc.SEL action)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleAction_1, action);
+    }
+
+    public void setObjectValue (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectValue_1, obj !is null ? obj.id : null);
+    }
+
+    public void setPathComponentCells (NSArray cells)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPathComponentCells_1, cells !is null ? cells.id : null);
+    }
+
+    public void setPathStyle (NSPathStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPathStyle_1, style);
+    }
+
+    public void setPlaceholderAttributedString (NSAttributedString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaceholderAttributedString_1, string !is null ? string.id : null);
+    }
+
+    public void setPlaceholderString (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaceholderString_1, string !is null ? string.id : null);
+    }
+
+    public void setURL (NSURL url)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setURL_1, url !is null ? url.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPathComponentCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPathComponentCell;
+
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPathComponentCell : NSTextFieldCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSURL URL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public void setImage (NSImage value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, value !is null ? value.id : null);
+    }
+
+    public void setURL (NSURL url)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setURL_1, url !is null ? url.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPathControl.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPathControl;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSDragOperation;
+import dwt.internal.cocoa.NSPathCell : NSPathStyle;
+import dwt.internal.cocoa.NSPathComponentCell;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPathControl : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSURL URL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSPathComponentCell clickedPathComponentCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_clickedPathComponentCell);
+        return result !is null ? new NSPathComponentCell(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.SEL doubleAction ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_doubleAction);
+    }
+
+    public NSArray pathComponentCells ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathComponentCells);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSPathStyle pathStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pathStyle);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDoubleAction (objc.SEL action)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleAction_1, action);
+    }
+
+    public void setDraggingSourceOperationMask (NSDragOperation mask, bool isLocal)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDraggingSourceOperationMask_1forLocal_1, mask, isLocal);
+    }
+
+    public void setPathComponentCells (NSArray cells)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPathComponentCells_1, cells !is null ? cells.id : null);
+    }
+
+    public void setPathStyle (NSPathStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPathStyle_1, style);
+    }
+
+    public void setURL (NSURL url)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setURL_1, url !is null ? url.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPersistentDocument.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPersistentDocument;
+
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSDocument;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPersistentDocument : NSDocument
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool configurePersistentStoreCoordinatorForURL_ofType_error_ (NSURL url, NSString fileType, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_configurePersistentStoreCoordinatorForURL_1ofType_1error_1, url !is null ? url.id : null,
+                fileType !is null ? fileType.id : null, error) !is null;
+    }
+
+    public bool configurePersistentStoreCoordinatorForURL_ofType_modelConfiguration_storeOptions_error_ (NSURL url, NSString fileType,
+            NSString configuration, NSDictionary storeOptions, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_configurePersistentStoreCoordinatorForURL_1ofType_1modelConfiguration_1storeOptions_1error_1,
+                url !is null ? url.id : null, fileType !is null ? fileType.id : null, configuration !is null ? configuration.id : null,
+                storeOptions !is null ? storeOptions.id : null, error) !is null;
+    }
+
+    //public NSManagedObjectContext managedObjectContext() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_managedObjectContext);
+    //  return result !is null ? new NSManagedObjectContext(result) : null;
+    //}
+
+    public id managedObjectModel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_managedObjectModel);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString persistentStoreTypeForFileType (NSString fileType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_persistentStoreTypeForFileType_1, fileType !is null ? fileType.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool readFromURL (NSURL absoluteURL, NSString typeName, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readFromURL_1ofType_1error_1, absoluteURL !is null ? absoluteURL.id : null,
+                typeName !is null ? typeName.id : null, error) !is null;
+    }
+
+    public bool revertToContentsOfURL (NSURL inAbsoluteURL, NSString inTypeName, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_revertToContentsOfURL_1ofType_1error_1, inAbsoluteURL !is null ? inAbsoluteURL.id : null,
+                inTypeName !is null ? inTypeName.id : null, outError) !is null;
+    }
+
+    //public void setManagedObjectContext(NSManagedObjectContext managedObjectContext) {
+    //  OS.objc_msgSend(this.id, OS.sel_setManagedObjectContext_1, managedObjectContext !is null ? managedObjectContext.id : null);
+    //}
+
+    public bool writeToURL (NSURL absoluteURL, NSString typeName, NSSaveOperationType saveOperation, NSURL absoluteOriginalContentsURL, objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1ofType_1forSaveOperation_1originalContentsURL_1error_1,
+                absoluteURL !is null ? absoluteURL.id : null, typeName !is null ? typeName.id : null, saveOperation,
+                absoluteOriginalContentsURL !is null ? absoluteOriginalContentsURL.id : null, error) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPipe.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPipe;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSFileHandle;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPipe : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSFileHandle fileHandleForReading ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileHandleForReading);
+        return result !is null ? new NSFileHandle(result) : null;
+    }
+
+    public NSFileHandle fileHandleForWriting ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileHandleForWriting);
+        return result !is null ? new NSFileHandle(result) : null;
+    }
+
+    public static id pipe ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPipe, OS.sel_pipe);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPoint.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPoint;
+
+import dwt.internal.cocoa.CGFloat;
+
+alias NSPoint* NSPointArray;
+alias NSPoint* NSPointPointer;
+
+public struct NSPoint {
+    public CGFloat x;
+    public CGFloat y;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPointerArray.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPointerArray;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPointerFunctions;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPointerArray : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addPointer (void* pointer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addPointer_1, pointer);
+    }
+
+    public NSArray allObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void compact ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_compact);
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public NSPointerArray initWithOptions (NSPointerFunctionsOptions options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithOptions_1, options);
+        return result !is null ? this : null;
+    }
+
+    public id initWithPointerFunctions (NSPointerFunctions functions)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPointerFunctions_1, functions !is null ? functions.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void insertPointer (void* item, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertPointer_1atIndex_1, item, index);
+    }
+
+    public static id pointerArrayWithOptions (NSPointerFunctionsOptions options)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPointerArray, OS.sel_pointerArrayWithOptions_1, options);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id pointerArrayWithPointerFunctions (NSPointerFunctions functions)
+    {
+        objc.id
+                result = OS.objc_msgSend(OS.class_NSPointerArray, OS.sel_pointerArrayWithPointerFunctions_1, functions !is null ? functions.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id pointerArrayWithStrongObjects ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPointerArray, OS.sel_pointerArrayWithStrongObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id pointerArrayWithWeakObjects ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPointerArray, OS.sel_pointerArrayWithWeakObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void* pointerAtIndex (NSUInteger index)
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_pointerAtIndex_1, index);
+    }
+
+    public NSPointerFunctions pointerFunctions ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pointerFunctions);
+        return result !is null ? new NSPointerFunctions(result) : null;
+    }
+
+    public void removePointerAtIndex (NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removePointerAtIndex_1, index);
+    }
+
+    public void replacePointerAtIndex (NSUInteger index, void* item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replacePointerAtIndex_1withPointer_1, index, item);
+    }
+
+    public void setCount (NSUInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCount_1, count);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPointerFunctions.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPointerFunctions;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+
+/*alias NSUInteger NSPointerFunctionsOptions;*/
+
+enum NSPointerFunctionsOptions : NSUInteger {
+    NSPointerFunctionsStrongMemory = (0 << 0),
+    NSPointerFunctionsZeroingWeakMemory = (1 << 0),
+    NSPointerFunctionsOpaqueMemory = (2 << 0),
+    NSPointerFunctionsMallocMemory = (3 << 0),
+    NSPointerFunctionsMachVirtualMemory = (4 << 0),
+    NSPointerFunctionsObjectPersonality = (0 << 8),
+    NSPointerFunctionsOpaquePersonality = (1 << 8),
+    NSPointerFunctionsObjectPointerPersonality = (2 << 8),
+    NSPointerFunctionsCStringPersonality = (3 << 8),
+    NSPointerFunctionsStructPersonality = (4 << 8),
+    NSPointerFunctionsIntegerPersonality = (5 << 8),
+    NSPointerFunctionsCopyIn = (1 << 16),
+}
+
+alias NSPointerFunctionsOptions.NSPointerFunctionsStrongMemory NSPointerFunctionsStrongMemory;
+alias NSPointerFunctionsOptions.NSPointerFunctionsZeroingWeakMemory NSPointerFunctionsZeroingWeakMemory;
+alias NSPointerFunctionsOptions.NSPointerFunctionsOpaqueMemory NSPointerFunctionsOpaqueMemory;
+alias NSPointerFunctionsOptions.NSPointerFunctionsMallocMemory NSPointerFunctionsMallocMemory;
+alias NSPointerFunctionsOptions.NSPointerFunctionsMachVirtualMemory NSPointerFunctionsMachVirtualMemory;
+alias NSPointerFunctionsOptions.NSPointerFunctionsObjectPersonality NSPointerFunctionsObjectPersonality;
+alias NSPointerFunctionsOptions.NSPointerFunctionsOpaquePersonality NSPointerFunctionsOpaquePersonality;
+alias NSPointerFunctionsOptions.NSPointerFunctionsObjectPointerPersonality NSPointerFunctionsObjectPointerPersonality;
+alias NSPointerFunctionsOptions.NSPointerFunctionsCStringPersonality NSPointerFunctionsCStringPersonality;
+alias NSPointerFunctionsOptions.NSPointerFunctionsStructPersonality NSPointerFunctionsStructPersonality;
+alias NSPointerFunctionsOptions.NSPointerFunctionsIntegerPersonality NSPointerFunctionsIntegerPersonality;
+alias NSPointerFunctionsOptions.NSPointerFunctionsCopyIn NSPointerFunctionsCopyIn;
+
+public class NSPointerFunctions : NSObject {
+
+    public this () {
+        super();
+    }
+
+    public this (objc.id id) {
+        super(id);
+    }
+
+    public NSPointerFunctions initWithOptions (NSPointerFunctionsOptions options) {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithOptions_1, options);
+        return result !is null ? this : null;
+    }
+
+    public static id pointerFunctionsWithOptions (NSPointerFunctionsOptions options) {
+        objc.id result = OS.objc_msgSend(OS.class_NSPointerFunctions, OS.sel_pointerFunctionsWithOptions_1, options);
+        return result !is null ? new id(result) : null;
+    }
+
+    //public void setUsesStrongWriteBarrier(bool ) {
+    //  OS.objc_msgSend(this.id, OS.sel_setUsesStrongWriteBarrier_1, );
+    //}
+    //
+    //public void setUsesWeakReadAndWriteBarriers(bool ) {
+    //  OS.objc_msgSend(this.id, OS.sel_setUsesWeakReadAndWriteBarriers_1, );
+    //}
+
+    public bool usesStrongWriteBarrier () {
+        return OS.objc_msgSend(this.id, OS.sel_usesStrongWriteBarrier) !is null;
+    }
+
+    public bool usesWeakReadAndWriteBarriers () {
+        return OS.objc_msgSend(this.id, OS.sel_usesWeakReadAndWriteBarriers) !is null;
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPopUpButton.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPopUpButton;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSButton;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPopUpButton : NSButton
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addItemWithTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public void addItemsWithTitles (NSArray itemTitles)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemsWithTitles_1, itemTitles !is null ? itemTitles.id : null);
+    }
+
+    public bool autoenablesItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoenablesItems) !is null;
+    }
+
+    public NSInteger indexOfItem (NSMenuItem item)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItem_1, item !is null ? item.id : null);
+    }
+
+    public NSInteger indexOfItemWithRepresentedObject (id obj)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithRepresentedObject_1, obj !is null ? obj.id : null);
+    }
+
+    public NSInteger indexOfItemWithTag (NSInteger tag)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTag_1, tag);
+    }
+
+    public NSInteger indexOfItemWithTarget (id target, objc.SEL actionSelector)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTarget_1andAction_1, target !is null ? target.id : null, actionSelector);
+    }
+
+    public NSInteger indexOfItemWithTitle (NSString title)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public NSInteger indexOfSelectedItem ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem);
+    }
+
+    public NSPopUpButton initWithFrame (NSRect buttonFrame, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1pullsDown_1, buttonFrame, flag);
+        return result !is null ? this : null;
+    }
+
+    public void insertItemWithTitle (NSString title, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertItemWithTitle_1atIndex_1, title !is null ? title.id : null, index);
+    }
+
+    public NSArray itemArray ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemArray);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSMenuItem itemAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtIndex_1, index);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSString itemTitleAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemTitleAtIndex_1, index);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray itemTitles ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemTitles);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSMenuItem itemWithTitle (NSString title)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTitle_1, title !is null ? title.id : null);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSMenuItem lastItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lastItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSMenu menu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSInteger numberOfItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfItems);
+    }
+
+    public NSRectEdge preferredEdge ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preferredEdge);
+    }
+
+    public bool pullsDown ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pullsDown) !is null;
+    }
+
+    public void removeAllItems ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllItems);
+    }
+
+    public void removeItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index);
+    }
+
+    public void removeItemWithTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public void selectItem (NSMenuItem item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItem_1, item !is null ? item.id : null);
+    }
+
+    public void selectItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_1, index);
+    }
+
+    public bool selectItemWithTag (NSInteger tag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectItemWithTag_1, tag) !is null;
+    }
+
+    public void selectItemWithTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public NSMenuItem selectedItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public void setAutoenablesItems (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoenablesItems_1, flag);
+    }
+
+    public void setMenu (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1, menu !is null ? menu.id : null);
+    }
+
+    public void setPreferredEdge (NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreferredEdge_1, edge);
+    }
+
+    public void setPullsDown (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPullsDown_1, flag);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void synchronizeTitleAndSelectedItem ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_synchronizeTitleAndSelectedItem);
+    }
+
+    public NSString titleOfSelectedItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleOfSelectedItem);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPopUpButtonCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPopUpButtonCell;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenuItemCell;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSPopUpArrowPosition
+{
+    NSPopUpNoArrow = 0,
+    NSPopUpArrowAtCenter = 1,
+    NSPopUpArrowAtBottom = 2
+}
+
+alias NSPopUpArrowPosition.NSPopUpNoArrow NSPopUpNoArrow;
+alias NSPopUpArrowPosition.NSPopUpArrowAtCenter NSPopUpArrowAtCenter;
+alias NSPopUpArrowPosition.NSPopUpArrowAtBottom NSPopUpArrowAtBottom;
+
+public class NSPopUpButtonCell : NSMenuItemCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addItemWithTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public void addItemsWithTitles (NSArray itemTitles)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addItemsWithTitles_1, itemTitles !is null ? itemTitles.id : null);
+    }
+
+    public bool altersStateOfSelectedItem ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_altersStateOfSelectedItem) !is null;
+    }
+
+    public NSPopUpArrowPosition arrowPosition ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_arrowPosition);
+    }
+
+    public void attachPopUpWithFrame (NSRect cellFrame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_attachPopUpWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id : null);
+    }
+
+    public bool autoenablesItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoenablesItems) !is null;
+    }
+
+    public void dismissPopUp ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_dismissPopUp);
+    }
+
+    public NSInteger indexOfItem (NSMenuItem item)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfItem_1, item !is null ? item.id : null);
+    }
+
+    public NSInteger indexOfItemWithRepresentedObject (id obj)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithRepresentedObject_1, obj !is null ? obj.id : null);
+    }
+
+    public NSInteger indexOfItemWithTag (NSInteger tag)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTag_1, tag);
+    }
+
+    public NSInteger indexOfItemWithTarget (id target, objc.SEL actionSelector)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTarget_1andAction_1, target !is null ? target.id : null, actionSelector);
+    }
+
+    public NSInteger indexOfItemWithTitle (NSString title)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public NSInteger indexOfSelectedItem ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem);
+    }
+
+    public NSPopUpButtonCell initTextCell (NSString stringValue, bool pullDown)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initTextCell_1pullsDown_1, stringValue !is null ? stringValue.id : null, pullDown);
+        return result !is null ? this : null;
+    }
+
+    public void insertItemWithTitle (NSString title, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertItemWithTitle_1atIndex_1, title !is null ? title.id : null, index);
+    }
+
+    public NSArray itemArray ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemArray);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSMenuItem itemAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtIndex_1, index);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSString itemTitleAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemTitleAtIndex_1, index);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray itemTitles ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemTitles);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSMenuItem itemWithTitle (NSString title)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTitle_1, title !is null ? title.id : null);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSMenuItem lastItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lastItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSMenu menu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSInteger numberOfItems ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_numberOfItems);
+    }
+
+    public id objectValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void performClickWithFrame (NSRect frame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performClickWithFrame_1inView_1, frame, controlView !is null ? controlView.id : null);
+    }
+
+    public NSRectEdge preferredEdge ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preferredEdge);
+    }
+
+    public bool pullsDown ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pullsDown) !is null;
+    }
+
+    public void removeAllItems ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllItems);
+    }
+
+    public void removeItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index);
+    }
+
+    public void removeItemWithTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public void selectItem (NSMenuItem item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItem_1, item !is null ? item.id : null);
+    }
+
+    public void selectItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_1, index);
+    }
+
+    public bool selectItemWithTag (NSInteger tag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectItemWithTag_1, tag) !is null;
+    }
+
+    public void selectItemWithTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectItemWithTitle_1, title !is null ? title.id : null);
+    }
+
+    public NSMenuItem selectedItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public void setAltersStateOfSelectedItem (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAltersStateOfSelectedItem_1, flag);
+    }
+
+    public void setArrowPosition (NSPopUpArrowPosition position)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setArrowPosition_1, position);
+    }
+
+    public void setAutoenablesItems (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoenablesItems_1, flag);
+    }
+
+    public void setMenu (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1, menu !is null ? menu.id : null);
+    }
+
+    public void setObjectValue (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectValue_1, obj !is null ? obj.id : null);
+    }
+
+    public void setPreferredEdge (NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreferredEdge_1, edge);
+    }
+
+    public void setPullsDown (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPullsDown_1, flag);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setUsesItemFromMenu (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesItemFromMenu_1, flag);
+    }
+
+    public void synchronizeTitleAndSelectedItem ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_synchronizeTitleAndSelectedItem);
+    }
+
+    public NSString titleOfSelectedItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleOfSelectedItem);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool usesItemFromMenu ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesItemFromMenu) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPort.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPort;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSConnection;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias int NSSocketNativeHandle;
+
+public class NSPort : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addConnection (NSConnection conn, NSRunLoop runLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addConnection_1toRunLoop_1forMode_1, conn !is null ? conn.id : null, runLoop !is null ? runLoop.id : null,
+                mode !is null ? mode.id : null);
+    }
+
+    public static id allocWithZone (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPort, OS.sel_allocWithZone_1, zone);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void invalidate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidate);
+    }
+
+    public bool isValid ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isValid) !is null;
+    }
+
+    public static NSPort port ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPort, OS.sel_port);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public void removeConnection (NSConnection conn, NSRunLoop runLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeConnection_1fromRunLoop_1forMode_1, conn !is null ? conn.id : null,
+                runLoop !is null ? runLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void removeFromRunLoop (NSRunLoop runLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFromRunLoop_1forMode_1, runLoop !is null ? runLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public NSUInteger reservedSpaceLength ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_reservedSpaceLength);
+    }
+
+    public void scheduleInRunLoop (NSRunLoop runLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scheduleInRunLoop_1forMode_1, runLoop !is null ? runLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public bool sendBeforeDate_components_from_reserved_ (NSDate limitDate, NSMutableArray components, NSPort receivePort, NSUInteger headerSpaceReserved)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendBeforeDate_1components_1from_1reserved_1, limitDate !is null ? limitDate.id : null,
+                components !is null ? components.id : null, receivePort !is null ? receivePort.id : null, headerSpaceReserved) !is null;
+    }
+
+    public bool sendBeforeDate_msgid_components_from_reserved_ (NSDate limitDate, NSUInteger msgID, NSMutableArray components, NSPort receivePort,
+                                                                NSUInteger headerSpaceReserved)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendBeforeDate_1msgid_1components_1from_1reserved_1, limitDate !is null ? limitDate.id : null, msgID,
+                components !is null ? components.id : null, receivePort !is null ? receivePort.id : null, headerSpaceReserved) !is null;
+    }
+
+    public void setDelegate (id anId)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anId !is null ? anId.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPortCoder.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPortCoder;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCoder;
+import dwt.internal.cocoa.NSConnection;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPortCoder : NSCoder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSConnection connection ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_connection);
+        return result !is null ? new NSConnection(result) : null;
+    }
+
+    public NSPort decodePortObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decodePortObject);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public void dispatch ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_dispatch);
+    }
+
+    public void encodePortObject (NSPort aport)
+    {
+        OS.objc_msgSend(this.id, OS.sel_encodePortObject_1, aport !is null ? aport.id : null);
+    }
+
+    public NSPortCoder initWithReceivePort (NSPort rcvPort, NSPort sndPort, NSArray comps)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithReceivePort_1sendPort_1components_1, rcvPort !is null ? rcvPort.id : null,
+                sndPort !is null ? sndPort.id : null, comps !is null ? comps.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isBycopy ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBycopy) !is null;
+    }
+
+    public bool isByref ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isByref) !is null;
+    }
+
+    public static id portCoderWithReceivePort (NSPort rcvPort, NSPort sndPort, NSArray comps)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPortCoder, OS.sel_portCoderWithReceivePort_1sendPort_1components_1,
+                rcvPort !is null ? rcvPort.id : null, sndPort !is null ? sndPort.id : null, comps !is null ? comps.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPortMessage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPortMessage;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPortMessage : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray components ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_components);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSPortMessage initWithSendPort (NSPort sendPort, NSPort replyPort, NSArray components)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSendPort_1receivePort_1components_1, sendPort !is null ? sendPort.id : null,
+                replyPort !is null ? replyPort.id : null, components !is null ? components.id : null);
+        return result !is null ? this : null;
+    }
+
+    public uint msgid ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_msgid);
+    }
+
+    public NSPort receivePort ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_receivePort);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public bool sendBeforeDate (NSDate date)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendBeforeDate_1, date !is null ? date.id : null) !is null;
+    }
+
+    public NSPort sendPort ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sendPort);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public void setMsgid (uint msgid)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMsgid_1, msgid);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPortNameServer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPortNameServer;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSPortNameServer;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPortNameServer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSPort portForName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public NSPort portForName_host_ (NSString name, NSString host)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1host_1, name !is null ? name.id : null, host !is null ? host.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public bool registerPort (NSPort port, NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_registerPort_1name_1, port !is null ? port.id : null, name !is null ? name.id : null) !is null;
+    }
+
+    public bool removePortForName (NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removePortForName_1, name !is null ? name.id : null) !is null;
+    }
+
+    public static NSPortNameServer systemDefaultPortNameServer ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPortNameServer, OS.sel_systemDefaultPortNameServer);
+        return result !is null ? new NSPortNameServer(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPositionalSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPositionalSpecifier;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSInsertionPosition
+{
+    NSPositionAfter,
+    NSPositionBefore,
+    NSPositionBeginning,
+    NSPositionEnd,
+    NSPositionReplace
+}
+
+alias NSInsertionPosition.NSPositionAfter NSPositionAfter;
+alias NSInsertionPosition.NSPositionBefore NSPositionBefore;
+alias NSInsertionPosition.NSPositionBeginning NSPositionBeginning;
+alias NSInsertionPosition.NSPositionEnd NSPositionEnd;
+alias NSInsertionPosition.NSPositionReplace NSPositionReplace;
+
+public class NSPositionalSpecifier : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void evaluate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_evaluate);
+    }
+
+    public NSPositionalSpecifier initWithPosition (NSInsertionPosition position, NSScriptObjectSpecifier specifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPosition_1objectSpecifier_1, position, specifier !is null ? specifier.id : null);
+        return result !is null ? this : null;
+    }
+
+    public id insertionContainer ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_insertionContainer);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger insertionIndex ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_insertionIndex);
+    }
+
+    public NSString insertionKey ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_insertionKey);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool insertionReplaces ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_insertionReplaces) !is null;
+    }
+
+    public NSScriptObjectSpecifier objectSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectSpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public NSInsertionPosition position ()
+    {
+        return cast(NSInsertionPosition) OS.objc_msgSend(this.id, OS.sel_position);
+    }
+
+    public void setInsertionClassDescription (NSScriptClassDescription classDescription)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInsertionClassDescription_1, classDescription !is null ? classDescription.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPredicate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPredicate;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPredicate : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool evaluateWithObject_ (id object)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_evaluateWithObject_1, object !is null ? object.id : null) !is null;
+    }
+
+    public bool evaluateWithObject_substitutionVariables_ (id object, NSDictionary bindings)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_evaluateWithObject_1substitutionVariables_1, object !is null ? object.id : null,
+                bindings !is null ? bindings.id : null) !is null;
+    }
+
+    public NSString predicateFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_predicateFormat);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSPredicate static_predicateWithFormat_ (NSString predicateWithFormat)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithFormat_1,
+                predicateWithFormat !is null ? predicateWithFormat.id : null);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public static NSPredicate static_predicateWithFormat_argumentArray_ (NSString predicateFormat, NSArray arguments)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithFormat_1argumentArray_1,
+                predicateFormat !is null ? predicateFormat.id : null, arguments !is null ? arguments.id : null);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public static NSPredicate static_predicateWithFormat_arguments_ (NSString predicateFormat, ...)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithFormat_1arguments_1,
+                predicateFormat !is null ? predicateFormat.id : null, _argptr);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public NSPredicate predicateWithSubstitutionVariables (NSDictionary variables)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_predicateWithSubstitutionVariables_1, variables !is null ? variables.id : null);
+        return result is this.id ? this : (result !is null ? new NSPredicate(result) : null);
+    }
+
+    public static NSPredicate predicateWithValue (bool value)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithValue_1, value);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPredicateEditor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPredicateEditor;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSRuleEditor;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPredicateEditor : NSRuleEditor
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray rowTemplates ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rowTemplates);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setRowTemplates (NSArray rowTemplates)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRowTemplates_1, rowTemplates !is null ? rowTemplates.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPredicateEditorRowTemplate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPredicateEditorRowTemplate;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAttributeType;
+import dwt.internal.cocoa.NSComparisonPredicate : NSComparisonPredicateModifier;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSPredicateEditorRowTemplate : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray compoundTypes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_compoundTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray displayableSubpredicatesOfPredicate (NSPredicate predicate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayableSubpredicatesOfPredicate_1, predicate !is null ? predicate.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id initWithCompoundTypes (NSArray compoundTypes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCompoundTypes_1, compoundTypes !is null ? compoundTypes.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithLeftExpressions_rightExpressionAttributeType_modifier_operators_options_ (NSArray leftExpressions,
+            NSAttributeType attributeType, NSComparisonPredicateModifier modifier, NSArray operators, NSUInteger options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLeftExpressions_1rightExpressionAttributeType_1modifier_1operators_1options_1,
+                leftExpressions !is null ? leftExpressions.id : null, attributeType, modifier, operators !is null ? operators.id : null, options);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithLeftExpressions_rightExpressions_modifier_operators_options_ (NSArray leftExpressions, NSArray rightExpressions, NSComparisonPredicateModifier modifier,
+            NSArray operators, NSUInteger options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLeftExpressions_1rightExpressions_1modifier_1operators_1options_1,
+                leftExpressions !is null ? leftExpressions.id : null, rightExpressions !is null ? rightExpressions.id : null, modifier,
+                operators !is null ? operators.id : null, options);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray leftExpressions ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_leftExpressions);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public double matchForPredicate (NSPredicate predicate)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_matchForPredicate_1, predicate !is null ? predicate.id : null);
+    }
+
+    public NSComparisonPredicateModifier modifier ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_modifier);
+    }
+
+    public NSArray operators ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_operators);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSUInteger options ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_options);
+    }
+
+    public NSPredicate predicateWithSubpredicates (NSArray subpredicates)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_predicateWithSubpredicates_1, subpredicates !is null ? subpredicates.id : null);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public NSAttributeType rightExpressionAttributeType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rightExpressionAttributeType);
+    }
+
+    public NSArray rightExpressions ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rightExpressions);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setPredicate (NSPredicate predicate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPredicate_1, predicate !is null ? predicate.id : null);
+    }
+
+    public NSArray templateViews ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_templateViews);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+//public static NSArray templatesWithAttributeKeyPaths(NSArray keyPaths, NSEntityDescription entityDescription) {
+//  objc.id result = OS.objc_msgSend(OS.class_NSPredicateEditorRowTemplate, OS.sel_templatesWithAttributeKeyPaths_1inEntityDescription_1, keyPaths !is null ? keyPaths.id : null, entityDescription !is null ? entityDescription.id : null);
+//  return result !is null ? new NSArray(result) : null;
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPrintInfo.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,297 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPrintInfo;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPrinter;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSPrintingPaginationMod
+{
+    NSAutoPagination = 0,
+    NSFitPagination = 1,
+    NSClipPagination = 2
+}
+
+alias NSPrintingPaginationMod.NSAutoPagination NSAutoPagination;
+alias NSPrintingPaginationMod.NSFitPagination NSFitPagination;
+alias NSPrintingPaginationMod.NSClipPagination NSClipPagination;
+
+enum NSPrintingOrientation
+{
+    NSPortraitOrientation = 0,
+    NSLandscapeOrientation = 1
+}
+
+alias NSPrintingOrientation.NSPortraitOrientation NSPortraitOrientation;
+alias NSPrintingOrientation.NSLandscapeOrientation NSLandscapeOrientation;
+
+enum NSPrintingPaginationMode
+{
+    NSAutoPagination = 0,
+    NSFitPagination = 1,
+    NSClipPagination = 2
+}
+
+alias NSPrintingPaginationMode.NSAutoPagination NSAutoPagination;
+alias NSPrintingPaginationMode.NSFitPagination NSFitPagination;
+alias NSPrintingPaginationMode.NSClipPagination NSClipPagination;
+
+public class NSPrintInfo : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void* PMPageFormat ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_PMPageFormat);
+    }
+
+    public void* PMPrintSession ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_PMPrintSession);
+    }
+
+    public void* PMPrintSettings ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_PMPrintSettings);
+    }
+
+    public CGFloat bottomMargin ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_bottomMargin);
+    }
+
+    public static NSPrinter defaultPrinter ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintInfo, OS.sel_defaultPrinter);
+        return result !is null ? new NSPrinter(result) : null;
+    }
+
+    public NSMutableDictionary dictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dictionary);
+        return result !is null ? new NSMutableDictionary(result) : null;
+    }
+
+    public NSPrintingPaginationMode horizontalPagination ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_horizontalPagination);
+    }
+
+    public NSRect imageablePageBounds ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_imageablePageBounds);
+        return result;
+    }
+
+    public id initWithDictionary (NSDictionary attributes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDictionary_1, attributes !is null ? attributes.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isHorizontallyCentered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHorizontallyCentered) !is null;
+    }
+
+    public bool isVerticallyCentered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isVerticallyCentered) !is null;
+    }
+
+    public NSString jobDisposition ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_jobDisposition);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public CGFloat leftMargin ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_leftMargin);
+    }
+
+    public NSString localizedPaperName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedPaperName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSPrintingOrientation orientation ()
+    {
+        return cast(NSPrintingOrientation) OS.objc_msgSend(this.id, OS.sel_orientation);
+    }
+
+    public NSString paperName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_paperName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSSize paperSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_paperSize);
+        return result;
+    }
+
+    public NSMutableDictionary printSettings ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printSettings);
+        return result !is null ? new NSMutableDictionary(result) : null;
+    }
+
+    public NSPrinter printer ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printer);
+        return result !is null ? new NSPrinter(result) : null;
+    }
+
+    public CGFloat rightMargin ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_rightMargin);
+    }
+
+    public void setBottomMargin (CGFloat margin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBottomMargin_1, margin);
+    }
+
+    public static void setDefaultPrinter (NSPrinter printer)
+    {
+        OS.objc_msgSend(OS.class_NSPrintInfo, OS.sel_setDefaultPrinter_1, printer !is null ? printer.id : null);
+    }
+
+    public void setHorizontalPagination (NSPrintingPaginationMode mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontalPagination_1, mode);
+    }
+
+    public void setHorizontallyCentered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontallyCentered_1, flag);
+    }
+
+    public void setJobDisposition (NSString disposition)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setJobDisposition_1, disposition !is null ? disposition.id : null);
+    }
+
+    public void setLeftMargin (CGFloat margin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLeftMargin_1, margin);
+    }
+
+    public void setOrientation (NSPrintingOrientation orientation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOrientation_1, orientation);
+    }
+
+    public void setPaperName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPaperName_1, name !is null ? name.id : null);
+    }
+
+    public void setPaperSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPaperSize_1, size);
+    }
+
+    public void setPrinter (NSPrinter printer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrinter_1, printer !is null ? printer.id : null);
+    }
+
+    public void setRightMargin (CGFloat margin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRightMargin_1, margin);
+    }
+
+    public static void setSharedPrintInfo (NSPrintInfo printInfo)
+    {
+        OS.objc_msgSend(OS.class_NSPrintInfo, OS.sel_setSharedPrintInfo_1, printInfo !is null ? printInfo.id : null);
+    }
+
+    public void setTopMargin (CGFloat margin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTopMargin_1, margin);
+    }
+
+    public void setUpPrintOperationDefaultValues ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUpPrintOperationDefaultValues);
+    }
+
+    public void setVerticalPagination (NSPrintingPaginationMode mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticalPagination_1, mode);
+    }
+
+    public void setVerticallyCentered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticallyCentered_1, flag);
+    }
+
+    public static NSPrintInfo sharedPrintInfo ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintInfo, OS.sel_sharedPrintInfo);
+        return result !is null ? new NSPrintInfo(result) : null;
+    }
+
+    public static NSSize sizeForPaperName (NSString name)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, OS.class_NSPrintInfo, OS.sel_sizeForPaperName_1, name !is null ? name.id : null);
+        return result;
+    }
+
+    public CGFloat topMargin ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_topMargin);
+    }
+
+    public void updateFromPMPageFormat ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateFromPMPageFormat);
+    }
+
+    public void updateFromPMPrintSettings ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateFromPMPrintSettings);
+    }
+
+    public NSPrintingPaginationMode verticalPagination ()
+    {
+        return cast(NSPrintingPaginationMode) OS.objc_msgSend(this.id, OS.sel_verticalPagination);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPrintOperation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPrintOperation;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMutableData;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPrintInfo;
+import dwt.internal.cocoa.NSPrintPanel;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSPrintingPageOrder
+{
+    NSDescendingPageOrder = (-1),
+    NSSpecialPageOrder = 0,
+    NSAscendingPageOrder = 1,
+    NSUnknownPageOrder = 2
+}
+
+alias NSPrintingPageOrder.NSDescendingPageOrder NSDescendingPageOrder;
+alias NSPrintingPageOrder.NSSpecialPageOrder NSSpecialPageOrder;
+alias NSPrintingPageOrder.NSAscendingPageOrder NSAscendingPageOrder;
+alias NSPrintingPageOrder.NSUnknownPageOrder NSUnknownPageOrder;
+
+public class NSPrintOperation : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSPrintOperation static_EPSOperationWithView_insideRect_toData_ (NSView view, NSRect rect, NSMutableData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_EPSOperationWithView_1insideRect_1toData_1,
+                view !is null ? view.id : null, rect, data !is null ? data.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public static NSPrintOperation static_EPSOperationWithView_insideRect_toData_printInfo_ (NSView view, NSRect rect, NSMutableData data,
+            NSPrintInfo printInfo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_EPSOperationWithView_1insideRect_1toData_1printInfo_1,
+                view !is null ? view.id : null, rect, data !is null ? data.id : null, printInfo !is null ? printInfo.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public static NSPrintOperation static_EPSOperationWithView_insideRect_toPath_printInfo_ (NSView view, NSRect rect, NSString path,
+            NSPrintInfo printInfo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_EPSOperationWithView_1insideRect_1toPath_1printInfo_1,
+                view !is null ? view.id : null, rect, path !is null ? path.id : null, printInfo !is null ? printInfo.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public static NSPrintOperation static_PDFOperationWithView_insideRect_toData_ (NSView view, NSRect rect, NSMutableData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_PDFOperationWithView_1insideRect_1toData_1,
+                view !is null ? view.id : null, rect, data !is null ? data.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public static NSPrintOperation static_PDFOperationWithView_insideRect_toData_printInfo_ (NSView view, NSRect rect, NSMutableData data,
+            NSPrintInfo printInfo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_PDFOperationWithView_1insideRect_1toData_1printInfo_1,
+                view !is null ? view.id : null, rect, data !is null ? data.id : null, printInfo !is null ? printInfo.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public static NSPrintOperation static_PDFOperationWithView_insideRect_toPath_printInfo_ (NSView view, NSRect rect, NSString path,
+            NSPrintInfo printInfo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_PDFOperationWithView_1insideRect_1toPath_1printInfo_1,
+                view !is null ? view.id : null, rect, path !is null ? path.id : null, printInfo !is null ? printInfo.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public bool canSpawnSeparateThread ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canSpawnSeparateThread) !is null;
+    }
+
+    public void cleanUpOperation ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cleanUpOperation);
+    }
+
+    public NSGraphicsContext context ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_context);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public NSGraphicsContext createContext ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_createContext);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public static NSPrintOperation currentOperation ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_currentOperation);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public NSInteger currentPage ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_currentPage);
+    }
+
+    public bool deliverResult ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_deliverResult) !is null;
+    }
+
+    public void destroyContext ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_destroyContext);
+    }
+
+    public bool isCopyingOperation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isCopyingOperation) !is null;
+    }
+
+    public NSString jobStyleHint ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_jobStyleHint);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString jobTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_jobTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSPrintingPageOrder pageOrder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pageOrder);
+    }
+
+    public NSRange pageRange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_pageRange);
+        return result;
+    }
+
+    public NSPrintInfo printInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printInfo);
+        return result !is null ? new NSPrintInfo(result) : null;
+    }
+
+    public static NSPrintOperation static_printOperationWithView_ (NSView view)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_printOperationWithView_1, view !is null ? view.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public static NSPrintOperation static_printOperationWithView_printInfo_ (NSView view, NSPrintInfo printInfo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_printOperationWithView_1printInfo_1, view !is null ? view.id : null,
+                printInfo !is null ? printInfo.id : null);
+        return result !is null ? new NSPrintOperation(result) : null;
+    }
+
+    public NSPrintPanel printPanel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printPanel);
+        return result !is null ? new NSPrintPanel(result) : null;
+    }
+
+    public bool runOperation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runOperation) !is null;
+    }
+
+    public void runOperationModalForWindow (NSWindow docWindow, id delegatee, objc.SEL didRunSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runOperationModalForWindow_1delegate_1didRunSelector_1contextInfo_1,
+                docWindow !is null ? docWindow.id : null, delegatee !is null ? delegatee.id : null, didRunSelector, contextInfo);
+    }
+
+    public void setAccessoryView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, view !is null ? view.id : null);
+    }
+
+    public void setCanSpawnSeparateThread (bool canSpawnSeparateThread)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanSpawnSeparateThread_1, canSpawnSeparateThread);
+    }
+
+    public static void setCurrentOperation (NSPrintOperation operation)
+    {
+        OS.objc_msgSend(OS.class_NSPrintOperation, OS.sel_setCurrentOperation_1, operation !is null ? operation.id : null);
+    }
+
+    public void setJobStyleHint (NSString hint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setJobStyleHint_1, hint !is null ? hint.id : null);
+    }
+
+    public void setJobTitle (NSString jobTitle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setJobTitle_1, jobTitle !is null ? jobTitle.id : null);
+    }
+
+    public void setPageOrder (NSPrintingPageOrder pageOrder)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPageOrder_1, pageOrder);
+    }
+
+    public void setPrintInfo (NSPrintInfo printInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrintInfo_1, printInfo !is null ? printInfo.id : null);
+    }
+
+    public void setPrintPanel (NSPrintPanel panel)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrintPanel_1, panel !is null ? panel.id : null);
+    }
+
+    public void setShowPanels (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowPanels_1, flag);
+    }
+
+    public void setShowsPrintPanel (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsPrintPanel_1, flag);
+    }
+
+    public void setShowsProgressPanel (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsProgressPanel_1, flag);
+    }
+
+    public bool showPanels ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showPanels) !is null;
+    }
+
+    public bool showsPrintPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsPrintPanel) !is null;
+    }
+
+    public bool showsProgressPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsProgressPanel) !is null;
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPrintPanel.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPrintPanel;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPrintInfo;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSViewController;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSPrintPanelOptions : NSInteger
+{
+    NSPrintPanelShowsCopies = 0x01,
+    NSPrintPanelShowsPageRange = 0x02,
+    NSPrintPanelShowsPaperSize = 0x04,
+    NSPrintPanelShowsOrientation = 0x08,
+    NSPrintPanelShowsScaling = 0x10,
+    NSPrintPanelShowsPageSetupAccessory = 0x100,
+    NSPrintPanelShowsPreview = 0x20000
+}
+
+alias NSPrintPanelOptions.NSPrintPanelShowsCopies NSPrintPanelShowsCopies;
+alias NSPrintPanelOptions.NSPrintPanelShowsPageRange NSPrintPanelShowsPageRange;
+alias NSPrintPanelOptions.NSPrintPanelShowsPaperSize NSPrintPanelShowsPaperSize;
+alias NSPrintPanelOptions.NSPrintPanelShowsOrientation NSPrintPanelShowsOrientation;
+alias NSPrintPanelOptions.NSPrintPanelShowsScaling NSPrintPanelShowsScaling;
+alias NSPrintPanelOptions.NSPrintPanelShowsPageSetupAccessory NSPrintPanelShowsPageSetupAccessory;
+alias NSPrintPanelOptions.NSPrintPanelShowsPreview NSPrintPanelShowsPreview;
+
+public class NSPrintPanel : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray accessoryControllers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryControllers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public void addAccessoryController (NSViewController accessoryController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addAccessoryController_1, accessoryController !is null ? accessoryController.id : null);
+    }
+
+    public void beginSheetWithPrintInfo (NSPrintInfo printInfo, NSWindow docWindow, id delegatee, objc.SEL didEndSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginSheetWithPrintInfo_1modalForWindow_1delegate_1didEndSelector_1contextInfo_1,
+                printInfo !is null ? printInfo.id : null, docWindow !is null ? docWindow.id : null, delegatee !is null ? delegatee.id : null,
+                didEndSelector, contextInfo);
+    }
+
+    public NSString defaultButtonTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultButtonTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void finalWritePrintInfo ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_finalWritePrintInfo);
+    }
+
+    public NSString helpAnchor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_helpAnchor);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString jobStyleHint ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_jobStyleHint);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSPrintPanelOptions options ()
+    {
+        return cast(NSPrintPanelOptions) OS.objc_msgSend(this.id, OS.sel_options);
+    }
+
+    public NSPrintInfo printInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printInfo);
+        return result !is null ? new NSPrintInfo(result) : null;
+    }
+
+    public static NSPrintPanel printPanel ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrintPanel, OS.sel_printPanel);
+        return result !is null ? new NSPrintPanel(result) : null;
+    }
+
+    public void removeAccessoryController (NSViewController accessoryController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAccessoryController_1, accessoryController !is null ? accessoryController.id : null);
+    }
+
+    public NSInteger runModal ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModal);
+    }
+
+    public NSInteger runModalWithPrintInfo (NSPrintInfo printInfo)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_runModalWithPrintInfo_1, printInfo !is null ? printInfo.id : null);
+    }
+
+    public void setAccessoryView (NSView accessoryView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, accessoryView !is null ? accessoryView.id : null);
+    }
+
+    public void setDefaultButtonTitle (NSString defaultButtonTitle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultButtonTitle_1, defaultButtonTitle !is null ? defaultButtonTitle.id : null);
+    }
+
+    public void setHelpAnchor (NSString helpAnchor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHelpAnchor_1, helpAnchor !is null ? helpAnchor.id : null);
+    }
+
+    public void setJobStyleHint (NSString hint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setJobStyleHint_1, hint !is null ? hint.id : null);
+    }
+
+    public void setOptions (NSPrintPanelOptions options)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOptions_1, options);
+    }
+
+    public void updateFromPrintInfo ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateFromPrintInfo);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPrinter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPrinter;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSPrinterTableStatus
+{
+    NSPrinterTableOK = 0,
+    NSPrinterTableNotFound = 1,
+    NSPrinterTableError = 2
+}
+
+alias NSPrinterTableStatus.NSPrinterTableOK NSPrinterTableOK;
+alias NSPrinterTableStatus.NSPrinterTableNotFound NSPrinterTableNotFound;
+alias NSPrinterTableStatus.NSPrinterTableError NSPrinterTableError;
+
+public class NSPrinter : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsBinary ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsBinary) !is null;
+    }
+
+    public bool booleanForKey (NSString key, NSString table)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_booleanForKey_1inTable_1, key !is null ? key.id : null, table !is null ? table.id : null) !is null;
+    }
+
+    public NSDictionary deviceDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_deviceDescription);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString domain ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_domain);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public float floatForKey (NSString key, NSString table)
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatForKey_1inTable_1, key !is null ? key.id : null,
+                table !is null ? table.id : null);
+    }
+
+    public NSString host ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_host);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSRect imageRectForPaper (NSString paperName)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_imageRectForPaper_1, paperName !is null ? paperName.id : null);
+        return result;
+    }
+
+    public int intForKey (NSString key, NSString table)
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_intForKey_1inTable_1, key !is null ? key.id : null, table !is null ? table.id : null);
+    }
+
+    public bool isColor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isColor) !is null;
+    }
+
+    public bool isFontAvailable (NSString faceName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFontAvailable_1, faceName !is null ? faceName.id : null) !is null;
+    }
+
+    public bool isKey (NSString key, NSString table)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isKey_1inTable_1, key !is null ? key.id : null, table !is null ? table.id : null) !is null;
+    }
+
+    public bool isOutputStackInReverseOrder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOutputStackInReverseOrder) !is null;
+    }
+
+    public NSInteger languageLevel ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_languageLevel);
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString note ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_note);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSSize pageSizeForPaper (NSString paperName)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_pageSizeForPaper_1, paperName !is null ? paperName.id : null);
+        return result;
+    }
+
+    public static NSArray printerNames ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrinter, OS.sel_printerNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray printerTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrinter, OS.sel_printerTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSPrinter static_printerWithName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrinter, OS.sel_printerWithName_1, name !is null ? name.id : null);
+        return result !is null ? new NSPrinter(result) : null;
+    }
+
+    public static NSPrinter static_printerWithName_domain_includeUnavailable_ (NSString name, NSString domain, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrinter, OS.sel_printerWithName_1domain_1includeUnavailable_1, name !is null ? name.id : null,
+                domain !is null ? domain.id : null, flag);
+        return result !is null ? new NSPrinter(result) : null;
+    }
+
+    public static NSPrinter printerWithType (NSString type)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPrinter, OS.sel_printerWithType_1, type !is null ? type.id : null);
+        return result !is null ? new NSPrinter(result) : null;
+    }
+
+    public NSRect rectForKey (NSString key, NSString table)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectForKey_1inTable_1, key !is null ? key.id : null, table !is null ? table.id : null);
+        return result;
+    }
+
+    public NSSize sizeForKey (NSString key, NSString table)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_sizeForKey_1inTable_1, key !is null ? key.id : null, table !is null ? table.id : null);
+        return result;
+    }
+
+    public NSPrinterTableStatus statusForTable (NSString tableName)
+    {
+        return cast(NSPrinterTableStatus) OS.objc_msgSend(this.id, OS.sel_statusForTable_1, tableName !is null ? tableName.id : null);
+    }
+
+    public NSString stringForKey (NSString key, NSString table)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringForKey_1inTable_1, key !is null ? key.id : null, table !is null ? table.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray stringListForKey (NSString key, NSString table)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringListForKey_1inTable_1, key !is null ? key.id : null, table !is null ? table.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString type ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_type);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSProcessInfo.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSProcessInfo;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSProcessInfo : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSUInteger activeProcessorCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_activeProcessorCount);
+    }
+
+    public NSArray arguments ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arguments);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSDictionary environment ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_environment);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString globallyUniqueString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_globallyUniqueString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString hostName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_hostName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public uint operatingSystem ()
+    {
+        return  cast(uint) OS.objc_msgSend(this.id, OS.sel_operatingSystem);
+    }
+
+    public NSString operatingSystemName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_operatingSystemName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString operatingSystemVersionString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_operatingSystemVersionString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public ulong physicalMemory ()
+    {
+        return cast(ulong) OS.objc_msgSend(this.id, OS.sel_physicalMemory);
+    }
+
+    public int processIdentifier ()
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_processIdentifier);
+    }
+
+    public static NSProcessInfo processInfo ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSProcessInfo, OS.sel_processInfo);
+        return result !is null ? new NSProcessInfo(result) : null;
+    }
+
+    public NSString processName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_processName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger processorCount ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_processorCount);
+    }
+
+    public void setProcessName (NSString newName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setProcessName_1, newName !is null ? newName.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSProgressIndicator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSProgressIndicator;
+
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSCell : NSControlTint, NSControlSize;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSProgressIndicatorStyle
+{
+    NSProgressIndicatorBarStyle = 0,
+    NSProgressIndicatorSpinningStyle = 1
+}
+
+alias NSProgressIndicatorStyle.NSProgressIndicatorBarStyle NSProgressIndicatorBarStyle;
+alias NSProgressIndicatorStyle.NSProgressIndicatorSpinningStyle NSProgressIndicatorSpinningStyle;
+
+public class NSProgressIndicator : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void animate (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_animate_1, sender !is null ? sender.id : null);
+    }
+
+    public NSTimeInterval animationDelay ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_animationDelay);
+    }
+
+    public NSControlSize controlSize ()
+    {
+        return cast(NSControlSize) OS.objc_msgSend(this.id, OS.sel_controlSize);
+    }
+
+    public NSControlTint controlTint ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_controlTint);
+    }
+
+    public double doubleValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+    }
+
+    public void incrementBy (double delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_incrementBy_1, delta);
+    }
+
+    public bool isBezeled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBezeled) !is null;
+    }
+
+    public bool isDisplayedWhenStopped ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDisplayedWhenStopped) !is null;
+    }
+
+    public bool isIndeterminate ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isIndeterminate) !is null;
+    }
+
+    public double maxValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_maxValue);
+    }
+
+    public double minValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_minValue);
+    }
+
+    public void setAnimationDelay (NSTimeInterval delay)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAnimationDelay_1, delay);
+    }
+
+    public void setBezeled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezeled_1, flag);
+    }
+
+    public void setControlSize (NSControlSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlSize_1, size);
+    }
+
+    public void setControlTint (NSControlSize tint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlTint_1, tint);
+    }
+
+    public void setDisplayedWhenStopped (bool isDisplayed)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDisplayedWhenStopped_1, isDisplayed);
+    }
+
+    public void setDoubleValue (double doubleValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleValue_1, doubleValue);
+    }
+
+    public void setIndeterminate (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIndeterminate_1, flag);
+    }
+
+    public void setMaxValue (double newMaximum)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxValue_1, newMaximum);
+    }
+
+    public void setMinValue (double newMinimum)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinValue_1, newMinimum);
+    }
+
+    public void setStyle (NSProgressIndicatorStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStyle_1, style);
+    }
+
+    public void setUsesThreadedAnimation (bool threadedAnimation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesThreadedAnimation_1, threadedAnimation);
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public void startAnimation (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_startAnimation_1, sender !is null ? sender.id : null);
+    }
+
+    public void stopAnimation (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopAnimation_1, sender !is null ? sender.id : null);
+    }
+
+    public NSProgressIndicatorStyle style ()
+    {
+        return cast(NSProgressIndicatorStyle) OS.objc_msgSend(this.id, OS.sel_style);
+    }
+
+    public bool usesThreadedAnimation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesThreadedAnimation) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPropertyListFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,20 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 28, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSPropertyListFormat;
+
+import dwt.internal.cocoa.CFPropertyList;
+
+enum NSPropertyListFormat {
+    NSPropertyListOpenStepFormat = kCFPropertyListOpenStepFormat,
+    NSPropertyListXMLFormat_v1_0 = kCFPropertyListXMLFormat_v1_0,
+    NSPropertyListBinaryFormat_v1_0 = kCFPropertyListBinaryFormat_v1_0
+}
+
+alias NSPropertyListFormat.NSPropertyListOpenStepFormat NSPropertyListOpenStepFormat;
+alias NSPropertyListFormat.NSPropertyListXMLFormat_v1_0 NSPropertyListXMLFormat_v1_0;
+alias NSPropertyListFormat.NSPropertyListBinaryFormat_v1_0 NSPropertyListBinaryFormat_v1_0;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSPropertyListSerialization.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSPropertyListSerialization;
+
+import dwt.internal.cocoa.CFPropertyList;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSPropertyListFormat
+{
+    NSPropertyListOpenStepFormat = kCFPropertyListOpenStepFormat,
+    NSPropertyListXMLFormat_v1_0 = kCFPropertyListXMLFormat_v1_0,
+    NSPropertyListBinaryFormat_v1_0 = kCFPropertyListBinaryFormat_v1_0
+}
+
+alias NSPropertyListFormat.NSPropertyListOpenStepFormat NSPropertyListOpenStepFormat;
+alias NSPropertyListFormat.NSPropertyListXMLFormat_v1_0 NSPropertyListXMLFormat_v1_0;
+alias NSPropertyListFormat.NSPropertyListBinaryFormat_v1_0 NSPropertyListBinaryFormat_v1_0;
+
+enum NSPropertyListMutabilityOptions
+{
+    NSPropertyListImmutable = kCFPropertyListImmutable,
+    NSPropertyListMutableContainers = kCFPropertyListMutableContainers,
+    NSPropertyListMutableContainersAndLeaves = kCFPropertyListMutableContainersAndLeaves
+}
+
+alias NSPropertyListMutabilityOptions.NSPropertyListImmutable NSPropertyListImmutable;
+alias NSPropertyListMutabilityOptions.NSPropertyListMutableContainers NSPropertyListMutableContainers;
+alias NSPropertyListMutabilityOptions.NSPropertyListMutableContainersAndLeaves NSPropertyListMutableContainersAndLeaves;
+
+public class NSPropertyListSerialization : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSData dataFromPropertyList (id plist, NSPropertyListFormat format, objc.id** errorString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPropertyListSerialization, OS.sel_dataFromPropertyList_1format_1errorDescription_1,
+                plist !is null ? plist.id : null, format, errorString);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public static bool propertyList (id plist, NSPropertyListFormat format)
+    {
+        return OS.objc_msgSend(OS.class_NSPropertyListSerialization, OS.sel_propertyList_1isValidForFormat_1, plist !is null ? plist.id : null,
+                format) !is null;
+    }
+
+    public static id propertyListFromData (NSData data, NSPropertyListMutabilityOptions opt, NSPropertyListFormat* format, objc.id** errorString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSPropertyListSerialization,
+                OS.sel_propertyListFromData_1mutabilityOption_1format_1errorDescription_1, data !is null ? data.id : null, opt, format, errorString);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSProtocolChecker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSProtocolChecker;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSProxy;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSProtocolChecker : NSProxy
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    //public id initWithTarget(NSObject anObject, Protocol aProtocol) {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTarget_1protocol_1, anObject !is null ? anObject.id : null, aProtocol !is null ? aProtocol.id : null);
+    //  return result !is null ? new id(result) : null;
+    //}
+    //
+    //public Protocol protocol() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_protocol);
+    //  return result !is null ? new Protocol(result) : null;
+    //}
+    //
+    //public static id protocolCheckerWithTarget(NSObject anObject, Protocol aProtocol) {
+    //  objc.id result = OS.objc_msgSend(OS.class_NSProtocolChecker, OS.sel_protocolCheckerWithTarget_1protocol_1, anObject !is null ? anObject.id : null, aProtocol !is null ? aProtocol.id : null);
+    //  return result !is null ? new id(result) : null;
+    //}
+
+    public NSObject target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new NSObject(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSProxy.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSProxy;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInvocation;
+import dwt.internal.cocoa.NSMethodSignature;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSProxy : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    //public static id alloc() {
+    //  objc.id result = OS.objc_msgSend(OS.class_NSProxy, OS.sel_alloc);
+    //  return result !is null ? new id(result) : null;
+    //}
+
+    public static id allocWithZone (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSProxy, OS.sel_allocWithZone_1, zone);
+        return result !is null ? new id(result) : null;
+    }
+
+    //public static int class() {
+    //  return OS.objc_msgSend(OS.class_NSProxy, OS.sel_class);
+    //}
+
+    public void dealloc ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_dealloc);
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void finalize ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_finalize);
+    }
+
+    public void forwardInvocation (NSInvocation invocation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_forwardInvocation_1, invocation !is null ? invocation.id : null);
+    }
+
+    public NSMethodSignature methodSignatureForSelector (objc.SEL sel)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_methodSignatureForSelector_1, sel);
+        return result !is null ? new NSMethodSignature(result) : null;
+    }
+
+//public static bool respondsToSelector(int aSelector) {
+//  return OS.objc_msgSend(OS.class_NSProxy, OS.sel_respondsToSelector_1, aSelector) !is null;
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSQuickDrawView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSQuickDrawView;
+
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSQuickDrawView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void* qdPort ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_qdPort);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSQuitCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSQuitCommand;
+
+import dwt.internal.cocoa.NSCloseCommand : NSSaveOptions;
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSQuitCommand : NSScriptCommand
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSSaveOptions saveOptions ()
+    {
+        return cast(NSSaveOptions) OS.objc_msgSend(this.id, OS.sel_saveOptions);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRange.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRange;
+
+import dwt.internal.cocoa.NSInteger;
+
+alias NSRange* NSRangePointer;
+
+struct NSRange {
+    NSUInteger location;
+    NSUInteger length;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRangeSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRangeSpecifier;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSRangeSpecifier : NSScriptObjectSpecifier
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptObjectSpecifier endSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_endSpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public id initWithContainerClassDescription (NSScriptClassDescription classDesc, NSScriptObjectSpecifier container, NSString property,
+            NSScriptObjectSpecifier startSpec, NSScriptObjectSpecifier endSpec)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerClassDescription_1containerSpecifier_1key_1startSpecifier_1endSpecifier_1,
+                classDesc !is null ? classDesc.id : null, container !is null ? container.id : null, property !is null ? property.id : null,
+                startSpec !is null ? startSpec.id : null, endSpec !is null ? endSpec.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setEndSpecifier (NSScriptObjectSpecifier endSpec)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEndSpecifier_1, endSpec !is null ? endSpec.id : null);
+    }
+
+    public void setStartSpecifier (NSScriptObjectSpecifier startSpec)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStartSpecifier_1, startSpec !is null ? startSpec.id : null);
+    }
+
+    public NSScriptObjectSpecifier startSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_startSpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRect.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRect;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSSize;
+
+alias NSRect* NSRectArray;
+alias NSRect* NSRectPointer;
+
+enum NSRectEdge : NSUInteger
+{
+    NSMinXEdge = 0,
+    NSMinYEdge = 1,
+    NSMaxXEdge = 2,
+    NSMaxYEdge = 3
+}
+
+alias NSRectEdge.NSMinXEdge NSMinXEdge;
+alias NSRectEdge.NSMinYEdge NSMinYEdge;
+alias NSRectEdge.NSMaxXEdge NSMaxXEdge;
+alias NSRectEdge.NSMaxYEdge NSMaxYEdge;
+
+struct NSRect
+{
+    NSPoint origin;
+    NSSize size;
+}
+
+/*public class NSRect {
+ public float x;
+ public float y;
+ public float width;
+ public float height;
+ public static final int sizeof = 16;
+ }*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRecursiveLock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRecursiveLock;
+
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSRecursiveLock : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool lockBeforeDate (NSDate limit)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lockBeforeDate_1, limit !is null ? limit.id : null) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setName (NSString n)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setName_1, n !is null ? n.id : null);
+    }
+
+    public bool tryLock ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryLock) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRelativeSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRelativeSpecifier;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSRelativePosition
+{
+    NSRelativeAfter = 0,
+    NSRelativeBefore
+}
+
+alias NSRelativePosition.NSRelativeAfter NSRelativeAfter;
+alias NSRelativePosition.NSRelativeBefore NSRelativeBefore;
+
+public class NSRelativeSpecifier : NSScriptObjectSpecifier
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptObjectSpecifier baseSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_baseSpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public id initWithContainerClassDescription (NSScriptClassDescription classDesc, NSScriptObjectSpecifier container, NSString property,
+            NSRelativePosition relPos, NSScriptObjectSpecifier baseSpecifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id,
+                OS.sel_initWithContainerClassDescription_1containerSpecifier_1key_1relativePosition_1baseSpecifier_1,
+                classDesc !is null ? classDesc.id : null, container !is null ? container.id : null, property !is null ? property.id : null, relPos,
+                baseSpecifier !is null ? baseSpecifier.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRelativePosition relativePosition ()
+    {
+        return cast(NSRelativePosition) OS.objc_msgSend(this.id, OS.sel_relativePosition);
+    }
+
+    public void setBaseSpecifier (NSScriptObjectSpecifier baseSpecifier)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBaseSpecifier_1, baseSpecifier !is null ? baseSpecifier.id : null);
+    }
+
+    public void setRelativePosition (NSRelativePosition relPos)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRelativePosition_1, relPos);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSResponder.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,609 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSResponder;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSInterfaceStyle;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSUndoManager;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSResponder : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsFirstResponder) !is null;
+    }
+
+    public bool becomeFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_becomeFirstResponder) !is null;
+    }
+
+    public void cancelOperation (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelOperation_1, sender !is null ? sender.id : null);
+    }
+
+    public void capitalizeWord (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_capitalizeWord_1, sender !is null ? sender.id : null);
+    }
+
+    public void centerSelectionInVisibleArea (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_centerSelectionInVisibleArea_1, sender !is null ? sender.id : null);
+    }
+
+    public void changeCaseOfLetter (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_changeCaseOfLetter_1, sender !is null ? sender.id : null);
+    }
+
+    public void complete (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_complete_1, sender !is null ? sender.id : null);
+    }
+
+    public void cursorUpdate (NSEvent event)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cursorUpdate_1, event !is null ? event.id : null);
+    }
+
+    public void deleteBackward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteBackward_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteBackwardByDecomposingPreviousCharacter (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteBackwardByDecomposingPreviousCharacter_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteForward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteForward_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteToBeginningOfLine (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteToBeginningOfLine_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteToBeginningOfParagraph (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteToBeginningOfParagraph_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteToEndOfLine (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteToEndOfLine_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteToEndOfParagraph (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteToEndOfParagraph_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteToMark (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteToMark_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteWordBackward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteWordBackward_1, sender !is null ? sender.id : null);
+    }
+
+    public void deleteWordForward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteWordForward_1, sender !is null ? sender.id : null);
+    }
+
+    public void doCommandBySelector (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_doCommandBySelector_1, aSelector);
+    }
+
+    public void flagsChanged (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_flagsChanged_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void flushBufferedKeyEvents ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushBufferedKeyEvents);
+    }
+
+    public void helpRequested (NSEvent eventPtr)
+    {
+        OS.objc_msgSend(this.id, OS.sel_helpRequested_1, eventPtr !is null ? eventPtr.id : null);
+    }
+
+    public void indent (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_indent_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertBacktab (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertBacktab_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertContainerBreak (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertContainerBreak_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertLineBreak (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertLineBreak_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertNewline (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertNewline_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertNewlineIgnoringFieldEditor (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertNewlineIgnoringFieldEditor_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertParagraphSeparator (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertParagraphSeparator_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertTab (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertTab_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertTabIgnoringFieldEditor (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertTabIgnoringFieldEditor_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertText (id insertString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertText_1, insertString !is null ? insertString.id : null);
+    }
+
+    public NSInterfaceStyle interfaceStyle ()
+    {
+        return cast(NSInterfaceStyle) OS.objc_msgSend(this.id, OS.sel_interfaceStyle);
+    }
+
+    public void interpretKeyEvents (NSArray eventArray)
+    {
+        OS.objc_msgSend(this.id, OS.sel_interpretKeyEvents_1, eventArray !is null ? eventArray.id : null);
+    }
+
+    public void keyDown (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_keyDown_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void keyUp (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_keyUp_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void lowercaseWord (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_lowercaseWord_1, sender !is null ? sender.id : null);
+    }
+
+    public NSMenu menu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public void mouseDown (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseDown_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void mouseDragged (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseDragged_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void mouseEntered (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseEntered_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void mouseExited (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseExited_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void mouseMoved (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseMoved_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void mouseUp (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_mouseUp_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void moveBackward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveBackward_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveBackwardAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveBackwardAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveDown (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveDown_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveDownAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveDownAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveForward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveForward_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveForwardAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveForwardAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveLeft (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveLeft_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveLeftAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveLeftAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveRight (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveRight_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveRightAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveRightAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveToBeginningOfDocument (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveToBeginningOfDocument_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveToBeginningOfLine (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveToBeginningOfLine_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveToBeginningOfParagraph (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveToBeginningOfParagraph_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveToEndOfDocument (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveToEndOfDocument_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveToEndOfLine (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveToEndOfLine_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveToEndOfParagraph (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveToEndOfParagraph_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveUp (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveUp_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveUpAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveUpAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordBackward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordBackward_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordBackwardAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordBackwardAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordForward (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordForward_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordForwardAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordForwardAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordLeft (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordLeft_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordLeftAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordLeftAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordRight (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordRight_1, sender !is null ? sender.id : null);
+    }
+
+    public void moveWordRightAndModifySelection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveWordRightAndModifySelection_1, sender !is null ? sender.id : null);
+    }
+
+    public NSResponder nextResponder ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextResponder);
+        return result is this.id ? this : (result !is null ? new NSResponder(result) : null);
+    }
+
+    public void noResponderFor (objc.SEL eventSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_noResponderFor_1, eventSelector);
+    }
+
+    public void otherMouseDown (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_otherMouseDown_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void otherMouseDragged (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_otherMouseDragged_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void otherMouseUp (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_otherMouseUp_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void pageDown (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_pageDown_1, sender !is null ? sender.id : null);
+    }
+
+    public void pageUp (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_pageUp_1, sender !is null ? sender.id : null);
+    }
+
+    public bool performKeyEquivalent (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performKeyEquivalent_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public bool performMnemonic (NSString theString)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performMnemonic_1, theString !is null ? theString.id : null) !is null;
+    }
+
+    public bool presentError_ (NSError error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_presentError_1, error !is null ? error.id : null) !is null;
+    }
+
+    public void presentError_modalForWindow_delegate_didPresentSelector_contextInfo_ (NSError error, NSWindow window, id delegatee,
+            objc.SEL didPresentSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_presentError_1modalForWindow_1delegate_1didPresentSelector_1contextInfo_1, error !is null ? error.id : null,
+                window !is null ? window.id : null, delegatee !is null ? delegatee.id : null, didPresentSelector, contextInfo);
+    }
+
+    public bool resignFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_resignFirstResponder) !is null;
+    }
+
+    public void rightMouseDown (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rightMouseDown_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void rightMouseDragged (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rightMouseDragged_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void rightMouseUp (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rightMouseUp_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void scrollLineDown (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollLineDown_1, sender !is null ? sender.id : null);
+    }
+
+    public void scrollLineUp (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollLineUp_1, sender !is null ? sender.id : null);
+    }
+
+    public void scrollPageDown (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollPageDown_1, sender !is null ? sender.id : null);
+    }
+
+    public void scrollPageUp (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollPageUp_1, sender !is null ? sender.id : null);
+    }
+
+    public void scrollWheel (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollWheel_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void selectAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectAll_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectLine (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectLine_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectParagraph (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectParagraph_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectToMark (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectToMark_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectWord (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectWord_1, sender !is null ? sender.id : null);
+    }
+
+    public void setInterfaceStyle (NSInterfaceStyle interfaceStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInterfaceStyle_1, interfaceStyle);
+    }
+
+    public void setMark (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMark_1, sender !is null ? sender.id : null);
+    }
+
+    public void setMenu (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1, menu !is null ? menu.id : null);
+    }
+
+    public void setNextResponder (NSResponder aResponder)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNextResponder_1, aResponder !is null ? aResponder.id : null);
+    }
+
+    public bool shouldBeTreatedAsInkEvent (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldBeTreatedAsInkEvent_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public void showContextHelp (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showContextHelp_1, sender !is null ? sender.id : null);
+    }
+
+    public void swapWithMark (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_swapWithMark_1, sender !is null ? sender.id : null);
+    }
+
+    public void tabletPoint (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_tabletPoint_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void tabletProximity (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_tabletProximity_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void transpose (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_transpose_1, sender !is null ? sender.id : null);
+    }
+
+    public void transposeWords (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_transposeWords_1, sender !is null ? sender.id : null);
+    }
+
+    public bool tryToPerform (objc.SEL anAction, id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryToPerform_1with_1, anAction, anObject !is null ? anObject.id : null) !is null;
+    }
+
+    public NSUndoManager undoManager ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_undoManager);
+        return result !is null ? new NSUndoManager(result) : null;
+    }
+
+    public void uppercaseWord (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_uppercaseWord_1, sender !is null ? sender.id : null);
+    }
+
+    public id validRequestorForSendType (NSString sendType, NSString returnType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_validRequestorForSendType_1returnType_1, sendType !is null ? sendType.id : null,
+                returnType !is null ? returnType.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSError willPresentError (NSError error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_willPresentError_1, error !is null ? error.id : null);
+        return result !is null ? new NSError(result) : null;
+    }
+
+    public void yank (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_yank_1, sender !is null ? sender.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRuleEditor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRuleEditor;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSRuleEditorRowType : NSUInteger
+{
+    NSRuleEditorRowTypeSimple,
+    NSRuleEditorRowTypeCompound
+}
+
+alias NSRuleEditorRowType.NSRuleEditorRowTypeSimple NSRuleEditorRowTypeSimple;
+alias NSRuleEditorRowType.NSRuleEditorRowTypeCompound NSRuleEditorRowTypeCompound;
+
+enum NSRuleEditorNestingMode : NSUInteger
+{
+    NSRuleEditorNestingModeSingle,
+    NSRuleEditorNestingModeList,
+    NSRuleEditorNestingModeCompound,
+    NSRuleEditorNestingModeSimple
+}
+
+alias NSRuleEditorNestingMode.NSRuleEditorNestingModeSingle NSRuleEditorNestingModeSingle;
+alias NSRuleEditorNestingMode.NSRuleEditorNestingModeList NSRuleEditorNestingModeList;
+alias NSRuleEditorNestingMode.NSRuleEditorNestingModeCompound NSRuleEditorNestingModeCompound;
+alias NSRuleEditorNestingMode.NSRuleEditorNestingModeSimple NSRuleEditorNestingModeSimple;
+
+public class NSRuleEditor : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addRow (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addRow_1, sender !is null ? sender.id : null);
+    }
+
+    public bool canRemoveAllRows ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canRemoveAllRows) !is null;
+    }
+
+    public NSArray criteriaForRow (NSInteger row)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_criteriaForRow_1, row);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString criteriaKeyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_criteriaKeyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray displayValuesForRow (NSInteger row)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayValuesForRow_1, row);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString displayValuesKeyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayValuesKeyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary formattingDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_formattingDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString formattingStringsFilename ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_formattingStringsFilename);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void insertRowAtIndex (NSInteger rowIndex, NSRuleEditorRowType rowType, NSInteger parentRow, bool shouldAnimate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertRowAtIndex_1withType_1asSubrowOfRow_1animate_1, rowIndex, rowType, parentRow, shouldAnimate);
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public NSRuleEditorNestingMode nestingMode ()
+    {
+        return cast(NSRuleEditorNestingMode) OS.objc_msgSend(this.id, OS.sel_nestingMode);
+    }
+
+    public NSInteger numberOfRows ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfRows);
+    }
+
+    public NSInteger parentRowForRow (NSInteger rowIndex)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_parentRowForRow_1, rowIndex);
+    }
+
+    public NSPredicate predicate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_predicate);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public NSPredicate predicateForRow (NSInteger row)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_predicateForRow_1, row);
+        return result !is null ? new NSPredicate(result) : null;
+    }
+
+    public void reloadCriteria ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadCriteria);
+    }
+
+    public void reloadPredicate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadPredicate);
+    }
+
+    public void removeRowAtIndex (NSInteger rowIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeRowAtIndex_1, rowIndex);
+    }
+
+    public void removeRowsAtIndexes (NSIndexSet rowIndexes, bool includeSubrows)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeRowsAtIndexes_1includeSubrows_1, rowIndexes !is null ? rowIndexes.id : null, includeSubrows);
+    }
+
+    public objc.Class rowClass ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(this.id, OS.sel_rowClass);
+    }
+
+    public NSInteger rowForDisplayValue (id displayValue)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_rowForDisplayValue_1, displayValue !is null ? displayValue.id : null);
+    }
+
+    public CGFloat rowHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_rowHeight);
+    }
+
+    public NSRuleEditorRowType rowTypeForRow (NSInteger rowIndex)
+    {
+        return cast(NSRuleEditorRowType) OS.objc_msgSend(this.id, OS.sel_rowTypeForRow_1, rowIndex);
+    }
+
+    public NSString rowTypeKeyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rowTypeKeyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void selectRowIndexes (NSIndexSet indexes, bool extend)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectRowIndexes_1byExtendingSelection_1, indexes !is null ? indexes.id : null, extend);
+    }
+
+    public NSIndexSet selectedRowIndexes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedRowIndexes);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public void setCanRemoveAllRows (bool val)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanRemoveAllRows_1, val);
+    }
+
+    public void setCriteria (NSArray criteria, NSArray values, NSInteger rowIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCriteria_1andDisplayValues_1forRowAtIndex_1, criteria !is null ? criteria.id : null,
+                values !is null ? values.id : null, rowIndex);
+    }
+
+    public void setCriteriaKeyPath (NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCriteriaKeyPath_1, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDisplayValuesKeyPath (NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDisplayValuesKeyPath_1, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void setEditable (bool editable)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, editable);
+    }
+
+    public void setFormattingDictionary (NSDictionary dictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormattingDictionary_1, dictionary !is null ? dictionary.id : null);
+    }
+
+    public void setFormattingStringsFilename (NSString stringsFilename)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFormattingStringsFilename_1, stringsFilename !is null ? stringsFilename.id : null);
+    }
+
+    public void setNestingMode (NSRuleEditorNestingMode mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNestingMode_1, mode);
+    }
+
+    public void setRowClass (objc.Class rowClass)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRowClass_1, rowClass);
+    }
+
+    public void setRowHeight (CGFloat height)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRowHeight_1, height);
+    }
+
+    public void setRowTypeKeyPath (NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRowTypeKeyPath_1, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void setSubrowsKeyPath (NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSubrowsKeyPath_1, keyPath !is null ? keyPath.id : null);
+    }
+
+    public NSIndexSet subrowIndexesForRow (NSInteger rowIndex)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subrowIndexesForRow_1, rowIndex);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public NSString subrowsKeyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subrowsKeyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRulerMarker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRulerMarker;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSRulerView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSRulerMarker : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void drawRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawRect_1, rect);
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSPoint imageOrigin ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_imageOrigin);
+        return result;
+    }
+
+    public NSRect imageRectInRuler ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_imageRectInRuler);
+        return result;
+    }
+
+    public id initWithRulerView (NSRulerView ruler, CGFloat location, NSImage image, NSPoint imageOrigin)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRulerView_1markerLocation_1image_1imageOrigin_1, ruler !is null ? ruler.id : null,
+                location, image !is null ? image.id : null, imageOrigin);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isDragging ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDragging) !is null;
+    }
+
+    public bool isMovable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMovable) !is null;
+    }
+
+    public bool isRemovable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRemovable) !is null;
+    }
+
+    public CGFloat markerLocation ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_markerLocation);
+    }
+
+    public id representedObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRulerView ruler ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_ruler);
+        return result !is null ? new NSRulerView(result) : null;
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setImageOrigin (NSPoint imageOrigin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageOrigin_1, imageOrigin);
+    }
+
+    public void setMarkerLocation (CGFloat location)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMarkerLocation_1, location);
+    }
+
+    public void setMovable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMovable_1, flag);
+    }
+
+    public void setRemovable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRemovable_1, flag);
+    }
+
+    public void setRepresentedObject (id representedObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRepresentedObject_1, representedObject !is null ? representedObject.id : null);
+    }
+
+    public CGFloat thicknessRequiredInRuler ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_thicknessRequiredInRuler);
+    }
+
+    public bool trackMouse (NSEvent mouseDownEvent, bool isAdding)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_trackMouse_1adding_1, mouseDownEvent !is null ? mouseDownEvent.id : null, isAdding) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRulerView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRulerView;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSRulerMarker;
+import dwt.internal.cocoa.NSScrollView;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSRulerOrientation
+{
+    NSHorizontalRuler,
+    NSVerticalRuler
+}
+
+alias NSRulerOrientation.NSHorizontalRuler NSHorizontalRuler;
+alias NSRulerOrientation.NSVerticalRuler NSVerticalRuler;
+
+public class NSRulerView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public void addMarker (NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addMarker_1, marker !is null ? marker.id : null);
+    }
+
+    public CGFloat baselineLocation ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_baselineLocation);
+    }
+
+    public NSView clientView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_clientView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public void drawHashMarksAndLabelsInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawHashMarksAndLabelsInRect_1, rect);
+    }
+
+    public void drawMarkersInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawMarkersInRect_1, rect);
+    }
+
+    public NSRulerView initWithScrollView (NSScrollView scrollView, NSRulerOrientation orientation)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithScrollView_1orientation_1, scrollView !is null ? scrollView.id : null, orientation);
+        return result !is null ? this : null;
+    }
+
+    public void invalidateHashMarks ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateHashMarks);
+    }
+
+    public bool isFlipped ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
+    }
+
+    public NSArray markers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_markers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString measurementUnits ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_measurementUnits);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void moveRulerlineFromLocation (CGFloat oldLocation, CGFloat newLocation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveRulerlineFromLocation_1toLocation_1, oldLocation, newLocation);
+    }
+
+    public NSRulerOrientation orientation ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_orientation);
+    }
+
+    public CGFloat originOffset ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_originOffset);
+    }
+
+    public static void registerUnitWithName (NSString unitName, NSString abbreviation, CGFloat conversionFactor, NSArray stepUpCycle,
+            NSArray stepDownCycle)
+    {
+        OS.objc_msgSend(OS.class_NSRulerView, OS.sel_registerUnitWithName_1abbreviation_1unitToPointsConversionFactor_1stepUpCycle_1stepDownCycle_1,
+                unitName !is null ? unitName.id : null, abbreviation !is null ? abbreviation.id : null, conversionFactor,
+                stepUpCycle !is null ? stepUpCycle.id : null, stepDownCycle !is null ? stepDownCycle.id : null);
+    }
+
+    public void removeMarker (NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeMarker_1, marker !is null ? marker.id : null);
+    }
+
+    public CGFloat requiredThickness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_requiredThickness);
+    }
+
+    public CGFloat reservedThicknessForAccessoryView ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_reservedThicknessForAccessoryView);
+    }
+
+    public CGFloat reservedThicknessForMarkers ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_reservedThicknessForMarkers);
+    }
+
+    public CGFloat ruleThickness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_ruleThickness);
+    }
+
+    public NSScrollView scrollView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_scrollView);
+        return result !is null ? new NSScrollView(result) : null;
+    }
+
+    public void setAccessoryView (NSView accessory)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, accessory !is null ? accessory.id : null);
+    }
+
+    public void setClientView (NSView client)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setClientView_1, client !is null ? client.id : null);
+    }
+
+    public void setMarkers (NSArray markers)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMarkers_1, markers !is null ? markers.id : null);
+    }
+
+    public void setMeasurementUnits (NSString unitName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMeasurementUnits_1, unitName !is null ? unitName.id : null);
+    }
+
+    public void setOrientation (NSRulerOrientation orientation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOrientation_1, orientation);
+    }
+
+    public void setOriginOffset (CGFloat offset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOriginOffset_1, offset);
+    }
+
+    public void setReservedThicknessForAccessoryView (CGFloat thickness)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReservedThicknessForAccessoryView_1, thickness);
+    }
+
+    public void setReservedThicknessForMarkers (CGFloat thickness)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReservedThicknessForMarkers_1, thickness);
+    }
+
+    public void setRuleThickness (CGFloat thickness)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRuleThickness_1, thickness);
+    }
+
+    public void setScrollView (NSScrollView scrollView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScrollView_1, scrollView !is null ? scrollView.id : null);
+    }
+
+    public bool trackMarker (NSRulerMarker marker, NSEvent event)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_trackMarker_1withMouseEvent_1, marker !is null ? marker.id : null, event !is null ? event.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSRunLoop.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSRunLoop;
+
+import dwt.internal.cocoa.CFRunLoopRef;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTimer;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSRunLoop : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void acceptInputForMode (NSString mode, NSDate limitDate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_acceptInputForMode_1beforeDate_1, mode !is null ? mode.id : null, limitDate !is null ? limitDate.id : null);
+    }
+
+    public void addPort (NSPort aPort, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addPort_1forMode_1, aPort !is null ? aPort.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void addTimer (NSTimer timer, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTimer_1forMode_1, timer !is null ? timer.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void cancelPerformSelector (objc.SEL aSelector, id target, id arg)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelPerformSelector_1target_1argument_1, aSelector, target !is null ? target.id : null,
+                arg !is null ? arg.id : null);
+    }
+
+    public void cancelPerformSelectorsWithTarget (id target)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelPerformSelectorsWithTarget_1, target !is null ? target.id : null);
+    }
+
+    public void configureAsServer ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_configureAsServer);
+    }
+
+    public NSString currentMode ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentMode);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSRunLoop currentRunLoop ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_currentRunLoop);
+        return result !is null ? new NSRunLoop(result) : null;
+    }
+
+    public CFRunLoopRef getCFRunLoop ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getCFRunLoop);
+    }
+
+    public NSDate limitDateForMode (NSString mode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_limitDateForMode_1, mode !is null ? mode.id : null);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public static NSRunLoop mainRunLoop ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSRunLoop, OS.sel_mainRunLoop);
+        return result !is null ? new NSRunLoop(result) : null;
+    }
+
+    public void performSelector (objc.SEL aSelector, id target, id arg, NSUInteger order, NSArray modes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performSelector_1target_1argument_1order_1modes_1, aSelector, target !is null ? target.id : null,
+                arg !is null ? arg.id : null, order, modes !is null ? modes.id : null);
+    }
+
+    public void removePort (NSPort aPort, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removePort_1forMode_1, aPort !is null ? aPort.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void run ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_run);
+    }
+
+    public bool runMode (NSString mode, NSDate limitDate)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runMode_1beforeDate_1, mode !is null ? mode.id : null, limitDate !is null ? limitDate.id : null) !is null;
+    }
+
+    public void runUntilDate (NSDate limitDate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runUntilDate_1, limitDate !is null ? limitDate.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSavePanel.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSavePanel;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPanel;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSavePanel : NSPanel
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSURL URL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSArray allowedFileTypes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allowedFileTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool allowsOtherFileTypes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsOtherFileTypes) !is null;
+    }
+
+    public void beginSheetForDirectory (NSString path, NSString name, NSWindow docWindow, id delegatee, objc.SEL didEndSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginSheetForDirectory_1file_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1,
+                path !is null ? path.id : null, name !is null ? name.id : null, docWindow !is null ? docWindow.id : null,
+                delegatee !is null ? delegatee.id : null, didEndSelector, contextInfo);
+    }
+
+    public bool canCreateDirectories ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canCreateDirectories) !is null;
+    }
+
+    public bool canSelectHiddenExtension ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canSelectHiddenExtension) !is null;
+    }
+
+    public void cancel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancel_1, sender !is null ? sender.id : null);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString directory ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_directory);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString filename ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_filename);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool isExpanded ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExpanded) !is null;
+    }
+
+    public bool isExtensionHidden ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExtensionHidden) !is null;
+    }
+
+    public NSString message ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_message);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString nameFieldLabel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nameFieldLabel);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void ok (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ok_1, sender !is null ? sender.id : null);
+    }
+
+    public NSString prompt ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_prompt);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString requiredFileType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_requiredFileType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSInteger runModal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModal);
+    }
+
+    public NSInteger runModalForDirectory (NSString path, NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_runModalForDirectory_1file_1, path !is null ? path.id : null, name !is null ? name.id : null);
+    }
+
+    public static NSSavePanel savePanel ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSavePanel, OS.sel_savePanel);
+        return result !is null ? new NSSavePanel(result) : null;
+    }
+
+    public void selectText (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectText_1, sender !is null ? sender.id : null);
+    }
+
+    public void setAccessoryView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, view !is null ? view.id : null);
+    }
+
+    public void setAllowedFileTypes (NSArray types)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowedFileTypes_1, types !is null ? types.id : null);
+    }
+
+    public void setAllowsOtherFileTypes (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsOtherFileTypes_1, flag);
+    }
+
+    public void setCanCreateDirectories (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanCreateDirectories_1, flag);
+    }
+
+    public void setCanSelectHiddenExtension (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanSelectHiddenExtension_1, flag);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDirectory (NSString path)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDirectory_1, path !is null ? path.id : null);
+    }
+
+    public void setExtensionHidden (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setExtensionHidden_1, flag);
+    }
+
+    public void setMessage (NSString message)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMessage_1, message !is null ? message.id : null);
+    }
+
+    public void setNameFieldLabel (NSString label)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNameFieldLabel_1, label !is null ? label.id : null);
+    }
+
+    public void setPrompt (NSString prompt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPrompt_1, prompt !is null ? prompt.id : null);
+    }
+
+    public void setRequiredFileType (NSString type)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRequiredFileType_1, type !is null ? type.id : null);
+    }
+
+    public void setTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, title !is null ? title.id : null);
+    }
+
+    public void setTreatsFilePackagesAsDirectories (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTreatsFilePackagesAsDirectories_1, flag);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool treatsFilePackagesAsDirectories ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_treatsFilePackagesAsDirectories) !is null;
+    }
+
+    public void validateVisibleColumns ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_validateVisibleColumns);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScanner.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScanner;
+
+import dwt.internal.cocoa.NSCharacterSet;
+import dwt.internal.cocoa.NSDecimal;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScanner : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool caseSensitive ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_caseSensitive) !is null;
+    }
+
+    public NSCharacterSet charactersToBeSkipped ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_charactersToBeSkipped);
+        return result !is null ? new NSCharacterSet(result) : null;
+    }
+
+    public NSScanner initWithString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, string !is null ? string.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isAtEnd ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAtEnd) !is null;
+    }
+
+    public id locale ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_locale);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id localizedScannerWithString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScanner, OS.sel_localizedScannerWithString_1, string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool scanCharactersFromSet (NSCharacterSet set, objc.id** value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanCharactersFromSet_1intoString_1, set !is null ? set.id : null, value) !is null;
+    }
+
+    public bool scanDecimal (NSDecimal* dcm)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanDecimal_1, dcm) !is null;
+    }
+
+    public bool scanDouble (double* value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanDouble_1, value) !is null;
+    }
+
+    public bool scanFloat (float* value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanFloat_1, value) !is null;
+    }
+
+    public bool scanHexDouble (objc.id result)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanHexDouble_1, result) !is null;
+    }
+
+    public bool scanHexFloat (objc.id result)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanHexFloat_1, result) !is null;
+    }
+
+    public bool scanHexInt (uint* value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanHexInt_1, value) !is null;
+    }
+
+    public bool scanHexLongLong (objc.id result)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanHexLongLong_1, result) !is null;
+    }
+
+    public bool scanInt (int* value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanInt_1, value) !is null;
+    }
+
+    public bool scanInteger (NSInteger* value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanInteger_1, value) !is null;
+    }
+
+    public NSUInteger scanLocation ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_scanLocation);
+    }
+
+    public bool scanLongLong (long* value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanLongLong_1, value) !is null;
+    }
+
+    public bool scanString (NSString string, objc.id** value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanString_1intoString_1, string !is null ? string.id : null, value) !is null;
+    }
+
+    public bool scanUpToCharactersFromSet (NSCharacterSet set, objc.id** value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanUpToCharactersFromSet_1intoString_1, set !is null ? set.id : null, value) !is null;
+    }
+
+    public bool scanUpToString (NSString string, objc.id** value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scanUpToString_1intoString_1, string !is null ? string.id : null, value) !is null;
+    }
+
+    public static id scannerWithString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScanner, OS.sel_scannerWithString_1, string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setCaseSensitive (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCaseSensitive_1, flag);
+    }
+
+    public void setCharactersToBeSkipped (NSCharacterSet set)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCharactersToBeSkipped_1, set !is null ? set.id : null);
+    }
+
+    public void setLocale (id locale)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocale_1, locale !is null ? locale.id : null);
+    }
+
+    public void setScanLocation (NSUInteger pos)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScanLocation_1, pos);
+    }
+
+    public NSString string ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_string);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScreen.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScreen;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSWindow : NSWindowDepth;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScreen : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSScreen deepestScreen ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScreen, OS.sel_deepestScreen);
+        return result !is null ? new NSScreen(result) : null;
+    }
+
+    public NSWindowDepth depth ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_depth);
+    }
+
+    public NSDictionary deviceDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_deviceDescription);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSRect frame ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frame);
+        return result;
+    }
+
+    public static NSScreen mainScreen ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScreen, OS.sel_mainScreen);
+        return result !is null ? new NSScreen(result) : null;
+    }
+
+    public static NSArray screens ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScreen, OS.sel_screens);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public /*const*/NSWindowDepth* supportedWindowDepths ()
+    {
+        return cast(/*const*/NSWindowDepth*)OS.objc_msgSend(this.id, OS.sel_supportedWindowDepths);
+    }
+
+    public CGFloat userSpaceScaleFactor ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_userSpaceScaleFactor);
+    }
+
+    public NSRect visibleFrame ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_visibleFrame);
+        return result;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptClassDescription.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptClassDescription;
+
+import dwt.internal.c.carboncore.MacTypes : FourCharCode;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSClassDescription;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSScriptCommandDescription;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptClassDescription : NSClassDescription
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public FourCharCode appleEventCode ()
+    {
+        return cast(FourCharCode) OS.objc_msgSend(this.id, OS.sel_appleEventCode);
+    }
+
+    public FourCharCode appleEventCodeForKey (NSString key)
+    {
+        return cast(FourCharCode) OS.objc_msgSend(this.id, OS.sel_appleEventCodeForKey_1, key !is null ? key.id : null);
+    }
+
+    //public static NSScriptClassDescription classDescriptionForClass(int aClass) {
+    //  objc.id result = OS.objc_msgSend(OS.class_NSScriptClassDescription, OS.sel_classDescriptionForClass_1, aClass);
+    //  return result !is null ? new NSScriptClassDescription(result) : null;
+    //}
+
+    public NSScriptClassDescription classDescriptionForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_classDescriptionForKey_1, key !is null ? key.id : null);
+        return result is this.id ? this : (result !is null ? new NSScriptClassDescription(result) : null);
+    }
+
+    public NSString className ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_className);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString defaultSubcontainerAttributeKey ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultSubcontainerAttributeKey);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool hasOrderedToManyRelationshipForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasOrderedToManyRelationshipForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public bool hasPropertyForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasPropertyForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public bool hasReadablePropertyForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasReadablePropertyForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public bool hasWritablePropertyForKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasWritablePropertyForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public NSString implementationClassName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_implementationClassName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initWithSuiteName (NSString suiteName, NSString className, NSDictionary classDeclaration)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSuiteName_1className_1dictionary_1, suiteName !is null ? suiteName.id : null,
+                className !is null ? className.id : null, classDeclaration !is null ? classDeclaration.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isLocationRequiredToCreateForKey (NSString toManyRelationshipKey)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLocationRequiredToCreateForKey_1, toManyRelationshipKey !is null ? toManyRelationshipKey.id : null) !is null;
+    }
+
+    public bool isReadOnlyKey (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isReadOnlyKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public NSString keyWithAppleEventCode (FourCharCode appleEventCode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyWithAppleEventCode_1, appleEventCode);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool matchesAppleEventCode (FourCharCode appleEventCode)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_matchesAppleEventCode_1, appleEventCode) !is null;
+    }
+
+    public int selectorForCommand (NSScriptCommandDescription commandDescription)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectorForCommand_1, commandDescription !is null ? commandDescription.id : null);
+    }
+
+    public NSString suiteName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_suiteName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSScriptClassDescription superclassDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_superclassDescription);
+        return result is this.id ? this : (result !is null ? new NSScriptClassDescription(result) : null);
+    }
+
+    public bool supportsCommand (NSScriptCommandDescription commandDescription)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_supportsCommand_1, commandDescription !is null ? commandDescription.id : null) !is null;
+    }
+
+    public NSString typeForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_typeForKey_1, key !is null ? key.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptCoercionHandler.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptCoercionHandler;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptCoercionHandler : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id coerceValue (id value, objc.Class toClass)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_coerceValue_1toClass_1, value !is null ? value.id : null, toClass);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void registerCoercer (id coercer, objc.SEL selector, objc.Class fromClass, objc.Class toClass)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerCoercer_1selector_1toConvertFromClass_1toClass_1, coercer !is null ? coercer.id : null, selector,
+                fromClass, toClass);
+    }
+
+    public static NSScriptCoercionHandler sharedCoercionHandler ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScriptCoercionHandler, OS.sel_sharedCoercionHandler);
+        return result !is null ? new NSScriptCoercionHandler(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptCommand;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAppleEventDescriptor;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSScriptCommandDescription;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptCommand : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSAppleEventDescriptor appleEvent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_appleEvent);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSDictionary arguments ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arguments);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSScriptCommandDescription commandDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commandDescription);
+        return result !is null ? new NSScriptCommandDescription(result) : null;
+    }
+
+    public static NSScriptCommand currentCommand ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScriptCommand, OS.sel_currentCommand);
+        return result !is null ? new NSScriptCommand(result) : null;
+    }
+
+    public id directParameter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_directParameter);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary evaluatedArguments ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_evaluatedArguments);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public id evaluatedReceivers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_evaluatedReceivers);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id executeCommand ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_executeCommand);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithCommandDescription (NSScriptCommandDescription commandDef)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCommandDescription_1, commandDef !is null ? commandDef.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isWellFormed ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isWellFormed) !is null;
+    }
+
+    public id performDefaultImplementation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_performDefaultImplementation);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSScriptObjectSpecifier receiversSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_receiversSpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public void resumeExecutionWithResult (id result)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resumeExecutionWithResult_1, result !is null ? result.id : null);
+    }
+
+    public NSAppleEventDescriptor scriptErrorExpectedTypeDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_scriptErrorExpectedTypeDescriptor);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public int scriptErrorNumber ()
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_scriptErrorNumber);
+    }
+
+    public NSAppleEventDescriptor scriptErrorOffendingObjectDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_scriptErrorOffendingObjectDescriptor);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSString scriptErrorString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_scriptErrorString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setArguments (NSDictionary args)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setArguments_1, args !is null ? args.id : null);
+    }
+
+    public void setDirectParameter (id directParameter)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDirectParameter_1, directParameter !is null ? directParameter.id : null);
+    }
+
+    public void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReceiversSpecifier_1, receiversRef !is null ? receiversRef.id : null);
+    }
+
+    public void setScriptErrorExpectedTypeDescriptor (NSAppleEventDescriptor errorExpectedTypeDescriptor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScriptErrorExpectedTypeDescriptor_1,
+                errorExpectedTypeDescriptor !is null ? errorExpectedTypeDescriptor.id : null);
+    }
+
+    public void setScriptErrorNumber (int errorNumber)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScriptErrorNumber_1, errorNumber);
+    }
+
+    public void setScriptErrorOffendingObjectDescriptor (NSAppleEventDescriptor errorOffendingObjectDescriptor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScriptErrorOffendingObjectDescriptor_1,
+                errorOffendingObjectDescriptor !is null ? errorOffendingObjectDescriptor.id : null);
+    }
+
+    public void setScriptErrorString (NSString errorString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScriptErrorString_1, errorString !is null ? errorString.id : null);
+    }
+
+    public void suspendExecution ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_suspendExecution);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptCommandDescription.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptCommandDescription;
+
+import dwt.internal.c.carboncore.MacTypes : FourCharCode;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptCommandDescription : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public FourCharCode appleEventClassCode ()
+    {
+        return cast(FourCharCode) OS.objc_msgSend(this.id, OS.sel_appleEventClassCode);
+    }
+
+    public FourCharCode appleEventCode ()
+    {
+        return cast(FourCharCode) OS.objc_msgSend(this.id, OS.sel_appleEventCode);
+    }
+
+    public FourCharCode appleEventCodeForArgumentWithName (NSString argumentName)
+    {
+        return cast(FourCharCode) OS.objc_msgSend(this.id, OS.sel_appleEventCodeForArgumentWithName_1, argumentName !is null ? argumentName.id : null);
+    }
+
+    public FourCharCode appleEventCodeForReturnType ()
+    {
+        return cast(FourCharCode) OS.objc_msgSend(this.id, OS.sel_appleEventCodeForReturnType);
+    }
+
+    public NSArray argumentNames ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_argumentNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString commandClassName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commandClassName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString commandName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commandName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSScriptCommand createCommandInstance ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_createCommandInstance);
+        return result !is null ? new NSScriptCommand(result) : null;
+    }
+
+    public NSScriptCommand createCommandInstanceWithZone (NSZone* zone)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_createCommandInstanceWithZone_1, zone);
+        return result !is null ? new NSScriptCommand(result) : null;
+    }
+
+    public id initWithSuiteName (NSString suiteName, NSString commandName, NSDictionary commandDeclaration)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSuiteName_1commandName_1dictionary_1, suiteName !is null ? suiteName.id : null,
+                commandName !is null ? commandName.id : null, commandDeclaration !is null ? commandDeclaration.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isOptionalArgumentWithName (NSString argumentName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOptionalArgumentWithName_1, argumentName !is null ? argumentName.id : null) !is null;
+    }
+
+    public NSString returnType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_returnType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString suiteName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_suiteName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString typeForArgumentWithName (NSString argumentName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_typeForArgumentWithName_1, argumentName !is null ? argumentName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptExecutionContext.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptExecutionContext;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptExecutionContext : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id objectBeingTested ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectBeingTested);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id rangeContainerObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rangeContainerObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setObjectBeingTested (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectBeingTested_1, obj !is null ? obj.id : null);
+    }
+
+    public void setRangeContainerObject (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRangeContainerObject_1, obj !is null ? obj.id : null);
+    }
+
+    public void setTopLevelObject (id obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTopLevelObject_1, obj !is null ? obj.id : null);
+    }
+
+    public static NSScriptExecutionContext sharedScriptExecutionContext ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScriptExecutionContext, OS.sel_sharedScriptExecutionContext);
+        return result !is null ? new NSScriptExecutionContext(result) : null;
+    }
+
+    public id topLevelObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_topLevelObject);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptObjectSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptObjectSpecifier;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAppleEventDescriptor;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptObjectSpecifier : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptObjectSpecifier childSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_childSpecifier);
+        return result is this.id ? this : (result !is null ? new NSScriptObjectSpecifier(result) : null);
+    }
+
+    public NSScriptClassDescription containerClassDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_containerClassDescription);
+        return result !is null ? new NSScriptClassDescription(result) : null;
+    }
+
+    public bool containerIsObjectBeingTested ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containerIsObjectBeingTested) !is null;
+    }
+
+    public bool containerIsRangeContainerObject ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containerIsRangeContainerObject) !is null;
+    }
+
+    public NSScriptObjectSpecifier containerSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_containerSpecifier);
+        return result is this.id ? this : (result !is null ? new NSScriptObjectSpecifier(result) : null);
+    }
+
+    public NSAppleEventDescriptor descriptor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptor);
+        return result !is null ? new NSAppleEventDescriptor(result) : null;
+    }
+
+    public NSInteger evaluationErrorNumber ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_evaluationErrorNumber);
+    }
+
+    public NSScriptObjectSpecifier evaluationErrorSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_evaluationErrorSpecifier);
+        return result is this.id ? this : (result !is null ? new NSScriptObjectSpecifier(result) : null);
+    }
+
+    public NSInteger* indicesOfObjectsByEvaluatingWithContainer (id container, NSInteger* count)
+    {
+        return cast(NSInteger*) OS.objc_msgSend(this.id, OS.sel_indicesOfObjectsByEvaluatingWithContainer_1count_1, container !is null ? container.id : null, count);
+    }
+
+    public id initWithContainerClassDescription (NSScriptClassDescription classDesc, NSScriptObjectSpecifier container, NSString property)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerClassDescription_1containerSpecifier_1key_1,
+                classDesc !is null ? classDesc.id : null, container !is null ? container.id : null, property !is null ? property.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithContainerSpecifier (NSScriptObjectSpecifier container, NSString property)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerSpecifier_1key_1, container !is null ? container.id : null,
+                property !is null ? property.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString key ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_key);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSScriptClassDescription keyClassDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keyClassDescription);
+        return result !is null ? new NSScriptClassDescription(result) : null;
+    }
+
+    public static NSScriptObjectSpecifier objectSpecifierWithDescriptor (NSAppleEventDescriptor descriptor)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScriptObjectSpecifier, OS.sel_objectSpecifierWithDescriptor_1,
+                descriptor !is null ? descriptor.id : null);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public id objectsByEvaluatingSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsByEvaluatingSpecifier);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id objectsByEvaluatingWithContainers (id containers)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsByEvaluatingWithContainers_1, containers !is null ? containers.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setChildSpecifier (NSScriptObjectSpecifier child)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setChildSpecifier_1, child !is null ? child.id : null);
+    }
+
+    public void setContainerClassDescription (NSScriptClassDescription classDesc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContainerClassDescription_1, classDesc !is null ? classDesc.id : null);
+    }
+
+    public void setContainerIsObjectBeingTested (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContainerIsObjectBeingTested_1, flag);
+    }
+
+    public void setContainerIsRangeContainerObject (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContainerIsRangeContainerObject_1, flag);
+    }
+
+    public void setContainerSpecifier (NSScriptObjectSpecifier subRef)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContainerSpecifier_1, subRef !is null ? subRef.id : null);
+    }
+
+    public void setEvaluationErrorNumber (NSInteger error)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEvaluationErrorNumber_1, error);
+    }
+
+    public void setKey (NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKey_1, key !is null ? key.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptSuiteRegistry.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptSuiteRegistry;
+
+import dwt.internal.c.carboncore.MacTypes : FourCharCodes;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSBundle;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptCommandDescription;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptSuiteRegistry : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData aeteResource (NSString languageName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_aeteResource_1, languageName !is null ? languageName.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public FourCharCode appleEventCodeForSuite (NSString suiteName)
+    {
+        return cast(FourCharCode) OS.objc_msgSend(this.id, OS.sel_appleEventCodeForSuite_1, suiteName !is null ? suiteName.id : null);
+    }
+
+    public NSBundle bundleForSuite (NSString suiteName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bundleForSuite_1, suiteName !is null ? suiteName.id : null);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public NSScriptClassDescription classDescriptionWithAppleEventCode (FourCharCode appleEventCode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_classDescriptionWithAppleEventCode_1, appleEventCode);
+        return result !is null ? new NSScriptClassDescription(result) : null;
+    }
+
+    public NSDictionary classDescriptionsInSuite (NSString suiteName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_classDescriptionsInSuite_1, suiteName !is null ? suiteName.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSScriptCommandDescription commandDescriptionWithAppleEventClass (FourCharCode appleEventClassCode, FourCharCode appleEventIDCode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commandDescriptionWithAppleEventClass_1andAppleEventCode_1, appleEventClassCode,
+                appleEventIDCode);
+        return result !is null ? new NSScriptCommandDescription(result) : null;
+    }
+
+    public NSDictionary commandDescriptionsInSuite (NSString suiteName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commandDescriptionsInSuite_1, suiteName !is null ? suiteName.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void loadSuiteWithDictionary (NSDictionary suiteDeclaration, NSBundle bundle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_loadSuiteWithDictionary_1fromBundle_1, suiteDeclaration !is null ? suiteDeclaration.id : null,
+                bundle !is null ? bundle.id : null);
+    }
+
+    public void loadSuitesFromBundle (NSBundle bundle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_loadSuitesFromBundle_1, bundle !is null ? bundle.id : null);
+    }
+
+    public void registerClassDescription (NSScriptClassDescription classDescription)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerClassDescription_1, classDescription !is null ? classDescription.id : null);
+    }
+
+    public void registerCommandDescription (NSScriptCommandDescription commandDescription)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerCommandDescription_1, commandDescription !is null ? commandDescription.id : null);
+    }
+
+    public static void setSharedScriptSuiteRegistry (NSScriptSuiteRegistry registry)
+    {
+        OS.objc_msgSend(OS.class_NSScriptSuiteRegistry, OS.sel_setSharedScriptSuiteRegistry_1, registry !is null ? registry.id : null);
+    }
+
+    public static NSScriptSuiteRegistry sharedScriptSuiteRegistry ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSScriptSuiteRegistry, OS.sel_sharedScriptSuiteRegistry);
+        return result !is null ? new NSScriptSuiteRegistry(result) : null;
+    }
+
+    public NSString suiteForAppleEventCode (FourCharCode appleEventCode)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_suiteForAppleEventCode_1, appleEventCode);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray suiteNames ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_suiteNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScriptWhoseTest.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScriptWhoseTest;
+
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScriptWhoseTest : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool isTrue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isTrue) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScrollView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScrollView;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSClipView;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSCursor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSRulerView;
+import dwt.internal.cocoa.NSScroller;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSScrollView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool autohidesScrollers ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autohidesScrollers) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSBorderType borderType ()
+    {
+        return cast(NSBorderType) OS.objc_msgSend(this.id, OS.sel_borderType);
+    }
+
+    public NSSize contentSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_contentSize);
+        return result;
+    }
+
+    public static NSSize contentSizeForFrameSize (NSSize fSize, bool hFlag, bool vFlag, NSBorderType aType)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, OS.class_NSScrollView,
+                OS.sel_contentSizeForFrameSize_1hasHorizontalScroller_1hasVerticalScroller_1borderType_1, fSize, hFlag, vFlag, aType);
+        return result;
+    }
+
+    public NSClipView contentView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentView);
+        return result !is null ? new NSClipView(result) : null;
+    }
+
+    public NSCursor documentCursor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentCursor);
+        return result !is null ? new NSCursor(result) : null;
+    }
+
+    public id documentView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_documentView);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRect documentVisibleRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_documentVisibleRect);
+        return result;
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public static NSSize frameSizeForContentSize (NSSize cSize, bool hFlag, bool vFlag, NSBorderType aType)
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, OS.class_NSScrollView,
+                OS.sel_frameSizeForContentSize_1hasHorizontalScroller_1hasVerticalScroller_1borderType_1, cSize, hFlag, vFlag, aType);
+        return result;
+    }
+
+    public bool hasHorizontalRuler ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasHorizontalRuler) !is null;
+    }
+
+    public bool hasHorizontalScroller ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasHorizontalScroller) !is null;
+    }
+
+    public bool hasVerticalRuler ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasVerticalRuler) !is null;
+    }
+
+    public bool hasVerticalScroller ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasVerticalScroller) !is null;
+    }
+
+    public CGFloat horizontalLineScroll ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_horizontalLineScroll);
+    }
+
+    public CGFloat horizontalPageScroll ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_horizontalPageScroll);
+    }
+
+    public NSRulerView horizontalRulerView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_horizontalRulerView);
+        return result !is null ? new NSRulerView(result) : null;
+    }
+
+    public NSScroller horizontalScroller ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_horizontalScroller);
+        return result !is null ? new NSScroller(result) : null;
+    }
+
+    public CGFloat lineScroll ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineScroll);
+    }
+
+    public CGFloat pageScroll ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_pageScroll);
+    }
+
+    public void reflectScrolledClipView (NSClipView cView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_reflectScrolledClipView_1, cView !is null ? cView.id : null);
+    }
+
+    public static objc.Class rulerViewClass ()
+    {
+        return OS.objc_msgSend(OS.class_NSScrollView, OS.sel_rulerViewClass);
+    }
+
+    public bool rulersVisible ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rulersVisible) !is null;
+    }
+
+    public void scrollWheel (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollWheel_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public bool scrollsDynamically ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scrollsDynamically) !is null;
+    }
+
+    public void setAutohidesScrollers (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutohidesScrollers_1, flag);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBorderType (NSBorderType aType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBorderType_1, aType);
+    }
+
+    public void setContentView (NSClipView contentView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentView_1, contentView !is null ? contentView.id : null);
+    }
+
+    public void setDocumentCursor (NSCursor anObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocumentCursor_1, anObj !is null ? anObj.id : null);
+    }
+
+    public void setDocumentView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocumentView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setHasHorizontalRuler (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasHorizontalRuler_1, flag);
+    }
+
+    public void setHasHorizontalScroller (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasHorizontalScroller_1, flag);
+    }
+
+    public void setHasVerticalRuler (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasVerticalRuler_1, flag);
+    }
+
+    public void setHasVerticalScroller (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasVerticalScroller_1, flag);
+    }
+
+    public void setHorizontalLineScroll (CGFloat value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontalLineScroll_1, value);
+    }
+
+    public void setHorizontalPageScroll (CGFloat value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontalPageScroll_1, value);
+    }
+
+    public void setHorizontalRulerView (NSRulerView ruler)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontalRulerView_1, ruler !is null ? ruler.id : null);
+    }
+
+    public void setHorizontalScroller (NSScroller anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontalScroller_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setLineScroll (CGFloat value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineScroll_1, value);
+    }
+
+    public void setPageScroll (CGFloat value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPageScroll_1, value);
+    }
+
+    public static void setRulerViewClass (objc.Class rulerViewClass)
+    {
+        OS.objc_msgSend(OS.class_NSScrollView, OS.sel_setRulerViewClass_1, rulerViewClass);
+    }
+
+    public void setRulersVisible (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRulersVisible_1, flag);
+    }
+
+    public void setScrollsDynamically (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setScrollsDynamically_1, flag);
+    }
+
+    public void setVerticalLineScroll (CGFloat value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticalLineScroll_1, value);
+    }
+
+    public void setVerticalPageScroll (CGFloat value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticalPageScroll_1, value);
+    }
+
+    public void setVerticalRulerView (NSRulerView ruler)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticalRulerView_1, ruler !is null ? ruler.id : null);
+    }
+
+    public void setVerticalScroller (NSScroller anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticalScroller_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void tile ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_tile);
+    }
+
+    public CGFloat verticalLineScroll ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_verticalLineScroll);
+    }
+
+    public CGFloat verticalPageScroll ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_verticalPageScroll);
+    }
+
+    public NSRulerView verticalRulerView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_verticalRulerView);
+        return result !is null ? new NSRulerView(result) : null;
+    }
+
+    public NSScroller verticalScroller ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_verticalScroller);
+        return result !is null ? new NSScroller(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSScroller.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSScroller;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSCell : NSControlSize, NSControlTint;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import dwt.internal.objc.runtime;
+
+
+
+enum NSScrollArrowPosition
+{
+    NSScrollerArrowsMaxEnd = 0,
+    NSScrollerArrowsMinEnd = 1,
+    NSScrollerArrowsDefaultSetting = 0,
+    NSScrollerArrowsNone = 2
+}
+
+alias NSScrollArrowPosition.NSScrollerArrowsMaxEnd NSScrollerArrowsMaxEnd;
+alias NSScrollArrowPosition.NSScrollerArrowsMinEnd NSScrollerArrowsMinEnd;
+alias NSScrollArrowPosition.NSScrollerArrowsDefaultSetting NSScrollerArrowsDefaultSetting;
+alias NSScrollArrowPosition.NSScrollerArrowsNone NSScrollerArrowsNone;
+
+
+
+enum NSScrollerArrow
+{
+    NSScrollerIncrementArrow = 0,
+    NSScrollerDecrementArrow = 1
+}
+
+alias NSScrollerArrow.NSScrollerIncrementArrow NSScrollerIncrementArrow;
+alias NSScrollerArrow.NSScrollerDecrementArrow NSScrollerDecrementArrow;
+
+
+
+enum NSScrollerPart
+{
+    NSScrollerNoPart = 0,
+    NSScrollerDecrementPage = 1,
+    NSScrollerKnob = 2,
+    NSScrollerIncrementPage = 3,
+    NSScrollerDecrementLine = 4,
+    NSScrollerIncrementLine = 5,
+    NSScrollerKnobSlot = 6
+}
+
+alias NSScrollerPart.NSScrollerNoPart NSScrollerNoPart;
+alias NSScrollerPart.NSScrollerDecrementPage NSScrollerDecrementPage;
+alias NSScrollerPart.NSScrollerKnob NSScrollerKnob;
+alias NSScrollerPart.NSScrollerIncrementPage NSScrollerIncrementPage;
+alias NSScrollerPart.NSScrollerDecrementLine NSScrollerDecrementLine;
+alias NSScrollerPart.NSScrollerIncrementLine NSScrollerIncrementLine;
+alias NSScrollerPart.NSScrollerKnobSlot NSScrollerKnobSlot;
+
+
+
+enum NSUsableScrollerParts
+{
+    NSNoScrollerParts = 0,
+    NSOnlyScrollerArrows = 1,
+    NSAllScrollerParts = 2
+}
+
+alias NSUsableScrollerParts.NSNoScrollerParts NSNoScrollerParts;
+alias NSUsableScrollerParts.NSOnlyScrollerArrows NSOnlyScrollerArrows;
+alias NSUsableScrollerParts.NSAllScrollerParts NSAllScrollerParts;
+
+public class NSScroller : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScrollArrowPosition arrowsPosition ()
+    {
+        return cast(NSScrollArrowPosition) OS.objc_msgSend(this.id, OS.sel_arrowsPosition);
+    }
+
+    public void checkSpaceForParts ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_checkSpaceForParts);
+    }
+
+    public NSControlSize controlSize ()
+    {
+        return cast(NSControlSize) OS.objc_msgSend(this.id, OS.sel_controlSize);
+    }
+
+    public NSControlTint controlTint ()
+    {
+        return cast(NSControlTint) OS.objc_msgSend(this.id, OS.sel_controlTint);
+    }
+
+    public void drawArrow (NSScrollerArrow whichArrow, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawArrow_1highlight_1, whichArrow, flag);
+    }
+
+    public void drawKnob ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawKnob);
+    }
+
+    public void drawKnobSlotInRect (NSRect slotRect, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawKnobSlotInRect_1highlight_1, slotRect, flag);
+    }
+
+    public void drawParts ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawParts);
+    }
+
+    public void highlight (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_highlight_1, flag);
+    }
+
+    public NSScrollerPart hitPart ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hitPart);
+    }
+
+    public CGFloat knobProportion ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_knobProportion);
+    }
+
+    public NSRect rectForPart (NSScrollerPart partCode)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectForPart_1, partCode);
+        return result;
+    }
+
+    public static CGFloat scrollerWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSScroller, OS.sel_scrollerWidth);
+    }
+
+    public static CGFloat scrollerWidthForControlSize (NSControlSize controlSize)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSScroller, OS.sel_scrollerWidthForControlSize_1, controlSize);
+    }
+
+    public void setArrowsPosition (NSScrollArrowPosition where)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setArrowsPosition_1, where);
+    }
+
+    public void setControlSize (NSControlSize controlSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlSize_1, controlSize);
+    }
+
+    public void setControlTint (NSControlTint controlTint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlTint_1, controlTint);
+    }
+
+    public void setFloatValue (float aFloat, CGFloat proportion)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloatValue_1knobProportion_1, aFloat, proportion);
+    }
+
+    public void setKnobProportion (CGFloat proportion)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKnobProportion_1, proportion);
+    }
+
+    public NSScrollerPart testPart (NSPoint thePoint)
+    {
+        return cast(NSScrollerPart) OS.objc_msgSend(this.id, OS.sel_testPart_1, thePoint);
+    }
+
+    public void trackKnob (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_trackKnob_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void trackScrollButtons (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_trackScrollButtons_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public NSUsableScrollerParts usableParts ()
+    {
+        return cast(NSUsableScrollerParts) OS.objc_msgSend(this.id, OS.sel_usableParts);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSearchField.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSearchField;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextField;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSearchField : NSTextField
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray recentSearches ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_recentSearches);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString recentsAutosaveName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_recentsAutosaveName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setRecentSearches (NSArray searches)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRecentSearches_1, searches !is null ? searches.id : null);
+    }
+
+    public void setRecentsAutosaveName (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRecentsAutosaveName_1, string !is null ? string.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSearchFieldCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSearchFieldCell;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSButtonCell;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSearchFieldCell : NSTextFieldCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSButtonCell cancelButtonCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cancelButtonCell);
+        return result !is null ? new NSButtonCell(result) : null;
+    }
+
+    public NSRect cancelButtonRectForBounds (NSRect rect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_cancelButtonRectForBounds_1, rect);
+        return result;
+    }
+
+    public NSInteger maximumRecents ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_maximumRecents);
+    }
+
+    public NSArray recentSearches ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_recentSearches);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString recentsAutosaveName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_recentsAutosaveName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void resetCancelButtonCell ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resetCancelButtonCell);
+    }
+
+    public void resetSearchButtonCell ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resetSearchButtonCell);
+    }
+
+    public NSButtonCell searchButtonCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_searchButtonCell);
+        return result !is null ? new NSButtonCell(result) : null;
+    }
+
+    public NSRect searchButtonRectForBounds (NSRect rect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_searchButtonRectForBounds_1, rect);
+        return result;
+    }
+
+    public NSMenu searchMenuTemplate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_searchMenuTemplate);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSRect searchTextRectForBounds (NSRect rect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_searchTextRectForBounds_1, rect);
+        return result;
+    }
+
+    public bool sendsSearchStringImmediately ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendsSearchStringImmediately) !is null;
+    }
+
+    public bool sendsWholeSearchString ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_sendsWholeSearchString) !is null;
+    }
+
+    public void setCancelButtonCell (NSButtonCell cell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCancelButtonCell_1, cell !is null ? cell.id : null);
+    }
+
+    public void setMaximumRecents (NSInteger maxRecents)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaximumRecents_1, maxRecents);
+    }
+
+    public void setRecentSearches (NSArray searches)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRecentSearches_1, searches !is null ? searches.id : null);
+    }
+
+    public void setRecentsAutosaveName (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRecentsAutosaveName_1, string !is null ? string.id : null);
+    }
+
+    public void setSearchButtonCell (NSButtonCell cell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSearchButtonCell_1, cell !is null ? cell.id : null);
+    }
+
+    public void setSearchMenuTemplate (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSearchMenuTemplate_1, menu !is null ? menu.id : null);
+    }
+
+    public void setSendsSearchStringImmediately (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSendsSearchStringImmediately_1, flag);
+    }
+
+    public void setSendsWholeSearchString (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSendsWholeSearchString_1, flag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSecureTextField.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSecureTextField;
+
+import dwt.internal.cocoa.NSTextField;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSecureTextField : NSTextField
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSecureTextFieldCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSecureTextFieldCell;
+
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSecureTextFieldCell : NSTextFieldCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool echosBullets ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_echosBullets) !is null;
+    }
+
+    public void setEchosBullets (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEchosBullets_1, flag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSegmentedCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSegmentedCell;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSImageCell : NSImageScaling;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSBackgroundStyle : NSUInteger
+{
+    NSBackgroundStyleLight = 0,
+    NSBackgroundStyleDark,
+    NSBackgroundStyleRaised,
+    NSBackgroundStyleLowered
+}
+
+alias NSBackgroundStyle.NSBackgroundStyleLight NSBackgroundStyleLight;
+alias NSBackgroundStyle.NSBackgroundStyleDark NSBackgroundStyleDark;
+alias NSBackgroundStyle.NSBackgroundStyleRaised NSBackgroundStyleRaised;
+alias NSBackgroundStyle.NSBackgroundStyleLowered NSBackgroundStyleLowered;
+
+enum NSSegmentSwitchTracking
+{
+    NSSegmentSwitchTrackingSelectOne = 0,
+    NSSegmentSwitchTrackingSelectAny = 1,
+    NSSegmentSwitchTrackingMomentary = 2
+}
+
+alias NSSegmentSwitchTracking.NSSegmentSwitchTrackingSelectOne NSSegmentSwitchTrackingSelectOne;
+alias NSSegmentSwitchTracking.NSSegmentSwitchTrackingSelectAny NSSegmentSwitchTrackingSelectAny;
+alias NSSegmentSwitchTracking.NSSegmentSwitchTrackingMomentary NSSegmentSwitchTrackingMomentary;
+
+public class NSSegmentedCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void drawSegment (NSInteger segment, NSRect frame, NSView controlView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawSegment_1inFrame_1withView_1, segment, frame, controlView !is null ? controlView.id : null);
+    }
+
+    public NSImage imageForSegment (NSInteger segment)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_imageForSegment_1, segment);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImageScaling imageScalingForSegment (NSInteger segment)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageScalingForSegment_1, segment);
+    }
+
+    public NSBackgroundStyle interiorBackgroundStyleForSegment (NSInteger segment)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_interiorBackgroundStyleForSegment_1, segment);
+    }
+
+    public bool isEnabledForSegment (NSInteger segment)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabledForSegment_1, segment) !is null;
+    }
+
+    public bool isSelectedForSegment (NSInteger segment)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectedForSegment_1, segment) !is null;
+    }
+
+    public NSString labelForSegment (NSInteger segment)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_labelForSegment_1, segment);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void makeNextSegmentKey ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeNextSegmentKey);
+    }
+
+    public void makePreviousSegmentKey ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_makePreviousSegmentKey);
+    }
+
+    public NSMenu menuForSegment (NSInteger segment)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuForSegment_1, segment);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSInteger segmentCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_segmentCount);
+    }
+
+    public NSInteger segmentStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_segmentStyle);
+    }
+
+    public bool selectSegmentWithTag (NSInteger tag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectSegmentWithTag_1, tag) !is null;
+    }
+
+    public NSInteger selectedSegment ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectedSegment);
+    }
+
+    public void setEnabled (bool enabled, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1forSegment_1, enabled, segment);
+    }
+
+    public void setImage (NSImage image, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1forSegment_1, image !is null ? image.id : null, segment);
+    }
+
+    public void setImageScaling (NSImageScaling scaling, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageScaling_1forSegment_1, scaling, segment);
+    }
+
+    public void setLabel (NSString label, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLabel_1forSegment_1, label !is null ? label.id : null, segment);
+    }
+
+    public void setMenu (NSMenu menu, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1forSegment_1, menu !is null ? menu.id : null, segment);
+    }
+
+    public void setSegmentCount (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSegmentCount_1, count);
+    }
+
+    public void setSegmentStyle (NSInteger segmentStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSegmentStyle_1, segmentStyle);
+    }
+
+    public void setSelected (bool selected, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelected_1forSegment_1, selected, segment);
+    }
+
+    public void setSelectedSegment (NSInteger selectedSegment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedSegment_1, selectedSegment);
+    }
+
+    public void setTag (NSInteger tag, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTag_1forSegment_1, tag, segment);
+    }
+
+    public void setToolTip (NSString toolTip, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setToolTip_1forSegment_1, toolTip !is null ? toolTip.id : null, segment);
+    }
+
+    public void setTrackingMode (NSSegmentSwitchTracking trackingMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTrackingMode_1, trackingMode);
+    }
+
+    public void setWidth (CGFloat width, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWidth_1forSegment_1, width, segment);
+    }
+
+    public NSInteger tagForSegment (NSInteger segment)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_tagForSegment_1, segment);
+    }
+
+    public NSString toolTipForSegment (NSInteger segment)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolTipForSegment_1, segment);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSSegmentSwitchTracking trackingMode ()
+    {
+        return cast(NSSegmentSwitchTracking) OS.objc_msgSend(this.id, OS.sel_trackingMode);
+    }
+
+    public CGFloat widthForSegment (NSInteger segment)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_widthForSegment_1, segment);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSegmentedControl.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSegmentedControl;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSImageCell : NSImageScaling;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSegmentedControl : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSImage imageForSegment (NSInteger segment)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_imageForSegment_1, segment);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImageScaling imageScalingForSegment (NSInteger segment)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_imageScalingForSegment_1, segment);
+    }
+
+    public bool isEnabledForSegment (NSInteger segment)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabledForSegment_1, segment) !is null;
+    }
+
+    public bool isSelectedForSegment (NSInteger segment)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectedForSegment_1, segment) !is null;
+    }
+
+    public NSString labelForSegment (NSInteger segment)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_labelForSegment_1, segment);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSMenu menuForSegment (NSInteger segment)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuForSegment_1, segment);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public NSInteger segmentCount ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_segmentCount);
+    }
+
+    public NSInteger segmentStyle ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_segmentStyle);
+    }
+
+    public bool selectSegmentWithTag (NSInteger tag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectSegmentWithTag_1, tag) !is null;
+    }
+
+    public NSInteger selectedSegment ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectedSegment);
+    }
+
+    public void setEnabled (bool enabled, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1forSegment_1, enabled, segment);
+    }
+
+    public void setImage (NSImage image, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1forSegment_1, image !is null ? image.id : null, segment);
+    }
+
+    public void setImageScaling (NSImageScaling scaling, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImageScaling_1forSegment_1, scaling, segment);
+    }
+
+    public void setLabel (NSString label, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLabel_1forSegment_1, label !is null ? label.id : null, segment);
+    }
+
+    public void setMenu (NSMenu menu, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1forSegment_1, menu !is null ? menu.id : null, segment);
+    }
+
+    public void setSegmentCount (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSegmentCount_1, count);
+    }
+
+    public void setSegmentStyle (NSInteger segmentStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSegmentStyle_1, segmentStyle);
+    }
+
+    public void setSelected (bool selected, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelected_1forSegment_1, selected, segment);
+    }
+
+    public void setSelectedSegment (NSInteger selectedSegment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedSegment_1, selectedSegment);
+    }
+
+    public void setWidth (CGFloat width, NSInteger segment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWidth_1forSegment_1, width, segment);
+    }
+
+    public CGFloat widthForSegment (NSInteger segment)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_widthForSegment_1, segment);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSet.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSet;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSKeyValueObserving;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSet : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObserver (NSObject observer, NSString keyPath, NSKeyValueObservingOptions options, void* context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
+                keyPath !is null ? keyPath.id : null, options, context);
+    }
+
+    public NSArray allObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id anyObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_anyObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool containsObject (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsObject_1, anObject !is null ? anObject.id : null) !is null;
+    }
+
+    public NSUInteger count ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_count);
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString descriptionWithLocale (id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSSet filteredSetUsingPredicate (NSPredicate predicate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_filteredSetUsingPredicate_1, predicate !is null ? predicate.id : null);
+        return result is this.id ? this : (result !is null ? new NSSet(result) : null);
+    }
+
+    public NSSet initWithArray (NSArray array)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithArray_1, array !is null ? array.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSSet initWithObjects_ (id initWithObjects)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1, initWithObjects !is null ? initWithObjects.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSSet initWithObjects_count_ (objc.id* objects, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1count_1, objects, cnt);
+        return result !is null ? this : null;
+    }
+
+    public NSSet initWithSet_ (NSSet set)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSet_1, set !is null ? set.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSSet initWithSet_copyItems_ (NSSet set, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithSet_1copyItems_1, set !is null ? set.id : null, flag);
+        return result !is null ? this : null;
+    }
+
+    public bool intersectsSet (NSSet otherSet)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_intersectsSet_1, otherSet !is null ? otherSet.id : null) !is null;
+    }
+
+    public bool isEqualToSet (NSSet otherSet)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToSet_1, otherSet !is null ? otherSet.id : null) !is null;
+    }
+
+    public bool isSubsetOfSet (NSSet otherSet)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSubsetOfSet_1, otherSet !is null ? otherSet.id : null) !is null;
+    }
+
+    public void makeObjectsPerformSelector_ (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1, aSelector);
+    }
+
+    public void makeObjectsPerformSelector_withObject_ (objc.SEL aSelector, id argument)
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1withObject_1, aSelector, argument !is null ? argument.id : null);
+    }
+
+    public id member (id object)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_member_1, object !is null ? object.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSEnumerator objectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public void removeObserver (NSObject observer, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public static id set ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_set);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSSet setByAddingObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_setByAddingObject_1, anObject !is null ? anObject.id : null);
+        return result is this.id ? this : (result !is null ? new NSSet(result) : null);
+    }
+
+    public NSSet setByAddingObjectsFromArray (NSArray other)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_setByAddingObjectsFromArray_1, other !is null ? other.id : null);
+        return result is this.id ? this : (result !is null ? new NSSet(result) : null);
+    }
+
+    public NSSet setByAddingObjectsFromSet (NSSet other)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_setByAddingObjectsFromSet_1, other !is null ? other.id : null);
+        return result is this.id ? this : (result !is null ? new NSSet(result) : null);
+    }
+
+    public void setValue (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public static id setWithArray (NSArray array)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithArray_1, array !is null ? array.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id setWithObject (id object)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObject_1, object !is null ? object.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_setWithObjects_ (id setWithObjects)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObjects_1, setWithObjects !is null ? setWithObjects.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_setWithObjects_count_ (objc.id* objects, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObjects_1count_1, objects, cnt);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id setWithSet (NSSet set)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithSet_1, set !is null ? set.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id valueForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSetCommand.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSetCommand;
+
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSetCommand : NSScriptCommand
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSScriptObjectSpecifier keySpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_keySpecifier);
+        return result !is null ? new NSScriptObjectSpecifier(result) : null;
+    }
+
+    public void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReceiversSpecifier_1, receiversRef !is null ? receiversRef.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSShadow.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSShadow;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSShadow : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void set ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_set);
+    }
+
+    public void setShadowBlurRadius (CGFloat val)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShadowBlurRadius_1, val);
+    }
+
+    public void setShadowColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShadowColor_1, color !is null ? color.id : null);
+    }
+
+    public void setShadowOffset (NSSize offset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShadowOffset_1, offset);
+    }
+
+    public CGFloat shadowBlurRadius ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_shadowBlurRadius);
+    }
+
+    public NSColor shadowColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shadowColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSSize shadowOffset ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_shadowOffset);
+        return result;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSize.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSize;
+
+import dwt.internal.cocoa.CGFloat;
+
+alias NSSize* NSSizeArray;
+alias NSSize* NSSizePointer;
+
+struct NSSize {
+    CGFloat width;
+    CGFloat height;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSlider.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSlider;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSliderCell : NSTickMarkPosition;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSlider : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsFirstMouse (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsFirstMouse_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public bool allowsTickMarkValuesOnly ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsTickMarkValuesOnly) !is null;
+    }
+
+    public double altIncrementValue ()
+    {
+        return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_altIncrementValue);
+    }
+
+    public double closestTickMarkValueToValue (double value)
+    {
+        return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_closestTickMarkValueToValue_1, value);
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSInteger indexOfTickMarkAtPoint (NSPoint point)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfTickMarkAtPoint_1, point);
+    }
+
+    public NSInteger isVertical ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_isVertical);
+    }
+
+    public CGFloat knobThickness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_knobThickness);
+    }
+
+    public double maxValue ()
+    {
+        return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_maxValue);
+    }
+
+    public double minValue ()
+    {
+        return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_minValue);
+    }
+
+    public NSInteger numberOfTickMarks ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfTickMarks);
+    }
+
+    public NSRect rectOfTickMarkAtIndex (NSInteger index)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfTickMarkAtIndex_1, index);
+        return result;
+    }
+
+    public void setAllowsTickMarkValuesOnly (bool yorn)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsTickMarkValuesOnly_1, yorn);
+    }
+
+    public void setAltIncrementValue (double incValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAltIncrementValue_1, incValue);
+    }
+
+    public void setImage (NSImage backgroundImage)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, backgroundImage !is null ? backgroundImage.id : null);
+    }
+
+    public void setKnobThickness (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKnobThickness_1, aFloat);
+    }
+
+    public void setMaxValue (double aDouble)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxValue_1, aDouble);
+    }
+
+    public void setMinValue (double aDouble)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinValue_1, aDouble);
+    }
+
+    public void setNumberOfTickMarks (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfTickMarks_1, count);
+    }
+
+    public void setTickMarkPosition (NSTickMarkPosition position)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTickMarkPosition_1, position);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleCell (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleCell_1, aCell !is null ? aCell.id : null);
+    }
+
+    public void setTitleColor (NSColor newColor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleColor_1, newColor !is null ? newColor.id : null);
+    }
+
+    public void setTitleFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public NSTickMarkPosition tickMarkPosition ()
+    {
+        return cast(NSTickMarkPosition) OS.objc_msgSend(this.id, OS.sel_tickMarkPosition);
+    }
+
+    public double tickMarkValueAtIndex (NSInteger index)
+    {
+        return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_tickMarkValueAtIndex_1, index);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id titleCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSColor titleColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSFont titleFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleFont);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSliderCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSliderCell;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSTickMarkPosition
+{
+    NSTickMarkBelow = 0,
+    NSTickMarkAbove = 1,
+    NSTickMarkLeft = NSTickMarkAbove,
+    NSTickMarkRight = NSTickMarkBelow
+}
+
+alias NSTickMarkPosition.NSTickMarkBelow NSTickMarkBelow;
+alias NSTickMarkPosition.NSTickMarkAbove NSTickMarkAbove;
+alias NSTickMarkPosition.NSTickMarkLeft NSTickMarkLeft;
+alias NSTickMarkPosition.NSTickMarkRight NSTickMarkRight;
+
+
+
+enum NSSliderType
+{
+    NSLinearSlider = 0,
+    NSCircularSlider = 1
+}
+
+alias NSSliderType.NSLinearSlider NSLinearSlider;
+alias NSSliderType.NSCircularSlider NSCircularSlider;
+
+public class NSSliderCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool allowsTickMarkValuesOnly ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsTickMarkValuesOnly) !is null;
+    }
+
+    public double altIncrementValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_altIncrementValue);
+    }
+
+    public double closestTickMarkValueToValue (double value)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_closestTickMarkValueToValue_1, value);
+    }
+
+    public void drawBarInside (NSRect aRect, bool flipped)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawBarInside_1flipped_1, aRect, flipped);
+    }
+
+    public void drawKnob ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawKnob);
+    }
+
+    public void drawKnob_ (NSRect knobRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawKnob_1, knobRect);
+    }
+
+    public NSInteger indexOfTickMarkAtPoint (NSPoint point)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfTickMarkAtPoint_1, point);
+    }
+
+    public NSInteger isVertical ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_isVertical);
+    }
+
+    public NSRect knobRectFlipped (bool flipped)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_knobRectFlipped_1, flipped);
+        return result;
+    }
+
+    public CGFloat knobThickness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_knobThickness);
+    }
+
+    public double maxValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_maxValue);
+    }
+
+    public double minValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_minValue);
+    }
+
+    public NSInteger numberOfTickMarks ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfTickMarks);
+    }
+
+    public static bool prefersTrackingUntilMouseUp ()
+    {
+        return OS.objc_msgSend(OS.class_NSSliderCell, OS.sel_prefersTrackingUntilMouseUp) !is null;
+    }
+
+    public NSRect rectOfTickMarkAtIndex (NSInteger index)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfTickMarkAtIndex_1, index);
+        return result;
+    }
+
+    public void setAllowsTickMarkValuesOnly (bool yorn)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsTickMarkValuesOnly_1, yorn);
+    }
+
+    public void setAltIncrementValue (double incValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAltIncrementValue_1, incValue);
+    }
+
+    public void setKnobThickness (CGFloat aFloat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKnobThickness_1, aFloat);
+    }
+
+    public void setMaxValue (double aDouble)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxValue_1, aDouble);
+    }
+
+    public void setMinValue (double aDouble)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinValue_1, aDouble);
+    }
+
+    public void setNumberOfTickMarks (NSInteger count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfTickMarks_1, count);
+    }
+
+    public void setSliderType (NSSliderType sliderType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSliderType_1, sliderType);
+    }
+
+    public void setTickMarkPosition (NSTickMarkPosition position)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTickMarkPosition_1, position);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleCell (NSCell aCell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleCell_1, aCell !is null ? aCell.id : null);
+    }
+
+    public void setTitleColor (NSColor newColor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleColor_1, newColor !is null ? newColor.id : null);
+    }
+
+    public void setTitleFont (NSFont fontObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id : null);
+    }
+
+    public NSSliderType sliderType ()
+    {
+        return cast(NSSliderType) OS.objc_msgSend(this.id, OS.sel_sliderType);
+    }
+
+    public NSTickMarkPosition tickMarkPosition ()
+    {
+        return cast(NSTickMarkPosition) OS.objc_msgSend(this.id, OS.sel_tickMarkPosition);
+    }
+
+    public double tickMarkValueAtIndex (NSInteger index)
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_tickMarkValueAtIndex_1, index);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id titleCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSColor titleColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSFont titleFont ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_titleFont);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSRect trackRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_trackRect);
+        return result;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSocketPort.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSocketPort;
+
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSocketPort : NSPort
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData address ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_address);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public id initRemoteWithProtocolFamily (int family, int type, int protocol, NSData address)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initRemoteWithProtocolFamily_1socketType_1protocol_1address_1, family, type, protocol,
+                address !is null ? address.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initRemoteWithTCPPort (ushort port, NSString hostName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initRemoteWithTCPPort_1host_1, port, hostName !is null ? hostName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithProtocolFamily_socketType_protocol_address_ (int family, int type, int protocol, NSData address)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithProtocolFamily_1socketType_1protocol_1address_1, family, type, protocol,
+                address !is null ? address.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithProtocolFamily_socketType_protocol_socket_ (int family, int type, int protocol, NSSocketNativeHandle sock)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithProtocolFamily_1socketType_1protocol_1socket_1, family, type, protocol, sock);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithTCPPort (short port)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTCPPort_1, port);
+        return result !is null ? new id(result) : null;
+    }
+
+    public int protocol ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_protocol);
+    }
+
+    public int protocolFamily ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_protocolFamily);
+    }
+
+    public NSSocketNativeHandle socket ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_socket);
+    }
+
+    public int socketType ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_socketType);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSocketPortNameServer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSocketPortNameServer;
+
+import dwt.internal.cocoa.NSPort;
+import dwt.internal.cocoa.NSPortNameServer;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSocketPortNameServer : NSPortNameServer
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public ushort defaultNameServerPortNumber ()
+    {
+        return cast(ushort) OS.objc_msgSend(this.id, OS.sel_defaultNameServerPortNumber);
+    }
+
+    public NSPort portForName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public NSPort portForName_host_ (NSString name, NSString host)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1host_1, name !is null ? name.id : null, host !is null ? host.id : null);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public NSPort portForName_host_nameServerPortNumber_ (NSString name, NSString host, ushort portNumber)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_portForName_1host_1nameServerPortNumber_1, name !is null ? name.id : null,
+                host !is null ? host.id : null, portNumber);
+        return result !is null ? new NSPort(result) : null;
+    }
+
+    public bool registerPort_name_ (NSPort port, NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_registerPort_1name_1, port !is null ? port.id : null, name !is null ? name.id : null) !is null;
+    }
+
+    public bool registerPort_name_nameServerPortNumber_ (NSPort port, NSString name, ushort portNumber)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_registerPort_1name_1nameServerPortNumber_1, port !is null ? port.id : null,
+                name !is null ? name.id : null, portNumber) !is null;
+    }
+
+    public bool removePortForName (NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removePortForName_1, name !is null ? name.id : null) !is null;
+    }
+
+    public void setDefaultNameServerPortNumber (ushort portNumber)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultNameServerPortNumber_1, portNumber);
+    }
+
+    public static id sharedInstance ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSocketPortNameServer, OS.sel_sharedInstance);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSortDescriptor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSortDescriptor;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSComparisonResult;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSortDescriptor : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool ascending ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_ascending) !is null;
+    }
+
+    public NSComparisonResult compareObject (id object1, id object2)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_compareObject_1toObject_1, object1 !is null ? object1.id : null, object2 !is null ? object2.id : null);
+    }
+
+    public id initWithKey_ascending_ (NSString key, bool ascending)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithKey_1ascending_1, key !is null ? key.id : null, ascending);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithKey_ascending_selector_ (NSString key, bool ascending, objc.SEL selector)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithKey_1ascending_1selector_1, key !is null ? key.id : null, ascending, selector);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString key ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_key);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id reversedSortDescriptor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_reversedSortDescriptor);
+        return result !is null ? new id(result) : null;
+    }
+
+    public objc.SEL selector ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selector);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSound.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSound;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSound : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static bool canInitWithPasteboard (NSPasteboard pasteboard)
+    {
+        return OS.objc_msgSend(OS.class_NSSound, OS.sel_canInitWithPasteboard_1, pasteboard !is null ? pasteboard.id : null) !is null;
+    }
+
+    public NSArray channelMapping ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_channelMapping);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSTimeInterval currentTime ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_currentTime);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSTimeInterval duration ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_duration);
+    }
+
+    public id initWithContentsOfFile (NSString path, bool byRef)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1byReference_1, path !is null ? path.id : null, byRef);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithContentsOfURL (NSURL url, bool byRef)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1byReference_1, url !is null ? url.id : null, byRef);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithPasteboard (NSPasteboard pasteboard)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPasteboard_1, pasteboard !is null ? pasteboard.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isPlaying ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isPlaying) !is null;
+    }
+
+    public bool loops ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_loops) !is null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool pause ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pause) !is null;
+    }
+
+    public bool play ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_play) !is null;
+    }
+
+    public NSString playbackDeviceIdentifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_playbackDeviceIdentifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool resume ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_resume) !is null;
+    }
+
+    public void setChannelMapping (NSArray channelMapping)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setChannelMapping_1, channelMapping !is null ? channelMapping.id : null);
+    }
+
+    public void setCurrentTime (NSTimeInterval seconds)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrentTime_1, seconds);
+    }
+
+    public void setDelegate (id aDelegate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, aDelegate !is null ? aDelegate.id : null);
+    }
+
+    public void setLoops (bool val)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLoops_1, val);
+    }
+
+    public bool setName (NSString string)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setName_1, string !is null ? string.id : null) !is null;
+    }
+
+    public void setPlaybackDeviceIdentifier (NSString deviceUID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaybackDeviceIdentifier_1, deviceUID !is null ? deviceUID.id : null);
+    }
+
+    public void setVolume (float volume)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVolume_1, volume);
+    }
+
+    public static id soundNamed (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSound, OS.sel_soundNamed_1, name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static NSArray soundUnfilteredFileTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSound, OS.sel_soundUnfilteredFileTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray soundUnfilteredPasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSound, OS.sel_soundUnfilteredPasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSArray soundUnfilteredTypes ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSound, OS.sel_soundUnfilteredTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool stop ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_stop) !is null;
+    }
+
+    public float volume ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_volume);
+    }
+
+    public void writeToPasteboard (NSPasteboard pasteboard)
+    {
+        OS.objc_msgSend(this.id, OS.sel_writeToPasteboard_1, pasteboard !is null ? pasteboard.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSpecifierTest.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSpecifierTest;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSScriptWhoseTest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSTestComparisonOperation
+{
+    NSEqualToComparison = 0,
+    NSLessThanOrEqualToComparison,
+    NSLessThanComparison,
+    NSGreaterThanOrEqualToComparison,
+    NSGreaterThanComparison,
+    NSBeginsWithComparison,
+    NSEndsWithComparison,
+    NSContainsComparison
+}
+
+alias NSTestComparisonOperation.NSEqualToComparison NSEqualToComparison;
+alias NSTestComparisonOperation.NSLessThanOrEqualToComparison NSLessThanOrEqualToComparison;
+alias NSTestComparisonOperation.NSLessThanComparison NSLessThanComparison;
+alias NSTestComparisonOperation.NSGreaterThanOrEqualToComparison NSGreaterThanOrEqualToComparison;
+alias NSTestComparisonOperation.NSGreaterThanComparison NSGreaterThanComparison;
+alias NSTestComparisonOperation.NSBeginsWithComparison NSBeginsWithComparison;
+alias NSTestComparisonOperation.NSEndsWithComparison NSEndsWithComparison;
+alias NSTestComparisonOperation.NSContainsComparison NSContainsComparison;
+
+
+
+public class NSSpecifierTest : NSScriptWhoseTest
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithObjectSpecifier (NSScriptObjectSpecifier obj1, NSTestComparisonOperation compOp, id obj2)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjectSpecifier_1comparisonOperator_1testObject_1, obj1 !is null ? obj1.id : null,
+                compOp, obj2 !is null ? obj2.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSpeechRecognizer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSpeechRecognizer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSpeechRecognizer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool blocksOtherRecognizers ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_blocksOtherRecognizers) !is null;
+    }
+
+    public NSArray commands ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commands);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString displayedCommandsTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_displayedCommandsTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool listensInForegroundOnly ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_listensInForegroundOnly) !is null;
+    }
+
+    public void setBlocksOtherRecognizers (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBlocksOtherRecognizers_1, flag);
+    }
+
+    public void setCommands (NSArray commands)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCommands_1, commands !is null ? commands.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDisplayedCommandsTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDisplayedCommandsTitle_1, title !is null ? title.id : null);
+    }
+
+    public void setListensInForegroundOnly (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setListensInForegroundOnly_1, flag);
+    }
+
+    public void startListening ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_startListening);
+    }
+
+    public void stopListening ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopListening);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSpeechSynthesizer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSpeechSynthesizer;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSSpeechBoundar : NSUInteger
+{
+    NSSpeechImmediateBoundary = 0,
+    NSSpeechWordBoundary,
+    NSSpeechSentenceBoundary
+}
+
+alias NSSpeechBoundar.NSSpeechImmediateBoundary NSSpeechImmediateBoundary;
+alias NSSpeechBoundar.NSSpeechWordBoundary NSSpeechWordBoundary;
+alias NSSpeechBoundar.NSSpeechSentenceBoundary NSSpeechSentenceBoundary;
+
+
+
+public class NSSpeechSynthesizer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addSpeechDictionary (NSDictionary speechDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addSpeechDictionary_1, speechDictionary !is null ? speechDictionary.id : null);
+    }
+
+    public static NSDictionary attributesForVoice (NSString voice)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_attributesForVoice_1, voice !is null ? voice.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public static NSArray availableVoices ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_availableVoices);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void continueSpeaking ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_continueSpeaking);
+    }
+
+    public static NSString defaultVoice ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_defaultVoice);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithVoice (NSString voice)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithVoice_1, voice !is null ? voice.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static bool isAnyApplicationSpeaking ()
+    {
+        return OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_isAnyApplicationSpeaking) !is null;
+    }
+
+    public bool isSpeaking ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSpeaking) !is null;
+    }
+
+    public id objectForProperty (NSString property, objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForProperty_1error_1, property !is null ? property.id : null, outError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void pauseSpeakingAtBoundary (NSSpeechBoundar boundary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_pauseSpeakingAtBoundary_1, boundary);
+    }
+
+    public NSString phonemesFromText (NSString text)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_phonemesFromText_1, text !is null ? text.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public float rate ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_rate);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public bool setObject (id object, NSString property, objc.id** outError)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setObject_1forProperty_1error_1, object !is null ? object.id : null,
+                property !is null ? property.id : null, outError) !is null;
+    }
+
+    public void setRate (float rate)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRate_1, rate);
+    }
+
+    public void setUsesFeedbackWindow (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesFeedbackWindow_1, flag);
+    }
+
+    public bool setVoice (NSString voice)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setVoice_1, voice !is null ? voice.id : null) !is null;
+    }
+
+    public void setVolume (float volume)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVolume_1, volume);
+    }
+
+    public bool startSpeakingString_ (NSString string)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_startSpeakingString_1, string !is null ? string.id : null) !is null;
+    }
+
+    public bool startSpeakingString_toURL_ (NSString string, NSURL url)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_startSpeakingString_1toURL_1, string !is null ? string.id : null, url !is null ? url.id : null) !is null;
+    }
+
+    public void stopSpeaking ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopSpeaking);
+    }
+
+    public void stopSpeakingAtBoundary (NSSpeechBoundar boundary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopSpeakingAtBoundary_1, boundary);
+    }
+
+    public bool usesFeedbackWindow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesFeedbackWindow) !is null;
+    }
+
+    public NSString voice ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_voice);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public float volume ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_volume);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSpellChecker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSpellChecker;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPanel;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSpellChecker : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSView accessoryView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSArray availableLanguages ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableLanguages);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSRange checkGrammarOfString (NSString stringToCheck, NSInteger startingOffset, NSString language, bool wrapFlag, NSInteger tag, /*NSArray** */objc.id** details)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_checkGrammarOfString_1startingAt_1language_1wrap_1inSpellDocumentWithTag_1details_1,
+                stringToCheck !is null ? stringToCheck.id : null, startingOffset, language !is null ? language.id : null, wrapFlag, tag, details);
+        return result;
+    }
+
+    public NSRange checkSpellingOfString_startingAt_ (NSString stringToCheck, NSInteger startingOffset)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_checkSpellingOfString_1startingAt_1, stringToCheck !is null ? stringToCheck.id : null,
+                startingOffset);
+        return result;
+    }
+
+    public NSRange checkSpellingOfString_startingAt_language_wrap_inSpellDocumentWithTag_wordCount_ (NSString stringToCheck, NSInteger startingOffset,
+            NSString language, bool wrapFlag, NSInteger tag, NSInteger* wordCount)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_checkSpellingOfString_1startingAt_1language_1wrap_1inSpellDocumentWithTag_1wordCount_1,
+                stringToCheck !is null ? stringToCheck.id : null, startingOffset, language !is null ? language.id : null, wrapFlag, tag, wordCount);
+        return result;
+    }
+
+    public void closeSpellDocumentWithTag (NSInteger tag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_closeSpellDocumentWithTag_1, tag);
+    }
+
+    public NSArray completionsForPartialWordRange (NSRange range, NSString string, NSString language, NSInteger tag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_completionsForPartialWordRange_1inString_1language_1inSpellDocumentWithTag_1, range,
+                string !is null ? string.id : null, language !is null ? language.id : null, tag);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSInteger countWordsInString (NSString stringToCount, NSString language)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_countWordsInString_1language_1, stringToCount !is null ? stringToCount.id : null,
+                language !is null ? language.id : null);
+    }
+
+    public void forgetWord (NSString word)
+    {
+        OS.objc_msgSend(this.id, OS.sel_forgetWord_1, word !is null ? word.id : null);
+    }
+
+    public NSArray guessesForWord (NSString word)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_guessesForWord_1, word !is null ? word.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool hasLearnedWord (NSString word)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasLearnedWord_1, word !is null ? word.id : null) !is null;
+    }
+
+    public void ignoreWord (NSString wordToIgnore, NSInteger tag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ignoreWord_1inSpellDocumentWithTag_1, wordToIgnore !is null ? wordToIgnore.id : null, tag);
+    }
+
+    public NSArray ignoredWordsInSpellDocumentWithTag (NSInteger tag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_ignoredWordsInSpellDocumentWithTag_1, tag);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString language ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_language);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void learnWord (NSString word)
+    {
+        OS.objc_msgSend(this.id, OS.sel_learnWord_1, word !is null ? word.id : null);
+    }
+
+    public void setAccessoryView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setIgnoredWords (NSArray words, NSInteger tag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIgnoredWords_1inSpellDocumentWithTag_1, words !is null ? words.id : null, tag);
+    }
+
+    public bool setLanguage (NSString language)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setLanguage_1, language !is null ? language.id : null) !is null;
+    }
+
+    public void setWordFieldStringValue (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWordFieldStringValue_1, aString !is null ? aString.id : null);
+    }
+
+    public static NSSpellChecker sharedSpellChecker ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSSpellChecker, OS.sel_sharedSpellChecker);
+        return result !is null ? new NSSpellChecker(result) : null;
+    }
+
+    public static bool sharedSpellCheckerExists ()
+    {
+        return OS.objc_msgSend(OS.class_NSSpellChecker, OS.sel_sharedSpellCheckerExists) !is null;
+    }
+
+    public NSPanel spellingPanel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_spellingPanel);
+        return result !is null ? new NSPanel(result) : null;
+    }
+
+    public static NSInteger uniqueSpellDocumentTag ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(OS.class_NSSpellChecker, OS.sel_uniqueSpellDocumentTag);
+    }
+
+    public void unlearnWord (NSString word)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unlearnWord_1, word !is null ? word.id : null);
+    }
+
+    public void updateSpellingPanelWithGrammarString (NSString string, NSDictionary detail)
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateSpellingPanelWithGrammarString_1detail_1, string !is null ? string.id : null,
+                detail !is null ? detail.id : null);
+    }
+
+    public void updateSpellingPanelWithMisspelledWord (NSString word)
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateSpellingPanelWithMisspelledWord_1, word !is null ? word.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSpellServer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSpellServer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSSpellServer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isWordInUserDictionaries (NSString word, bool flag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isWordInUserDictionaries_1caseSensitive_1, word !is null ? word.id : null, flag) !is null;
+    }
+
+    public bool registerLanguage (NSString language, NSString vendor)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_registerLanguage_1byVendor_1, language !is null ? language.id : null,
+                vendor !is null ? vendor.id : null) !is null;
+    }
+
+    public void run ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_run);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSplitView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSplitView;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSSplitViewDividerStyle : NSInteger
+{
+    NSSplitViewDividerStyleThick = 1,
+    NSSplitViewDividerStyleThin
+}
+
+alias NSSplitViewDividerStyle.NSSplitViewDividerStyleThick NSSplitViewDividerStyleThick;
+alias NSSplitViewDividerStyle.NSSplitViewDividerStyleThin NSSplitViewDividerStyleThin;
+
+
+
+public class NSSplitView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void adjustSubviews ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_adjustSubviews);
+    }
+
+    public NSString autosaveName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_autosaveName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSColor dividerColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dividerColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSSplitViewDividerStyle dividerStyle ()
+    {
+        return cast(NSSplitViewDividerStyle) OS.objc_msgSend(this.id, OS.sel_dividerStyle);
+    }
+
+    public CGFloat dividerThickness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_dividerThickness);
+    }
+
+    public void drawDividerInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawDividerInRect_1, rect);
+    }
+
+    public bool isPaneSplitter ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isPaneSplitter) !is null;
+    }
+
+    public bool isSubviewCollapsed (NSView subview)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSubviewCollapsed_1, subview !is null ? subview.id : null) !is null;
+    }
+
+    public bool isVertical ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isVertical) !is null;
+    }
+
+    public CGFloat maxPossiblePositionOfDividerAtIndex (NSInteger dividerIndex)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_maxPossiblePositionOfDividerAtIndex_1, dividerIndex);
+    }
+
+    public CGFloat minPossiblePositionOfDividerAtIndex (NSInteger dividerIndex)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_minPossiblePositionOfDividerAtIndex_1, dividerIndex);
+    }
+
+    public void setAutosaveName (NSString autosaveName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosaveName_1, autosaveName !is null ? autosaveName.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDividerStyle (NSSplitViewDividerStyle dividerStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDividerStyle_1, dividerStyle);
+    }
+
+    public void setIsPaneSplitter (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIsPaneSplitter_1, flag);
+    }
+
+    public void setPosition (CGFloat position, NSInteger dividerIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPosition_1ofDividerAtIndex_1, position, dividerIndex);
+    }
+
+    public void setVertical (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVertical_1, flag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSStatusBar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSStatusBar;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSStatusItem;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSStatusBar : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool isVertical ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isVertical) !is null;
+    }
+
+    public void removeStatusItem (NSStatusItem item)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeStatusItem_1, item !is null ? item.id : null);
+    }
+
+    public NSStatusItem statusItemWithLength (CGFloat length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_statusItemWithLength_1, length);
+        return result !is null ? new NSStatusItem(result) : null;
+    }
+
+    public static NSStatusBar systemStatusBar ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSStatusBar, OS.sel_systemStatusBar);
+        return result !is null ? new NSStatusBar(result) : null;
+    }
+
+    public CGFloat thickness ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_thickness);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSStatusItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSStatusItem;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSStatusBar;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSStatusItem : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.SEL action ()
+    {
+        return cast(objc.SEL) OS.objc_msgSend(this.id, OS.sel_action);
+    }
+
+    public NSImage alternateImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_alternateImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSAttributedString attributedTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedTitle);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public objc.SEL doubleAction ()
+    {
+        return cast(objc.SEL) OS.objc_msgSend(this.id, OS.sel_doubleAction);
+    }
+
+    public void drawStatusBarBackgroundInRect (NSRect rect, bool highlight)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawStatusBarBackgroundInRect_1withHighlight_1, rect, highlight);
+    }
+
+    public bool highlightMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_highlightMode) !is null;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public CGFloat length ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_length);
+    }
+
+    public NSMenu menu ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public void popUpStatusItemMenu (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_popUpStatusItemMenu_1, menu !is null ? menu.id : null);
+    }
+
+    public NSInteger sendActionOn (NSInteger mask)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_sendActionOn_1, mask);
+    }
+
+    public void setAction (objc.SEL action)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, action);
+    }
+
+    public void setAlternateImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlternateImage_1, image !is null ? image.id : null);
+    }
+
+    public void setAttributedTitle (NSAttributedString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedTitle_1, title !is null ? title.id : null);
+    }
+
+    public void setDoubleAction (objc.SEL action)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleAction_1, action);
+    }
+
+    public void setEnabled (bool enabled)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, enabled);
+    }
+
+    public void setHighlightMode (bool highlightMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHighlightMode_1, highlightMode);
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setLength (CGFloat length)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLength_1, length);
+    }
+
+    public void setMenu (NSMenu menu)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenu_1, menu !is null ? menu.id : null);
+    }
+
+    public void setTarget (id target)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, target !is null ? target.id : null);
+    }
+
+    public void setTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, title !is null ? title.id : null);
+    }
+
+    public void setToolTip (NSString toolTip)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setToolTip_1, toolTip !is null ? toolTip.id : null);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public NSStatusBar statusBar ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_statusBar);
+        return result !is null ? new NSStatusBar(result) : null;
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString toolTip ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolTip);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSStepper.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSStepper;
+
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSStepper : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool autorepeat ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autorepeat) !is null;
+    }
+
+    public double increment ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_increment);
+    }
+
+    public double maxValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_maxValue);
+    }
+
+    public double minValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_minValue);
+    }
+
+    public void setAutorepeat (bool autorepeat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutorepeat_1, autorepeat);
+    }
+
+    public void setIncrement (double increment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIncrement_1, increment);
+    }
+
+    public void setMaxValue (double maxValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxValue_1, maxValue);
+    }
+
+    public void setMinValue (double minValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinValue_1, minValue);
+    }
+
+    public void setValueWraps (bool valueWraps)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValueWraps_1, valueWraps);
+    }
+
+    public bool valueWraps ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_valueWraps) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSStepperCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSStepperCell;
+
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSStepperCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool autorepeat ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autorepeat) !is null;
+    }
+
+    public double increment ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_increment);
+    }
+
+    public double maxValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_maxValue);
+    }
+
+    public double minValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_minValue);
+    }
+
+    public void setAutorepeat (bool autorepeat)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutorepeat_1, autorepeat);
+    }
+
+    public void setIncrement (double increment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIncrement_1, increment);
+    }
+
+    public void setMaxValue (double maxValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxValue_1, maxValue);
+    }
+
+    public void setMinValue (double minValue)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinValue_1, minValue);
+    }
+
+    public void setValueWraps (bool valueWraps)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValueWraps_1, valueWraps);
+    }
+
+    public bool valueWraps ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_valueWraps) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSStream;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSHost;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSStreamEvent : NSUInteger
+{
+    NSStreamEventNone = 0,
+    NSStreamEventOpenCompleted = 1 << 0,
+    NSStreamEventHasBytesAvailable = 1 << 1,
+    NSStreamEventHasSpaceAvailable = 1 << 2,
+    NSStreamEventErrorOccurred = 1 << 3,
+    NSStreamEventEndEncountered = 1 << 4
+}
+
+alias NSStreamEvent.NSStreamEventNone NSStreamEventNone;
+alias NSStreamEvent.NSStreamEventOpenCompleted NSStreamEventOpenCompleted;
+alias NSStreamEvent.NSStreamEventHasBytesAvailable NSStreamEventHasBytesAvailable;
+alias NSStreamEvent.NSStreamEventHasSpaceAvailable NSStreamEventHasSpaceAvailable;
+alias NSStreamEvent.NSStreamEventErrorOccurred NSStreamEventErrorOccurred;
+alias NSStreamEvent.NSStreamEventEndEncountered NSStreamEventEndEncountered;
+
+
+
+enum NSStreamStatus : NSUInteger
+{
+    NSStreamStatusNotOpen = 0,
+    NSStreamStatusOpening = 1,
+    NSStreamStatusOpen = 2,
+    NSStreamStatusReading = 3,
+    NSStreamStatusWriting = 4,
+    NSStreamStatusAtEnd = 5,
+    NSStreamStatusClosed = 6,
+    NSStreamStatusError = 7
+}
+
+alias NSStreamStatus.NSStreamStatusNotOpen NSStreamStatusNotOpen;
+alias NSStreamStatus.NSStreamStatusOpening NSStreamStatusOpening;
+alias NSStreamStatus.NSStreamStatusOpen NSStreamStatusOpen;
+alias NSStreamStatus.NSStreamStatusReading NSStreamStatusReading;
+alias NSStreamStatus.NSStreamStatusWriting NSStreamStatusWriting;
+alias NSStreamStatus.NSStreamStatusAtEnd NSStreamStatusAtEnd;
+alias NSStreamStatus.NSStreamStatusClosed NSStreamStatusClosed;
+alias NSStreamStatus.NSStreamStatusError NSStreamStatusError;
+
+
+
+public class NSStream : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void close ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_close);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static void getStreamsToHost (NSHost host, NSInteger port, /*NSInputStream** */objc.id** inputStream,
+            /*NSOutputStream** */objc.id** outputStream)
+    {
+        OS.objc_msgSend(OS.class_NSStream, OS.sel_getStreamsToHost_1port_1inputStream_1outputStream_1, host !is null ? host.id : null, port,
+                inputStream, outputStream);
+    }
+
+    public void open ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_open);
+    }
+
+    public id propertyForKey (NSString key)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyForKey_1, key !is null ? key.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void removeFromRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFromRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void scheduleInRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scheduleInRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public bool setProperty (id property, NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setProperty_1forKey_1, property !is null ? property.id : null, key !is null ? key.id : null) !is null;
+    }
+
+    public NSError streamError ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_streamError);
+        return result !is null ? new NSError(result) : null;
+    }
+
+    public NSStreamStatus streamStatus ()
+    {
+        return cast(NSStreamStatus) OS.objc_msgSend(this.id, OS.sel_streamStatus);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSString.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,941 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSString;
+
+import tango.core.Vararg : va_list;
+import tango.stdc.stringz : toStringz;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCharacterSet;
+import dwt.internal.cocoa.NSComparisonResult;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSLocale;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSStringEncoding : NSUInteger
+{
+    NSASCIIStringEncoding = 1,
+    NSNEXTSTEPStringEncoding = 2,
+    NSJapaneseEUCStringEncoding = 3,
+    NSUTF8StringEncoding = 4,
+    NSISOLatin1StringEncoding = 5,
+    NSSymbolStringEncoding = 6,
+    NSNonLossyASCIIStringEncoding = 7,
+    NSShiftJISStringEncoding = 8,
+    NSISOLatin2StringEncoding = 9,
+    NSUnicodeStringEncoding = 10,
+    NSWindowsCP1251StringEncoding = 11,
+    NSWindowsCP1252StringEncoding = 12,
+    NSWindowsCP1253StringEncoding = 13,
+    NSWindowsCP1254StringEncoding = 14,
+    NSWindowsCP1250StringEncoding = 15,
+    NSISO2022JPStringEncoding = 21,
+    NSMacOSRomanStringEncoding = 30,
+    NSUTF16BigEndianStringEncoding = 0x90000100,
+    NSUTF16LittleEndianStringEncoding = 0x94000100,
+    NSUTF32StringEncoding = 0x8c000100,
+    NSUTF32BigEndianStringEncoding = 0x98000100,
+    NSUTF32LittleEndianStringEncoding = 0x9c000100,
+    NSProprietaryStringEncoding = 65536
+}
+
+alias NSStringEncoding.NSASCIIStringEncoding NSASCIIStringEncoding;
+alias NSStringEncoding.NSNEXTSTEPStringEncoding NSNEXTSTEPStringEncoding;
+alias NSStringEncoding.NSJapaneseEUCStringEncoding NSJapaneseEUCStringEncoding;
+alias NSStringEncoding.NSUTF8StringEncoding NSUTF8StringEncoding;
+alias NSStringEncoding.NSISOLatin1StringEncoding NSISOLatin1StringEncoding;
+alias NSStringEncoding.NSSymbolStringEncoding NSSymbolStringEncoding;
+alias NSStringEncoding.NSNonLossyASCIIStringEncoding NSNonLossyASCIIStringEncoding;
+alias NSStringEncoding.NSShiftJISStringEncoding NSShiftJISStringEncoding;
+alias NSStringEncoding.NSISOLatin2StringEncoding NSISOLatin2StringEncoding;
+alias NSStringEncoding.NSUnicodeStringEncoding NSUnicodeStringEncoding;
+alias NSStringEncoding.NSWindowsCP1251StringEncoding NSWindowsCP1251StringEncoding;
+alias NSStringEncoding.NSWindowsCP1252StringEncoding NSWindowsCP1252StringEncoding;
+alias NSStringEncoding.NSWindowsCP1253StringEncoding NSWindowsCP1253StringEncoding;
+alias NSStringEncoding.NSWindowsCP1254StringEncoding NSWindowsCP1254StringEncoding;
+alias NSStringEncoding.NSWindowsCP1250StringEncoding NSWindowsCP1250StringEncoding;
+alias NSStringEncoding.NSISO2022JPStringEncoding NSISO2022JPStringEncoding;
+alias NSStringEncoding.NSMacOSRomanStringEncoding NSMacOSRomanStringEncoding;
+alias NSStringEncoding.NSUTF16BigEndianStringEncoding NSUTF16BigEndianStringEncoding;
+alias NSStringEncoding.NSUTF16LittleEndianStringEncoding NSUTF16LittleEndianStringEncoding;
+alias NSStringEncoding.NSUTF32StringEncoding NSUTF32StringEncoding;
+alias NSStringEncoding.NSUTF32BigEndianStringEncoding NSUTF32BigEndianStringEncoding;
+alias NSStringEncoding.NSUTF32LittleEndianStringEncoding NSUTF32LittleEndianStringEncoding;
+alias NSStringEncoding.NSProprietaryStringEncoding NSProprietaryStringEncoding;
+
+enum NSStringCompareOptions : NSUInteger
+{
+    NSCaseInsensitiveSearch = 1,
+    NSLiteralSearch = 2,
+    NSBackwardsSearch = 4,
+    NSAnchoredSearch = 8,
+    NSNumericSearch = 64,
+    NSDiacriticInsensitiveSearch = 128,
+    NSWidthInsensitiveSearch = 256,
+    NSForcedOrderingSearch = 512
+}
+
+alias NSStringCompareOptions.NSCaseInsensitiveSearch NSCaseInsensitiveSearch;
+alias NSStringCompareOptions.NSLiteralSearch NSLiteralSearch;
+alias NSStringCompareOptions.NSBackwardsSearch NSBackwardsSearch;
+alias NSStringCompareOptions.NSAnchoredSearch NSAnchoredSearch;
+alias NSStringCompareOptions.NSNumericSearch NSNumericSearch;
+alias NSStringCompareOptions.NSDiacriticInsensitiveSearch NSDiacriticInsensitiveSearch;
+alias NSStringCompareOptions.NSWidthInsensitiveSearch NSWidthInsensitiveSearch;
+alias NSStringCompareOptions.NSForcedOrderingSearch NSForcedOrderingSearch;
+
+enum NSStringEncodingConversionOptions : NSUInteger
+{
+    NSStringEncodingConversionAllowLossy = 1,
+    NSStringEncodingConversionExternalRepresentation = 2
+}
+
+alias NSStringEncodingConversionOptions.NSStringEncodingConversionAllowLossy NSStringEncodingConversionAllowLossy;
+alias NSStringEncodingConversionOptions.NSStringEncodingConversionExternalRepresentation NSStringEncodingConversionExternalRepresentation;
+
+public class NSString : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public /*const*/char* UTF8String ()
+    {
+        return cast(/*const*/char*) OS.objc_msgSend(this.id, OS.sel_UTF8String);
+    }
+
+    public static NSStringEncoding availableStringEncodings ()
+    {
+        return cast(NSStringEncoding) OS.objc_msgSend(OS.class_NSString, OS.sel_availableStringEncodings);
+    }
+
+    public bool boolValue ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_boolValue) !is null;
+    }
+
+    public /*const char* */byte* cString ()
+    {
+        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_cString);
+    }
+
+    public NSUInteger cStringLength ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_cStringLength);
+    }
+
+    public /*const char* */byte* cStringUsingEncoding (NSStringEncoding encoding)
+    {
+        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_cStringUsingEncoding_1, encoding);
+    }
+
+    public bool canBeConvertedToEncoding (NSStringEncoding encoding)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canBeConvertedToEncoding_1, encoding) !is null;
+    }
+
+    public NSString capitalizedString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_capitalizedString);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSComparisonResult caseInsensitiveCompare (NSString string)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_caseInsensitiveCompare_1, string !is null ? string.id : null);
+    }
+
+    public wchar characterAtIndex (NSUInteger index)
+    {
+        return cast(wchar) OS.objc_msgSend(this.id, OS.sel_characterAtIndex_1, index);
+    }
+
+    public NSString commonPrefixWithString (NSString aString, NSStringCompareOptions mask)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_commonPrefixWithString_1options_1, aString !is null ? aString.id : null, mask);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSComparisonResult compare_ (NSString string)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_compare_1, string !is null ? string.id : null);
+    }
+
+    public NSComparisonResult compare_options_ (NSString string, NSStringCompareOptions mask)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_compare_1options_1, string !is null ? string.id : null, mask);
+    }
+
+    public NSComparisonResult compare_options_range_ (NSString string, NSStringCompareOptions mask, NSRange compareRange)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_compare_1options_1range_1, string !is null ? string.id : null, mask,
+                compareRange);
+    }
+
+    public NSComparisonResult compare_options_range_locale_ (NSString string, NSStringCompareOptions mask, NSRange compareRange, id locale)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_compare_1options_1range_1locale_1, string !is null ? string.id : null, mask,
+                compareRange, locale !is null ? locale.id : null);
+    }
+
+    public NSUInteger completePathIntoString (/*NSString** */objc.id** outputName, bool flag, /*NSArray** */objc.id** outputArray,
+            NSArray filterTypes)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_completePathIntoString_1caseSensitive_1matchesIntoArray_1filterTypes_1, outputName, flag, outputArray,
+                filterTypes !is null ? filterTypes.id : null);
+    }
+
+    public NSArray componentsSeparatedByCharactersInSet (NSCharacterSet separator)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_componentsSeparatedByCharactersInSet_1, separator !is null ? separator.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray componentsSeparatedByString (NSString separator)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_componentsSeparatedByString_1, separator !is null ? separator.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSData dataUsingEncoding_ (NSStringEncoding encoding)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataUsingEncoding_1, encoding);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData dataUsingEncoding_allowLossyConversion_ (NSStringEncoding encoding, bool lossy)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataUsingEncoding_1allowLossyConversion_1, encoding, lossy);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSString decomposedStringWithCanonicalMapping ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decomposedStringWithCanonicalMapping);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString decomposedStringWithCompatibilityMapping ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_decomposedStringWithCompatibilityMapping);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public static NSStringEncoding defaultCStringEncoding ()
+    {
+        return cast(NSStringEncoding) OS.objc_msgSend(OS.class_NSString, OS.sel_defaultCStringEncoding);
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public double doubleValue ()
+    {
+        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
+    }
+
+    public NSStringEncoding fastestEncoding ()
+    {
+        return cast(NSStringEncoding) OS.objc_msgSend(this.id, OS.sel_fastestEncoding);
+    }
+
+    public /*const char* */byte* fileSystemRepresentation ()
+    {
+        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_fileSystemRepresentation);
+    }
+
+    public float floatValue ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatValue);
+    }
+
+    public bool getBytes (void* buffer, NSUInteger maxBufferCount, NSUInteger* usedBufferCount, NSStringEncoding encoding, NSStringEncodingConversionOptions options,
+            NSRange range, NSRangePointer leftover)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getBytes_1maxLength_1usedLength_1encoding_1options_1range_1remainingRange_1, buffer, maxBufferCount,
+                usedBufferCount, encoding, options, range, leftover) !is null;
+    }
+
+    public void getCString_ (/*char* */byte* bytes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getCString_1, bytes);
+    }
+
+    public void getCString_maxLength_ (/*char* */byte* bytes, NSUInteger maxLength)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getCString_1maxLength_1, bytes, maxLength);
+    }
+
+    public bool getCString_maxLength_encoding_ (/*char* */byte* buffer, NSUInteger maxBufferCount, NSStringEncoding encoding)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getCString_1maxLength_1encoding_1, buffer, maxBufferCount, encoding) !is null;
+    }
+
+    public void getCString_maxLength_range_remainingRange_ (/*char* */byte* bytes, NSUInteger maxLength, NSRange aRange, NSRangePointer leftoverRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getCString_1maxLength_1range_1remainingRange_1, bytes, maxLength, aRange, leftoverRange);
+    }
+
+    public void getCharacters_ (wchar* buffer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getCharacters_1, buffer);
+    }
+
+    public void getCharacters_range_ (wchar* buffer, NSRange aRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getCharacters_1range_1, buffer, aRange);
+    }
+
+    public bool getFileSystemRepresentation (/*char* */byte* cname, NSUInteger max)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getFileSystemRepresentation_1maxLength_1, cname, max) !is null;
+    }
+
+    public void getLineStart (NSUInteger* startPtr, NSUInteger* lineEndPtr, NSUInteger* contentsEndPtr, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getLineStart_1end_1contentsEnd_1forRange_1, startPtr, lineEndPtr, contentsEndPtr, range);
+    }
+
+    public void getParagraphStart (NSUInteger* startPtr, NSUInteger* parEndPtr, NSUInteger* contentsEndPtr, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getParagraphStart_1end_1contentsEnd_1forRange_1, startPtr, parEndPtr, contentsEndPtr, range);
+    }
+
+    public bool hasPrefix (NSString aString)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasPrefix_1, aString !is null ? aString.id : null) !is null;
+    }
+
+    public bool hasSuffix (NSString aString)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasSuffix_1, aString !is null ? aString.id : null) !is null;
+    }
+
+    public NSUInteger hash ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_hash);
+    }
+
+    public NSString initWithBytes (/*const*/void* bytes, NSUInteger len, NSStringEncoding encoding)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytes_1length_1encoding_1, bytes, len, encoding);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithBytesNoCopy (/*const*/void* bytes, NSUInteger len, NSStringEncoding encoding, bool freeBuffer)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytesNoCopy_1length_1encoding_1freeWhenDone_1, bytes, len, encoding, freeBuffer);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithCString_ (/*const char* */byte* bytes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCString_1, bytes);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithCString_encoding_ (/*const char* */byte* nullTerminatedCString, NSStringEncoding encoding)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCString_1encoding_1, nullTerminatedCString, encoding);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithCString_length_ (/*const char* */byte* bytes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCString_1length_1, bytes, length);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithCStringNoCopy (/*const char* */byte* bytes, NSUInteger length, bool freeBuffer)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCStringNoCopy_1length_1freeWhenDone_1, bytes, length, freeBuffer);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithCharacters (/*const*/wchar* characters, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCharacters_1length_1, characters, length);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithCharactersNoCopy (/*const*/wchar* characters, NSUInteger length, bool freeBuffer)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCharactersNoCopy_1length_1freeWhenDone_1, characters, length, freeBuffer);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithContentsOfFile_ (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithContentsOfFile_encoding_error_ (NSString path, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1encoding_1error_1, path !is null ? path.id : null, enc, error);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithContentsOfFile_usedEncoding_error_ (NSString path, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1usedEncoding_1error_1, path !is null ? path.id : null, enc, error);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithContentsOfURL_ (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithContentsOfURL_encoding_error_ (NSURL url, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1encoding_1error_1, url !is null ? url.id : null, enc, error);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithContentsOfURL_usedEncoding_error_ (NSURL url, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1usedEncoding_1error_1, url !is null ? url.id : null, enc, error);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithData (NSData data, NSStringEncoding encoding)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1encoding_1, data !is null ? data.id : null, encoding);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithFormat_ (NSString initWithFormat)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFormat_1, initWithFormat !is null ? initWithFormat.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithFormat_arguments_ (NSString format, va_list argList)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFormat_1arguments_1, format !is null ? format.id : null, argList);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithFormat_locale_ (NSString format, id locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFormat_1locale_1, format !is null ? format.id : null,
+                locale !is null ? locale.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithFormat_locale_arguments_ (NSString format, id locale, va_list argList)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFormat_1locale_1arguments_1, format !is null ? format.id : null,
+                locale !is null ? locale.id : null, argList);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithString (NSString aString)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, aString !is null ? aString.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSString initWithUTF8String (/*const*/char* nullTerminatedCString)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUTF8String_1, nullTerminatedCString);
+        return result !is null ? this : null;
+    }
+
+    public int intValue ()
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_intValue);
+    }
+
+    public NSInteger integerValue ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_integerValue);
+    }
+
+    public bool isAbsolutePath ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAbsolutePath) !is null;
+    }
+
+    public bool isEqualToString (NSString aString)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToString_1, aString !is null ? aString.id : null) !is null;
+    }
+
+    public NSString lastPathComponent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lastPathComponent);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSUInteger length ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_length);
+    }
+
+    public NSUInteger lengthOfBytesUsingEncoding (NSStringEncoding enc)
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_lengthOfBytesUsingEncoding_1, enc);
+    }
+
+    public NSRange lineRangeForRange (NSRange range)
+    {
+        NSRange result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_lineRangeForRange_1, range);
+        return result;
+    }
+
+    public NSComparisonResult localizedCaseInsensitiveCompare (NSString string)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_localizedCaseInsensitiveCompare_1, string !is null ? string.id : null);
+    }
+
+    public NSComparisonResult localizedCompare (NSString string)
+    {
+        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_localizedCompare_1, string !is null ? string.id : null);
+    }
+
+    public static NSString localizedNameOfStringEncoding (NSStringEncoding encoding)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_localizedNameOfStringEncoding_1, encoding);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id localizedStringWithFormat (NSString localizedStringWithFormat)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_localizedStringWithFormat_1,
+                localizedStringWithFormat !is null ? localizedStringWithFormat.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public long longLongValue ()
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_longLongValue);
+    }
+
+    public /*const char* */byte* lossyCString ()
+    {
+        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_lossyCString);
+    }
+
+    public NSString lowercaseString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lowercaseString);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSUInteger maximumLengthOfBytesUsingEncoding (NSStringEncoding enc)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_maximumLengthOfBytesUsingEncoding_1, enc);
+    }
+
+    public NSRange paragraphRangeForRange (NSRange range)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_paragraphRangeForRange_1, range);
+        return result;
+    }
+
+    public NSArray pathComponents ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathComponents);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString pathExtension ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathExtension);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public static NSString pathWithComponents (NSArray components)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_pathWithComponents_1, components !is null ? components.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString precomposedStringWithCanonicalMapping ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_precomposedStringWithCanonicalMapping);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString precomposedStringWithCompatibilityMapping ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_precomposedStringWithCompatibilityMapping);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public id propertyList ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyList);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary propertyListFromStringsFileFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyListFromStringsFileFormat);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSRange rangeOfCharacterFromSet_ (NSCharacterSet aSet)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfCharacterFromSet_1, aSet !is null ? aSet.id : null);
+        return result;
+    }
+
+    public NSRange rangeOfCharacterFromSet_options_ (NSCharacterSet aSet, NSStringCompareOptions mask)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfCharacterFromSet_1options_1, aSet !is null ? aSet.id : null, mask);
+        return result;
+    }
+
+    public NSRange rangeOfCharacterFromSet_options_range_ (NSCharacterSet aSet, NSStringCompareOptions mask, NSRange searchRange)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfCharacterFromSet_1options_1range_1, aSet !is null ? aSet.id : null, mask, searchRange);
+        return result;
+    }
+
+    public NSRange rangeOfComposedCharacterSequenceAtIndex (NSUInteger index)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfComposedCharacterSequenceAtIndex_1, index);
+        return result;
+    }
+
+    public NSRange rangeOfComposedCharacterSequencesForRange (NSRange range)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfComposedCharacterSequencesForRange_1, range);
+        return result;
+    }
+
+    public NSRange rangeOfString_ (NSString aString)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfString_1, aString !is null ? aString.id : null);
+        return result;
+    }
+
+    public NSRange rangeOfString_options_ (NSString aString, NSStringCompareOptions mask)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfString_1options_1, aString !is null ? aString.id : null, mask);
+        return result;
+    }
+
+    public NSRange rangeOfString_options_range_ (NSString aString, NSStringCompareOptions mask, NSRange searchRange)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfString_1options_1range_1, aString !is null ? aString.id : null, mask, searchRange);
+        return result;
+    }
+
+    public NSRange rangeOfString_options_range_locale_ (NSString aString, NSStringCompareOptions mask, NSRange searchRange, NSLocale locale)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeOfString_1options_1range_1locale_1, aString !is null ? aString.id : null, mask,
+                searchRange, locale !is null ? locale.id : null);
+        return result;
+    }
+
+    public NSStringEncoding smallestEncoding ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_smallestEncoding);
+    }
+
+    public static NSString string ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_string);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString stringByAbbreviatingWithTildeInPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByAbbreviatingWithTildeInPath);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByAddingPercentEscapesUsingEncoding (NSStringEncoding enc)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByAddingPercentEscapesUsingEncoding_1, enc);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByAppendingFormat (NSString stringByAppendingFormat)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByAppendingFormat_1,
+                stringByAppendingFormat !is null ? stringByAppendingFormat.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByAppendingPathComponent (NSString str)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByAppendingPathComponent_1, str !is null ? str.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByAppendingPathExtension (NSString str)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByAppendingPathExtension_1, str !is null ? str.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByAppendingString (NSString aString)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByAppendingString_1, aString !is null ? aString.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByDeletingLastPathComponent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByDeletingLastPathComponent);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByDeletingPathExtension ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByDeletingPathExtension);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByExpandingTildeInPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByExpandingTildeInPath);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByFoldingWithOptions (NSStringCompareOptions options, NSLocale locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByFoldingWithOptions_1locale_1, options, locale !is null ? locale.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByPaddingToLength (NSUInteger newLength, NSString padString, NSUInteger padIndex)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByPaddingToLength_1withString_1startingAtIndex_1, newLength,
+                padString !is null ? padString.id : null, padIndex);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByReplacingCharactersInRange (NSRange range, NSString replacement)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByReplacingCharactersInRange_1withString_1, range,
+                replacement !is null ? replacement.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByReplacingOccurrencesOfString_withString_ (NSString target, NSString replacement)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByReplacingOccurrencesOfString_1withString_1, target !is null ? target.id : null,
+                replacement !is null ? replacement.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByReplacingOccurrencesOfString_withString_options_range_ (NSString target, NSString replacement, NSStringCompareOptions options,
+            NSRange searchRange)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByReplacingOccurrencesOfString_1withString_1options_1range_1,
+                target !is null ? target.id : null, replacement !is null ? replacement.id : null, options, searchRange);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByReplacingPercentEscapesUsingEncoding (NSStringEncoding enc)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByReplacingPercentEscapesUsingEncoding_1, enc);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByResolvingSymlinksInPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByResolvingSymlinksInPath);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByStandardizingPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByStandardizingPath);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString stringByTrimmingCharactersInSet (NSCharacterSet set)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringByTrimmingCharactersInSet_1, set !is null ? set.id : null);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public static id static_stringWithCString_ (/*const char* */byte* bytes)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithCString_1, bytes);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id static_stringWithCString_encoding_ (/*const char* */byte* cString, NSStringEncoding enc)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithCString_1encoding_1, cString, enc);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString static_stringWithCString_length_ (/*const char* */byte* bytes, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithCString_1length_1, bytes, length);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString stringWithCharacters (/*const*/wchar* characters, NSUInteger length)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithCharacters_1length_1, characters, length);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString stringWith (String str)
+    {
+        char[] chars = str.dup;
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithCharacters_1length_1, chars.toStringz(), chars.length);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id static_stringWithContentsOfFile_ (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_stringWithContentsOfFile_encoding_error_ (NSString path, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithContentsOfFile_1encoding_1error_1, path !is null ? path.id : null, enc,
+                error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_stringWithContentsOfFile_usedEncoding_error_ (NSString path, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithContentsOfFile_1usedEncoding_1error_1, path !is null ? path.id : null,
+                enc, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_stringWithContentsOfURL_ (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_stringWithContentsOfURL_encoding_error_ (NSURL url, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithContentsOfURL_1encoding_1error_1, url !is null ? url.id : null, enc,
+                error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_stringWithContentsOfURL_usedEncoding_error_ (NSURL url, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithContentsOfURL_1usedEncoding_1error_1, url !is null ? url.id : null, enc,
+                error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id stringWithFormat (NSString stringWithFormat)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithFormat_1, stringWithFormat !is null ? stringWithFormat.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id stringWithString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithString_1, string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id stringWithUTF8String (/*const*/char* nullTerminatedCString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithUTF8String_1, nullTerminatedCString);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray stringsByAppendingPaths (NSArray paths)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringsByAppendingPaths_1, paths !is null ? paths.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString substringFromIndex (NSUInteger from)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_substringFromIndex_1, from);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString substringToIndex (NSUInteger to)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_substringToIndex_1, to);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString substringWithRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_substringWithRange_1, range);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public NSString uppercaseString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_uppercaseString);
+        return result is this.id ? this : (result !is null ? new NSString(result) : null);
+    }
+
+    public bool writeToFile_atomically_ (NSString path, bool useAuxiliaryFile)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1, path !is null ? path.id : null, useAuxiliaryFile) !is null;
+    }
+
+    public bool writeToFile_atomically_encoding_error_ (NSString path, bool useAuxiliaryFile, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1encoding_1error_1, path !is null ? path.id : null, useAuxiliaryFile, enc,
+                error) !is null;
+    }
+
+    public bool writeToURL_atomically_ (NSURL url, bool atomically)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1atomically_1, url !is null ? url.id : null, atomically) !is null;
+    }
+
+    public bool writeToURL_atomically_encoding_error_ (NSURL url, bool useAuxiliaryFile, NSStringEncoding enc, /*NSError** */objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeToURL_1atomically_1encoding_1error_1, url !is null ? url.id : null, useAuxiliaryFile, enc, error) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSwappedDouble.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSwappedDouble;
+
+struct NSSwappedDouble {
+    long v;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSSwappedFloat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSSwappedFloat;
+
+struct NSSwappedFloat {
+    int v;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTabView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTabView;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCell : NSControlSize, NSControlTint;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSTabViewItem;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTabViewType
+{
+    NSTopTabsBezelBorder = 0,
+    NSLeftTabsBezelBorder = 1,
+    NSBottomTabsBezelBorder = 2,
+    NSRightTabsBezelBorder = 3,
+    NSNoTabsBezelBorder = 4,
+    NSNoTabsLineBorder = 5,
+    NSNoTabsNoBorder = 6
+}
+
+alias NSTabViewType.NSTopTabsBezelBorder NSTopTabsBezelBorder;
+alias NSTabViewType.NSLeftTabsBezelBorder NSLeftTabsBezelBorder;
+alias NSTabViewType.NSBottomTabsBezelBorder NSBottomTabsBezelBorder;
+alias NSTabViewType.NSRightTabsBezelBorder NSRightTabsBezelBorder;
+alias NSTabViewType.NSNoTabsBezelBorder NSNoTabsBezelBorder;
+alias NSTabViewType.NSNoTabsLineBorder NSNoTabsLineBorder;
+alias NSTabViewType.NSNoTabsNoBorder NSNoTabsNoBorder;
+
+public class NSTabView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addTabViewItem (NSTabViewItem tabViewItem)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTabViewItem_1, tabViewItem !is null ? tabViewItem.id : null);
+    }
+
+    public bool allowsTruncatedLabels ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsTruncatedLabels) !is null;
+    }
+
+    public NSRect contentRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentRect);
+        return result;
+    }
+
+    public NSControlSize controlSize ()
+    {
+        return cast(NSControlSize) OS.objc_msgSend(this.id, OS.sel_controlSize);
+    }
+
+    public NSControlTint controlTint ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_controlTint);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public NSFont font ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSInteger indexOfTabViewItem (NSTabViewItem tabViewItem)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfTabViewItem_1, tabViewItem !is null ? tabViewItem.id : null);
+    }
+
+    public NSInteger indexOfTabViewItemWithIdentifier (id identifier)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfTabViewItemWithIdentifier_1, identifier !is null ? identifier.id : null);
+    }
+
+    public void insertTabViewItem (NSTabViewItem tabViewItem, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertTabViewItem_1atIndex_1, tabViewItem !is null ? tabViewItem.id : null, index);
+    }
+
+    public NSSize minimumSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_minimumSize);
+        return result;
+    }
+
+    public NSInteger numberOfTabViewItems ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfTabViewItems);
+    }
+
+    public void removeTabViewItem (NSTabViewItem tabViewItem)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeTabViewItem_1, tabViewItem !is null ? tabViewItem.id : null);
+    }
+
+    public void selectFirstTabViewItem (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectFirstTabViewItem_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectLastTabViewItem (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectLastTabViewItem_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectNextTabViewItem (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectNextTabViewItem_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectPreviousTabViewItem (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectPreviousTabViewItem_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectTabViewItem (NSTabViewItem tabViewItem)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectTabViewItem_1, tabViewItem !is null ? tabViewItem.id : null);
+    }
+
+    public void selectTabViewItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectTabViewItemAtIndex_1, index);
+    }
+
+    public void selectTabViewItemWithIdentifier (id identifier)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectTabViewItemWithIdentifier_1, identifier !is null ? identifier.id : null);
+    }
+
+    public NSTabViewItem selectedTabViewItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedTabViewItem);
+        return result !is null ? new NSTabViewItem(result) : null;
+    }
+
+    public void setAllowsTruncatedLabels (bool allowTruncatedLabels)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsTruncatedLabels_1, allowTruncatedLabels);
+    }
+
+    public void setControlSize (NSControlSize controlSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlSize_1, controlSize);
+    }
+
+    public void setControlTint (NSControlTint controlTint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setControlTint_1, controlTint);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setFont (NSFont font)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, font !is null ? font.id : null);
+    }
+
+    public void setTabViewType (NSTabViewType tabViewType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTabViewType_1, tabViewType);
+    }
+
+    public NSTabViewItem tabViewItemAtIndex (NSInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tabViewItemAtIndex_1, index);
+        return result !is null ? new NSTabViewItem(result) : null;
+    }
+
+    public NSTabViewItem tabViewItemAtPoint (NSPoint point)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tabViewItemAtPoint_1, point);
+        return result !is null ? new NSTabViewItem(result) : null;
+    }
+
+    public NSArray tabViewItems ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tabViewItems);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSTabViewType tabViewType ()
+    {
+        return cast(NSTabViewType) OS.objc_msgSend(this.id, OS.sel_tabViewType);
+    }
+
+    public void takeSelectedTabViewItemFromSender (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_takeSelectedTabViewItemFromSender_1, sender !is null ? sender.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTabViewItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTabViewItem;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTabView;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTabState
+{
+    NSSelectedTab = 0,
+    NSBackgroundTab = 1,
+    NSPressedTab = 2
+}
+
+alias NSTabState.NSSelectedTab NSSelectedTab;
+alias NSTabState.NSBackgroundTab NSBackgroundTab;
+alias NSTabState.NSPressedTab NSPressedTab;
+
+public class NSTabViewItem : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSColor color ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_color);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void drawLabel (bool shouldTruncateLabel, NSRect labelRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawLabel_1inRect_1, shouldTruncateLabel, labelRect);
+    }
+
+    public id identifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_identifier);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSTabViewItem initWithIdentifier (id identifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIdentifier_1, identifier !is null ? identifier.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSTabViewItem initialFirstResponder ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initialFirstResponder);
+        return result !is null ? this : null;
+    }
+
+    public NSString label ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_label);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColor_1, color !is null ? color.id : null);
+    }
+
+    public void setIdentifier (id identifier)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIdentifier_1, identifier !is null ? identifier.id : null);
+    }
+
+    public void setInitialFirstResponder (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInitialFirstResponder_1, view !is null ? view.id : null);
+    }
+
+    public void setLabel (NSString label)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLabel_1, label !is null ? label.id : null);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public NSSize sizeOfLabel (bool computeMin)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_sizeOfLabel_1, computeMin);
+        return result;
+    }
+
+    public NSTabState tabState ()
+    {
+        return cast(NSTabState) OS.objc_msgSend(this.id, OS.sel_tabState);
+    }
+
+    public NSTabView tabView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tabView);
+        return result !is null ? new NSTabView(result) : null;
+    }
+
+    public id view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTableColumn.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTableColumn;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSSortDescriptor;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableHeaderCell;
+import dwt.internal.cocoa.NSTableView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTableColumn : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id dataCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id dataCellForRow (NSInteger row)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataCellForRow_1, row);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSTableHeaderCell headerCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_headerCell);
+        return result !is null ? new NSTableHeaderCell(result) : null;
+    }
+
+    public NSString headerToolTip ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_headerToolTip);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id identifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_identifier);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSTableColumn initWithIdentifier (id identifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIdentifier_1, identifier !is null ? identifier.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public bool isHidden ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHidden) !is null;
+    }
+
+    public bool isResizable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isResizable) !is null;
+    }
+
+    public CGFloat maxWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_maxWidth);
+    }
+
+    public CGFloat minWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_minWidth);
+    }
+
+    public NSUInteger resizingMask ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_resizingMask);
+    }
+
+    public void setDataCell (NSCell cell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDataCell_1, cell !is null ? cell.id : null);
+    }
+
+    public void setEditable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag);
+    }
+
+    public void setHeaderCell (NSCell cell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHeaderCell_1, cell !is null ? cell.id : null);
+    }
+
+    public void setHeaderToolTip (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHeaderToolTip_1, string !is null ? string.id : null);
+    }
+
+    public void setHidden (bool hidden)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHidden_1, hidden);
+    }
+
+    public void setIdentifier (id identifier)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIdentifier_1, identifier !is null ? identifier.id : null);
+    }
+
+    public void setMaxWidth (CGFloat maxWidth)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxWidth_1, maxWidth);
+    }
+
+    public void setMinWidth (CGFloat minWidth)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinWidth_1, minWidth);
+    }
+
+    public void setResizable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setResizable_1, flag);
+    }
+
+    public void setResizingMask (NSUInteger resizingMask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setResizingMask_1, resizingMask);
+    }
+
+    public void setSortDescriptorPrototype (NSSortDescriptor sortDescriptor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSortDescriptorPrototype_1, sortDescriptor !is null ? sortDescriptor.id : null);
+    }
+
+    public void setTableView (NSTableView tableView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTableView_1, tableView !is null ? tableView.id : null);
+    }
+
+    public void setWidth (CGFloat width)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWidth_1, width);
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public NSSortDescriptor sortDescriptorPrototype ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortDescriptorPrototype);
+        return result !is null ? new NSSortDescriptor(result) : null;
+    }
+
+    public NSTableView tableView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tableView);
+        return result !is null ? new NSTableView(result) : null;
+    }
+
+    public CGFloat width ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_width);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTableHeaderCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTableHeaderCell;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTableHeaderCell : NSTextFieldCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void drawSortIndicatorWithFrame (NSRect cellFrame, NSView controlView, bool ascending, NSInteger priority)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawSortIndicatorWithFrame_1inView_1ascending_1priority_1, cellFrame,
+                controlView !is null ? controlView.id : null, ascending, priority);
+    }
+
+    public NSRect sortIndicatorRectForBounds (NSRect theRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_sortIndicatorRectForBounds_1, theRect);
+        return result;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTableHeaderView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTableHeaderView;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSTableView;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTableHeaderView : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger columnAtPoint (NSPoint point)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_columnAtPoint_1, point);
+    }
+
+    public NSInteger draggedColumn ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_draggedColumn);
+    }
+
+    public CGFloat draggedDistance ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_draggedDistance);
+    }
+
+    public NSRect headerRectOfColumn (NSInteger column)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_headerRectOfColumn_1, column);
+        return result;
+    }
+
+    public NSInteger resizedColumn ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_resizedColumn);
+    }
+
+    public void setTableView (NSTableView tableView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTableView_1, tableView !is null ? tableView.id : null);
+    }
+
+    public NSTableView tableView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tableView);
+        return result !is null ? new NSTableView(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTableView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,704 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTableView;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSDragOperation;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSNotification;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableColumn;
+import dwt.internal.cocoa.NSTableHeaderView;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTableViewColumnAutoresizingStyle : NSUInteger
+{
+    NSTableViewNoColumnAutoresizing = 0,
+    NSTableViewUniformColumnAutoresizingStyle,
+    NSTableViewSequentialColumnAutoresizingStyle,
+    NSTableViewReverseSequentialColumnAutoresizingStyle,
+    NSTableViewLastColumnOnlyAutoresizingStyle,
+    NSTableViewFirstColumnOnlyAutoresizingStyle
+}
+
+alias NSTableViewColumnAutoresizingStyle.NSTableViewNoColumnAutoresizing NSTableViewNoColumnAutoresizing;
+alias NSTableViewColumnAutoresizingStyle.NSTableViewUniformColumnAutoresizingStyle NSTableViewUniformColumnAutoresizingStyle;
+alias NSTableViewColumnAutoresizingStyle.NSTableViewSequentialColumnAutoresizingStyle NSTableViewSequentialColumnAutoresizingStyle;
+alias NSTableViewColumnAutoresizingStyle.NSTableViewReverseSequentialColumnAutoresizingStyle NSTableViewReverseSequentialColumnAutoresizingStyle;
+alias NSTableViewColumnAutoresizingStyle.NSTableViewLastColumnOnlyAutoresizingStyle NSTableViewLastColumnOnlyAutoresizingStyle;
+alias NSTableViewColumnAutoresizingStyle.NSTableViewFirstColumnOnlyAutoresizingStyle NSTableViewFirstColumnOnlyAutoresizingStyle;
+
+enum NSTableViewSelectionHighlightStyle : NSInteger
+{
+    NSTableViewSelectionHighlightStyleRegular = 0,
+    NSTableViewSelectionHighlightStyleSourceList = 1,
+}
+
+alias NSTableViewSelectionHighlightStyle.NSTableViewSelectionHighlightStyleRegular NSTableViewSelectionHighlightStyleRegular;
+alias NSTableViewSelectionHighlightStyle.NSTableViewSelectionHighlightStyleSourceList NSTableViewSelectionHighlightStyleSourceList;
+
+enum NSTableViewDropOperation : NSUInteger
+{
+    NSTableViewDropOn,
+    NSTableViewDropAbove
+}
+
+alias NSTableViewDropOperation.NSTableViewDropOn NSTableViewDropOn;
+alias NSTableViewDropOperation.NSTableViewDropAbove NSTableViewDropAbove;
+
+public class NSTableView : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addTableColumn (NSTableColumn column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTableColumn_1, column !is null ? column.id : null);
+    }
+
+    public bool allowsColumnReordering ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsColumnReordering) !is null;
+    }
+
+    public bool allowsColumnResizing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsColumnResizing) !is null;
+    }
+
+    public bool allowsColumnSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsColumnSelection) !is null;
+    }
+
+    public bool allowsEmptySelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsEmptySelection) !is null;
+    }
+
+    public bool allowsMultipleSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsMultipleSelection) !is null;
+    }
+
+    public bool allowsTypeSelect ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsTypeSelect) !is null;
+    }
+
+    public bool autoresizesAllColumnsToFit ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoresizesAllColumnsToFit) !is null;
+    }
+
+    public NSString autosaveName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_autosaveName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool autosaveTableColumns ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autosaveTableColumns) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public bool canDragRowsWithIndexes (NSIndexSet rowIndexes, NSPoint mouseDownPoint)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canDragRowsWithIndexes_1atPoint_1, rowIndexes !is null ? rowIndexes.id : null, mouseDownPoint) !is null;
+    }
+
+    public NSInteger clickedColumn ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_clickedColumn);
+    }
+
+    public NSInteger clickedRow ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_clickedRow);
+    }
+
+    public NSTableViewColumnAutoresizingStyle columnAtPoint (NSPoint point)
+    {
+        return cast(NSTableViewColumnAutoresizingStyle) OS.objc_msgSend(this.id, OS.sel_columnAtPoint_1, point);
+    }
+
+    public NSInteger columnAutoresizingStyle ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_columnAutoresizingStyle);
+    }
+
+    public NSIndexSet columnIndexesInRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_columnIndexesInRect_1, rect);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public NSInteger columnWithIdentifier (id identifier)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_columnWithIdentifier_1, identifier !is null ? identifier.id : null);
+    }
+
+    public NSRange columnsInRect (NSRect rect)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_columnsInRect_1, rect);
+        return result;
+    }
+
+    public NSView cornerView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cornerView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public id dataSource ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataSource);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void deselectAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deselectAll_1, sender !is null ? sender.id : null);
+    }
+
+    public void deselectColumn (NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deselectColumn_1, column);
+    }
+
+    public void deselectRow (NSInteger row)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deselectRow_1, row);
+    }
+
+    public objc.SEL doubleAction ()
+    {
+        return cast(objc.SEL) OS.objc_msgSend(this.id, OS.sel_doubleAction);
+    }
+
+    public NSImage dragImageForRows (NSArray dragRows, NSEvent dragEvent, NSPointPointer dragImageOffset)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dragImageForRows_1event_1dragImageOffset_1, dragRows !is null ? dragRows.id : null,
+                dragEvent !is null ? dragEvent.id : null, dragImageOffset);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImage dragImageForRowsWithIndexes (NSIndexSet dragRows, NSArray tableColumns, NSEvent dragEvent, NSPointPointer dragImageOffset)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dragImageForRowsWithIndexes_1tableColumns_1event_1offset_1,
+                dragRows !is null ? dragRows.id : null, tableColumns !is null ? tableColumns.id : null, dragEvent !is null ? dragEvent.id : null,
+                dragImageOffset);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public void drawBackgroundInClipRect (NSRect clipRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawBackgroundInClipRect_1, clipRect);
+    }
+
+    public void drawGridInClipRect (NSRect clipRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawGridInClipRect_1, clipRect);
+    }
+
+    public void drawRow (NSInteger row, NSRect clipRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawRow_1clipRect_1, row, clipRect);
+    }
+
+    public bool drawsGrid ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsGrid) !is null;
+    }
+
+    public void editColumn (NSInteger column, NSInteger row, NSEvent theEvent, bool select)
+    {
+        OS.objc_msgSend(this.id, OS.sel_editColumn_1row_1withEvent_1select_1, column, row, theEvent !is null ? theEvent.id : null, select);
+    }
+
+    public NSInteger editedColumn ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_editedColumn);
+    }
+
+    public NSInteger editedRow ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_editedRow);
+    }
+
+    public NSRect frameOfCellAtColumn (NSInteger column, NSInteger row)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frameOfCellAtColumn_1row_1, column, row);
+        return result;
+    }
+
+    public NSColor gridColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_gridColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSUInteger gridStyleMask ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_gridStyleMask);
+    }
+
+    public NSTableHeaderView headerView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_headerView);
+        return result !is null ? new NSTableHeaderView(result) : null;
+    }
+
+    public void highlightSelectionInClipRect (NSRect clipRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_highlightSelectionInClipRect_1, clipRect);
+    }
+
+    public NSTableColumn highlightedTableColumn ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightedTableColumn);
+        return result !is null ? new NSTableColumn(result) : null;
+    }
+
+    public NSImage indicatorImageInTableColumn (NSTableColumn tc)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_indicatorImageInTableColumn_1, tc !is null ? tc.id : null);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSSize intercellSpacing ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_intercellSpacing);
+        return result;
+    }
+
+    public bool isColumnSelected (NSInteger column)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isColumnSelected_1, column) !is null;
+    }
+
+    public bool isRowSelected (NSInteger row)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRowSelected_1, row) !is null;
+    }
+
+    public void moveColumn (NSInteger column, NSInteger newIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveColumn_1toColumn_1, column, newIndex);
+    }
+
+    public void noteHeightOfRowsWithIndexesChanged (NSIndexSet indexSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteHeightOfRowsWithIndexesChanged_1, indexSet !is null ? indexSet.id : null);
+    }
+
+    public void noteNumberOfRowsChanged ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteNumberOfRowsChanged);
+    }
+
+    public NSInteger numberOfColumns ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfColumns);
+    }
+
+    public NSInteger numberOfRows ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfRows);
+    }
+
+    public NSInteger numberOfSelectedColumns ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfSelectedColumns);
+    }
+
+    public NSInteger numberOfSelectedRows ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfSelectedRows);
+    }
+
+    public NSCell preparedCellAtColumn (NSInteger column, NSInteger row)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_preparedCellAtColumn_1row_1, column, row);
+        return result !is null ? new NSCell(result) : null;
+    }
+
+    public NSRect rectOfColumn (NSInteger column)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfColumn_1, column);
+        return result;
+    }
+
+    public NSRect rectOfRow (NSInteger row)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfRow_1, row);
+        return result;
+    }
+
+    public void reloadData ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_reloadData);
+    }
+
+    public void removeTableColumn (NSTableColumn column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeTableColumn_1, column !is null ? column.id : null);
+    }
+
+    public NSInteger rowAtPoint (NSPoint point)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_rowAtPoint_1, point);
+    }
+
+    public CGFloat rowHeight ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_rowHeight);
+    }
+
+    public NSRange rowsInRect (NSRect rect)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rowsInRect_1, rect);
+        return result;
+    }
+
+    public void scrollColumnToVisible (NSInteger column)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollColumnToVisible_1, column);
+    }
+
+    public void scrollRowToVisible (NSInteger row)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollRowToVisible_1, row);
+    }
+
+    public void selectAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectAll_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectColumn (NSInteger column, bool extend)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectColumn_1byExtendingSelection_1, column, extend);
+    }
+
+    public void selectColumnIndexes (NSIndexSet indexes, bool extend)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectColumnIndexes_1byExtendingSelection_1, indexes !is null ? indexes.id : null, extend);
+    }
+
+    public void selectRow (NSInteger row, bool extend)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectRow_1byExtendingSelection_1, row, extend);
+    }
+
+    public void selectRowIndexes (NSIndexSet indexes, bool extend)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectRowIndexes_1byExtendingSelection_1, indexes !is null ? indexes.id : null, extend);
+    }
+
+    public NSInteger selectedColumn ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_selectedColumn);
+    }
+
+    public NSEnumerator selectedColumnEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedColumnEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public NSIndexSet selectedColumnIndexes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedColumnIndexes);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public NSInteger selectedRow ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_selectedRow);
+    }
+
+    public NSEnumerator selectedRowEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedRowEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public NSIndexSet selectedRowIndexes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedRowIndexes);
+        return result !is null ? new NSIndexSet(result) : null;
+    }
+
+    public NSTableViewSelectionHighlightStyle selectionHighlightStyle ()
+    {
+        return cast(NSTableViewSelectionHighlightStyle) OS.objc_msgSend(this.id, OS.sel_selectionHighlightStyle);
+    }
+
+    public void setAllowsColumnReordering (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsColumnReordering_1, flag);
+    }
+
+    public void setAllowsColumnResizing (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsColumnResizing_1, flag);
+    }
+
+    public void setAllowsColumnSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsColumnSelection_1, flag);
+    }
+
+    public void setAllowsEmptySelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsEmptySelection_1, flag);
+    }
+
+    public void setAllowsMultipleSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsMultipleSelection_1, flag);
+    }
+
+    public void setAllowsTypeSelect (bool value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsTypeSelect_1, value);
+    }
+
+    public void setAutoresizesAllColumnsToFit (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoresizesAllColumnsToFit_1, flag);
+    }
+
+    public void setAutosaveName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosaveName_1, name !is null ? name.id : null);
+    }
+
+    public void setAutosaveTableColumns (bool save)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosaveTableColumns_1, save);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setColumnAutoresizingStyle (NSTableViewColumnAutoresizingStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setColumnAutoresizingStyle_1, style);
+    }
+
+    public void setCornerView (NSView cornerView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCornerView_1, cornerView !is null ? cornerView.id : null);
+    }
+
+    public void setDataSource (id aSource)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDataSource_1, aSource !is null ? aSource.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDoubleAction (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDoubleAction_1, aSelector);
+    }
+
+    public void setDraggingSourceOperationMask (NSDragOperation mask, bool isLocal)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDraggingSourceOperationMask_1forLocal_1, mask, isLocal);
+    }
+
+    public void setDrawsGrid (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsGrid_1, flag);
+    }
+
+    public void setDropRow (NSInteger row, NSTableViewDropOperation op)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDropRow_1dropOperation_1, row, op);
+    }
+
+    public void setGridColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGridColor_1, color !is null ? color.id : null);
+    }
+
+    public void setGridStyleMask (NSUInteger gridType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGridStyleMask_1, gridType);
+    }
+
+    public void setHeaderView (NSTableHeaderView headerView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHeaderView_1, headerView !is null ? headerView.id : null);
+    }
+
+    public void setHighlightedTableColumn (NSTableColumn tc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHighlightedTableColumn_1, tc !is null ? tc.id : null);
+    }
+
+    public void setIndicatorImage (NSImage anImage, NSTableColumn tc)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIndicatorImage_1inTableColumn_1, anImage !is null ? anImage.id : null, tc !is null ? tc.id : null);
+    }
+
+    public void setIntercellSpacing (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIntercellSpacing_1, aSize);
+    }
+
+    public void setRowHeight (CGFloat rowHeight)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRowHeight_1, rowHeight);
+    }
+
+    public void setSelectionHighlightStyle (NSTableViewSelectionHighlightStyle selectionHighlightStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectionHighlightStyle_1, selectionHighlightStyle);
+    }
+
+    public void setSortDescriptors (NSArray array)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSortDescriptors_1, array !is null ? array.id : null);
+    }
+
+    public void setUsesAlternatingRowBackgroundColors (bool useAlternatingRowColors)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesAlternatingRowBackgroundColors_1, useAlternatingRowColors);
+    }
+
+    public void setVerticalMotionCanBeginDrag (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticalMotionCanBeginDrag_1, flag);
+    }
+
+    public void sizeLastColumnToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeLastColumnToFit);
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public NSArray sortDescriptors ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortDescriptors);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSTableColumn tableColumnWithIdentifier (id identifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tableColumnWithIdentifier_1, identifier !is null ? identifier.id : null);
+        return result !is null ? new NSTableColumn(result) : null;
+    }
+
+    public NSArray tableColumns ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tableColumns);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void textDidBeginEditing (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidBeginEditing_1, notification !is null ? notification.id : null);
+    }
+
+    public void textDidChange (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidChange_1, notification !is null ? notification.id : null);
+    }
+
+    public void textDidEndEditing (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidEndEditing_1, notification !is null ? notification.id : null);
+    }
+
+    public bool textShouldBeginEditing (NSText textObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_textShouldBeginEditing_1, textObject !is null ? textObject.id : null) !is null;
+    }
+
+    public bool textShouldEndEditing (NSText textObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_textShouldEndEditing_1, textObject !is null ? textObject.id : null) !is null;
+    }
+
+    public void tile ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_tile);
+    }
+
+    public bool usesAlternatingRowBackgroundColors ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesAlternatingRowBackgroundColors) !is null;
+    }
+
+    public bool verticalMotionCanBeginDrag ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_verticalMotionCanBeginDrag) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTask.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTask;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTask : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray arguments ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arguments);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString currentDirectoryPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentDirectoryPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary environment ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_environment);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void interrupt ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_interrupt);
+    }
+
+    public bool isRunning ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRunning) !is null;
+    }
+
+    public void launch ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_launch);
+    }
+
+    public NSString launchPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_launchPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSTask launchedTaskWithLaunchPath (NSString path, NSArray arguments)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTask, OS.sel_launchedTaskWithLaunchPath_1arguments_1, path !is null ? path.id : null,
+                arguments !is null ? arguments.id : null);
+        return result !is null ? new NSTask(result) : null;
+    }
+
+    public int processIdentifier ()
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_processIdentifier);
+    }
+
+    public bool resume ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_resume) !is null;
+    }
+
+    public void setArguments (NSArray arguments)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setArguments_1, arguments !is null ? arguments.id : null);
+    }
+
+    public void setCurrentDirectoryPath (NSString path)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrentDirectoryPath_1, path !is null ? path.id : null);
+    }
+
+    public void setEnvironment (NSDictionary dict)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnvironment_1, dict !is null ? dict.id : null);
+    }
+
+    public void setLaunchPath (NSString path)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLaunchPath_1, path !is null ? path.id : null);
+    }
+
+    public void setStandardError (id error)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStandardError_1, error !is null ? error.id : null);
+    }
+
+    public void setStandardInput (id input)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStandardInput_1, input !is null ? input.id : null);
+    }
+
+    public void setStandardOutput (id output)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStandardOutput_1, output !is null ? output.id : null);
+    }
+
+    public id standardError ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standardError);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id standardInput ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standardInput);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id standardOutput ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standardOutput);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool suspend ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_suspend) !is null;
+    }
+
+    public void terminate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_terminate);
+    }
+
+    public int terminationStatus ()
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_terminationStatus);
+    }
+
+    public void waitUntilExit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_waitUntilExit);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSText.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,440 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSText;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSWritingDirection
+{
+    NSWritingDirectionNatural = -1,
+    NSWritingDirectionLeftToRight = 0,
+    NSWritingDirectionRightToLeft
+}
+
+alias NSWritingDirection.NSWritingDirectionNatural NSWritingDirectionNatural;
+alias NSWritingDirection.NSWritingDirectionLeftToRight NSWritingDirectionLeftToRight;
+alias NSWritingDirection.NSWritingDirectionRightToLeft NSWritingDirectionRightToLeft;
+
+
+
+enum NSTextAlignment
+{
+    NSLeftTextAlignment = 0,
+    NSRightTextAlignment = 1,
+    NSCenterTextAlignment = 2,
+    NSJustifiedTextAlignment = 3,
+    NSNaturalTextAlignment = 4
+}
+
+alias NSTextAlignment.NSLeftTextAlignment NSLeftTextAlignment;
+alias NSTextAlignment.NSRightTextAlignment NSRightTextAlignment;
+alias NSTextAlignment.NSCenterTextAlignment NSCenterTextAlignment;
+alias NSTextAlignment.NSJustifiedTextAlignment NSJustifiedTextAlignment;
+alias NSTextAlignment.NSNaturalTextAlignment NSNaturalTextAlignment;
+
+
+
+public class NSText : NSView
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static objc.Class static_class ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(OS.class_NSText, OS.sel_class);
+    }
+
+    public NSData RTFDFromRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_RTFDFromRange_1, range);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData RTFFromRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_RTFFromRange_1, range);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void alignCenter (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_alignCenter_1, sender !is null ? sender.id : null);
+    }
+
+    public void alignLeft (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_alignLeft_1, sender !is null ? sender.id : null);
+    }
+
+    public void alignRight (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_alignRight_1, sender !is null ? sender.id : null);
+    }
+
+    public NSTextAlignment alignment ()
+    {
+        return cast(NSTextAlignment) OS.objc_msgSend(this.id, OS.sel_alignment);
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSWritingDirection baseWritingDirection ()
+    {
+        return cast(NSWritingDirection) OS.objc_msgSend(this.id, OS.sel_baseWritingDirection);
+    }
+
+    public void changeFont (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_changeFont_1, sender !is null ? sender.id : null);
+    }
+
+    public void checkSpelling (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_checkSpelling_1, sender !is null ? sender.id : null);
+    }
+
+    public void copy (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_copy_1, sender !is null ? sender.id : null);
+    }
+
+    public void copyFont (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_copyFont_1, sender !is null ? sender.id : null);
+    }
+
+    public void copyRuler (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_copyRuler_1, sender !is null ? sender.id : null);
+    }
+
+    public void cut (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cut_1, sender !is null ? sender.id : null);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void deletee (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_delete_1, sender !is null ? sender.id : null);
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public NSFont font ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public bool importsGraphics ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_importsGraphics) !is null;
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public bool isFieldEditor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFieldEditor) !is null;
+    }
+
+    public bool isHorizontallyResizable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHorizontallyResizable) !is null;
+    }
+
+    public bool isRichText ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRichText) !is null;
+    }
+
+    public bool isRulerVisible ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRulerVisible) !is null;
+    }
+
+    public bool isSelectable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectable) !is null;
+    }
+
+    public bool isVerticallyResizable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isVerticallyResizable) !is null;
+    }
+
+    public NSSize maxSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_maxSize);
+        return result;
+    }
+
+    public NSSize minSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_minSize);
+        return result;
+    }
+
+    public void paste (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_paste_1, sender !is null ? sender.id : null);
+    }
+
+    public void pasteFont (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_pasteFont_1, sender !is null ? sender.id : null);
+    }
+
+    public void pasteRuler (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_pasteRuler_1, sender !is null ? sender.id : null);
+    }
+
+    public bool readRTFDFromFile (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readRTFDFromFile_1, path !is null ? path.id : null) !is null;
+    }
+
+    public void replaceCharactersInRange_withRTF_ (NSRange range, NSData rtfData)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_1withRTF_1, range, rtfData !is null ? rtfData.id : null);
+    }
+
+    public void replaceCharactersInRange_withRTFD_ (NSRange range, NSData rtfdData)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_1withRTFD_1, range, rtfdData !is null ? rtfdData.id : null);
+    }
+
+    public void replaceCharactersInRange_withString_ (NSRange range, NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_1withString_1, range, aString !is null ? aString.id : null);
+    }
+
+    public void scrollRangeToVisible (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollRangeToVisible_1, range);
+    }
+
+    public void selectAll (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectAll_1, sender !is null ? sender.id : null);
+    }
+
+    public NSRange selectedRange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_selectedRange);
+        return result;
+    }
+
+    public void setAlignment (NSTextAlignment mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlignment_1, mode);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBaseWritingDirection (NSWritingDirection writingDirection)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBaseWritingDirection_1, writingDirection);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setEditable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag);
+    }
+
+    public void setFieldEditor (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFieldEditor_1, flag);
+    }
+
+    public void setFont_ (NSFont obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, obj !is null ? obj.id : null);
+    }
+
+    public void setFont_range_ (NSFont font, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1range_1, font !is null ? font.id : null, range);
+    }
+
+    public void setHorizontallyResizable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHorizontallyResizable_1, flag);
+    }
+
+    public void setImportsGraphics (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImportsGraphics_1, flag);
+    }
+
+    public void setMaxSize (NSSize newMaxSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxSize_1, newMaxSize);
+    }
+
+    public void setMinSize (NSSize newMinSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinSize_1, newMinSize);
+    }
+
+    public void setRichText (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRichText_1, flag);
+    }
+
+    public void setSelectable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectable_1, flag);
+    }
+
+    public void setSelectedRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedRange_1, range);
+    }
+
+    public void setString (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setString_1, string !is null ? string.id : null);
+    }
+
+    public void setTextColor_ (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextColor_1, color !is null ? color.id : null);
+    }
+
+    public void setTextColor_range_ (NSColor color, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextColor_1range_1, color !is null ? color.id : null, range);
+    }
+
+    public void setUsesFontPanel (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesFontPanel_1, flag);
+    }
+
+    public void setVerticallyResizable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticallyResizable_1, flag);
+    }
+
+    public void showGuessPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showGuessPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void sizeToFit ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_sizeToFit);
+    }
+
+    public NSString string ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_string);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void subscript (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_subscript_1, sender !is null ? sender.id : null);
+    }
+
+    public void superscript (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_superscript_1, sender !is null ? sender.id : null);
+    }
+
+    public NSColor textColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void toggleRuler (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleRuler_1, sender !is null ? sender.id : null);
+    }
+
+    public void underline (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_underline_1, sender !is null ? sender.id : null);
+    }
+
+    public void unscript (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unscript_1, sender !is null ? sender.id : null);
+    }
+
+    public bool usesFontPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesFontPanel) !is null;
+    }
+
+    public bool writeRTFDToFile (NSString path, bool flag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeRTFDToFile_1atomically_1, path !is null ? path.id : null, flag) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextAttachment.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextAttachment;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSFileWrapper;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTextAttachment : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id attachmentCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attachmentCell);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSFileWrapper fileWrapper ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fileWrapper);
+        return result !is null ? new NSFileWrapper(result) : null;
+    }
+
+    public id initWithFileWrapper (NSFileWrapper fileWrapper)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFileWrapper_1, fileWrapper !is null ? fileWrapper.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setAttachmentCell (id cell)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttachmentCell_1, cell !is null ? cell.id : null);
+    }
+
+    public void setFileWrapper (NSFileWrapper fileWrapper)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFileWrapper_1, fileWrapper !is null ? fileWrapper.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextBlock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextBlock;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSTextContainer;
+import dwt.internal.cocoa.NSTextTable : NSTextBlockDimension, NSTextBlockLayer, NSTextBlockValueType, NSTextBlockVerticalAlignment;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTextBlock : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSColor borderColorForEdge (NSRectEdge edge)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_borderColorForEdge_1, edge);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSRect boundsRectForContentRect (NSRect contentRect, NSRect rect, NSTextContainer textContainer, NSRange charRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundsRectForContentRect_1inRect_1textContainer_1characterRange_1, contentRect, rect,
+                textContainer !is null ? textContainer.id : null, charRange);
+        return result;
+    }
+
+    public CGFloat contentWidth ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_contentWidth);
+    }
+
+    public NSTextBlockValueType contentWidthValueType ()
+    {
+        return cast(NSTextBlockValueType) OS.objc_msgSend(this.id, OS.sel_contentWidthValueType);
+    }
+
+    public void drawBackgroundWithFrame (NSRect frameRect, NSView controlView, NSRange charRange, NSLayoutManager layoutManager)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawBackgroundWithFrame_1inView_1characterRange_1layoutManager_1, frameRect,
+                controlView !is null ? controlView.id : null, charRange, layoutManager !is null ? layoutManager.id : null);
+    }
+
+    public NSRect rectForLayoutAtPoint (NSPoint startingPoint, NSRect rect, NSTextContainer textContainer, NSRange charRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectForLayoutAtPoint_1inRect_1textContainer_1characterRange_1, startingPoint, rect,
+                textContainer !is null ? textContainer.id : null, charRange);
+        return result;
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBorderColor_ (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBorderColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBorderColor_forEdge_ (NSColor color, NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBorderColor_1forEdge_1, color !is null ? color.id : null, edge);
+    }
+
+    public void setContentWidth (CGFloat val, NSTextBlockValueType type)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentWidth_1type_1, val, type);
+    }
+
+    public void setValue (CGFloat val, NSTextBlockValueType type, NSTextBlockDimension dimension)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1type_1forDimension_1, val, type, dimension);
+    }
+
+    public void setVerticalAlignment (NSTextBlockVerticalAlignment alignment)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVerticalAlignment_1, alignment);
+    }
+
+    public void setWidth_type_forLayer_ (CGFloat val, NSTextBlockValueType type, NSTextBlockLayer layer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWidth_1type_1forLayer_1, val, type, layer);
+    }
+
+    public void setWidth_type_forLayer_edge_ (CGFloat val, NSTextBlockValueType type, NSTextBlockLayer layer, NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWidth_1type_1forLayer_1edge_1, val, type, layer, edge);
+    }
+
+    public CGFloat valueForDimension (NSTextBlockDimension dimension)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_valueForDimension_1, dimension);
+    }
+
+    public NSTextBlockValueType valueTypeForDimension (NSTextBlockDimension dimension)
+    {
+        return cast(NSTextBlockValueType) OS.objc_msgSend(this.id, OS.sel_valueTypeForDimension_1, dimension);
+    }
+
+    public NSTextBlockVerticalAlignment verticalAlignment ()
+    {
+        return cast(NSTextBlockVerticalAlignment) OS.objc_msgSend(this.id, OS.sel_verticalAlignment);
+    }
+
+    public CGFloat widthForLayer (NSTextBlockLayer layer, NSRectEdge edge)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_widthForLayer_1edge_1, layer, edge);
+    }
+
+    public NSTextBlockValueType widthValueTypeForLayer (NSTextBlockLayer layer, NSRectEdge edge)
+    {
+        return cast(NSTextBlockValueType) OS.objc_msgSend(this.id, OS.sel_widthValueTypeForLayer_1edge_1, layer, edge);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextContainer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextContainer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSTextView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSLineSweepDirection
+{
+    NSLineSweepLeft = 0,
+    NSLineSweepRight = 1,
+    NSLineSweepDown = 2,
+    NSLineSweepUp = 3
+}
+
+alias NSLineSweepDirection.NSLineSweepLeft NSLineSweepLeft;
+alias NSLineSweepDirection.NSLineSweepRight NSLineSweepRight;
+alias NSLineSweepDirection.NSLineSweepDown NSLineSweepDown;
+alias NSLineSweepDirection.NSLineSweepUp NSLineSweepUp;
+
+
+
+enum NSLineMovementDirection
+{
+    NSLineDoesntMove = 0,
+    NSLineMovesLeft = 1,
+    NSLineMovesRight = 2,
+    NSLineMovesDown = 3,
+    NSLineMovesUp = 4
+}
+
+alias NSLineMovementDirection.NSLineDoesntMove NSLineDoesntMove;
+alias NSLineMovementDirection.NSLineMovesLeft NSLineMovesLeft;
+alias NSLineMovementDirection.NSLineMovesRight NSLineMovesRight;
+alias NSLineMovementDirection.NSLineMovesDown NSLineMovesDown;
+alias NSLineMovementDirection.NSLineMovesUp NSLineMovesUp;
+
+
+
+public class NSTextContainer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSSize containerSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_containerSize);
+        return result;
+    }
+
+    public bool containsPoint (NSPoint point)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsPoint_1, point) !is null;
+    }
+
+    public bool heightTracksTextView ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_heightTracksTextView) !is null;
+    }
+
+    public id initWithContainerSize (NSSize size)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerSize_1, size);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isSimpleRectangularTextContainer ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSimpleRectangularTextContainer) !is null;
+    }
+
+    public NSLayoutManager layoutManager ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_layoutManager);
+        return result !is null ? new NSLayoutManager(result) : null;
+    }
+
+    public CGFloat lineFragmentPadding ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineFragmentPadding);
+    }
+
+    public NSRect lineFragmentRectForProposedRect (NSRect proposedRect, NSLineSweepDirection sweepDirection, NSLineMovementDirection movementDirection, NSRectPointer remainingRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_lineFragmentRectForProposedRect_1sweepDirection_1movementDirection_1remainingRect_1,
+                proposedRect, sweepDirection, movementDirection, remainingRect);
+        return result;
+    }
+
+    public void replaceLayoutManager (NSLayoutManager newLayoutManager)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceLayoutManager_1, newLayoutManager !is null ? newLayoutManager.id : null);
+    }
+
+    public void setContainerSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContainerSize_1, size);
+    }
+
+    public void setHeightTracksTextView (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHeightTracksTextView_1, flag);
+    }
+
+    public void setLayoutManager (NSLayoutManager layoutManager)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLayoutManager_1, layoutManager !is null ? layoutManager.id : null);
+    }
+
+    public void setLineFragmentPadding (CGFloat pad)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineFragmentPadding_1, pad);
+    }
+
+    public void setTextView (NSTextView textView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextView_1, textView !is null ? textView.id : null);
+    }
+
+    public void setWidthTracksTextView (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWidthTracksTextView_1, flag);
+    }
+
+    public NSTextView textView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textView);
+        return result !is null ? new NSTextView(result) : null;
+    }
+
+    public bool widthTracksTextView ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_widthTracksTextView) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextField.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextField;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSNotification;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.NSTextFieldCell : NSTextFieldBezelStyle;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTextField : NSControl
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsFirstResponder ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsFirstResponder) !is null;
+    }
+
+    public bool allowsEditingTextAttributes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsEditingTextAttributes) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSTextFieldBezelStyl bezelStyle ()
+    {
+        return cast(NSTextFieldBezelStyle) OS.objc_msgSend(this.id, OS.sel_bezelStyle);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public bool importsGraphics ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_importsGraphics) !is null;
+    }
+
+    public bool isBezeled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBezeled) !is null;
+    }
+
+    public bool isBordered ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isBordered) !is null;
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public bool isSelectable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectable) !is null;
+    }
+
+    public void selectText (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectText_1, sender !is null ? sender.id : null);
+    }
+
+    public void setAllowsEditingTextAttributes (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsEditingTextAttributes_1, flag);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBezelStyle (NSTextFieldBezelStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezelStyle_1, style);
+    }
+
+    public void setBezeled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezeled_1, flag);
+    }
+
+    public void setBordered (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBordered_1, flag);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setEditable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag);
+    }
+
+    public void setImportsGraphics (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImportsGraphics_1, flag);
+    }
+
+    public void setSelectable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectable_1, flag);
+    }
+
+    public void setTextColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextColor_1, color !is null ? color.id : null);
+    }
+
+    public void setTitleWithMnemonic (NSString stringWithAmpersand)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithMnemonic_1, stringWithAmpersand !is null ? stringWithAmpersand.id : null);
+    }
+
+    public NSColor textColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void textDidBeginEditing (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidBeginEditing_1, notification !is null ? notification.id : null);
+    }
+
+    public void textDidChange (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidChange_1, notification !is null ? notification.id : null);
+    }
+
+    public void textDidEndEditing (NSNotification notification)
+    {
+        OS.objc_msgSend(this.id, OS.sel_textDidEndEditing_1, notification !is null ? notification.id : null);
+    }
+
+    public bool textShouldBeginEditing (NSText textObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_textShouldBeginEditing_1, textObject !is null ? textObject.id : null) !is null;
+    }
+
+    public bool textShouldEndEditing (NSText textObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_textShouldEndEditing_1, textObject !is null ? textObject.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextFieldCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextFieldCell;
+
+import dwt.internal.cocoa.NSActionCell;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTextFieldBezelStyle
+{
+    NSTextFieldSquareBezel = 0,
+    NSTextFieldRoundedBezel = 1
+}
+
+alias NSTextFieldBezelStyle.NSTextFieldSquareBezel NSTextFieldSquareBezel;
+alias NSTextFieldBezelStyle.NSTextFieldRoundedBezel NSTextFieldRoundedBezel;
+
+public class NSTextFieldCell : NSActionCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray allowedInputSourceLocales ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allowedInputSourceLocales);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSTextFieldBezelStyle bezelStyle ()
+    {
+        return cast(NSTextFieldBezelStyle) OS.objc_msgSend(this.id, OS.sel_bezelStyle);
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public NSAttributedString placeholderAttributedString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_placeholderAttributedString);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSString placeholderString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_placeholderString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setAllowedInputSourceLocales (NSArray localeIdentifiers)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowedInputSourceLocales_1, localeIdentifiers !is null ? localeIdentifiers.id : null);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBezelStyle (NSTextFieldBezelStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBezelStyle_1, style);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setPlaceholderAttributedString (NSAttributedString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaceholderAttributedString_1, string !is null ? string.id : null);
+    }
+
+    public void setPlaceholderString (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPlaceholderString_1, string !is null ? string.id : null);
+    }
+
+    public void setTextColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextColor_1, color !is null ? color.id : null);
+    }
+
+    public NSText setUpFieldEditorAttributes (NSText textObj)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_setUpFieldEditorAttributes_1, textObj !is null ? textObj.id : null);
+        return result !is null ? new NSText(result) : null;
+    }
+
+    public void setWantsNotificationForMarkedText (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWantsNotificationForMarkedText_1, flag);
+    }
+
+    public NSColor textColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextList.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextList;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTextList : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTextList initWithMarkerFormat (NSString format, NSUInteger mask)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMarkerFormat_1options_1, format !is null ? format.id : null, mask);
+        return result !is null ? this : null;
+    }
+
+    public NSUInteger listOptions ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_listOptions);
+    }
+
+    public NSString markerForItemNumber (NSInteger itemNum)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_markerForItemNumber_1, itemNum);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString markerFormat ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_markerFormat);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextStorage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextStorage;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSMutableAttributedString;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTextStorage : NSMutableAttributedString
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addLayoutManager (NSLayoutManager obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addLayoutManager_1, obj !is null ? obj.id : null);
+    }
+
+    public NSArray attributeRuns ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributeRuns);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSInteger changeInLength ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_changeInLength);
+    }
+
+    public NSArray characters ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_characters);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void edited (NSUInteger editedMask, NSRange range, NSInteger delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_edited_1range_1changeInLength_1, editedMask, range, delta);
+    }
+
+    public NSUInteger editedMask ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_editedMask);
+    }
+
+    public NSRange editedRange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_editedRange);
+        return result;
+    }
+
+    public void ensureAttributesAreFixedInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_ensureAttributesAreFixedInRange_1, range);
+    }
+
+    public bool fixesAttributesLazily ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fixesAttributesLazily) !is null;
+    }
+
+    public NSFont font ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_font);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public NSColor foregroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_foregroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void invalidateAttributesInRange (NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateAttributesInRange_1, range);
+    }
+
+    public NSArray layoutManagers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_layoutManagers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray paragraphs ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_paragraphs);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void processEditing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_processEditing);
+    }
+
+    public void removeLayoutManager (NSLayoutManager obj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeLayoutManager_1, obj !is null ? obj.id : null);
+    }
+
+    public void setAttributeRuns (NSArray attributeRuns)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributeRuns_1, attributeRuns !is null ? attributeRuns.id : null);
+    }
+
+    public void setCharacters (NSArray characters)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCharacters_1, characters !is null ? characters.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setFont (NSFont font)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFont_1, font !is null ? font.id : null);
+    }
+
+    public void setForegroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setForegroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setParagraphs (NSArray paragraphs)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParagraphs_1, paragraphs !is null ? paragraphs.id : null);
+    }
+
+    public void setWords (NSArray words)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWords_1, words !is null ? words.id : null);
+    }
+
+    public NSArray words ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_words);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextTab.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextTab;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSText : NSTextAlignment;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTextTabType
+{
+    NSLeftTabStopType = 0,
+    NSRightTabStopType,
+    NSCenterTabStopType,
+    NSDecimalTabStopType
+}
+
+alias NSTextTabType.NSLeftTabStopType NSLeftTabStopType;
+alias NSTextTabType.NSRightTabStopType NSRightTabStopType;
+alias NSTextTabType.NSCenterTabStopType NSCenterTabStopType;
+alias NSTextTabType.NSDecimalTabStopType NSDecimalTabStopType;
+
+public class NSTextTab : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTextAlignment alignment ()
+    {
+        return cast(NSTextAlignment) OS.objc_msgSend(this.id, OS.sel_alignment);
+    }
+
+    public NSTextTab initWithTextAlignment (NSTextAlignment alignment, CGFloat loc, NSDictionary options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTextAlignment_1location_1options_1, alignment, loc,
+                options !is null ? options.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSTextTab initWithType (NSTextTabType type, CGFloat loc)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithType_1location_1, type, loc);
+        return result !is null ? this : null;
+    }
+
+    public CGFloat location ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_location);
+    }
+
+    public NSDictionary options ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_options);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSTextTabType tabStopType ()
+    {
+        return cast(NSTextTabType) OS.objc_msgSend(this.id, OS.sel_tabStopType);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextTable;
+
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSTextBlock;
+import dwt.internal.cocoa.NSTextContainer;
+import dwt.internal.cocoa.NSTextTableBlock;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTextBlockValueType : NSUInteger
+{
+    NSTextBlockAbsoluteValueType = 0,
+    NSTextBlockPercentageValueType = 1
+}
+
+alias NSTextBlockValueType.NSTextBlockAbsoluteValueType NSTextBlockAbsoluteValueType;
+alias NSTextBlockValueType.NSTextBlockPercentageValueType NSTextBlockPercentageValueType;
+
+enum NSTextBlockDimension : NSUInteger
+{
+    NSTextBlockWidth = 0,
+    NSTextBlockMinimumWidth = 1,
+    NSTextBlockMaximumWidth = 2,
+    NSTextBlockHeight = 4,
+    NSTextBlockMinimumHeight = 5,
+    NSTextBlockMaximumHeight = 6
+}
+
+alias NSTextBlockDimension.NSTextBlockWidth NSTextBlockWidth;
+alias NSTextBlockDimension.NSTextBlockMinimumWidth NSTextBlockMinimumWidth;
+alias NSTextBlockDimension.NSTextBlockMaximumWidth NSTextBlockMaximumWidth;
+alias NSTextBlockDimension.NSTextBlockHeight NSTextBlockHeight;
+alias NSTextBlockDimension.NSTextBlockMinimumHeight NSTextBlockMinimumHeight;
+alias NSTextBlockDimension.NSTextBlockMaximumHeight NSTextBlockMaximumHeight;
+
+enum NSTextBlockVerticalAlignment : NSUInteger
+{
+    NSTextBlockTopAlignment = 0,
+    NSTextBlockMiddleAlignment = 1,
+    NSTextBlockBottomAlignment = 2,
+    NSTextBlockBaselineAlignment = 3
+}
+
+alias NSTextBlockVerticalAlignment.NSTextBlockTopAlignment NSTextBlockTopAlignment;
+alias NSTextBlockVerticalAlignment.NSTextBlockMiddleAlignment NSTextBlockMiddleAlignment;
+alias NSTextBlockVerticalAlignment.NSTextBlockBottomAlignment NSTextBlockBottomAlignment;
+alias NSTextBlockVerticalAlignment.NSTextBlockBaselineAlignment NSTextBlockBaselineAlignment;
+
+enum NSTextBlockLayer : NSInteger
+{
+    NSTextBlockPadding = -1,
+    NSTextBlockBorder = 0,
+    NSTextBlockMargin = 1
+}
+
+alias NSTextBlockLayer.NSTextBlockPadding NSTextBlockPadding;
+alias NSTextBlockLayer.NSTextBlockBorder NSTextBlockBorder;
+alias NSTextBlockLayer.NSTextBlockMargin NSTextBlockMargin;
+
+enum NSTextTableLayoutAlgorithm : NSUInteger
+{
+    NSTextTableAutomaticLayoutAlgorithm = 0,
+    NSTextTableFixedLayoutAlgorithm = 1
+}
+
+alias NSTextTableLayoutAlgorithm.NSTextTableAutomaticLayoutAlgorithm NSTextTableAutomaticLayoutAlgorithm;
+alias NSTextTableLayoutAlgorithm.NSTextTableFixedLayoutAlgorithm NSTextTableFixedLayoutAlgorithm;
+
+public class NSTextTable : NSTextBlock
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSRect boundsRectForBlock (NSTextTableBlock block, NSRect contentRect, NSRect rect, NSTextContainer textContainer, NSRange charRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_boundsRectForBlock_1contentRect_1inRect_1textContainer_1characterRange_1,
+                block !is null ? block.id : null, contentRect, rect, textContainer !is null ? textContainer.id : null, charRange);
+        return result;
+    }
+
+    public bool collapsesBorders ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_collapsesBorders) !is null;
+    }
+
+    public void drawBackgroundForBlock (NSTextTableBlock block, NSRect frameRect, NSView controlView, NSRange charRange,
+            NSLayoutManager layoutManager)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawBackgroundForBlock_1withFrame_1inView_1characterRange_1layoutManager_1, block !is null ? block.id : null,
+                frameRect, controlView !is null ? controlView.id : null, charRange, layoutManager !is null ? layoutManager.id : null);
+    }
+
+    public bool hidesEmptyCells ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hidesEmptyCells) !is null;
+    }
+
+    public NSTextTableLayoutAlgorithm layoutAlgorithm ()
+    {
+        return cast(NSTextTableLayoutAlgorithm) OS.objc_msgSend(this.id, OS.sel_layoutAlgorithm);
+    }
+
+    public NSUInteger numberOfColumns ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_numberOfColumns);
+    }
+
+    public NSRect rectForBlock (NSTextTableBlock block, NSPoint startingPoint, NSRect rect, NSTextContainer textContainer, NSRange charRange)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectForBlock_1layoutAtPoint_1inRect_1textContainer_1characterRange_1,
+                block !is null ? block.id : null, startingPoint, rect, textContainer !is null ? textContainer.id : null, charRange);
+        return result;
+    }
+
+    public void setCollapsesBorders (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCollapsesBorders_1, flag);
+    }
+
+    public void setHidesEmptyCells (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHidesEmptyCells_1, flag);
+    }
+
+    public void setLayoutAlgorithm (NSTextTableLayoutAlgorithm algorithm)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLayoutAlgorithm_1, algorithm);
+    }
+
+    public void setNumberOfColumns (NSUInteger numCols)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNumberOfColumns_1, numCols);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextTableBlock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextTableBlock;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSTextBlock;
+import dwt.internal.cocoa.NSTextTable;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTextTableBlock : NSTextBlock
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSInteger columnSpan ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_columnSpan);
+    }
+
+    public id initWithTable (NSTextTable table, NSInteger row, NSInteger rowSpan, NSInteger col, NSInteger colSpan)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTable_1startingRow_1rowSpan_1startingColumn_1columnSpan_1,
+                table !is null ? table.id : null, row, rowSpan, col, colSpan);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger rowSpan ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_rowSpan);
+    }
+
+    public NSInteger startingColumn ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_startingColumn);
+    }
+
+    public NSInteger startingRow ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_startingRow);
+    }
+
+    public NSTextTable table ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_table);
+        return result !is null ? new NSTextTable(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTextView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,977 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTextView;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSDragOperation;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSParagraphStyle;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSRulerMarker;
+import dwt.internal.cocoa.NSRulerView;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.NSTextContainer;
+import dwt.internal.cocoa.NSTextStorage;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSSelectionAffinity
+{
+    NSSelectionAffinityUpstream = 0,
+    NSSelectionAffinityDownstream = 1
+}
+
+alias NSSelectionAffinity.NSSelectionAffinityUpstream NSSelectionAffinityUpstream;
+alias NSSelectionAffinity.NSSelectionAffinityDownstream NSSelectionAffinityDownstream;
+
+enum NSSelectionGranularity
+{
+    NSSelectByCharacter = 0,
+    NSSelectByWord = 1,
+    NSSelectByParagraph = 2
+}
+
+alias NSSelectionGranularity.NSSelectByCharacter NSSelectByCharacter;
+alias NSSelectionGranularity.NSSelectByWord NSSelectByWord;
+alias NSSelectionGranularity.NSSelectByParagraph NSSelectByParagraph;
+
+enum NSSelectionAffinity
+{
+    NSSelectionAffinityUpstream = 0,
+    NSSelectionAffinityDownstream = 1
+}
+
+alias NSSelectionAffinity.NSSelectionAffinityUpstream NSSelectionAffinityUpstream;
+alias NSSelectionAffinity.NSSelectionAffinityDownstream NSSelectionAffinityDownstream;
+
+public class NSTextView : NSText
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray acceptableDragTypes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_acceptableDragTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool acceptsGlyphInfo ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsGlyphInfo) !is null;
+    }
+
+    public void alignJustified (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_alignJustified_1, sender !is null ? sender.id : null);
+    }
+
+    public NSArray allowedInputSourceLocales ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allowedInputSourceLocales);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool allowsDocumentBackgroundColorChange ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsDocumentBackgroundColorChange) !is null;
+    }
+
+    public bool allowsImageEditing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsImageEditing) !is null;
+    }
+
+    public bool allowsUndo ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsUndo) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void breakUndoCoalescing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_breakUndoCoalescing);
+    }
+
+    public void changeAttributes (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_changeAttributes_1, sender !is null ? sender.id : null);
+    }
+
+    public void changeColor (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_changeColor_1, sender !is null ? sender.id : null);
+    }
+
+    public void changeDocumentBackgroundColor (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_changeDocumentBackgroundColor_1, sender !is null ? sender.id : null);
+    }
+
+    public NSUInteger characterIndexForInsertionAtPoint (NSPoint point)
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_characterIndexForInsertionAtPoint_1, point);
+    }
+
+    public void cleanUpAfterDragOperation ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cleanUpAfterDragOperation);
+    }
+
+    public void clickedOnLink (id link, NSUInteger charIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_clickedOnLink_1atIndex_1, link !is null ? link.id : null, charIndex);
+    }
+
+    public void complete (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_complete_1, sender !is null ? sender.id : null);
+    }
+
+    public NSArray completionsForPartialWordRange (NSRange charRange, NSInteger* index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_completionsForPartialWordRange_1indexOfSelectedItem_1, charRange, index);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSParagraphStyle defaultParagraphStyle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultParagraphStyle);
+        return result !is null ? new NSParagraphStyle(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void didChangeText ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_didChangeText);
+    }
+
+    public bool displaysLinkToolTips ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_displaysLinkToolTips) !is null;
+    }
+
+    public NSImage dragImageForSelectionWithEvent (NSEvent event, NSPointPointer origin)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dragImageForSelectionWithEvent_1origin_1, event !is null ? event.id : null, origin);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSDragOperation dragOperationForDraggingInfo (id dragInfo, NSString type)
+    {
+        return cast(NSDragOperation) OS.objc_msgSend(this.id, OS.sel_dragOperationForDraggingInfo_1type_1, dragInfo !is null ? dragInfo.id : null,
+                type !is null ? type.id : null);
+    }
+
+    public bool dragSelectionWithEvent (NSEvent event, NSSize mouseOffset, bool slideBack)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dragSelectionWithEvent_1offset_1slideBack_1, event !is null ? event.id : null, mouseOffset, slideBack) !is null;
+    }
+
+    public void drawInsertionPointInRect (NSRect rect, NSColor color, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawInsertionPointInRect_1color_1turnedOn_1, rect, color !is null ? color.id : null, flag);
+    }
+
+    public void drawViewBackgroundInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawViewBackgroundInRect_1, rect);
+    }
+
+    public bool drawsBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is null;
+    }
+
+    public NSRect firstRectForCharacterRange (NSRange range)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, id, OS.sel_firstRectForCharacterRange_1, range);
+        return result;
+    }
+
+    public bool importsGraphics ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_importsGraphics) !is null;
+    }
+
+    public id initWithFrame_ (NSRect frameRect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1, frameRect);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithFrame_textContainer_ (NSRect frameRect, NSTextContainer container)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1textContainer_1, frameRect, container !is null ? container.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void insertCompletion (NSString word, NSRange charRange, NSInteger movement, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertCompletion_1forPartialWordRange_1movement_1isFinal_1, word !is null ? word.id : null, charRange,
+                movement, flag);
+    }
+
+    public void insertText (id insertString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertText_1, insertString !is null ? insertString.id : null);
+    }
+
+    public NSColor insertionPointColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_insertionPointColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public void invalidateTextContainerOrigin ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateTextContainerOrigin);
+    }
+
+    public bool isAutomaticLinkDetectionEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAutomaticLinkDetectionEnabled) !is null;
+    }
+
+    public bool isAutomaticQuoteSubstitutionEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAutomaticQuoteSubstitutionEnabled) !is null;
+    }
+
+    public bool isContinuousSpellCheckingEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isContinuousSpellCheckingEnabled) !is null;
+    }
+
+    public bool isEditable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEditable) !is null;
+    }
+
+    public bool isFieldEditor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFieldEditor) !is null;
+    }
+
+    public bool isGrammarCheckingEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isGrammarCheckingEnabled) !is null;
+    }
+
+    public bool isRichText ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRichText) !is null;
+    }
+
+    public bool isRulerVisible ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRulerVisible) !is null;
+    }
+
+    public bool isSelectable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSelectable) !is null;
+    }
+
+    public NSLayoutManager layoutManager ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_layoutManager);
+        return result !is null ? new NSLayoutManager(result) : null;
+    }
+
+    public NSDictionary linkTextAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_linkTextAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void loosenKerning (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_loosenKerning_1, sender !is null ? sender.id : null);
+    }
+
+    public void lowerBaseline (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_lowerBaseline_1, sender !is null ? sender.id : null);
+    }
+
+    public NSDictionary markedTextAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_markedTextAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void orderFrontLinkPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontLinkPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontListPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontListPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontSpacingPanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontSpacingPanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontTablePanel (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontTablePanel_1, sender !is null ? sender.id : null);
+    }
+
+    public void outline (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_outline_1, sender !is null ? sender.id : null);
+    }
+
+    public void pasteAsPlainText (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_pasteAsPlainText_1, sender !is null ? sender.id : null);
+    }
+
+    public void pasteAsRichText (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_pasteAsRichText_1, sender !is null ? sender.id : null);
+    }
+
+    public void performFindPanelAction (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performFindPanelAction_1, sender !is null ? sender.id : null);
+    }
+
+    public NSString preferredPasteboardTypeFromArray (NSArray availableTypes, NSArray allowedTypes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_preferredPasteboardTypeFromArray_1restrictedToTypesFromArray_1,
+                availableTypes !is null ? availableTypes.id : null, allowedTypes !is null ? allowedTypes.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void raiseBaseline (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_raiseBaseline_1, sender !is null ? sender.id : null);
+    }
+
+    public NSRange rangeForUserCharacterAttributeChange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeForUserCharacterAttributeChange);
+        return result;
+    }
+
+    public NSRange rangeForUserCompletion ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeForUserCompletion);
+        return result;
+    }
+
+    public NSRange rangeForUserParagraphAttributeChange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeForUserParagraphAttributeChange);
+        return result;
+    }
+
+    public NSRange rangeForUserTextChange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeForUserTextChange);
+        return result;
+    }
+
+    public NSArray rangesForUserCharacterAttributeChange ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rangesForUserCharacterAttributeChange);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray rangesForUserParagraphAttributeChange ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rangesForUserParagraphAttributeChange);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray rangesForUserTextChange ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rangesForUserTextChange);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool readSelectionFromPasteboard_ (NSPasteboard pboard)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readSelectionFromPasteboard_1, pboard !is null ? pboard.id : null) !is null;
+    }
+
+    public bool readSelectionFromPasteboard_type_ (NSPasteboard pboard, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_readSelectionFromPasteboard_1type_1, pboard !is null ? pboard.id : null,
+                type !is null ? type.id : null) !is null;
+    }
+
+    public NSArray readablePasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_readablePasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static void registerForServices ()
+    {
+        OS.objc_msgSend(OS.class_NSTextView, OS.sel_registerForServices);
+    }
+
+    public void replaceTextContainer (NSTextContainer newContainer)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceTextContainer_1, newContainer !is null ? newContainer.id : null);
+    }
+
+    public void rulerView_didAddMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1didAddMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null);
+    }
+
+    public void rulerView_didMoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1didMoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null);
+    }
+
+    public void rulerView_didRemoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1didRemoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null);
+    }
+
+    public void rulerView_handleMouseDown_ (NSRulerView ruler, NSEvent event)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1handleMouseDown_1, ruler !is null ? ruler.id : null, event !is null ? event.id : null);
+    }
+
+    public bool rulerView_shouldAddMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rulerView_1shouldAddMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null) !is null;
+    }
+
+    public bool rulerView_shouldMoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rulerView_1shouldMoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null) !is null;
+    }
+
+    public bool rulerView_shouldRemoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rulerView_1shouldRemoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null) !is null;
+    }
+
+    public CGFloat rulerView_willAddMarker_atLocation_ (NSRulerView ruler, NSRulerMarker marker, CGFloat location)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_rulerView_1willAddMarker_1atLocation_1, ruler !is null ? ruler.id : null,
+                marker !is null ? marker.id : null, location);
+    }
+
+    public CGFloat rulerView_willMoveMarker_toLocation_ (NSRulerView ruler, NSRulerMarker marker, CGFloat location)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_rulerView_1willMoveMarker_1toLocation_1, ruler !is null ? ruler.id : null,
+                marker !is null ? marker.id : null, location);
+    }
+
+    public NSArray selectedRanges ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedRanges);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSDictionary selectedTextAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedTextAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSSelectionAffinity selectionAffinity ()
+    {
+        return cast(NSSelectionAffinity) OS.objc_msgSend(this.id, OS.sel_selectionAffinity);
+    }
+
+    public NSSelectionGranularity selectionGranularity ()
+    {
+        return cast(NSSelectionGranularity) OS.objc_msgSend(this.id, OS.sel_selectionGranularity);
+    }
+
+    public NSRange selectionRangeForProposedRange (NSRange proposedCharRange, NSSelectionGranularity granularity)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_selectionRangeForProposedRange_1granularity_1, proposedCharRange, granularity);
+        return result;
+    }
+
+    public void setAcceptsGlyphInfo (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAcceptsGlyphInfo_1, flag);
+    }
+
+    public void setAlignment (NSTextAlignment alignment, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlignment_1range_1, alignment, range);
+    }
+
+    public void setAllowedInputSourceLocales (NSArray localeIdentifiers)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowedInputSourceLocales_1, localeIdentifiers !is null ? localeIdentifiers.id : null);
+    }
+
+    public void setAllowsDocumentBackgroundColorChange (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsDocumentBackgroundColorChange_1, flag);
+    }
+
+    public void setAllowsImageEditing (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsImageEditing_1, flag);
+    }
+
+    public void setAllowsUndo (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsUndo_1, flag);
+    }
+
+    public void setAutomaticLinkDetectionEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutomaticLinkDetectionEnabled_1, flag);
+    }
+
+    public void setAutomaticQuoteSubstitutionEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutomaticQuoteSubstitutionEnabled_1, flag);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBaseWritingDirection (NSWritingDirection writingDirection, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBaseWritingDirection_1range_1, writingDirection, range);
+    }
+
+    public void setConstrainedFrameSize (NSSize desiredSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setConstrainedFrameSize_1, desiredSize);
+    }
+
+    public void setContinuousSpellCheckingEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContinuousSpellCheckingEnabled_1, flag);
+    }
+
+    public void setDefaultParagraphStyle (NSParagraphStyle paragraphStyle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultParagraphStyle_1, paragraphStyle !is null ? paragraphStyle.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDisplaysLinkToolTips (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDisplaysLinkToolTips_1, flag);
+    }
+
+    public void setDrawsBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, flag);
+    }
+
+    public void setEditable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag);
+    }
+
+    public void setFieldEditor (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFieldEditor_1, flag);
+    }
+
+    public void setGrammarCheckingEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGrammarCheckingEnabled_1, flag);
+    }
+
+    public void setImportsGraphics (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImportsGraphics_1, flag);
+    }
+
+    public void setInsertionPointColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInsertionPointColor_1, color !is null ? color.id : null);
+    }
+
+    public void setLinkTextAttributes (NSDictionary attributeDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLinkTextAttributes_1, attributeDictionary !is null ? attributeDictionary.id : null);
+    }
+
+    public void setMarkedTextAttributes (NSDictionary attributeDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMarkedTextAttributes_1, attributeDictionary !is null ? attributeDictionary.id : null);
+    }
+
+    public void setNeedsDisplayInRect (NSRect rect, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsDisplayInRect_1avoidAdditionalLayout_1, rect, flag);
+    }
+
+    public void setRichText (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRichText_1, flag);
+    }
+
+    public void setRulerVisible (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRulerVisible_1, flag);
+    }
+
+    public void setSelectable (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectable_1, flag);
+    }
+
+    public void setSelectedRange_ (NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedRange_1, charRange);
+    }
+
+    public void setSelectedRange_affinity_stillSelecting_ (NSRange charRange, NSSelectionAffinity affinity, bool stillSelectingFlag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedRange_1affinity_1stillSelecting_1, charRange, affinity, stillSelectingFlag);
+    }
+
+    public void setSelectedRanges_ (NSArray ranges)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedRanges_1, ranges !is null ? ranges.id : null);
+    }
+
+    public void setSelectedRanges_affinity_stillSelecting_ (NSArray ranges, NSSelectionAffinity affinity, bool stillSelectingFlag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedRanges_1affinity_1stillSelecting_1, ranges !is null ? ranges.id : null, affinity,
+                stillSelectingFlag);
+    }
+
+    public void setSelectedTextAttributes (NSDictionary attributeDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedTextAttributes_1, attributeDictionary !is null ? attributeDictionary.id : null);
+    }
+
+    public void setSelectionGranularity (NSSelectionGranularity granularity)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectionGranularity_1, granularity);
+    }
+
+    public void setSmartInsertDeleteEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSmartInsertDeleteEnabled_1, flag);
+    }
+
+    public void setSpellingState (NSInteger value, NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSpellingState_1range_1, value, charRange);
+    }
+
+    public void setTextContainer (NSTextContainer container)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextContainer_1, container !is null ? container.id : null);
+    }
+
+    public void setTextContainerInset (NSSize inset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextContainerInset_1, inset);
+    }
+
+    public void setTypingAttributes (NSDictionary attrs)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTypingAttributes_1, attrs !is null ? attrs.id : null);
+    }
+
+    public void setUsesFindPanel (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesFindPanel_1, flag);
+    }
+
+    public void setUsesFontPanel (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesFontPanel_1, flag);
+    }
+
+    public void setUsesRuler (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesRuler_1, flag);
+    }
+
+    public bool shouldChangeTextInRange (NSRange affectedCharRange, NSString replacementString)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldChangeTextInRange_1replacementString_1, affectedCharRange,
+                replacementString !is null ? replacementString.id : null) !is null;
+    }
+
+    public bool shouldChangeTextInRanges (NSArray affectedRanges, NSArray replacementStrings)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldChangeTextInRanges_1replacementStrings_1, affectedRanges !is null ? affectedRanges.id : null,
+                replacementStrings !is null ? replacementStrings.id : null) !is null;
+    }
+
+    public bool shouldDrawInsertionPoint ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldDrawInsertionPoint) !is null;
+    }
+
+    public void showFindIndicatorForRange (NSRange charRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showFindIndicatorForRange_1, charRange);
+    }
+
+    public NSRange smartDeleteRangeForProposedRange (NSRange proposedCharRange)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_smartDeleteRangeForProposedRange_1, proposedCharRange);
+        return result;
+    }
+
+    public NSString smartInsertAfterStringForString (NSString pasteString, NSRange charRangeToReplace)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_smartInsertAfterStringForString_1replacingRange_1,
+                pasteString !is null ? pasteString.id : null, charRangeToReplace);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString smartInsertBeforeStringForString (NSString pasteString, NSRange charRangeToReplace)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_smartInsertBeforeStringForString_1replacingRange_1,
+                pasteString !is null ? pasteString.id : null, charRangeToReplace);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool smartInsertDeleteEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_smartInsertDeleteEnabled) !is null;
+    }
+
+    public void smartInsertForString (NSString pasteString, NSRange charRangeToReplace, /*NSString** */objc.id** beforeString, /*NSString** */objc.id* afterString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_smartInsertForString_1replacingRange_1beforeString_1afterString_1,
+                pasteString !is null ? pasteString.id : null, charRangeToReplace, beforeString, afterString);
+    }
+
+    public NSInteger spellCheckerDocumentTag ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_spellCheckerDocumentTag);
+    }
+
+    public void startSpeaking (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_startSpeaking_1, sender !is null ? sender.id : null);
+    }
+
+    public void stopSpeaking (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopSpeaking_1, sender !is null ? sender.id : null);
+    }
+
+    public NSTextContainer textContainer ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textContainer);
+        return result !is null ? new NSTextContainer(result) : null;
+    }
+
+    public NSSize textContainerInset ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_textContainerInset);
+        return result;
+    }
+
+    public NSPoint textContainerOrigin ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_textContainerOrigin);
+        return result;
+    }
+
+    public NSTextStorage textStorage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textStorage);
+        return result !is null ? new NSTextStorage(result) : null;
+    }
+
+    public void tightenKerning (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_tightenKerning_1, sender !is null ? sender.id : null);
+    }
+
+    public void toggleAutomaticLinkDetection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleAutomaticLinkDetection_1, sender !is null ? sender.id : null);
+    }
+
+    public void toggleAutomaticQuoteSubstitution (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleAutomaticQuoteSubstitution_1, sender !is null ? sender.id : null);
+    }
+
+    public void toggleBaseWritingDirection (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleBaseWritingDirection_1, sender !is null ? sender.id : null);
+    }
+
+    public void toggleContinuousSpellChecking (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleContinuousSpellChecking_1, sender !is null ? sender.id : null);
+    }
+
+    public void toggleGrammarChecking (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleGrammarChecking_1, sender !is null ? sender.id : null);
+    }
+
+    public void toggleSmartInsertDelete (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleSmartInsertDelete_1, sender !is null ? sender.id : null);
+    }
+
+    public void toggleTraditionalCharacterShape (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleTraditionalCharacterShape_1, sender !is null ? sender.id : null);
+    }
+
+    public void turnOffKerning (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_turnOffKerning_1, sender !is null ? sender.id : null);
+    }
+
+    public void turnOffLigatures (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_turnOffLigatures_1, sender !is null ? sender.id : null);
+    }
+
+    public NSDictionary typingAttributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_typingAttributes);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void updateDragTypeRegistration ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateDragTypeRegistration);
+    }
+
+    public void updateFontPanel ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateFontPanel);
+    }
+
+    public void updateInsertionPointStateAndRestartTimer (bool restartFlag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateInsertionPointStateAndRestartTimer_1, restartFlag);
+    }
+
+    public void updateRuler ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateRuler);
+    }
+
+    public void useAllLigatures (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_useAllLigatures_1, sender !is null ? sender.id : null);
+    }
+
+    public void useStandardKerning (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_useStandardKerning_1, sender !is null ? sender.id : null);
+    }
+
+    public void useStandardLigatures (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_useStandardLigatures_1, sender !is null ? sender.id : null);
+    }
+
+    public bool usesFindPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesFindPanel) !is null;
+    }
+
+    public bool usesFontPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesFontPanel) !is null;
+    }
+
+    public bool usesRuler ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesRuler) !is null;
+    }
+
+    public id validRequestorForSendType (NSString sendType, NSString returnType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_validRequestorForSendType_1returnType_1, sendType !is null ? sendType.id : null,
+                returnType !is null ? returnType.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray writablePasteboardTypes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_writablePasteboardTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool writeSelectionToPasteboard_type_ (NSPasteboard pboard, NSString type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeSelectionToPasteboard_1type_1, pboard !is null ? pboard.id : null, type !is null ? type.id : null) !is null;
+    }
+
+    public bool writeSelectionToPasteboard_types_ (NSPasteboard pboard, NSArray types)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeSelectionToPasteboard_1types_1, pboard !is null ? pboard.id : null,
+                types !is null ? types.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSThread.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSThread;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSThread : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSArray callStackReturnAddresses ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSThread, OS.sel_callStackReturnAddresses);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void cancel ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancel);
+    }
+
+    public static NSThread currentThread ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSThread, OS.sel_currentThread);
+        return result !is null ? new NSThread(result) : null;
+    }
+
+    public static void detachNewThreadSelector (objc.SEL selector, id target, id argument)
+    {
+        OS.objc_msgSend(OS.class_NSThread, OS.sel_detachNewThreadSelector_1toTarget_1withObject_1, selector, target !is null ? target.id : null,
+                argument !is null ? argument.id : null);
+    }
+
+    public static void exit ()
+    {
+        OS.objc_msgSend(OS.class_NSThread, OS.sel_exit);
+    }
+
+    public id initWithTarget (id target, objc.SEL selector, id argument)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTarget_1selector_1object_1, target !is null ? target.id : null, selector,
+                argument !is null ? argument.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isCancelled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isCancelled) !is null;
+    }
+
+    public bool isExecuting ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExecuting) !is null;
+    }
+
+    public bool isFinished ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFinished) !is null;
+    }
+
+    public static bool static_isMainThread ()
+    {
+        return OS.objc_msgSend(OS.class_NSThread, OS.sel_isMainThread) !is null;
+    }
+
+    public bool isMainThread ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMainThread) !is null;
+    }
+
+    public static bool isMultiThreaded ()
+    {
+        return OS.objc_msgSend(OS.class_NSThread, OS.sel_isMultiThreaded) !is null;
+    }
+
+    public void main ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_main);
+    }
+
+    public static NSThread mainThread ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSThread, OS.sel_mainThread);
+        return result !is null ? new NSThread(result) : null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setName (NSString n)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setName_1, n !is null ? n.id : null);
+    }
+
+    public void setStackSize (NSUInteger s)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStackSize_1, s);
+    }
+
+    public static bool setThreadPriority (double p)
+    {
+        return OS.objc_msgSend(OS.class_NSThread, OS.sel_setThreadPriority_1, p) !is null;
+    }
+
+    public static void sleepForTimeInterval (NSTimeInterval ti)
+    {
+        OS.objc_msgSend(OS.class_NSThread, OS.sel_sleepForTimeInterval_1, ti);
+    }
+
+    public static void sleepUntilDate (NSDate date)
+    {
+        OS.objc_msgSend(OS.class_NSThread, OS.sel_sleepUntilDate_1, date !is null ? date.id : null);
+    }
+
+    public NSUInteger stackSize ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_stackSize);
+    }
+
+    public void start ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_start);
+    }
+
+    public NSMutableDictionary threadDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_threadDictionary);
+        return result !is null ? new NSMutableDictionary(result) : null;
+    }
+
+    public static double threadPriority ()
+    {
+        return OS.objc_msgSend_fpret(OS.class_NSThread, OS.sel_threadPriority);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTimeInterval.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,10 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 23, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSTimeInterval;
+
+alias double NSTimeInterval;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTimeZone.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTimeZone;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSLocale;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTimeZoneNameStyle : NSInteger
+{
+    NSTimeZoneNameStyleStandard,
+    NSTimeZoneNameStyleShortStandard,
+    NSTimeZoneNameStyleDaylightSaving,
+    NSTimeZoneNameStyleShortDaylightSaving
+}
+
+alias NSTimeZoneNameStyle.NSTimeZoneNameStyleStandard NSTimeZoneNameStyleStandard;
+alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortStandard NSTimeZoneNameStyleShortStandard;
+alias NSTimeZoneNameStyle.NSTimeZoneNameStyleDaylightSaving NSTimeZoneNameStyleDaylightSaving;
+alias NSTimeZoneNameStyle.NSTimeZoneNameStyleShortDaylightSaving NSTimeZoneNameStyleShortDaylightSaving;
+
+public class NSTimeZone : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString abbreviation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_abbreviation);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSDictionary abbreviationDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_abbreviationDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSString abbreviationForDate (NSDate aDate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_abbreviationForDate_1, aDate !is null ? aDate.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSData data ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_data);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSTimeInterval daylightSavingTimeOffset ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_daylightSavingTimeOffset);
+    }
+
+    public NSTimeInterval daylightSavingTimeOffsetForDate (NSDate aDate)
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_daylightSavingTimeOffsetForDate_1, aDate !is null ? aDate.id : null);
+    }
+
+    public static NSTimeZone defaultTimeZone ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_defaultTimeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initWithName_ (NSString tzName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1, tzName !is null ? tzName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithName_data_ (NSString tzName, NSData aData)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1data_1, tzName !is null ? tzName.id : null, aData !is null ? aData.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isDaylightSavingTime ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDaylightSavingTime) !is null;
+    }
+
+    public bool isDaylightSavingTimeForDate (NSDate aDate)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDaylightSavingTimeForDate_1, aDate !is null ? aDate.id : null) !is null;
+    }
+
+    public bool isEqualToTimeZone (NSTimeZone aTimeZone)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToTimeZone_1, aTimeZone !is null ? aTimeZone.id : null) !is null;
+    }
+
+    public static NSArray knownTimeZoneNames ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_knownTimeZoneNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static NSTimeZone localTimeZone ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_localTimeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+    public NSString localizedName (NSTimeZoneNameStyle style, NSLocale locale)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedName_1locale_1, style, locale !is null ? locale.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDate nextDaylightSavingTimeTransition ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextDaylightSavingTimeTransition);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public NSDate nextDaylightSavingTimeTransitionAfterDate (NSDate aDate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextDaylightSavingTimeTransitionAfterDate_1, aDate !is null ? aDate.id : null);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public static void resetSystemTimeZone ()
+    {
+        OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_resetSystemTimeZone);
+    }
+
+    public NSInteger secondsFromGMT ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_secondsFromGMT);
+    }
+
+    public NSInteger secondsFromGMTForDate (NSDate aDate)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_secondsFromGMTForDate_1, aDate !is null ? aDate.id : null);
+    }
+
+    public static void setDefaultTimeZone (NSTimeZone aTimeZone)
+    {
+        OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_setDefaultTimeZone_1, aTimeZone !is null ? aTimeZone.id : null);
+    }
+
+    public static NSTimeZone systemTimeZone ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_systemTimeZone);
+        return result !is null ? new NSTimeZone(result) : null;
+    }
+
+    public static id timeZoneForSecondsFromGMT (NSInteger seconds)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneForSecondsFromGMT_1, seconds);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id timeZoneWithAbbreviation (NSString abbreviation)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithAbbreviation_1, abbreviation !is null ? abbreviation.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_timeZoneWithName_ (NSString tzName)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithName_1, tzName !is null ? tzName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_timeZoneWithName_data_ (NSString tzName, NSData aData)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimeZone, OS.sel_timeZoneWithName_1data_1, tzName !is null ? tzName.id : null,
+                aData !is null ? aData.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTimer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTimer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSInvocation;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTimer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void fire ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_fire);
+    }
+
+    public NSDate fireDate ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fireDate);
+        return result !is null ? new NSDate(result) : null;
+    }
+
+    public id initWithFireDate (NSDate date, NSTimeInterval ti, id t, objc.SEL s, id ui, bool rep)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFireDate_1interval_1target_1selector_1userInfo_1repeats_1,
+                date !is null ? date.id : null, ti, t !is null ? t.id : null, s, ui !is null ? ui.id : null, rep);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void invalidate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidate);
+    }
+
+    public bool isValid ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isValid) !is null;
+    }
+
+    public static NSTimer static_scheduledTimerWithTimeInterval_invocation_repeats_ (NSTimeInterval ti, NSInvocation invocation, bool yesOrNo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_scheduledTimerWithTimeInterval_1invocation_1repeats_1, ti,
+                invocation !is null ? invocation.id : null, yesOrNo);
+        return result !is null ? new NSTimer(result) : null;
+    }
+
+    public static NSTimer static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, objc.SEL aSelector,
+            objc.id userInfo, bool yesOrNo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_scheduledTimerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti,
+                aTarget !is null ? aTarget.id : null, aSelector, userInfo, yesOrNo);
+        return result !is null ? new NSTimer(result) : null;
+    }
+
+    public void setFireDate (NSDate date)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFireDate_1, date !is null ? date.id : null);
+    }
+
+    public NSTimeInterval timeInterval ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_timeInterval);
+    }
+
+    public static NSTimer static_timerWithTimeInterval_invocation_repeats_ (NSTimeInterval ti, NSInvocation invocation, bool yesOrNo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_timerWithTimeInterval_1invocation_1repeats_1, ti,
+                invocation !is null ? invocation.id : null, yesOrNo);
+        return result !is null ? new NSTimer(result) : null;
+    }
+
+    public static NSTimer static_timerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, objc.SEL aSelector, id userInfo,
+            bool yesOrNo)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_timerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti,
+                aTarget !is null ? aTarget.id : null, aSelector, userInfo !is null ? userInfo.id : null, yesOrNo);
+        return result !is null ? new NSTimer(result) : null;
+    }
+
+    public objc.id userInfo ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_userInfo);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTokenField.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTokenField;
+
+import dwt.internal.cocoa.NSCharacterSet;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSTextField;
+import dwt.internal.cocoa.NSTokenFieldCell : NSTokenStyle;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTokenField : NSTextField
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTimeInterval completionDelay ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_completionDelay);
+    }
+
+    public static NSTimeInterval defaultCompletionDelay ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(OS.class_NSTokenField, OS.sel_defaultCompletionDelay);
+    }
+
+    public static NSCharacterSet defaultTokenizingCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTokenField, OS.sel_defaultTokenizingCharacterSet);
+        return result !is null ? new NSCharacterSet(result) : null;
+    }
+
+    public void setCompletionDelay (NSTimeInterval delay)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCompletionDelay_1, delay);
+    }
+
+    public void setTokenStyle (NSTokenStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTokenStyle_1, style);
+    }
+
+    public void setTokenizingCharacterSet (NSCharacterSet characterSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTokenizingCharacterSet_1, characterSet !is null ? characterSet.id : null);
+    }
+
+    public NSTokenStyle tokenStyle ()
+    {
+        return cast(NSTokenStyle) OS.objc_msgSend(this.id, OS.sel_tokenStyle);
+    }
+
+    public NSCharacterSet tokenizingCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tokenizingCharacterSet);
+        return result !is null ? new NSCharacterSet(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTokenFieldCell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTokenFieldCell;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCharacterSet;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTokenStyle : NSUInteger
+{
+    NSDefaultTokenStyle,
+    NSPlainTextTokenStyle,
+    NSRoundedTokenStyle
+}
+
+alias NSTokenStyle.NSDefaultTokenStyle NSDefaultTokenStyle;
+alias NSTokenStyle.NSPlainTextTokenStyle NSPlainTextTokenStyle;
+alias NSTokenStyle.NSRoundedTokenStyle NSRoundedTokenStyle;
+
+public class NSTokenFieldCell : NSTextFieldCell
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTimeInterval completionDelay ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_completionDelay);
+    }
+
+    public static NSTimeInterval defaultCompletionDelay ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(OS.class_NSTokenFieldCell, OS.sel_defaultCompletionDelay);
+    }
+
+    public static NSCharacterSet defaultTokenizingCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTokenFieldCell, OS.sel_defaultTokenizingCharacterSet);
+        return result !is null ? new NSCharacterSet(result) : null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setCompletionDelay (NSTimeInterval delay)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCompletionDelay_1, delay);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setTokenStyle (NSTokenStyle style)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTokenStyle_1, style);
+    }
+
+    public void setTokenizingCharacterSet (NSCharacterSet characterSet)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTokenizingCharacterSet_1, characterSet !is null ? characterSet.id : null);
+    }
+
+    public NSTokenStyle tokenStyle ()
+    {
+        return cast(NSTokenStyle) OS.objc_msgSend(this.id, OS.sel_tokenStyle);
+    }
+
+    public NSCharacterSet tokenizingCharacterSet ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_tokenizingCharacterSet);
+        return result !is null ? new NSCharacterSet(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSToolbar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSToolbar;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSToolbarDisplayMode
+{
+    NSToolbarDisplayModeDefault,
+    NSToolbarDisplayModeIconAndLabel,
+    NSToolbarDisplayModeIconOnly,
+    NSToolbarDisplayModeLabelOnly
+}
+
+alias NSToolbarDisplayMode.NSToolbarDisplayModeDefault NSToolbarDisplayModeDefault;
+alias NSToolbarDisplayMode.NSToolbarDisplayModeIconAndLabel NSToolbarDisplayModeIconAndLabel;
+alias NSToolbarDisplayMode.NSToolbarDisplayModeIconOnly NSToolbarDisplayModeIconOnly;
+alias NSToolbarDisplayMode.NSToolbarDisplayModeLabelOnly NSToolbarDisplayModeLabelOnly;
+
+enum NSToolbarSizeMode
+{
+    NSToolbarSizeModeDefault,
+    NSToolbarSizeModeRegular,
+    NSToolbarSizeModeSmall
+}
+
+alias NSToolbarSizeMode.NSToolbarSizeModeDefault NSToolbarSizeModeDefault;
+alias NSToolbarSizeMode.NSToolbarSizeModeRegular NSToolbarSizeModeRegular;
+alias NSToolbarSizeMode.NSToolbarSizeModeSmall NSToolbarSizeModeSmall;
+
+public class NSToolbar : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool allowsUserCustomization ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsUserCustomization) !is null;
+    }
+
+    public bool autosavesConfiguration ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autosavesConfiguration) !is null;
+    }
+
+    public NSDictionary configurationDictionary ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_configurationDictionary);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public bool customizationPaletteIsRunning ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_customizationPaletteIsRunning) !is null;
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSToolbarDisplayMode displayMode ()
+    {
+        return cast(NSToolbarDisplayMode) OS.objc_msgSend(this.id, OS.sel_displayMode);
+    }
+
+    public NSString identifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_identifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initWithIdentifier (NSString identifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithIdentifier_1, identifier !is null ? identifier.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void insertItemWithItemIdentifier (NSString itemIdentifier, NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertItemWithItemIdentifier_1atIndex_1, itemIdentifier !is null ? itemIdentifier.id : null, index);
+    }
+
+    public bool isVisible ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isVisible) !is null;
+    }
+
+    public NSArray items ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_items);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void removeItemAtIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index);
+    }
+
+    public void runCustomizationPalette (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runCustomizationPalette_1, sender !is null ? sender.id : null);
+    }
+
+    public NSString selectedItemIdentifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedItemIdentifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setAllowsUserCustomization (bool allowCustomization)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsUserCustomization_1, allowCustomization);
+    }
+
+    public void setAutosavesConfiguration (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutosavesConfiguration_1, flag);
+    }
+
+    public void setConfigurationFromDictionary (NSDictionary configDict)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setConfigurationFromDictionary_1, configDict !is null ? configDict.id : null);
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setDisplayMode (NSToolbarDisplayMode displayMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDisplayMode_1, displayMode);
+    }
+
+    public void setSelectedItemIdentifier (NSString itemIdentifier)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectedItemIdentifier_1, itemIdentifier !is null ? itemIdentifier.id : null);
+    }
+
+    public void setShowsBaselineSeparator (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsBaselineSeparator_1, flag);
+    }
+
+    public void setSizeMode (NSToolbarSizeMode sizeMode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSizeMode_1, sizeMode);
+    }
+
+    public void setVisible (bool shown)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVisible_1, shown);
+    }
+
+    public bool showsBaselineSeparator ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsBaselineSeparator) !is null;
+    }
+
+    public NSToolbarSizeMode sizeMode ()
+    {
+        return cast(NSToolbarSizeMode) OS.objc_msgSend(this.id, OS.sel_sizeMode);
+    }
+
+    public void validateVisibleItems ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_validateVisibleItems);
+    }
+
+    public NSArray visibleItems ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_visibleItems);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSToolbarItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSToolbarItem;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSToolbar;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSToolbarItem : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public objc.SEL action ()
+    {
+        return cast(objc.SEL) OS.objc_msgSend(this.id, OS.sel_action);
+    }
+
+    public bool allowsDuplicatesInToolbar ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsDuplicatesInToolbar) !is null;
+    }
+
+    public bool autovalidates ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autovalidates) !is null;
+    }
+
+    public NSImage image ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_image);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public id initWithItemIdentifier (NSString itemIdentifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithItemIdentifier_1, itemIdentifier !is null ? itemIdentifier.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEnabled) !is null;
+    }
+
+    public NSString itemIdentifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_itemIdentifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString label ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_label);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSSize maxSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_maxSize);
+        return result;
+    }
+
+    public NSMenuItem menuFormRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuFormRepresentation);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSSize minSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_minSize);
+        return result;
+    }
+
+    public NSString paletteLabel ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_paletteLabel);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setAction (objc.SEL action)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAction_1, action);
+    }
+
+    public void setAutovalidates (bool resistance)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutovalidates_1, resistance);
+    }
+
+    public void setEnabled (bool enabled)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEnabled_1, enabled);
+    }
+
+    public void setImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setImage_1, image !is null ? image.id : null);
+    }
+
+    public void setLabel (NSString label)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLabel_1, label !is null ? label.id : null);
+    }
+
+    public void setMaxSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxSize_1, size);
+    }
+
+    public void setMenuFormRepresentation (NSMenuItem menuItem)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMenuFormRepresentation_1, menuItem !is null ? menuItem.id : null);
+    }
+
+    public void setMinSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinSize_1, size);
+    }
+
+    public void setPaletteLabel (NSString paletteLabel)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPaletteLabel_1, paletteLabel !is null ? paletteLabel.id : null);
+    }
+
+    public void setTag (NSInteger tag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTag_1, tag);
+    }
+
+    public void setTarget (id target)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTarget_1, target !is null ? target.id : null);
+    }
+
+    public void setToolTip (NSString toolTip)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setToolTip_1, toolTip !is null ? toolTip.id : null);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public void setVisibilityPriority (NSInteger visibilityPriority)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVisibilityPriority_1, visibilityPriority);
+    }
+
+    public NSInteger tag ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_tag);
+    }
+
+    public id target ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_target);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString toolTip ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolTip);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSToolbar toolbar ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolbar);
+        return result !is null ? new NSToolbar(result) : null;
+    }
+
+    public void validate ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_validate);
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSInteger visibilityPriority ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_visibilityPriority);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSToolbarItemGroup.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSToolbarItemGroup;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSToolbarItem;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSToolbarItemGroup : NSToolbarItem
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void setSubitems (NSArray subitems)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSubitems_1, subitems !is null ? subitems.id : null);
+    }
+
+    public NSArray subitems ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subitems);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTrackingArea.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTrackingArea;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+/* Type of tracking area.  You must specify one or more type from this list in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */
+enum : NSUInteger
+{
+    NSTrackingMouseEnteredAndExited = 0x01, // owner receives mouseEntered when mouse enters area, and mouseExited when mouse leaves area
+    NSTrackingMouseMoved = 0x02, // owner receives mouseMoved while mouse is within area.  Note that mouseMoved events do not contain userInfo 
+    NSTrackingCursorUpdate = 0x04, // owner receives cursorUpdate when mouse enters area.  Cursor is set appropriately when mouse exits area
+}
+
+/* When tracking area is active.  You must specify one of the following in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */
+enum : NSUInteger
+{
+    NSTrackingActiveWhenFirstResponder = 0x10, // owner receives mouseEntered/Exited, mouseMoved, or cursorUpdate when view is first responder
+    NSTrackingActiveInKeyWindow = 0x20, // owner receives mouseEntered/Exited, mouseMoved, or cursorUpdate when view is in key window
+    NSTrackingActiveInActiveApp = 0x40, // owner receives mouseEntered/Exited, mouseMoved, or cursorUpdate when app is active
+    NSTrackingActiveAlways = 0x80, // owner receives mouseEntered/Exited or mouseMoved regardless of activation.  Not supported for NSTrackingCursorUpdate.
+}
+
+/* Behavior of tracking area.  These values are used in NSTrackingAreaOptions.  You may specify any number of the following in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */
+enum : NSUInteger
+{
+    NSTrackingAssumeInside = 0x100, // If set, generate mouseExited event when mouse leaves area (same as assumeInside argument in deprecated addtrackingArea:owner:userData:assumeInside:)
+    NSTrackingInVisibleRect = 0x200, // If set, tracking occurs in visibleRect of view and rect is ignored
+    NSTrackingEnabledDuringMouseDrag = 0x400 // If set, mouseEntered events will be generated as mouse is dragged.  If not set, mouseEntered events will be generated as mouse is moved, and on mouseUp after a drag.  mouseExited events are paired with mouseEntered events so their delivery is affected indirectly.  That is, if a mouseEntered event is generated and the mouse subsequently moves out of the trackingArea, a mouseExited event will be generated whether the mouse is being moved or dragged, independent of this flag.
+}
+
+alias NSUInteger NSTrackingAreaOptions;
+
+public class NSTrackingArea : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTrackingArea initWithRect (NSRect rect, NSTrackingAreaOptions options, id owner, NSDictionary userInfo)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRect_1options_1owner_1userInfo_1, rect, options, owner !is null ? owner.id : null,
+                userInfo !is null ? userInfo.id : null);
+        return result is this.id ? this : (result !is null ? new NSTrackingArea(result) : null);
+    }
+
+    public NSTrackingAreaOptions options ()
+    {
+        return cast(NSTrackingAreaOptions) OS.objc_msgSend(this.id, OS.sel_options);
+    }
+
+    public id owner ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_owner);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRect rect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rect);
+        return result;
+    }
+
+    public NSDictionary userInfo ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_userInfo);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTreeController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,279 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTreeController;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSIndexPath;
+import dwt.internal.cocoa.NSObjectController;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTreeNode;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTreeController : NSObjectController
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void add (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_add_1, sender !is null ? sender.id : null);
+    }
+
+    public void addChild (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addChild_1, sender !is null ? sender.id : null);
+    }
+
+    public bool addSelectionIndexPaths (NSArray indexPaths)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_addSelectionIndexPaths_1, indexPaths !is null ? indexPaths.id : null) !is null;
+    }
+
+    public bool alwaysUsesMultipleValuesMarker ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_alwaysUsesMultipleValuesMarker) !is null;
+    }
+
+    public id arrangedObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrangedObjects);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool avoidsEmptySelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_avoidsEmptySelection) !is null;
+    }
+
+    public bool canAddChild ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canAddChild) !is null;
+    }
+
+    public bool canInsert ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canInsert) !is null;
+    }
+
+    public bool canInsertChild ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canInsertChild) !is null;
+    }
+
+    public NSString childrenKeyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_childrenKeyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString childrenKeyPathForNode (NSTreeNode node)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_childrenKeyPathForNode_1, node !is null ? node.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id content ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_content);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString countKeyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_countKeyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString countKeyPathForNode (NSTreeNode node)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_countKeyPathForNode_1, node !is null ? node.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void insert (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insert_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertChild (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertChild_1, sender !is null ? sender.id : null);
+    }
+
+    public void insertObject (id object, NSIndexPath indexPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertObject_1atArrangedObjectIndexPath_1, object !is null ? object.id : null,
+                indexPath !is null ? indexPath.id : null);
+    }
+
+    public void insertObjects (NSArray objects, NSArray indexPaths)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertObjects_1atArrangedObjectIndexPaths_1, objects !is null ? objects.id : null,
+                indexPaths !is null ? indexPaths.id : null);
+    }
+
+    public NSString leafKeyPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_leafKeyPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString leafKeyPathForNode (NSTreeNode node)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_leafKeyPathForNode_1, node !is null ? node.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void moveNode (NSTreeNode node, NSIndexPath indexPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveNode_1toIndexPath_1, node !is null ? node.id : null, indexPath !is null ? indexPath.id : null);
+    }
+
+    public void moveNodes (NSArray nodes, NSIndexPath startingIndexPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_moveNodes_1toIndexPath_1, nodes !is null ? nodes.id : null,
+                startingIndexPath !is null ? startingIndexPath.id : null);
+    }
+
+    public bool preservesSelection ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preservesSelection) !is null;
+    }
+
+    public void rearrangeObjects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_rearrangeObjects);
+    }
+
+    public void remove (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_remove_1, sender !is null ? sender.id : null);
+    }
+
+    public void removeObjectAtArrangedObjectIndexPath (NSIndexPath indexPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectAtArrangedObjectIndexPath_1, indexPath !is null ? indexPath.id : null);
+    }
+
+    public void removeObjectsAtArrangedObjectIndexPaths (NSArray indexPaths)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectsAtArrangedObjectIndexPaths_1, indexPaths !is null ? indexPaths.id : null);
+    }
+
+    public bool removeSelectionIndexPaths (NSArray indexPaths)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_removeSelectionIndexPaths_1, indexPaths !is null ? indexPaths.id : null) !is null;
+    }
+
+    public NSArray selectedNodes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedNodes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray selectedObjects ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectedObjects);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSIndexPath selectionIndexPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectionIndexPath);
+        return result !is null ? new NSIndexPath(result) : null;
+    }
+
+    public NSArray selectionIndexPaths ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_selectionIndexPaths);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool selectsInsertedObjects ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectsInsertedObjects) !is null;
+    }
+
+    public void setAlwaysUsesMultipleValuesMarker (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlwaysUsesMultipleValuesMarker_1, flag);
+    }
+
+    public void setAvoidsEmptySelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAvoidsEmptySelection_1, flag);
+    }
+
+    public void setChildrenKeyPath (NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setChildrenKeyPath_1, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void setContent (id content)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContent_1, content !is null ? content.id : null);
+    }
+
+    public void setCountKeyPath (NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCountKeyPath_1, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void setLeafKeyPath (NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLeafKeyPath_1, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void setPreservesSelection (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreservesSelection_1, flag);
+    }
+
+    public bool setSelectionIndexPath (NSIndexPath indexPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setSelectionIndexPath_1, indexPath !is null ? indexPath.id : null) !is null;
+    }
+
+    public bool setSelectionIndexPaths (NSArray indexPaths)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setSelectionIndexPaths_1, indexPaths !is null ? indexPaths.id : null) !is null;
+    }
+
+    public void setSelectsInsertedObjects (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSelectsInsertedObjects_1, flag);
+    }
+
+    public void setSortDescriptors (NSArray sortDescriptors)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSortDescriptors_1, sortDescriptors !is null ? sortDescriptors.id : null);
+    }
+
+    public NSArray sortDescriptors ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortDescriptors);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTreeNode.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTreeNode;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSIndexPath;
+import dwt.internal.cocoa.NSMutableArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSTreeNode : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSArray childNodes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_childNodes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSTreeNode descendantNodeAtIndexPath (NSIndexPath indexPath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_descendantNodeAtIndexPath_1, indexPath !is null ? indexPath.id : null);
+        return result is this.id ? this : (result !is null ? new NSTreeNode(result) : null);
+    }
+
+    public NSIndexPath indexPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_indexPath);
+        return result !is null ? new NSIndexPath(result) : null;
+    }
+
+    public id initWithRepresentedObject (id modelObject)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRepresentedObject_1, modelObject !is null ? modelObject.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isLeaf ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isLeaf) !is null;
+    }
+
+    public NSMutableArray mutableChildNodes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mutableChildNodes);
+        return result !is null ? new NSMutableArray(result) : null;
+    }
+
+    public NSTreeNode parentNode ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parentNode);
+        return result is this.id ? this : (result !is null ? new NSTreeNode(result) : null);
+    }
+
+    public id representedObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void sortWithSortDescriptors (NSArray sortDescriptors, bool recursively)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sortWithSortDescriptors_1recursively_1, sortDescriptors !is null ? sortDescriptors.id : null, recursively);
+    }
+
+    public static id treeNodeWithRepresentedObject (id modelObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTreeNode, OS.sel_treeNodeWithRepresentedObject_1, modelObject !is null ? modelObject.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSTypesetter.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,421 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSTypesetter;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSLayoutManager;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSParagraphStyle;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSText : NSWritingDirection;
+import dwt.internal.cocoa.NSTextContainer;
+import dwt.internal.cocoa.NSTextTab;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSTypesetterControlCharacterAction : NSUInteger
+{
+    NSTypesetterZeroAdvancementAction = (1 << 0),
+    NSTypesetterWhitespaceAction = (1 << 1),
+    NSTypesetterHorizontalTabAction = (1 << 2),
+    NSTypesetterLineBreakAction = (1 << 3),
+    NSTypesetterParagraphBreakAction = (1 << 4),
+    NSTypesetterContainerBreakAction = (1 << 5)
+}
+
+alias NSTypesetterControlCharacterAction.NSTypesetterZeroAdvancementAction NSTypesetterZeroAdvancementAction;
+alias NSTypesetterControlCharacterAction.NSTypesetterWhitespaceAction NSTypesetterWhitespaceAction;
+alias NSTypesetterControlCharacterAction.NSTypesetterHorizontalTabAction NSTypesetterHorizontalTabAction;
+alias NSTypesetterControlCharacterAction.NSTypesetterLineBreakAction NSTypesetterLineBreakAction;
+alias NSTypesetterControlCharacterAction.NSTypesetterParagraphBreakAction NSTypesetterParagraphBreakAction;
+alias NSTypesetterControlCharacterAction.NSTypesetterContainerBreakAction NSTypesetterContainerBreakAction;
+
+public class NSTypesetter : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSTypesetterControlCharacterAction actionForControlCharacterAtIndex (NSUInteger charIndex)
+    {
+        return cast(NSTypesetterControlCharacterAction) OS.objc_msgSend(this.id, OS.sel_actionForControlCharacterAtIndex_1, charIndex);
+    }
+
+    public NSAttributedString attributedString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedString);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSDictionary attributesForExtraLineFragment ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesForExtraLineFragment);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public CGFloat baselineOffsetInLayoutManager (NSLayoutManager layoutMgr, NSUInteger glyphIndex)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_baselineOffsetInLayoutManager_1glyphIndex_1,
+                layoutMgr !is null ? layoutMgr.id : null, glyphIndex);
+    }
+
+    public void beginLineWithGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginLineWithGlyphAtIndex_1, glyphIndex);
+    }
+
+    public void beginParagraph ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginParagraph);
+    }
+
+    public bool bidiProcessingEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_bidiProcessingEnabled) !is null;
+    }
+
+    public NSRect boundingBoxForControlGlyphAtIndex (NSUInteger glyphIndex, NSTextContainer textContainer, NSRect proposedRect,
+            NSPoint glyphPosition, NSUInteger charIndex)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id,
+                OS.sel_boundingBoxForControlGlyphAtIndex_1forTextContainer_1proposedLineFragment_1glyphPosition_1characterIndex_1, glyphIndex,
+                textContainer !is null ? textContainer.id : null, proposedRect, glyphPosition, charIndex);
+        return result;
+    }
+
+    public NSRange characterRangeForGlyphRange (NSRange glyphRange, NSRangePointer actualGlyphRange)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_characterRangeForGlyphRange_1actualGlyphRange_1, glyphRange, actualGlyphRange);
+        return result;
+    }
+
+    public NSParagraphStyle currentParagraphStyle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentParagraphStyle);
+        return result !is null ? new NSParagraphStyle(result) : null;
+    }
+
+    public NSTextContainer currentTextContainer ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentTextContainer);
+        return result !is null ? new NSTextContainer(result) : null;
+    }
+
+    public static NSTypesetterBehavior defaultTypesetterBehavior ()
+    {
+        return cast(NSTypesetterBehavior) OS.objc_msgSend(OS.class_NSTypesetter, OS.sel_defaultTypesetterBehavior);
+    }
+
+    public void deleteGlyphsInRange (NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deleteGlyphsInRange_1, glyphRange);
+    }
+
+    public void endLineWithGlyphRange (NSRange lineGlyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_endLineWithGlyphRange_1, lineGlyphRange);
+    }
+
+    public void endParagraph ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_endParagraph);
+    }
+
+    public NSUInteger getGlyphsInRange (NSRange glyphsRange, NSGlyph* glyphBuffer, NSUInteger* charIndexBuffer, NSGlyphInscription* inscribeBuffer,
+            bool* elasticBuffer, /*unsigned char* */ubyte* bidiLevelBuffer)
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id,
+                OS.sel_getGlyphsInRange_1glyphs_1characterIndexes_1glyphInscriptions_1elasticBits_1bidiLevels_1, glyphsRange, glyphBuffer,
+                charIndexBuffer, inscribeBuffer, elasticBuffer, bidiLevelBuffer);
+    }
+
+    public void getLineFragmentRect_usedRect_forParagraphSeparatorGlyphRange_atProposedOrigin_ (NSRectPointer lineFragmentRect,
+            NSRectPointer lineFragmentUsedRect, NSRange paragraphSeparatorGlyphRange, NSPoint lineOrigin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getLineFragmentRect_1usedRect_1forParagraphSeparatorGlyphRange_1atProposedOrigin_1, lineFragmentRect,
+                lineFragmentUsedRect, paragraphSeparatorGlyphRange, lineOrigin);
+    }
+
+    public void getLineFragmentRect_usedRect_remainingRect_forStartingGlyphAtIndex_proposedRect_lineSpacing_paragraphSpacingBefore_paragraphSpacingAfter_ (
+            NSRectPointer lineFragmentRect, NSRectPointer lineFragmentUsedRect, NSRectPointer remainingRect, NSUInteger startingGlyphIndex,
+            NSRect proposedRect, CGFloat lineSpacing, CGFloat paragraphSpacingBefore, CGFloat paragraphSpacingAfter)
+    {
+        OS.objc_msgSend(
+                this.id,
+                OS.sel_getLineFragmentRect_1usedRect_1remainingRect_1forStartingGlyphAtIndex_1proposedRect_1lineSpacing_1paragraphSpacingBefore_1paragraphSpacingAfter_1,
+                lineFragmentRect, lineFragmentUsedRect, remainingRect, startingGlyphIndex, proposedRect, lineSpacing, paragraphSpacingBefore,
+                paragraphSpacingAfter);
+    }
+
+    public NSRange glyphRangeForCharacterRange (NSRange charRange, NSRangePointer actualCharRange)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_glyphRangeForCharacterRange_1actualCharacterRange_1, charRange, actualCharRange);
+        return result;
+    }
+
+    public /*UTF32Char*/dchar hyphenCharacterForGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        return cast(/*UTF32Char*/dchar) OS.objc_msgSend(this.id, OS.sel_hyphenCharacterForGlyphAtIndex_1, glyphIndex);
+    }
+
+    public float hyphenationFactor ()
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_hyphenationFactor);
+    }
+
+    public float hyphenationFactorForGlyphAtIndex (NSUInteger glyphIndex)
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_hyphenationFactorForGlyphAtIndex_1, glyphIndex);
+    }
+
+    public void insertGlyph (NSGlyph glyph, NSUInteger glyphIndex, NSUInteger characterIndex)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertGlyph_1atGlyphIndex_1characterIndex_1, glyph, glyphIndex, characterIndex);
+    }
+
+    public NSRange layoutCharactersInRange (NSRange characterRange, NSLayoutManager layoutManager, NSUInteger maxNumLines)
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_layoutCharactersInRange_1forLayoutManager_1maximumNumberOfLineFragments_1, characterRange,
+                layoutManager !is null ? layoutManager.id : null, maxNumLines);
+        return result;
+    }
+
+    public void layoutGlyphsInLayoutManager (NSLayoutManager layoutManager, NSUInteger startGlyphIndex, NSUInteger maxNumLines, NSUInteger* nextGlyph)
+    {
+        OS.objc_msgSend(this.id, OS.sel_layoutGlyphsInLayoutManager_1startingAtGlyphIndex_1maxNumberOfLineFragments_1nextGlyphIndex_1,
+                layoutManager !is null ? layoutManager.id : null, startGlyphIndex, maxNumLines, nextGlyph);
+    }
+
+    public NSLayoutManager layoutManager ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_layoutManager);
+        return result !is null ? new NSLayoutManager(result) : null;
+    }
+
+    public NSUInteger layoutParagraphAtPoint (NSPointPointer lineFragmentOrigin)
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_layoutParagraphAtPoint_1, lineFragmentOrigin);
+    }
+
+    public CGFloat lineFragmentPadding ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineFragmentPadding);
+    }
+
+    public CGFloat lineSpacingAfterGlyphAtIndex (NSUInteger glyphIndex, NSRect rect)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_lineSpacingAfterGlyphAtIndex_1withProposedLineFragmentRect_1, glyphIndex, rect);
+    }
+
+    public NSRange paragraphCharacterRange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_paragraphCharacterRange);
+        return result;
+    }
+
+    public NSRange paragraphGlyphRange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_paragraphGlyphRange);
+        return result;
+    }
+
+    public NSRange paragraphSeparatorCharacterRange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_paragraphSeparatorCharacterRange);
+        return result;
+    }
+
+    public NSRange paragraphSeparatorGlyphRange ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_paragraphSeparatorGlyphRange);
+        return result;
+    }
+
+    public CGFloat paragraphSpacingAfterGlyphAtIndex (NSUInteger glyphIndex, NSRect rect)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_paragraphSpacingAfterGlyphAtIndex_1withProposedLineFragmentRect_1, glyphIndex, rect);
+    }
+
+    public CGFloat paragraphSpacingBeforeGlyphAtIndex (NSUInteger glyphIndex, NSRect rect)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_paragraphSpacingBeforeGlyphAtIndex_1withProposedLineFragmentRect_1, glyphIndex, rect);
+    }
+
+    public static NSSize printingAdjustmentInLayoutManager (NSLayoutManager layoutMgr, NSRange nominallySpacedGlyphsRange,
+            /*const unsigned char* */ubyte* packedGlyphs, NSUInteger packedGlyphsCount)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, OS.class_NSTypesetter,
+                OS.sel_printingAdjustmentInLayoutManager_1forNominallySpacedGlyphRange_1packedGlyphs_1count_1,
+                layoutMgr !is null ? layoutMgr.id : null, nominallySpacedGlyphsRange, packedGlyphs, packedGlyphsCount);
+        return result;
+    }
+
+    public void setAttachmentSize (NSSize attachmentSize, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttachmentSize_1forGlyphRange_1, attachmentSize, glyphRange);
+    }
+
+    public void setAttributedString (NSAttributedString attrString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributedString_1, attrString !is null ? attrString.id : null);
+    }
+
+    public void setBidiLevels (/*const uint8_t* */ubyte* levels, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBidiLevels_1forGlyphRange_1, levels, glyphRange);
+    }
+
+    public void setBidiProcessingEnabled (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBidiProcessingEnabled_1, flag);
+    }
+
+    public void setDrawsOutsideLineFragment (bool flag, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDrawsOutsideLineFragment_1forGlyphRange_1, flag, glyphRange);
+    }
+
+    public void setHardInvalidation (bool flag, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHardInvalidation_1forGlyphRange_1, flag, glyphRange);
+    }
+
+    public void setHyphenationFactor (float factor)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHyphenationFactor_1, factor);
+    }
+
+    public void setLineFragmentPadding (CGFloat padding)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineFragmentPadding_1, padding);
+    }
+
+    public void setLineFragmentRect (NSRect fragmentRect, NSRange glyphRange, NSRect usedRect, CGFloat baselineOffset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLineFragmentRect_1forGlyphRange_1usedRect_1baselineOffset_1, fragmentRect, glyphRange, usedRect,
+                baselineOffset);
+    }
+
+    public void setLocation (NSPoint location, /*const CGFloat* */CGFloat* advancements, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLocation_1withAdvancements_1forStartOfGlyphRange_1, location, advancements, glyphRange);
+    }
+
+    public void setNotShownAttribute (bool flag, NSRange glyphRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNotShownAttribute_1forGlyphRange_1, flag, glyphRange);
+    }
+
+    public void setParagraphGlyphRange (NSRange paragraphRange, NSRange paragraphSeparatorRange)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParagraphGlyphRange_1separatorGlyphRange_1, paragraphRange, paragraphSeparatorRange);
+    }
+
+    public void setTypesetterBehavior (NSTypesetterBehavior behavior)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTypesetterBehavior_1, behavior);
+    }
+
+    public void setUsesFontLeading (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUsesFontLeading_1, flag);
+    }
+
+    public static id sharedSystemTypesetter ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTypesetter, OS.sel_sharedSystemTypesetter);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id sharedSystemTypesetterForBehavior (NSTypesetterBehavior theBehavior)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSTypesetter, OS.sel_sharedSystemTypesetterForBehavior_1, theBehavior);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool shouldBreakLineByHyphenatingBeforeCharacterAtIndex (NSUInteger charIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldBreakLineByHyphenatingBeforeCharacterAtIndex_1, charIndex) !is null;
+    }
+
+    public bool shouldBreakLineByWordBeforeCharacterAtIndex (NSUInteger charIndex)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldBreakLineByWordBeforeCharacterAtIndex_1, charIndex) !is null;
+    }
+
+    public NSFont substituteFontForFont (NSFont originalFont)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_substituteFontForFont_1, originalFont !is null ? originalFont.id : null);
+        return result !is null ? new NSFont(result) : null;
+    }
+
+    public void substituteGlyphsInRange (NSRange glyphRange, NSGlyph* glyphs)
+    {
+        OS.objc_msgSend(this.id, OS.sel_substituteGlyphsInRange_1withGlyphs_1, glyphRange, glyphs);
+    }
+
+    public NSArray textContainers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textContainers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSTextTab textTabForGlyphLocation (CGFloat glyphLocation, NSWritingDirection direction, CGFloat maxLocation)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textTabForGlyphLocation_1writingDirection_1maxLocation_1, glyphLocation, direction,
+                maxLocation);
+        return result !is null ? new NSTextTab(result) : null;
+    }
+
+    public NSTypesetterBehavior typesetterBehavior ()
+    {
+        return cast(NSTypesetterBehavior) OS.objc_msgSend(this.id, OS.sel_typesetterBehavior);
+    }
+
+    public bool usesFontLeading ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_usesFontLeading) !is null;
+    }
+
+    public void willSetLineFragmentRect (NSRectPointer lineRect, NSRange glyphRange, NSRectPointer usedRect, CGFloat* baselineOffset)
+    {
+        OS.objc_msgSend(this.id, OS.sel_willSetLineFragmentRect_1forGlyphRange_1usedRect_1baselineOffset_1, lineRect, glyphRange, usedRect,
+                baselineOffset);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURL.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURL;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURLHandle;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURL : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSURLHandle URLHandleUsingCache (bool shouldUseCache)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URLHandleUsingCache_1, shouldUseCache);
+        return result !is null ? new NSURLHandle(result) : null;
+    }
+
+    public static NSURL static_URLWithString_ (NSString URLString)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_URLWithString_1, URLString !is null ? URLString.id : null);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public static id static_URLWithString_relativeToURL_ (NSString URLString, NSURL baseURL)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_URLWithString_1relativeToURL_1, URLString !is null ? URLString.id : null,
+                baseURL !is null ? baseURL.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString absoluteString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_absoluteString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSURL absoluteURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_absoluteURL);
+        return result is this.id ? this : (result !is null ? new NSURL(result) : null);
+    }
+
+    public NSURL baseURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_baseURL);
+        return result is this.id ? this : (result !is null ? new NSURL(result) : null);
+    }
+
+    public static NSURL static_fileURLWithPath_ (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_fileURLWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public static id static_fileURLWithPath_isDirectory_ (NSString path, bool isDir)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURL, OS.sel_fileURLWithPath_1isDirectory_1, path !is null ? path.id : null, isDir);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString fragment ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fragment);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString host ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_host);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initFileURLWithPath_ (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initFileURLWithPath_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initFileURLWithPath_isDirectory_ (NSString path, bool isDir)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initFileURLWithPath_1isDirectory_1, path !is null ? path.id : null, isDir);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithScheme (NSString scheme, NSString host, NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithScheme_1host_1path_1, scheme !is null ? scheme.id : null,
+                host !is null ? host.id : null, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithString_ (NSString URLString)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, URLString !is null ? URLString.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithString_relativeToURL_ (NSString URLString, NSURL baseURL)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1relativeToURL_1, URLString !is null ? URLString.id : null,
+                baseURL !is null ? baseURL.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isFileURL ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFileURL) !is null;
+    }
+
+    public void loadResourceDataNotifyingClient (id client, bool shouldUseCache)
+    {
+        OS.objc_msgSend(this.id, OS.sel_loadResourceDataNotifyingClient_1usingCache_1, client !is null ? client.id : null, shouldUseCache);
+    }
+
+    public NSString parameterString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parameterString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString password ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_password);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString path ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_path);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSNumber port ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_port);
+        return result !is null ? new NSNumber(result) : null;
+    }
+
+    public id propertyForKey (NSString propertyKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyForKey_1, propertyKey !is null ? propertyKey.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString query ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_query);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString relativePath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_relativePath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString relativeString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_relativeString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSData resourceDataUsingCache (bool shouldUseCache)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resourceDataUsingCache_1, shouldUseCache);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSString resourceSpecifier ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resourceSpecifier);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString scheme ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_scheme);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool setProperty (id property, NSString propertyKey)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setProperty_1forKey_1, property !is null ? property.id : null,
+                propertyKey !is null ? propertyKey.id : null) !is null;
+    }
+
+    public bool setResourceData (NSData data)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setResourceData_1, data !is null ? data.id : null) !is null;
+    }
+
+    public NSURL standardizedURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standardizedURL);
+        return result is this.id ? this : (result !is null ? new NSURL(result) : null);
+    }
+
+    public NSString user ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_user);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLAuthenticationChallenge.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLAuthenticationChallenge;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSURLCredential;
+import dwt.internal.cocoa.NSURLProtectionSpace;
+import dwt.internal.cocoa.NSURLResponse;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLAuthenticationChallenge : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSError error ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_error);
+        return result !is null ? new NSError(result) : null;
+    }
+
+    public NSURLResponse failureResponse ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_failureResponse);
+        return result !is null ? new NSURLResponse(result) : null;
+    }
+
+    public id initWithAuthenticationChallenge (NSURLAuthenticationChallenge challenge, id sender)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithAuthenticationChallenge_1sender_1, challenge !is null ? challenge.id : null,
+                sender !is null ? sender.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithProtectionSpace (NSURLProtectionSpace space, NSURLCredential credential, NSInteger previousFailureCount, NSURLResponse response,
+            NSError error, id sender)
+    {
+        objc.id result = OS.objc_msgSend(this.id,
+                OS.sel_initWithProtectionSpace_1proposedCredential_1previousFailureCount_1failureResponse_1error_1sender_1,
+                space !is null ? space.id : null, credential !is null ? credential.id : null, previousFailureCount,
+                response !is null ? response.id : null, error !is null ? error.id : null, sender !is null ? sender.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger previousFailureCount ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_previousFailureCount);
+    }
+
+    public NSURLCredential proposedCredential ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_proposedCredential);
+        return result !is null ? new NSURLCredential(result) : null;
+    }
+
+    public NSURLProtectionSpace protectionSpace ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_protectionSpace);
+        return result !is null ? new NSURLProtectionSpace(result) : null;
+    }
+
+    public id sender ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sender);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLCache.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLCache;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCachedURLResponse;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSURLCacheStoragePolicy
+{
+    NSURLCacheStorageAllowed,
+    NSURLCacheStorageAllowedInMemoryOnly,
+    NSURLCacheStorageNotAllowed,
+}
+
+alias NSURLCacheStoragePolicy.NSURLCacheStorageAllowed NSURLCacheStorageAllowed;
+alias NSURLCacheStoragePolicy.NSURLCacheStorageAllowedInMemoryOnly NSURLCacheStorageAllowedInMemoryOnly;
+alias NSURLCacheStoragePolicy.NSURLCacheStorageNotAllowed NSURLCacheStorageNotAllowed;
+
+public class NSURLCache : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSCachedURLResponse cachedResponseForRequest (NSURLRequest request)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cachedResponseForRequest_1, request !is null ? request.id : null);
+        return result !is null ? new NSCachedURLResponse(result) : null;
+    }
+
+    public NSUInteger currentDiskUsage ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_currentDiskUsage);
+    }
+
+    public NSUInteger currentMemoryUsage ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_currentMemoryUsage);
+    }
+
+    public NSUInteger diskCapacity ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_diskCapacity);
+    }
+
+    public id initWithMemoryCapacity (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMemoryCapacity_1diskCapacity_1diskPath_1, memoryCapacity, diskCapacity,
+                path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger memoryCapacity ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_memoryCapacity);
+    }
+
+    public void removeAllCachedResponses ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllCachedResponses);
+    }
+
+    public void removeCachedResponseForRequest (NSURLRequest request)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeCachedResponseForRequest_1, request !is null ? request.id : null);
+    }
+
+    public void setDiskCapacity (NSUInteger diskCapacity)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDiskCapacity_1, diskCapacity);
+    }
+
+    public void setMemoryCapacity (NSUInteger memoryCapacity)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMemoryCapacity_1, memoryCapacity);
+    }
+
+    public static void setSharedURLCache (NSURLCache cache)
+    {
+        OS.objc_msgSend(OS.class_NSURLCache, OS.sel_setSharedURLCache_1, cache !is null ? cache.id : null);
+    }
+
+    public static NSURLCache sharedURLCache ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLCache, OS.sel_sharedURLCache);
+        return result !is null ? new NSURLCache(result) : null;
+    }
+
+    public void storeCachedResponse (NSCachedURLResponse cachedResponse, NSURLRequest request)
+    {
+        OS.objc_msgSend(this.id, OS.sel_storeCachedResponse_1forRequest_1, cachedResponse !is null ? cachedResponse.id : null,
+                request !is null ? request.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLConnection.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLConnection;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLConnection : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static bool canHandleRequest (NSURLRequest request)
+    {
+        return OS.objc_msgSend(OS.class_NSURLConnection, OS.sel_canHandleRequest_1, request !is null ? request.id : null) !is null;
+    }
+
+    public void cancel ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancel);
+    }
+
+    public static NSURLConnection connectionWithRequest (NSURLRequest request, id delegatee)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLConnection, OS.sel_connectionWithRequest_1delegate_1, request !is null ? request.id : null,
+                delegatee !is null ? delegatee.id : null);
+        return result !is null ? new NSURLConnection(result) : null;
+    }
+
+    public id initWithRequest_delegate_ (NSURLRequest request, id delegatee)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRequest_1delegate_1, request !is null ? request.id : null,
+                delegatee !is null ? delegatee.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithRequest_delegate_startImmediately_ (NSURLRequest request, id delegatee, bool startImmediately)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRequest_1delegate_1startImmediately_1, request !is null ? request.id : null,
+                delegatee !is null ? delegatee.id : null, startImmediately);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void scheduleInRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scheduleInRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+    public static NSData sendSynchronousRequest (NSURLRequest request, /*NSURLResponse** */objc.id** response, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLConnection, OS.sel_sendSynchronousRequest_1returningResponse_1error_1,
+                request !is null ? request.id : null, response, error);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void start ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_start);
+    }
+
+    public void unscheduleFromRunLoop (NSRunLoop aRunLoop, NSString mode)
+    {
+        OS.objc_msgSend(this.id, OS.sel_unscheduleFromRunLoop_1forMode_1, aRunLoop !is null ? aRunLoop.id : null, mode !is null ? mode.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLCredential.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLCredential;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSURLCredentialPersistence
+{
+    NSURLCredentialPersistenceNone,
+    NSURLCredentialPersistenceForSession,
+    NSURLCredentialPersistencePermanent
+}
+
+alias NSURLCredentialPersistence.NSURLCredentialPersistenceNone NSURLCredentialPersistenceNone;
+alias NSURLCredentialPersistence.NSURLCredentialPersistenceForSession NSURLCredentialPersistenceForSession;
+alias NSURLCredentialPersistence.NSURLCredentialPersistencePermanent NSURLCredentialPersistencePermanent;
+
+public class NSURLCredential : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSURLCredential credentialWithUser (NSString user, NSString password, NSURLCredentialPersistence persistence)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLCredential, OS.sel_credentialWithUser_1password_1persistence_1,
+                user !is null ? user.id : null, password !is null ? password.id : null, persistence);
+        return result !is null ? new NSURLCredential(result) : null;
+    }
+
+    public bool hasPassword ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasPassword) !is null;
+    }
+
+    public id initWithUser (NSString user, NSString password, NSURLCredentialPersistence persistence)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUser_1password_1persistence_1, user !is null ? user.id : null,
+                password !is null ? password.id : null, persistence);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString password ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_password);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSURLCredentialPersistence persistence ()
+    {
+        return cast(NSURLCredentialPersistence) OS.objc_msgSend(this.id, OS.sel_persistence);
+    }
+
+    public NSString user ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_user);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLCredentialStorage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLCredentialStorage;
+
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSURLCredential;
+import dwt.internal.cocoa.NSURLProtectionSpace;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLCredentialStorage : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSDictionary allCredentials ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allCredentials);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary credentialsForProtectionSpace (NSURLProtectionSpace space)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_credentialsForProtectionSpace_1, space !is null ? space.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSURLCredential defaultCredentialForProtectionSpace (NSURLProtectionSpace space)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultCredentialForProtectionSpace_1, space !is null ? space.id : null);
+        return result !is null ? new NSURLCredential(result) : null;
+    }
+
+    public void removeCredential (NSURLCredential credential, NSURLProtectionSpace space)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeCredential_1forProtectionSpace_1, credential !is null ? credential.id : null,
+                space !is null ? space.id : null);
+    }
+
+    public void setCredential (NSURLCredential credential, NSURLProtectionSpace space)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCredential_1forProtectionSpace_1, credential !is null ? credential.id : null,
+                space !is null ? space.id : null);
+    }
+
+    public void setDefaultCredential (NSURLCredential credential, NSURLProtectionSpace space)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultCredential_1forProtectionSpace_1, credential !is null ? credential.id : null,
+                space !is null ? space.id : null);
+    }
+
+    public static NSURLCredentialStorage sharedCredentialStorage ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLCredentialStorage, OS.sel_sharedCredentialStorage);
+        return result !is null ? new NSURLCredentialStorage(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLDownload.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLDownload;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLDownload : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static bool canResumeDownloadDecodedWithEncodingMIMEType (NSString MIMEType)
+    {
+        return OS.objc_msgSend(OS.class_NSURLDownload, OS.sel_canResumeDownloadDecodedWithEncodingMIMEType_1, MIMEType !is null ? MIMEType.id : null) !is null;
+    }
+
+    public void cancel ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancel);
+    }
+
+    public bool deletesFileUponFailure ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_deletesFileUponFailure) !is null;
+    }
+
+    public id initWithRequest (NSURLRequest request, id delegatee)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRequest_1delegate_1, request !is null ? request.id : null,
+                delegatee !is null ? delegatee.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithResumeData (NSData resumeData, id delegatee, NSString path)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithResumeData_1delegate_1path_1, resumeData !is null ? resumeData.id : null,
+                delegatee !is null ? delegatee.id : null, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSURLRequest request ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_request);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public NSData resumeData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resumeData);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void setDeletesFileUponFailure (bool deletesFileUponFailure)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDeletesFileUponFailure_1, deletesFileUponFailure);
+    }
+
+    public void setDestination (NSString path, bool allowOverwrite)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDestination_1allowOverwrite_1, path !is null ? path.id : null, allowOverwrite);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLHandle.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLHandle;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSURLHandleStatus : NSUInteger
+{
+    NSURLHandleNotLoaded = 0,
+    NSURLHandleLoadSucceeded,
+    NSURLHandleLoadInProgress,
+    NSURLHandleLoadFailed
+}
+
+alias NSURLHandleStatus.NSURLHandleNotLoaded NSURLHandleNotLoaded;
+alias NSURLHandleStatus.NSURLHandleLoadSucceeded NSURLHandleLoadSucceeded;
+alias NSURLHandleStatus.NSURLHandleLoadInProgress NSURLHandleLoadInProgress;
+alias NSURLHandleStatus.NSURLHandleLoadFailed NSURLHandleLoadFailed;
+
+public class NSURLHandle : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static objc.Class URLHandleClassForURL (NSURL anURL)
+    {
+        return cast(objc.Class) OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_URLHandleClassForURL_1, anURL !is null ? anURL.id : null);
+    }
+
+    public void addClient (id client)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addClient_1, client !is null ? client.id : null);
+    }
+
+    public NSData availableResourceData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_availableResourceData);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void backgroundLoadDidFailWithReason (NSString reason)
+    {
+        OS.objc_msgSend(this.id, OS.sel_backgroundLoadDidFailWithReason_1, reason !is null ? reason.id : null);
+    }
+
+    public void beginLoadInBackground ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginLoadInBackground);
+    }
+
+    public static NSURLHandle cachedHandleForURL (NSURL anURL)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_cachedHandleForURL_1, anURL !is null ? anURL.id : null);
+        return result !is null ? new NSURLHandle(result) : null;
+    }
+
+    public static bool canInitWithURL (NSURL anURL)
+    {
+        return OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_canInitWithURL_1, anURL !is null ? anURL.id : null) !is null;
+    }
+
+    public void cancelLoadInBackground ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_cancelLoadInBackground);
+    }
+
+    public void didLoadBytes (NSData newBytes, bool yorn)
+    {
+        OS.objc_msgSend(this.id, OS.sel_didLoadBytes_1loadComplete_1, newBytes !is null ? newBytes.id : null, yorn);
+    }
+
+    public void endLoadInBackground ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_endLoadInBackground);
+    }
+
+    public long expectedResourceDataSize ()
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_expectedResourceDataSize);
+    }
+
+    public NSString failureReason ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_failureReason);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void flushCachedData ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushCachedData);
+    }
+
+    public id initWithURL (NSURL anURL, bool willCache)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithURL_1cached_1, anURL !is null ? anURL.id : null, willCache);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void loadInBackground ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_loadInBackground);
+    }
+
+    public NSData loadInForeground ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_loadInForeground);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public id propertyForKey (NSString propertyKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyForKey_1, propertyKey !is null ? propertyKey.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id propertyForKeyIfAvailable (NSString propertyKey)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyForKeyIfAvailable_1, propertyKey !is null ? propertyKey.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static void registerURLHandleClass (objc.Class anURLHandleSubclass)
+    {
+        OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_registerURLHandleClass_1, anURLHandleSubclass);
+    }
+
+    public void removeClient (id client)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeClient_1, client !is null ? client.id : null);
+    }
+
+    public NSData resourceData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resourceData);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSURLHandleStatus status ()
+    {
+        return cast(NSURLHandleStatus) OS.objc_msgSend(this.id, OS.sel_status);
+    }
+
+    public bool writeData (NSData data)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeData_1, data !is null ? data.id : null) !is null;
+    }
+
+    public bool writeProperty (id propertyValue, NSString propertyKey)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_writeProperty_1forKey_1, propertyValue !is null ? propertyValue.id : null,
+                propertyKey !is null ? propertyKey.id : null) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLProtectionSpace.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLProtectionSpace;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLProtectionSpace : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString authenticationMethod ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_authenticationMethod);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString host ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_host);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id initWithHost (NSString host, NSInteger port, NSString protocol, NSString realm, NSString authenticationMethod)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithHost_1port_1protocol_1realm_1authenticationMethod_1, host !is null ? host.id : null,
+                port, protocol !is null ? protocol.id : null, realm !is null ? realm.id : null,
+                authenticationMethod !is null ? authenticationMethod.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithProxyHost (NSString host, NSInteger port, NSString type, NSString realm, NSString authenticationMethod)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithProxyHost_1port_1type_1realm_1authenticationMethod_1,
+                host !is null ? host.id : null, port, type !is null ? type.id : null, realm !is null ? realm.id : null,
+                authenticationMethod !is null ? authenticationMethod.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isProxy ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isProxy) !is null;
+    }
+
+    public NSInteger port ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_port);
+    }
+
+    public NSString protocol ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_protocol);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString proxyType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_proxyType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString realm ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_realm);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool receivesCredentialSecurely ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_receivesCredentialSecurely) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLProtocol.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLProtocol;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCachedURLResponse;
+import dwt.internal.cocoa.NSMutableURLRequest;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLProtocol : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSCachedURLResponse cachedResponse ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_cachedResponse);
+        return result !is null ? new NSCachedURLResponse(result) : null;
+    }
+
+    public static bool canInitWithRequest (NSURLRequest request)
+    {
+        return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canInitWithRequest_1, request !is null ? request.id : null) !is null;
+    }
+
+    public static NSURLRequest canonicalRequestForRequest (NSURLRequest request)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canonicalRequestForRequest_1, request !is null ? request.id : null);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public id client ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_client);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithRequest (NSURLRequest request, NSCachedURLResponse cachedResponse, id client)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRequest_1cachedResponse_1client_1, request !is null ? request.id : null,
+                cachedResponse !is null ? cachedResponse.id : null, client !is null ? client.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id propertyForKey (NSString key, NSURLRequest request)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_propertyForKey_1inRequest_1, key !is null ? key.id : null,
+                request !is null ? request.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static bool registerClass (objc.Class protocolClass)
+    {
+        return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_registerClass_1, protocolClass) !is null;
+    }
+
+    public static void removePropertyForKey (NSString key, NSMutableURLRequest request)
+    {
+        OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_removePropertyForKey_1inRequest_1, key !is null ? key.id : null,
+                request !is null ? request.id : null);
+    }
+
+    public NSURLRequest request ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_request);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public static bool requestIsCacheEquivalent (NSURLRequest a, NSURLRequest b)
+    {
+        return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_requestIsCacheEquivalent_1toRequest_1, a !is null ? a.id : null,
+                b !is null ? b.id : null) !is null;
+    }
+
+    public static void setProperty (id value, NSString key, NSMutableURLRequest request)
+    {
+        OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_setProperty_1forKey_1inRequest_1, value !is null ? value.id : null,
+                key !is null ? key.id : null, request !is null ? request.id : null);
+    }
+
+    public void startLoading ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_startLoading);
+    }
+
+    public void stopLoading ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_stopLoading);
+    }
+
+    public static void unregisterClass (objc.Class protocolClass)
+    {
+        OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_unregisterClass_1, protocolClass);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLRequest.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLRequest;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate : NSTimeInterval;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInputStream;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSURLRequest;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSURLRequestCachePolicy : NSUInteger
+{
+    NSURLRequestUseProtocolCachePolicy = 0,
+    NSURLRequestReloadIgnoringLocalCacheData = 1,
+    NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4,
+    NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData,
+    NSURLRequestReturnCacheDataElseLoad = 2,
+    NSURLRequestReturnCacheDataDontLoad = 3,
+    NSURLRequestReloadRevalidatingCacheData = 5
+}
+
+alias NSURLRequestCachePolicy.NSURLRequestUseProtocolCachePolicy NSURLRequestUseProtocolCachePolicy;
+alias NSURLRequestCachePolicy.NSURLRequestReloadIgnoringLocalCacheData NSURLRequestReloadIgnoringLocalCacheData;
+alias NSURLRequestCachePolicy.NSURLRequestReloadIgnoringLocalAndRemoteCacheData NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
+alias NSURLRequestCachePolicy.NSURLRequestReloadIgnoringCacheData NSURLRequestReloadIgnoringCacheData;
+alias NSURLRequestCachePolicy.NSURLRequestReturnCacheDataElseLoad NSURLRequestReturnCacheDataElseLoad;
+alias NSURLRequestCachePolicy.NSURLRequestReturnCacheDataDontLoad NSURLRequestReturnCacheDataDontLoad;
+alias NSURLRequestCachePolicy.NSURLRequestReloadRevalidatingCacheData NSURLRequestReloadRevalidatingCacheData;
+
+public class NSURLRequest : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSData HTTPBody ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_HTTPBody);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSInputStream HTTPBodyStream ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_HTTPBodyStream);
+        return result !is null ? new NSInputStream(result) : null;
+    }
+
+    public NSString HTTPMethod ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_HTTPMethod);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool HTTPShouldHandleCookies ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_HTTPShouldHandleCookies) !is null;
+    }
+
+    public NSURL URL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public NSDictionary allHTTPHeaderFields ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_allHTTPHeaderFields);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSURLRequestCachePolicy cachePolicy ()
+    {
+        return cast(NSURLRequestCachePolicy) OS.objc_msgSend(this.id, OS.sel_cachePolicy);
+    }
+
+    public id initWithURL_ (NSURL URL)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithURL_1, URL !is null ? URL.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithURL_cachePolicy_timeoutInterval_ (NSURL URL, NSURLRequestCachePolicy cachePolicy, NSTimeInterval timeoutInterval)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithURL_1cachePolicy_1timeoutInterval_1, URL !is null ? URL.id : null, cachePolicy,
+                timeoutInterval);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSURL mainDocumentURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mainDocumentURL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public static NSURLRequest static_requestWithURL_ (NSURL URL)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLRequest, OS.sel_requestWithURL_1, URL !is null ? URL.id : null);
+        return result !is null ? new NSURLRequest(result) : null;
+    }
+
+    public static id static_requestWithURL_cachePolicy_timeoutInterval_ (NSURL URL, NSURLRequestCachePolicy cachePolicy, NSTimeInterval timeoutInterval)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSURLRequest, OS.sel_requestWithURL_1cachePolicy_1timeoutInterval_1, URL !is null ? URL.id : null,
+                cachePolicy, timeoutInterval);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSTimeInterval timeoutInterval ()
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_timeoutInterval);
+    }
+
+    public NSString valueForHTTPHeaderField (NSString field)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForHTTPHeaderField_1, field !is null ? field.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSURLResponse.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSURLResponse;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSURLResponse : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString MIMEType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_MIMEType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSURL URL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public long expectedContentLength ()
+    {
+        return cast(long) OS.objc_msgSend(this.id, OS.sel_expectedContentLength);
+    }
+
+    public id initWithURL (NSURL URL, NSString MIMEType, NSInteger length, NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithURL_1MIMEType_1expectedContentLength_1textEncodingName_1,
+                URL !is null ? URL.id : null, MIMEType !is null ? MIMEType.id : null, length, name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString suggestedFilename ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_suggestedFilename);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString textEncodingName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_textEncodingName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSUnarchiver.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSUnarchiver;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSCoder;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSZone;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSUnarchiver : NSCoder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static NSString static_classNameDecodedForArchiveClassName_ (NSString inArchiveName)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSUnarchiver, OS.sel_classNameDecodedForArchiveClassName_1,
+                inArchiveName !is null ? inArchiveName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString classNameDecodedForArchiveClassName_ (NSString inArchiveName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_classNameDecodedForArchiveClassName_1, inArchiveName !is null ? inArchiveName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void decodeClassName_asClassName_ (NSString inArchiveName, NSString trueName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_decodeClassName_1asClassName_1, inArchiveName !is null ? inArchiveName.id : null,
+                trueName !is null ? trueName.id : null);
+    }
+
+    public static void static_decodeClassName_asClassName_ (NSString inArchiveName, NSString trueName)
+    {
+        OS.objc_msgSend(OS.class_NSUnarchiver, OS.sel_decodeClassName_1asClassName_1, inArchiveName !is null ? inArchiveName.id : null,
+                trueName !is null ? trueName.id : null);
+    }
+
+    public id initForReadingWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initForReadingWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isAtEnd ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAtEnd) !is null;
+    }
+
+    public NSZone* objectZone ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_objectZone);
+    }
+
+    public void replaceObject (id object, id newObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceObject_1withObject_1, object !is null ? object.id : null, newObject !is null ? newObject.id : null);
+    }
+
+    public void setObjectZone (NSZone* zone)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectZone_1, zone);
+    }
+
+    public uint systemVersion ()
+    {
+        return cast(uint) OS.objc_msgSend(this.id, OS.sel_systemVersion);
+    }
+
+    public static id unarchiveObjectWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSUnarchiver, OS.sel_unarchiveObjectWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id unarchiveObjectWithFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSUnarchiver, OS.sel_unarchiveObjectWithFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSUndoManager.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSUndoManager;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSUndoManager : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void beginUndoGrouping ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginUndoGrouping);
+    }
+
+    public bool canRedo ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canRedo) !is null;
+    }
+
+    public bool canUndo ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canUndo) !is null;
+    }
+
+    public void disableUndoRegistration ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_disableUndoRegistration);
+    }
+
+    public void enableUndoRegistration ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_enableUndoRegistration);
+    }
+
+    public void endUndoGrouping ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_endUndoGrouping);
+    }
+
+    public NSInteger groupingLevel ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_groupingLevel);
+    }
+
+    public bool groupsByEvent ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_groupsByEvent) !is null;
+    }
+
+    public bool isRedoing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRedoing) !is null;
+    }
+
+    public bool isUndoRegistrationEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isUndoRegistrationEnabled) !is null;
+    }
+
+    public bool isUndoing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isUndoing) !is null;
+    }
+
+    public NSUInteger levelsOfUndo ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_levelsOfUndo);
+    }
+
+    public id prepareWithInvocationTarget (id target)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_prepareWithInvocationTarget_1, target !is null ? target.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void redo ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_redo);
+    }
+
+    public NSString redoActionName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_redoActionName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString redoMenuItemTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_redoMenuItemTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString redoMenuTitleForUndoActionName (NSString actionName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_redoMenuTitleForUndoActionName_1, actionName !is null ? actionName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void registerUndoWithTarget (id target, objc.SEL selector, id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerUndoWithTarget_1selector_1object_1, target !is null ? target.id : null, selector,
+                anObject !is null ? anObject.id : null);
+    }
+
+    public void removeAllActions ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllActions);
+    }
+
+    public void removeAllActionsWithTarget (id target)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllActionsWithTarget_1, target !is null ? target.id : null);
+    }
+
+    public NSArray runLoopModes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_runLoopModes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void setActionName (NSString actionName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setActionName_1, actionName !is null ? actionName.id : null);
+    }
+
+    public void setGroupsByEvent (bool groupsByEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setGroupsByEvent_1, groupsByEvent);
+    }
+
+    public void setLevelsOfUndo (NSUInteger levels)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLevelsOfUndo_1, levels);
+    }
+
+    public void setRunLoopModes (NSArray runLoopModes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRunLoopModes_1, runLoopModes !is null ? runLoopModes.id : null);
+    }
+
+    public void undo ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_undo);
+    }
+
+    public NSString undoActionName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_undoActionName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString undoMenuItemTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_undoMenuItemTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString undoMenuTitleForUndoActionName (NSString actionName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_undoMenuTitleForUndoActionName_1, actionName !is null ? actionName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void undoNestedGroup ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_undoNestedGroup);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSUniqueIDSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSUniqueIDSpecifier;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSUniqueIDSpecifier : NSScriptObjectSpecifier
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithContainerClassDescription (NSScriptClassDescription classDesc, NSScriptObjectSpecifier container, NSString property,
+            id uniqueID)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerClassDescription_1containerSpecifier_1key_1uniqueID_1,
+                classDesc !is null ? classDesc.id : null, container !is null ? container.id : null, property !is null ? property.id : null,
+                uniqueID !is null ? uniqueID.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setUniqueID (id uniqueID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUniqueID_1, uniqueID !is null ? uniqueID.id : null);
+    }
+
+    public id uniqueID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_uniqueID);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSUserDefaults.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSUserDefaults;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSUserDefaults : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addSuiteNamed (NSString suiteName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addSuiteNamed_1, suiteName !is null ? suiteName.id : null);
+    }
+
+    public NSArray arrayForKey (NSString defaultName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayForKey_1, defaultName !is null ? defaultName.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public bool boolForKey (NSString defaultName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_boolForKey_1, defaultName !is null ? defaultName.id : null) !is null;
+    }
+
+    public NSData dataForKey (NSString defaultName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataForKey_1, defaultName !is null ? defaultName.id : null);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSDictionary dictionaryForKey (NSString defaultName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dictionaryForKey_1, defaultName !is null ? defaultName.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary dictionaryRepresentation ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dictionaryRepresentation);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public double doubleForKey (NSString defaultName)
+    {
+        return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_doubleForKey_1, defaultName !is null ? defaultName.id : null);
+    }
+
+    public float floatForKey (NSString defaultName)
+    {
+        return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatForKey_1, defaultName !is null ? defaultName.id : null);
+    }
+
+    public id initWithUser (NSString username)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUser_1, username !is null ? username.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger integerForKey (NSString defaultName)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_integerForKey_1, defaultName !is null ? defaultName.id : null);
+    }
+
+    public id objectForKey (NSString defaultName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_1, defaultName !is null ? defaultName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool objectIsForcedForKey_ (NSString key)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_objectIsForcedForKey_1, key !is null ? key.id : null) !is null;
+    }
+
+    public bool objectIsForcedForKey_inDomain_ (NSString key, NSString domain)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_objectIsForcedForKey_1inDomain_1, key !is null ? key.id : null, domain !is null ? domain.id : null) !is null;
+    }
+
+    public NSDictionary persistentDomainForName (NSString domainName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_persistentDomainForName_1, domainName !is null ? domainName.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSArray persistentDomainNames ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_persistentDomainNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void registerDefaults (NSDictionary registrationDictionary)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerDefaults_1, registrationDictionary !is null ? registrationDictionary.id : null);
+    }
+
+    public void removeObjectForKey (NSString defaultName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObjectForKey_1, defaultName !is null ? defaultName.id : null);
+    }
+
+    public void removePersistentDomainForName (NSString domainName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removePersistentDomainForName_1, domainName !is null ? domainName.id : null);
+    }
+
+    public void removeSuiteNamed (NSString suiteName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeSuiteNamed_1, suiteName !is null ? suiteName.id : null);
+    }
+
+    public void removeVolatileDomainForName (NSString domainName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeVolatileDomainForName_1, domainName !is null ? domainName.id : null);
+    }
+
+    public static void resetStandardUserDefaults ()
+    {
+        OS.objc_msgSend(OS.class_NSUserDefaults, OS.sel_resetStandardUserDefaults);
+    }
+
+    public void setBool (bool value, NSString defaultName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBool_1forKey_1, value, defaultName !is null ? defaultName.id : null);
+    }
+
+    public void setDouble (double value, NSString defaultName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDouble_1forKey_1, value, defaultName !is null ? defaultName.id : null);
+    }
+
+    public void setFloat (float value, NSString defaultName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFloat_1forKey_1, value, defaultName !is null ? defaultName.id : null);
+    }
+
+    public void setInteger (NSInteger value, NSString defaultName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInteger_1forKey_1, value, defaultName !is null ? defaultName.id : null);
+    }
+
+    public void setObject (id value, NSString defaultName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObject_1forKey_1, value !is null ? value.id : null, defaultName !is null ? defaultName.id : null);
+    }
+
+    public void setPersistentDomain (NSDictionary domain, NSString domainName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPersistentDomain_1forName_1, domain !is null ? domain.id : null,
+                domainName !is null ? domainName.id : null);
+    }
+
+    public void setVolatileDomain (NSDictionary domain, NSString domainName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVolatileDomain_1forName_1, domain !is null ? domain.id : null, domainName !is null ? domainName.id : null);
+    }
+
+    public static NSUserDefaults standardUserDefaults ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSUserDefaults, OS.sel_standardUserDefaults);
+        return result !is null ? new NSUserDefaults(result) : null;
+    }
+
+    public NSArray stringArrayForKey (NSString defaultName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringArrayForKey_1, defaultName !is null ? defaultName.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString stringForKey (NSString defaultName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringForKey_1, defaultName !is null ? defaultName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool synchronize ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_synchronize) !is null;
+    }
+
+    public NSDictionary volatileDomainForName (NSString domainName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_volatileDomainForName_1, domainName !is null ? domainName.id : null);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSArray volatileDomainNames ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_volatileDomainNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSUserDefaultsController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSUserDefaultsController;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSController;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSUserDefaults;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSUserDefaultsController : NSController
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool appliesImmediately ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_appliesImmediately) !is null;
+    }
+
+    public NSUserDefaults defaults ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaults);
+        return result !is null ? new NSUserDefaults(result) : null;
+    }
+
+    public bool hasUnappliedChanges ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasUnappliedChanges) !is null;
+    }
+
+    public id initWithDefaults (NSUserDefaults defaults, NSDictionary initialValues)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDefaults_1initialValues_1, defaults !is null ? defaults.id : null,
+                initialValues !is null ? initialValues.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSDictionary initialValues ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initialValues);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void revert (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_revert_1, sender !is null ? sender.id : null);
+    }
+
+    public void revertToInitialValues (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_revertToInitialValues_1, sender !is null ? sender.id : null);
+    }
+
+    public void save (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_save_1, sender !is null ? sender.id : null);
+    }
+
+    public void setAppliesImmediately (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAppliesImmediately_1, flag);
+    }
+
+    public void setInitialValues (NSDictionary initialValues)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInitialValues_1, initialValues !is null ? initialValues.id : null);
+    }
+
+    public static id sharedUserDefaultsController ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSUserDefaultsController, OS.sel_sharedUserDefaultsController);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id values ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_values);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSValue.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSValue;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSValue : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void getValue (void* value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getValue_1, value);
+    }
+
+    public id initWithBytes (/*const*/void* value, /*const char* */byte* type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytes_1objCType_1, value, type);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isEqualToValue (NSValue value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToValue_1, value !is null ? value.id : null) !is null;
+    }
+
+    public id nonretainedObjectValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nonretainedObjectValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public /*const char* */byte* objCType ()
+    {
+        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_objCType);
+    }
+
+    public NSPoint pointValue ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_pointValue);
+        return result;
+    }
+
+    public void* pointerValue ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_pointerValue);
+    }
+
+    public NSRange rangeValue ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeValue);
+        return result;
+    }
+
+    public NSRect rectValue ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectValue);
+        return result;
+    }
+
+    public NSSize sizeValue ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_sizeValue);
+        return result;
+    }
+
+    public static NSValue value (/*const*/void* value, /*const char* */byte* type)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_value_1withObjCType_1, value, type);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithBytes (/*const*/void* value, /*const char* */byte* type)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithBytes_1objCType_1, value, type);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithNonretainedObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithNonretainedObject_1, anObject !is null ? anObject.id : null);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithPoint (NSPoint point)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithPoint_1, point);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithPointer (/*const*/void* pointer)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithPointer_1, pointer);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRange_1, range);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRect_1, rect);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithSize (NSSize size)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithSize_1, size);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSValueTransformer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSValueTransformer;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSValueTransformer : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static bool allowsReverseTransformation ()
+    {
+        return OS.objc_msgSend(OS.class_NSValueTransformer, OS.sel_allowsReverseTransformation) !is null;
+    }
+
+    public id reverseTransformedValue (id value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_reverseTransformedValue_1, value !is null ? value.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static void setValueTransformer (NSValueTransformer transformer, NSString name)
+    {
+        OS.objc_msgSend(OS.class_NSValueTransformer, OS.sel_setValueTransformer_1forName_1, transformer !is null ? transformer.id : null,
+                name !is null ? name.id : null);
+    }
+
+    public id transformedValue (id value)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_transformedValue_1, value !is null ? value.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static objc.Class transformedValueClass ()
+    {
+        return cast(objc.Class) OS.objc_msgSend(OS.class_NSValueTransformer, OS.sel_transformedValueClass);
+    }
+
+    public static NSValueTransformer valueTransformerForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValueTransformer, OS.sel_valueTransformerForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSValueTransformer(result) : null;
+    }
+
+    public static NSArray valueTransformerNames ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValueTransformer, OS.sel_valueTransformerNames);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1195 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSView;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSBitmapImageRep;
+import dwt.internal.cocoa.NSClipView;
+import dwt.internal.cocoa.NSComparisonResult;
+import dwt.internal.cocoa.NSCursor;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSFocusRingType;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange : NSRangePointer;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSResponder;
+import dwt.internal.cocoa.NSRulerMarker;
+import dwt.internal.cocoa.NSRulerView;
+import dwt.internal.cocoa.NSScreen;
+import dwt.internal.cocoa.NSScrollView;
+import dwt.internal.cocoa.NSShadow;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTrackingArea;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias NSInteger NSToolTipTag;
+alias NSInteger NSTrackingRectTag;
+
+
+
+enum NSBorderType
+{
+    NSNoBorder = 0,
+    NSLineBorder = 1,
+    NSBezelBorder = 2,
+    NSGrooveBorder = 3
+}
+
+alias NSBorderType.NSNoBorder NSNoBorder;
+alias NSBorderType.NSLineBorder NSLineBorder;
+alias NSBorderType.NSBezelBorder NSBezelBorder;
+alias NSBorderType.NSGrooveBorder NSGrooveBorder;
+
+
+
+public class NSView : NSResponder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsFirstMouse (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsFirstMouse_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public void addCursorRect (NSRect aRect, NSCursor anObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addCursorRect_1cursor_1, aRect, anObj !is null ? anObj.id : null);
+    }
+
+    public void addSubview_ (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addSubview_1, aView !is null ? aView.id : null);
+    }
+
+    public void addSubview_positioned_relativeTo_ (NSView aView, NSWindowOrderingMode place, NSView otherView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addSubview_1positioned_1relativeTo_1, aView !is null ? aView.id : null, place,
+                otherView !is null ? otherView.id : null);
+    }
+
+    public NSToolTipTag addToolTipRect (NSRect aRect, id anObject, void* data)
+    {
+        return cast(NSToolTipTag) OS.objc_msgSend(this.id, OS.sel_addToolTipRect_1owner_1userData_1, aRect, anObject !is null ? anObject.id : null, data);
+    }
+
+    public void addTrackingArea (NSTrackingArea trackingArea)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addTrackingArea_1, trackingArea !is null ? trackingArea.id : null);
+    }
+
+    public NSTrackingRectTag addTrackingRect (NSRect aRect, id anObject, void* data, bool flag)
+    {
+        return cast(NSTrackingRectTag) OS.objc_msgSend(this.id, OS.sel_addTrackingRect_1owner_1userData_1assumeInside_1, aRect, anObject !is null ? anObject.id : null, data,
+                flag);
+    }
+
+    public void adjustPageHeightNew (CGFloat* newBottom, CGFloat oldTop, CGFloat oldBottom, CGFloat bottomLimit)
+    {
+        OS.objc_msgSend(this.id, OS.sel_adjustPageHeightNew_1top_1bottom_1limit_1, newBottom, oldTop, oldBottom, bottomLimit);
+    }
+
+    public void adjustPageWidthNew (CGFloat* newRight, CGFloat oldLeft, CGFloat oldRight, CGFloat rightLimit)
+    {
+        OS.objc_msgSend(this.id, OS.sel_adjustPageWidthNew_1left_1right_1limit_1, newRight, oldLeft, oldRight, rightLimit);
+    }
+
+    public NSRect adjustScroll (NSRect newVisible)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_adjustScroll_1, newVisible);
+        return result;
+    }
+
+    public void allocateGState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_allocateGState);
+    }
+
+    public CGFloat alphaValue ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_alphaValue);
+    }
+
+    public NSView ancestorSharedWithView (NSView aView)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_ancestorSharedWithView_1, aView !is null ? aView.id : null);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public bool autoresizesSubviews ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoresizesSubviews) !is null;
+    }
+
+    public NSUInteger autoresizingMask ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_autoresizingMask);
+    }
+
+    public bool autoscroll (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autoscroll_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public NSArray backgroundFilters ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundFilters);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void beginDocument ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginDocument);
+    }
+
+    public void beginPageInRect (NSRect aRect, NSPoint location)
+    {
+        OS.objc_msgSend(this.id, OS.sel_beginPageInRect_1atPlacement_1, aRect, location);
+    }
+
+    public NSBitmapImageRep bitmapImageRepForCachingDisplayInRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_bitmapImageRepForCachingDisplayInRect_1, rect);
+        return result !is null ? new NSBitmapImageRep(result) : null;
+    }
+
+    public NSRect bounds ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_bounds);
+        return result;
+    }
+
+    public CGFloat boundsRotation ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_boundsRotation);
+    }
+
+    public void cacheDisplayInRect (NSRect rect, NSBitmapImageRep bitmapImageRep)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cacheDisplayInRect_1toBitmapImageRep_1, rect, bitmapImageRep !is null ? bitmapImageRep.id : null);
+    }
+
+    public bool canBecomeKeyView ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canBecomeKeyView) !is null;
+    }
+
+    public bool canDraw ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canDraw) !is null;
+    }
+
+    public NSRect centerScanRect (NSRect aRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_centerScanRect_1, aRect);
+        return result;
+    }
+
+    //public CIFilter compositingFilter() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_compositingFilter);
+    //  return result !is null ? new CIFilter(result) : null;
+    //}
+
+    public NSArray contentFilters ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentFilters);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSPoint convertPoint_fromView_ (NSPoint aPoint, NSView aView)
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_convertPoint_1fromView_1, aPoint, aView !is null ? aView.id : null);
+        return result;
+    }
+
+    public NSPoint convertPoint_toView_ (NSPoint aPoint, NSView aView)
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_convertPoint_1toView_1, aPoint, aView !is null ? aView.id : null);
+        return result;
+    }
+
+    public NSPoint convertPointFromBase (NSPoint aPoint)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertPointFromBase_1, aPoint);
+        return result;
+    }
+
+    public NSPoint convertPointToBase (NSPoint aPoint)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertPointToBase_1, aPoint);
+        return result;
+    }
+
+    public NSRect convertRect_fromView_ (NSRect aRect, NSView aView)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertRect_1fromView_1, aRect, aView !is null ? aView.id : null);
+        return result;
+    }
+
+    public NSRect convertRect_toView_ (NSRect aRect, NSView aView)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertRect_1toView_1, aRect, aView !is null ? aView.id : null);
+        return result;
+    }
+
+    public NSRect convertRectFromBase (NSRect aRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertRectFromBase_1, aRect);
+        return result;
+    }
+
+    public NSRect convertRectToBase (NSRect aRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertRectToBase_1, aRect);
+        return result;
+    }
+
+    public NSSize convertSize_fromView_ (NSSize aSize, NSView aView)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertSize_1fromView_1, aSize, aView !is null ? aView.id : null);
+        return result;
+    }
+
+    public NSSize convertSize_toView_ (NSSize aSize, NSView aView)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertSize_1toView_1, aSize, aView !is null ? aView.id : null);
+        return result;
+    }
+
+    public NSSize convertSizeFromBase (NSSize aSize)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertSizeFromBase_1, aSize);
+        return result;
+    }
+
+    public NSSize convertSizeToBase (NSSize aSize)
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_convertSizeToBase_1, aSize);
+        return result;
+    }
+
+    public NSData dataWithEPSInsideRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataWithEPSInsideRect_1, rect);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData dataWithPDFInsideRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataWithPDFInsideRect_1, rect);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public static NSFocusRingType defaultFocusRingType ()
+    {
+        return cast(NSFocusRingType) OS.objc_msgSend(OS.class_NSView, OS.sel_defaultFocusRingType);
+    }
+
+    public static NSMenu defaultMenu ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSView, OS.sel_defaultMenu);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public void didAddSubview (NSView subview)
+    {
+        OS.objc_msgSend(this.id, OS.sel_didAddSubview_1, subview !is null ? subview.id : null);
+    }
+
+    public void discardCursorRects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_discardCursorRects);
+    }
+
+    public void display ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_display);
+    }
+
+    public void displayIfNeeded ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayIfNeeded);
+    }
+
+    public void displayIfNeededIgnoringOpacity ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayIfNeededIgnoringOpacity);
+    }
+
+    public void displayIfNeededInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayIfNeededInRect_1, rect);
+    }
+
+    public void displayIfNeededInRectIgnoringOpacity (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayIfNeededInRectIgnoringOpacity_1, rect);
+    }
+
+    public void displayRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayRect_1, rect);
+    }
+
+    public void displayRectIgnoringOpacity_ (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayRectIgnoringOpacity_1, rect);
+    }
+
+    public void displayRectIgnoringOpacity_inContext_ (NSRect aRect, NSGraphicsContext context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayRectIgnoringOpacity_1inContext_1, aRect, context !is null ? context.id : null);
+    }
+
+    public bool dragFile (NSString filename, NSRect rect, bool aFlag, NSEvent event)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dragFile_1fromRect_1slideBack_1event_1, filename !is null ? filename.id : null, rect, aFlag,
+                event !is null ? event.id : null) !is null;
+    }
+
+    public void dragImage (NSImage anImage, NSPoint viewLocation, NSSize initialOffset, NSEvent event, NSPasteboard pboard, id sourceObj,
+            bool slideFlag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_dragImage_1at_1offset_1event_1pasteboard_1source_1slideBack_1, anImage !is null ? anImage.id : null,
+                viewLocation, initialOffset, event !is null ? event.id : null, pboard !is null ? pboard.id : null,
+                sourceObj !is null ? sourceObj.id : null, slideFlag);
+    }
+
+    public bool dragPromisedFilesOfTypes (NSArray typeArray, NSRect rect, id sourceObject, bool aFlag, NSEvent event)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_dragPromisedFilesOfTypes_1fromRect_1source_1slideBack_1event_1,
+                typeArray !is null ? typeArray.id : null, rect, sourceObject !is null ? sourceObject.id : null, aFlag,
+                event !is null ? event.id : null) !is null;
+    }
+
+    public void drawPageBorderWithSize (NSSize borderSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawPageBorderWithSize_1, borderSize);
+    }
+
+    public void drawRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawRect_1, rect);
+    }
+
+    public void drawSheetBorderWithSize (NSSize borderSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_drawSheetBorderWithSize_1, borderSize);
+    }
+
+    public NSMenuItem enclosingMenuItem ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_enclosingMenuItem);
+        return result !is null ? new NSMenuItem(result) : null;
+    }
+
+    public NSScrollView enclosingScrollView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_enclosingScrollView);
+        return result !is null ? new NSScrollView(result) : null;
+    }
+
+    public void endDocument ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_endDocument);
+    }
+
+    public void endPage ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_endPage);
+    }
+
+    public bool enterFullScreenMode (NSScreen screen, NSDictionary options)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_enterFullScreenMode_1withOptions_1, screen !is null ? screen.id : null,
+                options !is null ? options.id : null) !is null;
+    }
+
+    public void exitFullScreenModeWithOptions (NSDictionary options)
+    {
+        OS.objc_msgSend(this.id, OS.sel_exitFullScreenModeWithOptions_1, options !is null ? options.id : null);
+    }
+
+    public NSFocusRingType focusRingType ()
+    {
+        return cast(NSFocusRingType) OS.objc_msgSend(this.id, OS.sel_focusRingType);
+    }
+
+    public static NSView focusView ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSView, OS.sel_focusView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSRect frame ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frame);
+        return result;
+    }
+
+    public CGFloat frameCenterRotation ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_frameCenterRotation);
+    }
+
+    public CGFloat frameRotation ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_frameRotation);
+    }
+
+    public NSInteger gState ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_gState);
+    }
+
+    public void getRectsBeingDrawn (/*const NSRect** */objc.id** rects, NSInteger* count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getRectsBeingDrawn_1count_1, rects, count);
+    }
+
+    public void getRectsExposedDuringLiveResize (/*NSRect[4]*/NSRect* exposedRects, NSInteger* count)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getRectsExposedDuringLiveResize_1count_1, exposedRects, count);
+    }
+
+    public CGFloat heightAdjustLimit ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_heightAdjustLimit);
+    }
+
+    public NSView hitTest (NSPoint aPoint)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_hitTest_1, aPoint);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public bool inLiveResize ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_inLiveResize) !is null;
+    }
+
+    public NSView initWithFrame (NSRect frameRect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1, frameRect);
+        return result !is null ? this : null;
+    }
+
+    public bool isDescendantOf (NSView aView)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDescendantOf_1, aView !is null ? aView.id : null) !is null;
+    }
+
+    public bool isFlipped ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
+    }
+
+    public bool isHidden ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHidden) !is null;
+    }
+
+    public bool isHiddenOrHasHiddenAncestor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isHiddenOrHasHiddenAncestor) !is null;
+    }
+
+    public bool isInFullScreenMode ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isInFullScreenMode) !is null;
+    }
+
+    public bool isOpaque ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOpaque) !is null;
+    }
+
+    public bool isRotatedFromBase ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRotatedFromBase) !is null;
+    }
+
+    public bool isRotatedOrScaledFromBase ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isRotatedOrScaledFromBase) !is null;
+    }
+
+    public bool knowsPageRange (NSRangePointer range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_knowsPageRange_1, range) !is null;
+    }
+
+    //public CALayer layer() {
+    //  objc.id result = OS.objc_msgSend(this.id, OS.sel_layer);
+    //  return result !is null ? new CALayer(result) : null;
+    //}
+
+    public NSPoint locationOfPrintRect (NSRect aRect)
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_locationOfPrintRect_1, aRect);
+        return result;
+    }
+
+    public void lockFocus ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_lockFocus);
+    }
+
+    public bool lockFocusIfCanDraw ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lockFocusIfCanDraw) !is null;
+    }
+
+    public bool lockFocusIfCanDrawInContext (NSGraphicsContext context)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_lockFocusIfCanDrawInContext_1, context !is null ? context.id : null) !is null;
+    }
+
+    public NSMenu menuForEvent (NSEvent event)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_menuForEvent_1, event !is null ? event.id : null);
+        return result !is null ? new NSMenu(result) : null;
+    }
+
+    public bool mouse (NSPoint aPoint, NSRect aRect)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mouse_1inRect_1, aPoint, aRect) !is null;
+    }
+
+    public bool mouseDownCanMoveWindow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_mouseDownCanMoveWindow) !is null;
+    }
+
+    public bool needsDisplay ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_needsDisplay) !is null;
+    }
+
+    public bool needsPanelToBecomeKey ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_needsPanelToBecomeKey) !is null;
+    }
+
+    public bool needsToDrawRect (NSRect aRect)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_needsToDrawRect_1, aRect) !is null;
+    }
+
+    public NSView nextKeyView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextKeyView);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public NSView nextValidKeyView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextValidKeyView);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public NSView opaqueAncestor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_opaqueAncestor);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public NSAttributedString pageFooter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pageFooter);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public NSAttributedString pageHeader ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pageHeader);
+        return result !is null ? new NSAttributedString(result) : null;
+    }
+
+    public bool performKeyEquivalent (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performKeyEquivalent_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public bool performMnemonic (NSString theString)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performMnemonic_1, theString !is null ? theString.id : null) !is null;
+    }
+
+    public bool postsBoundsChangedNotifications ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_postsBoundsChangedNotifications) !is null;
+    }
+
+    public bool postsFrameChangedNotifications ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_postsFrameChangedNotifications) !is null;
+    }
+
+    public bool preservesContentDuringLiveResize ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preservesContentDuringLiveResize) !is null;
+    }
+
+    public NSView previousKeyView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_previousKeyView);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public NSView previousValidKeyView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_previousValidKeyView);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public void print (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_print_1, sender !is null ? sender.id : null);
+    }
+
+    public NSString printJobTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_printJobTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSRect rectForPage (NSInteger page)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectForPage_1, page);
+        return result;
+    }
+
+    public NSRect rectPreservedDuringLiveResize ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectPreservedDuringLiveResize);
+        return result;
+    }
+
+    public void reflectScrolledClipView (NSClipView aClipView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_reflectScrolledClipView_1, aClipView !is null ? aClipView.id : null);
+    }
+
+    public void registerForDraggedTypes (NSArray newTypes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerForDraggedTypes_1, newTypes !is null ? newTypes.id : null);
+    }
+
+    public NSArray registeredDraggedTypes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_registeredDraggedTypes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void releaseGState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_releaseGState);
+    }
+
+    public void removeAllToolTips ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAllToolTips);
+    }
+
+    public void removeCursorRect (NSRect aRect, NSCursor anObj)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeCursorRect_1cursor_1, aRect, anObj !is null ? anObj.id : null);
+    }
+
+    public void removeFromSuperview ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFromSuperview);
+    }
+
+    public void removeFromSuperviewWithoutNeedingDisplay ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeFromSuperviewWithoutNeedingDisplay);
+    }
+
+    public void removeToolTip (NSToolTipTag tag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeToolTip_1, tag);
+    }
+
+    public void removeTrackingArea (NSTrackingArea trackingArea)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeTrackingArea_1, trackingArea !is null ? trackingArea.id : null);
+    }
+
+    public void removeTrackingRect (NSTrackingRectTag tag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeTrackingRect_1, tag);
+    }
+
+    public void renewGState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_renewGState);
+    }
+
+    public void replaceSubview (NSView oldView, NSView newView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceSubview_1with_1, oldView !is null ? oldView.id : null, newView !is null ? newView.id : null);
+    }
+
+    public void resetCursorRects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resetCursorRects);
+    }
+
+    public void resizeSubviewsWithOldSize (NSSize oldSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resizeSubviewsWithOldSize_1, oldSize);
+    }
+
+    public void resizeWithOldSuperviewSize (NSSize oldSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_resizeWithOldSuperviewSize_1, oldSize);
+    }
+
+    public void rotateByAngle (CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rotateByAngle_1, angle);
+    }
+
+    public void rulerView_didAddMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1didAddMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null);
+    }
+
+    public void rulerView_didMoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1didMoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null);
+    }
+
+    public void rulerView_didRemoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1didRemoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null);
+    }
+
+    public void rulerView_handleMouseDown_ (NSRulerView ruler, NSEvent event)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1handleMouseDown_1, ruler !is null ? ruler.id : null, event !is null ? event.id : null);
+    }
+
+    public bool rulerView_shouldAddMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rulerView_1shouldAddMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null) !is null;
+    }
+
+    public bool rulerView_shouldMoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rulerView_1shouldMoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null) !is null;
+    }
+
+    public bool rulerView_shouldRemoveMarker_ (NSRulerView ruler, NSRulerMarker marker)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_rulerView_1shouldRemoveMarker_1, ruler !is null ? ruler.id : null, marker !is null ? marker.id : null) !is null;
+    }
+
+    public CGFloat rulerView_willAddMarker_atLocation_ (NSRulerView ruler, NSRulerMarker marker, CGFloat location)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_rulerView_1willAddMarker_1atLocation_1, ruler !is null ? ruler.id : null,
+                marker !is null ? marker.id : null, location);
+    }
+
+    public CGFloat rulerView_willMoveMarker_toLocation_ (NSRulerView ruler, NSRulerMarker marker, CGFloat location)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_rulerView_1willMoveMarker_1toLocation_1, ruler !is null ? ruler.id : null,
+                marker !is null ? marker.id : null, location);
+    }
+
+    public void rulerView_willSetClientView_ (NSRulerView ruler, NSView newClient)
+    {
+        OS.objc_msgSend(this.id, OS.sel_rulerView_1willSetClientView_1, ruler !is null ? ruler.id : null, newClient !is null ? newClient.id : null);
+    }
+
+    public void scaleUnitSquareToSize (NSSize newUnitSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scaleUnitSquareToSize_1, newUnitSize);
+    }
+
+    public void scrollClipView (NSClipView aClipView, NSPoint aPoint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollClipView_1toPoint_1, aClipView !is null ? aClipView.id : null, aPoint);
+    }
+
+    public void scrollPoint (NSPoint aPoint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollPoint_1, aPoint);
+    }
+
+    public void scrollRect (NSRect aRect, NSSize delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_scrollRect_1by_1, aRect, delta);
+    }
+
+    public bool scrollRectToVisible (NSRect aRect)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_scrollRectToVisible_1, aRect) !is null;
+    }
+
+    public void setAlphaValue (CGFloat viewAlpha)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlphaValue_1, viewAlpha);
+    }
+
+    public void setAutoresizesSubviews (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoresizesSubviews_1, flag);
+    }
+
+    public void setAutoresizingMask (NSUInteger mask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutoresizingMask_1, mask);
+    }
+
+    public void setBackgroundFilters (NSArray filters)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundFilters_1, filters !is null ? filters.id : null);
+    }
+
+    public void setBounds (NSRect aRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBounds_1, aRect);
+    }
+
+    public void setBoundsOrigin (NSPoint newOrigin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBoundsOrigin_1, newOrigin);
+    }
+
+    public void setBoundsRotation (CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBoundsRotation_1, angle);
+    }
+
+    public void setBoundsSize (NSSize newSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBoundsSize_1, newSize);
+    }
+
+    //public void setCompositingFilter(CIFilter filter) {
+    //  OS.objc_msgSend(this.id, OS.sel_setCompositingFilter_1, filter !is null ? filter.id : null);
+    //}
+
+    public void setContentFilters (NSArray filters)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentFilters_1, filters !is null ? filters.id : null);
+    }
+
+    public void setFocusRingType (NSFocusRingType focusRingType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFocusRingType_1, focusRingType);
+    }
+
+    public void setFrame (NSRect frameRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrame_1, frameRect);
+    }
+
+    public void setFrameCenterRotation (CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameCenterRotation_1, angle);
+    }
+
+    public void setFrameOrigin (NSPoint newOrigin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameOrigin_1, newOrigin);
+    }
+
+    public void setFrameRotation (CGFloat angle)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameRotation_1, angle);
+    }
+
+    public void setFrameSize (NSSize newSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameSize_1, newSize);
+    }
+
+    public void setHidden (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHidden_1, flag);
+    }
+
+    public void setKeyboardFocusRingNeedsDisplayInRect (NSRect rect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setKeyboardFocusRingNeedsDisplayInRect_1, rect);
+    }
+
+    //public void setLayer(CALayer newLayer) {
+    //  OS.objc_msgSend(this.id, OS.sel_setLayer_1, newLayer !is null ? newLayer.id : null);
+    //}
+
+    public void setNeedsDisplay (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsDisplay_1, flag);
+    }
+
+    public void setNeedsDisplayInRect (NSRect invalidRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNeedsDisplayInRect_1, invalidRect);
+    }
+
+    public void setNextKeyView (NSView next)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNextKeyView_1, next !is null ? next.id : null);
+    }
+
+    public void setPostsBoundsChangedNotifications (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPostsBoundsChangedNotifications_1, flag);
+    }
+
+    public void setPostsFrameChangedNotifications (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPostsFrameChangedNotifications_1, flag);
+    }
+
+    public void setShadow (NSShadow shadow)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShadow_1, shadow !is null ? shadow.id : null);
+    }
+
+    public void setSubviews (NSArray newSubviews)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSubviews_1, newSubviews !is null ? newSubviews.id : null);
+    }
+
+    public void setToolTip (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setToolTip_1, string !is null ? string.id : null);
+    }
+
+    public void setUpGState ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setUpGState);
+    }
+
+    public void setWantsLayer (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWantsLayer_1, flag);
+    }
+
+    public NSShadow shadow ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_shadow);
+        return result !is null ? new NSShadow(result) : null;
+    }
+
+    public bool shouldDelayWindowOrderingForEvent (NSEvent theEvent)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldDelayWindowOrderingForEvent_1, theEvent !is null ? theEvent.id : null) !is null;
+    }
+
+    public bool shouldDrawColor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldDrawColor) !is null;
+    }
+
+    public void sortSubviewsUsingFunction (/*NSComparisonResult (*)(id, id, void *) */NSComparisonResult function(objc.id, objc.id, void*) compare, void* context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sortSubviewsUsingFunction_1context_1, compare, context);
+    }
+
+    public NSArray subviews ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subviews);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSView superview ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_superview);
+        return result is this.id ? this : (result !is null ? new NSView(result) : null);
+    }
+
+    public NSInteger tag ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_tag);
+    }
+
+    public NSString toolTip ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolTip);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray trackingAreas ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_trackingAreas);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void translateOriginToPoint (NSPoint translation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_translateOriginToPoint_1, translation);
+    }
+
+    public void translateRectsNeedingDisplayInRect (NSRect clipRect, NSSize delta)
+    {
+        OS.objc_msgSend(this.id, OS.sel_translateRectsNeedingDisplayInRect_1by_1, clipRect, delta);
+    }
+
+    public void unlockFocus ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_unlockFocus);
+    }
+
+    public void unregisterDraggedTypes ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_unregisterDraggedTypes);
+    }
+
+    public void updateTrackingAreas ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_updateTrackingAreas);
+    }
+
+    public void viewDidEndLiveResize ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewDidEndLiveResize);
+    }
+
+    public void viewDidHide ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewDidHide);
+    }
+
+    public void viewDidMoveToSuperview ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewDidMoveToSuperview);
+    }
+
+    public void viewDidMoveToWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewDidMoveToWindow);
+    }
+
+    public void viewDidUnhide ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewDidUnhide);
+    }
+
+    public void viewWillDraw ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewWillDraw);
+    }
+
+    public void viewWillMoveToSuperview (NSView newSuperview)
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewWillMoveToSuperview_1, newSuperview !is null ? newSuperview.id : null);
+    }
+
+    public void viewWillMoveToWindow (NSWindow newWindow)
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewWillMoveToWindow_1, newWindow !is null ? newWindow.id : null);
+    }
+
+    public void viewWillStartLiveResize ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_viewWillStartLiveResize);
+    }
+
+    public id viewWithTag (NSInteger aTag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_viewWithTag_1, aTag);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSRect visibleRect ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_visibleRect);
+        return result;
+    }
+
+    public bool wantsDefaultClipping ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_wantsDefaultClipping) !is null;
+    }
+
+    public bool wantsLayer ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_wantsLayer) !is null;
+    }
+
+    public CGFloat widthAdjustLimit ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_widthAdjustLimit);
+    }
+
+    public void willRemoveSubview (NSView subview)
+    {
+        OS.objc_msgSend(this.id, OS.sel_willRemoveSubview_1, subview !is null ? subview.id : null);
+    }
+
+    public NSWindow window ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_window);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public void writeEPSInsideRect (NSRect rect, NSPasteboard pasteboard)
+    {
+        OS.objc_msgSend(this.id, OS.sel_writeEPSInsideRect_1toPasteboard_1, rect, pasteboard !is null ? pasteboard.id : null);
+    }
+
+    public void writePDFInsideRect (NSRect rect, NSPasteboard pasteboard)
+    {
+        OS.objc_msgSend(this.id, OS.sel_writePDFInsideRect_1toPasteboard_1, rect, pasteboard !is null ? pasteboard.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSViewAnimation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSViewAnimation;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSAnimation;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSViewAnimation : NSAnimation
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public id initWithViewAnimations (NSArray viewAnimations)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithViewAnimations_1, viewAnimations !is null ? viewAnimations.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setViewAnimations (NSArray viewAnimations)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setViewAnimations_1, viewAnimations !is null ? viewAnimations.id : null);
+    }
+
+    public NSArray viewAnimations ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_viewAnimations);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSViewController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSViewController;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSBundle;
+import dwt.internal.cocoa.NSResponder;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSViewController : NSResponder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool commitEditing ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_commitEditing) !is null;
+    }
+
+    public void commitEditingWithDelegate (id delegatee, objc.SEL didCommitSelector, void* contextInfo)
+    {
+        OS.objc_msgSend(this.id, OS.sel_commitEditingWithDelegate_1didCommitSelector_1contextInfo_1, delegatee !is null ? delegatee.id : null,
+                didCommitSelector, contextInfo);
+    }
+
+    public void discardEditing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_discardEditing);
+    }
+
+    public id initWithNibName (NSString nibNameOrNil, NSBundle nibBundleOrNil)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithNibName_1bundle_1, nibNameOrNil !is null ? nibNameOrNil.id : null,
+                nibBundleOrNil !is null ? nibBundleOrNil.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void loadView ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_loadView);
+    }
+
+    public NSBundle nibBundle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nibBundle);
+        return result !is null ? new NSBundle(result) : null;
+    }
+
+    public NSString nibName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nibName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public id representedObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setRepresentedObject (id representedObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRepresentedObject_1, representedObject !is null ? representedObject.id : null);
+    }
+
+    public void setTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, title !is null ? title.id : null);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSWhoseSpecifier.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSWhoseSpecifier;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSScriptClassDescription;
+import dwt.internal.cocoa.NSScriptObjectSpecifier;
+import dwt.internal.cocoa.NSScriptWhoseTest;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSWhoseSubelementIdentifier
+{
+    NSIndexSubelement = 0,
+    NSEverySubelement = 1,
+    NSMiddleSubelement = 2,
+    NSRandomSubelement = 3,
+    NSNoSubelement = 4
+}
+
+alias NSWhoseSubelementIdentifier.NSIndexSubelement NSIndexSubelement;
+alias NSWhoseSubelementIdentifier.NSEverySubelement NSEverySubelement;
+alias NSWhoseSubelementIdentifier.NSMiddleSubelement NSMiddleSubelement;
+alias NSWhoseSubelementIdentifier.NSRandomSubelement NSRandomSubelement;
+alias NSWhoseSubelementIdentifier.NSNoSubelement NSNoSubelement;
+
+
+
+public class NSWhoseSpecifier : NSScriptObjectSpecifier
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSWhoseSubelementIdentifier endSubelementIdentifier ()
+    {
+        return cast(NSWhoseSubelementIdentifier) OS.objc_msgSend(this.id, OS.sel_endSubelementIdentifier);
+    }
+
+    public NSInteger endSubelementIndex ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_endSubelementIndex);
+    }
+
+    public id initWithContainerClassDescription (NSScriptClassDescription classDesc, NSScriptObjectSpecifier container, NSString property,
+            NSScriptWhoseTest test)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContainerClassDescription_1containerSpecifier_1key_1test_1,
+                classDesc !is null ? classDesc.id : null, container !is null ? container.id : null, property !is null ? property.id : null,
+                test !is null ? test.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setEndSubelementIdentifier (NSWhoseSubelementIdentifier subelement)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEndSubelementIdentifier_1, subelement);
+    }
+
+    public void setEndSubelementIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setEndSubelementIndex_1, index);
+    }
+
+    public void setStartSubelementIdentifier (NSWhoseSubelementIdentifier subelement)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStartSubelementIdentifier_1, subelement);
+    }
+
+    public void setStartSubelementIndex (NSInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStartSubelementIndex_1, index);
+    }
+
+    public void setTest (NSScriptWhoseTest test)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTest_1, test !is null ? test.id : null);
+    }
+
+    public NSWhoseSubelementIdentifier startSubelementIdentifier ()
+    {
+        return cast(NSWhoseSubelementIdentifier) OS.objc_msgSend(this.id, OS.sel_startSubelementIdentifier);
+    }
+
+    public NSInteger startSubelementIndex ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_startSubelementIndex);
+    }
+
+    public NSScriptWhoseTest test ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_test);
+        return result !is null ? new NSScriptWhoseTest(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSWindow.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1467 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSWindow;
+
+import dwt.internal.cocoa.CGFloat;
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSButton;
+import dwt.internal.cocoa.NSButtonCell;
+import dwt.internal.cocoa.NSCloseCommand;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSDockTile;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSPasteboard;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSResponder;
+import dwt.internal.cocoa.NSScreen;
+import dwt.internal.cocoa.NSScriptCommand;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.NSToolbar;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindowController;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+alias int NSWindowDepth;
+
+enum NSWindowOrderingMode
+{
+    NSWindowAbove = 1,
+    NSWindowBelow = -1,
+    NSWindowOut = 0
+}
+
+alias NSWindowOrderingMode.NSWindowAbove NSWindowAbove;
+alias NSWindowOrderingMode.NSWindowBelow NSWindowBelow;
+alias NSWindowOrderingMode.NSWindowOut NSWindowOut;
+
+enum NSWindowBackingLocation : NSUInteger
+{
+    NSWindowBackingLocationDefault = 0,
+    NSWindowBackingLocationVideoMemory = 1,
+    NSWindowBackingLocationMainMemory = 2
+}
+
+alias NSWindowBackingLocation.NSWindowBackingLocationDefault NSWindowBackingLocationDefault;
+alias NSWindowBackingLocation.NSWindowBackingLocationVideoMemory NSWindowBackingLocationVideoMemory;
+alias NSWindowBackingLocation.NSWindowBackingLocationMainMemory NSWindowBackingLocationMainMemory;
+
+enum NSBackingStoreType
+{
+    NSBackingStoreRetained = 0,
+    NSBackingStoreNonretained = 1,
+    NSBackingStoreBuffered = 2
+}
+
+alias NSBackingStoreType.NSBackingStoreRetained NSBackingStoreRetained;
+alias NSBackingStoreType.NSBackingStoreNonretained NSBackingStoreNonretained;
+alias NSBackingStoreType.NSBackingStoreBuffered NSBackingStoreBuffered;
+
+enum NSWindowCollectionBehavior : NSUInteger
+{
+    NSWindowCollectionBehaviorDefault = 0,
+    NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0,
+    NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1
+}
+
+alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorDefault NSWindowCollectionBehaviorDefault;
+alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorCanJoinAllSpaces NSWindowCollectionBehaviorCanJoinAllSpaces;
+alias NSWindowCollectionBehavior.NSWindowCollectionBehaviorMoveToActiveSpace NSWindowCollectionBehaviorMoveToActiveSpace;
+
+enum NSSelectionDirection
+{
+    NSDirectSelection = 0,
+    NSSelectingNext,
+    NSSelectingPrevious
+}
+
+alias NSSelectionDirection.NSDirectSelection NSDirectSelection;
+alias NSSelectionDirection.NSSelectingNext NSSelectingNext;
+alias NSSelectionDirection.NSSelectingPrevious NSSelectingPrevious;
+
+enum NSWindowSharingType : NSUInteger
+{
+    NSWindowSharingNone = 0,
+    NSWindowSharingReadOnly = 1,
+    NSWindowSharingReadWrite = 2
+}
+
+alias NSWindowSharingType.NSWindowSharingNone NSWindowSharingNone;
+alias NSWindowSharingType.NSWindowSharingReadOnly NSWindowSharingReadOnly;
+alias NSWindowSharingType.NSWindowSharingReadWrite NSWindowSharingReadWrite;
+
+enum NSWindowButton
+{
+    NSWindowCloseButton,
+    NSWindowMiniaturizeButton,
+    NSWindowZoomButton,
+    NSWindowToolbarButton,
+    NSWindowDocumentIconButton
+}
+
+alias NSWindowButton.NSWindowCloseButton NSWindowCloseButton;
+alias NSWindowButton.NSWindowMiniaturizeButton NSWindowMiniaturizeButton;
+alias NSWindowButton.NSWindowZoomButton NSWindowZoomButton;
+alias NSWindowButton.NSWindowToolbarButton NSWindowToolbarButton;
+alias NSWindowButton.NSWindowDocumentIconButton NSWindowDocumentIconButton;
+
+public class NSWindow : NSResponder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public bool acceptsMouseMovedEvents ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_acceptsMouseMovedEvents) !is null;
+    }
+
+    public void addChildWindow (NSWindow childWin, NSWindowOrderingMode place)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addChildWindow_1ordered_1, childWin !is null ? childWin.id : null, place);
+    }
+
+    public bool allowsToolTipsWhenApplicationIsInactive ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_allowsToolTipsWhenApplicationIsInactive) !is null;
+    }
+
+    public CGFloat alphaValue ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_alphaValue);
+    }
+
+    public NSTimeInterval animationResizeTime (NSRect newFrame)
+    {
+        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id, OS.sel_animationResizeTime_1, newFrame);
+    }
+
+    public bool areCursorRectsEnabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_areCursorRectsEnabled) !is null;
+    }
+
+    public NSSize aspectRatio ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_aspectRatio);
+        return result;
+    }
+
+    public NSWindow attachedSheet ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedSheet);
+        return result is this.id ? this : (result !is null ? new NSWindow(result) : null);
+    }
+
+    public bool autorecalculatesContentBorderThicknessForEdge (NSRectEdge edge)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autorecalculatesContentBorderThicknessForEdge_1, edge) !is null;
+    }
+
+    public bool autorecalculatesKeyViewLoop ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_autorecalculatesKeyViewLoop) !is null;
+    }
+
+    public NSColor backgroundColor ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_backgroundColor);
+        return result !is null ? new NSColor(result) : null;
+    }
+
+    public NSWindowBackingLocation backingLocation ()
+    {
+        return cast(NSWindowBackingLocation) OS.objc_msgSend(this.id, OS.sel_backingLocation);
+    }
+
+    public NSBackingStoreType backingType ()
+    {
+        return cast(NSBackingStoreType) OS.objc_msgSend(this.id, OS.sel_backingType);
+    }
+
+    public void becomeKeyWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_becomeKeyWindow);
+    }
+
+    public void becomeMainWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_becomeMainWindow);
+    }
+
+    public void cacheImageInRect (NSRect aRect)
+    {
+        OS.objc_msgSend(this.id, OS.sel_cacheImageInRect_1, aRect);
+    }
+
+    public bool canBeVisibleOnAllSpaces ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canBeVisibleOnAllSpaces) !is null;
+    }
+
+    public bool canBecomeKeyWindow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canBecomeKeyWindow) !is null;
+    }
+
+    public bool canBecomeMainWindow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canBecomeMainWindow) !is null;
+    }
+
+    public bool canBecomeVisibleWithoutLogin ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canBecomeVisibleWithoutLogin) !is null;
+    }
+
+    public bool canHide ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canHide) !is null;
+    }
+
+    public bool canStoreColor ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_canStoreColor) !is null;
+    }
+
+    public NSPoint cascadeTopLeftFromPoint (NSPoint topLeftPoint)
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_cascadeTopLeftFromPoint_1, topLeftPoint);
+        return result;
+    }
+
+    public void center ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_center);
+    }
+
+    public NSArray childWindows ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_childWindows);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void close ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_close);
+    }
+
+    public NSWindowCollectionBehavior collectionBehavior ()
+    {
+        return cast(NSWindowCollectionBehavior) OS.objc_msgSend(this.id, OS.sel_collectionBehavior);
+    }
+
+    public NSRect constrainFrameRect (NSRect frameRect, NSScreen screen)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_constrainFrameRect_1toScreen_1, frameRect, screen !is null ? screen.id : null);
+        return result;
+    }
+
+    public NSSize contentAspectRatio ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentAspectRatio);
+        return result;
+    }
+
+    public CGFloat contentBorderThicknessForEdge (NSRectEdge edge)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_contentBorderThicknessForEdge_1, edge);
+    }
+
+    public NSSize contentMaxSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentMaxSize);
+        return result;
+    }
+
+    public NSSize contentMinSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentMinSize);
+        return result;
+    }
+
+    public NSRect contentRectForFrameRect_ (NSRect frameRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentRectForFrameRect_1, frameRect);
+        return result;
+    }
+
+    public static NSRect static_contentRectForFrameRect_styleMask_ (NSRect fRect, NSUInteger aStyle)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, OS.class_NSWindow, OS.sel_contentRectForFrameRect_1styleMask_1, fRect, aStyle);
+        return result;
+    }
+
+    public NSSize contentResizeIncrements ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_contentResizeIncrements);
+        return result;
+    }
+
+    public NSView contentView ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_contentView);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public NSPoint convertBaseToScreen (NSPoint aPoint)
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_convertBaseToScreen_1, aPoint);
+        return result;
+    }
+
+    public NSPoint convertScreenToBase (NSPoint aPoint)
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_convertScreenToBase_1, aPoint);
+        return result;
+    }
+
+    public NSEvent currentEvent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_currentEvent);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public NSData dataWithEPSInsideRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataWithEPSInsideRect_1, rect);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData dataWithPDFInsideRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dataWithPDFInsideRect_1, rect);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSScreen deepestScreen ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_deepestScreen);
+        return result !is null ? new NSScreen(result) : null;
+    }
+
+    public NSButtonCell defaultButtonCell ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_defaultButtonCell);
+        return result !is null ? new NSButtonCell(result) : null;
+    }
+
+    public static NSWindowDepth defaultDepthLimit ()
+    {
+        return cast(NSWindowDepth) OS.objc_msgSend(OS.class_NSWindow, OS.sel_defaultDepthLimit);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void deminiaturize (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_deminiaturize_1, sender !is null ? sender.id : null);
+    }
+
+    public NSWindowDepth depthLimit ()
+    {
+        return cast(NSWindowDepth) OS.objc_msgSend(this.id, OS.sel_depthLimit);
+    }
+
+    public NSDictionary deviceDescription ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_deviceDescription);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void disableCursorRects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_disableCursorRects);
+    }
+
+    public void disableFlushWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_disableFlushWindow);
+    }
+
+    public void disableKeyEquivalentForDefaultButtonCell ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_disableKeyEquivalentForDefaultButtonCell);
+    }
+
+    public void disableScreenUpdatesUntilFlush ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_disableScreenUpdatesUntilFlush);
+    }
+
+    public void discardCachedImage ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_discardCachedImage);
+    }
+
+    public void discardCursorRects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_discardCursorRects);
+    }
+
+    public void discardEventsMatchingMask (NSUInteger mask, NSEvent lastEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_discardEventsMatchingMask_1beforeEvent_1, mask, lastEvent !is null ? lastEvent.id : null);
+    }
+
+    public void display ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_display);
+    }
+
+    public void displayIfNeeded ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_displayIfNeeded);
+    }
+
+    public bool displaysWhenScreenProfileChanges ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_displaysWhenScreenProfileChanges) !is null;
+    }
+
+    public NSDockTile dockTile ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_dockTile);
+        return result !is null ? new NSDockTile(result) : null;
+    }
+
+    public void dragImage (NSImage anImage, NSPoint baseLocation, NSSize initialOffset, NSEvent event, NSPasteboard pboard, id sourceObj,
+            bool slideFlag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_dragImage_1at_1offset_1event_1pasteboard_1source_1slideBack_1, anImage !is null ? anImage.id : null,
+                baseLocation, initialOffset, event !is null ? event.id : null, pboard !is null ? pboard.id : null,
+                sourceObj !is null ? sourceObj.id : null, slideFlag);
+    }
+
+    public NSArray drawers ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_drawers);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void enableCursorRects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_enableCursorRects);
+    }
+
+    public void enableFlushWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_enableFlushWindow);
+    }
+
+    public void enableKeyEquivalentForDefaultButtonCell ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_enableKeyEquivalentForDefaultButtonCell);
+    }
+
+    public void endEditingFor (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_endEditingFor_1, anObject !is null ? anObject.id : null);
+    }
+
+    public NSText fieldEditor (bool createFlag, id anObject)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fieldEditor_1forObject_1, createFlag, anObject !is null ? anObject.id : null);
+        return result !is null ? new NSText(result) : null;
+    }
+
+    public NSResponder firstResponder ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_firstResponder);
+        return result !is null ? new NSResponder(result) : null;
+    }
+
+    public void flushWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushWindow);
+    }
+
+    public void flushWindowIfNeeded ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushWindowIfNeeded);
+    }
+
+    public NSRect frame ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frame);
+        return result;
+    }
+
+    public NSString frameAutosaveName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_frameAutosaveName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSRect frameRectForContentRect_ (NSRect contentRect)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_frameRectForContentRect_1, contentRect);
+        return result;
+    }
+
+    public static NSRect static_frameRectForContentRect_styleMask_ (NSRect cRect, NSUInteger aStyle)
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, OS.class_NSWindow, OS.sel_frameRectForContentRect_1styleMask_1, cRect, aStyle);
+        return result;
+    }
+
+    public NSInteger gState ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_gState);
+    }
+
+    public NSGraphicsContext graphicsContext ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_graphicsContext);
+        return result !is null ? new NSGraphicsContext(result) : null;
+    }
+
+    public id handleCloseScriptCommand (NSCloseCommand command)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_handleCloseScriptCommand_1, command !is null ? command.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id handlePrintScriptCommand (NSScriptCommand command)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_handlePrintScriptCommand_1, command !is null ? command.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id handleSaveScriptCommand (NSScriptCommand command)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_handleSaveScriptCommand_1, command !is null ? command.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool hasCloseBox ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasCloseBox) !is null;
+    }
+
+    public bool hasDynamicDepthLimit ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasDynamicDepthLimit) !is null;
+    }
+
+    public bool hasShadow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasShadow) !is null;
+    }
+
+    public bool hasTitleBar ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hasTitleBar) !is null;
+    }
+
+    public bool hidesOnDeactivate ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_hidesOnDeactivate) !is null;
+    }
+
+    public bool ignoresMouseEvents ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_ignoresMouseEvents) !is null;
+    }
+
+    public NSWindow initWithContentRect_styleMask_backing_defer_ (NSRect contentRect, NSUInteger aStyle, NSBackingStoreType bufferingType, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentRect_1styleMask_1backing_1defer_1, contentRect, aStyle, bufferingType, flag);
+        return result !is null ? this : null;
+    }
+
+    public NSWindow initWithContentRect_styleMask_backing_defer_screen_ (NSRect contentRect, NSUInteger aStyle, NSBackingStoreType bufferingType,
+            bool flag, NSScreen screen)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentRect_1styleMask_1backing_1defer_1screen_1, contentRect, aStyle,
+                bufferingType, flag, screen !is null ? screen.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSWindow initWithWindowRef (void* windowRef)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithWindowRef_1, windowRef);
+        return result is this.id ? this : (result !is null ? new NSWindow(result) : null);
+    }
+
+    public NSView initialFirstResponder ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initialFirstResponder);
+        return result !is null ? new NSView(result) : null;
+    }
+
+    public void invalidateCursorRectsForView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateCursorRectsForView_1, aView !is null ? aView.id : null);
+    }
+
+    public void invalidateShadow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_invalidateShadow);
+    }
+
+    public bool isAutodisplay ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isAutodisplay) !is null;
+    }
+
+    public bool isDocumentEdited ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isDocumentEdited) !is null;
+    }
+
+    public bool isExcludedFromWindowsMenu ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExcludedFromWindowsMenu) !is null;
+    }
+
+    public bool isFloatingPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFloatingPanel) !is null;
+    }
+
+    public bool isFlushWindowDisabled ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFlushWindowDisabled) !is null;
+    }
+
+    public bool isKeyWindow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isKeyWindow) !is null;
+    }
+
+    public bool isMainWindow ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMainWindow) !is null;
+    }
+
+    public bool isMiniaturizable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMiniaturizable) !is null;
+    }
+
+    public bool isMiniaturized ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMiniaturized) !is null;
+    }
+
+    public bool isModalPanel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isModalPanel) !is null;
+    }
+
+    public bool isMovableByWindowBackground ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isMovableByWindowBackground) !is null;
+    }
+
+    public bool isOneShot ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOneShot) !is null;
+    }
+
+    public bool isOpaque ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isOpaque) !is null;
+    }
+
+    public bool isReleasedWhenClosed ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isReleasedWhenClosed) !is null;
+    }
+
+    public bool isResizable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isResizable) !is null;
+    }
+
+    public bool isSheet ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isSheet) !is null;
+    }
+
+    public bool isVisible ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isVisible) !is null;
+    }
+
+    public bool isZoomable ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isZoomable) !is null;
+    }
+
+    public bool isZoomed ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isZoomed) !is null;
+    }
+
+    public void keyDown (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_keyDown_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public NSSelectionDirection keyViewSelectionDirection ()
+    {
+        return cast(NSSelectionDirection) OS.objc_msgSend(this.id, OS.sel_keyViewSelectionDirection);
+    }
+
+    public NSInteger level ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_level);
+    }
+
+    public bool makeFirstResponder (NSResponder aResponder)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_makeFirstResponder_1, aResponder !is null ? aResponder.id : null) !is null;
+    }
+
+    public void makeKeyAndOrderFront (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeKeyAndOrderFront_1, sender !is null ? sender.id : null);
+    }
+
+    public void makeKeyWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeKeyWindow);
+    }
+
+    public void makeMainWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeMainWindow);
+    }
+
+    public NSSize maxSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_maxSize);
+        return result;
+    }
+
+    public static void menuChanged (NSMenu menu)
+    {
+        OS.objc_msgSend(OS.class_NSWindow, OS.sel_menuChanged_1, menu !is null ? menu.id : null);
+    }
+
+    public static CGFloat minFrameWidthWithTitle (NSString aTitle, NSUInteger aStyle)
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSWindow, OS.sel_minFrameWidthWithTitle_1styleMask_1, aTitle !is null ? aTitle.id : null,
+                aStyle);
+    }
+
+    public NSSize minSize ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_minSize);
+        return result;
+    }
+
+    public void miniaturize (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_miniaturize_1, sender !is null ? sender.id : null);
+    }
+
+    public NSImage miniwindowImage ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_miniwindowImage);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSString miniwindowTitle ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_miniwindowTitle);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSPoint mouseLocationOutsideOfEventStream ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_mouseLocationOutsideOfEventStream);
+        return result;
+    }
+
+    public NSEvent nextEventMatchingMask_ (NSUInteger mask)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextEventMatchingMask_1, mask);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public NSEvent nextEventMatchingMask_untilDate_inMode_dequeue_ (NSUInteger mask, NSDate expiration, NSString mode, bool deqFlag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextEventMatchingMask_1untilDate_1inMode_1dequeue_1, mask,
+                expiration !is null ? expiration.id : null, mode !is null ? mode.id : null, deqFlag);
+        return result !is null ? new NSEvent(result) : null;
+    }
+
+    public void orderBack (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderBack_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFront (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFront_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderFrontRegardless ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderFrontRegardless);
+    }
+
+    public void orderOut (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderOut_1, sender !is null ? sender.id : null);
+    }
+
+    public void orderWindow (NSWindowOrderingMode place, NSInteger otherWin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_orderWindow_1relativeTo_1, place, otherWin);
+    }
+
+    public int orderedIndex ()
+    {
+        return cast(int) OS.objc_msgSend(this.id, OS.sel_orderedIndex);
+    }
+
+    public NSWindow parentWindow ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parentWindow);
+        return result is this.id ? this : (result !is null ? new NSWindow(result) : null);
+    }
+
+    public void performClose (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performClose_1, sender !is null ? sender.id : null);
+    }
+
+    public void performMiniaturize (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performMiniaturize_1, sender !is null ? sender.id : null);
+    }
+
+    public void performZoom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_performZoom_1, sender !is null ? sender.id : null);
+    }
+
+    public void postEvent (NSEvent event, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_postEvent_1atStart_1, event !is null ? event.id : null, flag);
+    }
+
+    public NSWindowBackingLocation preferredBackingLocation ()
+    {
+        return cast(NSWindowBackingLocation) OS.objc_msgSend(this.id, OS.sel_preferredBackingLocation);
+    }
+
+    public bool preservesContentDuringLiveResize ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_preservesContentDuringLiveResize) !is null;
+    }
+
+    public void print (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_print_1, sender !is null ? sender.id : null);
+    }
+
+    public void recalculateKeyViewLoop ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_recalculateKeyViewLoop);
+    }
+
+    public void registerForDraggedTypes (NSArray newTypes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_registerForDraggedTypes_1, newTypes !is null ? newTypes.id : null);
+    }
+
+    public void removeChildWindow (NSWindow childWin)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeChildWindow_1, childWin !is null ? childWin.id : null);
+    }
+
+    public static void removeFrameUsingName (NSString name)
+    {
+        OS.objc_msgSend(OS.class_NSWindow, OS.sel_removeFrameUsingName_1, name !is null ? name.id : null);
+    }
+
+    public NSString representedFilename ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedFilename);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSURL representedURL ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_representedURL);
+        return result !is null ? new NSURL(result) : null;
+    }
+
+    public void resetCursorRects ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resetCursorRects);
+    }
+
+    public void resignKeyWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resignKeyWindow);
+    }
+
+    public void resignMainWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_resignMainWindow);
+    }
+
+    public NSInteger resizeFlags ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_resizeFlags);
+    }
+
+    public NSSize resizeIncrements ()
+    {
+        NSSize result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_resizeIncrements);
+        return result;
+    }
+
+    public void restoreCachedImage ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_restoreCachedImage);
+    }
+
+    public void runToolbarCustomizationPalette (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_runToolbarCustomizationPalette_1, sender !is null ? sender.id : null);
+    }
+
+    public void saveFrameUsingName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_saveFrameUsingName_1, name !is null ? name.id : null);
+    }
+
+    public NSScreen screen ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_screen);
+        return result !is null ? new NSScreen(result) : null;
+    }
+
+    public void selectKeyViewFollowingView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectKeyViewFollowingView_1, aView !is null ? aView.id : null);
+    }
+
+    public void selectKeyViewPrecedingView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectKeyViewPrecedingView_1, aView !is null ? aView.id : null);
+    }
+
+    public void selectNextKeyView (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectNextKeyView_1, sender !is null ? sender.id : null);
+    }
+
+    public void selectPreviousKeyView (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_selectPreviousKeyView_1, sender !is null ? sender.id : null);
+    }
+
+    public void sendEvent (NSEvent theEvent)
+    {
+        OS.objc_msgSend(this.id, OS.sel_sendEvent_1, theEvent !is null ? theEvent.id : null);
+    }
+
+    public void setAcceptsMouseMovedEvents (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAcceptsMouseMovedEvents_1, flag);
+    }
+
+    public void setAllowsToolTipsWhenApplicationIsInactive (bool allowWhenInactive)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAllowsToolTipsWhenApplicationIsInactive_1, allowWhenInactive);
+    }
+
+    public void setAlphaValue (CGFloat windowAlpha)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAlphaValue_1, windowAlpha);
+    }
+
+    public void setAspectRatio (NSSize ratio)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAspectRatio_1, ratio);
+    }
+
+    public void setAutodisplay (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutodisplay_1, flag);
+    }
+
+    public void setAutorecalculatesContentBorderThickness (bool flag, NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutorecalculatesContentBorderThickness_1forEdge_1, flag, edge);
+    }
+
+    public void setAutorecalculatesKeyViewLoop (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAutorecalculatesKeyViewLoop_1, flag);
+    }
+
+    public void setBackgroundColor (NSColor color)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_1, color !is null ? color.id : null);
+    }
+
+    public void setBackingType (NSBackingStoreType bufferingType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setBackingType_1, bufferingType);
+    }
+
+    public void setCanBeVisibleOnAllSpaces (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanBeVisibleOnAllSpaces_1, flag);
+    }
+
+    public void setCanBecomeVisibleWithoutLogin (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanBecomeVisibleWithoutLogin_1, flag);
+    }
+
+    public void setCanHide (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCanHide_1, flag);
+    }
+
+    public void setCollectionBehavior (NSWindowCollectionBehavior behavior)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCollectionBehavior_1, behavior);
+    }
+
+    public void setContentAspectRatio (NSSize ratio)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentAspectRatio_1, ratio);
+    }
+
+    public void setContentBorderThickness (CGFloat thickness, NSRectEdge edge)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentBorderThickness_1forEdge_1, thickness, edge);
+    }
+
+    public void setContentMaxSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentMaxSize_1, size);
+    }
+
+    public void setContentMinSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentMinSize_1, size);
+    }
+
+    public void setContentResizeIncrements (NSSize increments)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentResizeIncrements_1, increments);
+    }
+
+    public void setContentSize (NSSize aSize)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentSize_1, aSize);
+    }
+
+    public void setContentView (NSView aView)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setContentView_1, aView !is null ? aView.id : null);
+    }
+
+    public void setDefaultButtonCell (NSButtonCell defButt)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDefaultButtonCell_1, defButt !is null ? defButt.id : null);
+    }
+
+    public void setDelegate (id anObject)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null);
+    }
+
+    public void setDepthLimit (NSWindowDepth limit)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDepthLimit_1, limit);
+    }
+
+    public void setDisplaysWhenScreenProfileChanges (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDisplaysWhenScreenProfileChanges_1, flag);
+    }
+
+    public void setDocumentEdited (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocumentEdited_1, flag);
+    }
+
+    public void setDynamicDepthLimit (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDynamicDepthLimit_1, flag);
+    }
+
+    public void setExcludedFromWindowsMenu (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setExcludedFromWindowsMenu_1, flag);
+    }
+
+    public void setFrame_display_ (NSRect frameRect, bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrame_1display_1, frameRect, flag);
+    }
+
+    public void setFrame_display_animate_ (NSRect frameRect, bool displayFlag, bool animateFlag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrame_1display_1animate_1, frameRect, displayFlag, animateFlag);
+    }
+
+    public bool setFrameAutosaveName (NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setFrameAutosaveName_1, name !is null ? name.id : null) !is null;
+    }
+
+    public void setFrameFromString (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameFromString_1, string !is null ? string.id : null);
+    }
+
+    public void setFrameOrigin (NSPoint aPoint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameOrigin_1, aPoint);
+    }
+
+    public void setFrameTopLeftPoint (NSPoint aPoint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFrameTopLeftPoint_1, aPoint);
+    }
+
+    public bool setFrameUsingName_ (NSString name)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setFrameUsingName_1, name !is null ? name.id : null) !is null;
+    }
+
+    public bool setFrameUsingName_force_ (NSString name, bool force)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setFrameUsingName_1force_1, name !is null ? name.id : null, force) !is null;
+    }
+
+    public void setHasShadow (bool hasShadow)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHasShadow_1, hasShadow);
+    }
+
+    public void setHidesOnDeactivate (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setHidesOnDeactivate_1, flag);
+    }
+
+    public void setIgnoresMouseEvents (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIgnoresMouseEvents_1, flag);
+    }
+
+    public void setInitialFirstResponder (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setInitialFirstResponder_1, view !is null ? view.id : null);
+    }
+
+    public void setIsMiniaturized (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIsMiniaturized_1, flag);
+    }
+
+    public void setIsVisible (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIsVisible_1, flag);
+    }
+
+    public void setIsZoomed (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setIsZoomed_1, flag);
+    }
+
+    public void setLevel (NSInteger newLevel)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setLevel_1, newLevel);
+    }
+
+    public void setMaxSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMaxSize_1, size);
+    }
+
+    public void setMinSize (NSSize size)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMinSize_1, size);
+    }
+
+    public void setMiniwindowImage (NSImage image)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMiniwindowImage_1, image !is null ? image.id : null);
+    }
+
+    public void setMiniwindowTitle (NSString title)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMiniwindowTitle_1, title !is null ? title.id : null);
+    }
+
+    public void setMovableByWindowBackground (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMovableByWindowBackground_1, flag);
+    }
+
+    public void setOneShot (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOneShot_1, flag);
+    }
+
+    public void setOpaque (bool isOpaque)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOpaque_1, isOpaque);
+    }
+
+    public void setOrderedIndex (int index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOrderedIndex_1, index);
+    }
+
+    public void setParentWindow (NSWindow window)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setParentWindow_1, window !is null ? window.id : null);
+    }
+
+    public void setPreferredBackingLocation (NSWindowBackingLocation backingLocation)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreferredBackingLocation_1, backingLocation);
+    }
+
+    public void setPreservesContentDuringLiveResize (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPreservesContentDuringLiveResize_1, flag);
+    }
+
+    public void setReleasedWhenClosed (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setReleasedWhenClosed_1, flag);
+    }
+
+    public void setRepresentedFilename (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRepresentedFilename_1, aString !is null ? aString.id : null);
+    }
+
+    public void setRepresentedURL (NSURL url)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRepresentedURL_1, url !is null ? url.id : null);
+    }
+
+    public void setResizeIncrements (NSSize increments)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setResizeIncrements_1, increments);
+    }
+
+    public void setSharingType (NSWindowSharingType type)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSharingType_1, type);
+    }
+
+    public void setShowsResizeIndicator (bool show)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsResizeIndicator_1, show);
+    }
+
+    public void setShowsToolbarButton (bool show)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShowsToolbarButton_1, show);
+    }
+
+    public void setTitle (NSString aString)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null);
+    }
+
+    public void setTitleWithRepresentedFilename (NSString filename)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTitleWithRepresentedFilename_1, filename !is null ? filename.id : null);
+    }
+
+    public void setToolbar (NSToolbar toolbar)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setToolbar_1, toolbar !is null ? toolbar.id : null);
+    }
+
+    public void setViewsNeedDisplay (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setViewsNeedDisplay_1, flag);
+    }
+
+    public void setWindowController (NSWindowController windowController)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindowController_1, windowController !is null ? windowController.id : null);
+    }
+
+    public NSWindowSharingType sharingType ()
+    {
+        return cast(NSWindowSharingType) OS.objc_msgSend(this.id, OS.sel_sharingType);
+    }
+
+    public bool showsResizeIndicator ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsResizeIndicator) !is null;
+    }
+
+    public bool showsToolbarButton ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_showsToolbarButton) !is null;
+    }
+
+    public NSButton standardWindowButton_ (NSWindowButton b)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_standardWindowButton_1, b);
+        return result !is null ? new NSButton(result) : null;
+    }
+
+    public static NSButton static_standardWindowButton_forStyleMask_ (int b, int styleMask)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSWindow, OS.sel_standardWindowButton_1forStyleMask_1, b, styleMask);
+        return result !is null ? new NSButton(result) : null;
+    }
+
+    public NSString stringWithSavedFrame ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringWithSavedFrame);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSUInteger styleMask ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_styleMask);
+    }
+
+    public NSString title ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void toggleToolbarShown (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_toggleToolbarShown_1, sender !is null ? sender.id : null);
+    }
+
+    public NSToolbar toolbar ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_toolbar);
+        return result !is null ? new NSToolbar(result) : null;
+    }
+
+    public bool tryToPerform (objc.SEL anAction, id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_tryToPerform_1with_1, anAction, anObject !is null ? anObject.id : null) !is null;
+    }
+
+    public void unregisterDraggedTypes ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_unregisterDraggedTypes);
+    }
+
+    public void update ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_update);
+    }
+
+    public void useOptimizedDrawing (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_useOptimizedDrawing_1, flag);
+    }
+
+    public CGFloat userSpaceScaleFactor ()
+    {
+        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_userSpaceScaleFactor);
+    }
+
+    public id validRequestorForSendType (NSString sendType, NSString returnType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_validRequestorForSendType_1returnType_1, sendType !is null ? sendType.id : null,
+                returnType !is null ? returnType.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool viewsNeedDisplay ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_viewsNeedDisplay) !is null;
+    }
+
+    public id windowController ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowController);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger windowNumber ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_windowNumber);
+    }
+
+    public void* windowRef ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_windowRef);
+    }
+
+    public bool worksWhenModal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_worksWhenModal) !is null;
+    }
+
+    public void zoom (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_zoom_1, sender !is null ? sender.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSWindowController.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSWindowController;
+
+import dwt.internal.cocoa.NSDocument;
+import dwt.internal.cocoa.NSResponder;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSWindowController : NSResponder
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void close ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_close);
+    }
+
+    public id document ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_document);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithWindow (NSWindow window)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithWindow_1, window !is null ? window.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithWindowNibName_ (NSString windowNibName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithWindowNibName_1, windowNibName !is null ? windowNibName.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithWindowNibName_owner_ (NSString windowNibName, id owner)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithWindowNibName_1owner_1, windowNibName !is null ? windowNibName.id : null,
+                owner !is null ? owner.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithWindowNibPath (NSString windowNibPath, id owner)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithWindowNibPath_1owner_1, windowNibPath !is null ? windowNibPath.id : null,
+                owner !is null ? owner.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isWindowLoaded ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isWindowLoaded) !is null;
+    }
+
+    public void loadWindow ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_loadWindow);
+    }
+
+    public id owner ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_owner);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void setDocument (NSDocument document)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocument_1, document !is null ? document.id : null);
+    }
+
+    public void setDocumentEdited (bool dirtyFlag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocumentEdited_1, dirtyFlag);
+    }
+
+    public void setShouldCascadeWindows (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldCascadeWindows_1, flag);
+    }
+
+    public void setShouldCloseDocument (bool flag)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldCloseDocument_1, flag);
+    }
+
+    public void setWindow (NSWindow window)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindow_1, window !is null ? window.id : null);
+    }
+
+    public void setWindowFrameAutosaveName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setWindowFrameAutosaveName_1, name !is null ? name.id : null);
+    }
+
+    public bool shouldCascadeWindows ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldCascadeWindows) !is null;
+    }
+
+    public bool shouldCloseDocument ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldCloseDocument) !is null;
+    }
+
+    public void showWindow (id sender)
+    {
+        OS.objc_msgSend(this.id, OS.sel_showWindow_1, sender !is null ? sender.id : null);
+    }
+
+    public void synchronizeWindowTitleWithDocumentName ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_synchronizeWindowTitleWithDocumentName);
+    }
+
+    public NSWindow window ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_window);
+        return result !is null ? new NSWindow(result) : null;
+    }
+
+    public void windowDidLoad ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_windowDidLoad);
+    }
+
+    public NSString windowFrameAutosaveName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowFrameAutosaveName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString windowNibName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowNibName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString windowNibPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowNibPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString windowTitleForDocumentDisplayName (NSString displayName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_windowTitleForDocumentDisplayName_1, displayName !is null ? displayName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void windowWillLoad ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_windowWillLoad);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSWorkspace.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,331 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSWorkspace;
+
+import dwt.internal.cocoa.NSAppleEventDescriptor;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSNotificationCenter;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSWorkspaceLaunchOptions : uint
+{
+    NSWorkspaceLaunchAndPrint = 0x00000002,
+    NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
+    NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100,
+    NSWorkspaceLaunchWithoutActivation = 0x00000200,
+    NSWorkspaceLaunchAsync = 0x00010000,
+    NSWorkspaceLaunchAllowingClassicStartup = 0x00020000,
+    NSWorkspaceLaunchPreferringClassic = 0x00040000,
+    NSWorkspaceLaunchNewInstance = 0x00080000,
+    NSWorkspaceLaunchAndHide = 0x00100000,
+    NSWorkspaceLaunchAndHideOthers = 0x00200000,
+    NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | NSWorkspaceLaunchAllowingClassicStartup
+}
+
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndPrint NSWorkspaceLaunchAndPrint;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchInhibitingBackgroundOnly NSWorkspaceLaunchInhibitingBackgroundOnly;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchWithoutAddingToRecents NSWorkspaceLaunchWithoutAddingToRecents;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchWithoutActivation NSWorkspaceLaunchWithoutActivation;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAsync NSWorkspaceLaunchAsync;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAllowingClassicStartup NSWorkspaceLaunchAllowingClassicStartup;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchPreferringClassic NSWorkspaceLaunchPreferringClassic;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchNewInstance NSWorkspaceLaunchNewInstance;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndHide NSWorkspaceLaunchAndHide;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndHideOthers NSWorkspaceLaunchAndHideOthers;
+alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchDefault NSWorkspaceLaunchDefault;
+
+enum NSWorkspaceIconCreationOptions : NSUInteger
+{
+    NSExcludeQuickDrawElementsIconCreationOption = 1 << 1,
+    NSExclude10_4ElementsIconCreationOption = 1 << 2
+}
+
+alias NSWorkspaceIconCreationOptions.NSExcludeQuickDrawElementsIconCreationOption NSExcludeQuickDrawElementsIconCreationOption;
+alias NSWorkspaceIconCreationOptions.NSExclude10_4ElementsIconCreationOption NSExclude10_4ElementsIconCreationOption;
+
+public class NSWorkspace : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSString absolutePathForAppBundleWithIdentifier (NSString bundleIdentifier)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_absolutePathForAppBundleWithIdentifier_1,
+                bundleIdentifier !is null ? bundleIdentifier.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSDictionary activeApplication ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_activeApplication);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public void checkForRemovableMedia ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_checkForRemovableMedia);
+    }
+
+    public NSInteger extendPowerOffBy (NSInteger requested)
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_extendPowerOffBy_1, requested);
+    }
+
+    public bool fileSystemChanged ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_fileSystemChanged) !is null;
+    }
+
+    public bool filenameExtension (NSString filenameExtension, NSString typeName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_filenameExtension_1isValidForType_1, filenameExtension !is null ? filenameExtension.id : null,
+                typeName !is null ? typeName.id : null) !is null;
+    }
+
+    public void findApplications ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_findApplications);
+    }
+
+    public NSString fullPathForApplication (NSString appName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_fullPathForApplication_1, appName !is null ? appName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool getFileSystemInfoForPath (NSString fullPath, bool* removableFlag, bool* writableFlag, bool* unmountableFlag,
+    /*NSString** */objc.id** description,
+    /*NSString** */objc.id** fileSystemType)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getFileSystemInfoForPath_1isRemovable_1isWritable_1isUnmountable_1description_1type_1,
+                fullPath !is null ? fullPath.id : null, removableFlag, writableFlag, unmountableFlag, description, fileSystemType) !is null;
+    }
+
+    public bool getInfoForFile (NSString fullPath, /*NSString** */objc.id** appName, /*NSString** */objc.id** type)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_getInfoForFile_1application_1type_1, fullPath !is null ? fullPath.id : null, appName, type) !is null;
+    }
+
+    public void hideOtherApplications ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_hideOtherApplications);
+    }
+
+    public NSImage iconForFile (NSString fullPath)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_iconForFile_1, fullPath !is null ? fullPath.id : null);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImage iconForFileType (NSString fileType)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_iconForFileType_1, fileType !is null ? fileType.id : null);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public NSImage iconForFiles (NSArray fullPaths)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_iconForFiles_1, fullPaths !is null ? fullPaths.id : null);
+        return result !is null ? new NSImage(result) : null;
+    }
+
+    public bool isFilePackageAtPath (NSString fullPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isFilePackageAtPath_1, fullPath !is null ? fullPath.id : null) !is null;
+    }
+
+    public bool launchAppWithBundleIdentifier (NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor,
+    /*NSNumber** */objc.id** identifier)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_launchAppWithBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifier_1,
+                bundleIdentifier !is null ? bundleIdentifier.id : null, options, descriptor !is null ? descriptor.id : null, identifier) !is null;
+    }
+
+    public bool launchApplication_ (NSString appName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_launchApplication_1, appName !is null ? appName.id : null) !is null;
+    }
+
+    public bool launchApplication_showIcon_autolaunch_ (NSString appName, bool showIcon, bool autolaunch)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_launchApplication_1showIcon_1autolaunch_1, appName !is null ? appName.id : null, showIcon, autolaunch) !is null;
+    }
+
+    public NSArray launchedApplications ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_launchedApplications);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSString localizedDescriptionForType (NSString typeName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedDescriptionForType_1, typeName !is null ? typeName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSArray mountNewRemovableMedia ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mountNewRemovableMedia);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray mountedLocalVolumePaths ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mountedLocalVolumePaths);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray mountedRemovableMedia ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_mountedRemovableMedia);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void noteFileSystemChanged ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteFileSystemChanged);
+    }
+
+    public void noteFileSystemChanged_ (NSString path)
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteFileSystemChanged_1, path !is null ? path.id : null);
+    }
+
+    public void noteUserDefaultsChanged ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_noteUserDefaultsChanged);
+    }
+
+    public NSNotificationCenter notificationCenter ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_notificationCenter);
+        return result !is null ? new NSNotificationCenter(result) : null;
+    }
+
+    public bool openFile_ (NSString fullPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_openFile_1, fullPath !is null ? fullPath.id : null) !is null;
+    }
+
+    public bool openFile_fromImage_at_inView_ (NSString fullPath, NSImage anImage, NSPoint point, NSView aView)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_openFile_1fromImage_1at_1inView_1, fullPath !is null ? fullPath.id : null,
+                anImage !is null ? anImage.id : null, point, aView !is null ? aView.id : null) !is null;
+    }
+
+    public bool openFile_withApplication_ (NSString fullPath, NSString appName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_openFile_1withApplication_1, fullPath !is null ? fullPath.id : null,
+                appName !is null ? appName.id : null) !is null;
+    }
+
+    public bool openFile_withApplication_andDeactivate_ (NSString fullPath, NSString appName, bool flag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_openFile_1withApplication_1andDeactivate_1, fullPath !is null ? fullPath.id : null,
+                appName !is null ? appName.id : null, flag) !is null;
+    }
+
+    public bool openTempFile (NSString fullPath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_openTempFile_1, fullPath !is null ? fullPath.id : null) !is null;
+    }
+
+    public bool openURL (NSURL url)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_openURL_1, url !is null ? url.id : null) !is null;
+    }
+
+    public bool openURLs (NSArray urls, NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor,
+            /*NSArray** */objc.id** identifiers)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_openURLs_1withAppBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifiers_1,
+                urls !is null ? urls.id : null, bundleIdentifier !is null ? bundleIdentifier.id : null, options,
+                descriptor !is null ? descriptor.id : null, identifiers) !is null;
+    }
+
+    public bool performFileOperation (NSString operation, NSString source, NSString destination, NSArray files, NSInteger* tag)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_performFileOperation_1source_1destination_1files_1tag_1, operation !is null ? operation.id : null,
+                source !is null ? source.id : null, destination !is null ? destination.id : null, files !is null ? files.id : null, tag) !is null;
+    }
+
+    public NSString preferredFilenameExtensionForType (NSString typeName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_preferredFilenameExtensionForType_1, typeName !is null ? typeName.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool selectFile (NSString fullPath, NSString rootFullpath)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_selectFile_1inFileViewerRootedAtPath_1, fullPath !is null ? fullPath.id : null,
+                rootFullpath !is null ? rootFullpath.id : null) !is null;
+    }
+
+    public bool setIcon (NSImage image, NSString fullPath, NSWorkspaceIconCreationOptions options)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_setIcon_1forFile_1options_1, image !is null ? image.id : null, fullPath !is null ? fullPath.id : null,
+                options) !is null;
+    }
+
+    public static NSWorkspace sharedWorkspace ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSWorkspace, OS.sel_sharedWorkspace);
+        return result !is null ? new NSWorkspace(result) : null;
+    }
+
+    public void slideImage (NSImage image, NSPoint fromPoint, NSPoint toPoint)
+    {
+        OS.objc_msgSend(this.id, OS.sel_slideImage_1from_1to_1, image !is null ? image.id : null, fromPoint, toPoint);
+    }
+
+    public bool type (NSString firstTypeName, NSString secondTypeName)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_type_1conformsToType_1, firstTypeName !is null ? firstTypeName.id : null,
+                secondTypeName !is null ? secondTypeName.id : null) !is null;
+    }
+
+    public NSString typeOfFile (NSString absoluteFilePath, /*NSError** */objc.id** outError)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_typeOfFile_1error_1, absoluteFilePath !is null ? absoluteFilePath.id : null, outError);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool unmountAndEjectDeviceAtPath (NSString path)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_unmountAndEjectDeviceAtPath_1, path !is null ? path.id : null) !is null;
+    }
+
+    public bool userDefaultsChanged ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_userDefaultsChanged) !is null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSXMLDTD.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSXMLDTD;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSXMLDTDNode;
+import dwt.internal.cocoa.NSXMLNode;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSXMLDTD : NSXMLNode
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addChild (NSXMLNode child)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addChild_1, child !is null ? child.id : null);
+    }
+
+    public NSXMLDTDNode attributeDeclarationForName (NSString name, NSString elementName)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributeDeclarationForName_1elementName_1, name !is null ? name.id : null,
+                elementName !is null ? elementName.id : null);
+        return result !is null ? new NSXMLDTDNode(result) : null;
+    }
+
+    public NSXMLDTDNode elementDeclarationForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_elementDeclarationForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLDTDNode(result) : null;
+    }
+
+    public NSXMLDTDNode entityDeclarationForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_entityDeclarationForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLDTDNode(result) : null;
+    }
+
+    public id initWithContentsOfURL (NSURL url, NSUInteger mask, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1options_1error_1, url !is null ? url.id : null, mask, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithData (NSData data, NSUInteger mask, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1options_1error_1, data !is null ? data.id : null, mask, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void insertChild (NSXMLNode child, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertChild_1atIndex_1, child !is null ? child.id : null, index);
+    }
+
+    public void insertChildren (NSArray children, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertChildren_1atIndex_1, children !is null ? children.id : null, index);
+    }
+
+    public NSXMLDTDNode notationDeclarationForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_notationDeclarationForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLDTDNode(result) : null;
+    }
+
+    public static NSXMLDTDNode predefinedEntityDeclarationForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLDTD, OS.sel_predefinedEntityDeclarationForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLDTDNode(result) : null;
+    }
+
+    public NSString publicID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_publicID);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void removeChildAtIndex (NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeChildAtIndex_1, index);
+    }
+
+    public void replaceChildAtIndex (NSUInteger index, NSXMLNode node)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceChildAtIndex_1withNode_1, index, node !is null ? node.id : null);
+    }
+
+    public void setChildren (NSArray children)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setChildren_1, children !is null ? children.id : null);
+    }
+
+    public void setPublicID (NSString publicID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPublicID_1, publicID !is null ? publicID.id : null);
+    }
+
+    public void setSystemID (NSString systemID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSystemID_1, systemID !is null ? systemID.id : null);
+    }
+
+    public NSString systemID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_systemID);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSXMLDTDNode.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSXMLDTDNode;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSXMLNode;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+
+
+enum NSXMLDTDNodeKind : NSUInteger
+{
+    NSXMLEntityGeneralKind = 1,
+    NSXMLEntityParsedKind,
+    NSXMLEntityUnparsedKind,
+    NSXMLEntityParameterKind,
+    NSXMLEntityPredefined,
+
+    NSXMLAttributeCDATAKind,
+    NSXMLAttributeIDKind,
+    NSXMLAttributeIDRefKind,
+    NSXMLAttributeIDRefsKind,
+    NSXMLAttributeEntityKind,
+    NSXMLAttributeEntitiesKind,
+    NSXMLAttributeNMTokenKind,
+    NSXMLAttributeNMTokensKind,
+    NSXMLAttributeEnumerationKind,
+    NSXMLAttributeNotationKind,
+
+    NSXMLElementDeclarationUndefinedKind,
+    NSXMLElementDeclarationEmptyKind,
+    NSXMLElementDeclarationAnyKind,
+    NSXMLElementDeclarationMixedKind,
+    NSXMLElementDeclarationElementKind
+}
+
+alias NSXMLDTDNodeKind.NSXMLEntityGeneralKind NSXMLEntityGeneralKind;
+alias NSXMLDTDNodeKind.NSXMLEntityParsedKind NSXMLEntityParsedKind;
+alias NSXMLDTDNodeKind.NSXMLEntityUnparsedKind NSXMLEntityUnparsedKind;
+alias NSXMLDTDNodeKind.NSXMLEntityParameterKind NSXMLEntityParameterKind;
+alias NSXMLDTDNodeKind.NSXMLEntityPredefined NSXMLEntityPredefined;
+
+alias NSXMLDTDNodeKind.NSXMLAttributeCDATAKind NSXMLAttributeCDATAKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeIDKind NSXMLAttributeIDKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeIDRefKind NSXMLAttributeIDRefKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeIDRefsKind NSXMLAttributeIDRefsKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeEntityKind NSXMLAttributeEntityKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeEntitiesKind NSXMLAttributeEntitiesKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeNMTokenKind NSXMLAttributeNMTokenKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeNMTokensKind NSXMLAttributeNMTokensKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeEnumerationKind NSXMLAttributeEnumerationKind;
+alias NSXMLDTDNodeKind.NSXMLAttributeNotationKind NSXMLAttributeNotationKind;
+
+alias NSXMLDTDNodeKind.NSXMLElementDeclarationUndefinedKind NSXMLElementDeclarationUndefinedKind;
+alias NSXMLDTDNodeKind.NSXMLElementDeclarationEmptyKind NSXMLElementDeclarationEmptyKind;
+alias NSXMLDTDNodeKind.NSXMLElementDeclarationAnyKind NSXMLElementDeclarationAnyKind;
+alias NSXMLDTDNodeKind.NSXMLElementDeclarationMixedKind NSXMLElementDeclarationMixedKind;
+alias NSXMLDTDNodeKind.NSXMLElementDeclarationElementKind NSXMLElementDeclarationElementKind;
+
+
+
+public class NSXMLDTDNode : NSXMLNode
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSXMLDTDNodeKind DTDKind ()
+    {
+        return cast(NSXMLDTDNodeKind) OS.objc_msgSend(this.id, OS.sel_DTDKind);
+    }
+
+    public id initWithXMLString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithXMLString_1, string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isExternal ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isExternal) !is null;
+    }
+
+    public NSString notationName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_notationName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString publicID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_publicID);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setDTDKind (NSXMLDTDNodeKind kind)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDTDKind_1, kind);
+    }
+
+    public void setNotationName (NSString notationName)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNotationName_1, notationName !is null ? notationName.id : null);
+    }
+
+    public void setPublicID (NSString publicID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPublicID_1, publicID !is null ? publicID.id : null);
+    }
+
+    public void setSystemID (NSString systemID)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setSystemID_1, systemID !is null ? systemID.id : null);
+    }
+
+    public NSString systemID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_systemID);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSXMLDocument.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSXMLDocument;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSXMLDTD;
+import dwt.internal.cocoa.NSXMLElement;
+import dwt.internal.cocoa.NSXMLNode;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSXMLDocumentContentKind : NSUInteger
+{
+    NSXMLDocumentXMLKind = 0,
+    NSXMLDocumentXHTMLKind,
+    NSXMLDocumentHTMLKind,
+    NSXMLDocumentTextKind
+}
+
+alias NSXMLDocumentContentKind.NSXMLDocumentXMLKind NSXMLDocumentXMLKind;
+alias NSXMLDocumentContentKind.NSXMLDocumentXHTMLKind NSXMLDocumentXHTMLKind;
+alias NSXMLDocumentContentKind.NSXMLDocumentHTMLKind NSXMLDocumentHTMLKind;
+alias NSXMLDocumentContentKind.NSXMLDocumentTextKind NSXMLDocumentTextKind;
+
+public class NSXMLDocument : NSXMLNode
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public NSXMLDTD DTD ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_DTD);
+        return result !is null ? new NSXMLDTD(result) : null;
+    }
+
+    public NSString MIMEType ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_MIMEType);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSData XMLData ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_XMLData);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSData XMLDataWithOptions (NSUInteger options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_XMLDataWithOptions_1, options);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public void addChild (NSXMLNode child)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addChild_1, child !is null ? child.id : null);
+    }
+
+    public NSString characterEncoding ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_characterEncoding);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSXMLDocumentContentKind documentContentKind ()
+    {
+        return cast(NSXMLDocumentContentKind) OS.objc_msgSend(this.id, OS.sel_documentContentKind);
+    }
+
+    public id initWithContentsOfURL (NSURL url, NSUInteger mask, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1options_1error_1, url !is null ? url.id : null, mask, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithData (NSData data, NSUInteger mask, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1options_1error_1, data !is null ? data.id : null, mask, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithRootElement (NSXMLElement element)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithRootElement_1, element !is null ? element.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithXMLString (NSString string, NSUInteger mask, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithXMLString_1options_1error_1, string !is null ? string.id : null, mask, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void insertChild (NSXMLNode child, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertChild_1atIndex_1, child !is null ? child.id : null, index);
+    }
+
+    public void insertChildren (NSArray children, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertChildren_1atIndex_1, children !is null ? children.id : null, index);
+    }
+
+    public bool isStandalone ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isStandalone) !is null;
+    }
+
+    public id objectByApplyingXSLT (NSData xslt, NSDictionary arguments, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectByApplyingXSLT_1arguments_1error_1, xslt !is null ? xslt.id : null,
+                arguments !is null ? arguments.id : null, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id objectByApplyingXSLTAtURL (NSURL xsltURL, NSDictionary argument, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectByApplyingXSLTAtURL_1arguments_1error_1, xsltURL !is null ? xsltURL.id : null,
+                argument !is null ? argument.id : null, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id objectByApplyingXSLTString (NSString xslt, NSDictionary arguments, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectByApplyingXSLTString_1arguments_1error_1, xslt !is null ? xslt.id : null,
+                arguments !is null ? arguments.id : null, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void removeChildAtIndex (NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeChildAtIndex_1, index);
+    }
+
+    public void replaceChildAtIndex (NSUInteger index, NSXMLNode node)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceChildAtIndex_1withNode_1, index, node !is null ? node.id : null);
+    }
+
+    public static objc.Class replacementClassForClass (objc.Class cls)
+    {
+        return cast(objc.Class) OS.objc_msgSend(OS.class_NSXMLDocument, OS.sel_replacementClassForClass_1, cls);
+    }
+
+    public NSXMLElement rootElement ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rootElement);
+        return result !is null ? new NSXMLElement(result) : null;
+    }
+
+    public void setCharacterEncoding (NSString encoding)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCharacterEncoding_1, encoding !is null ? encoding.id : null);
+    }
+
+    public void setChildren (NSArray children)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setChildren_1, children !is null ? children.id : null);
+    }
+
+    public void setDTD (NSXMLDTD documentTypeDeclaration)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDTD_1, documentTypeDeclaration !is null ? documentTypeDeclaration.id : null);
+    }
+
+    public void setDocumentContentKind (NSXMLDocumentContentKind kind)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDocumentContentKind_1, kind);
+    }
+
+    public void setMIMEType (NSString MIMEType)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setMIMEType_1, MIMEType !is null ? MIMEType.id : null);
+    }
+
+    public void setRootElement (NSXMLNode root)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setRootElement_1, root !is null ? root.id : null);
+    }
+
+    public void setStandalone (bool standalone)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStandalone_1, standalone);
+    }
+
+    public void setVersion (NSString versionn)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setVersion_1, versionn !is null ? versionn.id : null);
+    }
+
+    public bool validateAndReturnError (/*NSError** */objc.id** error)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_validateAndReturnError_1, error) !is null;
+    }
+
+//public NSString version() {
+//  objc.id result = OS.objc_msgSend(this.id, OS.sel_version);
+//  return result !is null ? new NSString(result) : null;
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSXMLElement.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSXMLElement;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSXMLNode;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSXMLElement : NSXMLNode
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addAttribute (NSXMLNode attribute)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addAttribute_1, attribute !is null ? attribute.id : null);
+    }
+
+    public void addChild (NSXMLNode child)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addChild_1, child !is null ? child.id : null);
+    }
+
+    public void addNamespace (NSXMLNode aNamespace)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addNamespace_1, aNamespace !is null ? aNamespace.id : null);
+    }
+
+    public NSXMLNode attributeForLocalName (NSString localName, NSString URI)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributeForLocalName_1URI_1, localName !is null ? localName.id : null,
+                URI !is null ? URI.id : null);
+        return result !is null ? new NSXMLNode(result) : null;
+    }
+
+    public NSXMLNode attributeForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributeForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLNode(result) : null;
+    }
+
+    public NSArray attributes ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributes);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray elementsForLocalName (NSString localName, NSString URI)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_elementsForLocalName_1URI_1, localName !is null ? localName.id : null,
+                URI !is null ? URI.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray elementsForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_elementsForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id initWithName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1, name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithName_URI_ (NSString name, NSString URI)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1URI_1, name !is null ? name.id : null, URI !is null ? URI.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithName_stringValue_ (NSString name, NSString string)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithName_1stringValue_1, name !is null ? name.id : null,
+                string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithXMLString (NSString string, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithXMLString_1error_1, string !is null ? string.id : null, error);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void insertChild (NSXMLNode child, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertChild_1atIndex_1, child !is null ? child.id : null, index);
+    }
+
+    public void insertChildren (NSArray children, NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_insertChildren_1atIndex_1, children !is null ? children.id : null, index);
+    }
+
+    public NSXMLNode namespaceForPrefix (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_namespaceForPrefix_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLNode(result) : null;
+    }
+
+    public NSArray namespaces ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_namespaces);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public void normalizeAdjacentTextNodesPreservingCDATA (bool preserve)
+    {
+        OS.objc_msgSend(this.id, OS.sel_normalizeAdjacentTextNodesPreservingCDATA_1, preserve);
+    }
+
+    public void removeAttributeForName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeAttributeForName_1, name !is null ? name.id : null);
+    }
+
+    public void removeChildAtIndex (NSUInteger index)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeChildAtIndex_1, index);
+    }
+
+    public void removeNamespaceForPrefix (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeNamespaceForPrefix_1, name !is null ? name.id : null);
+    }
+
+    public void replaceChildAtIndex (NSUInteger index, NSXMLNode node)
+    {
+        OS.objc_msgSend(this.id, OS.sel_replaceChildAtIndex_1withNode_1, index, node !is null ? node.id : null);
+    }
+
+    public NSXMLNode resolveNamespaceForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resolveNamespaceForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLNode(result) : null;
+    }
+
+    public NSString resolvePrefixForNamespaceURI (NSString namespaceURI)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_resolvePrefixForNamespaceURI_1, namespaceURI !is null ? namespaceURI.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setAttributes (NSArray attributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributes_1, attributes !is null ? attributes.id : null);
+    }
+
+    public void setAttributesAsDictionary (NSDictionary attributes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setAttributesAsDictionary_1, attributes !is null ? attributes.id : null);
+    }
+
+    public void setChildren (NSArray children)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setChildren_1, children !is null ? children.id : null);
+    }
+
+    public void setNamespaces (NSArray namespaces)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setNamespaces_1, namespaces !is null ? namespaces.id : null);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSXMLNode.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,368 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSXMLNode;
+
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSXMLDocument;
+import dwt.internal.cocoa.NSXMLElement;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSXMLNodeKind : NSUInteger
+{
+    NSXMLInvalidKind = 0,
+    NSXMLDocumentKind,
+    NSXMLElementKind,
+    NSXMLAttributeKind,
+    NSXMLNamespaceKind,
+    NSXMLProcessingInstructionKind,
+    NSXMLCommentKind,
+    NSXMLTextKind,
+    NSXMLDTDKind,
+    NSXMLEntityDeclarationKind,
+    NSXMLAttributeDeclarationKind,
+    NSXMLElementDeclarationKind,
+    NSXMLNotationDeclarationKind
+}
+
+alias NSXMLNodeKind.NSXMLInvalidKind NSXMLInvalidKind;
+alias NSXMLNodeKind.NSXMLDocumentKind NSXMLDocumentKind;
+alias NSXMLNodeKind.NSXMLElementKind NSXMLElementKind;
+alias NSXMLNodeKind.NSXMLAttributeKind NSXMLAttributeKind;
+alias NSXMLNodeKind.NSXMLNamespaceKind NSXMLNamespaceKind;
+alias NSXMLNodeKind.NSXMLProcessingInstructionKind NSXMLProcessingInstructionKind;
+alias NSXMLNodeKind.NSXMLCommentKind NSXMLCommentKind;
+alias NSXMLNodeKind.NSXMLTextKind NSXMLTextKind;
+alias NSXMLNodeKind.NSXMLDTDKind NSXMLDTDKind;
+alias NSXMLNodeKind.NSXMLEntityDeclarationKind NSXMLEntityDeclarationKind;
+alias NSXMLNodeKind.NSXMLAttributeDeclarationKind NSXMLAttributeDeclarationKind;
+alias NSXMLNodeKind.NSXMLElementDeclarationKind NSXMLElementDeclarationKind;
+alias NSXMLNodeKind.NSXMLNotationDeclarationKind NSXMLNotationDeclarationKind;
+
+public class NSXMLNode : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public static id DTDNodeWithXMLString (NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_DTDNodeWithXMLString_1, string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString URI ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_URI);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString XMLString ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_XMLString);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString XMLStringWithOptions (NSUInteger options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_XMLStringWithOptions_1, options);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString XPath ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_XPath);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id static_attributeWithName_URI_stringValue_ (NSString name, NSString URI, NSString stringValue)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_attributeWithName_1URI_1stringValue_1, name !is null ? name.id : null,
+                URI !is null ? URI.id : null, stringValue !is null ? stringValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_attributeWithName_stringValue_ (NSString name, NSString stringValue)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_attributeWithName_1stringValue_1, name !is null ? name.id : null,
+                stringValue !is null ? stringValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString canonicalXMLStringPreservingComments (bool comments)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_canonicalXMLStringPreservingComments_1, comments);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSXMLNode childAtIndex (NSUInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_childAtIndex_1, index);
+        return result is this.id ? this : (result !is null ? new NSXMLNode(result) : null);
+    }
+
+    public NSUInteger childCount ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_childCount);
+    }
+
+    public NSArray children ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_children);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public static id commentWithStringValue (NSString stringValue)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_commentWithStringValue_1, stringValue !is null ? stringValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString description ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void detach ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_detach);
+    }
+
+    public static id document ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_document);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id documentWithRootElement (NSXMLElement element)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_documentWithRootElement_1, element !is null ? element.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_elementWithName_ (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_elementWithName_1, name !is null ? name.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_elementWithName_URI_ (NSString name, NSString URI)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_elementWithName_1URI_1, name !is null ? name.id : null,
+                URI !is null ? URI.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_elementWithName_children_attributes_ (NSString name, NSArray children, NSArray attributes)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_elementWithName_1children_1attributes_1, name !is null ? name.id : null,
+                children !is null ? children.id : null, attributes !is null ? attributes.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_elementWithName_stringValue_ (NSString name, NSString string)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_elementWithName_1stringValue_1, name !is null ? name.id : null,
+                string !is null ? string.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSUInteger index ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_index);
+    }
+
+    public id initWithKind_ (NSXMLNodeKind kind)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithKind_1, kind);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithKind_options_ (NSXMLNodeKind kind, NSUInteger options)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithKind_1options_1, kind, options);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSXMLNodeKind kind ()
+    {
+        return cast(NSXMLNodeKind) OS.objc_msgSend(this.id, OS.sel_kind);
+    }
+
+    public NSUInteger level ()
+    {
+        return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_level);
+    }
+
+    public NSString localName ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_localName);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString localNameForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_localNameForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSString name ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_name);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id namespaceWithName (NSString name, NSString stringValue)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_namespaceWithName_1stringValue_1, name !is null ? name.id : null,
+                stringValue !is null ? stringValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSXMLNode nextNode ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextNode);
+        return result is this.id ? this : (result !is null ? new NSXMLNode(result) : null);
+    }
+
+    public NSXMLNode nextSibling ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nextSibling);
+        return result is this.id ? this : (result !is null ? new NSXMLNode(result) : null);
+    }
+
+    public NSArray nodesForXPath (NSString xpath, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nodesForXPath_1error_1, xpath !is null ? xpath.id : null, error);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public id objectValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray objectsForXQuery_constants_error_ (NSString xquery, NSDictionary constants, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsForXQuery_1constants_1error_1, xquery !is null ? xquery.id : null,
+                constants !is null ? constants.id : null, error);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSArray objectsForXQuery_error_ (NSString xquery, /*NSError** */objc.id** error)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsForXQuery_1error_1, xquery !is null ? xquery.id : null, error);
+        return result !is null ? new NSArray(result) : null;
+    }
+
+    public NSXMLNode parent ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parent);
+        return result is this.id ? this : (result !is null ? new NSXMLNode(result) : null);
+    }
+
+    public static NSXMLNode predefinedNamespaceForPrefix (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_predefinedNamespaceForPrefix_1, name !is null ? name.id : null);
+        return result !is null ? new NSXMLNode(result) : null;
+    }
+
+    public NSString prefix ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_prefix);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static NSString prefixForName (NSString name)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_prefixForName_1, name !is null ? name.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSXMLNode previousNode ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_previousNode);
+        return result is this.id ? this : (result !is null ? new NSXMLNode(result) : null);
+    }
+
+    public NSXMLNode previousSibling ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_previousSibling);
+        return result is this.id ? this : (result !is null ? new NSXMLNode(result) : null);
+    }
+
+    public static id processingInstructionWithName (NSString name, NSString stringValue)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_processingInstructionWithName_1stringValue_1, name !is null ? name.id : null,
+                stringValue !is null ? stringValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSXMLDocument rootDocument ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_rootDocument);
+        return result !is null ? new NSXMLDocument(result) : null;
+    }
+
+    public void setName (NSString name)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setName_1, name !is null ? name.id : null);
+    }
+
+    public void setObjectValue (id value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setObjectValue_1, value !is null ? value.id : null);
+    }
+
+    public void setStringValue_ (NSString string)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStringValue_1, string !is null ? string.id : null);
+    }
+
+    public void setStringValue_resolvingEntities_ (NSString string, bool resolve)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setStringValue_1resolvingEntities_1, string !is null ? string.id : null, resolve);
+    }
+
+    public void setURI (NSString URI)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setURI_1, URI !is null ? URI.id : null);
+    }
+
+    public NSString stringValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_stringValue);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public static id textWithStringValue (NSString stringValue)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSXMLNode, OS.sel_textWithStringValue_1, stringValue !is null ? stringValue.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSXMLParser.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSXMLParser;
+
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSError;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSXMLParser : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void abortParsing ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_abortParsing);
+    }
+
+    public NSInteger columnNumber ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_columnNumber);
+    }
+
+    public id delegatee ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id initWithData (NSData data)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSInteger lineNumber ()
+    {
+        return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_lineNumber);
+    }
+
+    public bool parse ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_parse) !is null;
+    }
+
+    public NSError parserError ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_parserError);
+        return result !is null ? new NSError(result) : null;
+    }
+
+    public NSString publicID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_publicID);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public void setDelegate (id delegatee)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id : null);
+    }
+
+    public void setShouldProcessNamespaces (bool shouldProcessNamespaces)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldProcessNamespaces_1, shouldProcessNamespaces);
+    }
+
+    public void setShouldReportNamespacePrefixes (bool shouldReportNamespacePrefixes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldReportNamespacePrefixes_1, shouldReportNamespacePrefixes);
+    }
+
+    public void setShouldResolveExternalEntities (bool shouldResolveExternalEntities)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setShouldResolveExternalEntities_1, shouldResolveExternalEntities);
+    }
+
+    public bool shouldProcessNamespaces ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldProcessNamespaces) !is null;
+    }
+
+    public bool shouldReportNamespacePrefixes ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldReportNamespacePrefixes) !is null;
+    }
+
+    public bool shouldResolveExternalEntities ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_shouldResolveExternalEntities) !is null;
+    }
+
+    public NSString systemID ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_systemID);
+        return result !is null ? new NSString(result) : null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSZone.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,10 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 23, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.NSZone;
+
+alias void* NSZone;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/OS.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,10140 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.OS;
+
+import tango.stdc.string;
+
+import dwt.dwthelper.utils;
+import dwt.internal.C;
+import dwt.internal.Library;
+import dwt.internal.Platform;
+
+import dwt.internal.c.qd.Quickdraw;
+//import dwt.internal.cocoa.NSString;
+import dwt.internal.objc.runtime;
+import dwt.internal.objc.cocoa.Cocoa;
+
+public class OS : C
+{   
+    /*static this ()
+    {
+        Library.loadLibrary("swt-pi"); //$NON-NLS-1$
+    }*/
+
+    public static const int VERSION;
+
+    static this ()
+    {
+        int[] response = new int[1];
+        OS.Gestalt(OS.gestaltSystemVersion, response);
+        VERSION = response[0] & 0xffff;
+    }
+    
+    //TODO - don't hard code
+    public static const int PTR_SIZEOF = size_t.sizeof;
+    
+    public static const int gestaltSystemVersion = ('s'<<24) + ('y'<<16) + ('s'<<8) + 'v';
+    public static const int noErr = 0;
+    public static const int kProcessTransformToForegroundApplication = 1;
+    public static const int kAlertCautionIcon = ('c'<<24) + ('a'<<16) + ('u'<<8) + 't';
+    public static const int kAlertNoteIcon = ('n'<<24) + ('o'<<16) + ('t'<<8) + 'e';
+    public static const int kAlertStopIcon = ('s'<<24) + ('t'<<16) + ('o'<<8) + 'p';
+
+    public static /*const*/ string sel_sendSelection = sel_registerName("sendSelection");
+    public static /*const*/ string sel_sendDoubleSelection = sel_registerName("sendDoubleSelection");
+    public static /*const*/ string sel_sendArrowSelection = sel_registerName("sendArrowSelection");
+    public static /*const*/ string sel_sendVerticalSelection = sel_registerName("sendVerticalSelection");
+    public static /*const*/ string sel_sendHorizontalSelection = sel_registerName("sendHorizontalSelection");
+    public static /*const*/ string sel_drawAtPoint_ = sel_registerName("drawAtPoint:");
+    public static /*const*/ string sel_timerProc_1 = sel_registerName("timerProc:");
+    
+    /** QuickDraw calls */
+    static mixin Quickdraw;
+    
+    public static const int kQDParseRegionFromTop = (1 << 0);
+    public static const int kQDParseRegionFromBottom = (1 << 1);
+    public static const int kQDParseRegionFromLeft = (1 << 2);
+    public static const int kQDParseRegionFromRight = (1 << 3);
+    public static const int kQDParseRegionFromTopLeft = kQDParseRegionFromTop | kQDParseRegionFromLeft;
+    public static const int kQDRegionToRectsMsgParse = 2;
+    
+    static mixin Runtime;
+
+    /** Classes */
+    public static /*const*/ id class_NSScanner = objc_getClass("NSScanner");
+    public static /*const*/ id class_NSCIImageRep = objc_getClass("NSCIImageRep");
+    public static /*const*/ id class_NSPathControl = objc_getClass("NSPathControl");
+    public static /*const*/ id class_NSTreeController = objc_getClass("NSTreeController");
+    public static /*const*/ id class_NSPDFImageRep = objc_getClass("NSPDFImageRep");
+    public static /*const*/ id class_NSPageLayout = objc_getClass("NSPageLayout");
+    public static /*const*/ id class_NSMetadataQueryAttributeValueTuple = objc_getClass("NSMetadataQueryAttributeValueTuple");
+    public static /*const*/ id class_NSAppleScript = objc_getClass("NSAppleScript");
+    public static /*const*/ id class_NSGradient = objc_getClass("NSGradient");
+    public static /*const*/ id class_NSColorPanel = objc_getClass("NSColorPanel");
+    public static /*const*/ id class_NSPrinter = objc_getClass("NSPrinter");
+    public static /*const*/ id class_NSCachedURLResponse = objc_getClass("NSCachedURLResponse");
+    public static /*const*/ id class_NSLevelIndicatorCell = objc_getClass("NSLevelIndicatorCell");
+    public static /*const*/ id class_NSScriptClassDescription = objc_getClass("NSScriptClassDescription");
+    public static /*const*/ id class_NSDistantObjectRequest = objc_getClass("NSDistantObjectRequest");
+    public static /*const*/ id class_NSOpenPanel = objc_getClass("NSOpenPanel");
+    public static /*const*/ id class_NSOperationQueue = objc_getClass("NSOperationQueue");
+    public static /*const*/ id class_NSOpenGLPixelBuffer = objc_getClass("NSOpenGLPixelBuffer");
+    public static /*const*/ id class_NSRelativeSpecifier = objc_getClass("NSRelativeSpecifier");
+    public static /*const*/ id class_NSTextStorage = objc_getClass("NSTextStorage");
+    public static /*const*/ id class_NSPopUpButtonCell = objc_getClass("NSPopUpButtonCell");
+    public static /*const*/ id class_NSTextContainer = objc_getClass("NSTextContainer");
+    public static /*const*/ id class_NSStepperCell = objc_getClass("NSStepperCell");
+    public static /*const*/ id class_NSTextTable = objc_getClass("NSTextTable");
+    public static /*const*/ id class_NSInvocationOperation = objc_getClass("NSInvocationOperation");
+    public static /*const*/ id class_NSDeleteCommand = objc_getClass("NSDeleteCommand");
+    public static /*const*/ id class_NSImageView = objc_getClass("NSImageView");
+    public static /*const*/ id class_NSMovieView = objc_getClass("NSMovieView");
+    public static /*const*/ id class_NSLock = objc_getClass("NSLock");
+    public static /*const*/ id class_NSCoder = objc_getClass("NSCoder");
+    public static /*const*/ id class_NSXMLElement = objc_getClass("NSXMLElement");
+    public static /*const*/ id class_NSLayoutManager = objc_getClass("NSLayoutManager");
+    public static /*const*/ id class_NSTabView = objc_getClass("NSTabView");
+    public static /*const*/ id class_NSSpeechRecognizer = objc_getClass("NSSpeechRecognizer");
+    public static /*const*/ id class_NSAttributedString = objc_getClass("NSAttributedString");
+    public static /*const*/ id class_NSProcessInfo = objc_getClass("NSProcessInfo");
+    public static /*const*/ id class_NSTextFieldCell = objc_getClass("NSTextFieldCell");
+    public static /*const*/ id class_NSDate = objc_getClass("NSDate");
+    public static /*const*/ id class_NSMachBootstrapServer = objc_getClass("NSMachBootstrapServer");
+    public static /*const*/ id class_NSData = objc_getClass("NSData");
+    public static /*const*/ id class_NSNumberFormatter = objc_getClass("NSNumberFormatter");
+    public static /*const*/ id class_NSPositionalSpecifier = objc_getClass("NSPositionalSpecifier");
+    public static /*const*/ id class_NSSegmentedControl = objc_getClass("NSSegmentedControl");
+    public static /*const*/ id class_NSMatrix = objc_getClass("NSMatrix");
+    public static /*const*/ id class_NSPanel = objc_getClass("NSPanel");
+    public static /*const*/ id class_NSPrintInfo = objc_getClass("NSPrintInfo");
+    public static /*const*/ id class_NSResponder = objc_getClass("NSResponder");
+    public static /*const*/ id class_NSNull = objc_getClass("NSNull");
+    public static /*const*/ id class_NSRunLoop = objc_getClass("NSRunLoop");
+    public static /*const*/ id class_NSMutableAttributedString = objc_getClass("NSMutableAttributedString");
+    public static /*const*/ id class_NSImageCell = objc_getClass("NSImageCell");
+    public static /*const*/ id class_CIColor = objc_getClass("CIColor");
+    public static /*const*/ id class_NSSegmentedCell = objc_getClass("NSSegmentedCell");
+    public static /*const*/ id class_NSDocument = objc_getClass("NSDocument");
+    public static /*const*/ id class_NSTextTab = objc_getClass("NSTextTab");
+    public static /*const*/ id class_NSWhoseSpecifier = objc_getClass("NSWhoseSpecifier");
+    public static /*const*/ id class_NSMenu = objc_getClass("NSMenu");
+    public static /*const*/ id class_NSPopUpButton = objc_getClass("NSPopUpButton");
+    public static /*const*/ id class_NSInvocation = objc_getClass("NSInvocation");
+    public static /*const*/ id class_NSDatePicker = objc_getClass("NSDatePicker");
+    public static /*const*/ id class_NSSliderCell = objc_getClass("NSSliderCell");
+    public static /*const*/ id class_NSURLCache = objc_getClass("NSURLCache");
+    public static /*const*/ id class_NSSpeechSynthesizer = objc_getClass("NSSpeechSynthesizer");
+    public static /*const*/ id class_NSBezierPath = objc_getClass("NSBezierPath");
+    public static /*const*/ id class_NSSavePanel = objc_getClass("NSSavePanel");
+    public static /*const*/ id class_NSMetadataQuery = objc_getClass("NSMetadataQuery");
+    public static /*const*/ id class_NSLogicalTest = objc_getClass("NSLogicalTest");
+    public static /*const*/ id class_NSAffineTransform = objc_getClass("NSAffineTransform");
+    public static /*const*/ id class_NSTreeNode = objc_getClass("NSTreeNode");
+    public static /*const*/ id class_NSControl = objc_getClass("NSControl");
+    public static /*const*/ id class_NSWindowController = objc_getClass("NSWindowController");
+    public static /*const*/ id class_NSURLResponse = objc_getClass("NSURLResponse");
+    public static /*const*/ id class_NSFormatter = objc_getClass("NSFormatter");
+    public static /*const*/ id class_NSAssertionHandler = objc_getClass("NSAssertionHandler");
+    public static /*const*/ id class_NSPort = objc_getClass("NSPort");
+    public static /*const*/ id class_NSURLProtectionSpace = objc_getClass("NSURLProtectionSpace");
+    public static /*const*/ id class_NSPredicate = objc_getClass("NSPredicate");
+    public static /*const*/ id class_NSIndexSpecifier = objc_getClass("NSIndexSpecifier");
+    public static /*const*/ id class_NSPortMessage = objc_getClass("NSPortMessage");
+    public static /*const*/ id class_NSTypesetter = objc_getClass("NSTypesetter");
+    public static /*const*/ id class_NSCompoundPredicate = objc_getClass("NSCompoundPredicate");
+    public static /*const*/ id class_NSBundle = objc_getClass("NSBundle");
+    public static /*const*/ id class_NSSortDescriptor = objc_getClass("NSSortDescriptor");
+    public static /*const*/ id class_NSFontManager = objc_getClass("NSFontManager");
+    public static /*const*/ id class_NSProxy = objc_getClass("NSProxy");
+    public static /*const*/ id class_NSTextView = objc_getClass("NSTextView");
+    public static /*const*/ id class_NSMutableSet = objc_getClass("NSMutableSet");
+    public static /*const*/ id class_NSDatePickerCell = objc_getClass("NSDatePickerCell");
+    public static /*const*/ id class_NSStatusItem = objc_getClass("NSStatusItem");
+    public static /*const*/ id class_NSDirectoryEnumerator = objc_getClass("NSDirectoryEnumerator");
+    public static /*const*/ id class_NSPropertyListSerialization = objc_getClass("NSPropertyListSerialization");
+    public static /*const*/ id class_NSHost = objc_getClass("NSHost");
+    public static /*const*/ id class_NSPipe = objc_getClass("NSPipe");
+    public static /*const*/ id class_NSNibConnector = objc_getClass("NSNibConnector");
+    public static /*const*/ id class_NSDecimalNumber = objc_getClass("NSDecimalNumber");
+    public static /*const*/ id class_NSMenuView = objc_getClass("NSMenuView");
+    public static /*const*/ id class_NSMenuItem = objc_getClass("NSMenuItem");
+    public static /*const*/ id class_NSPICTImageRep = objc_getClass("NSPICTImageRep");
+    public static /*const*/ id class_NSPasteboard = objc_getClass("NSPasteboard");
+    public static /*const*/ id class_NSScriptExecutionContext = objc_getClass("NSScriptExecutionContext");
+    public static /*const*/ id class_NSNotificationQueue = objc_getClass("NSNotificationQueue");
+    public static /*const*/ id class_NSError = objc_getClass("NSError");
+    public static /*const*/ id class_NSNib = objc_getClass("NSNib");
+    public static /*const*/ id class_NSAppleEventManager = objc_getClass("NSAppleEventManager");
+    public static /*const*/ id class_NSCondition = objc_getClass("NSCondition");
+    public static /*const*/ id class_NSBrowser = objc_getClass("NSBrowser");
+    public static /*const*/ id class_NSDocumentController = objc_getClass("NSDocumentController");
+    public static /*const*/ id class_NSMethodSignature = objc_getClass("NSMethodSignature");
+    public static /*const*/ id class_NSTextList = objc_getClass("NSTextList");
+    public static /*const*/ id class_NSURLCredentialStorage = objc_getClass("NSURLCredentialStorage");
+    public static /*const*/ id class_NSEvent = objc_getClass("NSEvent");
+    public static /*const*/ id class_NSScreen = objc_getClass("NSScreen");
+    public static /*const*/ id class_NSMutableCharacterSet = objc_getClass("NSMutableCharacterSet");
+    public static /*const*/ id class_NSSecureTextFieldCell = objc_getClass("NSSecureTextFieldCell");
+    public static /*const*/ id class_NSOpenGLPixelFormat = objc_getClass("NSOpenGLPixelFormat");
+    public static /*const*/ id class_NSInputServer = objc_getClass("NSInputServer");
+    public static /*const*/ id class_NSNotification = objc_getClass("NSNotification");
+    public static /*const*/ id class_NSSpecifierTest = objc_getClass("NSSpecifierTest");
+    public static /*const*/ id class_NSCustomImageRep = objc_getClass("NSCustomImageRep");
+    public static /*const*/ id class_NSParagraphStyle = objc_getClass("NSParagraphStyle");
+    public static /*const*/ id class_NSTableView = objc_getClass("NSTableView");
+    public static /*const*/ id class_NSFileWrapper = objc_getClass("NSFileWrapper");
+    public static /*const*/ id class_NSNotificationCenter = objc_getClass("NSNotificationCenter");
+    public static /*const*/ id class_NSMutableString = objc_getClass("NSMutableString");
+    public static /*const*/ id class_NSFontPanel = objc_getClass("NSFontPanel");
+    public static /*const*/ id class_NSAppleEventDescriptor = objc_getClass("NSAppleEventDescriptor");
+    public static /*const*/ id class_NSConnection = objc_getClass("NSConnection");
+    public static /*const*/ id class_NSURLDownload = objc_getClass("NSURLDownload");
+    public static /*const*/ id class_NSKeyedUnarchiver = objc_getClass("NSKeyedUnarchiver");
+    public static /*const*/ id class_NSCountedSet = objc_getClass("NSCountedSet");
+    public static /*const*/ id class_NSSlider = objc_getClass("NSSlider");
+    public static /*const*/ id class_NSCharacterSet = objc_getClass("NSCharacterSet");
+    public static /*const*/ id class_NSDictionary = objc_getClass("NSDictionary");
+    public static /*const*/ id class_NSOpenGLContext = objc_getClass("NSOpenGLContext");
+    public static /*const*/ id class_NSCachedImageRep = objc_getClass("NSCachedImageRep");
+    public static /*const*/ id class_NSURL = objc_getClass("NSURL");
+    public static /*const*/ id class_NSInputStream = objc_getClass("NSInputStream");
+    public static /*const*/ id class_NSMutableURLRequest = objc_getClass("NSMutableURLRequest");
+    public static /*const*/ id class_NSURLConnection = objc_getClass("NSURLConnection");
+    public static /*const*/ id class_NSPersistentDocument = objc_getClass("NSPersistentDocument");
+    public static /*const*/ id class_NSClipView = objc_getClass("NSClipView");
+    public static /*const*/ id class_NSScriptSuiteRegistry = objc_getClass("NSScriptSuiteRegistry");
+    public static /*const*/ id class_NSStepper = objc_getClass("NSStepper");
+    public static /*const*/ id class_NSXMLNode = objc_getClass("NSXMLNode");
+    public static /*const*/ id class_NSHTTPCookie = objc_getClass("NSHTTPCookie");
+    public static /*const*/ id class_NSMetadataQueryResultGroup = objc_getClass("NSMetadataQueryResultGroup");
+    public static /*const*/ id class_NSURLCredential = objc_getClass("NSURLCredential");
+    public static /*const*/ id class_NSHashTable = objc_getClass("NSHashTable");
+    public static /*const*/ id class_NSColor = objc_getClass("NSColor");
+    public static /*const*/ id class_NSPathComponentCell = objc_getClass("NSPathComponentCell");
+    public static /*const*/ id class_NSToolbar = objc_getClass("NSToolbar");
+    public static /*const*/ id class_NSUndoManager = objc_getClass("NSUndoManager");
+    public static /*const*/ id class_NSNibControlConnector = objc_getClass("NSNibControlConnector");
+    public static /*const*/ id class_NSFontDescriptor = objc_getClass("NSFontDescriptor");
+    public static /*const*/ id class_NSSpellChecker = objc_getClass("NSSpellChecker");
+    public static /*const*/ id class_NSTableColumn = objc_getClass("NSTableColumn");
+    public static /*const*/ id class_NSSpellServer = objc_getClass("NSSpellServer");
+    public static /*const*/ id class_NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
+    public static /*const*/ id class_NSUnarchiver = objc_getClass("NSUnarchiver");
+    public static /*const*/ id class_NSColorSpace = objc_getClass("NSColorSpace");
+    public static /*const*/ id class_NSQuickDrawView = objc_getClass("NSQuickDrawView");
+    public static /*const*/ id class_NSDrawer = objc_getClass("NSDrawer");
+    public static /*const*/ id class_NSFileHandle = objc_getClass("NSFileHandle");
+    public static /*const*/ id class_NSCalendarDate = objc_getClass("NSCalendarDate");
+    public static /*const*/ id class_NSThread = objc_getClass("NSThread");
+    public static /*const*/ id class_NSProtocolChecker = objc_getClass("NSProtocolChecker");
+    public static /*const*/ id class_NSDateComponents = objc_getClass("NSDateComponents");
+    public static /*const*/ id class_NSAnimationContext = objc_getClass("NSAnimationContext");
+    public static /*const*/ id class_NSURLRequest = objc_getClass("NSURLRequest");
+    public static /*const*/ id class_NSViewAnimation = objc_getClass("NSViewAnimation");
+    public static /*const*/ id class_NSScriptObjectSpecifier = objc_getClass("NSScriptObjectSpecifier");
+    public static /*const*/ id class_NSCell = objc_getClass("NSCell");
+    public static /*const*/ id class_NSTableHeaderCell = objc_getClass("NSTableHeaderCell");
+    public static /*const*/ id class_NSATSTypesetter = objc_getClass("NSATSTypesetter");
+    public static /*const*/ id class_NSNetService = objc_getClass("NSNetService");
+    public static /*const*/ id class_NSMutableParagraphStyle = objc_getClass("NSMutableParagraphStyle");
+    public static /*const*/ id class_NSButton = objc_getClass("NSButton");
+    public static /*const*/ id class_NSAnimation = objc_getClass("NSAnimation");
+    public static /*const*/ id class_NSText = objc_getClass("NSText");
+    public static /*const*/ id class_NSMapTable = objc_getClass("NSMapTable");
+    public static /*const*/ id class_NSDictionaryController = objc_getClass("NSDictionaryController");
+    public static /*const*/ id class_NSTrackingArea = objc_getClass("NSTrackingArea");
+    public static /*const*/ id class_NSURLProtocol = objc_getClass("NSURLProtocol");
+    public static /*const*/ id class_NSGlyphInfo = objc_getClass("NSGlyphInfo");
+    public static /*const*/ id class_NSSocketPortNameServer = objc_getClass("NSSocketPortNameServer");
+    public static /*const*/ id class_NSQuitCommand = objc_getClass("NSQuitCommand");
+    public static /*const*/ id class_NSDistributedNotificationCenter = objc_getClass("NSDistributedNotificationCenter");
+    public static /*const*/ id class_NSCloseCommand = objc_getClass("NSCloseCommand");
+    public static /*const*/ id class_NSPrintOperation = objc_getClass("NSPrintOperation");
+    public static /*const*/ id class_NSGraphicsContext = objc_getClass("NSGraphicsContext");
+    public static /*const*/ id class_NSNumber = objc_getClass("NSNumber");
+    public static /*const*/ id class_NSPortCoder = objc_getClass("NSPortCoder");
+    public static /*const*/ id class_NSTextTableBlock = objc_getClass("NSTextTableBlock");
+    public static /*const*/ id class_NSNibOutletConnector = objc_getClass("NSNibOutletConnector");
+    public static /*const*/ id class_NSLocale = objc_getClass("NSLocale");
+    public static /*const*/ id class_NSTableHeaderView = objc_getClass("NSTableHeaderView");
+    public static /*const*/ id class_NSScriptWhoseTest = objc_getClass("NSScriptWhoseTest");
+    public static /*const*/ id class_NSNetServiceBrowser = objc_getClass("NSNetServiceBrowser");
+    public static /*const*/ id class_NSConditionLock = objc_getClass("NSConditionLock");
+    public static /*const*/ id class_NSTimeZone = objc_getClass("NSTimeZone");
+    public static /*const*/ id class_NSComparisonPredicate = objc_getClass("NSComparisonPredicate");
+    public static /*const*/ id class_NSScriptCoercionHandler = objc_getClass("NSScriptCoercionHandler");
+    public static /*const*/ id class_NSFileManager = objc_getClass("NSFileManager");
+    public static /*const*/ id class_NSPredicateEditorRowTemplate = objc_getClass("NSPredicateEditorRowTemplate");
+    public static /*const*/ id class_NSString = objc_getClass("NSString");
+    public static /*const*/ id class_NSToolbarItem = objc_getClass("NSToolbarItem");
+    public static /*const*/ id class_NSPointerArray = objc_getClass("NSPointerArray");
+    public static /*const*/ id class_NSURLAuthenticationChallenge = objc_getClass("NSURLAuthenticationChallenge");
+    public static /*const*/ id class_NSStatusBar = objc_getClass("NSStatusBar");
+    public static /*const*/ id class_NSTextField = objc_getClass("NSTextField");
+    public static /*const*/ id class_NSSecureTextField = objc_getClass("NSSecureTextField");
+    public static /*const*/ id class_NSOutputStream = objc_getClass("NSOutputStream");
+    public static /*const*/ id class_NSComboBoxCell = objc_getClass("NSComboBoxCell");
+    public static /*const*/ id class_NSXMLDTDNode = objc_getClass("NSXMLDTDNode");
+    public static /*const*/ id class_NSMessagePortNameServer = objc_getClass("NSMessagePortNameServer");
+    public static /*const*/ id class_NSHTTPCookieStorage = objc_getClass("NSHTTPCookieStorage");
+    public static /*const*/ id class_NSActionCell = objc_getClass("NSActionCell");
+    public static /*const*/ id class_NSXMLDocument = objc_getClass("NSXMLDocument");
+    public static /*const*/ id class_NSBitmapImageRep = objc_getClass("NSBitmapImageRep");
+    public static /*const*/ id class_NSHTTPURLResponse = objc_getClass("NSHTTPURLResponse");
+    public static /*const*/ id class_NSImage = objc_getClass("NSImage");
+    public static /*const*/ id class_NSIndexSet = objc_getClass("NSIndexSet");
+    public static /*const*/ id class_NSRangeSpecifier = objc_getClass("NSRangeSpecifier");
+    public static /*const*/ id class_NSGlyphGenerator = objc_getClass("NSGlyphGenerator");
+    public static /*const*/ id class_NSFormCell = objc_getClass("NSFormCell");
+    public static /*const*/ id class_NSScroller = objc_getClass("NSScroller");
+    public static /*const*/ id class_NSMetadataItem = objc_getClass("NSMetadataItem");
+    public static /*const*/ id class_NSStream = objc_getClass("NSStream");
+    public static /*const*/ id class_NSClassDescription = objc_getClass("NSClassDescription");
+    public static /*const*/ id class_NSMutableIndexSet = objc_getClass("NSMutableIndexSet");
+    public static /*const*/ id class_NSView = objc_getClass("NSView");
+    public static /*const*/ id class_NSUserDefaults = objc_getClass("NSUserDefaults");
+    public static /*const*/ id class_NSSetCommand = objc_getClass("NSSetCommand");
+    public static /*const*/ id class_NSPathCell = objc_getClass("NSPathCell");
+    public static /*const*/ id class_NSMoveCommand = objc_getClass("NSMoveCommand");
+    public static /*const*/ id class_NSSplitView = objc_getClass("NSSplitView");
+    public static /*const*/ id class_NSTextBlock = objc_getClass("NSTextBlock");
+    public static /*const*/ id class_NSTabViewItem = objc_getClass("NSTabViewItem");
+    public static /*const*/ id class_NSCollectionViewItem = objc_getClass("NSCollectionViewItem");
+    public static /*const*/ id class_NSValue = objc_getClass("NSValue");
+    public static /*const*/ id class_NSHelpManager = objc_getClass("NSHelpManager");
+    public static /*const*/ id class_NSEnumerator = objc_getClass("NSEnumerator");
+    public static /*const*/ id class_NSDistantObject = objc_getClass("NSDistantObject");
+    public static /*const*/ id class_NSGarbageCollector = objc_getClass("NSGarbageCollector");
+    public static /*const*/ id class_NSXMLParser = objc_getClass("NSXMLParser");
+    public static /*const*/ id class_NSFont = objc_getClass("NSFont");
+    public static /*const*/ id class_NSAlert = objc_getClass("NSAlert");
+    public static /*const*/ id class_NSUniqueIDSpecifier = objc_getClass("NSUniqueIDSpecifier");
+    public static /*const*/ id class_NSOutlineView = objc_getClass("NSOutlineView");
+    public static /*const*/ id class_NSProgressIndicator = objc_getClass("NSProgressIndicator");
+    public static /*const*/ id class_NSController = objc_getClass("NSController");
+    public static /*const*/ id class_NSComboBox = objc_getClass("NSComboBox");
+    public static /*const*/ id class_NSArrayController = objc_getClass("NSArrayController");
+    public static /*const*/ id class_NSKeyedArchiver = objc_getClass("NSKeyedArchiver");
+    public static /*const*/ id class_NSDecimalNumberHandler = objc_getClass("NSDecimalNumberHandler");
+    public static /*const*/ id class_NSObject = objc_getClass("NSObject");
+    public static /*const*/ id class_NSNameSpecifier = objc_getClass("NSNameSpecifier");
+    public static /*const*/ id class_NSUserDefaultsController = objc_getClass("NSUserDefaultsController");
+    public static /*const*/ id class_NSLevelIndicator = objc_getClass("NSLevelIndicator");
+    public static /*const*/ id class_NSDistributedLock = objc_getClass("NSDistributedLock");
+    public static /*const*/ id class_NSTokenFieldCell = objc_getClass("NSTokenFieldCell");
+    public static /*const*/ id class_NSSet = objc_getClass("NSSet");
+    public static /*const*/ id class_NSMutableData = objc_getClass("NSMutableData");
+    public static /*const*/ id class_NSArray = objc_getClass("NSArray");
+    public static /*const*/ id class_NSExpression = objc_getClass("NSExpression");
+    public static /*const*/ id class_NSMenuItemCell = objc_getClass("NSMenuItemCell");
+    public static /*const*/ id class_NSColorPicker = objc_getClass("NSColorPicker");
+    public static /*const*/ id class_NSForm = objc_getClass("NSForm");
+    public static /*const*/ id class_NSApplication = objc_getClass("NSApplication");
+    public static /*const*/ id class_NSInputManager = objc_getClass("NSInputManager");
+    public static /*const*/ id class_NSPointerFunctions = objc_getClass("NSPointerFunctions");
+    public static /*const*/ id class_NSRecursiveLock = objc_getClass("NSRecursiveLock");
+    public static /*const*/ id class_NSBox = objc_getClass("NSBox");
+    public static /*const*/ id class_NSDockTile = objc_getClass("NSDockTile");
+    public static /*const*/ id class_NSTextAttachment = objc_getClass("NSTextAttachment");
+    public static /*const*/ id class_NSIndexPath = objc_getClass("NSIndexPath");
+    public static /*const*/ id class_NSEPSImageRep = objc_getClass("NSEPSImageRep");
+    public static /*const*/ id class_NSBrowserCell = objc_getClass("NSBrowserCell");
+    public static /*const*/ id class_NSValueTransformer = objc_getClass("NSValueTransformer");
+    public static /*const*/ id class_CIImage = objc_getClass("CIImage");
+    public static /*const*/ id class_NSMovie = objc_getClass("NSMovie");
+    public static /*const*/ id class_NSTimer = objc_getClass("NSTimer");
+    public static /*const*/ id class_NSMachPort = objc_getClass("NSMachPort");
+    public static /*const*/ id class_NSCreateCommand = objc_getClass("NSCreateCommand");
+    public static /*const*/ id class_NSPortNameServer = objc_getClass("NSPortNameServer");
+    public static /*const*/ id class_NSRulerMarker = objc_getClass("NSRulerMarker");
+    public static /*const*/ id class_NSImageRep = objc_getClass("NSImageRep");
+    public static /*const*/ id class_NSWindow = objc_getClass("NSWindow");
+    public static /*const*/ id class_NSColorWell = objc_getClass("NSColorWell");
+    public static /*const*/ id class_NSSound = objc_getClass("NSSound");
+    public static /*const*/ id class_NSToolbarItemGroup = objc_getClass("NSToolbarItemGroup");
+    public static /*const*/ id class_NSRulerView = objc_getClass("NSRulerView");
+    public static /*const*/ id class_NSWorkspace = objc_getClass("NSWorkspace");
+    public static /*const*/ id class_NSSearchFieldCell = objc_getClass("NSSearchFieldCell");
+    public static /*const*/ id class_NSMutableArray = objc_getClass("NSMutableArray");
+    public static /*const*/ id class_NSRuleEditor = objc_getClass("NSRuleEditor");
+    public static /*const*/ id class_NSScriptCommandDescription = objc_getClass("NSScriptCommandDescription");
+    public static /*const*/ id class_NSViewController = objc_getClass("NSViewController");
+    public static /*const*/ id class_NSPredicateEditor = objc_getClass("NSPredicateEditor");
+    public static /*const*/ id class_NSCloneCommand = objc_getClass("NSCloneCommand");
+    public static /*const*/ id class_NSOpenGLView = objc_getClass("NSOpenGLView");
+    public static /*const*/ id class_NSCursor = objc_getClass("NSCursor");
+    public static /*const*/ id class_NSSearchField = objc_getClass("NSSearchField");
+    public static /*const*/ id class_NSXMLDTD = objc_getClass("NSXMLDTD");
+    public static /*const*/ id class_NSSocketPort = objc_getClass("NSSocketPort");
+    public static /*const*/ id class_NSObjectController = objc_getClass("NSObjectController");
+    public static /*const*/ id class_NSScriptCommand = objc_getClass("NSScriptCommand");
+    public static /*const*/ id class_NSShadow = objc_getClass("NSShadow");
+    public static /*const*/ id class_NSScrollView = objc_getClass("NSScrollView");
+    public static /*const*/ id class_NSPrintPanel = objc_getClass("NSPrintPanel");
+    public static /*const*/ id class_NSURLHandle = objc_getClass("NSURLHandle");
+    public static /*const*/ id class_NSOperation = objc_getClass("NSOperation");
+    public static /*const*/ id class_NSMutableDictionary = objc_getClass("NSMutableDictionary");
+    public static /*const*/ id class_NSException = objc_getClass("NSException");
+    public static /*const*/ id class_NSButtonCell = objc_getClass("NSButtonCell");
+    public static /*const*/ id class_NSTask = objc_getClass("NSTask");
+    public static /*const*/ id class_NSArchiver = objc_getClass("NSArchiver");
+    public static /*const*/ id class_NSDateFormatter = objc_getClass("NSDateFormatter");
+    public static /*const*/ id class_NSCalendar = objc_getClass("NSCalendar");
+    public static /*const*/ id class_NSTokenField = objc_getClass("NSTokenField");
+    public static /*const*/ id class_NSCollectionView = objc_getClass("NSCollectionView");
+    public static /*const*/ id class_NSColorList = objc_getClass("NSColorList");
+    public static /*const*/ id class_DOMEvent = objc_getClass("DOMEvent");
+    public static /*const*/ id class_DOMWheelEvent = objc_getClass("DOMWheelEvent");
+    public static /*const*/ id class_WebView = objc_getClass("WebView");
+    public static /*const*/ id class_WebPreferences = objc_getClass("WebPreferences");
+    public static /*const*/ id class_WebFrameView = objc_getClass("WebFrameView");
+
+    /** Selectors */
+    public static /*const*/ string sel_inputClientEnabled_1 = sel_registerName("inputClientEnabled:");
+    public static /*const*/ string sel_setVerticalPagination_1 = sel_registerName("setVerticalPagination:");
+    public static /*const*/ string sel_isEqualToHost_1 = sel_registerName("isEqualToHost:");
+    public static /*const*/ string sel_compare_1 = sel_registerName("compare:");
+    public static /*const*/ string sel_printPanel = sel_registerName("printPanel");
+    public static /*const*/ string sel_unregisterImageRepClass_1 = sel_registerName("unregisterImageRepClass:");
+    public static /*const*/ string sel_dataWithLength_1 = sel_registerName("dataWithLength:");
+    public static /*const*/ string sel_dismissPopUp = sel_registerName("dismissPopUp");
+    public static /*const*/ string sel_substituteFontForFont_1 = sel_registerName("substituteFontForFont:");
+    public static /*const*/ string sel_sendAction_1to_1 = sel_registerName("sendAction:to:");
+    public static /*const*/ string sel_rangeOfCharacterFromSet_1options_1range_1 = sel_registerName("rangeOfCharacterFromSet:options:range:");
+    public static /*const*/ string sel_autoupdatingCurrentCalendar = sel_registerName("autoupdatingCurrentCalendar");
+    public static /*const*/ string sel_nextDaylightSavingTimeTransitionAfterDate_1 = sel_registerName("nextDaylightSavingTimeTransitionAfterDate:");
+    public static /*const*/ string sel_attachmentSizeForGlyphAtIndex_1 = sel_registerName("attachmentSizeForGlyphAtIndex:");
+    public static /*const*/ string sel_shouldCollapseAutoExpandedItemsForDeposited_1 = sel_registerName("shouldCollapseAutoExpandedItemsForDeposited:");
+    public static /*const*/ string sel_decimalNumberByRoundingAccordingToBehavior_1 = sel_registerName("decimalNumberByRoundingAccordingToBehavior:");
+    public static /*const*/ string sel_scanHexFloat_1 = sel_registerName("scanHexFloat:");
+    public static /*const*/ string sel_rangesForUserTextChange = sel_registerName("rangesForUserTextChange");
+    public static /*const*/ string sel_indexOfItemWithObjectValue_1 = sel_registerName("indexOfItemWithObjectValue:");
+    public static /*const*/ string sel_sendsSearchStringImmediately = sel_registerName("sendsSearchStringImmediately");
+    public static /*const*/ string sel_isTransparent = sel_registerName("isTransparent");
+    public static /*const*/ string sel_widthOfColumn_1 = sel_registerName("widthOfColumn:");
+    public static /*const*/ string sel_calendarFormat = sel_registerName("calendarFormat");
+    public static /*const*/ string sel_lineBreakByHyphenatingBeforeIndex_1withinRange_1 = sel_registerName("lineBreakByHyphenatingBeforeIndex:withinRange:");
+    public static /*const*/ string sel_parentNode = sel_registerName("parentNode");
+    public static /*const*/ string sel_setDrawsOutsideLineFragment_1forGlyphRange_1 = sel_registerName("setDrawsOutsideLineFragment:forGlyphRange:");
+    public static /*const*/ string sel_negativeSuffix = sel_registerName("negativeSuffix");
+    public static /*const*/ string sel_setFlatness_1 = sel_registerName("setFlatness:");
+    public static /*const*/ string sel_ignoresAlpha = sel_registerName("ignoresAlpha");
+    public static /*const*/ string sel_setValue_1type_1forDimension_1 = sel_registerName("setValue:type:forDimension:");
+    public static /*const*/ string sel_setLayer_1 = sel_registerName("setLayer:");
+    public static /*const*/ string sel_setActionName_1 = sel_registerName("setActionName:");
+    public static /*const*/ string sel_setIcon_1 = sel_registerName("setIcon:");
+    public static /*const*/ string sel_tokenFieldCell_1readFromPasteboard_1 = sel_registerName("tokenFieldCell:readFromPasteboard:");
+    public static /*const*/ string sel_setPropertyList_1forType_1 = sel_registerName("setPropertyList:forType:");
+    public static /*const*/ string sel_endModalSession_1 = sel_registerName("endModalSession:");
+    public static /*const*/ string sel_sharedColorPanel = sel_registerName("sharedColorPanel");
+    public static /*const*/ string sel_contentSizeForFrameSize_1hasHorizontalScroller_1hasVerticalScroller_1borderType_1 = sel_registerName("contentSizeForFrameSize:hasHorizontalScroller:hasVerticalScroller:borderType:");
+    public static /*const*/ string sel_layoutRectForTextBlock_1glyphRange_1 = sel_registerName("layoutRectForTextBlock:glyphRange:");
+    public static /*const*/ string sel_scrollRowToVisible_1 = sel_registerName("scrollRowToVisible:");
+    public static /*const*/ string sel_attributedStringForZero = sel_registerName("attributedStringForZero");
+    public static /*const*/ string sel_showsInvisibleCharacters = sel_registerName("showsInvisibleCharacters");
+    public static /*const*/ string sel_adjustPageWidthNew_1left_1right_1limit_1 = sel_registerName("adjustPageWidthNew:left:right:limit:");
+    public static /*const*/ string sel_client = sel_registerName("client");
+    public static /*const*/ string sel_initWithKey_1ascending_1selector_1 = sel_registerName("initWithKey:ascending:selector:");
+    public static /*const*/ string sel_completedString_1 = sel_registerName("completedString:");
+    public static /*const*/ string sel_bundleForClass_1 = sel_registerName("bundleForClass:");
+    public static /*const*/ string sel_pathControl_1acceptDrop_1 = sel_registerName("pathControl:acceptDrop:");
+    public static /*const*/ string sel_imageRepsWithPasteboard_1 = sel_registerName("imageRepsWithPasteboard:");
+    public static /*const*/ string sel_toolTipForSegment_1 = sel_registerName("toolTipForSegment:");
+    public static /*const*/ string sel_suspended = sel_registerName("suspended");
+    public static /*const*/ string sel_encodeDouble_1forKey_1 = sel_registerName("encodeDouble:forKey:");
+    public static /*const*/ string sel_setNextState = sel_registerName("setNextState");
+    public static /*const*/ string sel_ignoreWord_1inSpellDocumentWithTag_1 = sel_registerName("ignoreWord:inSpellDocumentWithTag:");
+    public static /*const*/ string sel_stopMonitoring = sel_registerName("stopMonitoring");
+    public static /*const*/ string sel_initWithTitle_1action_1keyEquivalent_1 = sel_registerName("initWithTitle:action:keyEquivalent:");
+    public static /*const*/ string sel_setDropRow_1dropOperation_1 = sel_registerName("setDropRow:dropOperation:");
+    public static /*const*/ string sel_contentView = sel_registerName("contentView");
+    public static /*const*/ string sel_setNilSymbol_1 = sel_registerName("setNilSymbol:");
+    public static /*const*/ string sel_removePropertyForKey_1inRequest_1 = sel_registerName("removePropertyForKey:inRequest:");
+    public static /*const*/ string sel_setMarkerLocation_1 = sel_registerName("setMarkerLocation:");
+    public static /*const*/ string sel_resolvedKeyDictionary = sel_registerName("resolvedKeyDictionary");
+    public static /*const*/ string sel_enumeratorAtPath_1 = sel_registerName("enumeratorAtPath:");
+    public static /*const*/ string sel_decodeObjectForKey_1 = sel_registerName("decodeObjectForKey:");
+    public static /*const*/ string sel_loadInForeground = sel_registerName("loadInForeground");
+    public static /*const*/ string sel_baseSpecifier = sel_registerName("baseSpecifier");
+    public static /*const*/ string sel_isMemberOfClass_1 = sel_registerName("isMemberOfClass:");
+    public static /*const*/ string sel_setMaxVisibleColumns_1 = sel_registerName("setMaxVisibleColumns:");
+    public static /*const*/ string sel_unmountAndEjectDeviceAtPath_1 = sel_registerName("unmountAndEjectDeviceAtPath:");
+    public static /*const*/ string sel_openTempFile_1 = sel_registerName("openTempFile:");
+    public static /*const*/ string sel_isRowSelected_1 = sel_registerName("isRowSelected:");
+    public static /*const*/ string sel_insertItemWithItemIdentifier_1atIndex_1 = sel_registerName("insertItemWithItemIdentifier:atIndex:");
+    public static /*const*/ string sel_parserDidEndDocument_1 = sel_registerName("parserDidEndDocument:");
+    public static /*const*/ string sel_reverseTransformedValue_1 = sel_registerName("reverseTransformedValue:");
+    public static /*const*/ string sel_setTimeStyle_1 = sel_registerName("setTimeStyle:");
+    public static /*const*/ string sel_initWithContentsOfFile_1usedEncoding_1error_1 = sel_registerName("initWithContentsOfFile:usedEncoding:error:");
+    public static /*const*/ string sel_endGrouping = sel_registerName("endGrouping");
+    public static /*const*/ string sel_initWithProxyHost_1port_1type_1realm_1authenticationMethod_1 = sel_registerName("initWithProxyHost:port:type:realm:authenticationMethod:");
+    public static /*const*/ string sel_tableView_1dataCellForTableColumn_1row_1 = sel_registerName("tableView:dataCellForTableColumn:row:");
+    public static /*const*/ string sel_convertPoint_1toView_1 = sel_registerName("convertPoint:toView:");
+    public static /*const*/ string sel_setFrame_1display_1animate_1 = sel_registerName("setFrame:display:animate:");
+    public static /*const*/ string sel_exceptionDuringOperation_1error_1leftOperand_1rightOperand_1 = sel_registerName("exceptionDuringOperation:error:leftOperand:rightOperand:");
+    public static /*const*/ string sel_applicationOpenUntitledFile_1 = sel_registerName("applicationOpenUntitledFile:");
+    public static /*const*/ string sel_initWithRootElement_1 = sel_registerName("initWithRootElement:");
+    public static /*const*/ string sel_setHorizontalScroller_1 = sel_registerName("setHorizontalScroller:");
+    public static /*const*/ string sel_constWritePrintInfo = sel_registerName("constWritePrintInfo");
+    public static /*const*/ string sel_addItemWithTitle_1 = sel_registerName("addItemWithTitle:");
+    public static /*const*/ string sel_setColor_1 = sel_registerName("setColor:");
+    public static /*const*/ string sel_isHostCacheEnabled = sel_registerName("isHostCacheEnabled");
+    public static /*const*/ string sel_controlTextDidChange_1 = sel_registerName("controlTextDidChange:");
+    public static /*const*/ string sel_headerLevel = sel_registerName("headerLevel");
+    public static /*const*/ string sel_loadInBackground = sel_registerName("loadInBackground");
+    public static /*const*/ string sel_setNeedsDisplayForItemAtIndex_1 = sel_registerName("setNeedsDisplayForItemAtIndex:");
+    public static /*const*/ string sel_setCellPrototype_1 = sel_registerName("setCellPrototype:");
+    public static /*const*/ string sel_enqueueNotification_1postingStyle_1coalesceMask_1forModes_1 = sel_registerName("enqueueNotification:postingStyle:coalesceMask:forModes:");
+    public static /*const*/ string sel_minColumnWidth = sel_registerName("minColumnWidth");
+    public static /*const*/ string sel_tableView_1shouldTypeSelectForEvent_1withCurrentSearchString_1 = sel_registerName("tableView:shouldTypeSelectForEvent:withCurrentSearchString:");
+    public static /*const*/ string sel_validateValue_1forKey_1error_1 = sel_registerName("validateValue:forKey:error:");
+    public static /*const*/ string sel_canBeConvertedToEncoding_1 = sel_registerName("canBeConvertedToEncoding:");
+    public static /*const*/ string sel_numberOfItems = sel_registerName("numberOfItems");
+    public static /*const*/ string sel_bestRepresentationForDevice_1 = sel_registerName("bestRepresentationForDevice:");
+    public static /*const*/ string sel_setBorderColor_1forEdge_1 = sel_registerName("setBorderColor:forEdge:");
+    public static /*const*/ string sel_setHorizontalLineScroll_1 = sel_registerName("setHorizontalLineScroll:");
+    public static /*const*/ string sel_sharedHTTPCookieStorage = sel_registerName("sharedHTTPCookieStorage");
+    public static /*const*/ string sel_cachesBezierPath = sel_registerName("cachesBezierPath");
+    public static /*const*/ string sel_strokeLineFromPoint_1toPoint_1 = sel_registerName("strokeLineFromPoint:toPoint:");
+    public static /*const*/ string sel_preferredBackingLocation = sel_registerName("preferredBackingLocation");
+    public static /*const*/ string sel_removeRowAtIndex_1 = sel_registerName("removeRowAtIndex:");
+    public static /*const*/ string sel_setCurrentTime_1 = sel_registerName("setCurrentTime:");
+    public static /*const*/ string sel_String = sel_registerName("String");
+    public static /*const*/ string sel_hasVerticalScroller = sel_registerName("hasVerticalScroller");
+    public static /*const*/ string sel_initWithTimeInterval_1sinceDate_1 = sel_registerName("initWithTimeInterval:sinceDate:");
+    public static /*const*/ string sel_showsProgressPanel = sel_registerName("showsProgressPanel");
+    public static /*const*/ string sel_setDirectParameter_1 = sel_registerName("setDirectParameter:");
+    public static /*const*/ string sel_storeCachedResponse_1forRequest_1 = sel_registerName("storeCachedResponse:forRequest:");
+    public static /*const*/ string sel_textUnfilteredPasteboardTypes = sel_registerName("textUnfilteredPasteboardTypes");
+    public static /*const*/ string sel_isDragging = sel_registerName("isDragging");
+    public static /*const*/ string sel_tableView_1shouldTrackCell_1forTableColumn_1row_1 = sel_registerName("tableView:shouldTrackCell:forTableColumn:row:");
+    public static /*const*/ string sel_dictionaryRepresentation = sel_registerName("dictionaryRepresentation");
+    public static /*const*/ string sel_attributesForExtraLineFragment = sel_registerName("attributesForExtraLineFragment");
+    public static /*const*/ string sel_getCharacters_1range_1 = sel_registerName("getCharacters:range:");
+    public static /*const*/ string sel_nibName = sel_registerName("nibName");
+    public static /*const*/ string sel_initWithURL_1options_1documentAttributes_1error_1 = sel_registerName("initWithURL:options:documentAttributes:error:");
+    public static /*const*/ string sel_initWithFrame_1mode_1cellClass_1numberOfRows_1numberOfColumns_1 = sel_registerName("initWithFrame:mode:cellClass:numberOfRows:numberOfColumns:");
+    public static /*const*/ string sel_reflectScrolledClipView_1 = sel_registerName("reflectScrolledClipView:");
+    public static /*const*/ string sel_StringWithContentsOfURL_1usedEncoding_1error_1 = sel_registerName("StringWithContentsOfURL:usedEncoding:error:");
+    public static /*const*/ string sel_displayIfNeededIgnoringOpacity = sel_registerName("displayIfNeededIgnoringOpacity");
+    public static /*const*/ string sel_archiverWillFinish_1 = sel_registerName("archiverWillFinish:");
+    public static /*const*/ string sel_initWithOptions_1 = sel_registerName("initWithOptions:");
+    public static /*const*/ string sel_ruleEditor_1numberOfChildrenForCriterion_1withRowType_1 = sel_registerName("ruleEditor:numberOfChildrenForCriterion:withRowType:");
+    public static /*const*/ string sel_removeColorWithKey_1 = sel_registerName("removeColorWithKey:");
+    public static /*const*/ string sel_setObjectValue_1 = sel_registerName("setObjectValue:");
+    public static /*const*/ string sel_graphicsContextWithGraphicsPort_1flipped_1 = sel_registerName("graphicsContextWithGraphicsPort:flipped:");
+    public static /*const*/ string sel_setMarkedText_1selectedRange_1replacementRange_1 = sel_registerName("setMarkedText:selectedRange:replacementRange:");
+    public static /*const*/ string sel_outlineView_1numberOfChildrenOfItem_1 = sel_registerName("outlineView:numberOfChildrenOfItem:");
+    public static /*const*/ string sel_cellFrameAtRow_1column_1 = sel_registerName("cellFrameAtRow:column:");
+    public static /*const*/ string sel_blueColor = sel_registerName("blueColor");
+    public static /*const*/ string sel_selectedTextBackgroundColor = sel_registerName("selectedTextBackgroundColor");
+    public static /*const*/ string sel_initWithFormat_1locale_1 = sel_registerName("initWithFormat:locale:");
+    public static /*const*/ string sel_propertyListForType_1 = sel_registerName("propertyListForType:");
+    public static /*const*/ string sel_setConfigurationFromDictionary_1 = sel_registerName("setConfigurationFromDictionary:");
+    public static /*const*/ string sel_registerClassDescription_1forClass_1 = sel_registerName("registerClassDescription:forClass:");
+    public static /*const*/ string sel_removeAllItems = sel_registerName("removeAllItems");
+    public static /*const*/ string sel_setFontPanelFactory_1 = sel_registerName("setFontPanelFactory:");
+    public static /*const*/ string sel_didChangeValueForKey_1withSetMutation_1usingObjects_1 = sel_registerName("didChangeValueForKey:withSetMutation:usingObjects:");
+    public static /*const*/ string sel_CGEvent = sel_registerName("CGEvent");
+    public static /*const*/ string sel_disable = sel_registerName("disable");
+    public static /*const*/ string sel_setColumnAutoresizingStyle_1 = sel_registerName("setColumnAutoresizingStyle:");
+    public static /*const*/ string sel_absoluteZ = sel_registerName("absoluteZ");
+    public static /*const*/ string sel_intForKey_1inTable_1 = sel_registerName("intForKey:inTable:");
+    public static /*const*/ string sel_minFrameWidthWithTitle_1styleMask_1 = sel_registerName("minFrameWidthWithTitle:styleMask:");
+    public static /*const*/ string sel_highlightColor = sel_registerName("highlightColor");
+    public static /*const*/ string sel_setRoundingMode_1 = sel_registerName("setRoundingMode:");
+    public static /*const*/ string sel_didChangeValueForKey_1 = sel_registerName("didChangeValueForKey:");
+    public static /*const*/ string sel_setMenuZone_1 = sel_registerName("setMenuZone:");
+    public static /*const*/ string sel_updateFromPrintInfo = sel_registerName("updateFromPrintInfo");
+    public static /*const*/ string sel_setSelectedItemIdentifier_1 = sel_registerName("setSelectedItemIdentifier:");
+    public static /*const*/ string sel_setReplyTimeout_1 = sel_registerName("setReplyTimeout:");
+    public static /*const*/ string sel_showsFirstResponder = sel_registerName("showsFirstResponder");
+    public static /*const*/ string sel_loadNibNamed_1owner_1 = sel_registerName("loadNibNamed:owner:");
+    public static /*const*/ string sel_setDocument_1 = sel_registerName("setDocument:");
+    public static /*const*/ string sel_filePosixPermissions = sel_registerName("filePosixPermissions");
+    public static /*const*/ string sel_collapseItem_1collapseChildren_1 = sel_registerName("collapseItem:collapseChildren:");
+    public static /*const*/ string sel_setCell_1 = sel_registerName("setCell:");
+    public static /*const*/ string sel_setHTTPBodyStream_1 = sel_registerName("setHTTPBodyStream:");
+    public static /*const*/ string sel_updateAttachmentsFromPath_1 = sel_registerName("updateAttachmentsFromPath:");
+    public static /*const*/ string sel_updateFontPanel = sel_registerName("updateFontPanel");
+    public static /*const*/ string sel_animationDidStop_1 = sel_registerName("animationDidStop:");
+    public static /*const*/ string sel_URL_1resourceDidFailLoadingWithReason_1 = sel_registerName("URL:resourceDidFailLoadingWithReason:");
+    public static /*const*/ string sel_defaultBaselineOffsetForFont_1 = sel_registerName("defaultBaselineOffsetForFont:");
+    public static /*const*/ string sel_browser_1shouldShowCellExpansionForRow_1column_1 = sel_registerName("browser:shouldShowCellExpansionForRow:column:");
+    public static /*const*/ string sel_draggingEnded_1 = sel_registerName("draggingEnded:");
+    public static /*const*/ string sel_openURL_1 = sel_registerName("openURL:");
+    public static /*const*/ string sel_longLongValue = sel_registerName("longLongValue");
+    public static /*const*/ string sel_colorPanel = sel_registerName("colorPanel");
+    public static /*const*/ string sel_encodeFloat_1forKey_1 = sel_registerName("encodeFloat:forKey:");
+    public static /*const*/ string sel_shouldBreakLineByHyphenatingBeforeCharacterAtIndex_1 = sel_registerName("shouldBreakLineByHyphenatingBeforeCharacterAtIndex:");
+    public static /*const*/ string sel_performSelectorInBackground_1withObject_1 = sel_registerName("performSelectorInBackground:withObject:");
+    public static /*const*/ string sel_initTextCell_1 = sel_registerName("initTextCell:");
+    public static /*const*/ string sel_classDescription = sel_registerName("classDescription");
+    public static /*const*/ string sel_menuFontOfSize_1 = sel_registerName("menuFontOfSize:");
+    public static /*const*/ string sel_window_1willPositionSheet_1usingRect_1 = sel_registerName("window:willPositionSheet:usingRect:");
+    public static /*const*/ string sel_allowsTypeSelect = sel_registerName("allowsTypeSelect");
+    public static /*const*/ string sel_attributeWithName_1URI_1StringValue_1 = sel_registerName("attributeWithName:URI:StringValue:");
+    public static /*const*/ string sel_setLinkTextAttributes_1 = sel_registerName("setLinkTextAttributes:");
+    public static /*const*/ string sel_StringWithFormat_1 = sel_registerName("StringWithFormat:");
+    public static /*const*/ string sel_initWithTable_1startingRow_1rowSpan_1startingColumn_1columnSpan_1 = sel_registerName("initWithTable:startingRow:rowSpan:startingColumn:columnSpan:");
+    public static /*const*/ string sel_setShouldProcessNamespaces_1 = sel_registerName("setShouldProcessNamespaces:");
+    public static /*const*/ string sel_orderFrontRegardless = sel_registerName("orderFrontRegardless");
+    public static /*const*/ string sel_setProtocolForProxy_1 = sel_registerName("setProtocolForProxy:");
+    public static /*const*/ string sel_bundlePath = sel_registerName("bundlePath");
+    public static /*const*/ string sel_isAutoscroll = sel_registerName("isAutoscroll");
+    public static /*const*/ string sel_addConnection_1toRunLoop_1forMode_1 = sel_registerName("addConnection:toRunLoop:forMode:");
+    public static /*const*/ string sel_moveWordBackwardAndModifySelection_1 = sel_registerName("moveWordBackwardAndModifySelection:");
+    public static /*const*/ string sel_textContainerChangedGeometry_1 = sel_registerName("textContainerChangedGeometry:");
+    public static /*const*/ string sel_conversation = sel_registerName("conversation");
+    public static /*const*/ string sel_showWindow_1 = sel_registerName("showWindow:");
+    public static /*const*/ string sel_showGuessPanel_1 = sel_registerName("showGuessPanel:");
+    public static /*const*/ string sel_setBorderWidth_1 = sel_registerName("setBorderWidth:");
+    public static /*const*/ string sel_buttons = sel_registerName("buttons");
+    public static /*const*/ string sel_bitmapRepresentation = sel_registerName("bitmapRepresentation");
+    public static /*const*/ string sel_nextObject = sel_registerName("nextObject");
+    public static /*const*/ string sel_predicate = sel_registerName("predicate");
+    public static /*const*/ string sel_verticalPagination = sel_registerName("verticalPagination");
+    public static /*const*/ string sel_readInBackgroundAndNotify = sel_registerName("readInBackgroundAndNotify");
+    public static /*const*/ string sel_pixelBufferMipMapLevel = sel_registerName("pixelBufferMipMapLevel");
+    public static /*const*/ string sel_getValue_1 = sel_registerName("getValue:");
+    public static /*const*/ string sel_eventID = sel_registerName("eventID");
+    public static /*const*/ string sel_sortDescriptors = sel_registerName("sortDescriptors");
+    public static /*const*/ string sel_removeObjectAtArrangedObjectIndexPath_1 = sel_registerName("removeObjectAtArrangedObjectIndexPath:");
+    public static /*const*/ string sel_decodeBytesWithReturnedLength_1 = sel_registerName("decodeBytesWithReturnedLength:");
+    public static /*const*/ string sel_textView_1shouldChangeTextInRange_1replacementString_1 = sel_registerName("textView:shouldChangeTextInRange:replacementString:");
+    public static /*const*/ string sel_removeCursorRect_1cursor_1 = sel_registerName("removeCursorRect:cursor:");
+    public static /*const*/ string sel_hasPassword = sel_registerName("hasPassword");
+    public static /*const*/ string sel_updateWindows = sel_registerName("updateWindows");
+    public static /*const*/ string sel_pasteboardWithName_1 = sel_registerName("pasteboardWithName:");
+    public static /*const*/ string sel_writeSelectionToPasteboard_1types_1 = sel_registerName("writeSelectionToPasteboard:types:");
+    public static /*const*/ string sel_setFlipped_1 = sel_registerName("setFlipped:");
+    public static /*const*/ string sel_glyphWithName_1 = sel_registerName("glyphWithName:");
+    public static /*const*/ string sel_launchApplication_1showIcon_1autolaunch_1 = sel_registerName("launchApplication:showIcon:autolaunch:");
+    public static /*const*/ string sel_indexPath = sel_registerName("indexPath");
+    public static /*const*/ string sel_setAttributeDescriptor_1forKeyword_1 = sel_registerName("setAttributeDescriptor:forKeyword:");
+    public static /*const*/ string sel_removeAllActions = sel_registerName("removeAllActions");
+    public static /*const*/ string sel_defaultAttachmentScaling = sel_registerName("defaultAttachmentScaling");
+    public static /*const*/ string sel_localizedStringWithFormat_1 = sel_registerName("localizedStringWithFormat:");
+    public static /*const*/ string sel_setAutoscroll_1 = sel_registerName("setAutoscroll:");
+    public static /*const*/ string sel_heightAdjustLimit = sel_registerName("heightAdjustLimit");
+    public static /*const*/ string sel_moveUpAndModifySelection_1 = sel_registerName("moveUpAndModifySelection:");
+    public static /*const*/ string sel_visibilityPriority = sel_registerName("visibilityPriority");
+    public static /*const*/ string sel_textView_1clickedOnCell_1inRect_1atIndex_1 = sel_registerName("textView:clickedOnCell:inRect:atIndex:");
+    public static /*const*/ string sel_archivedDataWithRootObject_1 = sel_registerName("archivedDataWithRootObject:");
+    public static /*const*/ string sel_parser_1foundCDATA_1 = sel_registerName("parser:foundCDATA:");
+    public static /*const*/ string sel_setWidth_1ofColumn_1 = sel_registerName("setWidth:ofColumn:");
+    public static /*const*/ string sel_setHighlightedTableColumn_1 = sel_registerName("setHighlightedTableColumn:");
+    public static /*const*/ string sel_toggle_1 = sel_registerName("toggle:");
+    public static /*const*/ string sel_parent = sel_registerName("parent");
+    public static /*const*/ string sel_tableView_1shouldSelectRow_1 = sel_registerName("tableView:shouldSelectRow:");
+    public static /*const*/ string sel_setWithObject_1 = sel_registerName("setWithObject:");
+    public static /*const*/ string sel_attribute_1atIndex_1effectiveRange_1 = sel_registerName("attribute:atIndex:effectiveRange:");
+    public static /*const*/ string sel_columnsInRect_1 = sel_registerName("columnsInRect:");
+    public static /*const*/ string sel_setSearchScopes_1 = sel_registerName("setSearchScopes:");
+    public static /*const*/ string sel_setByAddingObjectsFromArray_1 = sel_registerName("setByAddingObjectsFromArray:");
+    public static /*const*/ string sel_textViewDidChangeTypingAttributes_1 = sel_registerName("textViewDidChangeTypingAttributes:");
+    public static /*const*/ string sel_frameRate = sel_registerName("frameRate");
+    public static /*const*/ string sel_browser_1writeRowsWithIndexes_1inColumn_1toPasteboard_1 = sel_registerName("browser:writeRowsWithIndexes:inColumn:toPasteboard:");
+    public static /*const*/ string sel_errorWithDomain_1code_1userInfo_1 = sel_registerName("errorWithDomain:code:userInfo:");
+    public static /*const*/ string sel_setAlternate_1 = sel_registerName("setAlternate:");
+    public static /*const*/ string sel_currentValue = sel_registerName("currentValue");
+    public static /*const*/ string sel_download_1decideDestinationWithSuggestedFilename_1 = sel_registerName("download:decideDestinationWithSuggestedFilename:");
+    public static /*const*/ string sel_setBoxType_1 = sel_registerName("setBoxType:");
+    public static /*const*/ string sel_fileNamesFromRunningOpenPanel = sel_registerName("fileNamesFromRunningOpenPanel");
+    public static /*const*/ string sel_valueWithPointer_1 = sel_registerName("valueWithPointer:");
+    public static /*const*/ string sel_metadataQuery_1replacementObjectForResultObject_1 = sel_registerName("metadataQuery:replacementObjectForResultObject:");
+    public static /*const*/ string sel_editedColumn = sel_registerName("editedColumn");
+    public static /*const*/ string sel_cachedResponseForRequest_1 = sel_registerName("cachedResponseForRequest:");
+    public static /*const*/ string sel_failureReason = sel_registerName("failureReason");
+    public static /*const*/ string sel_constantValue = sel_registerName("constantValue");
+    public static /*const*/ string sel_commandClassName = sel_registerName("commandClassName");
+    public static /*const*/ string sel_fileWrapper = sel_registerName("fileWrapper");
+    public static /*const*/ string sel_setUsesUserKeyEquivalents_1 = sel_registerName("setUsesUserKeyEquivalents:");
+    public static /*const*/ string sel_prototype = sel_registerName("prototype");
+    public static /*const*/ string sel_clearStartAnimation = sel_registerName("clearStartAnimation");
+    public static /*const*/ string sel_setMovableByWindowBackground_1 = sel_registerName("setMovableByWindowBackground:");
+    public static /*const*/ string sel_setDateFormat_1 = sel_registerName("setDateFormat:");
+    public static /*const*/ string sel_StringWithContentsOfFile_1usedEncoding_1error_1 = sel_registerName("StringWithContentsOfFile:usedEncoding:error:");
+    public static /*const*/ string sel_toggleAutomaticLinkDetection_1 = sel_registerName("toggleAutomaticLinkDetection:");
+    public static /*const*/ string sel_statusForTable_1 = sel_registerName("statusForTable:");
+    public static /*const*/ string sel_setAllowsColumnSelection_1 = sel_registerName("setAllowsColumnSelection:");
+    public static /*const*/ string sel_lowercaseWord_1 = sel_registerName("lowercaseWord:");
+    public static /*const*/ string sel_setResolvesAliases_1 = sel_registerName("setResolvesAliases:");
+    public static /*const*/ string sel_appendFormat_1 = sel_registerName("appendFormat:");
+    public static /*const*/ string sel_isAnimating = sel_registerName("isAnimating");
+    public static /*const*/ string sel_dateFormat = sel_registerName("dateFormat");
+    public static /*const*/ string sel_setMuted_1 = sel_registerName("setMuted:");
+    public static /*const*/ string sel_drawWithExpansionFrame_1inView_1 = sel_registerName("drawWithExpansionFrame:inView:");
+    public static /*const*/ string sel_copyPath_1toPath_1handler_1 = sel_registerName("copyPath:toPath:handler:");
+    public static /*const*/ string sel_isExplicitlyIncluded = sel_registerName("isExplicitlyIncluded");
+    public static /*const*/ string sel_isExtensionHidden = sel_registerName("isExtensionHidden");
+    public static /*const*/ string sel_showPackedGlyphs_1length_1glyphRange_1atPoint_1font_1color_1printingAdjustment_1 = sel_registerName("showPackedGlyphs:length:glyphRange:atPoint:font:color:printingAdjustment:");
+    public static /*const*/ string sel_rulerView_1didRemoveMarker_1 = sel_registerName("rulerView:didRemoveMarker:");
+    public static /*const*/ string sel_setControlTint_1 = sel_registerName("setControlTint:");
+    public static /*const*/ string sel_isSelectable = sel_registerName("isSelectable");
+    public static /*const*/ string sel_initWithMachPort_1 = sel_registerName("initWithMachPort:");
+    public static /*const*/ string sel_fill = sel_registerName("fill");
+    public static /*const*/ string sel_isEnteringProximity = sel_registerName("isEnteringProximity");
+    public static /*const*/ string sel_drawingRectForBounds_1 = sel_registerName("drawingRectForBounds:");
+    public static /*const*/ string sel_decodeInt32ForKey_1 = sel_registerName("decodeInt32ForKey:");
+    public static /*const*/ string sel_deltaY = sel_registerName("deltaY");
+    public static /*const*/ string sel_displaysLinkToolTips = sel_registerName("displaysLinkToolTips");
+    public static /*const*/ string sel_moveToEndOfDocument_1 = sel_registerName("moveToEndOfDocument:");
+    public static /*const*/ string sel_isFirstResponder = sel_registerName("isFirstResponder");
+    public static /*const*/ string sel_receiversSpecifier = sel_registerName("receiversSpecifier");
+    public static /*const*/ string sel_canInitWithURL_1 = sel_registerName("canInitWithURL:");
+    public static /*const*/ string sel_parameterString = sel_registerName("parameterString");
+    public static /*const*/ string sel_isMovable = sel_registerName("isMovable");
+    public static /*const*/ string sel_setAvoidsEmptySelection_1 = sel_registerName("setAvoidsEmptySelection:");
+    public static /*const*/ string sel_lockFocusIfCanDrawInContext_1 = sel_registerName("lockFocusIfCanDrawInContext:");
+    public static /*const*/ string sel_updateChangeCount_1 = sel_registerName("updateChangeCount:");
+    public static /*const*/ string sel_rootDocument = sel_registerName("rootDocument");
+    public static /*const*/ string sel_superview = sel_registerName("superview");
+    public static /*const*/ string sel_resolveNamespaceForName_1 = sel_registerName("resolveNamespaceForName:");
+    public static /*const*/ string sel_maxNumberOfColumns = sel_registerName("maxNumberOfColumns");
+    public static /*const*/ string sel_setMaxSize_1 = sel_registerName("setMaxSize:");
+    public static /*const*/ string sel_completePathIntoString_1caseSensitive_1matchesIntoArray_1filterTypes_1 = sel_registerName("completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:");
+    public static /*const*/ string sel_updateCell_1 = sel_registerName("updateCell:");
+    public static /*const*/ string sel_setWeek_1 = sel_registerName("setWeek:");
+    public static /*const*/ string sel_titleRectForBounds_1 = sel_registerName("titleRectForBounds:");
+    public static /*const*/ string sel_rulerView_1willAddMarker_1atLocation_1 = sel_registerName("rulerView:willAddMarker:atLocation:");
+    public static /*const*/ string sel_message = sel_registerName("message");
+    public static /*const*/ string sel_setContentSize_1 = sel_registerName("setContentSize:");
+    public static /*const*/ string sel_broadcast = sel_registerName("broadcast");
+    public static /*const*/ string sel_isNativeType_1 = sel_registerName("isNativeType:");
+    public static /*const*/ string sel_contentBorderThicknessForEdge_1 = sel_registerName("contentBorderThicknessForEdge:");
+    public static /*const*/ string sel_keyEquivalentOffset = sel_registerName("keyEquivalentOffset");
+    public static /*const*/ string sel_makeUntitledDocumentOfType_1 = sel_registerName("makeUntitledDocumentOfType:");
+    public static /*const*/ string sel_windowFrameTextColor = sel_registerName("windowFrameTextColor");
+    public static /*const*/ string sel_addItemsWithTitles_1 = sel_registerName("addItemsWithTitles:");
+    public static /*const*/ string sel_levelForRow_1 = sel_registerName("levelForRow:");
+    public static /*const*/ string sel_dissolveToPoint_1fromRect_1fraction_1 = sel_registerName("dissolveToPoint:fromRect:fraction:");
+    public static /*const*/ string sel_discardCachedImage = sel_registerName("discardCachedImage");
+    public static /*const*/ string sel_rootProxyForConnectionWithRegisteredName_1host_1usingNameServer_1 = sel_registerName("rootProxyForConnectionWithRegisteredName:host:usingNameServer:");
+    public static /*const*/ string sel_mouseExited_1 = sel_registerName("mouseExited:");
+    public static /*const*/ string sel_StringWithCString_1 = sel_registerName("StringWithCString:");
+    public static /*const*/ string sel_standardUserDefaults = sel_registerName("standardUserDefaults");
+    public static /*const*/ string sel_archiver_1didEncodeObject_1 = sel_registerName("archiver:didEncodeObject:");
+    public static /*const*/ string sel_canDraw = sel_registerName("canDraw");
+    public static /*const*/ string sel_shouldDelayWindowOrderingForEvent_1 = sel_registerName("shouldDelayWindowOrderingForEvent:");
+    public static /*const*/ string sel_selectedMenuItemTextColor = sel_registerName("selectedMenuItemTextColor");
+    public static /*const*/ string sel_attachSubmenuForItemAtIndex_1 = sel_registerName("attachSubmenuForItemAtIndex:");
+    public static /*const*/ string sel_condition = sel_registerName("condition");
+    public static /*const*/ string sel_setReservedThicknessForAccessoryView_1 = sel_registerName("setReservedThicknessForAccessoryView:");
+    public static /*const*/ string sel_replaceObjectsInRange_1withObjectsFromArray_1 = sel_registerName("replaceObjectsInRange:withObjectsFromArray:");
+    public static /*const*/ string sel_placeholderString = sel_registerName("placeholderString");
+    public static /*const*/ string sel_setPMSymbol_1 = sel_registerName("setPMSymbol:");
+    public static /*const*/ string sel_localizedNameOfStringEncoding_1 = sel_registerName("localizedNameOfStringEncoding:");
+    public static /*const*/ string sel_outlineViewItemWillCollapse_1 = sel_registerName("outlineViewItemWillCollapse:");
+    public static /*const*/ string sel_localizedKey = sel_registerName("localizedKey");
+    public static /*const*/ string sel_whiteColor = sel_registerName("whiteColor");
+    public static /*const*/ string sel_viewBoundsChanged_1 = sel_registerName("viewBoundsChanged:");
+    public static /*const*/ string sel_vendorDefined = sel_registerName("vendorDefined");
+    public static /*const*/ string sel_classNameDecodedForArchiveClassName_1 = sel_registerName("classNameDecodedForArchiveClassName:");
+    public static /*const*/ string sel_lockDate = sel_registerName("lockDate");
+    public static /*const*/ string sel_twoDigitStartDate = sel_registerName("twoDigitStartDate");
+    public static /*const*/ string sel_rectOfRow_1 = sel_registerName("rectOfRow:");
+    public static /*const*/ string sel_receivePort = sel_registerName("receivePort");
+    public static /*const*/ string sel_decimalNumberByMultiplyingByPowerOf10_1withBehavior_1 = sel_registerName("decimalNumberByMultiplyingByPowerOf10:withBehavior:");
+    public static /*const*/ string sel_isAnyApplicationSpeaking = sel_registerName("isAnyApplicationSpeaking");
+    public static /*const*/ string sel_aeDesc = sel_registerName("aeDesc");
+    public static /*const*/ string sel_windowWillBeginSheet_1 = sel_registerName("windowWillBeginSheet:");
+    public static /*const*/ string sel_accessibilityFocusedUIElement = sel_registerName("accessibilityFocusedUIElement");
+    public static /*const*/ string sel_orderBack_1 = sel_registerName("orderBack:");
+    public static /*const*/ string sel_scanDecimal_1 = sel_registerName("scanDecimal:");
+    public static /*const*/ string sel_transformStruct = sel_registerName("transformStruct");
+    public static /*const*/ string sel_fileAttributesToWriteToFile_1ofType_1saveOperation_1 = sel_registerName("fileAttributesToWriteToFile:ofType:saveOperation:");
+    public static /*const*/ string sel_controlCharacterSet = sel_registerName("controlCharacterSet");
+    public static /*const*/ string sel_setNextResponder_1 = sel_registerName("setNextResponder:");
+    public static /*const*/ string sel_pasteboardChangedOwner_1 = sel_registerName("pasteboardChangedOwner:");
+    public static /*const*/ string sel_canSelectHiddenExtension = sel_registerName("canSelectHiddenExtension");
+    public static /*const*/ string sel_attribute_1atIndex_1longestEffectiveRange_1inRange_1 = sel_registerName("attribute:atIndex:longestEffectiveRange:inRange:");
+    public static /*const*/ string sel_setAutovalidates_1 = sel_registerName("setAutovalidates:");
+    public static /*const*/ string sel_setAllowsFloats_1 = sel_registerName("setAllowsFloats:");
+    public static /*const*/ string sel_sortDescriptorPrototype = sel_registerName("sortDescriptorPrototype");
+    public static /*const*/ string sel_trackKnob_1 = sel_registerName("trackKnob:");
+    public static /*const*/ string sel_comboBox_1indexOfItemWithStringValue_1 = sel_registerName("comboBox:indexOfItemWithStringValue:");
+    public static /*const*/ string sel_setSource_1 = sel_registerName("setSource:");
+    public static /*const*/ string sel_contentFilters = sel_registerName("contentFilters");
+    public static /*const*/ string sel_dictionaryWithContentsOfFile_1 = sel_registerName("dictionaryWithContentsOfFile:");
+    public static /*const*/ string sel_drawArrow_1highlight_1 = sel_registerName("drawArrow:highlight:");
+    public static /*const*/ string sel_handleSaveScriptCommand_1 = sel_registerName("handleSaveScriptCommand:");
+    public static /*const*/ string sel_rangeOfString_1options_1 = sel_registerName("rangeOfString:options:");
+    public static /*const*/ string sel_setPickerMode_1 = sel_registerName("setPickerMode:");
+    public static /*const*/ string sel_setStandaloneQuarterSymbols_1 = sel_registerName("setStandaloneQuarterSymbols:");
+    public static /*const*/ string sel_setSize_1 = sel_registerName("setSize:");
+    public static /*const*/ string sel_setAllowsUndo_1 = sel_registerName("setAllowsUndo:");
+    public static /*const*/ string sel_edge = sel_registerName("edge");
+    public static /*const*/ string sel_stopLoading = sel_registerName("stopLoading");
+    public static /*const*/ string sel_fileURLWithPath_1isDirectory_1 = sel_registerName("fileURLWithPath:isDirectory:");
+    public static /*const*/ string sel_userInfo = sel_registerName("userInfo");
+    public static /*const*/ string sel_components_1fromDate_1 = sel_registerName("components:fromDate:");
+    public static /*const*/ string sel_dictionary = sel_registerName("dictionary");
+    public static /*const*/ string sel_connection_1didCancelAuthenticationChallenge_1 = sel_registerName("connection:didCancelAuthenticationChallenge:");
+    public static /*const*/ string sel_selectParagraph_1 = sel_registerName("selectParagraph:");
+    public static /*const*/ string sel_initWithCapacity_1 = sel_registerName("initWithCapacity:");
+    public static /*const*/ string sel_initWithObjectSpecifier_1comparisonOperator_1testObject_1 = sel_registerName("initWithObjectSpecifier:comparisonOperator:testObject:");
+    public static /*const*/ string sel_nestingMode = sel_registerName("nestingMode");
+    public static /*const*/ string sel_paragraphSpacingBefore = sel_registerName("paragraphSpacingBefore");
+    public static /*const*/ string sel_itemChanged_1 = sel_registerName("itemChanged:");
+    public static /*const*/ string sel_setSelectionIndexes_1 = sel_registerName("setSelectionIndexes:");
+    public static /*const*/ string sel_open = sel_registerName("open");
+    public static /*const*/ string sel_sendActionOn_1 = sel_registerName("sendActionOn:");
+    public static /*const*/ string sel_initWithFireDate_1interval_1target_1selector_1userInfo_1repeats_1 = sel_registerName("initWithFireDate:interval:target:selector:userInfo:repeats:");
+    public static /*const*/ string sel_formatterBehavior = sel_registerName("formatterBehavior");
+    public static /*const*/ string sel_fillRect_1 = sel_registerName("fillRect:");
+    public static /*const*/ string sel_animationCurve = sel_registerName("animationCurve");
+    public static /*const*/ string sel_remoteObjects = sel_registerName("remoteObjects");
+    public static /*const*/ string sel_setSelectionIndexPath_1 = sel_registerName("setSelectionIndexPath:");
+    public static /*const*/ string sel_availableFontNamesWithTraits_1 = sel_registerName("availableFontNamesWithTraits:");
+    public static /*const*/ string sel_convertFont_1toFamily_1 = sel_registerName("convertFont:toFamily:");
+    public static /*const*/ string sel_splitView_1resizeSubviewsWithOldSize_1 = sel_registerName("splitView:resizeSubviewsWithOldSize:");
+    public static /*const*/ string sel_setSmartInsertDeleteEnabled_1 = sel_registerName("setSmartInsertDeleteEnabled:");
+    public static /*const*/ string sel_shouldChangePrintInfo_1 = sel_registerName("shouldChangePrintInfo:");
+    public static /*const*/ string sel_objectBeingTested = sel_registerName("objectBeingTested");
+    public static /*const*/ string sel_selectItemWithObjectValue_1 = sel_registerName("selectItemWithObjectValue:");
+    public static /*const*/ string sel_rightExpressions = sel_registerName("rightExpressions");
+    public static /*const*/ string sel_unableToSetNilForKey_1 = sel_registerName("unableToSetNilForKey:");
+    public static /*const*/ string sel_visibleItems = sel_registerName("visibleItems");
+    public static /*const*/ string sel_items = sel_registerName("items");
+    public static /*const*/ string sel_templatesWithAttributeKeyPaths_1inEntityDescription_1 = sel_registerName("templatesWithAttributeKeyPaths:inEntityDescription:");
+    public static /*const*/ string sel_setMaximumIntegerDigits_1 = sel_registerName("setMaximumIntegerDigits:");
+    public static /*const*/ string sel_scrollRectToVisible_1 = sel_registerName("scrollRectToVisible:");
+    public static /*const*/ string sel_disableKeyEquivalentForDefaultButtonCell = sel_registerName("disableKeyEquivalentForDefaultButtonCell");
+    public static /*const*/ string sel_objectsForXQuery_1error_1 = sel_registerName("objectsForXQuery:error:");
+    public static /*const*/ string sel_readToEndOfFileInBackgroundAndNotifyForModes_1 = sel_registerName("readToEndOfFileInBackgroundAndNotifyForModes:");
+    public static /*const*/ string sel_scanHexLongLong_1 = sel_registerName("scanHexLongLong:");
+    public static /*const*/ string sel_ascender = sel_registerName("ascender");
+    public static /*const*/ string sel_arrangeObjects_1 = sel_registerName("arrangeObjects:");
+    public static /*const*/ string sel_setNegativeSuffix_1 = sel_registerName("setNegativeSuffix:");
+    public static /*const*/ string sel_initWithString_1 = sel_registerName("initWithString:");
+    public static /*const*/ string sel_initWithName_1data_1 = sel_registerName("initWithName:data:");
+    public static /*const*/ string sel_data = sel_registerName("data");
+    public static /*const*/ string sel_encodePortObject_1 = sel_registerName("encodePortObject:");
+    public static /*const*/ string sel_becomeFirstResponder = sel_registerName("becomeFirstResponder");
+    public static /*const*/ string sel_setImage_1forSegment_1 = sel_registerName("setImage:forSegment:");
+    public static /*const*/ string sel_copyRuler_1 = sel_registerName("copyRuler:");
+    public static /*const*/ string sel_appendBezierPathWithGlyphs_1count_1inFont_1 = sel_registerName("appendBezierPathWithGlyphs:count:inFont:");
+    public static /*const*/ string sel_playsSelectionOnly = sel_registerName("playsSelectionOnly");
+    public static /*const*/ string sel_boundsRectForTextBlock_1glyphRange_1 = sel_registerName("boundsRectForTextBlock:glyphRange:");
+    public static /*const*/ string sel_makeObjectsPerformSelector_1withObject_1 = sel_registerName("makeObjectsPerformSelector:withObject:");
+    public static /*const*/ string sel_StringByTrimmingCharactersInSet_1 = sel_registerName("StringByTrimmingCharactersInSet:");
+    public static /*const*/ string sel_timerWithTimeInterval_1invocation_1repeats_1 = sel_registerName("timerWithTimeInterval:invocation:repeats:");
+    public static /*const*/ string sel_viewDidMoveToSuperview = sel_registerName("viewDidMoveToSuperview");
+    public static /*const*/ string sel_pathCell_1willDisplayOpenPanel_1 = sel_registerName("pathCell:willDisplayOpenPanel:");
+    public static /*const*/ string sel_pathSeparator = sel_registerName("pathSeparator");
+    public static /*const*/ string sel_generatesCalendarDates = sel_registerName("generatesCalendarDates");
+    public static /*const*/ string sel_pressure = sel_registerName("pressure");
+    public static /*const*/ string sel_sendPort = sel_registerName("sendPort");
+    public static /*const*/ string sel_argumentsRetained = sel_registerName("argumentsRetained");
+    public static /*const*/ string sel_setContainerSpecifier_1 = sel_registerName("setContainerSpecifier:");
+    public static /*const*/ string sel_decodeNXColor = sel_registerName("decodeNXColor");
+    public static /*const*/ string sel_orientation = sel_registerName("orientation");
+    public static /*const*/ string sel_setScriptErrorString_1 = sel_registerName("setScriptErrorString:");
+    public static /*const*/ string sel_makeDocumentWithContentsOfFile_1ofType_1 = sel_registerName("makeDocumentWithContentsOfFile:ofType:");
+    public static /*const*/ string sel_reason = sel_registerName("reason");
+    public static /*const*/ string sel_currentEvent = sel_registerName("currentEvent");
+    public static /*const*/ string sel_setOffScreen_1width_1height_1rowbytes_1 = sel_registerName("setOffScreen:width:height:rowbytes:");
+    public static /*const*/ string sel_invalidateAttributesInRange_1 = sel_registerName("invalidateAttributesInRange:");
+    public static /*const*/ string sel_descriptorWithDescriptorType_1bytes_1length_1 = sel_registerName("descriptorWithDescriptorType:bytes:length:");
+    public static /*const*/ string sel_setCredential_1forProtectionSpace_1 = sel_registerName("setCredential:forProtectionSpace:");
+    public static /*const*/ string sel_fileGroupOwnerAccountName = sel_registerName("fileGroupOwnerAccountName");
+    public static /*const*/ string sel_setColor_1forKey_1 = sel_registerName("setColor:forKey:");
+    public static /*const*/ string sel_setAutohidesScrollers_1 = sel_registerName("setAutohidesScrollers:");
+    public static /*const*/ string sel_noteNumberOfRowsChanged = sel_registerName("noteNumberOfRowsChanged");
+    public static /*const*/ string sel_disableCursorRects = sel_registerName("disableCursorRects");
+    public static /*const*/ string sel_setLenient_1 = sel_registerName("setLenient:");
+    public static /*const*/ string sel_registerUnitWithName_1abbreviation_1unitToPointsConversionFactor_1stepUpCycle_1stepDownCycle_1 = sel_registerName("registerUnitWithName:abbreviation:unitToPointsConversionFactor:stepUpCycle:stepDownCycle:");
+    public static /*const*/ string sel_standardWindowButton_1 = sel_registerName("standardWindowButton:");
+    public static /*const*/ string sel_objectForProperty_1error_1 = sel_registerName("objectForProperty:error:");
+    public static /*const*/ string sel_imageRepWithData_1 = sel_registerName("imageRepWithData:");
+    public static /*const*/ string sel_flushGraphics = sel_registerName("flushGraphics");
+    public static /*const*/ string sel_setCacheDepthMatchesImageDepth_1 = sel_registerName("setCacheDepthMatchesImageDepth:");
+    public static /*const*/ string sel_highlightColorInView_1 = sel_registerName("highlightColorInView:");
+    public static /*const*/ string sel_setBaseSpecifier_1 = sel_registerName("setBaseSpecifier:");
+    public static /*const*/ string sel_performFileOperation_1source_1destination_1files_1tag_1 = sel_registerName("performFileOperation:source:destination:files:tag:");
+    public static /*const*/ string sel_outlineView_1itemForPersistentObject_1 = sel_registerName("outlineView:itemForPersistentObject:");
+    public static /*const*/ string sel_propertyListFromData_1mutabilityOption_1format_1errorDescription_1 = sel_registerName("propertyListFromData:mutabilityOption:format:errorDescription:");
+    public static /*const*/ string sel_setDocumentView_1 = sel_registerName("setDocumentView:");
+    public static /*const*/ string sel_drawsOutsideLineFragmentForGlyphAtIndex_1 = sel_registerName("drawsOutsideLineFragmentForGlyphAtIndex:");
+    public static /*const*/ string sel_dragImageForSelectionWithEvent_1origin_1 = sel_registerName("dragImageForSelectionWithEvent:origin:");
+    public static /*const*/ string sel_buttonNumber = sel_registerName("buttonNumber");
+    public static /*const*/ string sel_advancementForGlyph_1 = sel_registerName("advancementForGlyph:");
+    public static /*const*/ string sel_parser_1validationErrorOccurred_1 = sel_registerName("parser:validationErrorOccurred:");
+    public static /*const*/ string sel_reusesColumns = sel_registerName("reusesColumns");
+    public static /*const*/ string sel_minute = sel_registerName("minute");
+    public static /*const*/ string sel_setCanChooseFiles_1 = sel_registerName("setCanChooseFiles:");
+    public static /*const*/ string sel_groupingSize = sel_registerName("groupingSize");
+    public static /*const*/ string sel_containsAttachments = sel_registerName("containsAttachments");
+    public static /*const*/ string sel_selectedControlTextColor = sel_registerName("selectedControlTextColor");
+    public static /*const*/ string sel_initWithMantissa_1exponent_1isNegative_1 = sel_registerName("initWithMantissa:exponent:isNegative:");
+    public static /*const*/ string sel_initWithVoice_1 = sel_registerName("initWithVoice:");
+    public static /*const*/ string sel_setResizingMask_1 = sel_registerName("setResizingMask:");
+    public static /*const*/ string sel_setOnMouseExited_1 = sel_registerName("setOnMouseExited:");
+    public static /*const*/ string sel_toggleContinuousSpellChecking_1 = sel_registerName("toggleContinuousSpellChecking:");
+    public static /*const*/ string sel_allowsCutCopyPaste = sel_registerName("allowsCutCopyPaste");
+    public static /*const*/ string sel_endSheet_1 = sel_registerName("endSheet:");
+    public static /*const*/ string sel_allowsBranchSelection = sel_registerName("allowsBranchSelection");
+    public static /*const*/ string sel_initWithRequest_1delegate_1 = sel_registerName("initWithRequest:delegate:");
+    public static /*const*/ string sel_isAtEnd = sel_registerName("isAtEnd");
+    public static /*const*/ string sel_relativeString = sel_registerName("relativeString");
+    public static /*const*/ string sel_tableView_1willDisplayCell_1forTableColumn_1row_1 = sel_registerName("tableView:willDisplayCell:forTableColumn:row:");
+    public static /*const*/ string sel_resizeSubviewsWithOldSize_1 = sel_registerName("resizeSubviewsWithOldSize:");
+    public static /*const*/ string sel_compoundPredicateType = sel_registerName("compoundPredicateType");
+    public static /*const*/ string sel_accessoryControllers = sel_registerName("accessoryControllers");
+    public static /*const*/ string sel_shouldDrawColor = sel_registerName("shouldDrawColor");
+    public static /*const*/ string sel_applicationShouldTerminate_1 = sel_registerName("applicationShouldTerminate:");
+    public static /*const*/ string sel_setTextContainer_1 = sel_registerName("setTextContainer:");
+    public static /*const*/ string sel_discardCursorRects = sel_registerName("discardCursorRects");
+    public static /*const*/ string sel_deviceCMYKColorSpace = sel_registerName("deviceCMYKColorSpace");
+    public static /*const*/ string sel_setDefaultPlaceholder_1forMarker_1withBinding_1 = sel_registerName("setDefaultPlaceholder:forMarker:withBinding:");
+    public static /*const*/ string sel_setIsZoomed_1 = sel_registerName("setIsZoomed:");
+    public static /*const*/ string sel_blueComponent = sel_registerName("blueComponent");
+    public static /*const*/ string sel_portWithMachPort_1options_1 = sel_registerName("portWithMachPort:options:");
+    public static /*const*/ string sel_restoreGraphicsState = sel_registerName("restoreGraphicsState");
+    public static /*const*/ string sel_isTemplate = sel_registerName("isTemplate");
+    public static /*const*/ string sel_setScanLocation_1 = sel_registerName("setScanLocation:");
+    public static /*const*/ string sel_initWithBool_1 = sel_registerName("initWithBool:");
+    public static /*const*/ string sel_initWithSet_1copyItems_1 = sel_registerName("initWithSet:copyItems:");
+    public static /*const*/ string sel_setPositivePrefix_1 = sel_registerName("setPositivePrefix:");
+    public static /*const*/ string sel_propertyForKeyIfAvailable_1 = sel_registerName("propertyForKeyIfAvailable:");
+    public static /*const*/ string sel_fileOwnerAccountID = sel_registerName("fileOwnerAccountID");
+    public static /*const*/ string sel_initForIncrementalLoad = sel_registerName("initForIncrementalLoad");
+    public static /*const*/ string sel_cellAttribute_1 = sel_registerName("cellAttribute:");
+    public static /*const*/ string sel_baselineLocation = sel_registerName("baselineLocation");
+    public static /*const*/ string sel_initWithAttributedString_1 = sel_registerName("initWithAttributedString:");
+    public static /*const*/ string sel_showWindows = sel_registerName("showWindows");
+    public static /*const*/ string sel_writeToFile_1atomically_1updateFilenames_1 = sel_registerName("writeToFile:atomically:updateFilenames:");
+    public static /*const*/ string sel_setCookies_1forURL_1mainDocumentURL_1 = sel_registerName("setCookies:forURL:mainDocumentURL:");
+    public static /*const*/ string sel_unarchiver_1cannotDecodeObjectOfClassName_1originalClasses_1 = sel_registerName("unarchiver:cannotDecodeObjectOfClassName:originalClasses:");
+    public static /*const*/ string sel_selectRow_1inColumn_1 = sel_registerName("selectRow:inColumn:");
+    public static /*const*/ string sel_dissolveToPoint_1fraction_1 = sel_registerName("dissolveToPoint:fraction:");
+    public static /*const*/ string sel_wantsToTrackMouseForEvent_1inRect_1ofView_1atCharacterIndex_1 = sel_registerName("wantsToTrackMouseForEvent:inRect:ofView:atCharacterIndex:");
+    public static /*const*/ string sel_openURLs_1withAppBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifiers_1 = sel_registerName("openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:");
+    public static /*const*/ string sel_checkForRemovableMedia = sel_registerName("checkForRemovableMedia");
+    public static /*const*/ string sel_setImage_1 = sel_registerName("setImage:");
+    public static /*const*/ string sel_isFixedPitch = sel_registerName("isFixedPitch");
+    public static /*const*/ string sel_protocolFamily = sel_registerName("protocolFamily");
+    public static /*const*/ string sel_protocolCheckerWithTarget_1protocol_1 = sel_registerName("protocolCheckerWithTarget:protocol:");
+    public static /*const*/ string sel_streamError = sel_registerName("streamError");
+    public static /*const*/ string sel_replaceBytesInRange_1withBytes_1length_1 = sel_registerName("replaceBytesInRange:withBytes:length:");
+    public static /*const*/ string sel_canChooseDirectories = sel_registerName("canChooseDirectories");
+    public static /*const*/ string sel_classForPortCoder = sel_registerName("classForPortCoder");
+    public static /*const*/ string sel_mainRunLoop = sel_registerName("mainRunLoop");
+    public static /*const*/ string sel_setItemPrototype_1 = sel_registerName("setItemPrototype:");
+    public static /*const*/ string sel_controlShadowColor = sel_registerName("controlShadowColor");
+    public static /*const*/ string sel_level = sel_registerName("level");
+    public static /*const*/ string sel_setContextHelpModeActive_1 = sel_registerName("setContextHelpModeActive:");
+    public static /*const*/ string sel_levelForItem_1 = sel_registerName("levelForItem:");
+    public static /*const*/ string sel_setHeightTracksTextView_1 = sel_registerName("setHeightTracksTextView:");
+    public static /*const*/ string sel_applicationWillTerminate_1 = sel_registerName("applicationWillTerminate:");
+    public static /*const*/ string sel_wantsPeriodicDraggingUpdates = sel_registerName("wantsPeriodicDraggingUpdates");
+    public static /*const*/ string sel_createCommandInstance = sel_registerName("createCommandInstance");
+    public static /*const*/ string sel_parser_1foundElementDeclarationWithName_1model_1 = sel_registerName("parser:foundElementDeclarationWithName:model:");
+    public static /*const*/ string sel_window_1shouldPopUpDocumentPathMenu_1 = sel_registerName("window:shouldPopUpDocumentPathMenu:");
+    public static /*const*/ string sel_setRepresentedURL_1 = sel_registerName("setRepresentedURL:");
+    public static /*const*/ string sel_outlineView_1didDragTableColumn_1 = sel_registerName("outlineView:didDragTableColumn:");
+    public static /*const*/ string sel_appendTransform_1 = sel_registerName("appendTransform:");
+    public static /*const*/ string sel_setMIMEType_1 = sel_registerName("setMIMEType:");
+    public static /*const*/ string sel_setHeadIndent_1 = sel_registerName("setHeadIndent:");
+    public static /*const*/ string sel_setConstrainedFrameSize_1 = sel_registerName("setConstrainedFrameSize:");
+    public static /*const*/ string sel_setUsesDataSource_1 = sel_registerName("setUsesDataSource:");
+    public static /*const*/ string sel_replaceBytesInRange_1withBytes_1 = sel_registerName("replaceBytesInRange:withBytes:");
+    public static /*const*/ string sel_rowTypeKeyPath = sel_registerName("rowTypeKeyPath");
+    public static /*const*/ string sel_undoManager = sel_registerName("undoManager");
+    public static /*const*/ string sel_frameCenterRotation = sel_registerName("frameCenterRotation");
+    public static /*const*/ string sel_setTextView_1 = sel_registerName("setTextView:");
+    public static /*const*/ string sel_executeAppleEvent_1error_1 = sel_registerName("executeAppleEvent:error:");
+    public static /*const*/ string sel_setFormatter_1 = sel_registerName("setFormatter:");
+    public static /*const*/ string sel_scanLocation = sel_registerName("scanLocation");
+    public static /*const*/ string sel_scrollsDynamically = sel_registerName("scrollsDynamically");
+    public static /*const*/ string sel_setIndentationLevel_1 = sel_registerName("setIndentationLevel:");
+    public static /*const*/ string sel_minimumRangeOfUnit_1 = sel_registerName("minimumRangeOfUnit:");
+    public static /*const*/ string sel_textViewForBeginningOfSelection = sel_registerName("textViewForBeginningOfSelection");
+    public static /*const*/ string sel_tokenFieldCell_1displayStringForRepresentedObject_1 = sel_registerName("tokenFieldCell:displayStringForRepresentedObject:");
+    public static /*const*/ string sel_constrainFrameRect_1toScreen_1 = sel_registerName("constrainFrameRect:toScreen:");
+    public static /*const*/ string sel_getObjectValue_1forString_1range_1error_1 = sel_registerName("getObjectValue:forString:range:error:");
+    public static /*const*/ string sel_writeFileContents_1 = sel_registerName("writeFileContents:");
+    public static /*const*/ string sel_setProgressMarks_1 = sel_registerName("setProgressMarks:");
+    public static /*const*/ string sel_lastComponentOfFileName = sel_registerName("lastComponentOfFileName");
+    public static /*const*/ string sel_preventWindowOrdering = sel_registerName("preventWindowOrdering");
+    public static /*const*/ string sel_setDefaultDate_1 = sel_registerName("setDefaultDate:");
+    public static /*const*/ string sel_submenu = sel_registerName("submenu");
+    public static /*const*/ string sel_setTXTRecordData_1 = sel_registerName("setTXTRecordData:");
+    public static /*const*/ string sel_bytesPerRow = sel_registerName("bytesPerRow");
+    public static /*const*/ string sel_outlineView_1toolTipForCell_1rect_1tableColumn_1item_1mouseLocation_1 = sel_registerName("outlineView:toolTipForCell:rect:tableColumn:item:mouseLocation:");
+    public static /*const*/ string sel_outlineView_1shouldEditTableColumn_1item_1 = sel_registerName("outlineView:shouldEditTableColumn:item:");
+    public static /*const*/ string sel_initWithContainerSize_1 = sel_registerName("initWithContainerSize:");
+    public static /*const*/ string sel_setEvaluationErrorNumber_1 = sel_registerName("setEvaluationErrorNumber:");
+    public static /*const*/ string sel_setTopLevelObject_1 = sel_registerName("setTopLevelObject:");
+    public static /*const*/ string sel_dataOfType_1error_1 = sel_registerName("dataOfType:error:");
+    public static /*const*/ string sel_isSupersetOfSet_1 = sel_registerName("isSupersetOfSet:");
+    public static /*const*/ string sel_initWithURL_1cachePolicy_1timeoutInterval_1 = sel_registerName("initWithURL:cachePolicy:timeoutInterval:");
+    public static /*const*/ string sel_setAutosaveExpandedItems_1 = sel_registerName("setAutosaveExpandedItems:");
+    public static /*const*/ string sel_rangeValue = sel_registerName("rangeValue");
+    public static /*const*/ string sel_indexPathByAddingIndex_1 = sel_registerName("indexPathByAddingIndex:");
+    public static /*const*/ string sel_deleteToMark_1 = sel_registerName("deleteToMark:");
+    public static /*const*/ string sel_appleEventCodeForSuite_1 = sel_registerName("appleEventCodeForSuite:");
+    public static /*const*/ string sel_getBytes_1 = sel_registerName("getBytes:");
+    public static /*const*/ string sel_setMinimumDaysInFirstWeek_1 = sel_registerName("setMinimumDaysInFirstWeek:");
+    public static /*const*/ string sel_refusesFirstResponder = sel_registerName("refusesFirstResponder");
+    public static /*const*/ string sel_setMaxItemSize_1 = sel_registerName("setMaxItemSize:");
+    public static /*const*/ string sel_localizedStringForKey_1value_1table_1 = sel_registerName("localizedStringForKey:value:table:");
+    public static /*const*/ string sel_mapTableWithKeyOptions_1valueOptions_1 = sel_registerName("mapTableWithKeyOptions:valueOptions:");
+    public static /*const*/ string sel_test = sel_registerName("test");
+    public static /*const*/ string sel_trackScrollButtons_1 = sel_registerName("trackScrollButtons:");
+    public static /*const*/ string sel_PDFRepresentation = sel_registerName("PDFRepresentation");
+    public static /*const*/ string sel_setImageFrameStyle_1 = sel_registerName("setImageFrameStyle:");
+    public static /*const*/ string sel_encodeClassName_1intoClassName_1 = sel_registerName("encodeClassName:intoClassName:");
+    public static /*const*/ string sel_beginPageInRect_1atPlacement_1 = sel_registerName("beginPageInRect:atPlacement:");
+    public static /*const*/ string sel_setAllowsOtherFileTypes_1 = sel_registerName("setAllowsOtherFileTypes:");
+    public static /*const*/ string sel_isWordInUserDictionaries_1caseSensitive_1 = sel_registerName("isWordInUserDictionaries:caseSensitive:");
+    public static /*const*/ string sel_dispatchRawAppleEvent_1withRawReply_1handlerRefCon_1 = sel_registerName("dispatchRawAppleEvent:withRawReply:handlerRefCon:");
+    public static /*const*/ string sel_isScrollable = sel_registerName("isScrollable");
+    public static /*const*/ string sel_numberOfColorStops = sel_registerName("numberOfColorStops");
+    public static /*const*/ string sel_unhideAllApplications_1 = sel_registerName("unhideAllApplications:");
+    public static /*const*/ string sel_retainCount = sel_registerName("retainCount");
+    public static /*const*/ string sel_runModalPrintOperation_1delegate_1didRunSelector_1contextInfo_1 = sel_registerName("runModalPrintOperation:delegate:didRunSelector:contextInfo:");
+    public static /*const*/ string sel_update = sel_registerName("update");
+    public static /*const*/ string sel_isRotatedOrScaledFromBase = sel_registerName("isRotatedOrScaledFromBase");
+    public static /*const*/ string sel_initWithWindowNibPath_1owner_1 = sel_registerName("initWithWindowNibPath:owner:");
+    public static /*const*/ string sel_entryType = sel_registerName("entryType");
+    public static /*const*/ string sel_dictionaryFromTXTRecordData_1 = sel_registerName("dictionaryFromTXTRecordData:");
+    public static /*const*/ string sel_setLineCapStyle_1 = sel_registerName("setLineCapStyle:");
+    public static /*const*/ string sel_setValues_1forParameter_1 = sel_registerName("setValues:forParameter:");
+    public static /*const*/ string sel_numberStyle = sel_registerName("numberStyle");
+    public static /*const*/ string sel_disableCollectorForPointer_1 = sel_registerName("disableCollectorForPointer:");
+    public static /*const*/ string sel_initWithPointerFunctions_1capacity_1 = sel_registerName("initWithPointerFunctions:capacity:");
+    public static /*const*/ string sel_sendEvent_1 = sel_registerName("sendEvent:");
+    public static /*const*/ string sel_removeSelectedObjects_1 = sel_registerName("removeSelectedObjects:");
+    public static /*const*/ string sel_serviceConnectionWithName_1rootObject_1usingNameServer_1 = sel_registerName("serviceConnectionWithName:rootObject:usingNameServer:");
+    public static /*const*/ string sel_decimalNumberByMultiplyingBy_1 = sel_registerName("decimalNumberByMultiplyingBy:");
+    public static /*const*/ string sel_shouldChangeTextInRanges_1replacementStrings_1 = sel_registerName("shouldChangeTextInRanges:replacementStrings:");
+    public static /*const*/ string sel_setResizeIncrements_1 = sel_registerName("setResizeIncrements:");
+    public static /*const*/ string sel_alignLeft_1 = sel_registerName("alignLeft:");
+    public static /*const*/ string sel_launch = sel_registerName("launch");
+    public static /*const*/ string sel_executeCommand = sel_registerName("executeCommand");
+    public static /*const*/ string sel_setPixelBuffer_1cubeMapFace_1mipMapLevel_1currentVirtualScreen_1 = sel_registerName("setPixelBuffer:cubeMapFace:mipMapLevel:currentVirtualScreen:");
+    public static /*const*/ string sel_isCachedSeparately = sel_registerName("isCachedSeparately");
+    public static /*const*/ string sel_setUsesSignificantDigits_1 = sel_registerName("setUsesSignificantDigits:");
+    public static /*const*/ string sel_countKeyPathForNode_1 = sel_registerName("countKeyPathForNode:");
+    public static /*const*/ string sel_setContainerIsRangeContainerObject_1 = sel_registerName("setContainerIsRangeContainerObject:");
+    public static /*const*/ string sel_showsStateColumn = sel_registerName("showsStateColumn");
+    public static /*const*/ string sel_uppercaseString = sel_registerName("uppercaseString");
+    public static /*const*/ string sel_directoryContentsAtPath_1 = sel_registerName("directoryContentsAtPath:");
+    public static /*const*/ string sel_titleFont = sel_registerName("titleFont");
+    public static /*const*/ string sel_comparisonPredicateModifier = sel_registerName("comparisonPredicateModifier");
+    public static /*const*/ string sel_isMultiThreaded = sel_registerName("isMultiThreaded");
+    public static /*const*/ string sel_setGroupingAttributes_1 = sel_registerName("setGroupingAttributes:");
+    public static /*const*/ string sel_selectedRowIndexesInColumn_1 = sel_registerName("selectedRowIndexesInColumn:");
+    public static /*const*/ string sel_isFlushWindowDisabled = sel_registerName("isFlushWindowDisabled");
+    public static /*const*/ string sel_setReusesColumns_1 = sel_registerName("setReusesColumns:");
+    public static /*const*/ string sel_getCString_1maxLength_1 = sel_registerName("getCString:maxLength:");
+    public static /*const*/ string sel_setIndicatorImage_1inTableColumn_1 = sel_registerName("setIndicatorImage:inTableColumn:");
+    public static /*const*/ string sel_keyEquivalent = sel_registerName("keyEquivalent");
+    public static /*const*/ string sel_skipDescendents = sel_registerName("skipDescendents");
+    public static /*const*/ string sel_waitUntilExit = sel_registerName("waitUntilExit");
+    public static /*const*/ string sel_initWithWindowNibName_1owner_1 = sel_registerName("initWithWindowNibName:owner:");
+    public static /*const*/ string sel_objectClass = sel_registerName("objectClass");
+    public static /*const*/ string sel_allFrameworks = sel_registerName("allFrameworks");
+    public static /*const*/ string sel_cellWithTag_1 = sel_registerName("cellWithTag:");
+    public static /*const*/ string sel_representationUsingType_1properties_1 = sel_registerName("representationUsingType:properties:");
+    public static /*const*/ string sel_textPasteboardTypes = sel_registerName("textPasteboardTypes");
+    public static /*const*/ string sel_contentViewMargins = sel_registerName("contentViewMargins");
+    public static /*const*/ string sel_canUndo = sel_registerName("canUndo");
+    public static /*const*/ string sel_initWithFormat_1locale_1arguments_1 = sel_registerName("initWithFormat:locale:arguments:");
+    public static /*const*/ string sel_usableParts = sel_registerName("usableParts");
+    public static /*const*/ string sel_comboBoxSelectionIsChanging_1 = sel_registerName("comboBoxSelectionIsChanging:");
+    public static /*const*/ string sel_raise_1format_1arguments_1 = sel_registerName("raise:format:arguments:");
+    public static /*const*/ string sel_isWindowLoaded = sel_registerName("isWindowLoaded");
+    public static /*const*/ string sel_levelIndicatorStyle = sel_registerName("levelIndicatorStyle");
+    public static /*const*/ string sel_localizedFailureReason = sel_registerName("localizedFailureReason");
+    public static /*const*/ string sel_characterRangeForGlyphRange_1actualGlyphRange_1 = sel_registerName("characterRangeForGlyphRange:actualGlyphRange:");
+    public static /*const*/ string sel_lineNumber = sel_registerName("lineNumber");
+    public static /*const*/ string sel_HTTPBody = sel_registerName("HTTPBody");
+    public static /*const*/ string sel_lineBreakMode = sel_registerName("lineBreakMode");
+    public static /*const*/ string sel_isStopped = sel_registerName("isStopped");
+    public static /*const*/ string sel_canResumeDownloadDecodedWithEncodingMIMEType_1 = sel_registerName("canResumeDownloadDecodedWithEncodingMIMEType:");
+    public static /*const*/ string sel_removeObjectsAtArrangedObjectIndexPaths_1 = sel_registerName("removeObjectsAtArrangedObjectIndexPaths:");
+    public static /*const*/ string sel_isHidden = sel_registerName("isHidden");
+    public static /*const*/ string sel_otherMouseDragged_1 = sel_registerName("otherMouseDragged:");
+    public static /*const*/ string sel_headerRectOfColumn_1 = sel_registerName("headerRectOfColumn:");
+    public static /*const*/ string sel_hasVerticalRuler = sel_registerName("hasVerticalRuler");
+    public static /*const*/ string sel_setBottomMargin_1 = sel_registerName("setBottomMargin:");
+    public static /*const*/ string sel_initWithNotificationCenter_1 = sel_registerName("initWithNotificationCenter:");
+    public static /*const*/ string sel_addSpeechDictionary_1 = sel_registerName("addSpeechDictionary:");
+    public static /*const*/ string sel_setPositiveFormat_1 = sel_registerName("setPositiveFormat:");
+    public static /*const*/ string sel_application_1openTempFile_1 = sel_registerName("application:openTempFile:");
+    public static /*const*/ string sel_setEntityName_1 = sel_registerName("setEntityName:");
+    public static /*const*/ string sel_setForegroundColor_1 = sel_registerName("setForegroundColor:");
+    public static /*const*/ string sel_initWithUnsignedLong_1 = sel_registerName("initWithUnsignedLong:");
+    public static /*const*/ string sel_setWindowsMenu_1 = sel_registerName("setWindowsMenu:");
+    public static /*const*/ string sel_applicationDidUnhide_1 = sel_registerName("applicationDidUnhide:");
+    public static /*const*/ string sel_availableData = sel_registerName("availableData");
+    public static /*const*/ string sel_setVertical_1 = sel_registerName("setVertical:");
+    public static /*const*/ string sel_disableUpdates = sel_registerName("disableUpdates");
+    public static /*const*/ string sel_compileAndReturnError_1 = sel_registerName("compileAndReturnError:");
+    public static /*const*/ string sel_containsIndex_1 = sel_registerName("containsIndex:");
+    public static /*const*/ string sel_canSelectPrevious = sel_registerName("canSelectPrevious");
+    public static /*const*/ string sel_initWithBytes_1length_1encoding_1 = sel_registerName("initWithBytes:length:encoding:");
+    public static /*const*/ string sel_setTextColor_1 = sel_registerName("setTextColor:");
+    public static /*const*/ string sel_stream_1handleEvent_1 = sel_registerName("stream:handleEvent:");
+    public static /*const*/ string sel_setWeekdaySymbols_1 = sel_registerName("setWeekdaySymbols:");
+    public static /*const*/ string sel_setHiddenUntilMouseMoves_1 = sel_registerName("setHiddenUntilMouseMoves:");
+    public static /*const*/ string sel_orderFrontStandardAboutPanelWithOptions_1 = sel_registerName("orderFrontStandardAboutPanelWithOptions:");
+    public static /*const*/ string sel_setAttributesAsDictionary_1 = sel_registerName("setAttributesAsDictionary:");
+    public static /*const*/ string sel_rowTypeForRow_1 = sel_registerName("rowTypeForRow:");
+    public static /*const*/ string sel_setRequestTimeout_1 = sel_registerName("setRequestTimeout:");
+    public static /*const*/ string sel_XMLDataWithOptions_1 = sel_registerName("XMLDataWithOptions:");
+    public static /*const*/ string sel_closedHandCursor = sel_registerName("closedHandCursor");
+    public static /*const*/ string sel_nextSibling = sel_registerName("nextSibling");
+    public static /*const*/ string sel_controlTextColor = sel_registerName("controlTextColor");
+    public static /*const*/ string sel_abbreviationDictionary = sel_registerName("abbreviationDictionary");
+    public static /*const*/ string sel_archiverDidFinish_1 = sel_registerName("archiverDidFinish:");
+    public static /*const*/ string sel_valueTypeForDimension_1 = sel_registerName("valueTypeForDimension:");
+    public static /*const*/ string sel_setCriteriaKeyPath_1 = sel_registerName("setCriteriaKeyPath:");
+    public static /*const*/ string sel_isLessThan_1 = sel_registerName("isLessThan:");
+    public static /*const*/ string sel_processName = sel_registerName("processName");
+    public static /*const*/ string sel_frameOfOutlineCellAtRow_1 = sel_registerName("frameOfOutlineCellAtRow:");
+    public static /*const*/ string sel_removeObjectsInArray_1 = sel_registerName("removeObjectsInArray:");
+    public static /*const*/ string sel_leftExpression = sel_registerName("leftExpression");
+    public static /*const*/ string sel_removeToolTip_1 = sel_registerName("removeToolTip:");
+    public static /*const*/ string sel_mutableCopy = sel_registerName("mutableCopy");
+    public static /*const*/ string sel_directParameter = sel_registerName("directParameter");
+    public static /*const*/ string sel_name = sel_registerName("name");
+    public static /*const*/ string sel_bitsPerPixel = sel_registerName("bitsPerPixel");
+    public static /*const*/ string sel_weekday = sel_registerName("weekday");
+    public static /*const*/ string sel_descendantNodeAtIndexPath_1 = sel_registerName("descendantNodeAtIndexPath:");
+    public static /*const*/ string sel_setPercentSymbol_1 = sel_registerName("setPercentSymbol:");
+    public static /*const*/ string sel_selectedCell = sel_registerName("selectedCell");
+    public static /*const*/ string sel_windowWillClose_1 = sel_registerName("windowWillClose:");
+    public static /*const*/ string sel_setDatePickerStyle_1 = sel_registerName("setDatePickerStyle:");
+    public static /*const*/ string sel_initWithObjects_1 = sel_registerName("initWithObjects:");
+    public static /*const*/ string sel_numberWithInt_1 = sel_registerName("numberWithInt:");
+    public static /*const*/ string sel_collection = sel_registerName("collection");
+    public static /*const*/ string sel_initWithTarget_1selector_1object_1 = sel_registerName("initWithTarget:selector:object:");
+    public static /*const*/ string sel_insertText_1replacementRange_1 = sel_registerName("insertText:replacementRange:");
+    public static /*const*/ string sel_initWithAEDescNoCopy_1 = sel_registerName("initWithAEDescNoCopy:");
+    public static /*const*/ string sel_usesGroupingSeparator = sel_registerName("usesGroupingSeparator");
+    public static /*const*/ string sel_pathControl_1shouldDragPathComponentCell_1withPasteboard_1 = sel_registerName("pathControl:shouldDragPathComponentCell:withPasteboard:");
+    public static /*const*/ string sel_decimalNumberByAdding_1withBehavior_1 = sel_registerName("decimalNumberByAdding:withBehavior:");
+    public static /*const*/ string sel_setTextContainer_1forGlyphRange_1 = sel_registerName("setTextContainer:forGlyphRange:");
+    public static /*const*/ string sel_needsToDrawRect_1 = sel_registerName("needsToDrawRect:");
+    public static /*const*/ string sel_activeConversationChanged_1toNewConversation_1 = sel_registerName("activeConversationChanged:toNewConversation:");
+    public static /*const*/ string sel_italicAngle = sel_registerName("italicAngle");
+    public static /*const*/ string sel_aeteResource_1 = sel_registerName("aeteResource:");
+    public static /*const*/ string sel_noteNewRecentDocumentURL_1 = sel_registerName("noteNewRecentDocumentURL:");
+    public static /*const*/ string sel_setPageScroll_1 = sel_registerName("setPageScroll:");
+    public static /*const*/ string sel_speechSynthesizer_1didFinishSpeaking_1 = sel_registerName("speechSynthesizer:didFinishSpeaking:");
+    public static /*const*/ string sel_convertSizeToBase_1 = sel_registerName("convertSizeToBase:");
+    public static /*const*/ string sel_pointerFunctionsWithOptions_1 = sel_registerName("pointerFunctionsWithOptions:");
+    public static /*const*/ string sel_setHTTPBody_1 = sel_registerName("setHTTPBody:");
+    public static /*const*/ string sel_itemWithTag_1 = sel_registerName("itemWithTag:");
+    public static /*const*/ string sel_spellServer_1checkGrammarInString_1language_1details_1 = sel_registerName("spellServer:checkGrammarInString:language:details:");
+    public static /*const*/ string sel_vendorPointingDeviceType = sel_registerName("vendorPointingDeviceType");
+    public static /*const*/ string sel_firstRectForCharacterRange_1 = sel_registerName("firstRectForCharacterRange:");
+    public static /*const*/ string sel_classDescriptionsInSuite_1 = sel_registerName("classDescriptionsInSuite:");
+    public static /*const*/ string sel_setAttachmentSize_1forGlyphRange_1 = sel_registerName("setAttachmentSize:forGlyphRange:");
+    public static /*const*/ string sel_isEmpty = sel_registerName("isEmpty");
+    public static /*const*/ string sel_soundNamed_1 = sel_registerName("soundNamed:");
+    public static /*const*/ string sel_preparedCellAtColumn_1row_1 = sel_registerName("preparedCellAtColumn:row:");
+    public static /*const*/ string sel_setLeafKeyPath_1 = sel_registerName("setLeafKeyPath:");
+    public static /*const*/ string sel_initWithUnsignedInteger_1 = sel_registerName("initWithUnsignedInteger:");
+    public static /*const*/ string sel_fractionOfDistanceThroughGlyphForPoint_1inTextContainer_1 = sel_registerName("fractionOfDistanceThroughGlyphForPoint:inTextContainer:");
+    public static /*const*/ string sel_isFloatingPanel = sel_registerName("isFloatingPanel");
+    public static /*const*/ string sel_replaceObjectsAtIndexes_1withObjects_1 = sel_registerName("replaceObjectsAtIndexes:withObjects:");
+    public static /*const*/ string sel_getComponents_1 = sel_registerName("getComponents:");
+    public static /*const*/ string sel_fileType = sel_registerName("fileType");
+    public static /*const*/ string sel_setShowsBaselineSeparator_1 = sel_registerName("setShowsBaselineSeparator:");
+    public static /*const*/ string sel_removeCredential_1forProtectionSpace_1 = sel_registerName("removeCredential:forProtectionSpace:");
+    public static /*const*/ string sel_imageRepWithContentsOfFile_1 = sel_registerName("imageRepWithContentsOfFile:");
+    public static /*const*/ string sel_predicateWithFormat_1argumentArray_1 = sel_registerName("predicateWithFormat:argumentArray:");
+    public static /*const*/ string sel_positiveSuffix = sel_registerName("positiveSuffix");
+    public static /*const*/ string sel_formatter = sel_registerName("formatter");
+    public static /*const*/ string sel_setAnimationDelay_1 = sel_registerName("setAnimationDelay:");
+    public static /*const*/ string sel_maxConcurrentOperationCount = sel_registerName("maxConcurrentOperationCount");
+    public static /*const*/ string sel_childSpecifier = sel_registerName("childSpecifier");
+    public static /*const*/ string sel_cacheMode = sel_registerName("cacheMode");
+    public static /*const*/ string sel_registerForServices = sel_registerName("registerForServices");
+    public static /*const*/ string sel_setFirstWeekday_1 = sel_registerName("setFirstWeekday:");
+    public static /*const*/ string sel_rulerViewClass = sel_registerName("rulerViewClass");
+    public static /*const*/ string sel_initialValue = sel_registerName("initialValue");
+    public static /*const*/ string sel_redColor = sel_registerName("redColor");
+    public static /*const*/ string sel_addDependency_1 = sel_registerName("addDependency:");
+    public static /*const*/ string sel_pathExtension = sel_registerName("pathExtension");
+    public static /*const*/ string sel_fastestEncoding = sel_registerName("fastestEncoding");
+    public static /*const*/ string sel_socketType = sel_registerName("socketType");
+    public static /*const*/ string sel_setRuleThickness_1 = sel_registerName("setRuleThickness:");
+    public static /*const*/ string sel_setDTDKind_1 = sel_registerName("setDTDKind:");
+    public static /*const*/ string sel_setClass_1forClassName_1 = sel_registerName("setClass:forClassName:");
+    public static /*const*/ string sel_setDocumentCursor_1 = sel_registerName("setDocumentCursor:");
+    public static /*const*/ string sel_extraLineFragmentRect = sel_registerName("extraLineFragmentRect");
+    public static /*const*/ string sel_attributeForName_1 = sel_registerName("attributeForName:");
+    public static /*const*/ string sel_defaultCredentialForProtectionSpace_1 = sel_registerName("defaultCredentialForProtectionSpace:");
+    public static /*const*/ string sel_indexOfItemWithTag_1 = sel_registerName("indexOfItemWithTag:");
+    public static /*const*/ string sel_fontManager_1willIncludeFont_1 = sel_registerName("fontManager:willIncludeFont:");
+    public static /*const*/ string sel_scrollRangeToVisible_1 = sel_registerName("scrollRangeToVisible:");
+    public static /*const*/ string sel_fileTypeFromLastRunSavePanel = sel_registerName("fileTypeFromLastRunSavePanel");
+    public static /*const*/ string sel_collectionView = sel_registerName("collectionView");
+    public static /*const*/ string sel_tabView = sel_registerName("tabView");
+    public static /*const*/ string sel_commonISOCurrencyCodes = sel_registerName("commonISOCurrencyCodes");
+    public static /*const*/ string sel_removeFontTrait_1 = sel_registerName("removeFontTrait:");
+    public static /*const*/ string sel_drawKnob_1 = sel_registerName("drawKnob:");
+    public static /*const*/ string sel_tokenField_1menuForRepresentedObject_1 = sel_registerName("tokenField:menuForRepresentedObject:");
+    public static /*const*/ string sel_setFrameUsingName_1 = sel_registerName("setFrameUsingName:");
+    public static /*const*/ string sel_classNameEncodedForTrueClassName_1 = sel_registerName("classNameEncodedForTrueClassName:");
+    public static /*const*/ string sel_windowFrameAutosaveName = sel_registerName("windowFrameAutosaveName");
+    public static /*const*/ string sel_characterAtIndex_1 = sel_registerName("characterAtIndex:");
+    public static /*const*/ string sel_smartInsertAfterStringForString_1replacingRange_1 = sel_registerName("smartInsertAfterStringForString:replacingRange:");
+    public static /*const*/ string sel_version = sel_registerName("version");
+    public static /*const*/ string sel_objectsAtIndexes_1 = sel_registerName("objectsAtIndexes:");
+    public static /*const*/ string sel_requestIsCacheEquivalent_1toRequest_1 = sel_registerName("requestIsCacheEquivalent:toRequest:");
+    public static /*const*/ string sel_columnOfMatrix_1 = sel_registerName("columnOfMatrix:");
+    public static /*const*/ string sel_isBezeled = sel_registerName("isBezeled");
+    public static /*const*/ string sel_setAutosaveName_1 = sel_registerName("setAutosaveName:");
+    public static /*const*/ string sel_becomeMainWindow = sel_registerName("becomeMainWindow");
+    public static /*const*/ string sel_pasteAsRichText_1 = sel_registerName("pasteAsRichText:");
+    public static /*const*/ string sel_isSpeaking = sel_registerName("isSpeaking");
+    public static /*const*/ string sel_format = sel_registerName("format");
+    public static /*const*/ string sel_volume = sel_registerName("volume");
+    public static /*const*/ string sel_setMenu_1 = sel_registerName("setMenu:");
+    public static /*const*/ string sel_setEra_1 = sel_registerName("setEra:");
+    public static /*const*/ string sel_textContainerOrigin = sel_registerName("textContainerOrigin");
+    public static /*const*/ string sel_setLocalizesFormat_1 = sel_registerName("setLocalizesFormat:");
+    public static /*const*/ string sel_removeIndex_1 = sel_registerName("removeIndex:");
+    public static /*const*/ string sel_gotoPosterFrame_1 = sel_registerName("gotoPosterFrame:");
+    public static /*const*/ string sel_validateValue_1forKeyPath_1error_1 = sel_registerName("validateValue:forKeyPath:error:");
+    public static /*const*/ string sel_initWithCharactersNoCopy_1length_1freeWhenDone_1 = sel_registerName("initWithCharactersNoCopy:length:freeWhenDone:");
+    public static /*const*/ string sel_initWithLength_1 = sel_registerName("initWithLength:");
+    public static /*const*/ string sel_setAllowsMultipleSelection_1 = sel_registerName("setAllowsMultipleSelection:");
+    public static /*const*/ string sel_isRotatedFromBase = sel_registerName("isRotatedFromBase");
+    public static /*const*/ string sel_beginDocument = sel_registerName("beginDocument");
+    public static /*const*/ string sel_initWithContentsOfURL_1usedEncoding_1error_1 = sel_registerName("initWithContentsOfURL:usedEncoding:error:");
+    public static /*const*/ string sel_showsSuppressionButton = sel_registerName("showsSuppressionButton");
+    public static /*const*/ string sel_tearOffMenuRepresentation = sel_registerName("tearOffMenuRepresentation");
+    public static /*const*/ string sel_otherEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1subtype_1data1_1data2_1 = sel_registerName("otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:");
+    public static /*const*/ string sel_imageUnfilteredFileTypes = sel_registerName("imageUnfilteredFileTypes");
+    public static /*const*/ string sel_isGathering = sel_registerName("isGathering");
+    public static /*const*/ string sel_slideImage_1from_1to_1 = sel_registerName("slideImage:from:to:");
+    public static /*const*/ string sel_initWithTCPPort_1 = sel_registerName("initWithTCPPort:");
+    public static /*const*/ string sel_StringByFoldingWithOptions_1locale_1 = sel_registerName("StringByFoldingWithOptions:locale:");
+    public static /*const*/ string sel_viewDidUnhide = sel_registerName("viewDidUnhide");
+    public static /*const*/ string sel_controlSize = sel_registerName("controlSize");
+    public static /*const*/ string sel_resourceDataUsingCache_1 = sel_registerName("resourceDataUsingCache:");
+    public static /*const*/ string sel_startWhenAnimation_1reachesProgress_1 = sel_registerName("startWhenAnimation:reachesProgress:");
+    public static /*const*/ string sel_registerURLHandleClass_1 = sel_registerName("registerURLHandleClass:");
+    public static /*const*/ string sel_indicatorImageInTableColumn_1 = sel_registerName("indicatorImageInTableColumn:");
+    public static /*const*/ string sel_decimalNumberByMultiplyingByPowerOf10_1 = sel_registerName("decimalNumberByMultiplyingByPowerOf10:");
+    public static /*const*/ string sel_scrollPoint_1 = sel_registerName("scrollPoint:");
+    public static /*const*/ string sel_setValue_1forKeyPath_1 = sel_registerName("setValue:forKeyPath:");
+    public static /*const*/ string sel_fontDescriptorWithMatrix_1 = sel_registerName("fontDescriptorWithMatrix:");
+    public static /*const*/ string sel_parser_1foundProcessingInstructionWithTarget_1data_1 = sel_registerName("parser:foundProcessingInstructionWithTarget:data:");
+    public static /*const*/ string sel_interfaceStyle = sel_registerName("interfaceStyle");
+    public static /*const*/ string sel_comboBox_1objectValueForItemAtIndex_1 = sel_registerName("comboBox:objectValueForItemAtIndex:");
+    public static /*const*/ string sel_applicationDidFinishLaunching_1 = sel_registerName("applicationDidFinishLaunching:");
+    public static /*const*/ string sel_currentMemoryUsage = sel_registerName("currentMemoryUsage");
+    public static /*const*/ string sel_altersStateOfSelectedItem = sel_registerName("altersStateOfSelectedItem");
+    public static /*const*/ string sel_selectedColumn = sel_registerName("selectedColumn");
+    public static /*const*/ string sel_convertBaseToScreen_1 = sel_registerName("convertBaseToScreen:");
+    public static /*const*/ string sel_lineHeightMultiple = sel_registerName("lineHeightMultiple");
+    public static /*const*/ string sel_CGColorSpace = sel_registerName("CGColorSpace");
+    public static /*const*/ string sel_descriptionInStringsFileFormat = sel_registerName("descriptionInStringsFileFormat");
+    public static /*const*/ string sel_isOutputStackInReverseOrder = sel_registerName("isOutputStackInReverseOrder");
+    public static /*const*/ string sel_takeValue_1forKey_1 = sel_registerName("takeValue:forKey:");
+    public static /*const*/ string sel_StringWithContentsOfFile_1 = sel_registerName("StringWithContentsOfFile:");
+    public static /*const*/ string sel_addItem_1 = sel_registerName("addItem:");
+    public static /*const*/ string sel_viewWillMoveToWindow_1 = sel_registerName("viewWillMoveToWindow:");
+    public static /*const*/ string sel_changeFileAttributes_1atPath_1 = sel_registerName("changeFileAttributes:atPath:");
+    public static /*const*/ string sel_userFixedPitchFontOfSize_1 = sel_registerName("userFixedPitchFontOfSize:");
+    public static /*const*/ string sel_selectRowIndexes_1inColumn_1 = sel_registerName("selectRowIndexes:inColumn:");
+    public static /*const*/ string sel_defaultLineCapStyle = sel_registerName("defaultLineCapStyle");
+    public static /*const*/ string sel_attributedAlternateTitle = sel_registerName("attributedAlternateTitle");
+    public static /*const*/ string sel_fileExistsAtPath_1 = sel_registerName("fileExistsAtPath:");
+    public static /*const*/ string sel_textView_1clickedOnLink_1atIndex_1 = sel_registerName("textView:clickedOnLink:atIndex:");
+    public static /*const*/ string sel_drawers = sel_registerName("drawers");
+    public static /*const*/ string sel_outlineView_1shouldSelectTableColumn_1 = sel_registerName("outlineView:shouldSelectTableColumn:");
+    public static /*const*/ string sel_pointValue = sel_registerName("pointValue");
+    public static /*const*/ string sel_integerValue = sel_registerName("integerValue");
+    public static /*const*/ string sel_modifyFontViaPanel_1 = sel_registerName("modifyFontViaPanel:");
+    public static /*const*/ string sel_windowTitleForDocumentDisplayName_1 = sel_registerName("windowTitleForDocumentDisplayName:");
+    public static /*const*/ string sel_shortWeekdaySymbols = sel_registerName("shortWeekdaySymbols");
+    public static /*const*/ string sel_titleOfSelectedItem = sel_registerName("titleOfSelectedItem");
+    public static /*const*/ string sel_setWindowsNeedUpdate_1 = sel_registerName("setWindowsNeedUpdate:");
+    public static /*const*/ string sel_StringWithUTF8String_1 = sel_registerName("StringWithUTF8String:");
+    public static /*const*/ string sel_transformedValueClass = sel_registerName("transformedValueClass");
+    public static /*const*/ string sel_initWithColorsAndLocations_1 = sel_registerName("initWithColorsAndLocations:");
+    public static /*const*/ string sel_acceptsMouseMovedEvents = sel_registerName("acceptsMouseMovedEvents");
+    public static /*const*/ string sel_toolTipsFontOfSize_1 = sel_registerName("toolTipsFontOfSize:");
+    public static /*const*/ string sel_setTextAttributesForPositiveValues_1 = sel_registerName("setTextAttributesForPositiveValues:");
+    public static /*const*/ string sel_setAlwaysShowsDecimalSeparator_1 = sel_registerName("setAlwaysShowsDecimalSeparator:");
+    public static /*const*/ string sel_setNumberOfColumns_1 = sel_registerName("setNumberOfColumns:");
+    public static /*const*/ string sel_moveRightAndModifySelection_1 = sel_registerName("moveRightAndModifySelection:");
+    public static /*const*/ string sel_indexOfItem_1 = sel_registerName("indexOfItem:");
+    public static /*const*/ string sel_moveWordRight_1 = sel_registerName("moveWordRight:");
+    public static /*const*/ string sel_numberWithUnsignedLongLong_1 = sel_registerName("numberWithUnsignedLongLong:");
+    public static /*const*/ string sel_initWithAuthenticationChallenge_1sender_1 = sel_registerName("initWithAuthenticationChallenge:sender:");
+    public static /*const*/ string sel_panelConvertFont_1 = sel_registerName("panelConvertFont:");
+    public static /*const*/ string sel_temporaryAttribute_1atCharacterIndex_1effectiveRange_1 = sel_registerName("temporaryAttribute:atCharacterIndex:effectiveRange:");
+    public static /*const*/ string sel_intersectHashTable_1 = sel_registerName("intersectHashTable:");
+    public static /*const*/ string sel_positionOfGlyph_1precededByGlyph_1isNominal_1 = sel_registerName("positionOfGlyph:precededByGlyph:isNominal:");
+    public static /*const*/ string sel_setLocalizedKeyTable_1 = sel_registerName("setLocalizedKeyTable:");
+    public static /*const*/ string sel_fileManager_1shouldLinkItemAtPath_1toPath_1 = sel_registerName("fileManager:shouldLinkItemAtPath:toPath:");
+    public static /*const*/ string sel_setScriptErrorNumber_1 = sel_registerName("setScriptErrorNumber:");
+    public static /*const*/ string sel_initWithLocaleIdentifier_1 = sel_registerName("initWithLocaleIdentifier:");
+    public static /*const*/ string sel_toolTip = sel_registerName("toolTip");
+    public static /*const*/ string sel_alternateMnemonic = sel_registerName("alternateMnemonic");
+    public static /*const*/ string sel_setChannelMapping_1 = sel_registerName("setChannelMapping:");
+    public static /*const*/ string sel_setLocalizedKey_1 = sel_registerName("setLocalizedKey:");
+    public static /*const*/ string sel_selector = sel_registerName("selector");
+    public static /*const*/ string sel_setCurrencyGroupingSeparator_1 = sel_registerName("setCurrencyGroupingSeparator:");
+    public static /*const*/ string sel_initWithKeyOptions_1valueOptions_1capacity_1 = sel_registerName("initWithKeyOptions:valueOptions:capacity:");
+    public static /*const*/ string sel_setStandaloneMonthSymbols_1 = sel_registerName("setStandaloneMonthSymbols:");
+    public static /*const*/ string sel_physicalMemory = sel_registerName("physicalMemory");
+    public static /*const*/ string sel_parse = sel_registerName("parse");
+    public static /*const*/ string sel_defaultTypesetterBehavior = sel_registerName("defaultTypesetterBehavior");
+    public static /*const*/ string sel_setRulerVisible_1 = sel_registerName("setRulerVisible:");
+    public static /*const*/ string sel_resizeDownCursor = sel_registerName("resizeDownCursor");
+    public static /*const*/ string sel_getBoundingRects_1forGlyphs_1count_1 = sel_registerName("getBoundingRects:forGlyphs:count:");
+    public static /*const*/ string sel_openPanel = sel_registerName("openPanel");
+    public static /*const*/ string sel_setEntryWidth_1 = sel_registerName("setEntryWidth:");
+    public static /*const*/ string sel_insertChildren_1atIndex_1 = sel_registerName("insertChildren:atIndex:");
+    public static /*const*/ string sel_selectNext_1 = sel_registerName("selectNext:");
+    public static /*const*/ string sel_paragraphGlyphRange = sel_registerName("paragraphGlyphRange");
+    public static /*const*/ string sel_animations = sel_registerName("animations");
+    public static /*const*/ string sel_setMarkers_1 = sel_registerName("setMarkers:");
+    public static /*const*/ string sel_raise = sel_registerName("raise");
+    public static /*const*/ string sel_menuZone = sel_registerName("menuZone");
+    public static /*const*/ string sel_weekdaySymbols = sel_registerName("weekdaySymbols");
+    public static /*const*/ string sel_setHTTPMethod_1 = sel_registerName("setHTTPMethod:");
+    public static /*const*/ string sel_placeholderAttributedString = sel_registerName("placeholderAttributedString");
+    public static /*const*/ string sel_filenameExtension_1isValidForType_1 = sel_registerName("filenameExtension:isValidForType:");
+    public static /*const*/ string sel_initWithReceivePort_1sendPort_1 = sel_registerName("initWithReceivePort:sendPort:");
+    public static /*const*/ string sel_setContextHelp_1forObject_1 = sel_registerName("setContextHelp:forObject:");
+    public static /*const*/ string sel_archiveRootObject_1toFile_1 = sel_registerName("archiveRootObject:toFile:");
+    public static /*const*/ string sel_setAnimations_1 = sel_registerName("setAnimations:");
+    public static /*const*/ string sel_locationOfPrintRect_1 = sel_registerName("locationOfPrintRect:");
+    public static /*const*/ string sel_setInterfaceStyle_1 = sel_registerName("setInterfaceStyle:");
+    public static /*const*/ string sel_startMonitoring = sel_registerName("startMonitoring");
+    public static /*const*/ string sel_presentError_1modalForWindow_1delegate_1didPresentSelector_1contextInfo_1 = sel_registerName("presentError:modalForWindow:delegate:didPresentSelector:contextInfo:");
+    public static /*const*/ string sel_windowFrameColor = sel_registerName("windowFrameColor");
+    public static /*const*/ string sel_paragraphSpacing = sel_registerName("paragraphSpacing");
+    public static /*const*/ string sel_fileAttributes = sel_registerName("fileAttributes");
+    public static /*const*/ string sel_setDisplayedCommandsTitle_1 = sel_registerName("setDisplayedCommandsTitle:");
+    public static /*const*/ string sel_preflightAndReturnError_1 = sel_registerName("preflightAndReturnError:");
+    public static /*const*/ string sel_setObservationInfo_1 = sel_registerName("setObservationInfo:");
+    public static /*const*/ string sel_currentCommand = sel_registerName("currentCommand");
+    public static /*const*/ string sel_processInfo = sel_registerName("processInfo");
+    public static /*const*/ string sel_appendString_1 = sel_registerName("appendString:");
+    public static /*const*/ string sel_setShowsHelp_1 = sel_registerName("setShowsHelp:");
+    public static /*const*/ string sel_datePickerStyle = sel_registerName("datePickerStyle");
+    public static /*const*/ string sel_addFileWrapper_1 = sel_registerName("addFileWrapper:");
+    public static /*const*/ string sel_bitmapImageRepForCachingDisplayInRect_1 = sel_registerName("bitmapImageRepForCachingDisplayInRect:");
+    public static /*const*/ string sel_initWithFileAtPath_1 = sel_registerName("initWithFileAtPath:");
+    public static /*const*/ string sel_cellClass = sel_registerName("cellClass");
+    public static /*const*/ string sel_imageRepsWithContentsOfFile_1 = sel_registerName("imageRepsWithContentsOfFile:");
+    public static /*const*/ string sel_localizedScannerWithString_1 = sel_registerName("localizedScannerWithString:");
+    public static /*const*/ string sel_isExpandable_1 = sel_registerName("isExpandable:");
+    public static /*const*/ string sel_isLoaded = sel_registerName("isLoaded");
+    public static /*const*/ string sel_browser_1acceptDrop_1atRow_1column_1dropOperation_1 = sel_registerName("browser:acceptDrop:atRow:column:dropOperation:");
+    public static /*const*/ string sel_panel_1directoryDidChange_1 = sel_registerName("panel:directoryDidChange:");
+    public static /*const*/ string sel_publicID = sel_registerName("publicID");
+    public static /*const*/ string sel_contentMaxSize = sel_registerName("contentMaxSize");
+    public static /*const*/ string sel_menuDidClose_1 = sel_registerName("menuDidClose:");
+    public static /*const*/ string sel_setPrinter_1 = sel_registerName("setPrinter:");
+    public static /*const*/ string sel_keywordForDescriptorAtIndex_1 = sel_registerName("keywordForDescriptorAtIndex:");
+    public static /*const*/ string sel_notANumberSymbol = sel_registerName("notANumberSymbol");
+    public static /*const*/ string sel_minimumLineHeight = sel_registerName("minimumLineHeight");
+    public static /*const*/ string sel_setContentBorderThickness_1forEdge_1 = sel_registerName("setContentBorderThickness:forEdge:");
+    public static /*const*/ string sel_titleFrameOfColumn_1 = sel_registerName("titleFrameOfColumn:");
+    public static /*const*/ string sel_dateValue = sel_registerName("dateValue");
+    public static /*const*/ string sel_numberOfRows = sel_registerName("numberOfRows");
+    public static /*const*/ string sel_isReadableFileAtPath_1 = sel_registerName("isReadableFileAtPath:");
+    public static /*const*/ string sel_canInsertChild = sel_registerName("canInsertChild");
+    public static /*const*/ string sel_StringByReplacingOccurrencesOfString_1withString_1options_1range_1 = sel_registerName("StringByReplacingOccurrencesOfString:withString:options:range:");
+    public static /*const*/ string sel_ok_1 = sel_registerName("ok:");
+    public static /*const*/ string sel_hourOfDay = sel_registerName("hourOfDay");
+    public static /*const*/ string sel_paragraphRangeForRange_1 = sel_registerName("paragraphRangeForRange:");
+    public static /*const*/ string sel_focusStack = sel_registerName("focusStack");
+    public static /*const*/ string sel_setUsesThreadedAnimation_1 = sel_registerName("setUsesThreadedAnimation:");
+    public static /*const*/ string sel_dataForType_1 = sel_registerName("dataForType:");
+    public static /*const*/ string sel_isByref = sel_registerName("isByref");
+    public static /*const*/ string sel_initWithResponse_1data_1userInfo_1storagePolicy_1 = sel_registerName("initWithResponse:data:userInfo:storagePolicy:");
+    public static /*const*/ string sel_initWithSerializedRepresentation_1 = sel_registerName("initWithSerializedRepresentation:");
+    public static /*const*/ string sel_openDocument_1 = sel_registerName("openDocument:");
+    public static /*const*/ string sel_translateRectsNeedingDisplayInRect_1by_1 = sel_registerName("translateRectsNeedingDisplayInRect:by:");
+    public static /*const*/ string sel_highlightsBy = sel_registerName("highlightsBy");
+    public static /*const*/ string sel_openHandCursor = sel_registerName("openHandCursor");
+    public static /*const*/ string sel_lineFragmentRectForProposedRect_1remainingRect_1 = sel_registerName("lineFragmentRectForProposedRect:remainingRect:");
+    public static /*const*/ string sel_selectedNodes = sel_registerName("selectedNodes");
+    public static /*const*/ string sel_replaceObjectAtIndex_1withObject_1 = sel_registerName("replaceObjectAtIndex:withObject:");
+    public static /*const*/ string sel_indexOfItemAtPoint_1 = sel_registerName("indexOfItemAtPoint:");
+    public static /*const*/ string sel_setCriteria_1andDisplayValues_1forRowAtIndex_1 = sel_registerName("setCriteria:andDisplayValues:forRowAtIndex:");
+    public static /*const*/ string sel_textStorage_1edited_1range_1changeInLength_1invalidatedRange_1 = sel_registerName("textStorage:edited:range:changeInLength:invalidatedRange:");
+    public static /*const*/ string sel_synchronizeWindowTitleWithDocumentName = sel_registerName("synchronizeWindowTitleWithDocumentName");
+    public static /*const*/ string sel_fileHandleWithNullDevice = sel_registerName("fileHandleWithNullDevice");
+    public static /*const*/ string sel_descriptorWithTypeCode_1 = sel_registerName("descriptorWithTypeCode:");
+    public static /*const*/ string sel_initWithDocFormat_1documentAttributes_1 = sel_registerName("initWithDocFormat:documentAttributes:");
+    public static /*const*/ string sel_setAutoresizingMask_1 = sel_registerName("setAutoresizingMask:");
+    public static /*const*/ string sel_methodReturnLength = sel_registerName("methodReturnLength");
+    public static /*const*/ string sel_recentDocumentURLs = sel_registerName("recentDocumentURLs");
+    public static /*const*/ string sel_setCurrentDirectoryPath_1 = sel_registerName("setCurrentDirectoryPath:");
+    public static /*const*/ string sel_characterSetWithRange_1 = sel_registerName("characterSetWithRange:");
+    public static /*const*/ string sel_resizeUpCursor = sel_registerName("resizeUpCursor");
+    public static /*const*/ string sel_rect = sel_registerName("rect");
+    public static /*const*/ string sel_removeCharactersInRange_1 = sel_registerName("removeCharactersInRange:");
+    public static /*const*/ string sel_performSelectorOnMainThread_1withObject_1waitUntilDone_1 = sel_registerName("performSelectorOnMainThread:withObject:waitUntilDone:");
+    public static /*const*/ string sel_elementAtIndex_1associatedPoints_1 = sel_registerName("elementAtIndex:associatedPoints:");
+    public static /*const*/ string sel_dataForKey_1 = sel_registerName("dataForKey:");
+    public static /*const*/ string sel_defaultDepthLimit = sel_registerName("defaultDepthLimit");
+    public static /*const*/ string sel_rulersVisible = sel_registerName("rulersVisible");
+    public static /*const*/ string sel_generalPasteboard = sel_registerName("generalPasteboard");
+    public static /*const*/ string sel_setAllowsTickMarkValuesOnly_1 = sel_registerName("setAllowsTickMarkValuesOnly:");
+    public static /*const*/ string sel_stateImageOffset = sel_registerName("stateImageOffset");
+    public static /*const*/ string sel_isBordered = sel_registerName("isBordered");
+    public static /*const*/ string sel_insertPointer_1atIndex_1 = sel_registerName("insertPointer:atIndex:");
+    public static /*const*/ string sel_keyForFileWrapper_1 = sel_registerName("keyForFileWrapper:");
+    public static /*const*/ string sel_renewGState = sel_registerName("renewGState");
+    public static /*const*/ string sel_autovalidates = sel_registerName("autovalidates");
+    public static /*const*/ string sel_localizedNameForFamily_1face_1 = sel_registerName("localizedNameForFamily:face:");
+    public static /*const*/ string sel_setAltIncrementValue_1 = sel_registerName("setAltIncrementValue:");
+    public static /*const*/ string sel_sortUsingFunction_1context_1 = sel_registerName("sortUsingFunction:context:");
+    public static /*const*/ string sel_fileNameExtensionWasHiddenInLastRunSavePanel = sel_registerName("fileNameExtensionWasHiddenInLastRunSavePanel");
+    public static /*const*/ string sel_endSheet_1returnCode_1 = sel_registerName("endSheet:returnCode:");
+    public static /*const*/ string sel_insertObjects_1atIndexes_1 = sel_registerName("insertObjects:atIndexes:");
+    public static /*const*/ string sel_standaloneMonthSymbols = sel_registerName("standaloneMonthSymbols");
+    public static /*const*/ string sel_prefersAllColumnUserResizing = sel_registerName("prefersAllColumnUserResizing");
+    public static /*const*/ string sel_separatesColumns = sel_registerName("separatesColumns");
+    public static /*const*/ string sel_moveToBeginningOfDocument_1 = sel_registerName("moveToBeginningOfDocument:");
+    public static /*const*/ string sel_objectZone = sel_registerName("objectZone");
+    public static /*const*/ string sel_initWithURL_1MIMEType_1expectedContentLength_1textEncodingName_1 = sel_registerName("initWithURL:MIMEType:expectedContentLength:textEncodingName:");
+    public static /*const*/ string sel_gotoEnd_1 = sel_registerName("gotoEnd:");
+    public static /*const*/ string sel_superscriptRange_1 = sel_registerName("superscriptRange:");
+    public static /*const*/ string sel_readInBackgroundAndNotifyForModes_1 = sel_registerName("readInBackgroundAndNotifyForModes:");
+    public static /*const*/ string sel_initWithObjects_1forKeys_1 = sel_registerName("initWithObjects:forKeys:");
+    public static /*const*/ string sel_cancel = sel_registerName("cancel");
+    public static /*const*/ string sel_suiteName = sel_registerName("suiteName");
+    public static /*const*/ string sel_sortedArrayUsingFunction_1context_1hint_1 = sel_registerName("sortedArrayUsingFunction:context:hint:");
+    public static /*const*/ string sel_countWordsInString_1language_1 = sel_registerName("countWordsInString:language:");
+    public static /*const*/ string sel_prepareWithInvocationTarget_1 = sel_registerName("prepareWithInvocationTarget:");
+    public static /*const*/ string sel_statusItemWithLength_1 = sel_registerName("statusItemWithLength:");
+    public static /*const*/ string sel_tableView_1shouldEditTableColumn_1row_1 = sel_registerName("tableView:shouldEditTableColumn:row:");
+    public static /*const*/ string sel_appendBezierPathWithRect_1 = sel_registerName("appendBezierPathWithRect:");
+    public static /*const*/ string sel_scrollColumnsRightBy_1 = sel_registerName("scrollColumnsRightBy:");
+    public static /*const*/ string sel_negativeInfinitySymbol = sel_registerName("negativeInfinitySymbol");
+    public static /*const*/ string sel_firstLineHeadIndent = sel_registerName("firstLineHeadIndent");
+    public static /*const*/ string sel_generateGlyphsForGlyphStorage_1desiredNumberOfCharacters_1glyphIndex_1characterIndex_1 = sel_registerName("generateGlyphsForGlyphStorage:desiredNumberOfCharacters:glyphIndex:characterIndex:");
+    public static /*const*/ string sel_dateWithTimeIntervalSinceReferenceDate_1 = sel_registerName("dateWithTimeIntervalSinceReferenceDate:");
+    public static /*const*/ string sel_menu_1updateItem_1atIndex_1shouldCancel_1 = sel_registerName("menu:updateItem:atIndex:shouldCancel:");
+    public static /*const*/ string sel_connection_1willSendRequest_1redirectResponse_1 = sel_registerName("connection:willSendRequest:redirectResponse:");
+    public static /*const*/ string sel_attemptRecoveryFromError_1optionIndex_1delegate_1didRecoverSelector_1contextInfo_1 = sel_registerName("attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:");
+    public static /*const*/ string sel_cursorUpdate_1 = sel_registerName("cursorUpdate:");
+    public static /*const*/ string sel_initWithMachPort_1options_1 = sel_registerName("initWithMachPort:options:");
+    public static /*const*/ string sel_applyFontTraits_1range_1 = sel_registerName("applyFontTraits:range:");
+    public static /*const*/ string sel_noteHeightOfRowsWithIndexesChanged_1 = sel_registerName("noteHeightOfRowsWithIndexesChanged:");
+    public static /*const*/ string sel_orderFrontTablePanel_1 = sel_registerName("orderFrontTablePanel:");
+    public static /*const*/ string sel_arrayWithObjects_1 = sel_registerName("arrayWithObjects:");
+    public static /*const*/ string sel_enableFlushWindow = sel_registerName("enableFlushWindow");
+    public static /*const*/ string sel_minimum = sel_registerName("minimum");
+    public static /*const*/ string sel_stopListening = sel_registerName("stopListening");
+    public static /*const*/ string sel_endParagraph = sel_registerName("endParagraph");
+    public static /*const*/ string sel_sharingType = sel_registerName("sharingType");
+    public static /*const*/ string sel_backgroundLayoutEnabled = sel_registerName("backgroundLayoutEnabled");
+    public static /*const*/ string sel_yellowColor = sel_registerName("yellowColor");
+    public static /*const*/ string sel_columnIndexesInRect_1 = sel_registerName("columnIndexesInRect:");
+    public static /*const*/ string sel_compositingOperation = sel_registerName("compositingOperation");
+    public static /*const*/ string sel_stopModalWithCode_1 = sel_registerName("stopModalWithCode:");
+    public static /*const*/ string sel_smallSystemFontSize = sel_registerName("smallSystemFontSize");
+    public static /*const*/ string sel_nonretainedObjectValue = sel_registerName("nonretainedObjectValue");
+    public static /*const*/ string sel_encodeBytes_1length_1forKey_1 = sel_registerName("encodeBytes:length:forKey:");
+    public static /*const*/ string sel_objectValues = sel_registerName("objectValues");
+    public static /*const*/ string sel_destroyContext = sel_registerName("destroyContext");
+    public static /*const*/ string sel_setFileModificationDate_1 = sel_registerName("setFileModificationDate:");
+    public static /*const*/ string sel_rightMouseDragged_1 = sel_registerName("rightMouseDragged:");
+    public static /*const*/ string sel_systemStatusBar = sel_registerName("systemStatusBar");
+    public static /*const*/ string sel_executableArchitectures = sel_registerName("executableArchitectures");
+    public static /*const*/ string sel_recentSearches = sel_registerName("recentSearches");
+    public static /*const*/ string sel_getWhite_1alpha_1 = sel_registerName("getWhite:alpha:");
+    public static /*const*/ string sel_readDataToEndOfFile = sel_registerName("readDataToEndOfFile");
+    public static /*const*/ string sel_setHour_1 = sel_registerName("setHour:");
+    public static /*const*/ string sel_titleBarFontOfSize_1 = sel_registerName("titleBarFontOfSize:");
+    public static /*const*/ string sel_canDragRowsWithIndexes_1atPoint_1 = sel_registerName("canDragRowsWithIndexes:atPoint:");
+    public static /*const*/ string sel_acceptsArrowKeys = sel_registerName("acceptsArrowKeys");
+    public static /*const*/ string sel_availableColorLists = sel_registerName("availableColorLists");
+    public static /*const*/ string sel_setUsesLazyFetching_1 = sel_registerName("setUsesLazyFetching:");
+    public static /*const*/ string sel_convertAttributes_1 = sel_registerName("convertAttributes:");
+    public static /*const*/ string sel_isWritableFileAtPath_1 = sel_registerName("isWritableFileAtPath:");
+    public static /*const*/ string sel_timerWithTimeInterval_1target_1selector_1userInfo_1repeats_1 = sel_registerName("timerWithTimeInterval:target:selector:userInfo:repeats:");
+    public static /*const*/ string sel_windowDidChangeScreen_1 = sel_registerName("windowDidChangeScreen:");
+    public static /*const*/ string sel_insertTextContainer_1atIndex_1 = sel_registerName("insertTextContainer:atIndex:");
+    public static /*const*/ string sel_weightOfFont_1 = sel_registerName("weightOfFont:");
+    public static /*const*/ string sel_temporaryAttributesAtCharacterIndex_1longestEffectiveRange_1inRange_1 = sel_registerName("temporaryAttributesAtCharacterIndex:longestEffectiveRange:inRange:");
+    public static /*const*/ string sel_trackWithEvent_1 = sel_registerName("trackWithEvent:");
+    public static /*const*/ string sel_selectRowIndexes_1byExtendingSelection_1 = sel_registerName("selectRowIndexes:byExtendingSelection:");
+    public static /*const*/ string sel_charactersToBeSkipped = sel_registerName("charactersToBeSkipped");
+    public static /*const*/ string sel_names = sel_registerName("names");
+    public static /*const*/ string sel_setAllowsCutCopyPaste_1 = sel_registerName("setAllowsCutCopyPaste:");
+    public static /*const*/ string sel_setDuration_1 = sel_registerName("setDuration:");
+    public static /*const*/ string sel_sleepForTimeInterval_1 = sel_registerName("sleepForTimeInterval:");
+    public static /*const*/ string sel_removeChildAtIndex_1 = sel_registerName("removeChildAtIndex:");
+    public static /*const*/ string sel_tokenFieldCell_1writeRepresentedObjects_1toPasteboard_1 = sel_registerName("tokenFieldCell:writeRepresentedObjects:toPasteboard:");
+    public static /*const*/ string sel_backgroundStyle = sel_registerName("backgroundStyle");
+    public static /*const*/ string sel_open_1 = sel_registerName("open:");
+    public static /*const*/ string sel_indexGreaterThanOrEqualToIndex_1 = sel_registerName("indexGreaterThanOrEqualToIndex:");
+    public static /*const*/ string sel_isAbsolutePath = sel_registerName("isAbsolutePath");
+    public static /*const*/ string sel_paletteLabel = sel_registerName("paletteLabel");
+    public static /*const*/ string sel_setQuarterSymbols_1 = sel_registerName("setQuarterSymbols:");
+    public static /*const*/ string sel_suppressionButton = sel_registerName("suppressionButton");
+    public static /*const*/ string sel_undo = sel_registerName("undo");
+    public static /*const*/ string sel_rangeOfString_1options_1range_1locale_1 = sel_registerName("rangeOfString:options:range:locale:");
+    public static /*const*/ string sel_localizedName_1locale_1 = sel_registerName("localizedName:locale:");
+    public static /*const*/ string sel_setTableView_1 = sel_registerName("setTableView:");
+    public static /*const*/ string sel_isExecutableFileAtPath_1 = sel_registerName("isExecutableFileAtPath:");
+    public static /*const*/ string sel_standaloneQuarterSymbols = sel_registerName("standaloneQuarterSymbols");
+    public static /*const*/ string sel_textView_1shouldSetSpellingState_1range_1 = sel_registerName("textView:shouldSetSpellingState:range:");
+    public static /*const*/ string sel_newObject = sel_registerName("newObject");
+    public static /*const*/ string sel_setDocumentEdited_1 = sel_registerName("setDocumentEdited:");
+    public static /*const*/ string sel_setRelativePosition_1 = sel_registerName("setRelativePosition:");
+    public static /*const*/ string sel_allConnections = sel_registerName("allConnections");
+    public static /*const*/ string sel_isLessThanOrEqualTo_1 = sel_registerName("isLessThanOrEqualTo:");
+    public static /*const*/ string sel_attributeWithName_1StringValue_1 = sel_registerName("attributeWithName:StringValue:");
+    public static /*const*/ string sel_floatForKey_1 = sel_registerName("floatForKey:");
+    public static /*const*/ string sel_initWithDomain_1type_1name_1port_1 = sel_registerName("initWithDomain:type:name:port:");
+    public static /*const*/ string sel_setShadowOffset_1 = sel_registerName("setShadowOffset:");
+    public static /*const*/ string sel_tabViewItems = sel_registerName("tabViewItems");
+    public static /*const*/ string sel_appleEventCodeForReturnType = sel_registerName("appleEventCodeForReturnType");
+    public static /*const*/ string sel_createFileAtPath_1contents_1attributes_1 = sel_registerName("createFileAtPath:contents:attributes:");
+    public static /*const*/ string sel_ruleEditor_1predicatePartsForCriterion_1withDisplayValue_1inRow_1 = sel_registerName("ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow:");
+    public static /*const*/ string sel_evaluateWithObject_1 = sel_registerName("evaluateWithObject:");
+    public static /*const*/ string sel_pathComponents = sel_registerName("pathComponents");
+    public static /*const*/ string sel_setTarget_1 = sel_registerName("setTarget:");
+    public static /*const*/ string sel_fileCreationDate = sel_registerName("fileCreationDate");
+    public static /*const*/ string sel_port = sel_registerName("port");
+    public static /*const*/ string sel_publish = sel_registerName("publish");
+    public static /*const*/ string sel_downloadDidFinish_1 = sel_registerName("downloadDidFinish:");
+    public static /*const*/ string sel_endEditing_1 = sel_registerName("endEditing:");
+    public static /*const*/ string sel_expectedResourceDataSize = sel_registerName("expectedResourceDataSize");
+    public static /*const*/ string sel_paddingCharacter = sel_registerName("paddingCharacter");
+    public static /*const*/ string sel_convertPoint_1fromView_1 = sel_registerName("convertPoint:fromView:");
+    public static /*const*/ string sel_setIntValue_1 = sel_registerName("setIntValue:");
+    public static /*const*/ string sel_appendBezierPathWithArcFromPoint_1toPoint_1radius_1 = sel_registerName("appendBezierPathWithArcFromPoint:toPoint:radius:");
+    public static /*const*/ string sel_currentFontAction = sel_registerName("currentFontAction");
+    public static /*const*/ string sel_expressionForFunction_1arguments_1 = sel_registerName("expressionForFunction:arguments:");
+    public static /*const*/ string sel_minimumDaysInFirstWeek = sel_registerName("minimumDaysInFirstWeek");
+    public static /*const*/ string sel_setDeletesFileUponFailure_1 = sel_registerName("setDeletesFileUponFailure:");
+    public static /*const*/ string sel_pageCount = sel_registerName("pageCount");
+    public static /*const*/ string sel_imageAlignment = sel_registerName("imageAlignment");
+    public static /*const*/ string sel_URLProtocol_1didCancelAuthenticationChallenge_1 = sel_registerName("URLProtocol:didCancelAuthenticationChallenge:");
+    public static /*const*/ string sel_localizedPaperName = sel_registerName("localizedPaperName");
+    public static /*const*/ string sel_setAllowsBranchSelection_1 = sel_registerName("setAllowsBranchSelection:");
+    public static /*const*/ string sel_symbolicLinkDestination = sel_registerName("symbolicLinkDestination");
+    public static /*const*/ string sel_prepareSavePanel_1 = sel_registerName("prepareSavePanel:");
+    public static /*const*/ string sel_enableMultipleThreads = sel_registerName("enableMultipleThreads");
+    public static /*const*/ string sel_configurePersistentStoreCoordinatorForURL_1ofType_1modelConfiguration_1storeOptions_1error_1 = sel_registerName("configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:");
+    public static /*const*/ string sel_backgroundLoadDidFailWithReason_1 = sel_registerName("backgroundLoadDidFailWithReason:");
+    public static /*const*/ string sel_copyAttributesFromContext_1withMask_1 = sel_registerName("copyAttributesFromContext:withMask:");
+    public static /*const*/ string sel_isVertical = sel_registerName("isVertical");
+    public static /*const*/ string sel_wait = sel_registerName("wait");
+    public static /*const*/ string sel_firstObjectCommonWithArray_1 = sel_registerName("firstObjectCommonWithArray:");
+    public static /*const*/ string sel_hideOtherApplications_1 = sel_registerName("hideOtherApplications:");
+    public static /*const*/ string sel_startSpeakingString_1 = sel_registerName("startSpeakingString:");
+    public static /*const*/ string sel_makeKeyAndOrderFront_1 = sel_registerName("makeKeyAndOrderFront:");
+    public static /*const*/ string sel_drawCellAtIndex_1 = sel_registerName("drawCellAtIndex:");
+    public static /*const*/ string sel_headerToolTip = sel_registerName("headerToolTip");
+    public static /*const*/ string sel_readRTFDFromFile_1 = sel_registerName("readRTFDFromFile:");
+    public static /*const*/ string sel_knownTimeZoneNames = sel_registerName("knownTimeZoneNames");
+    public static /*const*/ string sel_toOneRelationshipKeys = sel_registerName("toOneRelationshipKeys");
+    public static /*const*/ string sel_replyTimeout = sel_registerName("replyTimeout");
+    public static /*const*/ string sel_setDelegate_1 = sel_registerName("setDelegate:");
+    public static /*const*/ string sel_initWithTarget_1protocol_1 = sel_registerName("initWithTarget:protocol:");
+    public static /*const*/ string sel_setShowsPrintPanel_1 = sel_registerName("setShowsPrintPanel:");
+    public static /*const*/ string sel_trackingNumber = sel_registerName("trackingNumber");
+    public static /*const*/ string sel_initWithDecimal_1 = sel_registerName("initWithDecimal:");
+    public static /*const*/ string sel_proxyWithTarget_1connection_1 = sel_registerName("proxyWithTarget:connection:");
+    public static /*const*/ string sel_setCompositingFilter_1 = sel_registerName("setCompositingFilter:");
+    public static /*const*/ string sel_systemFontSizeForControlSize_1 = sel_registerName("systemFontSizeForControlSize:");
+    public static /*const*/ string sel_registerDefaults_1 = sel_registerName("registerDefaults:");
+    public static /*const*/ string sel_veryShortStandaloneMonthSymbols = sel_registerName("veryShortStandaloneMonthSymbols");
+    public static /*const*/ string sel_setPlusSign_1 = sel_registerName("setPlusSign:");
+    public static /*const*/ string sel_colorRenderingIntent = sel_registerName("colorRenderingIntent");
+    public static /*const*/ string sel_thicknessRequiredInRuler = sel_registerName("thicknessRequiredInRuler");
+    public static /*const*/ string sel_setAlertStyle_1 = sel_registerName("setAlertStyle:");
+    public static /*const*/ string sel_searchScopes = sel_registerName("searchScopes");
+    public static /*const*/ string sel_tag = sel_registerName("tag");
+    public static /*const*/ string sel_autosavingDelay = sel_registerName("autosavingDelay");
+    public static /*const*/ string sel_setDateStyle_1 = sel_registerName("setDateStyle:");
+    public static /*const*/ string sel_setIcon_1forFile_1options_1 = sel_registerName("setIcon:forFile:options:");
+    public static /*const*/ string sel_internationalCurrencySymbol = sel_registerName("internationalCurrencySymbol");
+    public static /*const*/ string sel_netService_1didUpdateTXTRecordData_1 = sel_registerName("netService:didUpdateTXTRecordData:");
+    public static /*const*/ string sel_setOnMouseEntered_1 = sel_registerName("setOnMouseEntered:");
+    public static /*const*/ string sel_setTextBaseWritingDirection_1 = sel_registerName("setTextBaseWritingDirection:");
+    public static /*const*/ string sel_startSpecifier = sel_registerName("startSpecifier");
+    public static /*const*/ string sel_setExcludedFromWindowsMenu_1 = sel_registerName("setExcludedFromWindowsMenu:");
+    public static /*const*/ string sel_operatingSystemName = sel_registerName("operatingSystemName");
+    public static /*const*/ string sel_isConcurrent = sel_registerName("isConcurrent");
+    public static /*const*/ string sel_enableRelease_1 = sel_registerName("enableRelease:");
+    public static /*const*/ string sel_getValues_1forAttribute_1forVirtualScreen_1 = sel_registerName("getValues:forAttribute:forVirtualScreen:");
+    public static /*const*/ string sel_interrupt = sel_registerName("interrupt");
+    public static /*const*/ string sel_whiteComponent = sel_registerName("whiteComponent");
+    public static /*const*/ string sel_keyEquivalentRectForBounds_1 = sel_registerName("keyEquivalentRectForBounds:");
+    public static /*const*/ string sel_numberOfVisibleColumns = sel_registerName("numberOfVisibleColumns");
+    public static /*const*/ string sel_windowNibName = sel_registerName("windowNibName");
+    public static /*const*/ string sel_parser_1foundIgnorableWhitespace_1 = sel_registerName("parser:foundIgnorableWhitespace:");
+    public static /*const*/ string sel_menuItemCellForItemAtIndex_1 = sel_registerName("menuItemCellForItemAtIndex:");
+    public static /*const*/ string sel_addTrackingArea_1 = sel_registerName("addTrackingArea:");
+    public static /*const*/ string sel_arrangedObjects = sel_registerName("arrangedObjects");
+    public static /*const*/ string sel_timeStyle = sel_registerName("timeStyle");
+    public static /*const*/ string sel_indexPathWithIndexes_1length_1 = sel_registerName("indexPathWithIndexes:length:");
+    public static /*const*/ string sel_addNamespace_1 = sel_registerName("addNamespace:");
+    public static /*const*/ string sel_setDisplayValuesKeyPath_1 = sel_registerName("setDisplayValuesKeyPath:");
+    public static /*const*/ string sel_notificationBatchingInterval = sel_registerName("notificationBatchingInterval");
+    public static /*const*/ string sel_MIMEType = sel_registerName("MIMEType");
+    public static /*const*/ string sel_drawerWillClose_1 = sel_registerName("drawerWillClose:");
+    public static /*const*/ string sel_sortedArrayHint = sel_registerName("sortedArrayHint");
+    public static /*const*/ string sel_shortQuarterSymbols = sel_registerName("shortQuarterSymbols");
+    public static /*const*/ string sel_usesAlternatingRowBackgroundColors = sel_registerName("usesAlternatingRowBackgroundColors");
+    public static /*const*/ string sel_colorWithKey_1 = sel_registerName("colorWithKey:");
+    public static /*const*/ string sel_rangeForUserCompletion = sel_registerName("rangeForUserCompletion");
+    public static /*const*/ string sel_boolValue = sel_registerName("boolValue");
+    public static /*const*/ string sel_autosaveName = sel_registerName("autosaveName");
+    public static /*const*/ string sel_childWindows = sel_registerName("childWindows");
+    public static /*const*/ string sel_mapTableWithStrongToWeakObjects = sel_registerName("mapTableWithStrongToWeakObjects");
+    public static /*const*/ string sel_unhide = sel_registerName("unhide");
+    public static /*const*/ string sel_setRowClass_1 = sel_registerName("setRowClass:");
+    public static /*const*/ string sel_endSubelementIndex = sel_registerName("endSubelementIndex");
+    public static /*const*/ string sel_preferredLocalizations = sel_registerName("preferredLocalizations");
+    public static /*const*/ string sel_fileSystemChanged = sel_registerName("fileSystemChanged");
+    public static /*const*/ string sel_secondOfMinute = sel_registerName("secondOfMinute");
+    public static /*const*/ string sel_scrollWheel_1 = sel_registerName("scrollWheel:");
+    public static /*const*/ string sel_characterIndexForGlyphAtIndex_1 = sel_registerName("characterIndexForGlyphAtIndex:");
+    public static /*const*/ string sel_drawRepresentation_1inRect_1 = sel_registerName("drawRepresentation:inRect:");
+    public static /*const*/ string sel_setByAddingObject_1 = sel_registerName("setByAddingObject:");
+    public static /*const*/ string sel_rotateByAngle_1 = sel_registerName("rotateByAngle:");
+    public static /*const*/ string sel_allValues = sel_registerName("allValues");
+    public static /*const*/ string sel_addItemWithObjectValue_1 = sel_registerName("addItemWithObjectValue:");
+    public static /*const*/ string sel_tabViewItemAtIndex_1 = sel_registerName("tabViewItemAtIndex:");
+    public static /*const*/ string sel_servicePortWithName_1 = sel_registerName("servicePortWithName:");
+    public static /*const*/ string sel_multiplier = sel_registerName("multiplier");
+    public static /*const*/ string sel_setSelectionGranularity_1 = sel_registerName("setSelectionGranularity:");
+    public static /*const*/ string sel_setViewsNeedDisplay_1 = sel_registerName("setViewsNeedDisplay:");
+    public static /*const*/ string sel_object = sel_registerName("object");
+    public static /*const*/ string sel_writeFileWrapper_1 = sel_registerName("writeFileWrapper:");
+    public static /*const*/ string sel_authenticationMethod = sel_registerName("authenticationMethod");
+    public static /*const*/ string sel_frameLength = sel_registerName("frameLength");
+    public static /*const*/ string sel_nextNode = sel_registerName("nextNode");
+    public static /*const*/ string sel_characterSetWithCharactersInString_1 = sel_registerName("characterSetWithCharactersInString:");
+    public static /*const*/ string sel_messageText = sel_registerName("messageText");
+    public static /*const*/ string sel_setArguments_1 = sel_registerName("setArguments:");
+    public static /*const*/ string sel_getBytes_1length_1 = sel_registerName("getBytes:length:");
+    public static /*const*/ string sel_setDropItem_1dropChildIndex_1 = sel_registerName("setDropItem:dropChildIndex:");
+    public static /*const*/ string sel_expressionForVariable_1 = sel_registerName("expressionForVariable:");
+    public static /*const*/ string sel_rectPreservedDuringLiveResize = sel_registerName("rectPreservedDuringLiveResize");
+    public static /*const*/ string sel_isMuted = sel_registerName("isMuted");
+    public static /*const*/ string sel_allowsColumnResizing = sel_registerName("allowsColumnResizing");
+    public static /*const*/ string sel_readFileWrapper = sel_registerName("readFileWrapper");
+    public static /*const*/ string sel_undoNestedGroup = sel_registerName("undoNestedGroup");
+    public static /*const*/ string sel_setIncludedKeys_1 = sel_registerName("setIncludedKeys:");
+    public static /*const*/ string sel_textWithStringValue_1 = sel_registerName("textWithStringValue:");
+    public static /*const*/ string sel_ruleEditorRowsDidChange_1 = sel_registerName("ruleEditorRowsDidChange:");
+    public static /*const*/ string sel_handleMouseEvent_1 = sel_registerName("handleMouseEvent:");
+    public static /*const*/ string sel_browser_1canDragRowsWithIndexes_1inColumn_1withEvent_1 = sel_registerName("browser:canDragRowsWithIndexes:inColumn:withEvent:");
+    public static /*const*/ string sel_drawPageBorderWithSize_1 = sel_registerName("drawPageBorderWithSize:");
+    public static /*const*/ string sel_valueWithBytes_1objCType_1 = sel_registerName("valueWithBytes:objCType:");
+    public static /*const*/ string sel_subpathsAtPath_1 = sel_registerName("subpathsAtPath:");
+    public static /*const*/ string sel_mnemonicLocation = sel_registerName("mnemonicLocation");
+    public static /*const*/ string sel_dockTile = sel_registerName("dockTile");
+    public static /*const*/ string sel_setFirstLineHeadIndent_1 = sel_registerName("setFirstLineHeadIndent:");
+    public static /*const*/ string sel_isAutomaticQuoteSubstitutionEnabled = sel_registerName("isAutomaticQuoteSubstitutionEnabled");
+    public static /*const*/ string sel_allowsReverseTransformation = sel_registerName("allowsReverseTransformation");
+    public static /*const*/ string sel_moveNodes_1toIndexPath_1 = sel_registerName("moveNodes:toIndexPath:");
+    public static /*const*/ string sel_seekToFileOffset_1 = sel_registerName("seekToFileOffset:");
+    public static /*const*/ string sel_scriptingBeginsWith_1 = sel_registerName("scriptingBeginsWith:");
+    public static /*const*/ string sel_setInformativeText_1 = sel_registerName("setInformativeText:");
+    public static /*const*/ string sel_initWithIndexSet_1 = sel_registerName("initWithIndexSet:");
+    public static /*const*/ string sel_write_1maxLength_1 = sel_registerName("write:maxLength:");
+    public static /*const*/ string sel_canInitWithRequest_1 = sel_registerName("canInitWithRequest:");
+    public static /*const*/ string sel_enqueueNotification_1postingStyle_1 = sel_registerName("enqueueNotification:postingStyle:");
+    public static /*const*/ string sel_setShouldResolveExternalEntities_1 = sel_registerName("setShouldResolveExternalEntities:");
+    public static /*const*/ string sel_usesFindPanel = sel_registerName("usesFindPanel");
+    public static /*const*/ string sel_perMillSymbol = sel_registerName("perMillSymbol");
+    public static /*const*/ string sel_setClearsFilterPredicateOnInsertion_1 = sel_registerName("setClearsFilterPredicateOnInsertion:");
+    public static /*const*/ string sel_currentLocale = sel_registerName("currentLocale");
+    public static /*const*/ string sel_pasteboardByFilteringData_1ofType_1 = sel_registerName("pasteboardByFilteringData:ofType:");
+    public static /*const*/ string sel_isSheet = sel_registerName("isSheet");
+    public static /*const*/ string sel_hasWritablePropertyForKey_1 = sel_registerName("hasWritablePropertyForKey:");
+    public static /*const*/ string sel_drawDividerInRect_1 = sel_registerName("drawDividerInRect:");
+    public static /*const*/ string sel_sharedUserDefaultsController = sel_registerName("sharedUserDefaultsController");
+    public static /*const*/ string sel_preferredFontNames = sel_registerName("preferredFontNames");
+    public static /*const*/ string sel_menuBarFontOfSize_1 = sel_registerName("menuBarFontOfSize:");
+    public static /*const*/ string sel_sharedColorPanelExists = sel_registerName("sharedColorPanelExists");
+    public static /*const*/ string sel_reshape = sel_registerName("reshape");
+    public static /*const*/ string sel_initWithLong_1 = sel_registerName("initWithLong:");
+    public static /*const*/ string sel_reservedThicknessForAccessoryView = sel_registerName("reservedThicknessForAccessoryView");
+    public static /*const*/ string sel_setTitleCell_1 = sel_registerName("setTitleCell:");
+    public static /*const*/ string sel_sharedSpellCheckerExists = sel_registerName("sharedSpellCheckerExists");
+    public static /*const*/ string sel_locationForSubmenu_1 = sel_registerName("locationForSubmenu:");
+    public static /*const*/ string sel_nodesForXPath_1error_1 = sel_registerName("nodesForXPath:error:");
+    public static /*const*/ string sel_setHasVerticalRuler_1 = sel_registerName("setHasVerticalRuler:");
+    public static /*const*/ string sel_controlHighlightColor = sel_registerName("controlHighlightColor");
+    public static /*const*/ string sel_rowSpan = sel_registerName("rowSpan");
+    public static /*const*/ string sel_decodeObject = sel_registerName("decodeObject");
+    public static /*const*/ string sel_fileHandleForReadingAtPath_1 = sel_registerName("fileHandleForReadingAtPath:");
+    public static /*const*/ string sel_didLoadBytes_1loadComplete_1 = sel_registerName("didLoadBytes:loadComplete:");
+    public static /*const*/ string sel_renewRows_1columns_1 = sel_registerName("renewRows:columns:");
+    public static /*const*/ string sel_performKeyEquivalent_1 = sel_registerName("performKeyEquivalent:");
+    public static /*const*/ string sel_windowDidResignKey_1 = sel_registerName("windowDidResignKey:");
+    public static /*const*/ string sel_typeForKey_1 = sel_registerName("typeForKey:");
+    public static /*const*/ string sel_selectedObjects = sel_registerName("selectedObjects");
+    public static /*const*/ string sel_defaultPrinter = sel_registerName("defaultPrinter");
+    public static /*const*/ string sel_colorWithPatternImage_1 = sel_registerName("colorWithPatternImage:");
+    public static /*const*/ string sel_setAttributedAlternateTitle_1 = sel_registerName("setAttributedAlternateTitle:");
+    public static /*const*/ string sel_setValue_1forKey_1 = sel_registerName("setValue:forKey:");
+    public static /*const*/ string sel_drawInteriorWithFrame_1inView_1 = sel_registerName("drawInteriorWithFrame:inView:");
+    public static /*const*/ string sel_copy_1 = sel_registerName("copy:");
+    public static /*const*/ string sel_scanString_1intoString_1 = sel_registerName("scanString:intoString:");
+    public static /*const*/ string sel_fileManager_1shouldProceedAfterError_1 = sel_registerName("fileManager:shouldProceedAfterError:");
+    public static /*const*/ string sel_fileManager_1shouldRemoveItemAtPath_1 = sel_registerName("fileManager:shouldRemoveItemAtPath:");
+    public static /*const*/ string sel_removeSavedColumnsWithAutosaveName_1 = sel_registerName("removeSavedColumnsWithAutosaveName:");
+    public static /*const*/ string sel_numberWithUnsignedInteger_1 = sel_registerName("numberWithUnsignedInteger:");
+    public static /*const*/ string sel_rulerMarkersForTextView_1paragraphStyle_1ruler_1 = sel_registerName("rulerMarkersForTextView:paragraphStyle:ruler:");
+    public static /*const*/ string sel_layoutRectForTextBlock_1atIndex_1effectiveRange_1 = sel_registerName("layoutRectForTextBlock:atIndex:effectiveRange:");
+    public static /*const*/ string sel_maxPossiblePositionOfDividerAtIndex_1 = sel_registerName("maxPossiblePositionOfDividerAtIndex:");
+    public static /*const*/ string sel_removePort_1forMode_1 = sel_registerName("removePort:forMode:");
+    public static /*const*/ string sel_drawHashMarksAndLabelsInRect_1 = sel_registerName("drawHashMarksAndLabelsInRect:");
+    public static /*const*/ string sel_control_1textView_1doCommandBySelector_1 = sel_registerName("control:textView:doCommandBySelector:");
+    public static /*const*/ string sel_getLineFragmentRect_1usedRect_1remainingRect_1forStartingGlyphAtIndex_1proposedRect_1lineSpacing_1paragraphSpacingBefore_1paragraphSpacingAfter_1 = sel_registerName("getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:");
+    public static /*const*/ string sel_textContainerInset = sel_registerName("textContainerInset");
+    public static /*const*/ string sel_positionsForCompositeSequence_1numberOfGlyphs_1pointArray_1 = sel_registerName("positionsForCompositeSequence:numberOfGlyphs:pointArray:");
+    public static /*const*/ string sel_StringByAppendingPathComponent_1 = sel_registerName("StringByAppendingPathComponent:");
+    public static /*const*/ string sel_application_1printFiles_1 = sel_registerName("application:printFiles:");
+    public static /*const*/ string sel_scanInt_1 = sel_registerName("scanInt:");
+    public static /*const*/ string sel_operators = sel_registerName("operators");
+    public static /*const*/ string sel_fireDate = sel_registerName("fireDate");
+    public static /*const*/ string sel_isExternal = sel_registerName("isExternal");
+    public static /*const*/ string sel_setImagePosition_1 = sel_registerName("setImagePosition:");
+    public static /*const*/ string sel_predicateWithFormat_1arguments_1 = sel_registerName("predicateWithFormat:arguments:");
+    public static /*const*/ string sel_stopSpeaking = sel_registerName("stopSpeaking");
+    public static /*const*/ string sel_contentWidthValueType = sel_registerName("contentWidthValueType");
+    public static /*const*/ string sel_paddingPosition = sel_registerName("paddingPosition");
+    public static /*const*/ string sel_removeLastObject = sel_registerName("removeLastObject");
+    public static /*const*/ string sel_StringByReplacingCharactersInRange_1withString_1 = sel_registerName("StringByReplacingCharactersInRange:withString:");
+    public static /*const*/ string sel_pointerValue = sel_registerName("pointerValue");
+    public static /*const*/ string sel_setTruncatesLastVisibleLine_1 = sel_registerName("setTruncatesLastVisibleLine:");
+    public static /*const*/ string sel_URLHandleResourceDidBeginLoading_1 = sel_registerName("URLHandleResourceDidBeginLoading:");
+    public static /*const*/ string sel_valueForKeyPath_1 = sel_registerName("valueForKeyPath:");
+    public static /*const*/ string sel_setPeriodicDelay_1interval_1 = sel_registerName("setPeriodicDelay:interval:");
+    public static /*const*/ string sel_imageRepWithCIImage_1 = sel_registerName("imageRepWithCIImage:");
+    public static /*const*/ string sel_wantsNotificationForMarkedText = sel_registerName("wantsNotificationForMarkedText");
+    public static /*const*/ string sel_rectForPart_1 = sel_registerName("rectForPart:");
+    public static /*const*/ string sel_setWeekday_1 = sel_registerName("setWeekday:");
+    public static /*const*/ string sel_streamStatus = sel_registerName("streamStatus");
+    public static /*const*/ string sel_containsPoint_1 = sel_registerName("containsPoint:");
+    public static /*const*/ string sel_underlineThickness = sel_registerName("underlineThickness");
+    public static /*const*/ string sel_allObjects = sel_registerName("allObjects");
+    public static /*const*/ string sel_characters = sel_registerName("characters");
+    public static /*const*/ string sel_outlineViewSelectionIsChanging_1 = sel_registerName("outlineViewSelectionIsChanging:");
+    public static /*const*/ string sel_netServiceBrowser_1didNotSearch_1 = sel_registerName("netServiceBrowser:didNotSearch:");
+    public static /*const*/ string sel_poolCountHighWaterMark = sel_registerName("poolCountHighWaterMark");
+    public static /*const*/ string sel_setColorSpaceName_1 = sel_registerName("setColorSpaceName:");
+    public static /*const*/ string sel_graphicsPort = sel_registerName("graphicsPort");
+    public static /*const*/ string sel_fontDescriptorWithName_1matrix_1 = sel_registerName("fontDescriptorWithName:matrix:");
+    public static /*const*/ string sel_setSelectable_1 = sel_registerName("setSelectable:");
+    public static /*const*/ string sel_scriptErrorOffendingObjectDescriptor = sel_registerName("scriptErrorOffendingObjectDescriptor");
+    public static /*const*/ string sel_resizingMask = sel_registerName("resizingMask");
+    public static /*const*/ string sel_canHandleRequest_1 = sel_registerName("canHandleRequest:");
+    public static /*const*/ string sel_imageRepWithPasteboard_1 = sel_registerName("imageRepWithPasteboard:");
+    public static /*const*/ string sel_stopQuery = sel_registerName("stopQuery");
+    public static /*const*/ string sel_dataWithBytes_1length_1 = sel_registerName("dataWithBytes:length:");
+    public static /*const*/ string sel_setCachesBezierPath_1 = sel_registerName("setCachesBezierPath:");
+    public static /*const*/ string sel_arrayForKey_1 = sel_registerName("arrayForKey:");
+    public static /*const*/ string sel_cell = sel_registerName("cell");
+    public static /*const*/ string sel_dealloc = sel_registerName("dealloc");
+    public static /*const*/ string sel_constrainScrollPoint_1 = sel_registerName("constrainScrollPoint:");
+    public static /*const*/ string sel_printSettings = sel_registerName("printSettings");
+    public static /*const*/ string sel_autoresizesOutlineColumn = sel_registerName("autoresizesOutlineColumn");
+    public static /*const*/ string sel_setFont_1range_1 = sel_registerName("setFont:range:");
+    public static /*const*/ string sel_limitDateForMode_1 = sel_registerName("limitDateForMode:");
+    public static /*const*/ string sel_stroke = sel_registerName("stroke");
+    public static /*const*/ string sel_parser_1parseErrorOccurred_1 = sel_registerName("parser:parseErrorOccurred:");
+    public static /*const*/ string sel_sendsActionOnEndEditing = sel_registerName("sendsActionOnEndEditing");
+    public static /*const*/ string sel_toggleGrammarChecking_1 = sel_registerName("toggleGrammarChecking:");
+    public static /*const*/ string sel_acceptsBinary = sel_registerName("acceptsBinary");
+    public static /*const*/ string sel_indexLessThanIndex_1 = sel_registerName("indexLessThanIndex:");
+    public static /*const*/ string sel_setCollapsesBorders_1 = sel_registerName("setCollapsesBorders:");
+    public static /*const*/ string sel_setTimeoutInterval_1 = sel_registerName("setTimeoutInterval:");
+    public static /*const*/ string sel_setNeedsDisplayInRect_1avoidAdditionalLayout_1 = sel_registerName("setNeedsDisplayInRect:avoidAdditionalLayout:");
+    public static /*const*/ string sel_encodeWithCoder_1 = sel_registerName("encodeWithCoder:");
+    public static /*const*/ string sel_compositeToPoint_1operation_1 = sel_registerName("compositeToPoint:operation:");
+    public static /*const*/ string sel_textView_1doubleClickedOnCell_1inRect_1atIndex_1 = sel_registerName("textView:doubleClickedOnCell:inRect:atIndex:");
+    public static /*const*/ string sel_setAlternateTitleWithMnemonic_1 = sel_registerName("setAlternateTitleWithMnemonic:");
+    public static /*const*/ string sel_minimumSignificantDigits = sel_registerName("minimumSignificantDigits");
+    public static /*const*/ string sel_stackSize = sel_registerName("stackSize");
+    public static /*const*/ string sel_setLayoutManager_1 = sel_registerName("setLayoutManager:");
+    public static /*const*/ string sel_image_1didLoadRepresentationHeader_1 = sel_registerName("image:didLoadRepresentationHeader:");
+    public static /*const*/ string sel_depth = sel_registerName("depth");
+    public static /*const*/ string sel_setTypesetter_1 = sel_registerName("setTypesetter:");
+    public static /*const*/ string sel_isSessionOnly = sel_registerName("isSessionOnly");
+    public static /*const*/ string sel_performFindPanelAction_1 = sel_registerName("performFindPanelAction:");
+    public static /*const*/ string sel_fileManager_1shouldProceedAfterError_1removingItemAtPath_1 = sel_registerName("fileManager:shouldProceedAfterError:removingItemAtPath:");
+    public static /*const*/ string sel_paperSize = sel_registerName("paperSize");
+    public static /*const*/ string sel_changeColor_1 = sel_registerName("changeColor:");
+    public static /*const*/ string sel_unarchiverDidFinish_1 = sel_registerName("unarchiverDidFinish:");
+    public static /*const*/ string sel_initWithObjectsAndKeys_1 = sel_registerName("initWithObjectsAndKeys:");
+    public static /*const*/ string sel_notationDeclarationForName_1 = sel_registerName("notationDeclarationForName:");
+    public static /*const*/ string sel_maximumSignificantDigits = sel_registerName("maximumSignificantDigits");
+    public static /*const*/ string sel_receivesCredentialSecurely = sel_registerName("receivesCredentialSecurely");
+    public static /*const*/ string sel_setObjectBeingTested_1 = sel_registerName("setObjectBeingTested:");
+    public static /*const*/ string sel_cacheDepthMatchesImageDepth = sel_registerName("cacheDepthMatchesImageDepth");
+    public static /*const*/ string sel_hasPropertyForKey_1 = sel_registerName("hasPropertyForKey:");
+    public static /*const*/ string sel_draggingDestinationWindow = sel_registerName("draggingDestinationWindow");
+    public static /*const*/ string sel_typeCodeValue = sel_registerName("typeCodeValue");
+    public static /*const*/ string sel_portForName_1 = sel_registerName("portForName:");
+    public static /*const*/ string sel_getCString_1maxLength_1encoding_1 = sel_registerName("getCString:maxLength:encoding:");
+    public static /*const*/ string sel_attributedString = sel_registerName("attributedString");
+    public static /*const*/ string sel_fileExistsAtPath_1isDirectory_1 = sel_registerName("fileExistsAtPath:isDirectory:");
+    public static /*const*/ string sel_updateRuler = sel_registerName("updateRuler");
+    public static /*const*/ string sel_print_1 = sel_registerName("print:");
+    public static /*const*/ string sel_setFrameSize_1 = sel_registerName("setFrameSize:");
+    public static /*const*/ string sel_dataFromPropertyList_1format_1errorDescription_1 = sel_registerName("dataFromPropertyList:format:errorDescription:");
+    public static /*const*/ string sel_initWithContentsOfURL_1ofType_1 = sel_registerName("initWithContentsOfURL:ofType:");
+    public static /*const*/ string sel_replaceValueAtIndex_1inPropertyWithKey_1withValue_1 = sel_registerName("replaceValueAtIndex:inPropertyWithKey:withValue:");
+    public static /*const*/ string sel_formIntersectionWithCharacterSet_1 = sel_registerName("formIntersectionWithCharacterSet:");
+    public static /*const*/ string sel_renderingMode = sel_registerName("renderingMode");
+    public static /*const*/ string sel_viewsNeedDisplay = sel_registerName("viewsNeedDisplay");
+    public static /*const*/ string sel_lineFragmentRectForProposedRect_1sweepDirection_1movementDirection_1remainingRect_1 = sel_registerName("lineFragmentRectForProposedRect:sweepDirection:movementDirection:remainingRect:");
+    public static /*const*/ string sel_rulerAccessoryViewForTextView_1paragraphStyle_1ruler_1enabled_1 = sel_registerName("rulerAccessoryViewForTextView:paragraphStyle:ruler:enabled:");
+    public static /*const*/ string sel_initWithArray_1copyItems_1 = sel_registerName("initWithArray:copyItems:");
+    public static /*const*/ string sel_ensureLayoutForGlyphRange_1 = sel_registerName("ensureLayoutForGlyphRange:");
+    public static /*const*/ string sel_availableLocaleIdentifiers = sel_registerName("availableLocaleIdentifiers");
+    public static /*const*/ string sel_viewDidHide = sel_registerName("viewDidHide");
+    public static /*const*/ string sel_setShouldReportNamespacePrefixes_1 = sel_registerName("setShouldReportNamespacePrefixes:");
+    public static /*const*/ string sel_runToolbarCustomizationPalette_1 = sel_registerName("runToolbarCustomizationPalette:");
+    public static /*const*/ string sel_roundingBehavior = sel_registerName("roundingBehavior");
+    public static /*const*/ string sel_expressionForEvaluatedObject = sel_registerName("expressionForEvaluatedObject");
+    public static /*const*/ string sel_rulerView_1handleMouseDown_1 = sel_registerName("rulerView:handleMouseDown:");
+    public static /*const*/ string sel_scanCharactersFromSet_1intoString_1 = sel_registerName("scanCharactersFromSet:intoString:");
+    public static /*const*/ string sel_applicationDidChangeScreenParameters_1 = sel_registerName("applicationDidChangeScreenParameters:");
+    public static /*const*/ string sel_textView_1clickedOnCell_1inRect_1 = sel_registerName("textView:clickedOnCell:inRect:");
+    public static /*const*/ string sel_decodeDoubleForKey_1 = sel_registerName("decodeDoubleForKey:");
+    public static /*const*/ string sel_URLHandle_1resourceDidFailLoadingWithReason_1 = sel_registerName("URLHandle:resourceDidFailLoadingWithReason:");
+    public static /*const*/ string sel_setCountKeyPath_1 = sel_registerName("setCountKeyPath:");
+    public static /*const*/ string sel_showContextHelpForObject_1locationHint_1 = sel_registerName("showContextHelpForObject:locationHint:");
+    public static /*const*/ string sel_setData_1forType_1 = sel_registerName("setData:forType:");
+    public static /*const*/ string sel_setPixel_1atX_1y_1 = sel_registerName("setPixel:atX:y:");
+    public static /*const*/ string sel_setReceiversSpecifier_1 = sel_registerName("setReceiversSpecifier:");
+    public static /*const*/ string sel_postNotificationName_1object_1userInfo_1 = sel_registerName("postNotificationName:object:userInfo:");
+    public static /*const*/ string sel_rowForItem_1 = sel_registerName("rowForItem:");
+    public static /*const*/ string sel_fetch_1 = sel_registerName("fetch:");
+    public static /*const*/ string sel_propertyList_1isValidForFormat_1 = sel_registerName("propertyList:isValidForFormat:");
+    public static /*const*/ string sel_configureAsServer = sel_registerName("configureAsServer");
+    public static /*const*/ string sel_setAllowsColumnReordering_1 = sel_registerName("setAllowsColumnReordering:");
+    public static /*const*/ string sel_charValue = sel_registerName("charValue");
+    public static /*const*/ string sel_setInsertionClassDescription_1 = sel_registerName("setInsertionClassDescription:");
+    public static /*const*/ string sel_cyanColor = sel_registerName("cyanColor");
+    public static /*const*/ string sel_lockWhenCondition_1 = sel_registerName("lockWhenCondition:");
+    public static /*const*/ string sel_cacheImageInRect_1 = sel_registerName("cacheImageInRect:");
+    public static /*const*/ string sel_keyboardFocusIndicatorColor = sel_registerName("keyboardFocusIndicatorColor");
+    public static /*const*/ string sel_hasUndoManager = sel_registerName("hasUndoManager");
+    public static /*const*/ string sel_drawInBezierPath_1relativeCenterPosition_1 = sel_registerName("drawInBezierPath:relativeCenterPosition:");
+    public static /*const*/ string sel_decimalNumberByAdding_1 = sel_registerName("decimalNumberByAdding:");
+    public static /*const*/ string sel_initWithDescriptorType_1data_1 = sel_registerName("initWithDescriptorType:data:");
+    public static /*const*/ string sel_isUndoing = sel_registerName("isUndoing");
+    public static /*const*/ string sel_boolForKey_1 = sel_registerName("boolForKey:");
+    public static /*const*/ string sel_localizedCatalogNameComponent = sel_registerName("localizedCatalogNameComponent");
+    public static /*const*/ string sel_representations = sel_registerName("representations");
+    public static /*const*/ string sel_expressionValueWithObject_1context_1 = sel_registerName("expressionValueWithObject:context:");
+    public static /*const*/ string sel_viewWillMoveToSuperview_1 = sel_registerName("viewWillMoveToSuperview:");
+    public static /*const*/ string sel_alphaValue = sel_registerName("alphaValue");
+    public static /*const*/ string sel_learnWord_1 = sel_registerName("learnWord:");
+    public static /*const*/ string sel_releaseGlobally = sel_registerName("releaseGlobally");
+    public static /*const*/ string sel_defaultCompletionDelay = sel_registerName("defaultCompletionDelay");
+    public static /*const*/ string sel_control_1textShouldEndEditing_1 = sel_registerName("control:textShouldEndEditing:");
+    public static /*const*/ string sel_alertWithMessageText_1defaultButton_1alternateButton_1otherButton_1informativeTextWithFormat_1 = sel_registerName("alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:");
+    public static /*const*/ string sel_control_1textShouldBeginEditing_1 = sel_registerName("control:textShouldBeginEditing:");
+    public static /*const*/ string sel_sizeMode = sel_registerName("sizeMode");
+    public static /*const*/ string sel_representedURL = sel_registerName("representedURL");
+    public static /*const*/ string sel_fileHFSCreatorCode = sel_registerName("fileHFSCreatorCode");
+    public static /*const*/ string sel_removeDependency_1 = sel_registerName("removeDependency:");
+    public static /*const*/ string sel_parentForItem_1 = sel_registerName("parentForItem:");
+    public static /*const*/ string sel_adjustPageHeightNew_1top_1bottom_1limit_1 = sel_registerName("adjustPageHeightNew:top:bottom:limit:");
+    public static /*const*/ string sel_showPanels = sel_registerName("showPanels");
+    public static /*const*/ string sel_alwaysUsesMultipleValuesMarker = sel_registerName("alwaysUsesMultipleValuesMarker");
+    public static /*const*/ string sel_setUpFieldEditorAttributes_1 = sel_registerName("setUpFieldEditorAttributes:");
+    public static /*const*/ string sel_comboBoxCell_1completedString_1 = sel_registerName("comboBoxCell:completedString:");
+    public static /*const*/ string sel_null = sel_registerName("null");
+    public static /*const*/ string sel_setTextAttributesForNil_1 = sel_registerName("setTextAttributesForNil:");
+    public static /*const*/ string sel_currencyGroupingSeparator = sel_registerName("currencyGroupingSeparator");
+    public static /*const*/ string sel_toolbarSelectableItemIdentifiers_1 = sel_registerName("toolbarSelectableItemIdentifiers:");
+    public static /*const*/ string sel_size = sel_registerName("size");
+    public static /*const*/ string sel_fileModificationDate = sel_registerName("fileModificationDate");
+    public static /*const*/ string sel_timestamp = sel_registerName("timestamp");
+    public static /*const*/ string sel_canonicalRequestForRequest_1 = sel_registerName("canonicalRequestForRequest:");
+    public static /*const*/ string sel_moveBackwardAndModifySelection_1 = sel_registerName("moveBackwardAndModifySelection:");
+    public static /*const*/ string sel_frameOfColumn_1 = sel_registerName("frameOfColumn:");
+    public static /*const*/ string sel_setRefusesFirstResponder_1 = sel_registerName("setRefusesFirstResponder:");
+    public static /*const*/ string sel_hasDynamicDepthLimit = sel_registerName("hasDynamicDepthLimit");
+    public static /*const*/ string sel_decodeIntForKey_1 = sel_registerName("decodeIntForKey:");
+    public static /*const*/ string sel_autoupdatingCurrentLocale = sel_registerName("autoupdatingCurrentLocale");
+    public static /*const*/ string sel_transformBezierPath_1 = sel_registerName("transformBezierPath:");
+    public static /*const*/ string sel_registerPort_1name_1nameServerPortNumber_1 = sel_registerName("registerPort:name:nameServerPortNumber:");
+    public static /*const*/ string sel_contentWidth = sel_registerName("contentWidth");
+    public static /*const*/ string sel_noteUserDefaultsChanged = sel_registerName("noteUserDefaultsChanged");
+    public static /*const*/ string sel_orangeColor = sel_registerName("orangeColor");
+    public static /*const*/ string sel_lastItem = sel_registerName("lastItem");
+    public static /*const*/ string sel_setButtonType_1 = sel_registerName("setButtonType:");
+    public static /*const*/ string sel_initWithContentsOfURL_1ofType_1error_1 = sel_registerName("initWithContentsOfURL:ofType:error:");
+    public static /*const*/ string sel_rowTemplates = sel_registerName("rowTemplates");
+    public static /*const*/ string sel_setEnabled_1forSegment_1 = sel_registerName("setEnabled:forSegment:");
+    public static /*const*/ string sel_avoidsEmptySelection = sel_registerName("avoidsEmptySelection");
+    public static /*const*/ string sel_encodeInt_1forKey_1 = sel_registerName("encodeInt:forKey:");
+    public static /*const*/ string sel_dictionaryWithValuesForKeys_1 = sel_registerName("dictionaryWithValuesForKeys:");
+    public static /*const*/ string sel_start_1 = sel_registerName("start:");
+    public static /*const*/ string sel_sortUsingDescriptors_1 = sel_registerName("sortUsingDescriptors:");
+    public static /*const*/ string sel_currentParagraphStyle = sel_registerName("currentParagraphStyle");
+    public static /*const*/ string sel_treeNodeWithRepresentedObject_1 = sel_registerName("treeNodeWithRepresentedObject:");
+    public static /*const*/ string sel_tableColumnWithIdentifier_1 = sel_registerName("tableColumnWithIdentifier:");
+    public static /*const*/ string sel_attributedTitle = sel_registerName("attributedTitle");
+    public static /*const*/ string sel_setEntryType_1 = sel_registerName("setEntryType:");
+    public static /*const*/ string sel_pixelFormat = sel_registerName("pixelFormat");
+    public static /*const*/ string sel_temporaryAttribute_1atCharacterIndex_1longestEffectiveRange_1inRange_1 = sel_registerName("temporaryAttribute:atCharacterIndex:longestEffectiveRange:inRange:");
+    public static /*const*/ string sel_treatsFilePackagesAsDirectories = sel_registerName("treatsFilePackagesAsDirectories");
+    public static /*const*/ string sel_glyphAtIndex_1 = sel_registerName("glyphAtIndex:");
+    public static /*const*/ string sel_titleWidth_1 = sel_registerName("titleWidth:");
+    public static /*const*/ string sel_setWords_1 = sel_registerName("setWords:");
+    public static /*const*/ string sel_glyphIndexForPoint_1inTextContainer_1 = sel_registerName("glyphIndexForPoint:inTextContainer:");
+    public static /*const*/ string sel_alternateSelectedControlColor = sel_registerName("alternateSelectedControlColor");
+    public static /*const*/ string sel_sizeToCells = sel_registerName("sizeToCells");
+    public static /*const*/ string sel_flushWindow = sel_registerName("flushWindow");
+    public static /*const*/ string sel_URLAtIndex_1effectiveRange_1 = sel_registerName("URLAtIndex:effectiveRange:");
+    public static /*const*/ string sel_isSimpleRectangularTextContainer = sel_registerName("isSimpleRectangularTextContainer");
+    public static /*const*/ string sel_dragImageForRowsWithIndexes_1tableColumns_1event_1offset_1 = sel_registerName("dragImageForRowsWithIndexes:tableColumns:event:offset:");
+    public static /*const*/ string sel_takeDoubleValueFrom_1 = sel_registerName("takeDoubleValueFrom:");
+    public static /*const*/ string sel_selectItem_1 = sel_registerName("selectItem:");
+    public static /*const*/ string sel_isMultiple = sel_registerName("isMultiple");
+    public static /*const*/ string sel_arrangeInFront_1 = sel_registerName("arrangeInFront:");
+    public static /*const*/ string sel_defaultFocusRingType = sel_registerName("defaultFocusRingType");
+    public static /*const*/ string sel_componentsSeparatedByString_1 = sel_registerName("componentsSeparatedByString:");
+    public static /*const*/ string sel_calendar = sel_registerName("calendar");
+    public static /*const*/ string sel_openFile_1withApplication_1 = sel_registerName("openFile:withApplication:");
+    public static /*const*/ string sel_moveWordBackward_1 = sel_registerName("moveWordBackward:");
+    public static /*const*/ string sel_getCharacters_1 = sel_registerName("getCharacters:");
+    public static /*const*/ string sel_initWithInt_1 = sel_registerName("initWithInt:");
+    public static /*const*/ string sel_initWithReceivePort_1sendPort_1components_1 = sel_registerName("initWithReceivePort:sendPort:components:");
+    public static /*const*/ string sel_setBool_1forKey_1 = sel_registerName("setBool:forKey:");
+    public static /*const*/ string sel_keyPathsForValuesAffectingValueForKey_1 = sel_registerName("keyPathsForValuesAffectingValueForKey:");
+    public static /*const*/ string sel_saveDocumentTo_1 = sel_registerName("saveDocumentTo:");
+    public static /*const*/ string sel_knobRectFlipped_1 = sel_registerName("knobRectFlipped:");
+    public static /*const*/ string sel_isEqualToAttributedString_1 = sel_registerName("isEqualToAttributedString:");
+    public static /*const*/ string sel_indexOfResult_1 = sel_registerName("indexOfResult:");
+    public static /*const*/ string sel_attributesForVoice_1 = sel_registerName("attributesForVoice:");
+    public static /*const*/ string sel_encodeConditionalObject_1 = sel_registerName("encodeConditionalObject:");
+    public static /*const*/ string sel_pixelBufferCubeMapFace = sel_registerName("pixelBufferCubeMapFace");
+    public static /*const*/ string sel_index = sel_registerName("index");
+    public static /*const*/ string sel_transactionID = sel_registerName("transactionID");
+    public static /*const*/ string sel_displayRectIgnoringOpacity_1 = sel_registerName("displayRectIgnoringOpacity:");
+    public static /*const*/ string sel_setKeyboardFocusRingNeedsDisplayInRect_1 = sel_registerName("setKeyboardFocusRingNeedsDisplayInRect:");
+    public static /*const*/ string sel_invalidateLayoutForCharacterRange_1isSoft_1actualCharacterRange_1 = sel_registerName("invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:");
+    public static /*const*/ string sel_contentsEqualAtPath_1andPath_1 = sel_registerName("contentsEqualAtPath:andPath:");
+    public static /*const*/ string sel_cancelOperation_1 = sel_registerName("cancelOperation:");
+    public static /*const*/ string sel_accessibilityAttributeValue_1 = sel_registerName("accessibilityAttributeValue:");
+    public static /*const*/ string sel_windowNibPath = sel_registerName("windowNibPath");
+    public static /*const*/ string sel_saveToFile_1saveOperation_1delegate_1didSaveSelector_1contextInfo_1 = sel_registerName("saveToFile:saveOperation:delegate:didSaveSelector:contextInfo:");
+    public static /*const*/ string sel_setMixedStateImage_1 = sel_registerName("setMixedStateImage:");
+    public static /*const*/ string sel_predicateWithFormat_1 = sel_registerName("predicateWithFormat:");
+    public static /*const*/ string sel_initWithSendPort_1receivePort_1components_1 = sel_registerName("initWithSendPort:receivePort:components:");
+    public static /*const*/ string sel_setRecentsAutosaveName_1 = sel_registerName("setRecentsAutosaveName:");
+    public static /*const*/ string sel_autosavesConfiguration = sel_registerName("autosavesConfiguration");
+    public static /*const*/ string sel_setSubitems_1 = sel_registerName("setSubitems:");
+    public static /*const*/ string sel_setPathStyle_1 = sel_registerName("setPathStyle:");
+    public static /*const*/ string sel_startAnimation_1 = sel_registerName("startAnimation:");
+    public static /*const*/ string sel_bezierPath = sel_registerName("bezierPath");
+    public static /*const*/ string sel_archiver_1willEncodeObject_1 = sel_registerName("archiver:willEncodeObject:");
+    public static /*const*/ string sel_acceptInputForMode_1beforeDate_1 = sel_registerName("acceptInputForMode:beforeDate:");
+    public static /*const*/ string sel_setTearOffMenuRepresentation_1 = sel_registerName("setTearOffMenuRepresentation:");
+    public static /*const*/ string sel_writableTypes = sel_registerName("writableTypes");
+    public static /*const*/ string sel_domain = sel_registerName("domain");
+    public static /*const*/ string sel_removeDocument_1 = sel_registerName("removeDocument:");
+    public static /*const*/ string sel_showsBaselineSeparator = sel_registerName("showsBaselineSeparator");
+    public static /*const*/ string sel_dragImageForRows_1event_1dragImageOffset_1 = sel_registerName("dragImageForRows:event:dragImageOffset:");
+    public static /*const*/ string sel_table = sel_registerName("table");
+    public static /*const*/ string sel_initRegularFileWithContents_1 = sel_registerName("initRegularFileWithContents:");
+    public static /*const*/ string sel_add_1 = sel_registerName("add:");
+    public static /*const*/ string sel_stateImageWidth = sel_registerName("stateImageWidth");
+    public static /*const*/ string sel_URLProtocol_1didReceiveAuthenticationChallenge_1 = sel_registerName("URLProtocol:didReceiveAuthenticationChallenge:");
+    public static /*const*/ string sel_imageAndTitleWidth = sel_registerName("imageAndTitleWidth");
+    public static /*const*/ string sel_trackingAreas = sel_registerName("trackingAreas");
+    public static /*const*/ string sel_initRecordDescriptor = sel_registerName("initRecordDescriptor");
+    public static /*const*/ string sel_itemIdentifier = sel_registerName("itemIdentifier");
+    public static /*const*/ string sel_doubleClickAtIndex_1 = sel_registerName("doubleClickAtIndex:");
+    public static /*const*/ string sel_fixesAttributesLazily = sel_registerName("fixesAttributesLazily");
+    public static /*const*/ string sel_netServiceBrowserWillSearch_1 = sel_registerName("netServiceBrowserWillSearch:");
+    public static /*const*/ string sel_textureInternalFormat = sel_registerName("textureInternalFormat");
+    public static /*const*/ string sel_valueWithSize_1 = sel_registerName("valueWithSize:");
+    public static /*const*/ string sel_setVerticalScroller_1 = sel_registerName("setVerticalScroller:");
+    public static /*const*/ string sel_absolutePathForAppBundleWithIdentifier_1 = sel_registerName("absolutePathForAppBundleWithIdentifier:");
+    public static /*const*/ string sel_contentMinSize = sel_registerName("contentMinSize");
+    public static /*const*/ string sel_persistentDomainForName_1 = sel_registerName("persistentDomainForName:");
+    public static /*const*/ string sel_cellAtIndex_1 = sel_registerName("cellAtIndex:");
+    public static /*const*/ string sel_setWithArray_1 = sel_registerName("setWithArray:");
+    public static /*const*/ string sel_resetCursorRects = sel_registerName("resetCursorRects");
+    public static /*const*/ string sel_imageRepClassForFileType_1 = sel_registerName("imageRepClassForFileType:");
+    public static /*const*/ string sel_setContainerIsObjectBeingTested_1 = sel_registerName("setContainerIsObjectBeingTested:");
+    public static /*const*/ string sel_removeProgressMark_1 = sel_registerName("removeProgressMark:");
+    public static /*const*/ string sel_hitTestForEvent_1inRect_1ofView_1 = sel_registerName("hitTestForEvent:inRect:ofView:");
+    public static /*const*/ string sel_listDescriptor = sel_registerName("listDescriptor");
+    public static /*const*/ string sel_rangeOfUnit_1startDate_1interval_1forDate_1 = sel_registerName("rangeOfUnit:startDate:interval:forDate:");
+    public static /*const*/ string sel_checkSpaceForParts = sel_registerName("checkSpaceForParts");
+    public static /*const*/ string sel_availableVoices = sel_registerName("availableVoices");
+    public static /*const*/ string sel_PMPrintSettings = sel_registerName("PMPrintSettings");
+    public static /*const*/ string sel_nonBaseCharacterSet = sel_registerName("nonBaseCharacterSet");
+    public static /*const*/ string sel_launchedTaskWithLaunchPath_1arguments_1 = sel_registerName("launchedTaskWithLaunchPath:arguments:");
+    public static /*const*/ string sel_clearCurrentContext = sel_registerName("clearCurrentContext");
+    public static /*const*/ string sel_applicationWillUpdate_1 = sel_registerName("applicationWillUpdate:");
+    public static /*const*/ string sel_addFontTrait_1 = sel_registerName("addFontTrait:");
+    public static /*const*/ string sel_arrayByAddingObjectsFromArray_1 = sel_registerName("arrayByAddingObjectsFromArray:");
+    public static /*const*/ string sel_abortParsing = sel_registerName("abortParsing");
+    public static /*const*/ string sel_subviews = sel_registerName("subviews");
+    public static /*const*/ string sel_initWithContainerClassDescription_1containerSpecifier_1key_1uniqueID_1 = sel_registerName("initWithContainerClassDescription:containerSpecifier:key:uniqueID:");
+    public static /*const*/ string sel_acceptableDragTypes = sel_registerName("acceptableDragTypes");
+    public static /*const*/ string sel_managedObjectContext = sel_registerName("managedObjectContext");
+    public static /*const*/ string sel_resizeWithMagnification_1 = sel_registerName("resizeWithMagnification:");
+    public static /*const*/ string sel_setUsesFindPanel_1 = sel_registerName("setUsesFindPanel:");
+    public static /*const*/ string sel_application_1printFiles_1withSettings_1showPrintPanels_1 = sel_registerName("application:printFiles:withSettings:showPrintPanels:");
+    public static /*const*/ string sel_loadAndReturnError_1 = sel_registerName("loadAndReturnError:");
+    public static /*const*/ string sel_initWithLeftExpressions_1rightExpressions_1modifier_1operators_1options_1 = sel_registerName("initWithLeftExpressions:rightExpressions:modifier:operators:options:");
+    public static /*const*/ string sel_addSelectionIndexes_1 = sel_registerName("addSelectionIndexes:");
+    public static /*const*/ string sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bitmapFormat_1bytesPerRow_1bitsPerPixel_1 = sel_registerName("initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:");
+    public static /*const*/ string sel_initToFileAtPath_1append_1 = sel_registerName("initToFileAtPath:append:");
+    public static /*const*/ string sel_currencyDecimalSeparator = sel_registerName("currencyDecimalSeparator");
+    public static /*const*/ string sel_expansionFrameWithFrame_1inView_1 = sel_registerName("expansionFrameWithFrame:inView:");
+    public static /*const*/ string sel_HTTPShouldHandleCookies = sel_registerName("HTTPShouldHandleCookies");
+    public static /*const*/ string sel_rearrangeObjects = sel_registerName("rearrangeObjects");
+    public static /*const*/ string sel_graphicsContextWithWindow_1 = sel_registerName("graphicsContextWithWindow:");
+    public static /*const*/ string sel_StringWithCapacity_1 = sel_registerName("StringWithCapacity:");
+    public static /*const*/ string sel_results = sel_registerName("results");
+    public static /*const*/ string sel_loadFileWrapperRepresentation_1ofType_1 = sel_registerName("loadFileWrapperRepresentation:ofType:");
+    public static /*const*/ string sel_secondsFromGMTForDate_1 = sel_registerName("secondsFromGMTForDate:");
+    public static /*const*/ string sel_clearStopAnimation = sel_registerName("clearStopAnimation");
+    public static /*const*/ string sel_numberWithShort_1 = sel_registerName("numberWithShort:");
+    public static /*const*/ string sel_setHorizontallyCentered_1 = sel_registerName("setHorizontallyCentered:");
+    public static /*const*/ string sel_setNeedsDisplayInRect_1 = sel_registerName("setNeedsDisplayInRect:");
+    public static /*const*/ string sel_objectDidBeginEditing_1 = sel_registerName("objectDidBeginEditing:");
+    public static /*const*/ string sel_rightMouseDown_1 = sel_registerName("rightMouseDown:");
+    public static /*const*/ string sel_data2 = sel_registerName("data2");
+    public static /*const*/ string sel_initWithCalendarIdentifier_1 = sel_registerName("initWithCalendarIdentifier:");
+    public static /*const*/ string sel_containsValueForKey_1 = sel_registerName("containsValueForKey:");
+    public static /*const*/ string sel_result = sel_registerName("result");
+    public static /*const*/ string sel_printDocument_1 = sel_registerName("printDocument:");
+    public static /*const*/ string sel_addSuiteNamed_1 = sel_registerName("addSuiteNamed:");
+    public static /*const*/ string sel_deleteCookie_1 = sel_registerName("deleteCookie:");
+    public static /*const*/ string sel_isLocationRequiredToCreateForKey_1 = sel_registerName("isLocationRequiredToCreateForKey:");
+    public static /*const*/ string sel_saveGraphicsState = sel_registerName("saveGraphicsState");
+    public static /*const*/ string sel_getInfoForFile_1application_1type_1 = sel_registerName("getInfoForFile:application:type:");
+    public static /*const*/ string sel_HTTPBodyStream = sel_registerName("HTTPBodyStream");
+    public static /*const*/ string sel_accessibilityParameterizedAttributeNames = sel_registerName("accessibilityParameterizedAttributeNames");
+    public static /*const*/ string sel_objectForKey_1 = sel_registerName("objectForKey:");
+    public static /*const*/ string sel_classForArchiver = sel_registerName("classForArchiver");
+    public static /*const*/ string sel_allBundles = sel_registerName("allBundles");
+    public static /*const*/ string sel_rangeOfComposedCharacterSequenceAtIndex_1 = sel_registerName("rangeOfComposedCharacterSequenceAtIndex:");
+    public static /*const*/ string sel_allowsDuplicatesInToolbar = sel_registerName("allowsDuplicatesInToolbar");
+    public static /*const*/ string sel_speechSynthesizer_1didEncounterSyncMessage_1 = sel_registerName("speechSynthesizer:didEncounterSyncMessage:");
+    public static /*const*/ string sel_performSelector_1withObject_1afterDelay_1inModes_1 = sel_registerName("performSelector:withObject:afterDelay:inModes:");
+    public static /*const*/ string sel_setScalesWhenResized_1 = sel_registerName("setScalesWhenResized:");
+    public static /*const*/ string sel_fileWrappers = sel_registerName("fileWrappers");
+    public static /*const*/ string sel_setSubmenu_1 = sel_registerName("setSubmenu:");
+    public static /*const*/ string sel_setSendsSearchStringImmediately_1 = sel_registerName("setSendsSearchStringImmediately:");
+    public static /*const*/ string sel_movieUnfilteredPasteboardTypes = sel_registerName("movieUnfilteredPasteboardTypes");
+    public static /*const*/ string sel_browser_1willDisplayCell_1atRow_1column_1 = sel_registerName("browser:willDisplayCell:atRow:column:");
+    public static /*const*/ string sel_valueOfAttribute_1forResultAtIndex_1 = sel_registerName("valueOfAttribute:forResultAtIndex:");
+    public static /*const*/ string sel_rightExpression = sel_registerName("rightExpression");
+    public static /*const*/ string sel_moveNode_1toIndexPath_1 = sel_registerName("moveNode:toIndexPath:");
+    public static /*const*/ string sel_insertionKey = sel_registerName("insertionKey");
+    public static /*const*/ string sel_columnsAutosaveName = sel_registerName("columnsAutosaveName");
+    public static /*const*/ string sel_connection_1didReceiveResponse_1 = sel_registerName("connection:didReceiveResponse:");
+    public static /*const*/ string sel_delegate = sel_registerName("delegate");
+    public static /*const*/ string sel_valueForHTTPHeaderField_1 = sel_registerName("valueForHTTPHeaderField:");
+    public static /*const*/ string sel_requiredThickness = sel_registerName("requiredThickness");
+    public static /*const*/ string sel_selectedCells = sel_registerName("selectedCells");
+    public static /*const*/ string sel_setResizable_1 = sel_registerName("setResizable:");
+    public static /*const*/ string sel_resizeRightCursor = sel_registerName("resizeRightCursor");
+    public static /*const*/ string sel_arrayWithContentsOfURL_1 = sel_registerName("arrayWithContentsOfURL:");
+    public static /*const*/ string sel_setEchosBullets_1 = sel_registerName("setEchosBullets:");
+    public static /*const*/ string sel_outlineViewItemDidCollapse_1 = sel_registerName("outlineViewItemDidCollapse:");
+    public static /*const*/ string sel_mutableSetValueForKey_1 = sel_registerName("mutableSetValueForKey:");
+    public static /*const*/ string sel_initWithObjects_1forKeys_1count_1 = sel_registerName("initWithObjects:forKeys:count:");
+    public static /*const*/ string sel_canBeDisabled = sel_registerName("canBeDisabled");
+    public static /*const*/ string sel_selectTabViewItemWithIdentifier_1 = sel_registerName("selectTabViewItemWithIdentifier:");
+    public static /*const*/ string sel_setLongEraSymbols_1 = sel_registerName("setLongEraSymbols:");
+    public static /*const*/ string sel_displayRect_1 = sel_registerName("displayRect:");
+    public static /*const*/ string sel_initRemoteWithProtocolFamily_1socketType_1protocol_1address_1 = sel_registerName("initRemoteWithProtocolFamily:socketType:protocol:address:");
+    public static /*const*/ string sel_setQueuePriority_1 = sel_registerName("setQueuePriority:");
+    public static /*const*/ string sel_initWithFileDescriptor_1closeOnDealloc_1 = sel_registerName("initWithFileDescriptor:closeOnDealloc:");
+    public static /*const*/ string sel_comboBoxWillDismiss_1 = sel_registerName("comboBoxWillDismiss:");
+    public static /*const*/ string sel_setMatchesOnMultipleResolution_1 = sel_registerName("setMatchesOnMultipleResolution:");
+    public static /*const*/ string sel_connection = sel_registerName("connection");
+    public static /*const*/ string sel_includedKeys = sel_registerName("includedKeys");
+    public static /*const*/ string sel_writeToURL_1options_1error_1 = sel_registerName("writeToURL:options:error:");
+    public static /*const*/ string sel_activeProcessorCount = sel_registerName("activeProcessorCount");
+    public static /*const*/ string sel_countByEnumeratingWithState_1objects_1count_1 = sel_registerName("countByEnumeratingWithState:objects:count:");
+    public static /*const*/ string sel_setTransformStruct_1 = sel_registerName("setTransformStruct:");
+    public static /*const*/ string sel_setVeryShortWeekdaySymbols_1 = sel_registerName("setVeryShortWeekdaySymbols:");
+    public static /*const*/ string sel_markerLocation = sel_registerName("markerLocation");
+    public static /*const*/ string sel_widthForLayer_1edge_1 = sel_registerName("widthForLayer:edge:");
+    public static /*const*/ string sel_transform = sel_registerName("transform");
+    public static /*const*/ string sel_addSelectionIndexPaths_1 = sel_registerName("addSelectionIndexPaths:");
+    public static /*const*/ string sel_removeRequestMode_1 = sel_registerName("removeRequestMode:");
+    public static /*const*/ string sel_indexOfObject_1inRange_1 = sel_registerName("indexOfObject:inRange:");
+    public static /*const*/ string sel_awakeAfterUsingCoder_1 = sel_registerName("awakeAfterUsingCoder:");
+    public static /*const*/ string sel_setKnobProportion_1 = sel_registerName("setKnobProportion:");
+    public static /*const*/ string sel_setAllowsUserCustomization_1 = sel_registerName("setAllowsUserCustomization:");
+    public static /*const*/ string sel_setCurrentOperation_1 = sel_registerName("setCurrentOperation:");
+    public static /*const*/ string sel_outlineView_1isGroupItem_1 = sel_registerName("outlineView:isGroupItem:");
+    public static /*const*/ string sel_deleteGlyphsInRange_1 = sel_registerName("deleteGlyphsInRange:");
+    public static /*const*/ string sel_setSelectedObjects_1 = sel_registerName("setSelectedObjects:");
+    public static /*const*/ string sel_pathComponentCellAtPoint_1withFrame_1inView_1 = sel_registerName("pathComponentCellAtPoint:withFrame:inView:");
+    public static /*const*/ string sel_outlineView_1acceptDrop_1item_1childIndex_1 = sel_registerName("outlineView:acceptDrop:item:childIndex:");
+    public static /*const*/ string sel_setBackgroundColor_1 = sel_registerName("setBackgroundColor:");
+    public static /*const*/ string sel_canSelectNext = sel_registerName("canSelectNext");
+    public static /*const*/ string sel_encodeRect_1forKey_1 = sel_registerName("encodeRect:forKey:");
+    public static /*const*/ string sel_resetCursorRect_1inView_1 = sel_registerName("resetCursorRect:inView:");
+    public static /*const*/ string sel_resumeData = sel_registerName("resumeData");
+    public static /*const*/ string sel_levelsOfUndo = sel_registerName("levelsOfUndo");
+    public static /*const*/ string sel_objectIsForcedForKey_1 = sel_registerName("objectIsForcedForKey:");
+    public static /*const*/ string sel_minSize = sel_registerName("minSize");
+    public static /*const*/ string sel_indentationPerLevel = sel_registerName("indentationPerLevel");
+    public static /*const*/ string sel_browserColumnConfigurationDidChange_1 = sel_registerName("browserColumnConfigurationDidChange:");
+    public static /*const*/ string sel_startAnimation = sel_registerName("startAnimation");
+    public static /*const*/ string sel_outlineView_1namesOfPromisedFilesDroppedAtDestination_1forDraggedItems_1 = sel_registerName("outlineView:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:");
+    public static /*const*/ string sel_setAlignment_1range_1 = sel_registerName("setAlignment:range:");
+    public static /*const*/ string sel_zeroSymbol = sel_registerName("zeroSymbol");
+    public static /*const*/ string sel_draggedImage_1beganAt_1 = sel_registerName("draggedImage:beganAt:");
+    public static /*const*/ string sel_buttonMask = sel_registerName("buttonMask");
+    public static /*const*/ string sel_frame = sel_registerName("frame");
+    public static /*const*/ string sel_markers = sel_registerName("markers");
+    public static /*const*/ string sel_initWithObjects_1count_1 = sel_registerName("initWithObjects:count:");
+    public static /*const*/ string sel_unload = sel_registerName("unload");
+    public static /*const*/ string sel_initForReadingWithData_1 = sel_registerName("initForReadingWithData:");
+    public static /*const*/ string sel_year = sel_registerName("year");
+    public static /*const*/ string sel_ruleEditor_1child_1forCriterion_1withRowType_1 = sel_registerName("ruleEditor:child:forCriterion:withRowType:");
+    public static /*const*/ string sel_dayOfMonth = sel_registerName("dayOfMonth");
+    public static /*const*/ string sel_colorUsingColorSpaceName_1 = sel_registerName("colorUsingColorSpaceName:");
+    public static /*const*/ string sel_registerCoercer_1selector_1toConvertFromClass_1toClass_1 = sel_registerName("registerCoercer:selector:toConvertFromClass:toClass:");
+    public static /*const*/ string sel_removeObject_1inRange_1 = sel_registerName("removeObject:inRange:");
+    public static /*const*/ string sel_setFrameFromString_1 = sel_registerName("setFrameFromString:");
+    public static /*const*/ string sel_canAdd = sel_registerName("canAdd");
+    public static /*const*/ string sel_era = sel_registerName("era");
+    public static /*const*/ string sel_expressionForSubquery_1usingIteratorVariable_1predicate_1 = sel_registerName("expressionForSubquery:usingIteratorVariable:predicate:");
+    public static /*const*/ string sel_setAMSymbol_1 = sel_registerName("setAMSymbol:");
+    public static /*const*/ string sel_groupedResults = sel_registerName("groupedResults");
+    public static /*const*/ string sel_attributedStringValue = sel_registerName("attributedStringValue");
+    public static /*const*/ string sel_enclosingScrollView = sel_registerName("enclosingScrollView");
+    public static /*const*/ string sel_isEqualToNumber_1 = sel_registerName("isEqualToNumber:");
+    public static /*const*/ string sel_mainBundle = sel_registerName("mainBundle");
+    public static /*const*/ string sel_textContainerForGlyphAtIndex_1effectiveRange_1 = sel_registerName("textContainerForGlyphAtIndex:effectiveRange:");
+    public static /*const*/ string sel_setUsesGroupingSeparator_1 = sel_registerName("setUsesGroupingSeparator:");
+    public static /*const*/ string sel_pointerAtIndex_1 = sel_registerName("pointerAtIndex:");
+    public static /*const*/ string sel_arrowsPosition = sel_registerName("arrowsPosition");
+    public static /*const*/ string sel_panel_1compareFilename_1with_1caseSensitive_1 = sel_registerName("panel:compareFilename:with:caseSensitive:");
+    public static /*const*/ string sel_drawSeparatorItemWithFrame_1inView_1 = sel_registerName("drawSeparatorItemWithFrame:inView:");
+    public static /*const*/ string sel_objectsByEvaluatingWithContainers_1 = sel_registerName("objectsByEvaluatingWithContainers:");
+    public static /*const*/ string sel_textTabForGlyphLocation_1writingDirection_1maxLocation_1 = sel_registerName("textTabForGlyphLocation:writingDirection:maxLocation:");
+    public static /*const*/ string sel_fontDescriptor = sel_registerName("fontDescriptor");
+    public static /*const*/ string sel_validAttributesForMarkedText = sel_registerName("validAttributesForMarkedText");
+    public static /*const*/ string sel_scriptingEndsWith_1 = sel_registerName("scriptingEndsWith:");
+    public static /*const*/ string sel_scrollViaScroller_1 = sel_registerName("scrollViaScroller:");
+    public static /*const*/ string sel_setAlwaysUsesMultipleValuesMarker_1 = sel_registerName("setAlwaysUsesMultipleValuesMarker:");
+    public static /*const*/ string sel_attributeKeys = sel_registerName("attributeKeys");
+    public static /*const*/ string sel_darkGrayColor = sel_registerName("darkGrayColor");
+    public static /*const*/ string sel_setExtensionHidden_1 = sel_registerName("setExtensionHidden:");
+    public static /*const*/ string sel_drawInRect_1withAttributes_1 = sel_registerName("drawInRect:withAttributes:");
+    public static /*const*/ string sel_selectTabViewItemAtIndex_1 = sel_registerName("selectTabViewItemAtIndex:");
+    public static /*const*/ string sel_contentRectForFrameRect_1 = sel_registerName("contentRectForFrameRect:");
+    public static /*const*/ string sel_setParagraphSpacingBefore_1 = sel_registerName("setParagraphSpacingBefore:");
+    public static /*const*/ string sel_minDate = sel_registerName("minDate");
+    public static /*const*/ string sel_isARepeat = sel_registerName("isARepeat");
+    public static /*const*/ string sel_selectedTabViewItem = sel_registerName("selectedTabViewItem");
+    public static /*const*/ string sel_minusHashTable_1 = sel_registerName("minusHashTable:");
+    public static /*const*/ string sel_preferredLocalizationsFromArray_1forPreferences_1 = sel_registerName("preferredLocalizationsFromArray:forPreferences:");
+    public static /*const*/ string sel_setTextBlocks_1 = sel_registerName("setTextBlocks:");
+    public static /*const*/ string sel_writePrintInfo = sel_registerName("writePrintInfo");
+    public static /*const*/ string sel_paperName = sel_registerName("paperName");
+    public static /*const*/ string sel_pauseSpeakingAtBoundary_1 = sel_registerName("pauseSpeakingAtBoundary:");
+    public static /*const*/ string sel_markedTextAbandoned_1 = sel_registerName("markedTextAbandoned:");
+    public static /*const*/ string sel_setTitled_1 = sel_registerName("setTitled:");
+    public static /*const*/ string sel_hidesOnDeactivate = sel_registerName("hidesOnDeactivate");
+    public static /*const*/ string sel_selectedRange = sel_registerName("selectedRange");
+    public static /*const*/ string sel_reportException_1 = sel_registerName("reportException:");
+    public static /*const*/ string sel_drawBezelWithFrame_1inView_1 = sel_registerName("drawBezelWithFrame:inView:");
+    public static /*const*/ string sel_relativeMoveToPoint_1 = sel_registerName("relativeMoveToPoint:");
+    public static /*const*/ string sel_printingAdjustmentInLayoutManager_1forNominallySpacedGlyphRange_1packedGlyphs_1count_1 = sel_registerName("printingAdjustmentInLayoutManager:forNominallySpacedGlyphRange:packedGlyphs:count:");
+    public static /*const*/ string sel_longValue = sel_registerName("longValue");
+    public static /*const*/ string sel_setMaxNumberOfColumns_1 = sel_registerName("setMaxNumberOfColumns:");
+    public static /*const*/ string sel_textView_1draggedCell_1inRect_1event_1atIndex_1 = sel_registerName("textView:draggedCell:inRect:event:atIndex:");
+    public static /*const*/ string sel_isRemovable = sel_registerName("isRemovable");
+    public static /*const*/ string sel_handleCloseScriptCommand_1 = sel_registerName("handleCloseScriptCommand:");
+    public static /*const*/ string sel_layoutManager_1shouldUseTemporaryAttributes_1forDrawingToScreen_1atCharacterIndex_1effectiveRange_1 = sel_registerName("layoutManager:shouldUseTemporaryAttributes:forDrawingToScreen:atCharacterIndex:effectiveRange:");
+    public static /*const*/ string sel_expressionForKeyPath_1 = sel_registerName("expressionForKeyPath:");
+    public static /*const*/ string sel_bezierPathWithOvalInRect_1 = sel_registerName("bezierPathWithOvalInRect:");
+    public static /*const*/ string sel_deselectSelectedCell = sel_registerName("deselectSelectedCell");
+    public static /*const*/ string sel_defaultSubcontainerAttributeKey = sel_registerName("defaultSubcontainerAttributeKey");
+    public static /*const*/ string sel_yank_1 = sel_registerName("yank:");
+    public static /*const*/ string sel_changeSpelling_1 = sel_registerName("changeSpelling:");
+    public static /*const*/ string sel_totalAutoreleasedObjects = sel_registerName("totalAutoreleasedObjects");
+    public static /*const*/ string sel_loops = sel_registerName("loops");
+    public static /*const*/ string sel_boundsRectForTextBlock_1atIndex_1effectiveRange_1 = sel_registerName("boundsRectForTextBlock:atIndex:effectiveRange:");
+    public static /*const*/ string sel_resignMainWindow = sel_registerName("resignMainWindow");
+    public static /*const*/ string sel_availableLanguages = sel_registerName("availableLanguages");
+    public static /*const*/ string sel_initWithMarkerFormat_1options_1 = sel_registerName("initWithMarkerFormat:options:");
+    public static /*const*/ string sel_runInNewThread = sel_registerName("runInNewThread");
+    public static /*const*/ string sel_tableView_1selectionIndexesForProposedSelection_1 = sel_registerName("tableView:selectionIndexesForProposedSelection:");
+    public static /*const*/ string sel_fetchWithRequest_1merge_1error_1 = sel_registerName("fetchWithRequest:merge:error:");
+    public static /*const*/ string sel_endSubelementIdentifier = sel_registerName("endSubelementIdentifier");
+    public static /*const*/ string sel_implementationClassName = sel_registerName("implementationClassName");
+    public static /*const*/ string sel_eventNumber = sel_registerName("eventNumber");
+    public static /*const*/ string sel_requestTimeout = sel_registerName("requestTimeout");
+    public static /*const*/ string sel_boldSystemFontOfSize_1 = sel_registerName("boldSystemFontOfSize:");
+    public static /*const*/ string sel_setPixelsWide_1 = sel_registerName("setPixelsWide:");
+    public static /*const*/ string sel_labelForSegment_1 = sel_registerName("labelForSegment:");
+    public static /*const*/ string sel_setAlternateTitle_1 = sel_registerName("setAlternateTitle:");
+    public static /*const*/ string sel_shouldBreakLineByWordBeforeCharacterAtIndex_1 = sel_registerName("shouldBreakLineByWordBeforeCharacterAtIndex:");
+    public static /*const*/ string sel_lockFocusIfCanDraw = sel_registerName("lockFocusIfCanDraw");
+    public static /*const*/ string sel_setFormat_1 = sel_registerName("setFormat:");
+    public static /*const*/ string sel_setSegmentCount_1 = sel_registerName("setSegmentCount:");
+    public static /*const*/ string sel_accessInstanceVariablesDirectly = sel_registerName("accessInstanceVariablesDirectly");
+    public static /*const*/ string sel_comboBox_1completedString_1 = sel_registerName("comboBox:completedString:");
+    public static /*const*/ string sel_moveToBeginningOfParagraph_1 = sel_registerName("moveToBeginningOfParagraph:");
+    public static /*const*/ string sel_defaultParagraphStyle = sel_registerName("defaultParagraphStyle");
+    public static /*const*/ string sel_availableTypeFromArray_1 = sel_registerName("availableTypeFromArray:");
+    public static /*const*/ string sel_setGregorianStartDate_1 = sel_registerName("setGregorianStartDate:");
+    public static /*const*/ string sel_dateWithTimeIntervalSince1970_1 = sel_registerName("dateWithTimeIntervalSince1970:");
+    public static /*const*/ string sel_imagePasteboardTypes = sel_registerName("imagePasteboardTypes");
+    public static /*const*/ string sel_laterDate_1 = sel_registerName("laterDate:");
+    public static /*const*/ string sel_setBounds_1 = sel_registerName("setBounds:");
+    public static /*const*/ string sel_HTTPMethod = sel_registerName("HTTPMethod");
+    public static /*const*/ string sel_getGlyphsInRange_1glyphs_1characterIndexes_1glyphInscriptions_1elasticBits_1bidiLevels_1 = sel_registerName("getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels:");
+    public static /*const*/ string sel_rectArrayForCharacterRange_1withinSelectedCharacterRange_1inTextContainer_1rectCount_1 = sel_registerName("rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:rectCount:");
+    public static /*const*/ string sel_drawGridInClipRect_1 = sel_registerName("drawGridInClipRect:");
+    public static /*const*/ string sel_isStarted = sel_registerName("isStarted");
+    public static /*const*/ string sel_descriptorType = sel_registerName("descriptorType");
+    public static /*const*/ string sel_ISOCurrencyCodes = sel_registerName("ISOCurrencyCodes");
+    public static /*const*/ string sel_resetCancelButtonCell = sel_registerName("resetCancelButtonCell");
+    public static /*const*/ string sel_positiveInfinitySymbol = sel_registerName("positiveInfinitySymbol");
+    public static /*const*/ string sel_sendsActionOnArrowKeys = sel_registerName("sendsActionOnArrowKeys");
+    public static /*const*/ string sel_delete_1 = sel_registerName("delete:");
+    public static /*const*/ string sel_toolbarWillAddItem_1 = sel_registerName("toolbarWillAddItem:");
+    public static /*const*/ string sel_updateCellInside_1 = sel_registerName("updateCellInside:");
+    public static /*const*/ string sel_inputClientResignActive_1 = sel_registerName("inputClientResignActive:");
+    public static /*const*/ string sel_initWithEventClass_1eventID_1targetDescriptor_1returnID_1transactionID_1 = sel_registerName("initWithEventClass:eventID:targetDescriptor:returnID:transactionID:");
+    public static /*const*/ string sel_decimalNumberByDividingBy_1withBehavior_1 = sel_registerName("decimalNumberByDividingBy:withBehavior:");
+    public static /*const*/ string sel_spellServer_1suggestCompletionsForPartialWordRange_1inString_1language_1 = sel_registerName("spellServer:suggestCompletionsForPartialWordRange:inString:language:");
+    public static /*const*/ string sel_arrayWithObjects_1count_1 = sel_registerName("arrayWithObjects:count:");
+    public static /*const*/ string sel_connectionWithRegisteredName_1host_1 = sel_registerName("connectionWithRegisteredName:host:");
+    public static /*const*/ string sel_initWithFormat_1 = sel_registerName("initWithFormat:");
+    public static /*const*/ string sel_sharedURLCache = sel_registerName("sharedURLCache");
+    public static /*const*/ string sel_edited_1range_1changeInLength_1 = sel_registerName("edited:range:changeInLength:");
+    public static /*const*/ string sel_prepareContent = sel_registerName("prepareContent");
+    public static /*const*/ string sel_StringWithCString_1encoding_1 = sel_registerName("StringWithCString:encoding:");
+    public static /*const*/ string sel_postNotificationName_1object_1userInfo_1deliverImmediately_1 = sel_registerName("postNotificationName:object:userInfo:deliverImmediately:");
+    public static /*const*/ string sel_coerceToDescriptorType_1 = sel_registerName("coerceToDescriptorType:");
+    public static /*const*/ string sel_selectionIndex = sel_registerName("selectionIndex");
+    public static /*const*/ string sel_setContentMaxSize_1 = sel_registerName("setContentMaxSize:");
+    public static /*const*/ string sel_setColor_1atX_1y_1 = sel_registerName("setColor:atX:y:");
+    public static /*const*/ string sel_graphicsContext = sel_registerName("graphicsContext");
+    public static /*const*/ string sel_hostWithName_1 = sel_registerName("hostWithName:");
+    public static /*const*/ string sel_toggleRuler_1 = sel_registerName("toggleRuler:");
+    public static /*const*/ string sel_glyphInfoWithGlyph_1forFont_1baseString_1 = sel_registerName("glyphInfoWithGlyph:forFont:baseString:");
+    public static /*const*/ string sel_panel_1willExpand_1 = sel_registerName("panel:willExpand:");
+    public static /*const*/ string sel_selectText_1 = sel_registerName("selectText:");
+    public static /*const*/ string sel_setShortMonthSymbols_1 = sel_registerName("setShortMonthSymbols:");
+    public static /*const*/ string sel_setBorderType_1 = sel_registerName("setBorderType:");
+    public static /*const*/ string sel_rangeOfString_1 = sel_registerName("rangeOfString:");
+    public static /*const*/ string sel_invalidateGlyphsOnLayoutInvalidationForGlyphRange_1 = sel_registerName("invalidateGlyphsOnLayoutInvalidationForGlyphRange:");
+    public static /*const*/ string sel_availableMembersOfFontFamily_1 = sel_registerName("availableMembersOfFontFamily:");
+    public static /*const*/ string sel_XPath = sel_registerName("XPath");
+    public static /*const*/ string sel_contentsOfDirectoryAtPath_1error_1 = sel_registerName("contentsOfDirectoryAtPath:error:");
+    public static /*const*/ string sel_newItemForRepresentedObject_1 = sel_registerName("newItemForRepresentedObject:");
+    public static /*const*/ string sel_setMatrixClass_1 = sel_registerName("setMatrixClass:");
+    public static /*const*/ string sel_compositeToPoint_1operation_1fraction_1 = sel_registerName("compositeToPoint:operation:fraction:");
+    public static /*const*/ string sel_setHorizontallyResizable_1 = sel_registerName("setHorizontallyResizable:");
+    public static /*const*/ string sel_mapTableWithStrongToStrongObjects = sel_registerName("mapTableWithStrongToStrongObjects");
+    public static /*const*/ string sel_colorSpaceModel = sel_registerName("colorSpaceModel");
+    public static /*const*/ string sel_setCriticalValue_1 = sel_registerName("setCriticalValue:");
+    public static /*const*/ string sel_allowsToolTipsWhenApplicationIsInactive = sel_registerName("allowsToolTipsWhenApplicationIsInactive");
+    public static /*const*/ string sel_transformUsingAffineTransform_1 = sel_registerName("transformUsingAffineTransform:");
+    public static /*const*/ string sel_initWithInvocation_1 = sel_registerName("initWithInvocation:");
+    public static /*const*/ string sel_containerClassDescription = sel_registerName("containerClassDescription");
+    public static /*const*/ string sel_parser_1resolveExternalEntityName_1systemID_1 = sel_registerName("parser:resolveExternalEntityName:systemID:");
+    public static /*const*/ string sel_mouseLocationOutsideOfEventStream = sel_registerName("mouseLocationOutsideOfEventStream");
+    public static /*const*/ string sel_detach = sel_registerName("detach");
+    public static /*const*/ string sel_setPickerMask_1 = sel_registerName("setPickerMask:");
+    public static /*const*/ string sel_tokenStyle = sel_registerName("tokenStyle");
+    public static /*const*/ string sel_setOptions_1 = sel_registerName("setOptions:");
+    public static /*const*/ string sel_PDFOperationWithView_1insideRect_1toPath_1printInfo_1 = sel_registerName("PDFOperationWithView:insideRect:toPath:printInfo:");
+    public static /*const*/ string sel_parser_1didStartElement_1namespaceURI_1qualifiedName_1attributes_1 = sel_registerName("parser:didStartElement:namespaceURI:qualifiedName:attributes:");
+    public static /*const*/ string sel_availableFontNamesMatchingFontDescriptor_1 = sel_registerName("availableFontNamesMatchingFontDescriptor:");
+    public static /*const*/ string sel_relativePath = sel_registerName("relativePath");
+    public static /*const*/ string sel_moveWordForwardAndModifySelection_1 = sel_registerName("moveWordForwardAndModifySelection:");
+    public static /*const*/ string sel_currentTime = sel_registerName("currentTime");
+    public static /*const*/ string sel_slideDraggedImageTo_1 = sel_registerName("slideDraggedImageTo:");
+    public static /*const*/ string sel_application_1printFile_1 = sel_registerName("application:printFile:");
+    public static /*const*/ string sel_punctuationCharacterSet = sel_registerName("punctuationCharacterSet");
+    public static /*const*/ string sel_allKeysForObject_1 = sel_registerName("allKeysForObject:");
+    public static /*const*/ string sel_pathStyle = sel_registerName("pathStyle");
+    public static /*const*/ string sel_allowsEditingTextAttributes = sel_registerName("allowsEditingTextAttributes");
+    public static /*const*/ string sel_lineSpacingAfterGlyphAtIndex_1withProposedLineFragmentRect_1 = sel_registerName("lineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:");
+    public static /*const*/ string sel_initWithContentsOfMappedFile_1 = sel_registerName("initWithContentsOfMappedFile:");
+    public static /*const*/ string sel_initWithFrame_1pullsDown_1 = sel_registerName("initWithFrame:pullsDown:");
+    public static /*const*/ string sel_setView_1 = sel_registerName("setView:");
+    public static /*const*/ string sel_outlineViewSelectionDidChange_1 = sel_registerName("outlineViewSelectionDidChange:");
+    public static /*const*/ string sel_widthValueTypeForLayer_1edge_1 = sel_registerName("widthValueTypeForLayer:edge:");
+    public static /*const*/ string sel_dateWithTimeIntervalSinceNow_1 = sel_registerName("dateWithTimeIntervalSinceNow:");
+    public static /*const*/ string sel_display = sel_registerName("display");
+    public static /*const*/ string sel_setRoundingBehavior_1 = sel_registerName("setRoundingBehavior:");
+    public static /*const*/ string sel_valueWithPoint_1 = sel_registerName("valueWithPoint:");
+    public static /*const*/ string sel_tickMarkValueAtIndex_1 = sel_registerName("tickMarkValueAtIndex:");
+    public static /*const*/ string sel_addColumnWithCells_1 = sel_registerName("addColumnWithCells:");
+    public static /*const*/ string sel_exposeBinding_1 = sel_registerName("exposeBinding:");
+    public static /*const*/ string sel_weekdayOrdinal = sel_registerName("weekdayOrdinal");
+    public static /*const*/ string sel_canAddChild = sel_registerName("canAddChild");
+    public static /*const*/ string sel_hitTest_1 = sel_registerName("hitTest:");
+    public static /*const*/ string sel_nibBundle = sel_registerName("nibBundle");
+    public static /*const*/ string sel_resumeExecutionWithResult_1 = sel_registerName("resumeExecutionWithResult:");
+    public static /*const*/ string sel_setMonthSymbols_1 = sel_registerName("setMonthSymbols:");
+    public static /*const*/ string sel_hitPart = sel_registerName("hitPart");
+    public static /*const*/ string sel_download_1didCancelAuthenticationChallenge_1 = sel_registerName("download:didCancelAuthenticationChallenge:");
+    public static /*const*/ string sel_descriptionWithCalendarFormat_1 = sel_registerName("descriptionWithCalendarFormat:");
+    public static /*const*/ string sel_setProtocolSpecificInformation_1 = sel_registerName("setProtocolSpecificInformation:");
+    public static /*const*/ string sel_tokenField_1shouldAddObjects_1atIndex_1 = sel_registerName("tokenField:shouldAddObjects:atIndex:");
+    public static /*const*/ string sel_popUpContextMenu_1withEvent_1forView_1 = sel_registerName("popUpContextMenu:withEvent:forView:");
+    public static /*const*/ string sel_stopPeriodicEvents = sel_registerName("stopPeriodicEvents");
+    public static /*const*/ string sel_setDTD_1 = sel_registerName("setDTD:");
+    public static /*const*/ string sel_glyphAtIndex_1isValidIndex_1 = sel_registerName("glyphAtIndex:isValidIndex:");
+    public static /*const*/ string sel_encodeSize_1 = sel_registerName("encodeSize:");
+    public static /*const*/ string sel_windowForSheet = sel_registerName("windowForSheet");
+    public static /*const*/ string sel_displayMode = sel_registerName("displayMode");
+    public static /*const*/ string sel_revertDocumentToSaved_1 = sel_registerName("revertDocumentToSaved:");
+    public static /*const*/ string sel_tableView_1objectValueForTableColumn_1row_1 = sel_registerName("tableView:objectValueForTableColumn:row:");
+    public static /*const*/ string sel_setBackingType_1 = sel_registerName("setBackingType:");
+    public static /*const*/ string sel_scanUpToCharactersFromSet_1intoString_1 = sel_registerName("scanUpToCharactersFromSet:intoString:");
+    public static /*const*/ string sel_nextValidKeyView = sel_registerName("nextValidKeyView");
+    public static /*const*/ string sel_arrayWithObject_1 = sel_registerName("arrayWithObject:");
+    public static /*const*/ string sel_flushBuffer = sel_registerName("flushBuffer");
+    public static /*const*/ string sel_hasValidObjectValue = sel_registerName("hasValidObjectValue");
+    public static /*const*/ string sel_numberWithUnsignedLong_1 = sel_registerName("numberWithUnsignedLong:");
+    public static /*const*/ string sel_collectExhaustively = sel_registerName("collectExhaustively");
+    public static /*const*/ string sel_setImageInterpolation_1 = sel_registerName("setImageInterpolation:");
+    public static /*const*/ string sel_setSystemID_1 = sel_registerName("setSystemID:");
+    public static /*const*/ string sel_setCornerView_1 = sel_registerName("setCornerView:");
+    public static /*const*/ string sel_initWithDouble_1 = sel_registerName("initWithDouble:");
+    public static /*const*/ string sel_sortedArrayUsingDescriptors_1 = sel_registerName("sortedArrayUsingDescriptors:");
+    public static /*const*/ string sel_removeTextContainerAtIndex_1 = sel_registerName("removeTextContainerAtIndex:");
+    public static /*const*/ string sel_whitespaceCharacterSet = sel_registerName("whitespaceCharacterSet");
+    public static /*const*/ string sel_classDescriptionForClass_1 = sel_registerName("classDescriptionForClass:");
+    public static /*const*/ string sel_setAttributedString_1 = sel_registerName("setAttributedString:");
+    public static /*const*/ string sel_setPixelsHigh_1 = sel_registerName("setPixelsHigh:");
+    public static /*const*/ string sel_setDynamicDepthLimit_1 = sel_registerName("setDynamicDepthLimit:");
+    public static /*const*/ string sel_sharedApplication = sel_registerName("sharedApplication");
+    public static /*const*/ string sel_sound_1didFinishPlaying_1 = sel_registerName("sound:didFinishPlaying:");
+    public static /*const*/ string sel_defaultBehavior = sel_registerName("defaultBehavior");
+    public static /*const*/ string sel_beginSheetForDirectory_1file_1types_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1 = sel_registerName("beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:");
+    public static /*const*/ string sel_orderFrontFontPanel_1 = sel_registerName("orderFrontFontPanel:");
+    public static /*const*/ string sel_searchForBrowsableDomains = sel_registerName("searchForBrowsableDomains");
+    public static /*const*/ string sel_toggleAutomaticQuoteSubstitution_1 = sel_registerName("toggleAutomaticQuoteSubstitution:");
+    public static /*const*/ string sel_textView_1willChangeSelectionFromCharacterRanges_1toCharacterRanges_1 = sel_registerName("textView:willChangeSelectionFromCharacterRanges:toCharacterRanges:");
+    public static /*const*/ string sel_alignRight_1 = sel_registerName("alignRight:");
+    public static /*const*/ string sel_getBytes_1maxLength_1usedLength_1encoding_1options_1range_1remainingRange_1 = sel_registerName("getBytes:maxLength:usedLength:encoding:options:range:remainingRange:");
+    public static /*const*/ string sel_keyPointerFunctions = sel_registerName("keyPointerFunctions");
+    public static /*const*/ string sel_mouseDownFlags = sel_registerName("mouseDownFlags");
+    public static /*const*/ string sel_expandItem_1 = sel_registerName("expandItem:");
+    public static /*const*/ string sel_bezierPathWithRect_1 = sel_registerName("bezierPathWithRect:");
+    public static /*const*/ string sel_setGradientType_1 = sel_registerName("setGradientType:");
+    public static /*const*/ string sel_alphanumericCharacterSet = sel_registerName("alphanumericCharacterSet");
+    public static /*const*/ string sel_deleteWordForward_1 = sel_registerName("deleteWordForward:");
+    public static /*const*/ string sel_cStringUsingEncoding_1 = sel_registerName("cStringUsingEncoding:");
+    public static /*const*/ string sel_storedValueForKey_1 = sel_registerName("storedValueForKey:");
+    public static /*const*/ string sel_fileSize = sel_registerName("fileSize");
+    public static /*const*/ string sel_elementWithName_1URI_1 = sel_registerName("elementWithName:URI:");
+    public static /*const*/ string sel_pointSize = sel_registerName("pointSize");
+    public static /*const*/ string sel_veryShortMonthSymbols = sel_registerName("veryShortMonthSymbols");
+    public static /*const*/ string sel_transformSize_1 = sel_registerName("transformSize:");
+    public static /*const*/ string sel_titleWidth = sel_registerName("titleWidth");
+    public static /*const*/ string sel_setTextContainerInset_1 = sel_registerName("setTextContainerInset:");
+    public static /*const*/ string sel_supportedWindowDepths = sel_registerName("supportedWindowDepths");
+    public static /*const*/ string sel_appleEvent = sel_registerName("appleEvent");
+    public static /*const*/ string sel_valueClassForBinding_1 = sel_registerName("valueClassForBinding:");
+    public static /*const*/ string sel_setFullScreen = sel_registerName("setFullScreen");
+    public static /*const*/ string sel_encodeObject_1forKey_1 = sel_registerName("encodeObject:forKey:");
+    public static /*const*/ string sel_setSpellingState_1range_1 = sel_registerName("setSpellingState:range:");
+    public static /*const*/ string sel_greenComponent = sel_registerName("greenComponent");
+    public static /*const*/ string sel_textBackgroundColor = sel_registerName("textBackgroundColor");
+    public static /*const*/ string sel_currentEditor = sel_registerName("currentEditor");
+    public static /*const*/ string sel_attachedSheet = sel_registerName("attachedSheet");
+    public static /*const*/ string sel_new = sel_registerName("new");
+    public static /*const*/ string sel_setChildren_1 = sel_registerName("setChildren:");
+    public static /*const*/ string sel_options = sel_registerName("options");
+    public static /*const*/ string sel_setObjectClass_1 = sel_registerName("setObjectClass:");
+    public static /*const*/ string sel_borderWidth = sel_registerName("borderWidth");
+    public static /*const*/ string sel_secondarySelectedControlColor = sel_registerName("secondarySelectedControlColor");
+    public static /*const*/ string sel_scrollItemAtIndexToVisible_1 = sel_registerName("scrollItemAtIndexToVisible:");
+    public static /*const*/ string sel_wantsLayer = sel_registerName("wantsLayer");
+    public static /*const*/ string sel_setPath_1 = sel_registerName("setPath:");
+    public static /*const*/ string sel_setKeys_1triggerChangeNotificationsForDependentKey_1 = sel_registerName("setKeys:triggerChangeNotificationsForDependentKey:");
+    public static /*const*/ string sel_verticalAlignment = sel_registerName("verticalAlignment");
+    public static /*const*/ string sel_selectionGranularity = sel_registerName("selectionGranularity");
+    public static /*const*/ string sel_minimumIntegerDigits = sel_registerName("minimumIntegerDigits");
+    public static /*const*/ string sel_canCreateDirectories = sel_registerName("canCreateDirectories");
+    public static /*const*/ string sel_fixAttributesInRange_1 = sel_registerName("fixAttributesInRange:");
+    public static /*const*/ string sel_URLWithString_1 = sel_registerName("URLWithString:");
+    public static /*const*/ string sel_setFrameFromContentFrame_1 = sel_registerName("setFrameFromContentFrame:");
+    public static /*const*/ string sel_setFillColor_1 = sel_registerName("setFillColor:");
+    public static /*const*/ string sel_dictionaryWithCapacity_1 = sel_registerName("dictionaryWithCapacity:");
+    public static /*const*/ string sel_updateFromPath_1 = sel_registerName("updateFromPath:");
+    public static /*const*/ string sel_netServiceDidResolveAddress_1 = sel_registerName("netServiceDidResolveAddress:");
+    public static /*const*/ string sel_usesLazyFetching = sel_registerName("usesLazyFetching");
+    public static /*const*/ string sel_setMenuBarVisible_1 = sel_registerName("setMenuBarVisible:");
+    public static /*const*/ string sel_windowDidBecomeKey_1 = sel_registerName("windowDidBecomeKey:");
+    public static /*const*/ string sel_menuChanged_1 = sel_registerName("menuChanged:");
+    public static /*const*/ string sel_itemObjectValueAtIndex_1 = sel_registerName("itemObjectValueAtIndex:");
+    public static /*const*/ string sel_setClassName_1forClass_1 = sel_registerName("setClassName:forClass:");
+    public static /*const*/ string sel_setShowsToolbarButton_1 = sel_registerName("setShowsToolbarButton:");
+    public static /*const*/ string sel_plusSign = sel_registerName("plusSign");
+    public static /*const*/ string sel_sharedSpellChecker = sel_registerName("sharedSpellChecker");
+    public static /*const*/ string sel_getNumberOfRows_1columns_1 = sel_registerName("getNumberOfRows:columns:");
+    public static /*const*/ string sel_valueTransformerNames = sel_registerName("valueTransformerNames");
+    public static /*const*/ string sel_interpolatedColorAtLocation_1 = sel_registerName("interpolatedColorAtLocation:");
+    public static /*const*/ string sel_updateSpellingPanelWithMisspelledWord_1 = sel_registerName("updateSpellingPanelWithMisspelledWord:");
+    public static /*const*/ string sel_yellowComponent = sel_registerName("yellowComponent");
+    public static /*const*/ string sel_acceptsFirstResponder = sel_registerName("acceptsFirstResponder");
+    public static /*const*/ string sel_valueWithRect_1 = sel_registerName("valueWithRect:");
+    public static /*const*/ string sel_frameOfCellAtColumn_1row_1 = sel_registerName("frameOfCellAtColumn:row:");
+    public static /*const*/ string sel_makeWindowsPerform_1inOrder_1 = sel_registerName("makeWindowsPerform:inOrder:");
+    public static /*const*/ string sel_lastIndex = sel_registerName("lastIndex");
+    public static /*const*/ string sel_initWithCharacters_1length_1 = sel_registerName("initWithCharacters:length:");
+    public static /*const*/ string sel_initWithIdentifier_1 = sel_registerName("initWithIdentifier:");
+    public static /*const*/ string sel_proxyWithLocal_1connection_1 = sel_registerName("proxyWithLocal:connection:");
+    public static /*const*/ string sel_scrollColumnToVisible_1 = sel_registerName("scrollColumnToVisible:");
+    public static /*const*/ string sel_descriptor = sel_registerName("descriptor");
+    public static /*const*/ string sel_ISOCountryCodes = sel_registerName("ISOCountryCodes");
+    public static /*const*/ string sel_setStandardInput_1 = sel_registerName("setStandardInput:");
+    public static /*const*/ string sel_getAdvancements_1forGlyphs_1count_1 = sel_registerName("getAdvancements:forGlyphs:count:");
+    public static /*const*/ string sel_displayColumn_1 = sel_registerName("displayColumn:");
+    public static /*const*/ string sel_setAltersStateOfSelectedItem_1 = sel_registerName("setAltersStateOfSelectedItem:");
+    public static /*const*/ string sel_setFrameRotation_1 = sel_registerName("setFrameRotation:");
+    public static /*const*/ string sel_clickedOnLink_1atIndex_1 = sel_registerName("clickedOnLink:atIndex:");
+    public static /*const*/ string sel_addAttribute_1 = sel_registerName("addAttribute:");
+    public static /*const*/ string sel_readPrintInfo = sel_registerName("readPrintInfo");
+    public static /*const*/ string sel_setCurrentContext_1 = sel_registerName("setCurrentContext:");
+    public static /*const*/ string sel_setVerticalLineScroll_1 = sel_registerName("setVerticalLineScroll:");
+    public static /*const*/ string sel_commands = sel_registerName("commands");
+    public static /*const*/ string sel_setNamespaces_1 = sel_registerName("setNamespaces:");
+    public static /*const*/ string sel_removeEntryAtIndex_1 = sel_registerName("removeEntryAtIndex:");
+    public static /*const*/ string sel_setAllowsColumnResizing_1 = sel_registerName("setAllowsColumnResizing:");
+    public static /*const*/ string sel_colorWithDeviceCyan_1magenta_1yellow_1black_1alpha_1 = sel_registerName("colorWithDeviceCyan:magenta:yellow:black:alpha:");
+    public static /*const*/ string sel_textView_1shouldChangeTypingAttributes_1toAttributes_1 = sel_registerName("textView:shouldChangeTypingAttributes:toAttributes:");
+    public static /*const*/ string sel_usesFeedbackWindow = sel_registerName("usesFeedbackWindow");
+    public static /*const*/ string sel_setCookie_1 = sel_registerName("setCookie:");
+    public static /*const*/ string sel_keyWindow = sel_registerName("keyWindow");
+    public static /*const*/ string sel_headIndent = sel_registerName("headIndent");
+    public static /*const*/ string sel_removeObjectIdenticalTo_1inRange_1 = sel_registerName("removeObjectIdenticalTo:inRange:");
+    public static /*const*/ string sel_applicationWillUnhide_1 = sel_registerName("applicationWillUnhide:");
+    public static /*const*/ string sel_currentPage = sel_registerName("currentPage");
+    public static /*const*/ string sel_setOffStateImage_1 = sel_registerName("setOffStateImage:");
+    public static /*const*/ string sel_addRowWithCells_1 = sel_registerName("addRowWithCells:");
+    public static /*const*/ string sel_setInterlineSpacing_1 = sel_registerName("setInterlineSpacing:");
+    public static /*const*/ string sel_imageFileTypes = sel_registerName("imageFileTypes");
+    public static /*const*/ string sel_setArray_1 = sel_registerName("setArray:");
+    public static /*const*/ string sel_addLayoutManager_1 = sel_registerName("addLayoutManager:");
+    public static /*const*/ string sel_outputStreamToFileAtPath_1append_1 = sel_registerName("outputStreamToFileAtPath:append:");
+    public static /*const*/ string sel_registeredDraggedTypes = sel_registerName("registeredDraggedTypes");
+    public static /*const*/ string sel_colorWithCalibratedRed_1green_1blue_1alpha_1 = sel_registerName("colorWithCalibratedRed:green:blue:alpha:");
+    public static /*const*/ string sel_invalidateClassDescriptionCache = sel_registerName("invalidateClassDescriptionCache");
+    public static /*const*/ string sel_URLProtocolDidFinishLoading_1 = sel_registerName("URLProtocolDidFinishLoading:");
+    public static /*const*/ string sel_didChangeArrangementCriteria = sel_registerName("didChangeArrangementCriteria");
+    public static /*const*/ string sel_ICCProfileData = sel_registerName("ICCProfileData");
+    public static /*const*/ string sel_availableResourceData = sel_registerName("availableResourceData");
+    public static /*const*/ string sel_glyphIndexForPoint_1inTextContainer_1fractionOfDistanceThroughGlyph_1 = sel_registerName("glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:");
+    public static /*const*/ string sel_moveToEndOfParagraph_1 = sel_registerName("moveToEndOfParagraph:");
+    public static /*const*/ string sel_enterFullScreenMode_1withOptions_1 = sel_registerName("enterFullScreenMode:withOptions:");
+    public static /*const*/ string sel_fieldEditor_1forObject_1 = sel_registerName("fieldEditor:forObject:");
+    public static /*const*/ string sel_setTreatsFilePackagesAsDirectories_1 = sel_registerName("setTreatsFilePackagesAsDirectories:");
+    public static /*const*/ string sel_setLevelIndicatorStyle_1 = sel_registerName("setLevelIndicatorStyle:");
+    public static /*const*/ string sel_minimumDecimalNumber = sel_registerName("minimumDecimalNumber");
+    public static /*const*/ string sel_hasSpaceAvailable = sel_registerName("hasSpaceAvailable");
+    public static /*const*/ string sel_widthOfString_1 = sel_registerName("widthOfString:");
+    public static /*const*/ string sel_setLocale_1 = sel_registerName("setLocale:");
+    public static /*const*/ string sel_setPreferredEdge_1 = sel_registerName("setPreferredEdge:");
+    public static /*const*/ string sel_setRichText_1 = sel_registerName("setRichText:");
+    public static /*const*/ string sel_rangesForUserCharacterAttributeChange = sel_registerName("rangesForUserCharacterAttributeChange");
+    public static /*const*/ string sel_rectForPage_1 = sel_registerName("rectForPage:");
+    public static /*const*/ string sel_rowHeight = sel_registerName("rowHeight");
+    public static /*const*/ string sel_windowDidChangeScreenProfile_1 = sel_registerName("windowDidChangeScreenProfile:");
+    public static /*const*/ string sel_setCachePolicy_1 = sel_registerName("setCachePolicy:");
+    public static /*const*/ string sel_parser_1didEndMappingPrefix_1 = sel_registerName("parser:didEndMappingPrefix:");
+    public static /*const*/ string sel_cleanUpAfterDragOperation = sel_registerName("cleanUpAfterDragOperation");
+    public static /*const*/ string sel_browser_1typeSelectStringForRow_1inColumn_1 = sel_registerName("browser:typeSelectStringForRow:inColumn:");
+    public static /*const*/ string sel_canInitWithPasteboard_1 = sel_registerName("canInitWithPasteboard:");
+    public static /*const*/ string sel_startListening = sel_registerName("startListening");
+    public static /*const*/ string sel_setExcludedKeys_1 = sel_registerName("setExcludedKeys:");
+    public static /*const*/ string sel_readFromFile_1ofType_1 = sel_registerName("readFromFile:ofType:");
+    public static /*const*/ string sel_setReservedThicknessForMarkers_1 = sel_registerName("setReservedThicknessForMarkers:");
+    public static /*const*/ string sel_windowRef = sel_registerName("windowRef");
+    public static /*const*/ string sel_browser_1selectRow_1inColumn_1 = sel_registerName("browser:selectRow:inColumn:");
+    public static /*const*/ string sel_isOpaque = sel_registerName("isOpaque");
+    public static /*const*/ string sel_fontDescriptorWithFamily_1 = sel_registerName("fontDescriptorWithFamily:");
+    public static /*const*/ string sel_itemTitleAtIndex_1 = sel_registerName("itemTitleAtIndex:");
+    public static /*const*/ string sel_boundingBox = sel_registerName("boundingBox");
+    public static /*const*/ string sel_moveColumn_1toColumn_1 = sel_registerName("moveColumn:toColumn:");
+    public static /*const*/ string sel_badgeLabel = sel_registerName("badgeLabel");
+    public static /*const*/ string sel_outline_1 = sel_registerName("outline:");
+    public static /*const*/ string sel_characterIndexForInsertionAtPoint_1 = sel_registerName("characterIndexForInsertionAtPoint:");
+    public static /*const*/ string sel_URLHandleClassForURL_1 = sel_registerName("URLHandleClassForURL:");
+    public static /*const*/ string sel_selectKeyViewFollowingView_1 = sel_registerName("selectKeyViewFollowingView:");
+    public static /*const*/ string sel_fullPathForApplication_1 = sel_registerName("fullPathForApplication:");
+    public static /*const*/ string sel_outlineView_1willDisplayOutlineCell_1forTableColumn_1item_1 = sel_registerName("outlineView:willDisplayOutlineCell:forTableColumn:item:");
+    public static /*const*/ string sel_encodePropertyList_1 = sel_registerName("encodePropertyList:");
+    public static /*const*/ string sel_generatesDecimalNumbers = sel_registerName("generatesDecimalNumbers");
+    public static /*const*/ string sel_appendAttributedString_1 = sel_registerName("appendAttributedString:");
+    public static /*const*/ string sel_persistentDomainNames = sel_registerName("persistentDomainNames");
+    public static /*const*/ string sel_setUserFont_1 = sel_registerName("setUserFont:");
+    public static /*const*/ string sel_initWithProperties_1 = sel_registerName("initWithProperties:");
+    public static /*const*/ string sel_loadResourceDataNotifyingClient_1usingCache_1 = sel_registerName("loadResourceDataNotifyingClient:usingCache:");
+    public static /*const*/ string sel_closeFile = sel_registerName("closeFile");
+    public static /*const*/ string sel_allHeaderFields = sel_registerName("allHeaderFields");
+    public static /*const*/ string sel_unlearnWord_1 = sel_registerName("unlearnWord:");
+    public static /*const*/ string sel_drawsCellBackground = sel_registerName("drawsCellBackground");
+    public static /*const*/ string sel_PICTRepresentation = sel_registerName("PICTRepresentation");
+    public static /*const*/ string sel_imageScaling = sel_registerName("imageScaling");
+    public static /*const*/ string sel_scanUpToString_1intoString_1 = sel_registerName("scanUpToString:intoString:");
+    public static /*const*/ string sel_scrollBarColor = sel_registerName("scrollBarColor");
+    public static /*const*/ string sel_initWithDelegate_1name_1 = sel_registerName("initWithDelegate:name:");
+    public static /*const*/ string sel_setDateValue_1 = sel_registerName("setDateValue:");
+    public static /*const*/ string sel_dividerStyle = sel_registerName("dividerStyle");
+    public static /*const*/ string sel_scrollPageDown_1 = sel_registerName("scrollPageDown:");
+    public static /*const*/ string sel_removeLayoutManager_1 = sel_registerName("removeLayoutManager:");
+    public static /*const*/ string sel_textAttributesForNegativeValues = sel_registerName("textAttributesForNegativeValues");
+    public static /*const*/ string sel_attachment = sel_registerName("attachment");
+    public static /*const*/ string sel_reset = sel_registerName("reset");
+    public static /*const*/ string sel_initWithAttributes_1 = sel_registerName("initWithAttributes:");
+    public static /*const*/ string sel_allowsMixedState = sel_registerName("allowsMixedState");
+    public static /*const*/ string sel_addPort_1forMode_1 = sel_registerName("addPort:forMode:");
+    public static /*const*/ string sel_windowDidDeminiaturize_1 = sel_registerName("windowDidDeminiaturize:");
+    public static /*const*/ string sel_setRowHeight_1 = sel_registerName("setRowHeight:");
+    public static /*const*/ string sel_setGraphicsState_1 = sel_registerName("setGraphicsState:");
+    public static /*const*/ string sel_replaceCharactersInRange_1withAttributedString_1 = sel_registerName("replaceCharactersInRange:withAttributedString:");
+    public static /*const*/ string sel_setAttributedStringValue_1 = sel_registerName("setAttributedStringValue:");
+    public static /*const*/ string sel_criteriaKeyPath = sel_registerName("criteriaKeyPath");
+    public static /*const*/ string sel_standardInput = sel_registerName("standardInput");
+    public static /*const*/ string sel_isFontAvailable_1 = sel_registerName("isFontAvailable:");
+    public static /*const*/ string sel_setAllowsTypeSelect_1 = sel_registerName("setAllowsTypeSelect:");
+    public static /*const*/ string sel_portWithMachPort_1 = sel_registerName("portWithMachPort:");
+    public static /*const*/ string sel_panel_1isValidFilename_1 = sel_registerName("panel:isValidFilename:");
+    public static /*const*/ string sel_imageablePageBounds = sel_registerName("imageablePageBounds");
+    public static /*const*/ string sel_notificationWithName_1object_1 = sel_registerName("notificationWithName:object:");
+    public static /*const*/ string sel_sharedFontPanelExists = sel_registerName("sharedFontPanelExists");
+    public static /*const*/ string sel_blackColor = sel_registerName("blackColor");
+    public static /*const*/ string sel_removeDescriptorAtIndex_1 = sel_registerName("removeDescriptorAtIndex:");
+    public static /*const*/ string sel_dataUsingEncoding_1allowLossyConversion_1 = sel_registerName("dataUsingEncoding:allowLossyConversion:");
+    public static /*const*/ string sel_propertyForKey_1inRequest_1 = sel_registerName("propertyForKey:inRequest:");
+    public static /*const*/ string sel_setHeaderLevel_1 = sel_registerName("setHeaderLevel:");
+    public static /*const*/ string sel_jobTitle = sel_registerName("jobTitle");
+    public static /*const*/ string sel_removePersistentDomainForName_1 = sel_registerName("removePersistentDomainForName:");
+    public static /*const*/ string sel_contentResizeIncrements = sel_registerName("contentResizeIncrements");
+    public static /*const*/ string sel_textFileTypes = sel_registerName("textFileTypes");
+    public static /*const*/ string sel_setAction_1 = sel_registerName("setAction:");
+    public static /*const*/ string sel_knobProportion = sel_registerName("knobProportion");
+    public static /*const*/ string sel_numberOfArguments = sel_registerName("numberOfArguments");
+    public static /*const*/ string sel_setScrollsDynamically_1 = sel_registerName("setScrollsDynamically:");
+    public static /*const*/ string sel_setTextColor_1range_1 = sel_registerName("setTextColor:range:");
+    public static /*const*/ string sel_setBoundsSize_1 = sel_registerName("setBoundsSize:");
+    public static /*const*/ string sel_setVolume_1 = sel_registerName("setVolume:");
+    public static /*const*/ string sel_windowControllers = sel_registerName("windowControllers");
+    public static /*const*/ string sel_insertAttributedString_1atIndex_1 = sel_registerName("insertAttributedString:atIndex:");
+    public static /*const*/ string sel_eventWithEventRef_1 = sel_registerName("eventWithEventRef:");
+    public static /*const*/ string sel_initByReferencingFile_1 = sel_registerName("initByReferencingFile:");
+    public static /*const*/ string sel_fire = sel_registerName("fire");
+    public static /*const*/ string sel_writeToPasteboard_1 = sel_registerName("writeToPasteboard:");
+    public static /*const*/ string sel_connectionForProxy = sel_registerName("connectionForProxy");
+    public static /*const*/ string sel_outlineView_1mouseDownInHeaderOfTableColumn_1 = sel_registerName("outlineView:mouseDownInHeaderOfTableColumn:");
+    public static /*const*/ string sel_mutableArrayValueForKeyPath_1 = sel_registerName("mutableArrayValueForKeyPath:");
+    public static /*const*/ string sel_validRequestorForSendType_1returnType_1 = sel_registerName("validRequestorForSendType:returnType:");
+    public static /*const*/ string sel_isRichText = sel_registerName("isRichText");
+    public static /*const*/ string sel_moveWordLeft_1 = sel_registerName("moveWordLeft:");
+    public static /*const*/ string sel_indexSetWithIndex_1 = sel_registerName("indexSetWithIndex:");
+    public static /*const*/ string sel_setContextMenuRepresentation_1 = sel_registerName("setContextMenuRepresentation:");
+    public static /*const*/ string sel_updateTrackingAreas = sel_registerName("updateTrackingAreas");
+    public static /*const*/ string sel_defaultCollector = sel_registerName("defaultCollector");
+    public static /*const*/ string sel_orderedIndex = sel_registerName("orderedIndex");
+    public static /*const*/ string sel_relativeCurveToPoint_1controlPoint1_1controlPoint2_1 = sel_registerName("relativeCurveToPoint:controlPoint1:controlPoint2:");
+    public static /*const*/ string sel_setShowsApplicationBadge_1 = sel_registerName("setShowsApplicationBadge:");
+    public static /*const*/ string sel_setValue_1 = sel_registerName("setValue:");
+    public static /*const*/ string sel_attributeDeclarationForName_1elementName_1 = sel_registerName("attributeDeclarationForName:elementName:");
+    public static /*const*/ string sel_setWidth_1type_1forLayer_1 = sel_registerName("setWidth:type:forLayer:");
+    public static /*const*/ string sel_decodePoint = sel_registerName("decodePoint");
+    public static /*const*/ string sel_makeWindowControllers = sel_registerName("makeWindowControllers");
+    public static /*const*/ string sel_userFontOfSize_1 = sel_registerName("userFontOfSize:");
+    public static /*const*/ string sel_dependencies = sel_registerName("dependencies");
+    public static /*const*/ string sel_setAttributes_1 = sel_registerName("setAttributes:");
+    public static /*const*/ string sel_setFrameCenterRotation_1 = sel_registerName("setFrameCenterRotation:");
+    public static /*const*/ string sel_nilSymbol = sel_registerName("nilSymbol");
+    public static /*const*/ string sel_scalesWhenResized = sel_registerName("scalesWhenResized");
+    public static /*const*/ string sel_setMinusSign_1 = sel_registerName("setMinusSign:");
+    public static /*const*/ string sel_predicateOperatorType = sel_registerName("predicateOperatorType");
+    public static /*const*/ string sel_replyWithException_1 = sel_registerName("replyWithException:");
+    public static /*const*/ string sel_fileName = sel_registerName("fileName");
+    public static /*const*/ string sel_indexPathByRemovingLastIndex = sel_registerName("indexPathByRemovingLastIndex");
+    public static /*const*/ string sel_openHelpAnchor_1inBook_1 = sel_registerName("openHelpAnchor:inBook:");
+    public static /*const*/ string sel_initWithBytes_1objCType_1 = sel_registerName("initWithBytes:objCType:");
+    public static /*const*/ string sel_removeObject_1 = sel_registerName("removeObject:");
+    public static /*const*/ string sel_colorNameComponent = sel_registerName("colorNameComponent");
+    public static /*const*/ string sel_setCellBackgroundColor_1 = sel_registerName("setCellBackgroundColor:");
+    public static /*const*/ string sel_getLineDash_1count_1phase_1 = sel_registerName("getLineDash:count:phase:");
+    public static /*const*/ string sel_scriptingContains_1 = sel_registerName("scriptingContains:");
+    public static /*const*/ string sel_setDefaultWindingRule_1 = sel_registerName("setDefaultWindingRule:");
+    public static /*const*/ string sel_outputStreamToBuffer_1capacity_1 = sel_registerName("outputStreamToBuffer:capacity:");
+    public static /*const*/ string sel_defaultButtonTitle = sel_registerName("defaultButtonTitle");
+    public static /*const*/ string sel_draggingSourceOperationMask = sel_registerName("draggingSourceOperationMask");
+    public static /*const*/ string sel_textDidChange_1 = sel_registerName("textDidChange:");
+    public static /*const*/ string sel_drawSheetBorderWithSize_1 = sel_registerName("drawSheetBorderWithSize:");
+    public static /*const*/ string sel_integerForKey_1 = sel_registerName("integerForKey:");
+    public static /*const*/ string sel_setDefaultNameServerPortNumber_1 = sel_registerName("setDefaultNameServerPortNumber:");
+    public static /*const*/ string sel_previousNode = sel_registerName("previousNode");
+    public static /*const*/ string sel_trackingArea = sel_registerName("trackingArea");
+    public static /*const*/ string sel_highlightWithLevel_1 = sel_registerName("highlightWithLevel:");
+    public static /*const*/ string sel_trackMouse_1inRect_1ofView_1atCharacterIndex_1untilMouseUp_1 = sel_registerName("trackMouse:inRect:ofView:atCharacterIndex:untilMouseUp:");
+    public static /*const*/ string sel_signatureWithObjCTypes_1 = sel_registerName("signatureWithObjCTypes:");
+    public static /*const*/ string sel_saveToURL_1ofType_1forSaveOperation_1error_1 = sel_registerName("saveToURL:ofType:forSaveOperation:error:");
+    public static /*const*/ string sel_dataWithBytesNoCopy_1length_1freeWhenDone_1 = sel_registerName("dataWithBytesNoCopy:length:freeWhenDone:");
+    public static /*const*/ string sel_encodeInteger_1forKey_1 = sel_registerName("encodeInteger:forKey:");
+    public static /*const*/ string sel_removeFromSuperview = sel_registerName("removeFromSuperview");
+    public static /*const*/ string sel_dataWithBytesNoCopy_1length_1 = sel_registerName("dataWithBytesNoCopy:length:");
+    public static /*const*/ string sel_initWithIndexesInRange_1 = sel_registerName("initWithIndexesInRange:");
+    public static /*const*/ string sel_initWithKeyPointerFunctions_1valuePointerFunctions_1capacity_1 = sel_registerName("initWithKeyPointerFunctions:valuePointerFunctions:capacity:");
+    public static /*const*/ string sel_tilt = sel_registerName("tilt");
+    public static /*const*/ string sel_setHidden_1 = sel_registerName("setHidden:");
+    public static /*const*/ string sel_setMenuFormRepresentation_1 = sel_registerName("setMenuFormRepresentation:");
+    public static /*const*/ string sel_setCanChooseDirectories_1 = sel_registerName("setCanChooseDirectories:");
+    public static /*const*/ string sel_usedRectForTextContainer_1 = sel_registerName("usedRectForTextContainer:");
+    public static /*const*/ string sel_allowsColumnSelection = sel_registerName("allowsColumnSelection");
+    public static /*const*/ string sel_orderOut_1 = sel_registerName("orderOut:");
+    public static /*const*/ string sel_filterUsingPredicate_1 = sel_registerName("filterUsingPredicate:");
+    public static /*const*/ string sel_setTest_1 = sel_registerName("setTest:");
+    public static /*const*/ string sel_setAllowedTypes_1 = sel_registerName("setAllowedTypes:");
+    public static /*const*/ string sel_registerForDraggedTypes_1 = sel_registerName("registerForDraggedTypes:");
+    public static /*const*/ string sel_objectEnumerator = sel_registerName("objectEnumerator");
+    public static /*const*/ string sel_setWindowController_1 = sel_registerName("setWindowController:");
+    public static /*const*/ string sel_setDestination_1 = sel_registerName("setDestination:");
+    public static /*const*/ string sel_addRepresentation_1 = sel_registerName("addRepresentation:");
+    public static /*const*/ string sel_isEqual_1 = sel_registerName("isEqual:");
+    public static /*const*/ string sel_glyphRangeForTextContainer_1 = sel_registerName("glyphRangeForTextContainer:");
+    public static /*const*/ string sel_setStandaloneWeekdaySymbols_1 = sel_registerName("setStandaloneWeekdaySymbols:");
+    public static /*const*/ string sel_setIgnoresAlpha_1 = sel_registerName("setIgnoresAlpha:");
+    public static /*const*/ string sel_drawBarInside_1flipped_1 = sel_registerName("drawBarInside:flipped:");
+    public static /*const*/ string sel_doesNotRecognizeSelector_1 = sel_registerName("doesNotRecognizeSelector:");
+    public static /*const*/ string sel_windowDidResignMain_1 = sel_registerName("windowDidResignMain:");
+    public static /*const*/ string sel_scrollItemAtIndexToTop_1 = sel_registerName("scrollItemAtIndexToTop:");
+    public static /*const*/ string sel_makePreviousSegmentKey = sel_registerName("makePreviousSegmentKey");
+    public static /*const*/ string sel_download_1shouldDecodeSourceDataOfMIMEType_1 = sel_registerName("download:shouldDecodeSourceDataOfMIMEType:");
+    public static /*const*/ string sel_compareObject_1toObject_1 = sel_registerName("compareObject:toObject:");
+    public static /*const*/ string sel_widthTracksTextView = sel_registerName("widthTracksTextView");
+    public static /*const*/ string sel_subpredicates = sel_registerName("subpredicates");
+    public static /*const*/ string sel_relativeLineToPoint_1 = sel_registerName("relativeLineToPoint:");
+    public static /*const*/ string sel_gridStyleMask = sel_registerName("gridStyleMask");
+    public static /*const*/ string sel_initWithCString_1 = sel_registerName("initWithCString:");
+    public static /*const*/ string sel_imageScalingForSegment_1 = sel_registerName("imageScalingForSegment:");
+    public static /*const*/ string sel_editWithFrame_1inView_1editor_1delegate_1event_1 = sel_registerName("editWithFrame:inView:editor:delegate:event:");
+    public static /*const*/ string sel_glyphPacking = sel_registerName("glyphPacking");
+    public static /*const*/ string sel_resolveWithTimeout_1 = sel_registerName("resolveWithTimeout:");
+    public static /*const*/ string sel_hasEditedDocuments = sel_registerName("hasEditedDocuments");
+    public static /*const*/ string sel_getLineFragmentRect_1usedRect_1forParagraphSeparatorGlyphRange_1atProposedOrigin_1 = sel_registerName("getLineFragmentRect:usedRect:forParagraphSeparatorGlyphRange:atProposedOrigin:");
+    public static /*const*/ string sel_autosaveDocumentWithDelegate_1didAutosaveSelector_1contextInfo_1 = sel_registerName("autosaveDocumentWithDelegate:didAutosaveSelector:contextInfo:");
+    public static /*const*/ string sel_readSelectionFromPasteboard_1type_1 = sel_registerName("readSelectionFromPasteboard:type:");
+    public static /*const*/ string sel_spellServer_1suggestGuessesForWord_1inLanguage_1 = sel_registerName("spellServer:suggestGuessesForWord:inLanguage:");
+    public static /*const*/ string sel_initWithTimeIntervalSinceNow_1 = sel_registerName("initWithTimeIntervalSinceNow:");
+    public static /*const*/ string sel_setMaxWidth_1 = sel_registerName("setMaxWidth:");
+    public static /*const*/ string sel_userDefaultsChanged = sel_registerName("userDefaultsChanged");
+    public static /*const*/ string sel_setWidth_1 = sel_registerName("setWidth:");
+    public static /*const*/ string sel_setPrintPanel_1 = sel_registerName("setPrintPanel:");
+    public static /*const*/ string sel_setCurrentPage_1 = sel_registerName("setCurrentPage:");
+    public static /*const*/ string sel_resizeIncrements = sel_registerName("resizeIncrements");
+    public static /*const*/ string sel_selectWithFrame_1inView_1editor_1delegate_1start_1length_1 = sel_registerName("selectWithFrame:inView:editor:delegate:start:length:");
+    public static /*const*/ string sel_sRGBColorSpace = sel_registerName("sRGBColorSpace");
+    public static /*const*/ string sel_scriptErrorExpectedTypeDescriptor = sel_registerName("scriptErrorExpectedTypeDescriptor");
+    public static /*const*/ string sel_setHasHorizontalRuler_1 = sel_registerName("setHasHorizontalRuler:");
+    public static /*const*/ string sel_initialFirstResponder = sel_registerName("initialFirstResponder");
+    public static /*const*/ string sel_StringForObjectValue_1 = sel_registerName("StringForObjectValue:");
+    public static /*const*/ string sel_pageRange = sel_registerName("pageRange");
+    public static /*const*/ string sel_printOperationWithView_1 = sel_registerName("printOperationWithView:");
+    public static /*const*/ string sel_initWithFrame_1pixelFormat_1 = sel_registerName("initWithFrame:pixelFormat:");
+    public static /*const*/ string sel_fileWrapperOfType_1error_1 = sel_registerName("fileWrapperOfType:error:");
+    public static /*const*/ string sel_doesContain_1 = sel_registerName("doesContain:");
+    public static /*const*/ string sel_mutableSetValueForKeyPath_1 = sel_registerName("mutableSetValueForKeyPath:");
+    public static /*const*/ string sel_initWithURL_1cached_1 = sel_registerName("initWithURL:cached:");
+    public static /*const*/ string sel_controlAlternatingRowBackgroundColors = sel_registerName("controlAlternatingRowBackgroundColors");
+    public static /*const*/ string sel_pathComponentCellClass = sel_registerName("pathComponentCellClass");
+    public static /*const*/ string sel_arrayWithCapacity_1 = sel_registerName("arrayWithCapacity:");
+    public static /*const*/ string sel_types = sel_registerName("types");
+    public static /*const*/ string sel_setPrintInfo_1 = sel_registerName("setPrintInfo:");
+    public static /*const*/ string sel_indexOfTabViewItemWithIdentifier_1 = sel_registerName("indexOfTabViewItemWithIdentifier:");
+    public static /*const*/ string sel_isEnabled = sel_registerName("isEnabled");
+    public static /*const*/ string sel_setHeaderView_1 = sel_registerName("setHeaderView:");
+    public static /*const*/ string sel_accessibilityHitTest_1 = sel_registerName("accessibilityHitTest:");
+    public static /*const*/ string sel_removeMarker_1 = sel_registerName("removeMarker:");
+    public static /*const*/ string sel_showContextHelp_1 = sel_registerName("showContextHelp:");
+    public static /*const*/ string sel_selectsInsertedObjects = sel_registerName("selectsInsertedObjects");
+    public static /*const*/ string sel_selectedRowInColumn_1 = sel_registerName("selectedRowInColumn:");
+    public static /*const*/ string sel_noteNewRecentDocument_1 = sel_registerName("noteNewRecentDocument:");
+    public static /*const*/ string sel_setAttachment_1 = sel_registerName("setAttachment:");
+    public static /*const*/ string sel_localeIdentifier = sel_registerName("localeIdentifier");
+    public static /*const*/ string sel_scrollLineUp_1 = sel_registerName("scrollLineUp:");
+    public static /*const*/ string sel_setCalendarFormat_1 = sel_registerName("setCalendarFormat:");
+    public static /*const*/ string sel_setAssociatedPoints_1atIndex_1 = sel_registerName("setAssociatedPoints:atIndex:");
+    public static /*const*/ string sel_resourceData = sel_registerName("resourceData");
+    public static /*const*/ string sel_setVeryShortStandaloneMonthSymbols_1 = sel_registerName("setVeryShortStandaloneMonthSymbols:");
+    public static /*const*/ string sel_windowDidUpdate_1 = sel_registerName("windowDidUpdate:");
+    public static /*const*/ string sel_moveLeft_1 = sel_registerName("moveLeft:");
+    public static /*const*/ string sel_showsBorderOnlyWhileMouseInside = sel_registerName("showsBorderOnlyWhileMouseInside");
+    public static /*const*/ string sel_valueForKey_1 = sel_registerName("valueForKey:");
+    public static /*const*/ string sel_setContentResizeIncrements_1 = sel_registerName("setContentResizeIncrements:");
+    public static /*const*/ string sel_drain = sel_registerName("drain");
+    public static /*const*/ string sel_concat = sel_registerName("concat");
+    public static /*const*/ string sel_scrollerWidthForControlSize_1 = sel_registerName("scrollerWidthForControlSize:");
+    public static /*const*/ string sel_insertItemWithTitle_1action_1keyEquivalent_1atIndex_1 = sel_registerName("insertItemWithTitle:action:keyEquivalent:atIndex:");
+    public static /*const*/ string sel_doubleValue = sel_registerName("doubleValue");
+    public static /*const*/ string sel_dividerThickness = sel_registerName("dividerThickness");
+    public static /*const*/ string sel_rowAtPoint_1 = sel_registerName("rowAtPoint:");
+    public static /*const*/ string sel_updateWindowsItem_1 = sel_registerName("updateWindowsItem:");
+    public static /*const*/ string sel_calendarDate = sel_registerName("calendarDate");
+    public static /*const*/ string sel_fixAttachmentAttributeInRange_1 = sel_registerName("fixAttachmentAttributeInRange:");
+    public static /*const*/ string sel_mapTableWithWeakToWeakObjects = sel_registerName("mapTableWithWeakToWeakObjects");
+    public static /*const*/ string sel_setClip = sel_registerName("setClip");
+    public static /*const*/ string sel_evaluationErrorNumber = sel_registerName("evaluationErrorNumber");
+    public static /*const*/ string sel_revertToSavedFromURL_1ofType_1 = sel_registerName("revertToSavedFromURL:ofType:");
+    public static /*const*/ string sel_autorecalculatesContentBorderThicknessForEdge_1 = sel_registerName("autorecalculatesContentBorderThicknessForEdge:");
+    public static /*const*/ string sel_lineToPoint_1 = sel_registerName("lineToPoint:");
+    public static /*const*/ string sel_insertionReplaces = sel_registerName("insertionReplaces");
+    public static /*const*/ string sel_smallestEncoding = sel_registerName("smallestEncoding");
+    public static /*const*/ string sel_elementAtIndex_1 = sel_registerName("elementAtIndex:");
+    public static /*const*/ string sel_getReturnValue_1 = sel_registerName("getReturnValue:");
+    public static /*const*/ string sel_regularFileContents = sel_registerName("regularFileContents");
+    public static /*const*/ string sel_recache = sel_registerName("recache");
+    public static /*const*/ string sel_setTextAttributesForNegativeInfinity_1 = sel_registerName("setTextAttributesForNegativeInfinity:");
+    public static /*const*/ string sel_horizontalRulerView = sel_registerName("horizontalRulerView");
+    public static /*const*/ string sel_initToMemory = sel_registerName("initToMemory");
+    public static /*const*/ string sel_shouldCreateUI = sel_registerName("shouldCreateUI");
+    public static /*const*/ string sel_scheme = sel_registerName("scheme");
+    public static /*const*/ string sel_raiseBaseline_1 = sel_registerName("raiseBaseline:");
+    public static /*const*/ string sel_initWithArray_1 = sel_registerName("initWithArray:");
+    public static /*const*/ string sel_displayNameForKey_1value_1 = sel_registerName("displayNameForKey:value:");
+    public static /*const*/ string sel_centerScanRect_1 = sel_registerName("centerScanRect:");
+    public static /*const*/ string sel_memoryCapacity = sel_registerName("memoryCapacity");
+    public static /*const*/ string sel_setBackgroundLayoutEnabled_1 = sel_registerName("setBackgroundLayoutEnabled:");
+    public static /*const*/ string sel_machPort = sel_registerName("machPort");
+    public static /*const*/ string sel_selectedFont = sel_registerName("selectedFont");
+    public static /*const*/ string sel_tableColumns = sel_registerName("tableColumns");
+    public static /*const*/ string sel_removeObjectAtIndex_1 = sel_registerName("removeObjectAtIndex:");
+    public static /*const*/ string sel_insertNewButtonImage_1in_1 = sel_registerName("insertNewButtonImage:in:");
+    public static /*const*/ string sel_StringWithContentsOfURL_1encoding_1error_1 = sel_registerName("StringWithContentsOfURL:encoding:error:");
+    public static /*const*/ string sel_menuChangedMessagesEnabled = sel_registerName("menuChangedMessagesEnabled");
+    public static /*const*/ string sel_initWithShort_1 = sel_registerName("initWithShort:");
+    public static /*const*/ string sel_setColorRenderingIntent_1 = sel_registerName("setColorRenderingIntent:");
+    public static /*const*/ string sel_descriptionWithCalendarFormat_1locale_1 = sel_registerName("descriptionWithCalendarFormat:locale:");
+    public static /*const*/ string sel_resourceSpecifier = sel_registerName("resourceSpecifier");
+    public static /*const*/ string sel_pasteboardByFilteringFile_1 = sel_registerName("pasteboardByFilteringFile:");
+    public static /*const*/ string sel_dragColor_1withEvent_1fromView_1 = sel_registerName("dragColor:withEvent:fromView:");
+    public static /*const*/ string sel_setStroke = sel_registerName("setStroke");
+    public static /*const*/ string sel_isControllerVisible = sel_registerName("isControllerVisible");
+    public static /*const*/ string sel_putCell_1atRow_1column_1 = sel_registerName("putCell:atRow:column:");
+    public static /*const*/ string sel_firstIndex = sel_registerName("firstIndex");
+    public static /*const*/ string sel_setFontManagerFactory_1 = sel_registerName("setFontManagerFactory:");
+    public static /*const*/ string sel_exponentSymbol = sel_registerName("exponentSymbol");
+    public static /*const*/ string sel_StringValue = sel_registerName("StringValue");
+    public static /*const*/ string sel_getObjects_1range_1 = sel_registerName("getObjects:range:");
+    public static /*const*/ string sel_scriptingProperties = sel_registerName("scriptingProperties");
+    public static /*const*/ string sel_query = sel_registerName("query");
+    public static /*const*/ string sel_eventClass = sel_registerName("eventClass");
+    public static /*const*/ string sel_dateWithNaturalLanguageString_1 = sel_registerName("dateWithNaturalLanguageString:");
+    public static /*const*/ string sel_datePickerMode = sel_registerName("datePickerMode");
+    public static /*const*/ string sel_setAlternateMnemonicLocation_1 = sel_registerName("setAlternateMnemonicLocation:");
+    public static /*const*/ string sel_StringByDeletingLastPathComponent = sel_registerName("StringByDeletingLastPathComponent");
+    public static /*const*/ string sel_encodeObject_1 = sel_registerName("encodeObject:");
+    public static /*const*/ string sel_unarchiveObjectWithData_1 = sel_registerName("unarchiveObjectWithData:");
+    public static /*const*/ string sel_destination = sel_registerName("destination");
+    public static /*const*/ string sel_ensureLayoutForCharacterRange_1 = sel_registerName("ensureLayoutForCharacterRange:");
+    public static /*const*/ string sel_tabView_1didSelectTabViewItem_1 = sel_registerName("tabView:didSelectTabViewItem:");
+    public static /*const*/ string sel_removeContextHelpForObject_1 = sel_registerName("removeContextHelpForObject:");
+    public static /*const*/ string sel_ensureGlyphsForCharacterRange_1 = sel_registerName("ensureGlyphsForCharacterRange:");
+    public static /*const*/ string sel_setMinimumFractionDigits_1 = sel_registerName("setMinimumFractionDigits:");
+    public static /*const*/ string sel_boundsRotation = sel_registerName("boundsRotation");
+    public static /*const*/ string sel_invalidateDisplayForGlyphRange_1 = sel_registerName("invalidateDisplayForGlyphRange:");
+    public static /*const*/ string sel_rectForBlock_1layoutAtPoint_1inRect_1textContainer_1characterRange_1 = sel_registerName("rectForBlock:layoutAtPoint:inRect:textContainer:characterRange:");
+    public static /*const*/ string sel_pasteFont_1 = sel_registerName("pasteFont:");
+    public static /*const*/ string sel_backgroundColor = sel_registerName("backgroundColor");
+    public static /*const*/ string sel_StringFromNumber_1 = sel_registerName("StringFromNumber:");
+    public static /*const*/ string sel_expiresDate = sel_registerName("expiresDate");
+    public static /*const*/ string sel_initWithWindowRef_1 = sel_registerName("initWithWindowRef:");
+    public static /*const*/ string sel_toggleToolbarShown_1 = sel_registerName("toggleToolbarShown:");
+    public static /*const*/ string sel_outlineViewItemDidExpand_1 = sel_registerName("outlineViewItemDidExpand:");
+    public static /*const*/ string sel_TIFFRepresentationOfImageRepsInArray_1usingCompression_1factor_1 = sel_registerName("TIFFRepresentationOfImageRepsInArray:usingCompression:factor:");
+    public static /*const*/ string sel_variable = sel_registerName("variable");
+    public static /*const*/ string sel_objectsForKeys_1notFoundMarker_1 = sel_registerName("objectsForKeys:notFoundMarker:");
+    public static /*const*/ string sel_controlColor = sel_registerName("controlColor");
+    public static /*const*/ string sel_unarchiverWillFinish_1 = sel_registerName("unarchiverWillFinish:");
+    public static /*const*/ string sel_proposedCredential = sel_registerName("proposedCredential");
+    public static /*const*/ string sel_isPaneSplitter = sel_registerName("isPaneSplitter");
+    public static /*const*/ string sel_endUndoGrouping = sel_registerName("endUndoGrouping");
+    public static /*const*/ string sel_setFrameRate_1 = sel_registerName("setFrameRate:");
+    public static /*const*/ string sel_completionDelay = sel_registerName("completionDelay");
+    public static /*const*/ string sel_setUserFixedPitchFont_1 = sel_registerName("setUserFixedPitchFont:");
+    public static /*const*/ string sel_isIndeterminate = sel_registerName("isIndeterminate");
+    public static /*const*/ string sel_menuItem = sel_registerName("menuItem");
+    public static /*const*/ string sel_setNumberStyle_1 = sel_registerName("setNumberStyle:");
+    public static /*const*/ string sel_takeIntegerValueFrom_1 = sel_registerName("takeIntegerValueFrom:");
+    public static /*const*/ string sel_setIndentationMarkerFollowsCell_1 = sel_registerName("setIndentationMarkerFollowsCell:");
+    public static /*const*/ string sel_tile = sel_registerName("tile");
+    public static /*const*/ string sel_cancelButtonRectForBounds_1 = sel_registerName("cancelButtonRectForBounds:");
+    public static /*const*/ string sel_deselectRow_1 = sel_registerName("deselectRow:");
+    public static /*const*/ string sel_setMouseCoalescingEnabled_1 = sel_registerName("setMouseCoalescingEnabled:");
+    public static /*const*/ string sel_removeWindowController_1 = sel_registerName("removeWindowController:");
+    public static /*const*/ string sel_warningValue = sel_registerName("warningValue");
+    public static /*const*/ string sel_isVerticallyResizable = sel_registerName("isVerticallyResizable");
+    public static /*const*/ string sel_defaultFetchRequest = sel_registerName("defaultFetchRequest");
+    public static /*const*/ string sel_netServiceWillResolve_1 = sel_registerName("netServiceWillResolve:");
+    public static /*const*/ string sel_addProgressMark_1 = sel_registerName("addProgressMark:");
+    public static /*const*/ string sel_recentsAutosaveName = sel_registerName("recentsAutosaveName");
+    public static /*const*/ string sel_commitEditing = sel_registerName("commitEditing");
+    public static /*const*/ string sel_attributesOfItemAtPath_1error_1 = sel_registerName("attributesOfItemAtPath:error:");
+    public static /*const*/ string sel_download_1willSendRequest_1redirectResponse_1 = sel_registerName("download:willSendRequest:redirectResponse:");
+    public static /*const*/ string sel_canBeCompressedUsing_1 = sel_registerName("canBeCompressedUsing:");
+    public static /*const*/ string sel_strokeRect_1 = sel_registerName("strokeRect:");
+    public static /*const*/ string sel_descriptionWithLocale_1indent_1 = sel_registerName("descriptionWithLocale:indent:");
+    public static /*const*/ string sel_applicationDockMenu_1 = sel_registerName("applicationDockMenu:");
+    public static /*const*/ string sel_initWithCString_1length_1 = sel_registerName("initWithCString:length:");
+    public static /*const*/ string sel_runPageLayout_1 = sel_registerName("runPageLayout:");
+    public static /*const*/ string sel_toolbar_1itemForItemIdentifier_1willBeInsertedIntoToolbar_1 = sel_registerName("toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:");
+    public static /*const*/ string sel_setSelectsInsertedObjects_1 = sel_registerName("setSelectsInsertedObjects:");
+    public static /*const*/ string sel_alternateSelectedControlTextColor = sel_registerName("alternateSelectedControlTextColor");
+    public static /*const*/ string sel_isValidGlyphIndex_1 = sel_registerName("isValidGlyphIndex:");
+    public static /*const*/ string sel_StringForKey_1inTable_1 = sel_registerName("StringForKey:inTable:");
+    public static /*const*/ string sel_cellSizeForBounds_1 = sel_registerName("cellSizeForBounds:");
+    public static /*const*/ string sel_beginSheetForDirectory_1file_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1 = sel_registerName("beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:");
+    public static /*const*/ string sel_invalidateLayoutForCharacterRange_1actualCharacterRange_1 = sel_registerName("invalidateLayoutForCharacterRange:actualCharacterRange:");
+    public static /*const*/ string sel_initAsTearOff = sel_registerName("initAsTearOff");
+    public static /*const*/ string sel_allowsOtherFileTypes = sel_registerName("allowsOtherFileTypes");
+    public static /*const*/ string sel_mouseMoved_1 = sel_registerName("mouseMoved:");
+    public static /*const*/ string sel_deleteCharactersInRange_1 = sel_registerName("deleteCharactersInRange:");
+    public static /*const*/ string sel_setTitleFont_1 = sel_registerName("setTitleFont:");
+    public static /*const*/ string sel_showsApplicationBadge = sel_registerName("showsApplicationBadge");
+    public static /*const*/ string sel_initWithLeftExpression_1rightExpression_1modifier_1type_1options_1 = sel_registerName("initWithLeftExpression:rightExpression:modifier:type:options:");
+    public static /*const*/ string sel_distantPast = sel_registerName("distantPast");
+    public static /*const*/ string sel_isReady = sel_registerName("isReady");
+    public static /*const*/ string sel_draggedImage_1movedTo_1 = sel_registerName("draggedImage:movedTo:");
+    public static /*const*/ string sel_resetTotalAutoreleasedObjects = sel_registerName("resetTotalAutoreleasedObjects");
+    public static /*const*/ string sel_setGlyphGenerator_1 = sel_registerName("setGlyphGenerator:");
+    public static /*const*/ string sel_groupsByEvent = sel_registerName("groupsByEvent");
+    public static /*const*/ string sel_shortMonthSymbols = sel_registerName("shortMonthSymbols");
+    public static /*const*/ string sel_setDescriptor_1forKeyword_1 = sel_registerName("setDescriptor:forKeyword:");
+    public static /*const*/ string sel_description = sel_registerName("description");
+    public static /*const*/ string sel_replaceOccurrencesOfString_1withString_1options_1range_1 = sel_registerName("replaceOccurrencesOfString:withString:options:range:");
+    public static /*const*/ string sel_boundsRectForContentRect_1inRect_1textContainer_1characterRange_1 = sel_registerName("boundsRectForContentRect:inRect:textContainer:characterRange:");
+    public static /*const*/ string sel_authenticationDataForComponents_1 = sel_registerName("authenticationDataForComponents:");
+    public static /*const*/ string sel_isExecuting = sel_registerName("isExecuting");
+    public static /*const*/ string sel_branchImage = sel_registerName("branchImage");
+    public static /*const*/ string sel_decodeRectForKey_1 = sel_registerName("decodeRectForKey:");
+    public static /*const*/ string sel_rectValue = sel_registerName("rectValue");
+    public static /*const*/ string sel_setFrameTopLeftPoint_1 = sel_registerName("setFrameTopLeftPoint:");
+    public static /*const*/ string sel_initWithFileDescriptor_1 = sel_registerName("initWithFileDescriptor:");
+    public static /*const*/ string sel_removePointerAtIndex_1 = sel_registerName("removePointerAtIndex:");
+    public static /*const*/ string sel_executeAndReturnError_1 = sel_registerName("executeAndReturnError:");
+    public static /*const*/ string sel_changeCaseOfLetter_1 = sel_registerName("changeCaseOfLetter:");
+    public static /*const*/ string sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1clockwise_1 = sel_registerName("appendBezierPathWithArcWithCenter:radius:startAngle:endAngle:clockwise:");
+    public static /*const*/ string sel_insertNewlineIgnoringFieldEditor_1 = sel_registerName("insertNewlineIgnoringFieldEditor:");
+    public static /*const*/ string sel_attributeDescriptorForKeyword_1 = sel_registerName("attributeDescriptorForKeyword:");
+    public static /*const*/ string sel_decimalNumberWithMantissa_1exponent_1isNegative_1 = sel_registerName("decimalNumberWithMantissa:exponent:isNegative:");
+    public static /*const*/ string sel_activeConversationWillChange_1fromOldConversation_1 = sel_registerName("activeConversationWillChange:fromOldConversation:");
+    public static /*const*/ string sel_layoutAlgorithm = sel_registerName("layoutAlgorithm");
+    public static /*const*/ string sel_itemNumberInTextList_1atIndex_1 = sel_registerName("itemNumberInTextList:atIndex:");
+    public static /*const*/ string sel_initWithImage_1hotSpot_1 = sel_registerName("initWithImage:hotSpot:");
+    public static /*const*/ string sel_setStackSize_1 = sel_registerName("setStackSize:");
+    public static /*const*/ string sel_matrixInColumn_1 = sel_registerName("matrixInColumn:");
+    public static /*const*/ string sel_performSelector_1withObject_1 = sel_registerName("performSelector:withObject:");
+    public static /*const*/ string sel_setSound_1 = sel_registerName("setSound:");
+    public static /*const*/ string sel_accessibilityPerformAction_1 = sel_registerName("accessibilityPerformAction:");
+    public static /*const*/ string sel_comment = sel_registerName("comment");
+    public static /*const*/ string sel_rangeOfNominallySpacedGlyphsContainingIndex_1 = sel_registerName("rangeOfNominallySpacedGlyphsContainingIndex:");
+    public static /*const*/ string sel_showAttachmentCell_1inRect_1characterIndex_1 = sel_registerName("showAttachmentCell:inRect:characterIndex:");
+    public static /*const*/ string sel_isDisplayedWhenStopped = sel_registerName("isDisplayedWhenStopped");
+    public static /*const*/ string sel_addCollection_1options_1 = sel_registerName("addCollection:options:");
+    public static /*const*/ string sel_drawInRect_1angle_1 = sel_registerName("drawInRect:angle:");
+    public static /*const*/ string sel_initWithFrame_1mode_1prototype_1numberOfRows_1numberOfColumns_1 = sel_registerName("initWithFrame:mode:prototype:numberOfRows:numberOfColumns:");
+    public static /*const*/ string sel_sharedCredentialStorage = sel_registerName("sharedCredentialStorage");
+    public static /*const*/ string sel_colorWithDeviceWhite_1alpha_1 = sel_registerName("colorWithDeviceWhite:alpha:");
+    public static /*const*/ string sel_setMainDocumentURL_1 = sel_registerName("setMainDocumentURL:");
+    public static /*const*/ string sel_interpretKeyEvents_1 = sel_registerName("interpretKeyEvents:");
+    public static /*const*/ string sel_readFromData_1ofType_1error_1 = sel_registerName("readFromData:ofType:error:");
+    public static /*const*/ string sel_tokenFieldCell_1menuForRepresentedObject_1 = sel_registerName("tokenFieldCell:menuForRepresentedObject:");
+    public static /*const*/ string sel_setEventHandler_1andSelector_1forEventClass_1andEventID_1 = sel_registerName("setEventHandler:andSelector:forEventClass:andEventID:");
+    public static /*const*/ string sel_addAttribute_1value_1range_1 = sel_registerName("addAttribute:value:range:");
+    public static /*const*/ string sel_outlineView_1writeItems_1toPasteboard_1 = sel_registerName("outlineView:writeItems:toPasteboard:");
+    public static /*const*/ string sel_initWithCString_1encoding_1 = sel_registerName("initWithCString:encoding:");
+    public static /*const*/ string sel_setTypesetterBehavior_1 = sel_registerName("setTypesetterBehavior:");
+    public static /*const*/ string sel_removeObjectAtArrangedObjectIndex_1 = sel_registerName("removeObjectAtArrangedObjectIndex:");
+    public static /*const*/ string sel_redo = sel_registerName("redo");
+    public static /*const*/ string sel_addMarker_1 = sel_registerName("addMarker:");
+    public static /*const*/ string sel_backgroundColors = sel_registerName("backgroundColors");
+    public static /*const*/ string sel_leafKeyPath = sel_registerName("leafKeyPath");
+    public static /*const*/ string sel_setMinimumIntegerDigits_1 = sel_registerName("setMinimumIntegerDigits:");
+    public static /*const*/ string sel_waitForDataInBackgroundAndNotify = sel_registerName("waitForDataInBackgroundAndNotify");
+    public static /*const*/ string sel_setPreservesContentDuringLiveResize_1 = sel_registerName("setPreservesContentDuringLiveResize:");
+    public static /*const*/ string sel_setRootElement_1 = sel_registerName("setRootElement:");
+    public static /*const*/ string sel_dataWithEPSInsideRect_1 = sel_registerName("dataWithEPSInsideRect:");
+    public static /*const*/ string sel_valuesForKeys_1 = sel_registerName("valuesForKeys:");
+    public static /*const*/ string sel_imageOrigin = sel_registerName("imageOrigin");
+    public static /*const*/ string sel_writePDFInsideRect_1toPasteboard_1 = sel_registerName("writePDFInsideRect:toPasteboard:");
+    public static /*const*/ string sel_sortIndicatorRectForBounds_1 = sel_registerName("sortIndicatorRectForBounds:");
+    public static /*const*/ string sel_predefinedNamespaceForPrefix_1 = sel_registerName("predefinedNamespaceForPrefix:");
+    public static /*const*/ string sel_viewWillStartLiveResize = sel_registerName("viewWillStartLiveResize");
+    public static /*const*/ string sel_becomeKeyWindow = sel_registerName("becomeKeyWindow");
+    public static /*const*/ string sel_isHighlighted = sel_registerName("isHighlighted");
+    public static /*const*/ string sel_initWithPickerMask_1colorPanel_1 = sel_registerName("initWithPickerMask:colorPanel:");
+    public static /*const*/ string sel_systemFontOfSize_1 = sel_registerName("systemFontOfSize:");
+    public static /*const*/ string sel_decimalNumberBySubtracting_1withBehavior_1 = sel_registerName("decimalNumberBySubtracting:withBehavior:");
+    public static /*const*/ string sel_hide_1 = sel_registerName("hide:");
+    public static /*const*/ string sel_resetSearchButtonCell = sel_registerName("resetSearchButtonCell");
+    public static /*const*/ string sel_runModalForDirectory_1file_1types_1 = sel_registerName("runModalForDirectory:file:types:");
+    public static /*const*/ string sel_pathForImageResource_1 = sel_registerName("pathForImageResource:");
+    public static /*const*/ string sel_setFilterPredicate_1 = sel_registerName("setFilterPredicate:");
+    public static /*const*/ string sel_validateEditing = sel_registerName("validateEditing");
+    public static /*const*/ string sel_makeDocumentForURL_1withContentsOfURL_1ofType_1error_1 = sel_registerName("makeDocumentForURL:withContentsOfURL:ofType:error:");
+    public static /*const*/ string sel_localizedCompare_1 = sel_registerName("localizedCompare:");
+    public static /*const*/ string sel_sharedWorkspace = sel_registerName("sharedWorkspace");
+    public static /*const*/ string sel_deliverResult = sel_registerName("deliverResult");
+    public static /*const*/ string sel_aspectRatio = sel_registerName("aspectRatio");
+    public static /*const*/ string sel_keyEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1characters_1charactersIgnoringModifiers_1isARepeat_1keyCode_1 = sel_registerName("keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:");
+    public static /*const*/ string sel_soundUnfilteredPasteboardTypes = sel_registerName("soundUnfilteredPasteboardTypes");
+    public static /*const*/ string sel_dateByAddingComponents_1toDate_1options_1 = sel_registerName("dateByAddingComponents:toDate:options:");
+    public static /*const*/ string sel_indentationMarkerFollowsCell = sel_registerName("indentationMarkerFollowsCell");
+    public static /*const*/ string sel_typesetter = sel_registerName("typesetter");
+    public static /*const*/ string sel_childCount = sel_registerName("childCount");
+    public static /*const*/ string sel_borderRect = sel_registerName("borderRect");
+    public static /*const*/ string sel_setPageOrder_1 = sel_registerName("setPageOrder:");
+    public static /*const*/ string sel_currentThread = sel_registerName("currentThread");
+    public static /*const*/ string sel_textViewDidChangeSelection_1 = sel_registerName("textViewDidChangeSelection:");
+    public static /*const*/ string sel_setBaseWritingDirection_1 = sel_registerName("setBaseWritingDirection:");
+    public static /*const*/ string sel_attributedSubStringForProposedRange_1actualRange_1 = sel_registerName("attributedSubStringForProposedRange:actualRange:");
+    public static /*const*/ string sel_pop = sel_registerName("pop");
+    public static /*const*/ string sel_animator = sel_registerName("animator");
+    public static /*const*/ string sel_allowsEmptySelection = sel_registerName("allowsEmptySelection");
+    public static /*const*/ string sel_scriptingIsGreaterThanOrEqualTo_1 = sel_registerName("scriptingIsGreaterThanOrEqualTo:");
+    public static /*const*/ string sel_numberOfSelectedRows = sel_registerName("numberOfSelectedRows");
+    public static /*const*/ string sel_imageDidNotDraw_1inRect_1 = sel_registerName("imageDidNotDraw:inRect:");
+    public static /*const*/ string sel_topLevelObject = sel_registerName("topLevelObject");
+    public static /*const*/ string sel_openDocumentWithContentsOfURL_1display_1 = sel_registerName("openDocumentWithContentsOfURL:display:");
+    public static /*const*/ string sel_valueListAttributes = sel_registerName("valueListAttributes");
+    public static /*const*/ string sel_enableFreedObjectCheck_1 = sel_registerName("enableFreedObjectCheck:");
+    public static /*const*/ string sel_moveForward_1 = sel_registerName("moveForward:");
+    public static /*const*/ string sel_setSendsActionOnArrowKeys_1 = sel_registerName("setSendsActionOnArrowKeys:");
+    public static /*const*/ string sel_versionForClassName_1 = sel_registerName("versionForClassName:");
+    public static /*const*/ string sel_coerceValue_1forKey_1 = sel_registerName("coerceValue:forKey:");
+    public static /*const*/ string sel_operatingSystem = sel_registerName("operatingSystem");
+    public static /*const*/ string sel_characterEncoding = sel_registerName("characterEncoding");
+    public static /*const*/ string sel_blendedColorWithFraction_1ofColor_1 = sel_registerName("blendedColorWithFraction:ofColor:");
+    public static /*const*/ string sel_panel_1userEnteredFilename_1confirmed_1 = sel_registerName("panel:userEnteredFilename:confirmed:");
+    public static /*const*/ string sel_addSelectedObjects_1 = sel_registerName("addSelectedObjects:");
+    public static /*const*/ string sel_pointingDeviceID = sel_registerName("pointingDeviceID");
+    public static /*const*/ string sel_children = sel_registerName("children");
+    public static /*const*/ string sel_takeObjectValueFrom_1 = sel_registerName("takeObjectValueFrom:");
+    public static /*const*/ string sel_indexSet = sel_registerName("indexSet");
+    public static /*const*/ string sel_setMovie_1 = sel_registerName("setMovie:");
+    public static /*const*/ string sel_setKeyEquivalentModifierMask_1 = sel_registerName("setKeyEquivalentModifierMask:");
+    public static /*const*/ string sel_allowsKeyedCoding = sel_registerName("allowsKeyedCoding");
+    public static /*const*/ string sel_rotateByDegrees_1 = sel_registerName("rotateByDegrees:");
+    public static /*const*/ string sel_compoundTypes = sel_registerName("compoundTypes");
+    public static /*const*/ string sel_setShortStandaloneWeekdaySymbols_1 = sel_registerName("setShortStandaloneWeekdaySymbols:");
+    public static /*const*/ string sel_removeWindowsItem_1 = sel_registerName("removeWindowsItem:");
+    public static /*const*/ string sel_StringArrayForKey_1 = sel_registerName("StringArrayForKey:");
+    public static /*const*/ string sel_outlineView_1typeSelectStringForTableColumn_1item_1 = sel_registerName("outlineView:typeSelectStringForTableColumn:item:");
+    public static /*const*/ string sel_initWithWindow_1 = sel_registerName("initWithWindow:");
+    public static /*const*/ string sel_accessibilityIsAttributeSettable_1 = sel_registerName("accessibilityIsAttributeSettable:");
+    public static /*const*/ string sel_rangeForUserCharacterAttributeChange = sel_registerName("rangeForUserCharacterAttributeChange");
+    public static /*const*/ string sel_setCalendar_1 = sel_registerName("setCalendar:");
+    public static /*const*/ string sel_beginEditing = sel_registerName("beginEditing");
+    public static /*const*/ string sel_enableUpdates = sel_registerName("enableUpdates");
+    public static /*const*/ string sel_setPrefersAllColumnUserResizing_1 = sel_registerName("setPrefersAllColumnUserResizing:");
+    public static /*const*/ string sel_isTornOff = sel_registerName("isTornOff");
+    public static /*const*/ string sel_checkSpellingOfString_1startingAt_1 = sel_registerName("checkSpellingOfString:startingAt:");
+    public static /*const*/ string sel_drawPackedGlyphs_1atPoint_1 = sel_registerName("drawPackedGlyphs:atPoint:");
+    public static /*const*/ string sel_graphicsContextWithAttributes_1 = sel_registerName("graphicsContextWithAttributes:");
+    public static /*const*/ string sel_textView_1completions_1forPartialWordRange_1indexOfSelectedItem_1 = sel_registerName("textView:completions:forPartialWordRange:indexOfSelectedItem:");
+    public static /*const*/ string sel_outlineView_1shouldExpandItem_1 = sel_registerName("outlineView:shouldExpandItem:");
+    public static /*const*/ string sel_isInFullScreenMode = sel_registerName("isInFullScreenMode");
+    public static /*const*/ string sel_userKeyEquivalent = sel_registerName("userKeyEquivalent");
+    public static /*const*/ string sel_menuBarHeight = sel_registerName("menuBarHeight");
+    public static /*const*/ string sel_initWithSize_1depth_1separate_1alpha_1 = sel_registerName("initWithSize:depth:separate:alpha:");
+    public static /*const*/ string sel_criticalValue = sel_registerName("criticalValue");
+    public static /*const*/ string sel_tableView_1didClickTableColumn_1 = sel_registerName("tableView:didClickTableColumn:");
+    public static /*const*/ string sel_addChildWindow_1ordered_1 = sel_registerName("addChildWindow:ordered:");
+    public static /*const*/ string sel_autoscroll_1 = sel_registerName("autoscroll:");
+    public static /*const*/ string sel_infoDictionary = sel_registerName("infoDictionary");
+    public static /*const*/ string sel_printOperationWithSettings_1error_1 = sel_registerName("printOperationWithSettings:error:");
+    public static /*const*/ string sel_translateOriginToPoint_1 = sel_registerName("translateOriginToPoint:");
+    public static /*const*/ string sel_takeStoredValue_1forKey_1 = sel_registerName("takeStoredValue:forKey:");
+    public static /*const*/ string sel_mouseUp_1 = sel_registerName("mouseUp:");
+    public static /*const*/ string sel_setNotationName_1 = sel_registerName("setNotationName:");
+    public static /*const*/ string sel_setArgument_1atIndex_1 = sel_registerName("setArgument:atIndex:");
+    public static /*const*/ string sel_setSelectedAttributes_1isMultiple_1 = sel_registerName("setSelectedAttributes:isMultiple:");
+    public static /*const*/ string sel_dayOfCommonEra = sel_registerName("dayOfCommonEra");
+    public static /*const*/ string sel_greenColor = sel_registerName("greenColor");
+    public static /*const*/ string sel_initWithProtocolFamily_1socketType_1protocol_1address_1 = sel_registerName("initWithProtocolFamily:socketType:protocol:address:");
+    public static /*const*/ string sel_setAttachmentCell_1 = sel_registerName("setAttachmentCell:");
+    public static /*const*/ string sel_previousFailureCount = sel_registerName("previousFailureCount");
+    public static /*const*/ string sel_currentOperation = sel_registerName("currentOperation");
+    public static /*const*/ string sel_tokenField_1completionsForSubString_1indexOfToken_1indexOfSelectedItem_1 = sel_registerName("tokenField:completionsForSubString:indexOfToken:indexOfSelectedItem:");
+    public static /*const*/ string sel_positionOfGlyph_1struckOverGlyph_1metricsExist_1 = sel_registerName("positionOfGlyph:struckOverGlyph:metricsExist:");
+    public static /*const*/ string sel_setMarkedTextAttributes_1 = sel_registerName("setMarkedTextAttributes:");
+    public static /*const*/ string sel_validateToolbarItem_1 = sel_registerName("validateToolbarItem:");
+    public static /*const*/ string sel_startingColumn = sel_registerName("startingColumn");
+    public static /*const*/ string sel_setSelectedRanges_1 = sel_registerName("setSelectedRanges:");
+    public static /*const*/ string sel_addItemWithTitle_1action_1keyEquivalent_1 = sel_registerName("addItemWithTitle:action:keyEquivalent:");
+    public static /*const*/ string sel_postNotificationName_1object_1 = sel_registerName("postNotificationName:object:");
+    public static /*const*/ string sel_replacementObjectForKeyedArchiver_1 = sel_registerName("replacementObjectForKeyedArchiver:");
+    public static /*const*/ string sel_deletesFileUponFailure = sel_registerName("deletesFileUponFailure");
+    public static /*const*/ string sel_speechRecognizer_1didRecognizeCommand_1 = sel_registerName("speechRecognizer:didRecognizeCommand:");
+    public static /*const*/ string sel_columnSpan = sel_registerName("columnSpan");
+    public static /*const*/ string sel_animationBlockingMode = sel_registerName("animationBlockingMode");
+    public static /*const*/ string sel_drawParts = sel_registerName("drawParts");
+    public static /*const*/ string sel_style = sel_registerName("style");
+    public static /*const*/ string sel_makeUntitledDocumentOfType_1error_1 = sel_registerName("makeUntitledDocumentOfType:error:");
+    public static /*const*/ string sel_filteredArrayUsingPredicate_1 = sel_registerName("filteredArrayUsingPredicate:");
+    public static /*const*/ string sel_wantsDefaultClipping = sel_registerName("wantsDefaultClipping");
+    public static /*const*/ string sel_one = sel_registerName("one");
+    public static /*const*/ string sel_persistentStoreTypeForFileType_1 = sel_registerName("persistentStoreTypeForFileType:");
+    public static /*const*/ string sel_pixelsHigh = sel_registerName("pixelsHigh");
+    public static /*const*/ string sel_rulerView_1shouldMoveMarker_1 = sel_registerName("rulerView:shouldMoveMarker:");
+    public static /*const*/ string sel_sizeWithAttributes_1 = sel_registerName("sizeWithAttributes:");
+    public static /*const*/ string sel_drawTitleOfColumn_1inRect_1 = sel_registerName("drawTitleOfColumn:inRect:");
+    public static /*const*/ string sel_setLevelsOfUndo_1 = sel_registerName("setLevelsOfUndo:");
+    public static /*const*/ string sel_invoke = sel_registerName("invoke");
+    public static /*const*/ string sel_keyEnumerator = sel_registerName("keyEnumerator");
+    public static /*const*/ string sel_convertFont_1toSize_1 = sel_registerName("convertFont:toSize:");
+    public static /*const*/ string sel_mouseExited_1withFrame_1inView_1 = sel_registerName("mouseExited:withFrame:inView:");
+    public static /*const*/ string sel_widthAdjustLimit = sel_registerName("widthAdjustLimit");
+    public static /*const*/ string sel_animationResizeTime_1 = sel_registerName("animationResizeTime:");
+    public static /*const*/ string sel_ensureLayoutForBoundingRect_1inTextContainer_1 = sel_registerName("ensureLayoutForBoundingRect:inTextContainer:");
+    public static /*const*/ string sel_initWithExpressionType_1 = sel_registerName("initWithExpressionType:");
+    public static /*const*/ string sel_numberWithUnsignedChar_1 = sel_registerName("numberWithUnsignedChar:");
+    public static /*const*/ string sel_directory = sel_registerName("directory");
+    public static /*const*/ string sel_address = sel_registerName("address");
+    public static /*const*/ string sel_defaultPixelFormat = sel_registerName("defaultPixelFormat");
+    public static /*const*/ string sel_deleteBackwardByDecomposingPreviousCharacter_1 = sel_registerName("deleteBackwardByDecomposingPreviousCharacter:");
+    public static /*const*/ string sel_clickCount = sel_registerName("clickCount");
+    public static /*const*/ string sel_trackMarker_1withMouseEvent_1 = sel_registerName("trackMarker:withMouseEvent:");
+    public static /*const*/ string sel_URL_1resourceDataDidBecomeAvailable_1 = sel_registerName("URL:resourceDataDidBecomeAvailable:");
+    public static /*const*/ string sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1 = sel_registerName("outlineView:setObjectValue:forTableColumn:byItem:");
+    public static /*const*/ string sel_insert_1 = sel_registerName("insert:");
+    public static /*const*/ string sel_methodForSelector_1 = sel_registerName("methodForSelector:");
+    public static /*const*/ string sel_insertGlyph_1atGlyphIndex_1characterIndex_1 = sel_registerName("insertGlyph:atGlyphIndex:characterIndex:");
+    public static /*const*/ string sel_readFromFileWrapper_1ofType_1error_1 = sel_registerName("readFromFileWrapper:ofType:error:");
+    public static /*const*/ string sel_selectedControlColor = sel_registerName("selectedControlColor");
+    public static /*const*/ string sel_selectedRow = sel_registerName("selectedRow");
+    public static /*const*/ string sel_control_1isValidObject_1 = sel_registerName("control:isValidObject:");
+    public static /*const*/ string sel_setUniqueID_1 = sel_registerName("setUniqueID:");
+    public static /*const*/ string sel_initWithName_1fromFile_1 = sel_registerName("initWithName:fromFile:");
+    public static /*const*/ string sel_sizeOfLabel_1 = sel_registerName("sizeOfLabel:");
+    public static /*const*/ string sel_credentialsForProtectionSpace_1 = sel_registerName("credentialsForProtectionSpace:");
+    public static /*const*/ string sel_anyObject = sel_registerName("anyObject");
+    public static /*const*/ string sel_runLoopModesForAnimating = sel_registerName("runLoopModesForAnimating");
+    public static /*const*/ string sel_setSortDescriptors_1 = sel_registerName("setSortDescriptors:");
+    public static /*const*/ string sel_convertSize_1toView_1 = sel_registerName("convertSize:toView:");
+    public static /*const*/ string sel_setLineFragmentRect_1forGlyphRange_1usedRect_1 = sel_registerName("setLineFragmentRect:forGlyphRange:usedRect:");
+    public static /*const*/ string sel_discardEditing = sel_registerName("discardEditing");
+    public static /*const*/ string sel_isAutodisplay = sel_registerName("isAutodisplay");
+    public static /*const*/ string sel_matchesOnMultipleResolution = sel_registerName("matchesOnMultipleResolution");
+    public static /*const*/ string sel_multipleThreadsEnabled = sel_registerName("multipleThreadsEnabled");
+    public static /*const*/ string sel_positionOfGlyph_1forCharacter_1struckOverRect_1 = sel_registerName("positionOfGlyph:forCharacter:struckOverRect:");
+    public static /*const*/ string sel_boundsRectForBlock_1contentRect_1inRect_1textContainer_1characterRange_1 = sel_registerName("boundsRectForBlock:contentRect:inRect:textContainer:characterRange:");
+    public static /*const*/ string sel_outlineView_1objectValueForTableColumn_1byItem_1 = sel_registerName("outlineView:objectValueForTableColumn:byItem:");
+    public static /*const*/ string sel_transformPoint_1 = sel_registerName("transformPoint:");
+    public static /*const*/ string sel_createClassDescription = sel_registerName("createClassDescription");
+    public static /*const*/ string sel_inputStreamWithFileAtPath_1 = sel_registerName("inputStreamWithFileAtPath:");
+    public static /*const*/ string sel_menuForEvent_1inRect_1ofView_1 = sel_registerName("menuForEvent:inRect:ofView:");
+    public static /*const*/ string sel_setRowTypeKeyPath_1 = sel_registerName("setRowTypeKeyPath:");
+    public static /*const*/ string sel_infoForBinding_1 = sel_registerName("infoForBinding:");
+    public static /*const*/ string sel_setDataRetained_1 = sel_registerName("setDataRetained:");
+    public static /*const*/ string sel_revertToContentsOfURL_1ofType_1error_1 = sel_registerName("revertToContentsOfURL:ofType:error:");
+    public static /*const*/ string sel_currentControlTint = sel_registerName("currentControlTint");
+    public static /*const*/ string sel_selection = sel_registerName("selection");
+    public static /*const*/ string sel_array = sel_registerName("array");
+    public static /*const*/ string sel_setStyle_1 = sel_registerName("setStyle:");
+    public static /*const*/ string sel_setPredicate_1 = sel_registerName("setPredicate:");
+    public static /*const*/ string sel_endEditing = sel_registerName("endEditing");
+    public static /*const*/ string sel_doClick_1 = sel_registerName("doClick:");
+    public static /*const*/ string sel_toManyRelationshipKeys = sel_registerName("toManyRelationshipKeys");
+    public static /*const*/ string sel_selectedKnobColor = sel_registerName("selectedKnobColor");
+    public static /*const*/ string sel_setOrderedIndex_1 = sel_registerName("setOrderedIndex:");
+    public static /*const*/ string sel_initWithSet_1 = sel_registerName("initWithSet:");
+    public static /*const*/ string sel_drawSelector = sel_registerName("drawSelector");
+    public static /*const*/ string sel_requestWithURL_1 = sel_registerName("requestWithURL:");
+    public static /*const*/ string sel_imageNamed_1 = sel_registerName("imageNamed:");
+    public static /*const*/ string sel_hyphenationFactorForGlyphAtIndex_1 = sel_registerName("hyphenationFactorForGlyphAtIndex:");
+    public static /*const*/ string sel_miniwindowTitle = sel_registerName("miniwindowTitle");
+    public static /*const*/ string sel_isFileURL = sel_registerName("isFileURL");
+    public static /*const*/ string sel_selectedSegment = sel_registerName("selectedSegment");
+    public static /*const*/ string sel_applicationDidResignActive_1 = sel_registerName("applicationDidResignActive:");
+    public static /*const*/ string sel_initWithString_1calendarFormat_1 = sel_registerName("initWithString:calendarFormat:");
+    public static /*const*/ string sel_initWithProtectionSpace_1proposedCredential_1previousFailureCount_1failureResponse_1error_1sender_1 = sel_registerName("initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:");
+    public static /*const*/ string sel_menuHasKeyEquivalent_1forEvent_1target_1action_1 = sel_registerName("menuHasKeyEquivalent:forEvent:target:action:");
+    public static /*const*/ string sel_minPossiblePositionOfDividerAtIndex_1 = sel_registerName("minPossiblePositionOfDividerAtIndex:");
+    public static /*const*/ string sel_abbreviationForDate_1 = sel_registerName("abbreviationForDate:");
+    public static /*const*/ string sel_absoluteX = sel_registerName("absoluteX");
+    public static /*const*/ string sel_scriptErrorNumber = sel_registerName("scriptErrorNumber");
+    public static /*const*/ string sel_previousValidKeyView = sel_registerName("previousValidKeyView");
+    public static /*const*/ string sel_valueWithRange_1 = sel_registerName("valueWithRange:");
+    public static /*const*/ string sel_initWithDefaults_1initialValues_1 = sel_registerName("initWithDefaults:initialValues:");
+    public static /*const*/ string sel_initNotTestWithTest_1 = sel_registerName("initNotTestWithTest:");
+    public static /*const*/ string sel_abortModal = sel_registerName("abortModal");
+    public static /*const*/ string sel_isSuspended = sel_registerName("isSuspended");
+    public static /*const*/ string sel_isFilePackageAtPath_1 = sel_registerName("isFilePackageAtPath:");
+    public static /*const*/ string sel_useCredential_1forAuthenticationChallenge_1 = sel_registerName("useCredential:forAuthenticationChallenge:");
+    public static /*const*/ string sel_draggingSequenceNumber = sel_registerName("draggingSequenceNumber");
+    public static /*const*/ string sel_lastColumn = sel_registerName("lastColumn");
+    public static /*const*/ string sel_distantFuture = sel_registerName("distantFuture");
+    public static /*const*/ string sel_download_1didReceiveResponse_1 = sel_registerName("download:didReceiveResponse:");
+    public static /*const*/ string sel_textTransform = sel_registerName("textTransform");
+    public static /*const*/ string sel_hasHorizontalScroller = sel_registerName("hasHorizontalScroller");
+    public static /*const*/ string sel_shadowBlurRadius = sel_registerName("shadowBlurRadius");
+    public static /*const*/ string sel_pointingDeviceType = sel_registerName("pointingDeviceType");
+    public static /*const*/ string sel_setMenuView_1 = sel_registerName("setMenuView:");
+    public static /*const*/ string sel_setWindingRule_1 = sel_registerName("setWindingRule:");
+    public static /*const*/ string sel_imageForSegment_1 = sel_registerName("imageForSegment:");
+    public static /*const*/ string sel_bytes = sel_registerName("bytes");
+    public static /*const*/ string sel_propertyListFromStringsFileFormat = sel_registerName("propertyListFromStringsFileFormat");
+    public static /*const*/ string sel_setParagraphStyle_1 = sel_registerName("setParagraphStyle:");
+    public static /*const*/ string sel_highlightMode = sel_registerName("highlightMode");
+    public static /*const*/ string sel_voice = sel_registerName("voice");
+    public static /*const*/ string sel_hostName = sel_registerName("hostName");
+    public static /*const*/ string sel_removeAccessoryController_1 = sel_registerName("removeAccessoryController:");
+    public static /*const*/ string sel_rowsInRect_1 = sel_registerName("rowsInRect:");
+    public static /*const*/ string sel_registerImageRepClass_1 = sel_registerName("registerImageRepClass:");
+    public static /*const*/ string sel_value_1withObjCType_1 = sel_registerName("value:withObjCType:");
+    public static /*const*/ string sel_enclosingMenuItem = sel_registerName("enclosingMenuItem");
+    public static /*const*/ string sel_exposedBindings = sel_registerName("exposedBindings");
+    public static /*const*/ string sel_setSharedScriptSuiteRegistry_1 = sel_registerName("setSharedScriptSuiteRegistry:");
+    public static /*const*/ string sel_readablePasteboardTypes = sel_registerName("readablePasteboardTypes");
+    public static /*const*/ string sel_drawViewBackgroundInRect_1 = sel_registerName("drawViewBackgroundInRect:");
+    public static /*const*/ string sel_setDataCell_1 = sel_registerName("setDataCell:");
+    public static /*const*/ string sel_dataRepresentationOfType_1 = sel_registerName("dataRepresentationOfType:");
+    public static /*const*/ string sel_setOrientation_1 = sel_registerName("setOrientation:");
+    public static /*const*/ string sel_setFileWrapper_1 = sel_registerName("setFileWrapper:");
+    public static /*const*/ string sel_runModalOpenPanel_1forTypes_1 = sel_registerName("runModalOpenPanel:forTypes:");
+    public static /*const*/ string sel_adjustSubviews = sel_registerName("adjustSubviews");
+    public static /*const*/ string sel_setCurrencyDecimalSeparator_1 = sel_registerName("setCurrencyDecimalSeparator:");
+    public static /*const*/ string sel_needsDisplay = sel_registerName("needsDisplay");
+    public static /*const*/ string sel_insertValue_1atIndex_1inPropertyWithKey_1 = sel_registerName("insertValue:atIndex:inPropertyWithKey:");
+    public static /*const*/ string sel_setTextStorage_1 = sel_registerName("setTextStorage:");
+    public static /*const*/ string sel_isAlternate = sel_registerName("isAlternate");
+    public static /*const*/ string sel_setOutputFormat_1 = sel_registerName("setOutputFormat:");
+    public static /*const*/ string sel_comboBoxWillPopUp_1 = sel_registerName("comboBoxWillPopUp:");
+    public static /*const*/ string sel_insertChild_1 = sel_registerName("insertChild:");
+    public static /*const*/ string sel_initWithCommandDescription_1 = sel_registerName("initWithCommandDescription:");
+    public static /*const*/ string sel_setLineDash_1count_1phase_1 = sel_registerName("setLineDash:count:phase:");
+    public static /*const*/ string sel_setHardInvalidation_1forGlyphRange_1 = sel_registerName("setHardInvalidation:forGlyphRange:");
+    public static /*const*/ string sel_setAllowsToolTipsWhenApplicationIsInactive_1 = sel_registerName("setAllowsToolTipsWhenApplicationIsInactive:");
+    public static /*const*/ string sel_tableView_1namesOfPromisedFilesDroppedAtDestination_1forDraggedRowsWithIndexes_1 = sel_registerName("tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:");
+    public static /*const*/ string sel_highlightedItemIndex = sel_registerName("highlightedItemIndex");
+    public static /*const*/ string sel_trailingOffset = sel_registerName("trailingOffset");
+    public static /*const*/ string sel_layer = sel_registerName("layer");
+    public static /*const*/ string sel_isDeletableFileAtPath_1 = sel_registerName("isDeletableFileAtPath:");
+    public static /*const*/ string sel_textUnfilteredTypes = sel_registerName("textUnfilteredTypes");
+    public static /*const*/ string sel_gregorianStartDate = sel_registerName("gregorianStartDate");
+    public static /*const*/ string sel_isDocumentEdited = sel_registerName("isDocumentEdited");
+    public static /*const*/ string sel_colorWithCalibratedWhite_1alpha_1 = sel_registerName("colorWithCalibratedWhite:alpha:");
+    public static /*const*/ string sel_shouldRunSavePanelWithAccessoryView = sel_registerName("shouldRunSavePanelWithAccessoryView");
+    public static /*const*/ string sel_finishEncoding = sel_registerName("finishEncoding");
+    public static /*const*/ string sel_setKeyCell_1 = sel_registerName("setKeyCell:");
+    public static /*const*/ string sel_isPartialStringValid_1newEditingString_1errorDescription_1 = sel_registerName("isPartialStringValid:newEditingString:errorDescription:");
+    public static /*const*/ string sel_setRangeContainerObject_1 = sel_registerName("setRangeContainerObject:");
+    public static /*const*/ string sel_typeOfFile_1error_1 = sel_registerName("typeOfFile:error:");
+    public static /*const*/ string sel_disappearingItemCursor = sel_registerName("disappearingItemCursor");
+    public static /*const*/ string sel_textureMaxMipMapLevel = sel_registerName("textureMaxMipMapLevel");
+    public static /*const*/ string sel_setEraSymbols_1 = sel_registerName("setEraSymbols:");
+    public static /*const*/ string sel_setBordered_1 = sel_registerName("setBordered:");
+    public static /*const*/ string sel_precomposedStringWithCanonicalMapping = sel_registerName("precomposedStringWithCanonicalMapping");
+    public static /*const*/ string sel_setEnabled_1 = sel_registerName("setEnabled:");
+    public static /*const*/ string sel_setChildrenKeyPath_1 = sel_registerName("setChildrenKeyPath:");
+    public static /*const*/ string sel_applicationDidBecomeActive_1 = sel_registerName("applicationDidBecomeActive:");
+    public static /*const*/ string sel_setCancelButtonCell_1 = sel_registerName("setCancelButtonCell:");
+    public static /*const*/ string sel_backgroundFilters = sel_registerName("backgroundFilters");
+    public static /*const*/ string sel_indexOfCellWithTag_1 = sel_registerName("indexOfCellWithTag:");
+    public static /*const*/ string sel_UTF8String = sel_registerName("UTF8String");
+    public static /*const*/ string sel_horizontalPagination = sel_registerName("horizontalPagination");
+    public static /*const*/ string sel_allowedInputSourceLocales = sel_registerName("allowedInputSourceLocales");
+    public static /*const*/ string sel_toolbar = sel_registerName("toolbar");
+    public static /*const*/ string sel_setGeneratesDecimalNumbers_1 = sel_registerName("setGeneratesDecimalNumbers:");
+    public static /*const*/ string sel_highlight_1withFrame_1inView_1 = sel_registerName("highlight:withFrame:inView:");
+    public static /*const*/ string sel_rotation = sel_registerName("rotation");
+    public static /*const*/ string sel_colorForControlTint_1 = sel_registerName("colorForControlTint:");
+    public static /*const*/ string sel_mutableString = sel_registerName("mutableString");
+    public static /*const*/ string sel_shadowWithLevel_1 = sel_registerName("shadowWithLevel:");
+    public static /*const*/ string sel_frameRectForContentRect_1styleMask_1 = sel_registerName("frameRectForContentRect:styleMask:");
+    public static /*const*/ string sel_numberOfColorComponents = sel_registerName("numberOfColorComponents");
+    public static /*const*/ string sel_alternateImage = sel_registerName("alternateImage");
+    public static /*const*/ string sel_initWithString_1relativeToURL_1 = sel_registerName("initWithString:relativeToURL:");
+    public static /*const*/ string sel_pageOrder = sel_registerName("pageOrder");
+    public static /*const*/ string sel_cancel_1 = sel_registerName("cancel:");
+    public static /*const*/ string sel_declareTypes_1owner_1 = sel_registerName("declareTypes:owner:");
+    public static /*const*/ string sel_lastObject = sel_registerName("lastObject");
+    public static /*const*/ string sel_type_1conformsToType_1 = sel_registerName("type:conformsToType:");
+    public static /*const*/ string sel_mutableArrayValueForKey_1 = sel_registerName("mutableArrayValueForKey:");
+    public static /*const*/ string sel_initWithName_1host_1 = sel_registerName("initWithName:host:");
+    public static /*const*/ string sel_keyEquivalentWidth = sel_registerName("keyEquivalentWidth");
+    public static /*const*/ string sel_modifier = sel_registerName("modifier");
+    public static /*const*/ string sel_setPerMillSymbol_1 = sel_registerName("setPerMillSymbol:");
+    public static /*const*/ string sel_setToolbar_1 = sel_registerName("setToolbar:");
+    public static /*const*/ string sel_changeAttributes_1 = sel_registerName("changeAttributes:");
+    public static /*const*/ string sel_removeItemWithTitle_1 = sel_registerName("removeItemWithTitle:");
+    public static /*const*/ string sel_setAspectRatio_1 = sel_registerName("setAspectRatio:");
+    public static /*const*/ string sel_undoManagerForTextView_1 = sel_registerName("undoManagerForTextView:");
+    public static /*const*/ string sel_clickedPathComponentCell = sel_registerName("clickedPathComponentCell");
+    public static /*const*/ string sel_commentWithStringValue_1 = sel_registerName("commentWithStringValue:");
+    public static /*const*/ string sel_initWithContainerSpecifier_1key_1 = sel_registerName("initWithContainerSpecifier:key:");
+    public static /*const*/ string sel_windowWillReturnUndoManager_1 = sel_registerName("windowWillReturnUndoManager:");
+    public static /*const*/ string sel_imageAndTitleOffset = sel_registerName("imageAndTitleOffset");
+    public static /*const*/ string sel_initialize = sel_registerName("initialize");
+    public static /*const*/ string sel_truncatesLastVisibleLine = sel_registerName("truncatesLastVisibleLine");
+    public static /*const*/ string sel_setExponentSymbol_1 = sel_registerName("setExponentSymbol:");
+    public static /*const*/ string sel_setCurrentProgress_1 = sel_registerName("setCurrentProgress:");
+    public static /*const*/ string sel_initWithContentsOfFile_1options_1error_1 = sel_registerName("initWithContentsOfFile:options:error:");
+    public static /*const*/ string sel_titleCell = sel_registerName("titleCell");
+    public static /*const*/ string sel_setCurrencySymbol_1 = sel_registerName("setCurrencySymbol:");
+    public static /*const*/ string sel_usesScreenFonts = sel_registerName("usesScreenFonts");
+    public static /*const*/ string sel_propertyList = sel_registerName("propertyList");
+    public static /*const*/ string sel_subgroups = sel_registerName("subgroups");
+    public static /*const*/ string sel_setFloatValue_1knobProportion_1 = sel_registerName("setFloatValue:knobProportion:");
+    public static /*const*/ string sel_componentsJoinedByString_1 = sel_registerName("componentsJoinedByString:");
+    public static /*const*/ string sel_initWithICCProfileData_1 = sel_registerName("initWithICCProfileData:");
+    public static /*const*/ string sel_setNextKeyView_1 = sel_registerName("setNextKeyView:");
+    public static /*const*/ string sel_setAnimationCurve_1 = sel_registerName("setAnimationCurve:");
+    public static /*const*/ string sel_tokenFieldCell_1completionsForSubString_1indexOfToken_1indexOfSelectedItem_1 = sel_registerName("tokenFieldCell:completionsForSubString:indexOfToken:indexOfSelectedItem:");
+    public static /*const*/ string sel_takeValuesFromDictionary_1 = sel_registerName("takeValuesFromDictionary:");
+    public static /*const*/ string sel_imageRepClassForPasteboardType_1 = sel_registerName("imageRepClassForPasteboardType:");
+    public static /*const*/ string sel_setPlaybackDeviceIdentifier_1 = sel_registerName("setPlaybackDeviceIdentifier:");
+    public static /*const*/ string sel_globallyUniqueString = sel_registerName("globallyUniqueString");
+    public static /*const*/ string sel_setLineWidth_1 = sel_registerName("setLineWidth:");
+    public static /*const*/ string sel_selectedColumnIndexes = sel_registerName("selectedColumnIndexes");
+    public static /*const*/ string sel_addWindowsItem_1title_1filename_1 = sel_registerName("addWindowsItem:title:filename:");
+    public static /*const*/ string sel_truncateFileAtOffset_1 = sel_registerName("truncateFileAtOffset:");
+    public static /*const*/ string sel_setStandardOutput_1 = sel_registerName("setStandardOutput:");
+    public static /*const*/ string sel_encodeInt32_1forKey_1 = sel_registerName("encodeInt32:forKey:");
+    public static /*const*/ string sel_baselineDeltaForCharacterAtIndex_1 = sel_registerName("baselineDeltaForCharacterAtIndex:");
+    public static /*const*/ string sel_setValueWraps_1 = sel_registerName("setValueWraps:");
+    public static /*const*/ string sel_addOperation_1 = sel_registerName("addOperation:");
+    public static /*const*/ string sel_resignKeyWindow = sel_registerName("resignKeyWindow");
+    public static /*const*/ string sel_insertNewline_1 = sel_registerName("insertNewline:");
+    public static /*const*/ string sel_saveFrameUsingName_1 = sel_registerName("saveFrameUsingName:");
+    public static /*const*/ string sel_setWithObjects_1 = sel_registerName("setWithObjects:");
+    public static /*const*/ string sel_indexOfItemWithTarget_1andAction_1 = sel_registerName("indexOfItemWithTarget:andAction:");
+    public static /*const*/ string sel_processEditing = sel_registerName("processEditing");
+    public static /*const*/ string sel_removeValueAtIndex_1fromPropertyWithKey_1 = sel_registerName("removeValueAtIndex:fromPropertyWithKey:");
+    public static /*const*/ string sel_setShouldCascadeWindows_1 = sel_registerName("setShouldCascadeWindows:");
+    public static /*const*/ string sel_stepBack_1 = sel_registerName("stepBack:");
+    public static /*const*/ string sel_lockWhenCondition_1beforeDate_1 = sel_registerName("lockWhenCondition:beforeDate:");
+    public static /*const*/ string sel_realm = sel_registerName("realm");
+    public static /*const*/ string sel_appendBezierPathWithPackedGlyphs_1 = sel_registerName("appendBezierPathWithPackedGlyphs:");
+    public static /*const*/ string sel_inputStreamWithData_1 = sel_registerName("inputStreamWithData:");
+    public static /*const*/ string sel_clickedRow = sel_registerName("clickedRow");
+    public static /*const*/ string sel_animationShouldStart_1 = sel_registerName("animationShouldStart:");
+    public static /*const*/ string sel_appleEventCodeForKey_1 = sel_registerName("appleEventCodeForKey:");
+    public static /*const*/ string sel_sendAction_1to_1forAllCells_1 = sel_registerName("sendAction:to:forAllCells:");
+    public static /*const*/ string sel_writableTypesForSaveOperation_1 = sel_registerName("writableTypesForSaveOperation:");
+    public static /*const*/ string sel_drawWellInside_1 = sel_registerName("drawWellInside:");
+    public static /*const*/ string sel_intersectsSet_1 = sel_registerName("intersectsSet:");
+    public static /*const*/ string sel_runOperationModalForWindow_1delegate_1didRunSelector_1contextInfo_1 = sel_registerName("runOperationModalForWindow:delegate:didRunSelector:contextInfo:");
+    public static /*const*/ string sel_setAllowsEmptySelection_1 = sel_registerName("setAllowsEmptySelection:");
+    public static /*const*/ string sel_tighteningFactorForTruncation = sel_registerName("tighteningFactorForTruncation");
+    public static /*const*/ string sel_insertDescriptor_1atIndex_1 = sel_registerName("insertDescriptor:atIndex:");
+    public static /*const*/ string sel_setDefaultBehavior_1 = sel_registerName("setDefaultBehavior:");
+    public static /*const*/ string sel_allowsFloats = sel_registerName("allowsFloats");
+    public static /*const*/ string sel_representedObject = sel_registerName("representedObject");
+    public static /*const*/ string sel_isFlipped = sel_registerName("isFlipped");
+    public static /*const*/ string sel_rectOfColumn_1 = sel_registerName("rectOfColumn:");
+    public static /*const*/ string sel_setFrame_1display_1 = sel_registerName("setFrame:display:");
+    public static /*const*/ string sel_setTextAttributesForPositiveInfinity_1 = sel_registerName("setTextAttributesForPositiveInfinity:");
+    public static /*const*/ string sel_textUnfilteredFileTypes = sel_registerName("textUnfilteredFileTypes");
+    public static /*const*/ string sel_bezierPathByFlatteningPath = sel_registerName("bezierPathByFlatteningPath");
+    public static /*const*/ string sel_week = sel_registerName("week");
+    public static /*const*/ string sel_takeIntValueFrom_1 = sel_registerName("takeIntValueFrom:");
+    public static /*const*/ string sel_setWantsNotificationForMarkedText_1 = sel_registerName("setWantsNotificationForMarkedText:");
+    public static /*const*/ string sel_StringByPaddingToLength_1withString_1startingAtIndex_1 = sel_registerName("StringByPaddingToLength:withString:startingAtIndex:");
+    public static /*const*/ string sel_stopModal = sel_registerName("stopModal");
+    public static /*const*/ string sel_veryShortWeekdaySymbols = sel_registerName("veryShortWeekdaySymbols");
+    public static /*const*/ string sel_user = sel_registerName("user");
+    public static /*const*/ string sel_animation_1didReachProgressMark_1 = sel_registerName("animation:didReachProgressMark:");
+    public static /*const*/ string sel_fontWithName_1size_1 = sel_registerName("fontWithName:size:");
+    public static /*const*/ string sel_selectWord_1 = sel_registerName("selectWord:");
+    public static /*const*/ string sel_initWithDuration_1animationCurve_1 = sel_registerName("initWithDuration:animationCurve:");
+    public static /*const*/ string sel_afmDictionary = sel_registerName("afmDictionary");
+    public static /*const*/ string sel_canChooseFiles = sel_registerName("canChooseFiles");
+    public static /*const*/ string sel_defaultLineWidth = sel_registerName("defaultLineWidth");
+    public static /*const*/ string sel_childAtIndex_1 = sel_registerName("childAtIndex:");
+    public static /*const*/ string sel_pathForResource_1ofType_1inDirectory_1 = sel_registerName("pathForResource:ofType:inDirectory:");
+    public static /*const*/ string sel_outlineView_1heightOfRowByItem_1 = sel_registerName("outlineView:heightOfRowByItem:");
+    public static /*const*/ string sel_PMSymbol = sel_registerName("PMSymbol");
+    public static /*const*/ string sel_setBackgroundStyle_1 = sel_registerName("setBackgroundStyle:");
+    public static /*const*/ string sel_decimalSeparator = sel_registerName("decimalSeparator");
+    public static /*const*/ string sel_knobThickness = sel_registerName("knobThickness");
+    public static /*const*/ string sel_request = sel_registerName("request");
+    public static /*const*/ string sel_indicesOfObjectsByEvaluatingWithContainer_1count_1 = sel_registerName("indicesOfObjectsByEvaluatingWithContainer:count:");
+    public static /*const*/ string sel_objectByApplyingXSLTString_1arguments_1error_1 = sel_registerName("objectByApplyingXSLTString:arguments:error:");
+    public static /*const*/ string sel_colorizeByMappingGray_1toColor_1blackMapping_1whiteMapping_1 = sel_registerName("colorizeByMappingGray:toColor:blackMapping:whiteMapping:");
+    public static /*const*/ string sel_minusSet_1 = sel_registerName("minusSet:");
+    public static /*const*/ string sel_setAutomaticallyRearrangesObjects_1 = sel_registerName("setAutomaticallyRearrangesObjects:");
+    public static /*const*/ string sel_fixFontAttributeInRange_1 = sel_registerName("fixFontAttributeInRange:");
+    public static /*const*/ string sel_frameRotation = sel_registerName("frameRotation");
+    public static /*const*/ string sel_addObserver_1forKeyPath_1options_1context_1 = sel_registerName("addObserver:forKeyPath:options:context:");
+    public static /*const*/ string sel_collectionNames = sel_registerName("collectionNames");
+    public static /*const*/ string sel_titleOfColumn_1 = sel_registerName("titleOfColumn:");
+    public static /*const*/ string sel_characterIdentifier = sel_registerName("characterIdentifier");
+    public static /*const*/ string sel_setPanelFont_1isMultiple_1 = sel_registerName("setPanelFont:isMultiple:");
+    public static /*const*/ string sel_ruleThickness = sel_registerName("ruleThickness");
+    public static /*const*/ string sel_customSelector = sel_registerName("customSelector");
+    public static /*const*/ string sel_startSpeakingString_1toURL_1 = sel_registerName("startSpeakingString:toURL:");
+    public static /*const*/ string sel_language = sel_registerName("language");
+    public static /*const*/ string sel_draggedImage_1endedAt_1operation_1 = sel_registerName("draggedImage:endedAt:operation:");
+    public static /*const*/ string sel_removeSelectionIndexPaths_1 = sel_registerName("removeSelectionIndexPaths:");
+    public static /*const*/ string sel_TIFFRepresentationOfImageRepsInArray_1 = sel_registerName("TIFFRepresentationOfImageRepsInArray:");
+    public static /*const*/ string sel_setSet_1 = sel_registerName("setSet:");
+    public static /*const*/ string sel_StringWithCString_1length_1 = sel_registerName("StringWithCString:length:");
+    public static /*const*/ string sel_objectsByEvaluatingSpecifier = sel_registerName("objectsByEvaluatingSpecifier");
+    public static /*const*/ string sel_subarrayWithRange_1 = sel_registerName("subarrayWithRange:");
+    public static /*const*/ string sel_collectIfNeeded = sel_registerName("collectIfNeeded");
+    public static /*const*/ string sel_pathWithComponents_1 = sel_registerName("pathWithComponents:");
+    public static /*const*/ string sel_autoreleasedObjectCount = sel_registerName("autoreleasedObjectCount");
+    public static /*const*/ string sel_addCharactersInString_1 = sel_registerName("addCharactersInString:");
+    public static /*const*/ string sel_setTemplate_1 = sel_registerName("setTemplate:");
+    public static /*const*/ string sel_indexOfObjectIdenticalTo_1 = sel_registerName("indexOfObjectIdenticalTo:");
+    public static /*const*/ string sel_setRepresentation = sel_registerName("setRepresentation");
+    public static /*const*/ string sel_URLResourceDidFinishLoading_1 = sel_registerName("URLResourceDidFinishLoading:");
+    public static /*const*/ string sel_type = sel_registerName("type");
+    public static /*const*/ string sel_setMarkedText_1selectedRange_1 = sel_registerName("setMarkedText:selectedRange:");
+    public static /*const*/ string sel_dictionaryWithObjects_1forKeys_1 = sel_registerName("dictionaryWithObjects:forKeys:");
+    public static /*const*/ string sel_wantsToDelayTextChangeNotifications = sel_registerName("wantsToDelayTextChangeNotifications");
+    public static /*const*/ string sel_setCompletes_1 = sel_registerName("setCompletes:");
+    public static /*const*/ string sel_releaseGState = sel_registerName("releaseGState");
+    public static /*const*/ string sel_descriptorWithEnumCode_1 = sel_registerName("descriptorWithEnumCode:");
+    public static /*const*/ string sel_label = sel_registerName("label");
+    public static /*const*/ string sel_run = sel_registerName("run");
+    public static /*const*/ string sel_hasHorizontalRuler = sel_registerName("hasHorizontalRuler");
+    public static /*const*/ string sel_rowClass = sel_registerName("rowClass");
+    public static /*const*/ string sel_automaticRearrangementKeyPaths = sel_registerName("automaticRearrangementKeyPaths");
+    public static /*const*/ string sel_fileManager_1shouldProceedAfterError_1movingItemAtPath_1toPath_1 = sel_registerName("fileManager:shouldProceedAfterError:movingItemAtPath:toPath:");
+    public static /*const*/ string sel_writeToURL_1atomically_1encoding_1error_1 = sel_registerName("writeToURL:atomically:encoding:error:");
+    public static /*const*/ string sel_deviceID = sel_registerName("deviceID");
+    public static /*const*/ string sel_descriptorWithInt32_1 = sel_registerName("descriptorWithInt32:");
+    public static /*const*/ string sel_encodeInt64_1forKey_1 = sel_registerName("encodeInt64:forKey:");
+    public static /*const*/ string sel_insertEntry_1atIndex_1 = sel_registerName("insertEntry:atIndex:");
+    public static /*const*/ string sel_leftMargin = sel_registerName("leftMargin");
+    public static /*const*/ string sel_setKeyEquivalentFont_1size_1 = sel_registerName("setKeyEquivalentFont:size:");
+    public static /*const*/ string sel_colorWithDeviceHue_1saturation_1brightness_1alpha_1 = sel_registerName("colorWithDeviceHue:saturation:brightness:alpha:");
+    public static /*const*/ string sel_nextState = sel_registerName("nextState");
+    public static /*const*/ string sel_scanHexInt_1 = sel_registerName("scanHexInt:");
+    public static /*const*/ string sel_lineSpacing = sel_registerName("lineSpacing");
+    public static /*const*/ string sel_textureTarget = sel_registerName("textureTarget");
+    public static /*const*/ string sel_miniaturize_1 = sel_registerName("miniaturize:");
+    public static /*const*/ string sel_browser_1namesOfPromisedFilesDroppedAtDestination_1forDraggedRowsWithIndexes_1inColumn_1 = sel_registerName("browser:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:inColumn:");
+    public static /*const*/ string sel_localizedNameForTIFFCompressionType_1 = sel_registerName("localizedNameForTIFFCompressionType:");
+    public static /*const*/ string sel_acceptConnectionInBackgroundAndNotifyForModes_1 = sel_registerName("acceptConnectionInBackgroundAndNotifyForModes:");
+    public static /*const*/ string sel_setCanBecomeVisibleWithoutLogin_1 = sel_registerName("setCanBecomeVisibleWithoutLogin:");
+    public static /*const*/ string sel_dictionaryWithObjectsAndKeys_1 = sel_registerName("dictionaryWithObjectsAndKeys:");
+    public static /*const*/ string sel_ensureGlyphsForGlyphRange_1 = sel_registerName("ensureGlyphsForGlyphRange:");
+    public static /*const*/ string sel_indexOfTickMarkAtPoint_1 = sel_registerName("indexOfTickMarkAtPoint:");
+    public static /*const*/ string sel_dayOfWeek = sel_registerName("dayOfWeek");
+    public static /*const*/ string sel_glyphRangeForCharacterRange_1actualCharacterRange_1 = sel_registerName("glyphRangeForCharacterRange:actualCharacterRange:");
+    public static /*const*/ string sel_enableCollectorForPointer_1 = sel_registerName("enableCollectorForPointer:");
+    public static /*const*/ string sel_rulerView_1willMoveMarker_1toLocation_1 = sel_registerName("rulerView:willMoveMarker:toLocation:");
+    public static /*const*/ string sel_comboBoxCell_1objectValueForItemAtIndex_1 = sel_registerName("comboBoxCell:objectValueForItemAtIndex:");
+    public static /*const*/ string sel_setValidateSize_1 = sel_registerName("setValidateSize:");
+    public static /*const*/ string sel_controlTint = sel_registerName("controlTint");
+    public static /*const*/ string sel_deselectItemAtIndex_1 = sel_registerName("deselectItemAtIndex:");
+    public static /*const*/ string sel_defaultWindingRule = sel_registerName("defaultWindingRule");
+    public static /*const*/ string sel_setMaxValue_1 = sel_registerName("setMaxValue:");
+    public static /*const*/ string sel_longEraSymbols = sel_registerName("longEraSymbols");
+    public static /*const*/ string sel_canRedo = sel_registerName("canRedo");
+    public static /*const*/ string sel_arguments = sel_registerName("arguments");
+    public static /*const*/ string sel_windows = sel_registerName("windows");
+    public static /*const*/ string sel_downloadDidBegin_1 = sel_registerName("downloadDidBegin:");
+    public static /*const*/ string sel_pasteboard_1provideDataForType_1 = sel_registerName("pasteboard:provideDataForType:");
+    public static /*const*/ string sel_length = sel_registerName("length");
+    public static /*const*/ string sel_imagePosition = sel_registerName("imagePosition");
+    public static /*const*/ string sel_setAllowedFileTypes_1 = sel_registerName("setAllowedFileTypes:");
+    public static /*const*/ string sel_moveForwardAndModifySelection_1 = sel_registerName("moveForwardAndModifySelection:");
+    public static /*const*/ string sel_filename = sel_registerName("filename");
+    public static /*const*/ string sel_mountedLocalVolumePaths = sel_registerName("mountedLocalVolumePaths");
+    public static /*const*/ string sel_sharedFontManager = sel_registerName("sharedFontManager");
+    public static /*const*/ string sel_dictionaryWithObjects_1forKeys_1count_1 = sel_registerName("dictionaryWithObjects:forKeys:count:");
+    public static /*const*/ string sel_transpose_1 = sel_registerName("transpose:");
+    public static /*const*/ string sel_drawTitleWithFrame_1inView_1 = sel_registerName("drawTitleWithFrame:inView:");
+    public static /*const*/ string sel_worksWhenModal = sel_registerName("worksWhenModal");
+    public static /*const*/ string sel_registerClassDescription_1 = sel_registerName("registerClassDescription:");
+    public static /*const*/ string sel_setAllowsTruncatedLabels_1 = sel_registerName("setAllowsTruncatedLabels:");
+    public static /*const*/ string sel_bezierPathWithRoundedRect_1xRadius_1yRadius_1 = sel_registerName("bezierPathWithRoundedRect:xRadius:yRadius:");
+    public static /*const*/ string sel_prefix = sel_registerName("prefix");
+    public static /*const*/ string sel_usesStrongWriteBarrier = sel_registerName("usesStrongWriteBarrier");
+    public static /*const*/ string sel_argumentNames = sel_registerName("argumentNames");
+    public static /*const*/ string sel_setCaseSensitive_1 = sel_registerName("setCaseSensitive:");
+    public static /*const*/ string sel_outlineView_1didClickTableColumn_1 = sel_registerName("outlineView:didClickTableColumn:");
+    public static /*const*/ string sel_textDidBeginEditing_1 = sel_registerName("textDidBeginEditing:");
+    public static /*const*/ string sel_visibleRect = sel_registerName("visibleRect");
+    public static /*const*/ string sel_isSubviewCollapsed_1 = sel_registerName("isSubviewCollapsed:");
+    public static /*const*/ string sel_completionsForPartialWordRange_1indexOfSelectedItem_1 = sel_registerName("completionsForPartialWordRange:indexOfSelectedItem:");
+    public static /*const*/ string sel_setMinDate_1 = sel_registerName("setMinDate:");
+    public static /*const*/ string sel_colorFromPasteboard_1 = sel_registerName("colorFromPasteboard:");
+    public static /*const*/ string sel_instanceMethodSignatureForSelector_1 = sel_registerName("instanceMethodSignatureForSelector:");
+    public static /*const*/ string sel_makeCellAtRow_1column_1 = sel_registerName("makeCellAtRow:column:");
+    public static /*const*/ string sel_pasteAsPlainText_1 = sel_registerName("pasteAsPlainText:");
+    public static /*const*/ string sel_willRemoveSubview_1 = sel_registerName("willRemoveSubview:");
+    public static /*const*/ string sel_beginSheet_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1 = sel_registerName("beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:");
+    public static /*const*/ string sel_notificationCenterForType_1 = sel_registerName("notificationCenterForType:");
+    public static /*const*/ string sel_isDaylightSavingTimeForDate_1 = sel_registerName("isDaylightSavingTimeForDate:");
+    public static /*const*/ string sel_load = sel_registerName("load");
+    public static /*const*/ string sel_menuForSegment_1 = sel_registerName("menuForSegment:");
+    public static /*const*/ string sel_scheduledTimerWithTimeInterval_1invocation_1repeats_1 = sel_registerName("scheduledTimerWithTimeInterval:invocation:repeats:");
+    public static /*const*/ string sel_unregisterClass_1 = sel_registerName("unregisterClass:");
+    public static /*const*/ string sel_setByAddingObjectsFromSet_1 = sel_registerName("setByAddingObjectsFromSet:");
+    public static /*const*/ string sel_setDepthLimit_1 = sel_registerName("setDepthLimit:");
+    public static /*const*/ string sel_setVeryShortMonthSymbols_1 = sel_registerName("setVeryShortMonthSymbols:");
+    public static /*const*/ string sel_writeToURL_1ofType_1forSaveOperation_1originalContentsURL_1error_1 = sel_registerName("writeToURL:ofType:forSaveOperation:originalContentsURL:error:");
+    public static /*const*/ string sel_directoryAttributes = sel_registerName("directoryAttributes");
+    public static /*const*/ string sel_otherMouseDown_1 = sel_registerName("otherMouseDown:");
+    public static /*const*/ string sel_unhideWithoutActivation = sel_registerName("unhideWithoutActivation");
+    public static /*const*/ string sel_initWithContainerClassDescription_1containerSpecifier_1key_1startSpecifier_1endSpecifier_1 = sel_registerName("initWithContainerClassDescription:containerSpecifier:key:startSpecifier:endSpecifier:");
+    public static /*const*/ string sel_setHasHorizontalScroller_1 = sel_registerName("setHasHorizontalScroller:");
+    public static /*const*/ string sel_trackMouse_1adding_1 = sel_registerName("trackMouse:adding:");
+    public static /*const*/ string sel_substituteGlyphsInRange_1withGlyphs_1 = sel_registerName("substituteGlyphsInRange:withGlyphs:");
+    public static /*const*/ string sel_drawCell_1 = sel_registerName("drawCell:");
+    public static /*const*/ string sel_currentCursor = sel_registerName("currentCursor");
+    public static /*const*/ string sel_maxSize = sel_registerName("maxSize");
+    public static /*const*/ string sel_cookiesWithResponseHeaderFields_1forURL_1 = sel_registerName("cookiesWithResponseHeaderFields:forURL:");
+    public static /*const*/ string sel_isBycopy = sel_registerName("isBycopy");
+    public static /*const*/ string sel_addCursorRect_1cursor_1 = sel_registerName("addCursorRect:cursor:");
+    public static /*const*/ string sel_accessibilityActionNames = sel_registerName("accessibilityActionNames");
+    public static /*const*/ string sel_openDocumentWithContentsOfURL_1display_1error_1 = sel_registerName("openDocumentWithContentsOfURL:display:error:");
+    public static /*const*/ string sel_templateViews = sel_registerName("templateViews");
+    public static /*const*/ string sel_keyPath = sel_registerName("keyPath");
+    public static /*const*/ string sel_minValue = sel_registerName("minValue");
+    public static /*const*/ string sel_setImageDimsWhenDisabled_1 = sel_registerName("setImageDimsWhenDisabled:");
+    public static /*const*/ string sel_appendData_1 = sel_registerName("appendData:");
+    public static /*const*/ string sel_netServiceBrowser_1didFindDomain_1moreComing_1 = sel_registerName("netServiceBrowser:didFindDomain:moreComing:");
+    public static /*const*/ string sel_initWithDescriptorType_1bytes_1length_1 = sel_registerName("initWithDescriptorType:bytes:length:");
+    public static /*const*/ string sel_hasReadablePropertyForKey_1 = sel_registerName("hasReadablePropertyForKey:");
+    public static /*const*/ string sel_stopWhenAnimation_1reachesProgress_1 = sel_registerName("stopWhenAnimation:reachesProgress:");
+    public static /*const*/ string sel_setWorksWhenModal_1 = sel_registerName("setWorksWhenModal:");
+    public static /*const*/ string sel_localizedInputManagerName = sel_registerName("localizedInputManagerName");
+    public static /*const*/ string sel_knobColor = sel_registerName("knobColor");
+    public static /*const*/ string sel_screens = sel_registerName("screens");
+    public static /*const*/ string sel_deminiaturize_1 = sel_registerName("deminiaturize:");
+    public static /*const*/ string sel_bundleIdentifier = sel_registerName("bundleIdentifier");
+    public static /*const*/ string sel_setLoopMode_1 = sel_registerName("setLoopMode:");
+    public static /*const*/ string sel_expandItem_1expandChildren_1 = sel_registerName("expandItem:expandChildren:");
+    public static /*const*/ string sel_dataWithContentsOfFile_1options_1error_1 = sel_registerName("dataWithContentsOfFile:options:error:");
+    public static /*const*/ string sel_lineBreakBeforeIndex_1withinRange_1 = sel_registerName("lineBreakBeforeIndex:withinRange:");
+    public static /*const*/ string sel_fileOwnerAccountName = sel_registerName("fileOwnerAccountName");
+    public static /*const*/ string sel_insertColumn_1withCells_1 = sel_registerName("insertColumn:withCells:");
+    public static /*const*/ string sel_windowLevel = sel_registerName("windowLevel");
+    public static /*const*/ string sel_setGrammarCheckingEnabled_1 = sel_registerName("setGrammarCheckingEnabled:");
+    public static /*const*/ string sel_shortStandaloneWeekdaySymbols = sel_registerName("shortStandaloneWeekdaySymbols");
+    public static /*const*/ string sel_push = sel_registerName("push");
+    public static /*const*/ string sel_initWithContentsOfFile_1ofType_1 = sel_registerName("initWithContentsOfFile:ofType:");
+    public static /*const*/ string sel_removePortForName_1 = sel_registerName("removePortForName:");
+    public static /*const*/ string sel_setMaximumRecents_1 = sel_registerName("setMaximumRecents:");
+    public static /*const*/ string sel_supermenu = sel_registerName("supermenu");
+    public static /*const*/ string sel_setWidth_1type_1forLayer_1edge_1 = sel_registerName("setWidth:type:forLayer:edge:");
+    public static /*const*/ string sel_itemRemoved_1 = sel_registerName("itemRemoved:");
+    public static /*const*/ string sel_initWithBytesNoCopy_1length_1 = sel_registerName("initWithBytesNoCopy:length:");
+    public static /*const*/ string sel_printer = sel_registerName("printer");
+    public static /*const*/ string sel_compact = sel_registerName("compact");
+    public static /*const*/ string sel_setDefaultLineWidth_1 = sel_registerName("setDefaultLineWidth:");
+    public static /*const*/ string sel_CGLPixelFormatObj = sel_registerName("CGLPixelFormatObj");
+    public static /*const*/ string sel_initWithDictionary_1copyItems_1 = sel_registerName("initWithDictionary:copyItems:");
+    public static /*const*/ string sel_tableView_1didDragTableColumn_1 = sel_registerName("tableView:didDragTableColumn:");
+    public static /*const*/ string sel_formattingStringsFilename = sel_registerName("formattingStringsFilename");
+    public static /*const*/ string sel_setScrollView_1 = sel_registerName("setScrollView:");
+    public static /*const*/ string sel_value = sel_registerName("value");
+    public static /*const*/ string sel_editedMask = sel_registerName("editedMask");
+    public static /*const*/ string sel_ruleEditor_1displayValueForCriterion_1inRow_1 = sel_registerName("ruleEditor:displayValueForCriterion:inRow:");
+    public static /*const*/ string sel_leading = sel_registerName("leading");
+    public static /*const*/ string sel_titleRect = sel_registerName("titleRect");
+    public static /*const*/ string sel_setColumnsAutosaveName_1 = sel_registerName("setColumnsAutosaveName:");
+    public static /*const*/ string sel_stop_1 = sel_registerName("stop:");
+    public static /*const*/ string sel_titleColor = sel_registerName("titleColor");
+    public static /*const*/ string sel_initWithContainerClassDescription_1containerSpecifier_1key_1test_1 = sel_registerName("initWithContainerClassDescription:containerSpecifier:key:test:");
+    public static /*const*/ string sel_bytesPerPlane = sel_registerName("bytesPerPlane");
+    public static /*const*/ string sel_pageScroll = sel_registerName("pageScroll");
+    public static /*const*/ string sel_groupingAttributes = sel_registerName("groupingAttributes");
+    public static /*const*/ string sel_setAutomaticLinkDetectionEnabled_1 = sel_registerName("setAutomaticLinkDetectionEnabled:");
+    public static /*const*/ string sel_tableView_1mouseDownInHeaderOfTableColumn_1 = sel_registerName("tableView:mouseDownInHeaderOfTableColumn:");
+    public static /*const*/ string sel_representationOfImageRepsInArray_1usingType_1properties_1 = sel_registerName("representationOfImageRepsInArray:usingType:properties:");
+    public static /*const*/ string sel_attributeRuns = sel_registerName("attributeRuns");
+    public static /*const*/ string sel_decodeRect = sel_registerName("decodeRect");
+    public static /*const*/ string sel_drawerDidOpen_1 = sel_registerName("drawerDidOpen:");
+    public static /*const*/ string sel_scrollerWidth = sel_registerName("scrollerWidth");
+    public static /*const*/ string sel_defaultMenu = sel_registerName("defaultMenu");
+    public static /*const*/ string sel_URLProtocol_1didLoadData_1 = sel_registerName("URLProtocol:didLoadData:");
+    public static /*const*/ string sel_allKeys = sel_registerName("allKeys");
+    public static /*const*/ string sel_startPeriodicEventsAfterDelay_1withPeriod_1 = sel_registerName("startPeriodicEventsAfterDelay:withPeriod:");
+    public static /*const*/ string sel_tableViewSelectionDidChange_1 = sel_registerName("tableViewSelectionDidChange:");
+    public static /*const*/ string sel_setStandalone_1 = sel_registerName("setStandalone:");
+    public static /*const*/ string sel_makeMainWindow = sel_registerName("makeMainWindow");
+    public static /*const*/ string sel_moveLeftAndModifySelection_1 = sel_registerName("moveLeftAndModifySelection:");
+    public static /*const*/ string sel_pasteboardWithUniqueName = sel_registerName("pasteboardWithUniqueName");
+    public static /*const*/ string sel_fileSystemFileNumber = sel_registerName("fileSystemFileNumber");
+    public static /*const*/ string sel_jobDisposition = sel_registerName("jobDisposition");
+    public static /*const*/ string sel_setCurrentVirtualScreen_1 = sel_registerName("setCurrentVirtualScreen:");
+    public static /*const*/ string sel_setHasThousandSeparators_1 = sel_registerName("setHasThousandSeparators:");
+    public static /*const*/ string sel_alternateMnemonicLocation = sel_registerName("alternateMnemonicLocation");
+    public static /*const*/ string sel_characterSetWithBitmapRepresentation_1 = sel_registerName("characterSetWithBitmapRepresentation:");
+    public static /*const*/ string sel_startLoading = sel_registerName("startLoading");
+    public static /*const*/ string sel_member_1 = sel_registerName("member:");
+    public static /*const*/ string sel_setSelectedFont_1isMultiple_1 = sel_registerName("setSelectedFont:isMultiple:");
+    public static /*const*/ string sel_monthOfYear = sel_registerName("monthOfYear");
+    public static /*const*/ string sel_restoreCachedImage = sel_registerName("restoreCachedImage");
+    public static /*const*/ string sel_image_1didLoadPartOfRepresentation_1withValidRows_1 = sel_registerName("image:didLoadPartOfRepresentation:withValidRows:");
+    public static /*const*/ string sel_mouseEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1clickCount_1pressure_1 = sel_registerName("mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:");
+    public static /*const*/ string sel_setInternationalCurrencySymbol_1 = sel_registerName("setInternationalCurrencySymbol:");
+    public static /*const*/ string sel_mainThread = sel_registerName("mainThread");
+    public static /*const*/ string sel_lineCapStyle = sel_registerName("lineCapStyle");
+    public static /*const*/ string sel_setDefaultParagraphStyle_1 = sel_registerName("setDefaultParagraphStyle:");
+    public static /*const*/ string sel_cellFrameForTextContainer_1proposedLineFragment_1glyphPosition_1characterIndex_1 = sel_registerName("cellFrameForTextContainer:proposedLineFragment:glyphPosition:characterIndex:");
+    public static /*const*/ string sel_resolveInstanceMethod_1 = sel_registerName("resolveInstanceMethod:");
+    public static /*const*/ string sel_illegalCharacterSet = sel_registerName("illegalCharacterSet");
+    public static /*const*/ string sel_setKnobThickness_1 = sel_registerName("setKnobThickness:");
+    public static /*const*/ string sel_runModalPageLayoutWithPrintInfo_1 = sel_registerName("runModalPageLayoutWithPrintInfo:");
+    public static /*const*/ string sel_popUpContextMenu_1withEvent_1forView_1withFont_1 = sel_registerName("popUpContextMenu:withEvent:forView:withFont:");
+    public static /*const*/ string sel_modalWindow = sel_registerName("modalWindow");
+    public static /*const*/ string sel_autorelease = sel_registerName("autorelease");
+    public static /*const*/ string sel_draggingEntered_1 = sel_registerName("draggingEntered:");
+    public static /*const*/ string sel_allowsTruncatedLabels = sel_registerName("allowsTruncatedLabels");
+    public static /*const*/ string sel_fileDescriptor = sel_registerName("fileDescriptor");
+    public static /*const*/ string sel_ISOLanguageCodes = sel_registerName("ISOLanguageCodes");
+    public static /*const*/ string sel_onStateImage = sel_registerName("onStateImage");
+    public static /*const*/ string sel_imageFrameStyle = sel_registerName("imageFrameStyle");
+    public static /*const*/ string sel_setFloatValue_1 = sel_registerName("setFloatValue:");
+    public static /*const*/ string sel_initWithColors_1atLocations_1colorSpace_1 = sel_registerName("initWithColors:atLocations:colorSpace:");
+    public static /*const*/ string sel_descriptorWithString_1 = sel_registerName("descriptorWithString:");
+    public static /*const*/ string sel_setPoolCountHighWaterMark_1 = sel_registerName("setPoolCountHighWaterMark:");
+    public static /*const*/ string sel_veryShortStandaloneWeekdaySymbols = sel_registerName("veryShortStandaloneWeekdaySymbols");
+    public static /*const*/ string sel_addTypes_1owner_1 = sel_registerName("addTypes:owner:");
+    public static /*const*/ string sel_numberWithLongLong_1 = sel_registerName("numberWithLongLong:");
+    public static /*const*/ string sel_setDay_1 = sel_registerName("setDay:");
+    public static /*const*/ string sel_initWithHTML_1documentAttributes_1 = sel_registerName("initWithHTML:documentAttributes:");
+    public static /*const*/ string sel_replaceSubview_1with_1 = sel_registerName("replaceSubview:with:");
+    public static /*const*/ string sel_makeObjectsPerformSelector_1 = sel_registerName("makeObjectsPerformSelector:");
+    public static /*const*/ string sel_setRunLoopModes_1 = sel_registerName("setRunLoopModes:");
+    public static /*const*/ string sel_getFileSystemRepresentation_1maxLength_1 = sel_registerName("getFileSystemRepresentation:maxLength:");
+    public static /*const*/ string sel_scale = sel_registerName("scale");
+    public static /*const*/ string sel_draggedImageLocation = sel_registerName("draggedImageLocation");
+    public static /*const*/ string sel_setFocusStack_1 = sel_registerName("setFocusStack:");
+    public static /*const*/ string sel_isReadOnlyKey_1 = sel_registerName("isReadOnlyKey:");
+    public static /*const*/ string sel_shadowOffset = sel_registerName("shadowOffset");
+    public static /*const*/ string sel_URLHandleUsingCache_1 = sel_registerName("URLHandleUsingCache:");
+    public static /*const*/ string sel_isWellFormed = sel_registerName("isWellFormed");
+    public static /*const*/ string sel_tokenField_1editingStringForRepresentedObject_1 = sel_registerName("tokenField:editingStringForRepresentedObject:");
+    public static /*const*/ string sel_setGroupsByEvent_1 = sel_registerName("setGroupsByEvent:");
+    public static /*const*/ string sel_parser_1foundComment_1 = sel_registerName("parser:foundComment:");
+    public static /*const*/ string sel_initWithHTML_1baseURL_1documentAttributes_1 = sel_registerName("initWithHTML:baseURL:documentAttributes:");
+    public static /*const*/ string sel_uppercaseWord_1 = sel_registerName("uppercaseWord:");
+    public static /*const*/ string sel_testPart_1 = sel_registerName("testPart:");
+    public static /*const*/ string sel_dataSource = sel_registerName("dataSource");
+    public static /*const*/ string sel_lineRangeForRange_1 = sel_registerName("lineRangeForRange:");
+    public static /*const*/ string sel_hostWithAddress_1 = sel_registerName("hostWithAddress:");
+    public static /*const*/ string sel_removeRunLoop_1 = sel_registerName("removeRunLoop:");
+    public static /*const*/ string sel_fileHandleWithStandardInput = sel_registerName("fileHandleWithStandardInput");
+    public static /*const*/ string sel_itemArray = sel_registerName("itemArray");
+    public static /*const*/ string sel_rectOfPathComponentCell_1withFrame_1inView_1 = sel_registerName("rectOfPathComponentCell:withFrame:inView:");
+    public static /*const*/ string sel_TIFFRepresentation = sel_registerName("TIFFRepresentation");
+    public static /*const*/ string sel_archiver_1willReplaceObject_1withObject_1 = sel_registerName("archiver:willReplaceObject:withObject:");
+    public static /*const*/ string sel_currentVirtualScreen = sel_registerName("currentVirtualScreen");
+    public static /*const*/ string sel_gridColor = sel_registerName("gridColor");
+    public static /*const*/ string sel_boundingRectForGlyph_1 = sel_registerName("boundingRectForGlyph:");
+    public static /*const*/ string sel_setDataSource_1 = sel_registerName("setDataSource:");
+    public static /*const*/ string sel_setDefaultLineJoinStyle_1 = sel_registerName("setDefaultLineJoinStyle:");
+    public static /*const*/ string sel_textBlocks = sel_registerName("textBlocks");
+    public static /*const*/ string sel_drawerDidClose_1 = sel_registerName("drawerDidClose:");
+    public static /*const*/ string sel_valueWithName_1inPropertyWithKey_1 = sel_registerName("valueWithName:inPropertyWithKey:");
+    public static /*const*/ string sel_managedObjectModel = sel_registerName("managedObjectModel");
+    public static /*const*/ string sel_outlineView_1persistentObjectForItem_1 = sel_registerName("outlineView:persistentObjectForItem:");
+    public static /*const*/ string sel_setSelectedRange_1 = sel_registerName("setSelectedRange:");
+    public static /*const*/ string sel_magentaComponent = sel_registerName("magentaComponent");
+    public static /*const*/ string sel_setIncrement_1 = sel_registerName("setIncrement:");
+    public static /*const*/ string sel_editingStringForObjectValue_1 = sel_registerName("editingStringForObjectValue:");
+    public static /*const*/ string sel_addClip = sel_registerName("addClip");
+    public static /*const*/ string sel_setSelectionIndex_1 = sel_registerName("setSelectionIndex:");
+    public static /*const*/ string sel_replyAppleEventForSuspensionID_1 = sel_registerName("replyAppleEventForSuspensionID:");
+    public static /*const*/ string sel_URLProtocol_1didFailWithError_1 = sel_registerName("URLProtocol:didFailWithError:");
+    public static /*const*/ string sel_ignoresMouseEvents = sel_registerName("ignoresMouseEvents");
+    public static /*const*/ string sel_dateWithNaturalLanguageString_1locale_1 = sel_registerName("dateWithNaturalLanguageString:locale:");
+    public static /*const*/ string sel_recordDescriptor = sel_registerName("recordDescriptor");
+    public static /*const*/ string sel_makeCurrentContext = sel_registerName("makeCurrentContext");
+    public static /*const*/ string sel_excludedKeys = sel_registerName("excludedKeys");
+    public static /*const*/ string sel_fileManager_1shouldProceedAfterError_1linkingItemAtPath_1toPath_1 = sel_registerName("fileManager:shouldProceedAfterError:linkingItemAtPath:toPath:");
+    public static /*const*/ string sel_set = sel_registerName("set");
+    public static /*const*/ string sel_mainScreen = sel_registerName("mainScreen");
+    public static /*const*/ string sel_setVersion_1 = sel_registerName("setVersion:");
+    public static /*const*/ string sel_displayRectIgnoringOpacity_1inContext_1 = sel_registerName("displayRectIgnoringOpacity:inContext:");
+    public static /*const*/ string sel_setNumberOfTickMarks_1 = sel_registerName("setNumberOfTickMarks:");
+    public static /*const*/ string sel_showsHelp = sel_registerName("showsHelp");
+    public static /*const*/ string sel_takeColorFrom_1 = sel_registerName("takeColorFrom:");
+    public static /*const*/ string sel_horizontalPageScroll = sel_registerName("horizontalPageScroll");
+    public static /*const*/ string sel_pointingHandCursor = sel_registerName("pointingHandCursor");
+    public static /*const*/ string sel_vendorID = sel_registerName("vendorID");
+    public static /*const*/ string sel_setSelectedRanges_1affinity_1stillSelecting_1 = sel_registerName("setSelectedRanges:affinity:stillSelecting:");
+    public static /*const*/ string sel_setHTTPShouldHandleCookies_1 = sel_registerName("setHTTPShouldHandleCookies:");
+    public static /*const*/ string sel_initWithType_1location_1 = sel_registerName("initWithType:location:");
+    public static /*const*/ string sel_StringByResolvingSymlinksInPath = sel_registerName("StringByResolvingSymlinksInPath");
+    public static /*const*/ string sel_tryLock = sel_registerName("tryLock");
+    public static /*const*/ string sel_convertSizeFromBase_1 = sel_registerName("convertSizeFromBase:");
+    public static /*const*/ string sel_setCacheMode_1 = sel_registerName("setCacheMode:");
+    public static /*const*/ string sel_entityName = sel_registerName("entityName");
+    public static /*const*/ string sel_takeFloatValueFrom_1 = sel_registerName("takeFloatValueFrom:");
+    public static /*const*/ string sel_showsStateBy = sel_registerName("showsStateBy");
+    public static /*const*/ string sel_highlightedItem = sel_registerName("highlightedItem");
+    public static /*const*/ string sel_superclassDescription = sel_registerName("superclassDescription");
+    public static /*const*/ string sel_flagsChanged_1 = sel_registerName("flagsChanged:");
+    public static /*const*/ string sel_alloc = sel_registerName("alloc");
+    public static /*const*/ string sel_setDisplaysWhenScreenProfileChanges_1 = sel_registerName("setDisplaysWhenScreenProfileChanges:");
+    public static /*const*/ string sel_CIImage = sel_registerName("CIImage");
+    public static /*const*/ string sel_setSupermenu_1 = sel_registerName("setSupermenu:");
+    public static /*const*/ string sel_setSharedURLCache_1 = sel_registerName("setSharedURLCache:");
+    public static /*const*/ string sel_pathCell_1willPopUpMenu_1 = sel_registerName("pathCell:willPopUpMenu:");
+    public static /*const*/ string sel_setAttributes_1ofItemAtPath_1error_1 = sel_registerName("setAttributes:ofItemAtPath:error:");
+    public static /*const*/ string sel_tableView_1typeSelectStringForTableColumn_1row_1 = sel_registerName("tableView:typeSelectStringForTableColumn:row:");
+    public static /*const*/ string sel_moveWordLeftAndModifySelection_1 = sel_registerName("moveWordLeftAndModifySelection:");
+    public static /*const*/ string sel_whitespaceAndNewlineCharacterSet = sel_registerName("whitespaceAndNewlineCharacterSet");
+    public static /*const*/ string sel_pathControl_1validateDrop_1 = sel_registerName("pathControl:validateDrop:");
+    public static /*const*/ string sel_createCommandInstanceWithZone_1 = sel_registerName("createCommandInstanceWithZone:");
+    public static /*const*/ string sel_configurationDictionary = sel_registerName("configurationDictionary");
+    public static /*const*/ string sel_classFallbacksForKeyedArchiver = sel_registerName("classFallbacksForKeyedArchiver");
+    public static /*const*/ string sel_DTDKind = sel_registerName("DTDKind");
+    public static /*const*/ string sel_initWithPath_1documentAttributes_1 = sel_registerName("initWithPath:documentAttributes:");
+    public static /*const*/ string sel_addObjectsFromArray_1 = sel_registerName("addObjectsFromArray:");
+    public static /*const*/ string sel_tokenField_1displayStringForRepresentedObject_1 = sel_registerName("tokenField:displayStringForRepresentedObject:");
+    public static /*const*/ string sel_firstVisibleColumn = sel_registerName("firstVisibleColumn");
+    public static /*const*/ string sel_gradientType = sel_registerName("gradientType");
+    public static /*const*/ string sel_familyName = sel_registerName("familyName");
+    public static /*const*/ string sel_uniqueID = sel_registerName("uniqueID");
+    public static /*const*/ string sel_setFormatterBehavior_1 = sel_registerName("setFormatterBehavior:");
+    public static /*const*/ string sel_tokenFieldCell_1hasMenuForRepresentedObject_1 = sel_registerName("tokenFieldCell:hasMenuForRepresentedObject:");
+    public static /*const*/ string sel_fileManager_1shouldCopyItemAtPath_1toPath_1 = sel_registerName("fileManager:shouldCopyItemAtPath:toPath:");
+    public static /*const*/ string sel_keySpecifier = sel_registerName("keySpecifier");
+    public static /*const*/ string sel_copyItemAtPath_1toPath_1error_1 = sel_registerName("copyItemAtPath:toPath:error:");
+    public static /*const*/ string sel_setLength_1 = sel_registerName("setLength:");
+    public static /*const*/ string sel_reloadItem_1 = sel_registerName("reloadItem:");
+    public static /*const*/ string sel_removeObjectsAtArrangedObjectIndexes_1 = sel_registerName("removeObjectsAtArrangedObjectIndexes:");
+    public static /*const*/ string sel_setVisibilityPriority_1 = sel_registerName("setVisibilityPriority:");
+    public static /*const*/ string sel_insertItemWithObjectValue_1atIndex_1 = sel_registerName("insertItemWithObjectValue:atIndex:");
+    public static /*const*/ string sel_searchButtonCell = sel_registerName("searchButtonCell");
+    public static /*const*/ string sel_getCString_1maxLength_1range_1remainingRange_1 = sel_registerName("getCString:maxLength:range:remainingRange:");
+    public static /*const*/ string sel_outlineView_1child_1ofItem_1 = sel_registerName("outlineView:child:ofItem:");
+    public static /*const*/ string sel_numberOfComponents = sel_registerName("numberOfComponents");
+    public static /*const*/ string sel_isKindOfClass_1 = sel_registerName("isKindOfClass:");
+    public static /*const*/ string sel_processorCount = sel_registerName("processorCount");
+    public static /*const*/ string sel_lineJoinStyle = sel_registerName("lineJoinStyle");
+    public static /*const*/ string sel_collectionBehavior = sel_registerName("collectionBehavior");
+    public static /*const*/ string sel_setApplicationIconImage_1 = sel_registerName("setApplicationIconImage:");
+    public static /*const*/ string sel_setLaunchPath_1 = sel_registerName("setLaunchPath:");
+    public static /*const*/ string sel_initFileURLWithPath_1 = sel_registerName("initFileURLWithPath:");
+    public static /*const*/ string sel_selectItemAtIndex_1 = sel_registerName("selectItemAtIndex:");
+    public static /*const*/ string sel_IBeamCursor = sel_registerName("IBeamCursor");
+    public static /*const*/ string sel_isColor = sel_registerName("isColor");
+    public static /*const*/ string sel_cancelAuthenticationChallenge_1 = sel_registerName("cancelAuthenticationChallenge:");
+    public static /*const*/ string sel_echosBullets = sel_registerName("echosBullets");
+    public static /*const*/ string sel_setHasUndoManager_1 = sel_registerName("setHasUndoManager:");
+    public static /*const*/ string sel_RTFDFileWrapperFromRange_1documentAttributes_1 = sel_registerName("RTFDFileWrapperFromRange:documentAttributes:");
+    public static /*const*/ string sel_highlightCell_1atRow_1column_1 = sel_registerName("highlightCell:atRow:column:");
+    public static /*const*/ string sel_currentHost = sel_registerName("currentHost");
+    public static /*const*/ string sel_setURI_1 = sel_registerName("setURI:");
+    public static /*const*/ string sel_suiteNames = sel_registerName("suiteNames");
+    public static /*const*/ string sel_genericGrayColorSpace = sel_registerName("genericGrayColorSpace");
+    public static /*const*/ string sel_volatileDomainForName_1 = sel_registerName("volatileDomainForName:");
+    public static /*const*/ string sel_tokenizingCharacterSet = sel_registerName("tokenizingCharacterSet");
+    public static /*const*/ string sel_initWithXMLString_1 = sel_registerName("initWithXMLString:");
+    public static /*const*/ string sel_function = sel_registerName("function");
+    public static /*const*/ string sel_sizeForMagnification_1 = sel_registerName("sizeForMagnification:");
+    public static /*const*/ string sel_commitEditingWithDelegate_1didCommitSelector_1contextInfo_1 = sel_registerName("commitEditingWithDelegate:didCommitSelector:contextInfo:");
+    public static /*const*/ string sel_writeToFile_1 = sel_registerName("writeToFile:");
+    public static /*const*/ string sel_displayIfNeededInRect_1 = sel_registerName("displayIfNeededInRect:");
+    public static /*const*/ string sel_optionDescriptionsForBinding_1 = sel_registerName("optionDescriptionsForBinding:");
+    public static /*const*/ string sel_initWithSize_1 = sel_registerName("initWithSize:");
+    public static /*const*/ string sel_cornerView = sel_registerName("cornerView");
+    public static /*const*/ string sel_redoActionName = sel_registerName("redoActionName");
+    public static /*const*/ string sel_setLocation_1forStartOfGlyphRange_1 = sel_registerName("setLocation:forStartOfGlyphRange:");
+    public static /*const*/ string sel_setAllowedInputSourceLocales_1 = sel_registerName("setAllowedInputSourceLocales:");
+    public static /*const*/ string sel_convertRect_1toView_1 = sel_registerName("convertRect:toView:");
+    public static /*const*/ string sel_preferredFilenameExtensionForType_1 = sel_registerName("preferredFilenameExtensionForType:");
+    public static /*const*/ string sel_tableView_1writeRows_1toPasteboard_1 = sel_registerName("tableView:writeRows:toPasteboard:");
+    public static /*const*/ string sel_rootObject = sel_registerName("rootObject");
+    public static /*const*/ string sel_isEqualToHashTable_1 = sel_registerName("isEqualToHashTable:");
+    public static /*const*/ string sel_indent_1 = sel_registerName("indent:");
+    public static /*const*/ string sel_removeIndexesInRange_1 = sel_registerName("removeIndexesInRange:");
+    public static /*const*/ string sel_numberWithBool_1 = sel_registerName("numberWithBool:");
+    public static /*const*/ string sel_setPersistentDomain_1forName_1 = sel_registerName("setPersistentDomain:forName:");
+    public static /*const*/ string sel_netServiceBrowser_1didRemoveService_1moreComing_1 = sel_registerName("netServiceBrowser:didRemoveService:moreComing:");
+    public static /*const*/ string sel_timeZoneWithName_1data_1 = sel_registerName("timeZoneWithName:data:");
+    public static /*const*/ string sel_drawImage_1withFrame_1inView_1 = sel_registerName("drawImage:withFrame:inView:");
+    public static /*const*/ string sel_buttonToolTip = sel_registerName("buttonToolTip");
+    public static /*const*/ string sel_enableCursorRects = sel_registerName("enableCursorRects");
+    public static /*const*/ string sel_rulerAttributesInRange_1 = sel_registerName("rulerAttributesInRange:");
+    public static /*const*/ string sel_setMemoryCapacity_1 = sel_registerName("setMemoryCapacity:");
+    public static /*const*/ string sel_isSeparatorItem = sel_registerName("isSeparatorItem");
+    public static /*const*/ string sel_save_1 = sel_registerName("save:");
+    public static /*const*/ string sel_documentView = sel_registerName("documentView");
+    public static /*const*/ string sel_setHostCacheEnabled_1 = sel_registerName("setHostCacheEnabled:");
+    public static /*const*/ string sel_setDatePickerElements_1 = sel_registerName("setDatePickerElements:");
+    public static /*const*/ string sel_mixedStateImage = sel_registerName("mixedStateImage");
+    public static /*const*/ string sel_setAcceptsMouseMovedEvents_1 = sel_registerName("setAcceptsMouseMovedEvents:");
+    public static /*const*/ string sel_numberOfTabViewItems = sel_registerName("numberOfTabViewItems");
+    public static /*const*/ string sel_portForName_1host_1nameServerPortNumber_1 = sel_registerName("portForName:host:nameServerPortNumber:");
+    public static /*const*/ string sel_printerWithName_1domain_1includeUnavailable_1 = sel_registerName("printerWithName:domain:includeUnavailable:");
+    public static /*const*/ string sel_insertObjects_1atArrangedObjectIndexPaths_1 = sel_registerName("insertObjects:atArrangedObjectIndexPaths:");
+    public static /*const*/ string sel_browser_1shouldTypeSelectForEvent_1withCurrentSearchString_1 = sel_registerName("browser:shouldTypeSelectForEvent:withCurrentSearchString:");
+    public static /*const*/ string sel_defaultTabInterval = sel_registerName("defaultTabInterval");
+    public static /*const*/ string sel_initWithTitle_1 = sel_registerName("initWithTitle:");
+    public static /*const*/ string sel_timeZoneForSecondsFromGMT_1 = sel_registerName("timeZoneForSecondsFromGMT:");
+    public static /*const*/ string sel_initWithPasteboard_1 = sel_registerName("initWithPasteboard:");
+    public static /*const*/ string sel_subscriptRange_1 = sel_registerName("subscriptRange:");
+    public static /*const*/ string sel_highlightColorWithFrame_1inView_1 = sel_registerName("highlightColorWithFrame:inView:");
+    public static /*const*/ string sel_didChangeText = sel_registerName("didChangeText");
+    public static /*const*/ string sel_storagePolicy = sel_registerName("storagePolicy");
+    public static /*const*/ string sel_respondsToSelector_1 = sel_registerName("respondsToSelector:");
+    public static /*const*/ string sel_namesOfPromisedFilesDroppedAtDestination_1 = sel_registerName("namesOfPromisedFilesDroppedAtDestination:");
+    public static /*const*/ string sel_unsignedShortValue = sel_registerName("unsignedShortValue");
+    public static /*const*/ string sel_setZeroSymbol_1 = sel_registerName("setZeroSymbol:");
+    public static /*const*/ string sel_resourcePath = sel_registerName("resourcePath");
+    public static /*const*/ string sel_markerFormat = sel_registerName("markerFormat");
+    public static /*const*/ string sel_hotSpot = sel_registerName("hotSpot");
+    public static /*const*/ string sel_imageUnfilteredPasteboardTypes = sel_registerName("imageUnfilteredPasteboardTypes");
+    public static /*const*/ string sel_editedRange = sel_registerName("editedRange");
+    public static /*const*/ string sel_setMenuChangedMessagesEnabled_1 = sel_registerName("setMenuChangedMessagesEnabled:");
+    public static /*const*/ string sel_tailIndent = sel_registerName("tailIndent");
+    public static /*const*/ string sel_release = sel_registerName("release");
+    public static /*const*/ string sel_readFromURL_1options_1documentAttributes_1 = sel_registerName("readFromURL:options:documentAttributes:");
+    public static /*const*/ string sel_underlinePosition = sel_registerName("underlinePosition");
+    public static /*const*/ string sel_setMinItemSize_1 = sel_registerName("setMinItemSize:");
+    public static /*const*/ string sel_initWithImage_1foregroundColorHint_1backgroundColorHint_1hotSpot_1 = sel_registerName("initWithImage:foregroundColorHint:backgroundColorHint:hotSpot:");
+    public static /*const*/ string sel_setPlaceholderString_1 = sel_registerName("setPlaceholderString:");
+    public static /*const*/ string sel_createDirectoryAtPath_1withIntermediateDirectories_1attributes_1error_1 = sel_registerName("createDirectoryAtPath:withIntermediateDirectories:attributes:error:");
+    public static /*const*/ string sel_setDefaultTabInterval_1 = sel_registerName("setDefaultTabInterval:");
+    public static /*const*/ string sel_invertedSet = sel_registerName("invertedSet");
+    public static /*const*/ string sel_iconForFile_1 = sel_registerName("iconForFile:");
+    public static /*const*/ string sel_modifyFont_1 = sel_registerName("modifyFont:");
+    public static /*const*/ string sel_setProcessName_1 = sel_registerName("setProcessName:");
+    public static /*const*/ string sel_addObserver_1toObjectsAtIndexes_1forKeyPath_1options_1context_1 = sel_registerName("addObserver:toObjectsAtIndexes:forKeyPath:options:context:");
+    public static /*const*/ string sel_resolve = sel_registerName("resolve");
+    public static /*const*/ string sel_namespaces = sel_registerName("namespaces");
+    public static /*const*/ string sel_drawInBezierPath_1angle_1 = sel_registerName("drawInBezierPath:angle:");
+    public static /*const*/ string sel_setPixelFormat_1 = sel_registerName("setPixelFormat:");
+    public static /*const*/ string sel_resizeUpDownCursor = sel_registerName("resizeUpDownCursor");
+    public static /*const*/ string sel_daylightSavingTimeOffsetForDate_1 = sel_registerName("daylightSavingTimeOffsetForDate:");
+    public static /*const*/ string sel_setCanSpawnSeparateThread_1 = sel_registerName("setCanSpawnSeparateThread:");
+    public static /*const*/ string sel_setTitleBaseWritingDirection_1 = sel_registerName("setTitleBaseWritingDirection:");
+    public static /*const*/ string sel_subscript_1 = sel_registerName("subscript:");
+    public static /*const*/ string sel_URL = sel_registerName("URL");
+    public static /*const*/ string sel_headerColor = sel_registerName("headerColor");
+    public static /*const*/ string sel_StringByAddingPercentEscapesUsingEncoding_1 = sel_registerName("StringByAddingPercentEscapesUsingEncoding:");
+    public static /*const*/ string sel_draggingExited_1 = sel_registerName("draggingExited:");
+    public static /*const*/ string sel_ignoreModifierKeysWhileDragging = sel_registerName("ignoreModifierKeysWhileDragging");
+    public static /*const*/ string sel_componentsToDisplayForPath_1 = sel_registerName("componentsToDisplayForPath:");
+    public static /*const*/ string sel_glyphRangeForBoundingRectWithoutAdditionalLayout_1inTextContainer_1 = sel_registerName("glyphRangeForBoundingRectWithoutAdditionalLayout:inTextContainer:");
+    public static /*const*/ string sel_removeTrackingRect_1 = sel_registerName("removeTrackingRect:");
+    public static /*const*/ string sel_handlePrintScriptCommand_1 = sel_registerName("handlePrintScriptCommand:");
+    public static /*const*/ string sel_viewDidMoveToWindow = sel_registerName("viewDidMoveToWindow");
+    public static /*const*/ string sel_allocateGState = sel_registerName("allocateGState");
+    public static /*const*/ string sel_availableStringEncodings = sel_registerName("availableStringEncodings");
+    public static /*const*/ string sel_instantiateNibWithExternalNameTable_1 = sel_registerName("instantiateNibWithExternalNameTable:");
+    public static /*const*/ string sel_setWeekdayOrdinal_1 = sel_registerName("setWeekdayOrdinal:");
+    public static /*const*/ string sel_setWithCapacity_1 = sel_registerName("setWithCapacity:");
+    public static /*const*/ string sel_setCurrentAppleEventAndReplyEventWithSuspensionID_1 = sel_registerName("setCurrentAppleEventAndReplyEventWithSuspensionID:");
+    public static /*const*/ string sel_convertFont_1toNotHaveTrait_1 = sel_registerName("convertFont:toNotHaveTrait:");
+    public static /*const*/ string sel_performSelector_1withObject_1withObject_1 = sel_registerName("performSelector:withObject:withObject:");
+    public static /*const*/ string sel_removeIndexes_1 = sel_registerName("removeIndexes:");
+    public static /*const*/ string sel_objectSpecifierWithDescriptor_1 = sel_registerName("objectSpecifierWithDescriptor:");
+    public static /*const*/ string sel_objectValue = sel_registerName("objectValue");
+    public static /*const*/ string sel_timeZone = sel_registerName("timeZone");
+    public static /*const*/ string sel_viewSizeChanged_1 = sel_registerName("viewSizeChanged:");
+    public static /*const*/ string sel_clearDrawable = sel_registerName("clearDrawable");
+    public static /*const*/ string sel_parentRowForRow_1 = sel_registerName("parentRowForRow:");
+    public static /*const*/ string sel_trackingMode = sel_registerName("trackingMode");
+    public static /*const*/ string sel_selectedRanges = sel_registerName("selectedRanges");
+    public static /*const*/ string sel_suspendExecution = sel_registerName("suspendExecution");
+    public static /*const*/ string sel_setDefaultPrinter_1 = sel_registerName("setDefaultPrinter:");
+    public static /*const*/ string sel_loadDataRepresentation_1ofType_1 = sel_registerName("loadDataRepresentation:ofType:");
+    public static /*const*/ string sel_closestTickMarkValueToValue_1 = sel_registerName("closestTickMarkValueToValue:");
+    public static /*const*/ string sel_removeFromRunLoop_1forMode_1 = sel_registerName("removeFromRunLoop:forMode:");
+    public static /*const*/ string sel_cancelUserAttentionRequest_1 = sel_registerName("cancelUserAttentionRequest:");
+    public static /*const*/ string sel_dictionaryWithObject_1forKey_1 = sel_registerName("dictionaryWithObject:forKey:");
+    public static /*const*/ string sel_isDataRetained = sel_registerName("isDataRetained");
+    public static /*const*/ string sel_setLoops_1 = sel_registerName("setLoops:");
+    public static /*const*/ string sel_hashTableWithWeakObjects = sel_registerName("hashTableWithWeakObjects");
+    public static /*const*/ string sel_documentForURL_1 = sel_registerName("documentForURL:");
+    public static /*const*/ string sel_removeRepresentation_1 = sel_registerName("removeRepresentation:");
+    public static /*const*/ string sel_keyClassDescription = sel_registerName("keyClassDescription");
+    public static /*const*/ string sel_noResponderFor_1 = sel_registerName("noResponderFor:");
+    public static /*const*/ string sel_setBidiLevels_1forGlyphRange_1 = sel_registerName("setBidiLevels:forGlyphRange:");
+    public static /*const*/ string sel_cancelIncrementalLoad = sel_registerName("cancelIncrementalLoad");
+    public static /*const*/ string sel_highlightedBranchImage = sel_registerName("highlightedBranchImage");
+    public static /*const*/ string sel_setAttributedStringForZero_1 = sel_registerName("setAttributedStringForZero:");
+    public static /*const*/ string sel_drawAtPoint_1fromRect_1operation_1fraction_1 = sel_registerName("drawAtPoint:fromRect:operation:fraction:");
+    public static /*const*/ string sel_fileHFSTypeCode = sel_registerName("fileHFSTypeCode");
+    public static /*const*/ string sel_maximumRecents = sel_registerName("maximumRecents");
+    public static /*const*/ string sel_useFont_1 = sel_registerName("useFont:");
+    public static /*const*/ string sel_selectKeyViewPrecedingView_1 = sel_registerName("selectKeyViewPrecedingView:");
+    public static /*const*/ string sel_attributedStringForNil = sel_registerName("attributedStringForNil");
+    public static /*const*/ string sel_isGrammarCheckingEnabled = sel_registerName("isGrammarCheckingEnabled");
+    public static /*const*/ string sel_owner = sel_registerName("owner");
+    public static /*const*/ string sel_searchForServicesOfType_1inDomain_1 = sel_registerName("searchForServicesOfType:inDomain:");
+    public static /*const*/ string sel_frameAutosaveName = sel_registerName("frameAutosaveName");
+    public static /*const*/ string sel_setCommands_1 = sel_registerName("setCommands:");
+    public static /*const*/ string sel_URLResourceDidCancelLoading_1 = sel_registerName("URLResourceDidCancelLoading:");
+    public static /*const*/ string sel_uniqueSpellDocumentTag = sel_registerName("uniqueSpellDocumentTag");
+    public static /*const*/ string sel_needsToBeUpdatedFromPath_1 = sel_registerName("needsToBeUpdatedFromPath:");
+    public static /*const*/ string sel_bounds = sel_registerName("bounds");
+    public static /*const*/ string sel_contextHelpForKey_1 = sel_registerName("contextHelpForKey:");
+    public static /*const*/ string sel_setSendsActionOnEndEditing_1 = sel_registerName("setSendsActionOnEndEditing:");
+    public static /*const*/ string sel_scanDouble_1 = sel_registerName("scanDouble:");
+    public static /*const*/ string sel_download_1willResumeWithResponse_1fromByte_1 = sel_registerName("download:willResumeWithResponse:fromByte:");
+    public static /*const*/ string sel_drawFromCenter_1radius_1toCenter_1radius_1options_1 = sel_registerName("drawFromCenter:radius:toCenter:radius:options:");
+    public static /*const*/ string sel_defaultFlatness = sel_registerName("defaultFlatness");
+    public static /*const*/ string sel_keepBackupFile = sel_registerName("keepBackupFile");
+    public static /*const*/ string sel_willChangeValueForKey_1 = sel_registerName("willChangeValueForKey:");
+    public static /*const*/ string sel_initWithDateFormat_1allowNaturalLanguage_1 = sel_registerName("initWithDateFormat:allowNaturalLanguage:");
+    public static /*const*/ string sel_textView_1writablePasteboardTypesForCell_1atIndex_1 = sel_registerName("textView:writablePasteboardTypesForCell:atIndex:");
+    public static /*const*/ string sel_getTIFFCompressionTypes_1count_1 = sel_registerName("getTIFFCompressionTypes:count:");
+    public static /*const*/ string sel_decodePropertyList = sel_registerName("decodePropertyList");
+    public static /*const*/ string sel_saveDocumentWithDelegate_1didSaveSelector_1contextInfo_1 = sel_registerName("saveDocumentWithDelegate:didSaveSelector:contextInfo:");
+    public static /*const*/ string sel_encodePoint_1 = sel_registerName("encodePoint:");
+    public static /*const*/ string sel_selectRow_1byExtendingSelection_1 = sel_registerName("selectRow:byExtendingSelection:");
+    public static /*const*/ string sel_preservesContentDuringLiveResize = sel_registerName("preservesContentDuringLiveResize");
+    public static /*const*/ string sel_registerUndoWithTarget_1selector_1object_1 = sel_registerName("registerUndoWithTarget:selector:object:");
+    public static /*const*/ string sel_removeCollection_1 = sel_registerName("removeCollection:");
+    public static /*const*/ string sel_nextEventMatchingMask_1 = sel_registerName("nextEventMatchingMask:");
+    public static /*const*/ string sel_getObjects_1andKeys_1 = sel_registerName("getObjects:andKeys:");
+    public static /*const*/ string sel_EPSRepresentation = sel_registerName("EPSRepresentation");
+    public static /*const*/ string sel_isModalPanel = sel_registerName("isModalPanel");
+    public static /*const*/ string sel_statusCode = sel_registerName("statusCode");
+    public static /*const*/ string sel_setCopiesOnScroll_1 = sel_registerName("setCopiesOnScroll:");
+    public static /*const*/ string sel_setHorizontalPagination_1 = sel_registerName("setHorizontalPagination:");
+    public static /*const*/ string sel_removeAllIndexes = sel_registerName("removeAllIndexes");
+    public static /*const*/ string sel_download_1didFailWithError_1 = sel_registerName("download:didFailWithError:");
+    public static /*const*/ string sel_modifierFlags = sel_registerName("modifierFlags");
+    public static /*const*/ string sel_draggedColumn = sel_registerName("draggedColumn");
+    public static /*const*/ string sel_initWithUser_1 = sel_registerName("initWithUser:");
+    public static /*const*/ string sel_setLayoutRect_1forTextBlock_1glyphRange_1 = sel_registerName("setLayoutRect:forTextBlock:glyphRange:");
+    public static /*const*/ string sel_selectionAffinity = sel_registerName("selectionAffinity");
+    public static /*const*/ string sel_beginParagraph = sel_registerName("beginParagraph");
+    public static /*const*/ string sel_runModalForTypes_1 = sel_registerName("runModalForTypes:");
+    public static /*const*/ string sel_reloadCriteria = sel_registerName("reloadCriteria");
+    public static /*const*/ string sel_PDFOperationWithView_1insideRect_1toData_1printInfo_1 = sel_registerName("PDFOperationWithView:insideRect:toData:printInfo:");
+    public static /*const*/ string sel_cellAtRow_1column_1 = sel_registerName("cellAtRow:column:");
+    public static /*const*/ string sel_selectColumn_1byExtendingSelection_1 = sel_registerName("selectColumn:byExtendingSelection:");
+    public static /*const*/ string sel_addresses = sel_registerName("addresses");
+    public static /*const*/ string sel_setCanBeVisibleOnAllSpaces_1 = sel_registerName("setCanBeVisibleOnAllSpaces:");
+    public static /*const*/ string sel_bundleForSuite_1 = sel_registerName("bundleForSuite:");
+    public static /*const*/ string sel_StringWithCharacters_1length_1 = sel_registerName("StringWithCharacters:length:");
+    public static /*const*/ string sel_dataWithContentsOfURL_1options_1error_1 = sel_registerName("dataWithContentsOfURL:options:error:");
+    public static /*const*/ string sel_isExpanded = sel_registerName("isExpanded");
+    public static /*const*/ string sel_rectForLayoutAtPoint_1inRect_1textContainer_1characterRange_1 = sel_registerName("rectForLayoutAtPoint:inRect:textContainer:characterRange:");
+    public static /*const*/ string sel_initWithXMLString_1options_1error_1 = sel_registerName("initWithXMLString:options:error:");
+    public static /*const*/ string sel_datePickerCell_1validateProposedDateValue_1timeInterval_1 = sel_registerName("datePickerCell:validateProposedDateValue:timeInterval:");
+    public static /*const*/ string sel_replaceCharactersInRange_1withRTFD_1 = sel_registerName("replaceCharactersInRange:withRTFD:");
+    public static /*const*/ string sel_setNeedsDisplay_1 = sel_registerName("setNeedsDisplay:");
+    public static /*const*/ string sel_tableViewColumnDidMove_1 = sel_registerName("tableViewColumnDidMove:");
+    public static /*const*/ string sel_printOperationWithView_1printInfo_1 = sel_registerName("printOperationWithView:printInfo:");
+    public static /*const*/ string sel_parserDidStartDocument_1 = sel_registerName("parserDidStartDocument:");
+    public static /*const*/ string sel_privateFrameworksPath = sel_registerName("privateFrameworksPath");
+    public static /*const*/ string sel_informativeText = sel_registerName("informativeText");
+    public static /*const*/ string sel_attributesAtIndex_1effectiveRange_1 = sel_registerName("attributesAtIndex:effectiveRange:");
+    public static /*const*/ string sel_rectArrayForGlyphRange_1withinSelectedGlyphRange_1inTextContainer_1rectCount_1 = sel_registerName("rectArrayForGlyphRange:withinSelectedGlyphRange:inTextContainer:rectCount:");
+    public static /*const*/ string sel_swapWithMark_1 = sel_registerName("swapWithMark:");
+    public static /*const*/ string sel_setDrawsGrid_1 = sel_registerName("setDrawsGrid:");
+    public static /*const*/ string sel_highlight_1 = sel_registerName("highlight:");
+    public static /*const*/ string sel_maximumLineHeight = sel_registerName("maximumLineHeight");
+    public static /*const*/ string sel_phonemesFromText_1 = sel_registerName("phonemesFromText:");
+    public static /*const*/ string sel_convertSize_1fromView_1 = sel_registerName("convertSize:fromView:");
+    public static /*const*/ string sel_setProperty_1withValue_1 = sel_registerName("setProperty:withValue:");
+    public static /*const*/ string sel_cookieAcceptPolicy = sel_registerName("cookieAcceptPolicy");
+    public static /*const*/ string sel_hasThousandSeparators = sel_registerName("hasThousandSeparators");
+    public static /*const*/ string sel_setTighteningFactorForTruncation_1 = sel_registerName("setTighteningFactorForTruncation:");
+    public static /*const*/ string sel_contextMenuRepresentation = sel_registerName("contextMenuRepresentation");
+    public static /*const*/ string sel_precomposedStringWithCompatibilityMapping = sel_registerName("precomposedStringWithCompatibilityMapping");
+    public static /*const*/ string sel_threadDictionary = sel_registerName("threadDictionary");
+    public static /*const*/ string sel_redoMenuTitleForUndoActionName_1 = sel_registerName("redoMenuTitleForUndoActionName:");
+    public static /*const*/ string sel_setNumberOfVisibleItems_1 = sel_registerName("setNumberOfVisibleItems:");
+    public static /*const*/ string sel_preferredLanguages = sel_registerName("preferredLanguages");
+    public static /*const*/ string sel_mouseDraggedOnCharacterIndex_1atCoordinate_1withModifier_1client_1 = sel_registerName("mouseDraggedOnCharacterIndex:atCoordinate:withModifier:client:");
+    public static /*const*/ string sel_setMultiplier_1 = sel_registerName("setMultiplier:");
+    public static /*const*/ string sel_sortedArrayUsingSelector_1 = sel_registerName("sortedArrayUsingSelector:");
+    public static /*const*/ string sel_drawInRect_1 = sel_registerName("drawInRect:");
+    public static /*const*/ string sel_reversedSortDescriptor = sel_registerName("reversedSortDescriptor");
+    public static /*const*/ string sel_setIdentifier_1 = sel_registerName("setIdentifier:");
+    public static /*const*/ string sel_systemLocale = sel_registerName("systemLocale");
+    public static /*const*/ string sel_rulerView_1didMoveMarker_1 = sel_registerName("rulerView:didMoveMarker:");
+    public static /*const*/ string sel_serviceConnectionWithName_1rootObject_1 = sel_registerName("serviceConnectionWithName:rootObject:");
+    public static /*const*/ string sel_mouseDownCanMoveWindow = sel_registerName("mouseDownCanMoveWindow");
+    public static /*const*/ string sel_setMode_1 = sel_registerName("setMode:");
+    public static /*const*/ string sel_rectOfTickMarkAtIndex_1 = sel_registerName("rectOfTickMarkAtIndex:");
+    public static /*const*/ string sel_rangeOfCharacterFromSet_1 = sel_registerName("rangeOfCharacterFromSet:");
+    public static /*const*/ string sel_pageUp_1 = sel_registerName("pageUp:");
+    public static /*const*/ string sel_sendsWholeSearchString = sel_registerName("sendsWholeSearchString");
+    public static /*const*/ string sel_selectColumnIndexes_1byExtendingSelection_1 = sel_registerName("selectColumnIndexes:byExtendingSelection:");
+    public static /*const*/ string sel_localizedCaseInsensitiveCompare_1 = sel_registerName("localizedCaseInsensitiveCompare:");
+    public static /*const*/ string sel_isEqualToString_1 = sel_registerName("isEqualToString:");
+    public static /*const*/ string sel_invalidateHashMarks = sel_registerName("invalidateHashMarks");
+    public static /*const*/ string sel_setInitialKey_1 = sel_registerName("setInitialKey:");
+    public static /*const*/ string sel_setDividerStyle_1 = sel_registerName("setDividerStyle:");
+    public static /*const*/ string sel_expressionForMinusSet_1with_1 = sel_registerName("expressionForMinusSet:with:");
+    public static /*const*/ string sel_netService_1didNotPublish_1 = sel_registerName("netService:didNotPublish:");
+    public static /*const*/ string sel_evaluatedReceivers = sel_registerName("evaluatedReceivers");
+    public static /*const*/ string sel_removeTabViewItem_1 = sel_registerName("removeTabViewItem:");
+    public static /*const*/ string sel_initWithContainerClassDescription_1containerSpecifier_1key_1index_1 = sel_registerName("initWithContainerClassDescription:containerSpecifier:key:index:");
+    public static /*const*/ string sel_predicateWithLeftExpression_1rightExpression_1customSelector_1 = sel_registerName("predicateWithLeftExpression:rightExpression:customSelector:");
+    public static /*const*/ string sel_brownColor = sel_registerName("brownColor");
+    public static /*const*/ string sel_leafKeyPathForNode_1 = sel_registerName("leafKeyPathForNode:");
+    public static /*const*/ string sel_drawBackgroundForGlyphRange_1atPoint_1 = sel_registerName("drawBackgroundForGlyphRange:atPoint:");
+    public static /*const*/ string sel_rulerView_1willSetClientView_1 = sel_registerName("rulerView:willSetClientView:");
+    public static /*const*/ string sel_className = sel_registerName("className");
+    public static /*const*/ string sel_runMode_1beforeDate_1 = sel_registerName("runMode:beforeDate:");
+    public static /*const*/ string sel_applicationShouldTerminateAfterLastWindowClosed_1 = sel_registerName("applicationShouldTerminateAfterLastWindowClosed:");
+    public static /*const*/ string sel_newDocument_1 = sel_registerName("newDocument:");
+    public static /*const*/ string sel_arrayByAddingObject_1 = sel_registerName("arrayByAddingObject:");
+    public static /*const*/ string sel_savePanel = sel_registerName("savePanel");
+    public static /*const*/ string sel_prefersTrackingUntilMouseUp = sel_registerName("prefersTrackingUntilMouseUp");
+    public static /*const*/ string sel_setLocations_1startingGlyphIndexes_1count_1forGlyphRange_1 = sel_registerName("setLocations:startingGlyphIndexes:count:forGlyphRange:");
+    public static /*const*/ string sel_setListensInForegroundOnly_1 = sel_registerName("setListensInForegroundOnly:");
+    public static /*const*/ string sel_initWithUnsignedShort_1 = sel_registerName("initWithUnsignedShort:");
+    public static /*const*/ string sel_letterCharacterSet = sel_registerName("letterCharacterSet");
+    public static /*const*/ string sel_listensInForegroundOnly = sel_registerName("listensInForegroundOnly");
+    public static /*const*/ string sel_menu_1willHighlightItem_1 = sel_registerName("menu:willHighlightItem:");
+    public static /*const*/ string sel_charactersIgnoringModifiers = sel_registerName("charactersIgnoringModifiers");
+    public static /*const*/ string sel_insertionContainer = sel_registerName("insertionContainer");
+    public static /*const*/ string sel_searchButtonRectForBounds_1 = sel_registerName("searchButtonRectForBounds:");
+    public static /*const*/ string sel_accessibilitySetValue_1forAttribute_1 = sel_registerName("accessibilitySetValue:forAttribute:");
+    public static /*const*/ string sel_setPathSeparator_1 = sel_registerName("setPathSeparator:");
+    public static /*const*/ string sel_applicationWillResignActive_1 = sel_registerName("applicationWillResignActive:");
+    public static /*const*/ string sel_scriptingIsLessThanOrEqualTo_1 = sel_registerName("scriptingIsLessThanOrEqualTo:");
+    public static /*const*/ string sel_decodeValuesOfObjCTypes_1 = sel_registerName("decodeValuesOfObjCTypes:");
+    public static /*const*/ string sel_setIntercellSpacing_1 = sel_registerName("setIntercellSpacing:");
+    public static /*const*/ string sel_sharedSystemTypesetterForBehavior_1 = sel_registerName("sharedSystemTypesetterForBehavior:");
+    public static /*const*/ string sel_drawFromPoint_1toPoint_1options_1 = sel_registerName("drawFromPoint:toPoint:options:");
+    public static /*const*/ string sel_windowDidMove_1 = sel_registerName("windowDidMove:");
+    public static /*const*/ string sel_setVisible_1 = sel_registerName("setVisible:");
+    public static /*const*/ string sel_credentialWithUser_1password_1persistence_1 = sel_registerName("credentialWithUser:password:persistence:");
+    public static /*const*/ string sel_decomposedStringWithCanonicalMapping = sel_registerName("decomposedStringWithCanonicalMapping");
+    public static /*const*/ string sel_openFile_1withApplication_1andDeactivate_1 = sel_registerName("openFile:withApplication:andDeactivate:");
+    public static /*const*/ string sel_convertRectToBase_1 = sel_registerName("convertRectToBase:");
+    public static /*const*/ string sel_outputStreamToMemory = sel_registerName("outputStreamToMemory");
+    public static /*const*/ string sel_autorepeat = sel_registerName("autorepeat");
+    public static /*const*/ string sel_servicesMenu = sel_registerName("servicesMenu");
+    public static /*const*/ string sel_beginGrouping = sel_registerName("beginGrouping");
+    public static /*const*/ string sel_setNilValueForKey_1 = sel_registerName("setNilValueForKey:");
+    public static /*const*/ string sel_usesFontLeading = sel_registerName("usesFontLeading");
+    public static /*const*/ string sel_lineFragmentRectForGlyphAtIndex_1effectiveRange_1 = sel_registerName("lineFragmentRectForGlyphAtIndex:effectiveRange:");
+    public static /*const*/ string sel_takeStringValueFrom_1 = sel_registerName("takeStringValueFrom:");
+    public static /*const*/ string sel_fontDescriptorByAddingAttributes_1 = sel_registerName("fontDescriptorByAddingAttributes:");
+    public static /*const*/ string sel_startTrackingAt_1inView_1 = sel_registerName("startTrackingAt:inView:");
+    public static /*const*/ string sel_application_1delegateHandlesKey_1 = sel_registerName("application:delegateHandlesKey:");
+    public static /*const*/ string sel_StringByExpandingTildeInPath = sel_registerName("StringByExpandingTildeInPath");
+    public static /*const*/ string sel_menu = sel_registerName("menu");
+    public static /*const*/ string sel_setMinute_1 = sel_registerName("setMinute:");
+    public static /*const*/ string sel_startSubelementIdentifier = sel_registerName("startSubelementIdentifier");
+    public static /*const*/ string sel_waitForDataInBackgroundAndNotifyForModes_1 = sel_registerName("waitForDataInBackgroundAndNotifyForModes:");
+    public static /*const*/ string sel_removeCachedResponseForRequest_1 = sel_registerName("removeCachedResponseForRequest:");
+    public static /*const*/ string sel_attributeForLocalName_1URI_1 = sel_registerName("attributeForLocalName:URI:");
+    public static /*const*/ string sel_saveDocumentAs_1 = sel_registerName("saveDocumentAs:");
+    public static /*const*/ string sel_containerIsObjectBeingTested = sel_registerName("containerIsObjectBeingTested");
+    public static /*const*/ string sel_mouseDownOnCharacterIndex_1atCoordinate_1withModifier_1client_1 = sel_registerName("mouseDownOnCharacterIndex:atCoordinate:withModifier:client:");
+    public static /*const*/ string sel_setPosition_1ofDividerAtIndex_1 = sel_registerName("setPosition:ofDividerAtIndex:");
+    public static /*const*/ string sel_terminationStatus = sel_registerName("terminationStatus");
+    public static /*const*/ string sel_imageWidth = sel_registerName("imageWidth");
+    public static /*const*/ string sel_accessoryView = sel_registerName("accessoryView");
+    public static /*const*/ string sel_outlineView_1shouldTrackCell_1forTableColumn_1item_1 = sel_registerName("outlineView:shouldTrackCell:forTableColumn:item:");
+    public static /*const*/ string sel_initWithLevelIndicatorStyle_1 = sel_registerName("initWithLevelIndicatorStyle:");
+    public static /*const*/ string sel_deltaX = sel_registerName("deltaX");
+    public static /*const*/ string sel_valueForUndefinedKey_1 = sel_registerName("valueForUndefinedKey:");
+    public static /*const*/ string sel_mainDocumentURL = sel_registerName("mainDocumentURL");
+    public static /*const*/ string sel_position = sel_registerName("position");
+    public static /*const*/ string sel_animates = sel_registerName("animates");
+    public static /*const*/ string sel_addTabViewItem_1 = sel_registerName("addTabViewItem:");
+    public static /*const*/ string sel_unlockFocus = sel_registerName("unlockFocus");
+    public static /*const*/ string sel_download_1didCreateDestination_1 = sel_registerName("download:didCreateDestination:");
+    public static /*const*/ string sel_defaults = sel_registerName("defaults");
+    public static /*const*/ string sel_viewWillDraw = sel_registerName("viewWillDraw");
+    public static /*const*/ string sel_findApplications = sel_registerName("findApplications");
+    public static /*const*/ string sel_unbind_1 = sel_registerName("unbind:");
+    public static /*const*/ string sel_positionOfGlyph_1withRelation_1toBaseGlyph_1totalAdvancement_1metricsExist_1 = sel_registerName("positionOfGlyph:withRelation:toBaseGlyph:totalAdvancement:metricsExist:");
+    public static /*const*/ string sel_isGreaterThan_1 = sel_registerName("isGreaterThan:");
+    public static /*const*/ string sel_dataWithPDFInsideRect_1 = sel_registerName("dataWithPDFInsideRect:");
+    public static /*const*/ string sel_setAttributedTitle_1 = sel_registerName("setAttributedTitle:");
+    public static /*const*/ string sel_expressionType = sel_registerName("expressionType");
+    public static /*const*/ string sel_tokenFieldCell_1shouldAddObjects_1atIndex_1 = sel_registerName("tokenFieldCell:shouldAddObjects:atIndex:");
+    public static /*const*/ string sel_removeEventHandlerForEventClass_1andEventID_1 = sel_registerName("removeEventHandlerForEventClass:andEventID:");
+    public static /*const*/ string sel_postNotification_1 = sel_registerName("postNotification:");
+    public static /*const*/ string sel_indexOfTabViewItem_1 = sel_registerName("indexOfTabViewItem:");
+    public static /*const*/ string sel_outlineView_1shouldSelectItem_1 = sel_registerName("outlineView:shouldSelectItem:");
+    public static /*const*/ string sel_setSegmentStyle_1 = sel_registerName("setSegmentStyle:");
+    public static /*const*/ string sel_stateImageRectForBounds_1 = sel_registerName("stateImageRectForBounds:");
+    public static /*const*/ string sel_setContentAspectRatio_1 = sel_registerName("setContentAspectRatio:");
+    public static /*const*/ string sel_instantiateNibWithOwner_1topLevelObjects_1 = sel_registerName("instantiateNibWithOwner:topLevelObjects:");
+    public static /*const*/ string sel_setPrototype_1 = sel_registerName("setPrototype:");
+    public static /*const*/ string sel_allowsMultipleSelection = sel_registerName("allowsMultipleSelection");
+    public static /*const*/ string sel_setRecentSearches_1 = sel_registerName("setRecentSearches:");
+    public static /*const*/ string sel_setTypingAttributes_1 = sel_registerName("setTypingAttributes:");
+    public static /*const*/ string sel_observeValueForKeyPath_1ofObject_1change_1context_1 = sel_registerName("observeValueForKeyPath:ofObject:change:context:");
+    public static /*const*/ string sel_performDragOperation_1 = sel_registerName("performDragOperation:");
+    public static /*const*/ string sel_processingInstructionWithName_1StringValue_1 = sel_registerName("processingInstructionWithName:StringValue:");
+    public static /*const*/ string sel_initWithKind_1options_1 = sel_registerName("initWithKind:options:");
+    public static /*const*/ string sel_instancesRespondToSelector_1 = sel_registerName("instancesRespondToSelector:");
+    public static /*const*/ string sel_keyEquivalentFont = sel_registerName("keyEquivalentFont");
+    public static /*const*/ string sel_calendarIdentifier = sel_registerName("calendarIdentifier");
+    public static /*const*/ string sel_source = sel_registerName("source");
+    public static /*const*/ string sel_shouldBeTreatedAsInkEvent_1 = sel_registerName("shouldBeTreatedAsInkEvent:");
+    public static /*const*/ string sel_queuePriority = sel_registerName("queuePriority");
+    public static /*const*/ string sel_autoresizesAllColumnsToFit = sel_registerName("autoresizesAllColumnsToFit");
+    public static /*const*/ string sel_outlineView_1shouldCollapseItem_1 = sel_registerName("outlineView:shouldCollapseItem:");
+    public static /*const*/ string sel_dragImage_1at_1offset_1event_1pasteboard_1source_1slideBack_1 = sel_registerName("dragImage:at:offset:event:pasteboard:source:slideBack:");
+    public static /*const*/ string sel_sender = sel_registerName("sender");
+    public static /*const*/ string sel_numberOfColumns = sel_registerName("numberOfColumns");
+    public static /*const*/ string sel_indexPathWithIndex_1 = sel_registerName("indexPathWithIndex:");
+    public static /*const*/ string sel_setPreferredFontNames_1 = sel_registerName("setPreferredFontNames:");
+    public static /*const*/ string sel_windowDidEndSheet_1 = sel_registerName("windowDidEndSheet:");
+    public static /*const*/ string sel_capHeight = sel_registerName("capHeight");
+    public static /*const*/ string sel_matchingFontDescriptorWithMandatoryKeys_1 = sel_registerName("matchingFontDescriptorWithMandatoryKeys:");
+    public static /*const*/ string sel_constize = sel_registerName("constize");
+    public static /*const*/ string sel_prepareForDragOperation_1 = sel_registerName("prepareForDragOperation:");
+    public static /*const*/ string sel_setCellAttribute_1to_1 = sel_registerName("setCellAttribute:to:");
+    public static /*const*/ string sel_metadataQuery_1replacementValueForAttribute_1value_1 = sel_registerName("metadataQuery:replacementValueForAttribute:value:");
+    public static /*const*/ string sel_hueComponent = sel_registerName("hueComponent");
+    public static /*const*/ string sel_maxValue = sel_registerName("maxValue");
+    public static /*const*/ string sel_soundUnfilteredTypes = sel_registerName("soundUnfilteredTypes");
+    public static /*const*/ string sel_setFileAttributes_1 = sel_registerName("setFileAttributes:");
+    public static /*const*/ string sel_valueLists = sel_registerName("valueLists");
+    public static /*const*/ string sel_breakLock = sel_registerName("breakLock");
+    public static /*const*/ string sel_selectCellWithTag_1 = sel_registerName("selectCellWithTag:");
+    public static /*const*/ string sel_setMovable_1 = sel_registerName("setMovable:");
+    public static /*const*/ string sel_synchronizeFile = sel_registerName("synchronizeFile");
+    public static /*const*/ string sel_setVerticallyResizable_1 = sel_registerName("setVerticallyResizable:");
+    public static /*const*/ string sel_setButtonBordered_1 = sel_registerName("setButtonBordered:");
+    public static /*const*/ string sel_useOptimizedDrawing_1 = sel_registerName("useOptimizedDrawing:");
+    public static /*const*/ string sel_tryLockWhenCondition_1 = sel_registerName("tryLockWhenCondition:");
+    public static /*const*/ string sel_textContainer = sel_registerName("textContainer");
+    public static /*const*/ string sel_setValueListAttributes_1 = sel_registerName("setValueListAttributes:");
+    public static /*const*/ string sel_rangeOfCharacterFromSet_1options_1 = sel_registerName("rangeOfCharacterFromSet:options:");
+    public static /*const*/ string sel_dragFile_1fromRect_1slideBack_1event_1 = sel_registerName("dragFile:fromRect:slideBack:event:");
+    public static /*const*/ string sel_tickMarkPosition = sel_registerName("tickMarkPosition");
+    public static /*const*/ string sel_addRunLoop_1 = sel_registerName("addRunLoop:");
+    public static /*const*/ string sel_dataWithCapacity_1 = sel_registerName("dataWithCapacity:");
+    public static /*const*/ string sel_removeVolatileDomainForName_1 = sel_registerName("removeVolatileDomainForName:");
+    public static /*const*/ string sel_signal = sel_registerName("signal");
+    public static /*const*/ string sel_progressMarks = sel_registerName("progressMarks");
+    public static /*const*/ string sel_unhide_1 = sel_registerName("unhide:");
+    public static /*const*/ string sel_provideNewButtonImage = sel_registerName("provideNewButtonImage");
+    public static /*const*/ string sel_connectionWithRegisteredName_1host_1usingNameServer_1 = sel_registerName("connectionWithRegisteredName:host:usingNameServer:");
+    public static /*const*/ string sel_localizesFormat = sel_registerName("localizesFormat");
+    public static /*const*/ string sel_lineScroll = sel_registerName("lineScroll");
+    public static /*const*/ string sel_initDirectoryWithFileWrappers_1 = sel_registerName("initDirectoryWithFileWrappers:");
+    public static /*const*/ string sel_wantsToInterpretAllKeystrokes = sel_registerName("wantsToInterpretAllKeystrokes");
+    public static /*const*/ string sel_convertPointToBase_1 = sel_registerName("convertPointToBase:");
+    public static /*const*/ string sel_keyWithAppleEventCode_1 = sel_registerName("keyWithAppleEventCode:");
+    public static /*const*/ string sel_loadSuiteWithDictionary_1fromBundle_1 = sel_registerName("loadSuiteWithDictionary:fromBundle:");
+    public static /*const*/ string sel_automaticallyPreparesContent = sel_registerName("automaticallyPreparesContent");
+    public static /*const*/ string sel_cornerRadius = sel_registerName("cornerRadius");
+    public static /*const*/ string sel_sharedScriptExecutionContext = sel_registerName("sharedScriptExecutionContext");
+    public static /*const*/ string sel_setPoolCountHighWaterResolution_1 = sel_registerName("setPoolCountHighWaterResolution:");
+    public static /*const*/ string sel_appendBezierPath_1 = sel_registerName("appendBezierPath:");
+    public static /*const*/ string sel_appleEventClassCode = sel_registerName("appleEventClassCode");
+    public static /*const*/ string sel_initTextCell_1pullsDown_1 = sel_registerName("initTextCell:pullsDown:");
+    public static /*const*/ string sel_numberOfTickMarks = sel_registerName("numberOfTickMarks");
+    public static /*const*/ string sel_setIndependentConversationQueueing_1 = sel_registerName("setIndependentConversationQueueing:");
+    public static /*const*/ string sel_extendPowerOffBy_1 = sel_registerName("extendPowerOffBy:");
+    public static /*const*/ string sel_isCollecting = sel_registerName("isCollecting");
+    public static /*const*/ string sel_canInsert = sel_registerName("canInsert");
+    public static /*const*/ string sel_valuePointerFunctions = sel_registerName("valuePointerFunctions");
+    public static /*const*/ string sel_sizeValue = sel_registerName("sizeValue");
+    public static /*const*/ string sel_openOnEdge_1 = sel_registerName("openOnEdge:");
+    public static /*const*/ string sel_rectOfItemAtIndex_1 = sel_registerName("rectOfItemAtIndex:");
+    public static /*const*/ string sel_boolForKey_1inTable_1 = sel_registerName("boolForKey:inTable:");
+    public static /*const*/ string sel_showHelp_1 = sel_registerName("showHelp:");
+    public static /*const*/ string sel_heightTracksTextView = sel_registerName("heightTracksTextView");
+    public static /*const*/ string sel_hasTitleBar = sel_registerName("hasTitleBar");
+    public static /*const*/ string sel_setViewAnimations_1 = sel_registerName("setViewAnimations:");
+    public static /*const*/ string sel_updateSpellingPanelWithGrammarString_1detail_1 = sel_registerName("updateSpellingPanelWithGrammarString:detail:");
+    public static /*const*/ string sel_showsToolbarButton = sel_registerName("showsToolbarButton");
+    public static /*const*/ string sel_environment = sel_registerName("environment");
+    public static /*const*/ string sel_matchesAppleEventCode_1 = sel_registerName("matchesAppleEventCode:");
+    public static /*const*/ string sel_hasPrefix_1 = sel_registerName("hasPrefix:");
+    public static /*const*/ string sel_hasUnappliedChanges = sel_registerName("hasUnappliedChanges");
+    public static /*const*/ string sel_setName_1 = sel_registerName("setName:");
+    public static /*const*/ string sel_isMovableByWindowBackground = sel_registerName("isMovableByWindowBackground");
+    public static /*const*/ string sel_printerNames = sel_registerName("printerNames");
+    public static /*const*/ string sel_initWithDictionary_1 = sel_registerName("initWithDictionary:");
+    public static /*const*/ string sel_StringByStandardizingPath = sel_registerName("StringByStandardizingPath");
+    public static /*const*/ string sel_usesUserKeyEquivalents = sel_registerName("usesUserKeyEquivalents");
+    public static /*const*/ string sel_drawStateImageWithFrame_1inView_1 = sel_registerName("drawStateImageWithFrame:inView:");
+    public static /*const*/ string sel_openUntitledDocumentAndDisplay_1error_1 = sel_registerName("openUntitledDocumentAndDisplay:error:");
+    public static /*const*/ string sel_lastVisibleColumn = sel_registerName("lastVisibleColumn");
+    public static /*const*/ string sel_paste_1 = sel_registerName("paste:");
+    public static /*const*/ string sel_indexOfItemWithRepresentedObject_1 = sel_registerName("indexOfItemWithRepresentedObject:");
+    public static /*const*/ string sel_supportsCommand_1 = sel_registerName("supportsCommand:");
+    public static /*const*/ string sel_scrollPageUp_1 = sel_registerName("scrollPageUp:");
+    public static /*const*/ string sel_draggedImage_1endedAt_1deposited_1 = sel_registerName("draggedImage:endedAt:deposited:");
+    public static /*const*/ string sel_setPositiveInfinitySymbol_1 = sel_registerName("setPositiveInfinitySymbol:");
+    public static /*const*/ string sel_noteFileSystemChanged_1 = sel_registerName("noteFileSystemChanged:");
+    public static /*const*/ string sel_moveRight_1 = sel_registerName("moveRight:");
+    public static /*const*/ string sel_arrowPosition = sel_registerName("arrowPosition");
+    public static /*const*/ string sel_setMenuRepresentation_1 = sel_registerName("setMenuRepresentation:");
+    public static /*const*/ string sel_endLoadInBackground = sel_registerName("endLoadInBackground");
+    public static /*const*/ string sel_smartInsertBeforeStringForString_1replacingRange_1 = sel_registerName("smartInsertBeforeStringForString:replacingRange:");
+    public static /*const*/ string sel_openUntitledDocumentOfType_1display_1 = sel_registerName("openUntitledDocumentOfType:display:");
+    public static /*const*/ string sel_scriptingValueForSpecifier_1 = sel_registerName("scriptingValueForSpecifier:");
+    public static /*const*/ string sel_setShowsSuppressionButton_1 = sel_registerName("setShowsSuppressionButton:");
+    public static /*const*/ string sel_resizeLeftCursor = sel_registerName("resizeLeftCursor");
+    public static /*const*/ string sel_setDefaultCredential_1forProtectionSpace_1 = sel_registerName("setDefaultCredential:forProtectionSpace:");
+    public static /*const*/ string sel_systemTabletID = sel_registerName("systemTabletID");
+    public static /*const*/ string sel_unlock = sel_registerName("unlock");
+    public static /*const*/ string sel_mostCompatibleStringEncoding = sel_registerName("mostCompatibleStringEncoding");
+    public static /*const*/ string sel_glyphName = sel_registerName("glyphName");
+    public static /*const*/ string sel_center = sel_registerName("center");
+    public static /*const*/ string sel_setJobTitle_1 = sel_registerName("setJobTitle:");
+    public static /*const*/ string sel_cancelButtonCell = sel_registerName("cancelButtonCell");
+    public static /*const*/ string sel_namespaceForPrefix_1 = sel_registerName("namespaceForPrefix:");
+    public static /*const*/ string sel_browserWillScroll_1 = sel_registerName("browserWillScroll:");
+    public static /*const*/ string sel_initWithCompoundTypes_1 = sel_registerName("initWithCompoundTypes:");
+    public static /*const*/ string sel_setPaddingCharacter_1 = sel_registerName("setPaddingCharacter:");
+    public static /*const*/ string sel_image_1willLoadRepresentation_1 = sel_registerName("image:willLoadRepresentation:");
+    public static /*const*/ string sel_pasteRuler_1 = sel_registerName("pasteRuler:");
+    public static /*const*/ string sel_drawGlyphsForGlyphRange_1atPoint_1 = sel_registerName("drawGlyphsForGlyphRange:atPoint:");
+    public static /*const*/ string sel_PMPrintSession = sel_registerName("PMPrintSession");
+    public static /*const*/ string sel_setDefaultButtonCell_1 = sel_registerName("setDefaultButtonCell:");
+    public static /*const*/ string sel_printerTypes = sel_registerName("printerTypes");
+    public static /*const*/ string sel_findString_1inBook_1 = sel_registerName("findString:inBook:");
+    public static /*const*/ string sel_executablePath = sel_registerName("executablePath");
+    public static /*const*/ string sel_components_1fromDate_1toDate_1options_1 = sel_registerName("components:fromDate:toDate:options:");
+    public static /*const*/ string sel_displayValuesForRow_1 = sel_registerName("displayValuesForRow:");
+    public static /*const*/ string sel_pageLayout = sel_registerName("pageLayout");
+    public static /*const*/ string sel_resizeFlags = sel_registerName("resizeFlags");
+    public static /*const*/ string sel_DTDNodeWithXMLString_1 = sel_registerName("DTDNodeWithXMLString:");
+    public static /*const*/ string sel_replyToOpenOrPrint_1 = sel_registerName("replyToOpenOrPrint:");
+    public static /*const*/ string sel_insertTab_1 = sel_registerName("insertTab:");
+    public static /*const*/ string sel_documents = sel_registerName("documents");
+    public static /*const*/ string sel_tagForSegment_1 = sel_registerName("tagForSegment:");
+    public static /*const*/ string sel_initForURL_1withContentsOfURL_1ofType_1error_1 = sel_registerName("initForURL:withContentsOfURL:ofType:error:");
+    public static /*const*/ string sel_initWithRoundingMode_1scale_1raiseOnExactness_1raiseOnOverflow_1raiseOnUnderflow_1raiseOnDivideByZero_1 = sel_registerName("initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:");
+    public static /*const*/ string sel_addIndexes_1 = sel_registerName("addIndexes:");
+    public static /*const*/ string sel_setAttributeRuns_1 = sel_registerName("setAttributeRuns:");
+    public static /*const*/ string sel_splitView_1additionalEffectiveRectOfDividerAtIndex_1 = sel_registerName("splitView:additionalEffectiveRectOfDividerAtIndex:");
+    public static /*const*/ string sel_writeSelectionToPasteboard_1type_1 = sel_registerName("writeSelectionToPasteboard:type:");
+    public static /*const*/ string sel_day = sel_registerName("day");
+    public static /*const*/ string sel_numberOfRowsInTableView_1 = sel_registerName("numberOfRowsInTableView:");
+    public static /*const*/ string sel_insertCompletion_1forPartialWordRange_1movement_1isFinal_1 = sel_registerName("insertCompletion:forPartialWordRange:movement:isFinal:");
+    public static /*const*/ string sel_notPredicateWithSubpredicate_1 = sel_registerName("notPredicateWithSubpredicate:");
+    public static /*const*/ string sel_rootProxyForConnectionWithRegisteredName_1host_1 = sel_registerName("rootProxyForConnectionWithRegisteredName:host:");
+    public static /*const*/ string sel_stopSpeakingAtBoundary_1 = sel_registerName("stopSpeakingAtBoundary:");
+    public static /*const*/ string sel_pathsMatchingExtensions_1 = sel_registerName("pathsMatchingExtensions:");
+    public static /*const*/ string sel_caseInsensitiveCompare_1 = sel_registerName("caseInsensitiveCompare:");
+    public static /*const*/ string sel_labelFontOfSize_1 = sel_registerName("labelFontOfSize:");
+    public static /*const*/ string sel_createDirectoryAtPath_1attributes_1 = sel_registerName("createDirectoryAtPath:attributes:");
+    public static /*const*/ string sel_initListDescriptor = sel_registerName("initListDescriptor");
+    public static /*const*/ string sel_setParagraphSpacing_1 = sel_registerName("setParagraphSpacing:");
+    public static /*const*/ string sel_getColor_1location_1atIndex_1 = sel_registerName("getColor:location:atIndex:");
+    public static /*const*/ string sel_pointerArrayWithOptions_1 = sel_registerName("pointerArrayWithOptions:");
+    public static /*const*/ string sel_guessesForWord_1 = sel_registerName("guessesForWord:");
+    public static /*const*/ string sel_searchTextRectForBounds_1 = sel_registerName("searchTextRectForBounds:");
+    public static /*const*/ string sel_allowsColumnReordering = sel_registerName("allowsColumnReordering");
+    public static /*const*/ string sel_isMainThread = sel_registerName("isMainThread");
+    public static /*const*/ string sel_accessibilityAttributeNames = sel_registerName("accessibilityAttributeNames");
+    public static /*const*/ string sel_saveOptions = sel_registerName("saveOptions");
+    public static /*const*/ string sel_setAutomaticallyPreparesContent_1 = sel_registerName("setAutomaticallyPreparesContent:");
+    public static /*const*/ string sel_setGridColor_1 = sel_registerName("setGridColor:");
+    public static /*const*/ string sel_textAttributesForNegativeInfinity = sel_registerName("textAttributesForNegativeInfinity");
+    public static /*const*/ string sel_decimalDigitCharacterSet = sel_registerName("decimalDigitCharacterSet");
+    public static /*const*/ string sel_removeObserver_1name_1object_1 = sel_registerName("removeObserver:name:object:");
+    public static /*const*/ string sel_columnContentWidthForColumnWidth_1 = sel_registerName("columnContentWidthForColumnWidth:");
+    public static /*const*/ string sel_wraps = sel_registerName("wraps");
+    public static /*const*/ string sel_getIndexes_1maxCount_1inIndexRange_1 = sel_registerName("getIndexes:maxCount:inIndexRange:");
+    public static /*const*/ string sel_doubleAction = sel_registerName("doubleAction");
+    public static /*const*/ string sel_layoutParagraphAtPoint_1 = sel_registerName("layoutParagraphAtPoint:");
+    public static /*const*/ string sel_cacheDisplayInRect_1toBitmapImageRep_1 = sel_registerName("cacheDisplayInRect:toBitmapImageRep:");
+    public static /*const*/ string sel_setUsesItemFromMenu_1 = sel_registerName("setUsesItemFromMenu:");
+    public static /*const*/ string sel_parserError = sel_registerName("parserError");
+    public static /*const*/ string sel_numberOfMajorTickMarks = sel_registerName("numberOfMajorTickMarks");
+    public static /*const*/ string sel_changeFont_1 = sel_registerName("changeFont:");
+    public static /*const*/ string sel_displaysWhenScreenProfileChanges = sel_registerName("displaysWhenScreenProfileChanges");
+    public static /*const*/ string sel_titleBaseWritingDirection = sel_registerName("titleBaseWritingDirection");
+    public static /*const*/ string sel_columnAtPoint_1 = sel_registerName("columnAtPoint:");
+    public static /*const*/ string sel_setAppliesImmediately_1 = sel_registerName("setAppliesImmediately:");
+    public static /*const*/ string sel_addAccessoryController_1 = sel_registerName("addAccessoryController:");
+    public static /*const*/ string sel_setEditable_1 = sel_registerName("setEditable:");
+    public static /*const*/ string sel_moveRulerlineFromLocation_1toLocation_1 = sel_registerName("moveRulerlineFromLocation:toLocation:");
+    public static /*const*/ string sel_runModal = sel_registerName("runModal");
+    public static /*const*/ string sel_selectionShouldChangeInTableView_1 = sel_registerName("selectionShouldChangeInTableView:");
+    public static /*const*/ string sel_dragSelectionWithEvent_1offset_1slideBack_1 = sel_registerName("dragSelectionWithEvent:offset:slideBack:");
+    public static /*const*/ string sel_rootProxy = sel_registerName("rootProxy");
+    public static /*const*/ string sel_brightnessComponent = sel_registerName("brightnessComponent");
+    public static /*const*/ string sel_setLabel_1forSegment_1 = sel_registerName("setLabel:forSegment:");
+    public static /*const*/ string sel_copy = sel_registerName("copy");
+    public static /*const*/ string sel_helpRequested_1 = sel_registerName("helpRequested:");
+    public static /*const*/ string sel_setThreadPriority_1 = sel_registerName("setThreadPriority:");
+    public static /*const*/ string sel_minContentSize = sel_registerName("minContentSize");
+    public static /*const*/ string sel_setShowsProgressPanel_1 = sel_registerName("setShowsProgressPanel:");
+    public static /*const*/ string sel_setMessageText_1 = sel_registerName("setMessageText:");
+    public static /*const*/ string sel_setLayoutAlgorithm_1 = sel_registerName("setLayoutAlgorithm:");
+    public static /*const*/ string sel_setInContext_1 = sel_registerName("setInContext:");
+    public static /*const*/ string sel_resultCount = sel_registerName("resultCount");
+    public static /*const*/ string sel_usesDataSource = sel_registerName("usesDataSource");
+    public static /*const*/ string sel_textLists = sel_registerName("textLists");
+    public static /*const*/ string sel_setSelectedRange_1affinity_1stillSelecting_1 = sel_registerName("setSelectedRange:affinity:stillSelecting:");
+    public static /*const*/ string sel_shouldResolveExternalEntities = sel_registerName("shouldResolveExternalEntities");
+    public static /*const*/ string sel_clientView = sel_registerName("clientView");
+    public static /*const*/ string sel_styleMask = sel_registerName("styleMask");
+    public static /*const*/ string sel_setCurrencyCode_1 = sel_registerName("setCurrencyCode:");
+    public static /*const*/ string sel_methodReturnType = sel_registerName("methodReturnType");
+    public static /*const*/ string sel_dataUsingEncoding_1 = sel_registerName("dataUsingEncoding:");
+    public static /*const*/ string sel_removeTabStop_1 = sel_registerName("removeTabStop:");
+    public static /*const*/ string sel_reloadItem_1reloadChildren_1 = sel_registerName("reloadItem:reloadChildren:");
+    public static /*const*/ string sel_ancestorSharedWithView_1 = sel_registerName("ancestorSharedWithView:");
+    public static /*const*/ string sel_indexLessThanOrEqualToIndex_1 = sel_registerName("indexLessThanOrEqualToIndex:");
+    public static /*const*/ string sel_removeAllActionsWithTarget_1 = sel_registerName("removeAllActionsWithTarget:");
+    public static /*const*/ string sel_subtype = sel_registerName("subtype");
+    public static /*const*/ string sel_imageRectForPaper_1 = sel_registerName("imageRectForPaper:");
+    public static /*const*/ string sel_initWithWindow_1rect_1 = sel_registerName("initWithWindow:rect:");
+    public static /*const*/ string sel_enable = sel_registerName("enable");
+    public static /*const*/ string sel_scanInteger_1 = sel_registerName("scanInteger:");
+    public static /*const*/ string sel_initWithContentsOfURL_1encoding_1error_1 = sel_registerName("initWithContentsOfURL:encoding:error:");
+    public static /*const*/ string sel_removeObjectIdenticalTo_1 = sel_registerName("removeObjectIdenticalTo:");
+    public static /*const*/ string sel_createTexture_1fromView_1internalFormat_1 = sel_registerName("createTexture:fromView:internalFormat:");
+    public static /*const*/ string sel_decimalNumberByRaisingToPower_1withBehavior_1 = sel_registerName("decimalNumberByRaisingToPower:withBehavior:");
+    public static /*const*/ string sel_appendBezierPathWithArcWithCenter_1radius_1startAngle_1endAngle_1 = sel_registerName("appendBezierPathWithArcWithCenter:radius:startAngle:endAngle:");
+    public static /*const*/ string sel_fontPanel_1 = sel_registerName("fontPanel:");
+    public static /*const*/ string sel_predicateWithSubpredicates_1 = sel_registerName("predicateWithSubpredicates:");
+    public static /*const*/ string sel_layoutGlyphsInLayoutManager_1startingAtGlyphIndex_1maxNumberOfLineFragments_1nextGlyphIndex_1 = sel_registerName("layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:");
+    public static /*const*/ string sel_attributes = sel_registerName("attributes");
+    public static /*const*/ string sel_EPSOperationWithView_1insideRect_1toData_1 = sel_registerName("EPSOperationWithView:insideRect:toData:");
+    public static /*const*/ string sel_listOptions = sel_registerName("listOptions");
+    public static /*const*/ string sel_windowWillLoad = sel_registerName("windowWillLoad");
+    public static /*const*/ string sel_alwaysShowsDecimalSeparator = sel_registerName("alwaysShowsDecimalSeparator");
+    public static /*const*/ string sel_replyToApplicationShouldTerminate_1 = sel_registerName("replyToApplicationShouldTerminate:");
+    public static /*const*/ string sel_setThousandSeparator_1 = sel_registerName("setThousandSeparator:");
+    public static /*const*/ string sel_insertObject_1atArrangedObjectIndexPath_1 = sel_registerName("insertObject:atArrangedObjectIndexPath:");
+    public static /*const*/ string sel_cleanUpOperation = sel_registerName("cleanUpOperation");
+    public static /*const*/ string sel_trackMouse_1inRect_1ofView_1untilMouseUp_1 = sel_registerName("trackMouse:inRect:ofView:untilMouseUp:");
+    public static /*const*/ string sel_replaceLayoutManager_1 = sel_registerName("replaceLayoutManager:");
+    public static /*const*/ string sel_isPartialStringValid_1proposedSelectedRange_1originalString_1originalSelectedRange_1errorDescription_1 = sel_registerName("isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:");
+    public static /*const*/ string sel_setNegativeFormat_1 = sel_registerName("setNegativeFormat:");
+    public static /*const*/ string sel_copyFont_1 = sel_registerName("copyFont:");
+    public static /*const*/ string sel_outlineView_1sortDescriptorsDidChange_1 = sel_registerName("outlineView:sortDescriptorsDidChange:");
+    public static /*const*/ string sel_StringWithString_1 = sel_registerName("StringWithString:");
+    public static /*const*/ string sel_valueWithUniqueID_1inPropertyWithKey_1 = sel_registerName("valueWithUniqueID:inPropertyWithKey:");
+    public static /*const*/ string sel_setHighlightsBy_1 = sel_registerName("setHighlightsBy:");
+    public static /*const*/ string sel_setContinuousSpellCheckingEnabled_1 = sel_registerName("setContinuousSpellCheckingEnabled:");
+    public static /*const*/ string sel_isMouseCoalescingEnabled = sel_registerName("isMouseCoalescingEnabled");
+    public static /*const*/ string sel_numberOfSelectedColumns = sel_registerName("numberOfSelectedColumns");
+    public static /*const*/ string sel_spellServer_1findMisspelledWordInString_1language_1wordCount_1countOnly_1 = sel_registerName("spellServer:findMisspelledWordInString:language:wordCount:countOnly:");
+    public static /*const*/ string sel_PMPageFormat = sel_registerName("PMPageFormat");
+    public static /*const*/ string sel_insertText_1client_1 = sel_registerName("insertText:client:");
+    public static /*const*/ string sel_numberWithFloat_1 = sel_registerName("numberWithFloat:");
+    public static /*const*/ string sel_compositeToPoint_1fromRect_1operation_1 = sel_registerName("compositeToPoint:fromRect:operation:");
+    public static /*const*/ string sel_numberOfPlanes = sel_registerName("numberOfPlanes");
+    public static /*const*/ string sel_childrenKeyPath = sel_registerName("childrenKeyPath");
+    public static /*const*/ string sel_countForObject_1 = sel_registerName("countForObject:");
+    public static /*const*/ string sel_fontWithName_1matrix_1 = sel_registerName("fontWithName:matrix:");
+    public static /*const*/ string sel_toolbarAllowedItemIdentifiers_1 = sel_registerName("toolbarAllowedItemIdentifiers:");
+    public static /*const*/ string sel_makeDocumentWithContentsOfURL_1ofType_1 = sel_registerName("makeDocumentWithContentsOfURL:ofType:");
+    public static /*const*/ string sel_initWithHTML_1options_1documentAttributes_1 = sel_registerName("initWithHTML:options:documentAttributes:");
+    public static /*const*/ string sel_fileSystemRepresentation = sel_registerName("fileSystemRepresentation");
+    public static /*const*/ string sel_viewAnimations = sel_registerName("viewAnimations");
+    public static /*const*/ string sel_tabletProximity_1 = sel_registerName("tabletProximity:");
+    public static /*const*/ string sel_replacementClassForClass_1 = sel_registerName("replacementClassForClass:");
+    public static /*const*/ string sel_columnWidthForColumnContentWidth_1 = sel_registerName("columnWidthForColumnContentWidth:");
+    public static /*const*/ string sel_undoMenuItemTitle = sel_registerName("undoMenuItemTitle");
+    public static /*const*/ string sel_expressionForAggregate_1 = sel_registerName("expressionForAggregate:");
+    public static /*const*/ string sel_useStoredAccessor = sel_registerName("useStoredAccessor");
+    public static /*const*/ string sel_ensureAttributesAreFixedInRange_1 = sel_registerName("ensureAttributesAreFixedInRange:");
+    public static /*const*/ string sel_StringForType_1 = sel_registerName("StringForType:");
+    public static /*const*/ string sel_setLeaf_1 = sel_registerName("setLeaf:");
+    public static /*const*/ string sel_URLFromPasteboard_1 = sel_registerName("URLFromPasteboard:");
+    public static /*const*/ string sel_initWithURL_1byReference_1 = sel_registerName("initWithURL:byReference:");
+    public static /*const*/ string sel_readToEndOfFileInBackgroundAndNotify = sel_registerName("readToEndOfFileInBackgroundAndNotify");
+    public static /*const*/ string sel_application_1openFileWithoutUI_1 = sel_registerName("application:openFileWithoutUI:");
+    public static /*const*/ string sel_performClick_1 = sel_registerName("performClick:");
+    public static /*const*/ string sel_completes = sel_registerName("completes");
+    public static /*const*/ string sel_setRulersVisible_1 = sel_registerName("setRulersVisible:");
+    public static /*const*/ string sel_minimumSize = sel_registerName("minimumSize");
+    public static /*const*/ string sel_setProperty_1forKey_1inRequest_1 = sel_registerName("setProperty:forKey:inRequest:");
+    public static /*const*/ string sel_isCopyingOperation = sel_registerName("isCopyingOperation");
+    public static /*const*/ string sel_allowsTickMarkValuesOnly = sel_registerName("allowsTickMarkValuesOnly");
+    public static /*const*/ string sel_insertGlyphs_1length_1forStartingGlyphAtIndex_1characterIndex_1 = sel_registerName("insertGlyphs:length:forStartingGlyphAtIndex:characterIndex:");
+    public static /*const*/ string sel_convertFont_1 = sel_registerName("convertFont:");
+    public static /*const*/ string sel_setNegativePrefix_1 = sel_registerName("setNegativePrefix:");
+    public static /*const*/ string sel_dispatch = sel_registerName("dispatch");
+    public static /*const*/ string sel_makeNewConnection_1sender_1 = sel_registerName("makeNewConnection:sender:");
+    public static /*const*/ string sel_writeToFile_1atomically_1encoding_1error_1 = sel_registerName("writeToFile:atomically:encoding:error:");
+    public static /*const*/ string sel_isHiddenOrHasHiddenAncestor = sel_registerName("isHiddenOrHasHiddenAncestor");
+    public static /*const*/ string sel_endEditingFor_1 = sel_registerName("endEditingFor:");
+    public static /*const*/ string sel_acceptConnectionInBackgroundAndNotify = sel_registerName("acceptConnectionInBackgroundAndNotify");
+    public static /*const*/ string sel_setValue_1forHTTPHeaderField_1 = sel_registerName("setValue:forHTTPHeaderField:");
+    public static /*const*/ string sel_intersectSet_1 = sel_registerName("intersectSet:");
+    public static /*const*/ string sel_tabView_1shouldSelectTabViewItem_1 = sel_registerName("tabView:shouldSelectTabViewItem:");
+    public static /*const*/ string sel_mouseDragged_1 = sel_registerName("mouseDragged:");
+    public static /*const*/ string sel_dataFromRange_1documentAttributes_1error_1 = sel_registerName("dataFromRange:documentAttributes:error:");
+    public static /*const*/ string sel_sharedFrameworksPath = sel_registerName("sharedFrameworksPath");
+    public static /*const*/ string sel_tableView_1writeRowsWithIndexes_1toPasteboard_1 = sel_registerName("tableView:writeRowsWithIndexes:toPasteboard:");
+    public static /*const*/ string sel_setWindowFrameForAttachingToRect_1onScreen_1preferredEdge_1popUpSelectedItem_1 = sel_registerName("setWindowFrameForAttachingToRect:onScreen:preferredEdge:popUpSelectedItem:");
+    public static /*const*/ string sel_valueAtIndex_1inPropertyWithKey_1 = sel_registerName("valueAtIndex:inPropertyWithKey:");
+    public static /*const*/ string sel_setDisplaysLinkToolTips_1 = sel_registerName("setDisplaysLinkToolTips:");
+    public static /*const*/ string sel_removeObserver_1forKeyPath_1 = sel_registerName("removeObserver:forKeyPath:");
+    public static /*const*/ string sel_hasAlpha = sel_registerName("hasAlpha");
+    public static /*const*/ string sel_scrollCellToVisibleAtRow_1column_1 = sel_registerName("scrollCellToVisibleAtRow:column:");
+    public static /*const*/ string sel_activateIgnoringOtherApps_1 = sel_registerName("activateIgnoringOtherApps:");
+    public static /*const*/ string sel_getArgumentTypeAtIndex_1 = sel_registerName("getArgumentTypeAtIndex:");
+    public static /*const*/ string sel_textShouldEndEditing_1 = sel_registerName("textShouldEndEditing:");
+    public static /*const*/ string sel_nextEventMatchingMask_1untilDate_1inMode_1dequeue_1 = sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:");
+    public static /*const*/ string sel_timeIntervalSince1970 = sel_registerName("timeIntervalSince1970");
+    public static /*const*/ string sel_decimalNumberBySubtracting_1 = sel_registerName("decimalNumberBySubtracting:");
+    public static /*const*/ string sel_sendBeforeDate_1 = sel_registerName("sendBeforeDate:");
+    public static /*const*/ string sel_autohidesScrollers = sel_registerName("autohidesScrollers");
+    public static /*const*/ string sel_controlPointBounds = sel_registerName("controlPointBounds");
+    public static /*const*/ string sel_setMinimumSignificantDigits_1 = sel_registerName("setMinimumSignificantDigits:");
+    public static /*const*/ string sel_setDestination_1allowOverwrite_1 = sel_registerName("setDestination:allowOverwrite:");
+    public static /*const*/ string sel_setTransparent_1 = sel_registerName("setTransparent:");
+    public static /*const*/ string sel_decodeArrayOfObjCType_1count_1at_1 = sel_registerName("decodeArrayOfObjCType:count:at:");
+    public static /*const*/ string sel_isMiniaturized = sel_registerName("isMiniaturized");
+    public static /*const*/ string sel_setAlignment_1 = sel_registerName("setAlignment:");
+    public static /*const*/ string sel_setCornerRadius_1 = sel_registerName("setCornerRadius:");
+    public static /*const*/ string sel_foregroundColor = sel_registerName("foregroundColor");
+    public static /*const*/ string sel_lineFragmentUsedRectForGlyphAtIndex_1effectiveRange_1 = sel_registerName("lineFragmentUsedRectForGlyphAtIndex:effectiveRange:");
+    public static /*const*/ string sel_attributedSubStringFromRange_1 = sel_registerName("attributedSubStringFromRange:");
+    public static /*const*/ string sel_isSubsetOfSet_1 = sel_registerName("isSubsetOfSet:");
+    public static /*const*/ string sel_iconForFileType_1 = sel_registerName("iconForFileType:");
+    public static /*const*/ string sel_readFromURL_1ofType_1 = sel_registerName("readFromURL:ofType:");
+    public static /*const*/ string sel_decodeBytesForKey_1returnedLength_1 = sel_registerName("decodeBytesForKey:returnedLength:");
+    public static /*const*/ string sel_parser_1foundInternalEntityDeclarationWithName_1value_1 = sel_registerName("parser:foundInternalEntityDeclarationWithName:value:");
+    public static /*const*/ string sel_commonPrefixWithString_1options_1 = sel_registerName("commonPrefixWithString:options:");
+    public static /*const*/ string sel_tableView_1setObjectValue_1forTableColumn_1row_1 = sel_registerName("tableView:setObjectValue:forTableColumn:row:");
+    public static /*const*/ string sel_fileWrapperRepresentationOfType_1 = sel_registerName("fileWrapperRepresentationOfType:");
+    public static /*const*/ string sel_representedFilename = sel_registerName("representedFilename");
+    public static /*const*/ string sel_eventWithCGEvent_1 = sel_registerName("eventWithCGEvent:");
+    public static /*const*/ string sel_setFileURL_1 = sel_registerName("setFileURL:");
+    public static /*const*/ string sel_loadWindow = sel_registerName("loadWindow");
+    public static /*const*/ string sel_defaultLineJoinStyle = sel_registerName("defaultLineJoinStyle");
+    public static /*const*/ string sel_backingLocation = sel_registerName("backingLocation");
+    public static /*const*/ string sel_matrix = sel_registerName("matrix");
+    public static /*const*/ string sel_isEqualToTimeZone_1 = sel_registerName("isEqualToTimeZone:");
+    public static /*const*/ string sel_statistics = sel_registerName("statistics");
+    public static /*const*/ string sel_launchAppWithBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifier_1 = sel_registerName("launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:");
+    public static /*const*/ string sel_isHorizontal = sel_registerName("isHorizontal");
+    public static /*const*/ string sel_launchPath = sel_registerName("launchPath");
+    public static /*const*/ string sel_setTextAlignment_1 = sel_registerName("setTextAlignment:");
+    public static /*const*/ string sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bytesPerRow_1bitsPerPixel_1 = sel_registerName("initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:");
+    public static /*const*/ string sel_setPatternPhase_1 = sel_registerName("setPatternPhase:");
+    public static /*const*/ string sel_mouseEntered_1withFrame_1inView_1 = sel_registerName("mouseEntered:withFrame:inView:");
+    public static /*const*/ string sel_matchingFontDescriptorsWithMandatoryKeys_1 = sel_registerName("matchingFontDescriptorsWithMandatoryKeys:");
+    public static /*const*/ string sel_objectDidEndEditing_1 = sel_registerName("objectDidEndEditing:");
+    public static /*const*/ string sel_setMaximum_1 = sel_registerName("setMaximum:");
+    public static /*const*/ string sel_initWithIndexes_1length_1 = sel_registerName("initWithIndexes:length:");
+    public static /*const*/ string sel_tableView_1shouldShowCellExpansionForTableColumn_1row_1 = sel_registerName("tableView:shouldShowCellExpansionForTableColumn:row:");
+    public static /*const*/ string sel_moveToPoint_1 = sel_registerName("moveToPoint:");
+    public static /*const*/ string sel_setGridStyleMask_1 = sel_registerName("setGridStyleMask:");
+    public static /*const*/ string sel_firstUnlaidGlyphIndex = sel_registerName("firstUnlaidGlyphIndex");
+    public static /*const*/ string sel_isProxy = sel_registerName("isProxy");
+    public static /*const*/ string sel_takeValue_1forKeyPath_1 = sel_registerName("takeValue:forKeyPath:");
+    public static /*const*/ string sel_drawCellAtRow_1column_1 = sel_registerName("drawCellAtRow:column:");
+    public static /*const*/ string sel_setRulerViewClass_1 = sel_registerName("setRulerViewClass:");
+    public static /*const*/ string sel_objectByApplyingXSLT_1arguments_1error_1 = sel_registerName("objectByApplyingXSLT:arguments:error:");
+    public static /*const*/ string sel_setArrowPosition_1 = sel_registerName("setArrowPosition:");
+    public static /*const*/ string sel_setCharacterIndex_1forGlyphAtIndex_1 = sel_registerName("setCharacterIndex:forGlyphAtIndex:");
+    public static /*const*/ string sel_willChangeValueForKey_1withSetMutation_1usingObjects_1 = sel_registerName("willChangeValueForKey:withSetMutation:usingObjects:");
+    public static /*const*/ string sel_setVerticalRulerView_1 = sel_registerName("setVerticalRulerView:");
+    public static /*const*/ string sel_suspendCurrentAppleEvent = sel_registerName("suspendCurrentAppleEvent");
+    public static /*const*/ string sel_drawStatusBarBackgroundInRect_1withHighlight_1 = sel_registerName("drawStatusBarBackgroundInRect:withHighlight:");
+    public static /*const*/ string sel_performClickWithFrame_1inView_1 = sel_registerName("performClickWithFrame:inView:");
+    public static /*const*/ string sel_coveredCharacterSet = sel_registerName("coveredCharacterSet");
+    public static /*const*/ string sel_browser_1numberOfRowsInColumn_1 = sel_registerName("browser:numberOfRowsInColumn:");
+    public static /*const*/ string sel_isLike_1 = sel_registerName("isLike:");
+    public static /*const*/ string sel_blackComponent = sel_registerName("blackComponent");
+    public static /*const*/ string sel_appendBezierPathWithGlyph_1inFont_1 = sel_registerName("appendBezierPathWithGlyph:inFont:");
+    public static /*const*/ string sel_validateMenuItem_1 = sel_registerName("validateMenuItem:");
+    public static /*const*/ string sel_isEqualToIndexSet_1 = sel_registerName("isEqualToIndexSet:");
+    public static /*const*/ string sel_setBezelStyle_1 = sel_registerName("setBezelStyle:");
+    public static /*const*/ string sel_scaleUnitSquareToSize_1 = sel_registerName("scaleUnitSquareToSize:");
+    public static /*const*/ string sel_setStartSubelementIndex_1 = sel_registerName("setStartSubelementIndex:");
+    public static /*const*/ string sel_frameOfInsideOfColumn_1 = sel_registerName("frameOfInsideOfColumn:");
+    public static /*const*/ string sel_setBlocksOtherRecognizers_1 = sel_registerName("setBlocksOtherRecognizers:");
+    public static /*const*/ string sel_setMinSize_1 = sel_registerName("setMinSize:");
+    public static /*const*/ string sel_setEndSubelementIndex_1 = sel_registerName("setEndSubelementIndex:");
+    public static /*const*/ string sel_cStringLength = sel_registerName("cStringLength");
+    public static /*const*/ string sel_writeWithBackupToFile_1ofType_1saveOperation_1 = sel_registerName("writeWithBackupToFile:ofType:saveOperation:");
+    public static /*const*/ string sel_setDefaultButtonTitle_1 = sel_registerName("setDefaultButtonTitle:");
+    public static /*const*/ string sel_setMinContentSize_1 = sel_registerName("setMinContentSize:");
+    public static /*const*/ string sel_setFormattingDictionary_1 = sel_registerName("setFormattingDictionary:");
+    public static /*const*/ string sel_boundingRectForFont = sel_registerName("boundingRectForFont");
+    public static /*const*/ string sel_postsBoundsChangedNotifications = sel_registerName("postsBoundsChangedNotifications");
+    public static /*const*/ string sel_setParagraphs_1 = sel_registerName("setParagraphs:");
+    public static /*const*/ string sel_setShowsControlCharacters_1 = sel_registerName("setShowsControlCharacters:");
+    public static /*const*/ string sel_writeSafelyToURL_1ofType_1forSaveOperation_1error_1 = sel_registerName("writeSafelyToURL:ofType:forSaveOperation:error:");
+    public static /*const*/ string sel_controlLightHighlightColor = sel_registerName("controlLightHighlightColor");
+    public static /*const*/ string sel_objectSpecifier = sel_registerName("objectSpecifier");
+    public static /*const*/ string sel_dictionaryWithContentsOfURL_1 = sel_registerName("dictionaryWithContentsOfURL:");
+    public static /*const*/ string sel_performSelector_1onThread_1withObject_1waitUntilDone_1modes_1 = sel_registerName("performSelector:onThread:withObject:waitUntilDone:modes:");
+    public static /*const*/ string sel_setJobStyleHint_1 = sel_registerName("setJobStyleHint:");
+    public static /*const*/ string sel_sortedArrayUsingFunction_1context_1 = sel_registerName("sortedArrayUsingFunction:context:");
+    public static /*const*/ string sel_setBoundsRect_1forTextBlock_1glyphRange_1 = sel_registerName("setBoundsRect:forTextBlock:glyphRange:");
+    public static /*const*/ string sel_hasShadow = sel_registerName("hasShadow");
+    public static /*const*/ string sel_windowShouldClose_1 = sel_registerName("windowShouldClose:");
+    public static /*const*/ string sel_defaultTokenizingCharacterSet = sel_registerName("defaultTokenizingCharacterSet");
+    public static /*const*/ string sel_isRulerVisible = sel_registerName("isRulerVisible");
+    public static /*const*/ string sel_setSubrowsKeyPath_1 = sel_registerName("setSubrowsKeyPath:");
+    public static /*const*/ string sel_animationDelay = sel_registerName("animationDelay");
+    public static /*const*/ string sel_selectAll_1 = sel_registerName("selectAll:");
+    public static /*const*/ string sel_parser_1foundNotationDeclarationWithName_1publicID_1systemID_1 = sel_registerName("parser:foundNotationDeclarationWithName:publicID:systemID:");
+    public static /*const*/ string sel_readSelectionFromPasteboard_1 = sel_registerName("readSelectionFromPasteboard:");
+    public static /*const*/ string sel_validateAndReturnError_1 = sel_registerName("validateAndReturnError:");
+    public static /*const*/ string sel_setScriptErrorOffendingObjectDescriptor_1 = sel_registerName("setScriptErrorOffendingObjectDescriptor:");
+    public static /*const*/ string sel_makeKeyWindow = sel_registerName("makeKeyWindow");
+    public static /*const*/ string sel_itemAtIndex_1 = sel_registerName("itemAtIndex:");
+    public static /*const*/ string sel_objectAtIndex_1 = sel_registerName("objectAtIndex:");
+    public static /*const*/ string sel_protectionSpace = sel_registerName("protectionSpace");
+    public static /*const*/ string sel_getCString_1 = sel_registerName("getCString:");
+    public static /*const*/ string sel_initSymbolicLinkWithDestination_1 = sel_registerName("initSymbolicLinkWithDestination:");
+    public static /*const*/ string sel_daylightSavingTimeOffset = sel_registerName("daylightSavingTimeOffset");
+    public static /*const*/ string sel_rangeOfTextList_1atIndex_1 = sel_registerName("rangeOfTextList:atIndex:");
+    public static /*const*/ string sel_currentDirectory = sel_registerName("currentDirectory");
+    public static /*const*/ string sel_windowControllerDidLoadNib_1 = sel_registerName("windowControllerDidLoadNib:");
+    public static /*const*/ string sel_setGroupingSize_1 = sel_registerName("setGroupingSize:");
+    public static /*const*/ string sel_subitems = sel_registerName("subitems");
+    public static /*const*/ string sel_initWithFileWrapper_1 = sel_registerName("initWithFileWrapper:");
+    public static /*const*/ string sel_documentVisibleRect = sel_registerName("documentVisibleRect");
+    public static /*const*/ string sel_setCount_1 = sel_registerName("setCount:");
+    public static /*const*/ string sel_setScriptErrorExpectedTypeDescriptor_1 = sel_registerName("setScriptErrorExpectedTypeDescriptor:");
+    public static /*const*/ string sel_setReleasedWhenClosed_1 = sel_registerName("setReleasedWhenClosed:");
+    public static /*const*/ string sel_imageUnfilteredTypes = sel_registerName("imageUnfilteredTypes");
+    public static /*const*/ string sel_writeToFile_1options_1error_1 = sel_registerName("writeToFile:options:error:");
+    public static /*const*/ string sel_controlContentFontOfSize_1 = sel_registerName("controlContentFontOfSize:");
+    public static /*const*/ string sel_insertRow_1withCells_1 = sel_registerName("insertRow:withCells:");
+    public static /*const*/ string sel_temporaryAttributesAtCharacterIndex_1effectiveRange_1 = sel_registerName("temporaryAttributesAtCharacterIndex:effectiveRange:");
+    public static /*const*/ string sel_stepForward_1 = sel_registerName("stepForward:");
+    public static /*const*/ string sel_convertScreenToBase_1 = sel_registerName("convertScreenToBase:");
+    public static /*const*/ string sel_printerWithType_1 = sel_registerName("printerWithType:");
+    public static /*const*/ string sel_setSliderType_1 = sel_registerName("setSliderType:");
+    public static /*const*/ string sel_applicationShouldHandleReopen_1hasVisibleWindows_1 = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");
+    public static /*const*/ string sel_selectedTextAttributes = sel_registerName("selectedTextAttributes");
+    public static /*const*/ string sel_setStandardError_1 = sel_registerName("setStandardError:");
+    public static /*const*/ string sel_drawRect_1 = sel_registerName("drawRect:");
+    public static /*const*/ string sel_URLs = sel_registerName("URLs");
+    public static /*const*/ string sel_animationForKey_1 = sel_registerName("animationForKey:");
+    public static /*const*/ string sel_setSubviews_1 = sel_registerName("setSubviews:");
+    public static /*const*/ string sel_setString_1 = sel_registerName("setString:");
+    public static /*const*/ string sel_openFile_1fromImage_1at_1inView_1 = sel_registerName("openFile:fromImage:at:inView:");
+    public static /*const*/ string sel_draggedImage = sel_registerName("draggedImage");
+    public static /*const*/ string sel_numberOfGlyphs = sel_registerName("numberOfGlyphs");
+    public static /*const*/ string sel_itemAtRow_1 = sel_registerName("itemAtRow:");
+    public static /*const*/ string sel_drawKnob = sel_registerName("drawKnob");
+    public static /*const*/ string sel_imageRepsWithData_1 = sel_registerName("imageRepsWithData:");
+    public static /*const*/ string sel_dragOperationForDraggingInfo_1type_1 = sel_registerName("dragOperationForDraggingInfo:type:");
+    public static /*const*/ string sel_initWithRTF_1documentAttributes_1 = sel_registerName("initWithRTF:documentAttributes:");
+    public static /*const*/ string sel_pathsForResourcesOfType_1inDirectory_1 = sel_registerName("pathsForResourcesOfType:inDirectory:");
+    public static /*const*/ string sel_fontName = sel_registerName("fontName");
+    public static /*const*/ string sel_layoutManagers = sel_registerName("layoutManagers");
+    public static /*const*/ string sel_error = sel_registerName("error");
+    public static /*const*/ string sel_parentWindow = sel_registerName("parentWindow");
+    public static /*const*/ string sel_registerClass_1 = sel_registerName("registerClass:");
+    public static /*const*/ string sel_hideOtherApplications = sel_registerName("hideOtherApplications");
+    public static /*const*/ string sel_alphaComponent = sel_registerName("alphaComponent");
+    public static /*const*/ string sel_setPrefersColorMatch_1 = sel_registerName("setPrefersColorMatch:");
+    public static /*const*/ string sel_stopAnimation_1 = sel_registerName("stopAnimation:");
+    public static /*const*/ string sel_glyphIndexForCharacterAtIndex_1 = sel_registerName("glyphIndexForCharacterAtIndex:");
+    public static /*const*/ string sel_rulerView_1shouldAddMarker_1 = sel_registerName("rulerView:shouldAddMarker:");
+    public static /*const*/ string sel_initWithFrame_1 = sel_registerName("initWithFrame:");
+    public static /*const*/ string sel_init = sel_registerName("init");
+    public static /*const*/ string sel_selectedColumnEnumerator = sel_registerName("selectedColumnEnumerator");
+    public static /*const*/ string sel_viewWithTag_1 = sel_registerName("viewWithTag:");
+    public static /*const*/ string sel_classForKeyedUnarchiver = sel_registerName("classForKeyedUnarchiver");
+    public static /*const*/ string sel_addRow_1 = sel_registerName("addRow:");
+    public static /*const*/ string sel_contextHelpForObject_1 = sel_registerName("contextHelpForObject:");
+    public static /*const*/ string sel_server = sel_registerName("server");
+    public static /*const*/ string sel_colorUsingColorSpaceName_1device_1 = sel_registerName("colorUsingColorSpaceName:device:");
+    public static /*const*/ string sel_valueTransformerForName_1 = sel_registerName("valueTransformerForName:");
+    public static /*const*/ string sel_soundUnfilteredFileTypes = sel_registerName("soundUnfilteredFileTypes");
+    public static /*const*/ string sel_setSelectedTextAttributes_1 = sel_registerName("setSelectedTextAttributes:");
+    public static /*const*/ string sel_setLeadingOffset_1 = sel_registerName("setLeadingOffset:");
+    public static /*const*/ string sel_scrollToPoint_1 = sel_registerName("scrollToPoint:");
+    public static /*const*/ string sel_lastPathComponent = sel_registerName("lastPathComponent");
+    public static /*const*/ string sel_lossyCString = sel_registerName("lossyCString");
+    public static /*const*/ string sel_registerServicesMenuSendTypes_1returnTypes_1 = sel_registerName("registerServicesMenuSendTypes:returnTypes:");
+    public static /*const*/ string sel_keyDown_1 = sel_registerName("keyDown:");
+    public static /*const*/ string sel_setWidthTracksTextView_1 = sel_registerName("setWidthTracksTextView:");
+    public static /*const*/ string sel_incrementBy_1 = sel_registerName("incrementBy:");
+    public static /*const*/ string sel_moveWordForward_1 = sel_registerName("moveWordForward:");
+    public static /*const*/ string sel_dataWithContentsOfMappedFile_1 = sel_registerName("dataWithContentsOfMappedFile:");
+    public static /*const*/ string sel_socket = sel_registerName("socket");
+    public static /*const*/ string sel_EPSOperationWithView_1insideRect_1toData_1printInfo_1 = sel_registerName("EPSOperationWithView:insideRect:toData:printInfo:");
+    public static /*const*/ string sel_width = sel_registerName("width");
+    public static /*const*/ string sel_capabilityMask = sel_registerName("capabilityMask");
+    public static /*const*/ string sel_setBezeled_1 = sel_registerName("setBezeled:");
+    public static /*const*/ string sel_currentMode = sel_registerName("currentMode");
+    public static /*const*/ string sel_sliderType = sel_registerName("sliderType");
+    public static /*const*/ string sel_fileIsAppendOnly = sel_registerName("fileIsAppendOnly");
+    public static /*const*/ string sel_isAutomaticLinkDetectionEnabled = sel_registerName("isAutomaticLinkDetectionEnabled");
+    public static /*const*/ string sel_setBoundsOrigin_1 = sel_registerName("setBoundsOrigin:");
+    public static /*const*/ string sel_selectionHighlightStyle = sel_registerName("selectionHighlightStyle");
+    public static /*const*/ string sel_registerName_1 = sel_registerName("registerName:");
+    public static /*const*/ string sel_moveWordRightAndModifySelection_1 = sel_registerName("moveWordRightAndModifySelection:");
+    public static /*const*/ string sel_setCharacters_1 = sel_registerName("setCharacters:");
+    public static /*const*/ string sel_setWordFieldStringValue_1 = sel_registerName("setWordFieldStringValue:");
+    public static /*const*/ string sel_reverseObjectEnumerator = sel_registerName("reverseObjectEnumerator");
+    public static /*const*/ string sel_encodeByrefObject_1 = sel_registerName("encodeByrefObject:");
+    public static /*const*/ string sel_defaultDecimalNumberHandler = sel_registerName("defaultDecimalNumberHandler");
+    public static /*const*/ string sel_isEntryAcceptable_1 = sel_registerName("isEntryAcceptable:");
+    public static /*const*/ string sel_orderWindow_1relativeTo_1 = sel_registerName("orderWindow:relativeTo:");
+    public static /*const*/ string sel_writablePasteboardTypes = sel_registerName("writablePasteboardTypes");
+    public static /*const*/ string sel_addTrackingRect_1owner_1userData_1assumeInside_1 = sel_registerName("addTrackingRect:owner:userData:assumeInside:");
+    public static /*const*/ string sel_setPathComponentCells_1 = sel_registerName("setPathComponentCells:");
+    public static /*const*/ string sel_timeZoneWithName_1 = sel_registerName("timeZoneWithName:");
+    public static /*const*/ string sel_setAutosaveTableColumns_1 = sel_registerName("setAutosaveTableColumns:");
+    public static /*const*/ string sel_orPredicateWithSubpredicates_1 = sel_registerName("orPredicateWithSubpredicates:");
+    public static /*const*/ string sel_isEqualToDictionary_1 = sel_registerName("isEqualToDictionary:");
+    public static /*const*/ string sel_bottomMargin = sel_registerName("bottomMargin");
+    public static /*const*/ string sel_initWithYear_1month_1day_1hour_1minute_1second_1timeZone_1 = sel_registerName("initWithYear:month:day:hour:minute:second:timeZone:");
+    public static /*const*/ string sel_scrollColumnsLeftBy_1 = sel_registerName("scrollColumnsLeftBy:");
+    public static /*const*/ string sel_initWithContentsOfURL_1error_1 = sel_registerName("initWithContentsOfURL:error:");
+    public static /*const*/ string sel_setTabViewType_1 = sel_registerName("setTabViewType:");
+    public static /*const*/ string sel_initWithFloat_1 = sel_registerName("initWithFloat:");
+    public static /*const*/ string sel_attributedStringForObjectValue_1withDefaultAttributes_1 = sel_registerName("attributedStringForObjectValue:withDefaultAttributes:");
+    public static /*const*/ string sel_sharedGlyphGenerator = sel_registerName("sharedGlyphGenerator");
+    public static /*const*/ string sel_maximumRangeOfUnit_1 = sel_registerName("maximumRangeOfUnit:");
+    public static /*const*/ string sel_docFormatFromRange_1documentAttributes_1 = sel_registerName("docFormatFromRange:documentAttributes:");
+    public static /*const*/ string sel_initWithBitmapImageRep_1 = sel_registerName("initWithBitmapImageRep:");
+    public static /*const*/ string sel_mnemonic = sel_registerName("mnemonic");
+    public static /*const*/ string sel_prefersColorMatch = sel_registerName("prefersColorMatch");
+    public static /*const*/ string sel_fileSystemAttributesAtPath_1 = sel_registerName("fileSystemAttributesAtPath:");
+    public static /*const*/ string sel_rotateByRadians_1 = sel_registerName("rotateByRadians:");
+    public static /*const*/ string sel_createConversationForConnection_1 = sel_registerName("createConversationForConnection:");
+    public static /*const*/ string sel_setWindow_1 = sel_registerName("setWindow:");
+    public static /*const*/ string sel_addFontDescriptors_1toCollection_1 = sel_registerName("addFontDescriptors:toCollection:");
+    public static /*const*/ string sel_setMark_1 = sel_registerName("setMark:");
+    public static /*const*/ string sel_terminate = sel_registerName("terminate");
+    public static /*const*/ string sel_setTickMarkPosition_1 = sel_registerName("setTickMarkPosition:");
+    public static /*const*/ string sel_setIgnoresMouseEvents_1 = sel_registerName("setIgnoresMouseEvents:");
+    public static /*const*/ string sel_pointerArrayWithStrongObjects = sel_registerName("pointerArrayWithStrongObjects");
+    public static /*const*/ string sel_intersectsHashTable_1 = sel_registerName("intersectsHashTable:");
+    public static /*const*/ string sel_initWithTransform_1 = sel_registerName("initWithTransform:");
+    public static /*const*/ string sel_deviceRGBColorSpace = sel_registerName("deviceRGBColorSpace");
+    public static /*const*/ string sel_currentDiskUsage = sel_registerName("currentDiskUsage");
+    public static /*const*/ string sel_writeToFile_1ofType_1 = sel_registerName("writeToFile:ofType:");
+    public static /*const*/ string sel_unionSet_1 = sel_registerName("unionSet:");
+    public static /*const*/ string sel_bitmapFormat = sel_registerName("bitmapFormat");
+    public static /*const*/ string sel_moveItemAtPath_1toPath_1error_1 = sel_registerName("moveItemAtPath:toPath:error:");
+    public static /*const*/ string sel_tableView = sel_registerName("tableView");
+    public static /*const*/ string sel_performSelectorOnMainThread_1withObject_1waitUntilDone_1modes_1 = sel_registerName("performSelectorOnMainThread:withObject:waitUntilDone:modes:");
+    public static /*const*/ string sel_initAndTestWithTests_1 = sel_registerName("initAndTestWithTests:");
+    public static /*const*/ string sel_setVerticalMotionCanBeginDrag_1 = sel_registerName("setVerticalMotionCanBeginDrag:");
+    public static /*const*/ string sel_documentClassNames = sel_registerName("documentClassNames");
+    public static /*const*/ string sel_setShadow_1 = sel_registerName("setShadow:");
+    public static /*const*/ string sel_beginLineWithGlyphAtIndex_1 = sel_registerName("beginLineWithGlyphAtIndex:");
+    public static /*const*/ string sel_predicateWithSubstitutionVariables_1 = sel_registerName("predicateWithSubstitutionVariables:");
+    public static /*const*/ string sel_EPSOperationWithView_1insideRect_1toPath_1printInfo_1 = sel_registerName("EPSOperationWithView:insideRect:toPath:printInfo:");
+    public static /*const*/ string sel_startSubelementIndex = sel_registerName("startSubelementIndex");
+    public static /*const*/ string sel_sleepUntilDate_1 = sel_registerName("sleepUntilDate:");
+    public static /*const*/ string sel_menuForEvent_1 = sel_registerName("menuForEvent:");
+    public static /*const*/ string sel_disabledControlTextColor = sel_registerName("disabledControlTextColor");
+    public static /*const*/ string sel_addRegularFileWithContents_1preferredFilename_1 = sel_registerName("addRegularFileWithContents:preferredFilename:");
+    public static /*const*/ string sel_setTakesTitleFromPreviousColumn_1 = sel_registerName("setTakesTitleFromPreviousColumn:");
+    public static /*const*/ string sel_removeSelectionIndexes_1 = sel_registerName("removeSelectionIndexes:");
+    public static /*const*/ string sel_resizedColumn = sel_registerName("resizedColumn");
+    public static /*const*/ string sel_host = sel_registerName("host");
+    public static /*const*/ string sel_setDefaultAttachmentScaling_1 = sel_registerName("setDefaultAttachmentScaling:");
+    public static /*const*/ string sel_boundingRectWithSize_1options_1 = sel_registerName("boundingRectWithSize:options:");
+    public static /*const*/ string sel_magentaColor = sel_registerName("magentaColor");
+    public static /*const*/ string sel_performDefaultImplementation = sel_registerName("performDefaultImplementation");
+    public static /*const*/ string sel_getPeriodicDelay_1interval_1 = sel_registerName("getPeriodicDelay:interval:");
+    public static /*const*/ string sel_RTFFromRange_1 = sel_registerName("RTFFromRange:");
+    public static /*const*/ string sel_setStringValue_1 = sel_registerName("setStringValue:");
+    public static /*const*/ string sel_setPaletteLabel_1 = sel_registerName("setPaletteLabel:");
+    public static /*const*/ string sel_years_1months_1days_1hours_1minutes_1seconds_1sinceDate_1 = sel_registerName("years:months:days:hours:minutes:seconds:sinceDate:");
+    public static /*const*/ string sel_initWithFormat_1arguments_1 = sel_registerName("initWithFormat:arguments:");
+    public static /*const*/ string sel_firstUnlaidCharacterIndex = sel_registerName("firstUnlaidCharacterIndex");
+    public static /*const*/ string sel_panelSelectionDidChange_1 = sel_registerName("panelSelectionDidChange:");
+    public static /*const*/ string sel_typesFilterableTo_1 = sel_registerName("typesFilterableTo:");
+    public static /*const*/ string sel_selectPreviousTabViewItem_1 = sel_registerName("selectPreviousTabViewItem:");
+    public static /*const*/ string sel_URLProtocol_1didReceiveResponse_1cacheStoragePolicy_1 = sel_registerName("URLProtocol:didReceiveResponse:cacheStoragePolicy:");
+    public static /*const*/ string sel_loadView = sel_registerName("loadView");
+    public static /*const*/ string sel_setPositiveSuffix_1 = sel_registerName("setPositiveSuffix:");
+    public static /*const*/ string sel_setSizeMode_1 = sel_registerName("setSizeMode:");
+    public static /*const*/ string sel_addValue_1forHTTPHeaderField_1 = sel_registerName("addValue:forHTTPHeaderField:");
+    public static /*const*/ string sel_replacementObjectForPortCoder_1 = sel_registerName("replacementObjectForPortCoder:");
+    public static /*const*/ string sel_cycleToNextInputLanguage_1 = sel_registerName("cycleToNextInputLanguage:");
+    public static /*const*/ string sel_setContentMinSize_1 = sel_registerName("setContentMinSize:");
+    public static /*const*/ string sel_convertWeight_1ofFont_1 = sel_registerName("convertWeight:ofFont:");
+    public static /*const*/ string sel_code = sel_registerName("code");
+    public static /*const*/ string sel_TIFFRepresentationUsingCompression_1factor_1 = sel_registerName("TIFFRepresentationUsingCompression:factor:");
+    public static /*const*/ string sel_setSelector_1 = sel_registerName("setSelector:");
+    public static /*const*/ string sel_URLHandleResourceDidCancelLoading_1 = sel_registerName("URLHandleResourceDidCancelLoading:");
+    public static /*const*/ string sel_setTag_1forSegment_1 = sel_registerName("setTag:forSegment:");
+    public static /*const*/ string sel_viewFrameChanged_1 = sel_registerName("viewFrameChanged:");
+    public static /*const*/ string sel_attachmentCell = sel_registerName("attachmentCell");
+    public static /*const*/ string sel_removeStatusItem_1 = sel_registerName("removeStatusItem:");
+    public static /*const*/ string sel_pathForAuxiliaryExecutable_1 = sel_registerName("pathForAuxiliaryExecutable:");
+    public static /*const*/ string sel_fileURL = sel_registerName("fileURL");
+    public static /*const*/ string sel_drawerShouldOpen_1 = sel_registerName("drawerShouldOpen:");
+    public static /*const*/ string sel_initForWritingWithMutableData_1 = sel_registerName("initForWritingWithMutableData:");
+    public static /*const*/ string sel_content = sel_registerName("content");
+    public static /*const*/ string sel_addSubview_1 = sel_registerName("addSubview:");
+    public static /*const*/ string sel_StringByReplacingOccurrencesOfString_1withString_1 = sel_registerName("StringByReplacingOccurrencesOfString:withString:");
+    public static /*const*/ string sel_StringWithFileSystemRepresentation_1length_1 = sel_registerName("StringWithFileSystemRepresentation:length:");
+    public static /*const*/ string sel_isVerticallyCentered = sel_registerName("isVerticallyCentered");
+    public static /*const*/ string sel_setVerticallyCentered_1 = sel_registerName("setVerticallyCentered:");
+    public static /*const*/ string sel_selectPrevious_1 = sel_registerName("selectPrevious:");
+    public static /*const*/ string sel_addTemporaryAttributes_1forCharacterRange_1 = sel_registerName("addTemporaryAttributes:forCharacterRange:");
+    public static /*const*/ string sel_tabState = sel_registerName("tabState");
+    public static /*const*/ string sel_defaultQueue = sel_registerName("defaultQueue");
+    public static /*const*/ string sel_showsControlCharacters = sel_registerName("showsControlCharacters");
+    public static /*const*/ string sel_indexOfObject_1 = sel_registerName("indexOfObject:");
+    public static /*const*/ string sel_shadow = sel_registerName("shadow");
+    public static /*const*/ string sel_fontMenu_1 = sel_registerName("fontMenu:");
+    public static /*const*/ string sel_movePath_1toPath_1handler_1 = sel_registerName("movePath:toPath:handler:");
+    public static /*const*/ string sel_setDictionary_1 = sel_registerName("setDictionary:");
+    public static /*const*/ string sel_verticalLineScroll = sel_registerName("verticalLineScroll");
+    public static /*const*/ string sel_showsAlpha = sel_registerName("showsAlpha");
+    public static /*const*/ string sel_removeObserver_1 = sel_registerName("removeObserver:");
+    public static /*const*/ string sel_isFieldEditor = sel_registerName("isFieldEditor");
+    public static /*const*/ string sel_fileHandleForWriting = sel_registerName("fileHandleForWriting");
+    public static /*const*/ string sel_contentsAtPath_1 = sel_registerName("contentsAtPath:");
+    public static /*const*/ string sel_writeProperty_1forKey_1 = sel_registerName("writeProperty:forKey:");
+    public static /*const*/ string sel_drawWithRect_1options_1attributes_1 = sel_registerName("drawWithRect:options:attributes:");
+    public static /*const*/ string sel_initWithName_1 = sel_registerName("initWithName:");
+    public static /*const*/ string sel_getFileSystemInfoForPath_1isRemovable_1isWritable_1isUnmountable_1description_1type_1 = sel_registerName("getFileSystemInfoForPath:isRemovable:isWritable:isUnmountable:description:type:");
+    public static /*const*/ string sel_setOpenGLContext_1 = sel_registerName("setOpenGLContext:");
+    public static /*const*/ string sel_hasSubmenu = sel_registerName("hasSubmenu");
+    public static /*const*/ string sel_rangeOfTextTable_1atIndex_1 = sel_registerName("rangeOfTextTable:atIndex:");
+    public static /*const*/ string sel_connection_1willCacheResponse_1 = sel_registerName("connection:willCacheResponse:");
+    public static /*const*/ string sel_automaticallyRearrangesObjects = sel_registerName("automaticallyRearrangesObjects");
+    public static /*const*/ string sel_registerCommandDescription_1 = sel_registerName("registerCommandDescription:");
+    public static /*const*/ string sel_indexOfSelectedItem = sel_registerName("indexOfSelectedItem");
+    public static /*const*/ string sel_underline_1 = sel_registerName("underline:");
+    public static /*const*/ string sel_beginModalSessionForWindow_1relativeToWindow_1 = sel_registerName("beginModalSessionForWindow:relativeToWindow:");
+    public static /*const*/ string sel_initWithData_1options_1documentAttributes_1error_1 = sel_registerName("initWithData:options:documentAttributes:error:");
+    public static /*const*/ string sel_revert_1 = sel_registerName("revert:");
+    public static /*const*/ string sel_displayableSubpredicatesOfPredicate_1 = sel_registerName("displayableSubpredicatesOfPredicate:");
+    public static /*const*/ string sel_dataWithData_1 = sel_registerName("dataWithData:");
+    public static /*const*/ string sel_scaleXBy_1yBy_1 = sel_registerName("scaleXBy:yBy:");
+    public static /*const*/ string sel_decodeBoolForKey_1 = sel_registerName("decodeBoolForKey:");
+    public static /*const*/ string sel_itemTitles = sel_registerName("itemTitles");
+    public static /*const*/ string sel_removeFontDescriptor_1fromCollection_1 = sel_registerName("removeFontDescriptor:fromCollection:");
+    public static /*const*/ string sel_isContinuousSpellCheckingEnabled = sel_registerName("isContinuousSpellCheckingEnabled");
+    public static /*const*/ string sel_paragraphSpacingBeforeGlyphAtIndex_1withProposedLineFragmentRect_1 = sel_registerName("paragraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:");
+    public static /*const*/ string sel_ignoreSpelling_1 = sel_registerName("ignoreSpelling:");
+    public static /*const*/ string sel_crosshairCursor = sel_registerName("crosshairCursor");
+    public static /*const*/ string sel_setSelected_1 = sel_registerName("setSelected:");
+    public static /*const*/ string sel_RTFDFromRange_1 = sel_registerName("RTFDFromRange:");
+    public static /*const*/ string sel_setCanSelectHiddenExtension_1 = sel_registerName("setCanSelectHiddenExtension:");
+    public static /*const*/ string sel_setNestingMode_1 = sel_registerName("setNestingMode:");
+    public static /*const*/ string sel_addItemsWithObjectValues_1 = sel_registerName("addItemsWithObjectValues:");
+    public static /*const*/ string sel_setContentFilters_1 = sel_registerName("setContentFilters:");
+    public static /*const*/ string sel_setAutorepeat_1 = sel_registerName("setAutorepeat:");
+    public static /*const*/ string sel_resizeWithOldSuperviewSize_1 = sel_registerName("resizeWithOldSuperviewSize:");
+    public static /*const*/ string sel_areCursorRectsEnabled = sel_registerName("areCursorRectsEnabled");
+    public static /*const*/ string sel_browser_1selectCellWithString_1inColumn_1 = sel_registerName("browser:selectCellWithString:inColumn:");
+    public static /*const*/ string sel_setLastColumn_1 = sel_registerName("setLastColumn:");
+    public static /*const*/ string sel_isContextHelpModeActive = sel_registerName("isContextHelpModeActive");
+    public static /*const*/ string sel_setTitleColor_1 = sel_registerName("setTitleColor:");
+    public static /*const*/ string sel_initWithBytes_1length_1 = sel_registerName("initWithBytes:length:");
+    public static /*const*/ string sel_animation_1valueForProgress_1 = sel_registerName("animation:valueForProgress:");
+    public static /*const*/ string sel_fillColor = sel_registerName("fillColor");
+    public static /*const*/ string sel_completionsForPartialWordRange_1inString_1language_1inSpellDocumentWithTag_1 = sel_registerName("completionsForPartialWordRange:inString:language:inSpellDocumentWithTag:");
+    public static /*const*/ string sel_typeForContentsOfURL_1error_1 = sel_registerName("typeForContentsOfURL:error:");
+    public static /*const*/ string sel_setShowPanels_1 = sel_registerName("setShowPanels:");
+    public static /*const*/ string sel_outlineView_1dataCellForTableColumn_1item_1 = sel_registerName("outlineView:dataCellForTableColumn:item:");
+    public static /*const*/ string sel_setLineJoinStyle_1 = sel_registerName("setLineJoinStyle:");
+    public static /*const*/ string sel_cancelPerformSelectorsWithTarget_1 = sel_registerName("cancelPerformSelectorsWithTarget:");
+    public static /*const*/ string sel_nextDaylightSavingTimeTransition = sel_registerName("nextDaylightSavingTimeTransition");
+    public static /*const*/ string sel_setEndSubelementIdentifier_1 = sel_registerName("setEndSubelementIdentifier:");
+    public static /*const*/ string sel_channelMapping = sel_registerName("channelMapping");
+    public static /*const*/ string sel_setTitle_1ofColumn_1 = sel_registerName("setTitle:ofColumn:");
+    public static /*const*/ string sel_setHeaderToolTip_1 = sel_registerName("setHeaderToolTip:");
+    public static /*const*/ string sel_initWithChar_1 = sel_registerName("initWithChar:");
+    public static /*const*/ string sel_shouldReportNamespacePrefixes = sel_registerName("shouldReportNamespacePrefixes");
+    public static /*const*/ string sel_decomposedStringWithCompatibilityMapping = sel_registerName("decomposedStringWithCompatibilityMapping");
+    public static /*const*/ string sel_undoActionName = sel_registerName("undoActionName");
+    public static /*const*/ string sel_attachColorList_1 = sel_registerName("attachColorList:");
+    public static /*const*/ string sel_cancelPreviousPerformRequestsWithTarget_1 = sel_registerName("cancelPreviousPerformRequestsWithTarget:");
+    public static /*const*/ string sel_addToolTipRect_1owner_1userData_1 = sel_registerName("addToolTipRect:owner:userData:");
+    public static /*const*/ string sel_isOptionalArgumentWithName_1 = sel_registerName("isOptionalArgumentWithName:");
+    public static /*const*/ string sel_fileHandleForReading = sel_registerName("fileHandleForReading");
+    public static /*const*/ string sel_removeConnection_1fromRunLoop_1forMode_1 = sel_registerName("removeConnection:fromRunLoop:forMode:");
+    public static /*const*/ string sel_controlTextDidBeginEditing_1 = sel_registerName("controlTextDidBeginEditing:");
+    public static /*const*/ string sel_closePath = sel_registerName("closePath");
+    public static /*const*/ string sel_isPlaying = sel_registerName("isPlaying");
+    public static /*const*/ string sel_matrixClass = sel_registerName("matrixClass");
+    public static /*const*/ string sel_doCommandBySelector_1client_1 = sel_registerName("doCommandBySelector:client:");
+    public static /*const*/ string sel_appendBytes_1length_1 = sel_registerName("appendBytes:length:");
+    public static /*const*/ string sel_lightGrayColor = sel_registerName("lightGrayColor");
+    public static /*const*/ string sel_menuRepresentation = sel_registerName("menuRepresentation");
+    public static /*const*/ string sel_dateWithString_1calendarFormat_1 = sel_registerName("dateWithString:calendarFormat:");
+    public static /*const*/ string sel_decodeClassName_1asClassName_1 = sel_registerName("decodeClassName:asClassName:");
+    public static /*const*/ string sel_deleteToBeginningOfParagraph_1 = sel_registerName("deleteToBeginningOfParagraph:");
+    public static /*const*/ string sel_runModalForDirectory_1file_1 = sel_registerName("runModalForDirectory:file:");
+    public static /*const*/ string sel_inverseForRelationshipKey_1 = sel_registerName("inverseForRelationshipKey:");
+    public static /*const*/ string sel_cancelLoadInBackground = sel_registerName("cancelLoadInBackground");
+    public static /*const*/ string sel_setLeftMargin_1 = sel_registerName("setLeftMargin:");
+    public static /*const*/ string sel_tabStopType = sel_registerName("tabStopType");
+    public static /*const*/ string sel_replaceCharactersInRange_1withRTF_1 = sel_registerName("replaceCharactersInRange:withRTF:");
+    public static /*const*/ string sel_drawInRect_1fromRect_1operation_1fraction_1 = sel_registerName("drawInRect:fromRect:operation:fraction:");
+    public static /*const*/ string sel_sound = sel_registerName("sound");
+    public static /*const*/ string sel_localizedRecoverySuggestion = sel_registerName("localizedRecoverySuggestion");
+    public static /*const*/ string sel_getInputStream_1outputStream_1 = sel_registerName("getInputStream:outputStream:");
+    public static /*const*/ string sel_defaultType = sel_registerName("defaultType");
+    public static /*const*/ string sel_sharedFontPanel = sel_registerName("sharedFontPanel");
+    public static /*const*/ string sel_fixParagraphStyleAttributeInRange_1 = sel_registerName("fixParagraphStyleAttributeInRange:");
+    public static /*const*/ string sel_textColor = sel_registerName("textColor");
+    public static /*const*/ string sel_noteFileSystemChanged = sel_registerName("noteFileSystemChanged");
+    public static /*const*/ string sel_setObject_1forKey_1 = sel_registerName("setObject:forKey:");
+    public static /*const*/ string sel_drawAtPoint_1 = sel_registerName("drawAtPoint:");
+    public static /*const*/ string sel_tableView_1shouldSelectTableColumn_1 = sel_registerName("tableView:shouldSelectTableColumn:");
+    public static /*const*/ string sel_deleteWordBackward_1 = sel_registerName("deleteWordBackward:");
+    public static /*const*/ string sel_pipe = sel_registerName("pipe");
+    public static /*const*/ string sel_resetStandardUserDefaults = sel_registerName("resetStandardUserDefaults");
+    public static /*const*/ string sel_orderFrontSpacingPanel_1 = sel_registerName("orderFrontSpacingPanel:");
+    public static /*const*/ string sel_setUsesFontPanel_1 = sel_registerName("setUsesFontPanel:");
+    public static /*const*/ string sel_saveToURL_1ofType_1forSaveOperation_1delegate_1didSaveSelector_1contextInfo_1 = sel_registerName("saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:");
+    public static /*const*/ string sel_linkPath_1toPath_1handler_1 = sel_registerName("linkPath:toPath:handler:");
+    public static /*const*/ string sel_addTimeInterval_1 = sel_registerName("addTimeInterval:");
+    public static /*const*/ string sel_formattingDictionary = sel_registerName("formattingDictionary");
+    public static /*const*/ string sel_ignoresMultiClick = sel_registerName("ignoresMultiClick");
+    public static /*const*/ string sel_encodeValuesOfObjCTypes_1 = sel_registerName("encodeValuesOfObjCTypes:");
+    public static /*const*/ string sel_indexAtPosition_1 = sel_registerName("indexAtPosition:");
+    public static /*const*/ string sel_autoresizesSubviews = sel_registerName("autoresizesSubviews");
+    public static /*const*/ string sel_takesTitleFromPreviousColumn = sel_registerName("takesTitleFromPreviousColumn");
+    public static /*const*/ string sel_titlePosition = sel_registerName("titlePosition");
+    public static /*const*/ string sel_currentAppleEvent = sel_registerName("currentAppleEvent");
+    public static /*const*/ string sel_valueForDimension_1 = sel_registerName("valueForDimension:");
+    public static /*const*/ string sel_printDocumentWithSettings_1showPrintPanel_1delegate_1didPrintSelector_1contextInfo_1 = sel_registerName("printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:");
+    public static /*const*/ string sel_isZoomable = sel_registerName("isZoomable");
+    public static /*const*/ string sel_setNeedsDisplay = sel_registerName("setNeedsDisplay");
+    public static /*const*/ string sel_initWithColors_1 = sel_registerName("initWithColors:");
+    public static /*const*/ string sel_isSubclassOfClass_1 = sel_registerName("isSubclassOfClass:");
+    public static /*const*/ string sel_adobeRGB1998ColorSpace = sel_registerName("adobeRGB1998ColorSpace");
+    public static /*const*/ string sel_textView_1willChangeSelectionFromCharacterRange_1toCharacterRange_1 = sel_registerName("textView:willChangeSelectionFromCharacterRange:toCharacterRange:");
+    public static /*const*/ string sel_useAllLigatures_1 = sel_registerName("useAllLigatures:");
+    public static /*const*/ string sel_setFrameUsingName_1force_1 = sel_registerName("setFrameUsingName:force:");
+    public static /*const*/ string sel_percentSymbol = sel_registerName("percentSymbol");
+    public static /*const*/ string sel_addRepresentations_1 = sel_registerName("addRepresentations:");
+    public static /*const*/ string sel_writeEPSInsideRect_1toPasteboard_1 = sel_registerName("writeEPSInsideRect:toPasteboard:");
+    public static /*const*/ string sel_systemFontSize = sel_registerName("systemFontSize");
+    public static /*const*/ string sel_canRemoveAllRows = sel_registerName("canRemoveAllRows");
+    public static /*const*/ string sel_endLineWithGlyphRange_1 = sel_registerName("endLineWithGlyphRange:");
+    public static /*const*/ string sel_maxItemSize = sel_registerName("maxItemSize");
+    public static /*const*/ string sel_setImageScaling_1forSegment_1 = sel_registerName("setImageScaling:forSegment:");
+    public static /*const*/ string sel_reloadDefaultFontFamilies = sel_registerName("reloadDefaultFontFamilies");
+    public static /*const*/ string sel_removeRow_1 = sel_registerName("removeRow:");
+    public static /*const*/ string sel_contentSize = sel_registerName("contentSize");
+    public static /*const*/ string sel_setValueTransformer_1forName_1 = sel_registerName("setValueTransformer:forName:");
+    public static /*const*/ string sel_defaultCStringEncoding = sel_registerName("defaultCStringEncoding");
+    public static /*const*/ string sel_setMaxNumberOfRows_1 = sel_registerName("setMaxNumberOfRows:");
+    public static /*const*/ string sel_continueWithoutCredentialForAuthenticationChallenge_1 = sel_registerName("continueWithoutCredentialForAuthenticationChallenge:");
+    public static /*const*/ string sel_encodeArrayOfObjCType_1count_1at_1 = sel_registerName("encodeArrayOfObjCType:count:at:");
+    public static /*const*/ string sel_tabStops = sel_registerName("tabStops");
+    public static /*const*/ string sel_altIncrementValue = sel_registerName("altIncrementValue");
+    public static /*const*/ string sel_removeAttribute_1range_1 = sel_registerName("removeAttribute:range:");
+    public static /*const*/ string sel_rightExpressionAttributeType = sel_registerName("rightExpressionAttributeType");
+    public static /*const*/ string sel_setAutoresizesAllColumnsToFit_1 = sel_registerName("setAutoresizesAllColumnsToFit:");
+    public static /*const*/ string sel_removeAllToolTips = sel_registerName("removeAllToolTips");
+    public static /*const*/ string sel_setNotANumberSymbol_1 = sel_registerName("setNotANumberSymbol:");
+    public static /*const*/ string sel_setMinWidth_1 = sel_registerName("setMinWidth:");
+    public static /*const*/ string sel_setDefaultTimeZone_1 = sel_registerName("setDefaultTimeZone:");
+    public static /*const*/ string sel_setTabStops_1 = sel_registerName("setTabStops:");
+    public static /*const*/ string sel_textView_1draggedCell_1inRect_1event_1 = sel_registerName("textView:draggedCell:inRect:event:");
+    public static /*const*/ string sel_PDFOperationWithView_1insideRect_1toData_1 = sel_registerName("PDFOperationWithView:insideRect:toData:");
+    public static /*const*/ string sel_outlineView_1selectionIndexesForProposedSelection_1 = sel_registerName("outlineView:selectionIndexesForProposedSelection:");
+    public static /*const*/ string sel_initWithContentsOfURL_1 = sel_registerName("initWithContentsOfURL:");
+    public static /*const*/ string sel_setBidiProcessingEnabled_1 = sel_registerName("setBidiProcessingEnabled:");
+    public static /*const*/ string sel_selectToMark_1 = sel_registerName("selectToMark:");
+    public static /*const*/ string sel_newlineCharacterSet = sel_registerName("newlineCharacterSet");
+    public static /*const*/ string sel_accessibilitySetOverrideValue_1forAttribute_1 = sel_registerName("accessibilitySetOverrideValue:forAttribute:");
+    public static /*const*/ string sel_setPostsFrameChangedNotifications_1 = sel_registerName("setPostsFrameChangedNotifications:");
+    public static /*const*/ string sel_cellPrototype = sel_registerName("cellPrototype");
+    public static /*const*/ string sel_unmarkText = sel_registerName("unmarkText");
+    public static /*const*/ string sel_displayValuesKeyPath = sel_registerName("displayValuesKeyPath");
+    public static /*const*/ string sel_orderFrontStylesPanel_1 = sel_registerName("orderFrontStylesPanel:");
+    public static /*const*/ string sel_getBuffer_1length_1 = sel_registerName("getBuffer:length:");
+    public static /*const*/ string sel_calcDrawInfo_1 = sel_registerName("calcDrawInfo:");
+    public static /*const*/ string sel_initWithUTF8String_1 = sel_registerName("initWithUTF8String:");
+    public static /*const*/ string sel_deselectAllCells = sel_registerName("deselectAllCells");
+    public static /*const*/ string sel_checkGrammarOfString_1startingAt_1language_1wrap_1inSpellDocumentWithTag_1details_1 = sel_registerName("checkGrammarOfString:startingAt:language:wrap:inSpellDocumentWithTag:details:");
+    public static /*const*/ string sel_poolCountHighWaterResolution = sel_registerName("poolCountHighWaterResolution");
+    public static /*const*/ string sel_canInitWithData_1 = sel_registerName("canInitWithData:");
+    public static /*const*/ string sel_setHasVerticalScroller_1 = sel_registerName("setHasVerticalScroller:");
+    public static /*const*/ string sel_flushHostCache = sel_registerName("flushHostCache");
+    public static /*const*/ string sel_toolbarDefaultItemIdentifiers_1 = sel_registerName("toolbarDefaultItemIdentifiers:");
+    public static /*const*/ string sel_setSearchButtonCell_1 = sel_registerName("setSearchButtonCell:");
+    public static /*const*/ string sel_defaultButtonCell = sel_registerName("defaultButtonCell");
+    public static /*const*/ string sel_sizeLastColumnToFit = sel_registerName("sizeLastColumnToFit");
+    public static /*const*/ string sel_addColumn = sel_registerName("addColumn");
+    public static /*const*/ string sel_failureResponse = sel_registerName("failureResponse");
+    public static /*const*/ string sel_insertTabIgnoringFieldEditor_1 = sel_registerName("insertTabIgnoringFieldEditor:");
+    public static /*const*/ string sel_locationForGlyphAtIndex_1 = sel_registerName("locationForGlyphAtIndex:");
+    public static /*const*/ string sel_insertContainerBreak_1 = sel_registerName("insertContainerBreak:");
+    public static /*const*/ string sel_setAutosizesCells_1 = sel_registerName("setAutosizesCells:");
+    public static /*const*/ string sel_isEditable = sel_registerName("isEditable");
+    public static /*const*/ string sel_path = sel_registerName("path");
+    public static /*const*/ string sel_setStringValue_1resolvingEntities_1 = sel_registerName("setStringValue:resolvingEntities:");
+    public static /*const*/ string sel_readFileContentsType_1toFile_1 = sel_registerName("readFileContentsType:toFile:");
+    public static /*const*/ string sel_fileExtensionHidden = sel_registerName("fileExtensionHidden");
+    public static /*const*/ string sel_setTextureImageToPixelBuffer_1colorBuffer_1 = sel_registerName("setTextureImageToPixelBuffer:colorBuffer:");
+    public static /*const*/ string sel_setFilename_1 = sel_registerName("setFilename:");
+    public static /*const*/ string sel_callStackReturnAddresses = sel_registerName("callStackReturnAddresses");
+    public static /*const*/ string sel_blocksOtherRecognizers = sel_registerName("blocksOtherRecognizers");
+    public static /*const*/ string sel_pixelBuffer = sel_registerName("pixelBuffer");
+    public static /*const*/ string sel_initWithStartingColor_1endingColor_1 = sel_registerName("initWithStartingColor:endingColor:");
+    public static /*const*/ string sel_indexOfObjectIdenticalTo_1inRange_1 = sel_registerName("indexOfObjectIdenticalTo:inRange:");
+    public static /*const*/ string sel_duration = sel_registerName("duration");
+    public static /*const*/ string sel_matchForPredicate_1 = sel_registerName("matchForPredicate:");
+    public static /*const*/ string sel_windowDidMiniaturize_1 = sel_registerName("windowDidMiniaturize:");
+    public static /*const*/ string sel_drawWithFrame_1inView_1characterIndex_1layoutManager_1 = sel_registerName("drawWithFrame:inView:characterIndex:layoutManager:");
+    public static /*const*/ string sel_setTwoDigitStartDate_1 = sel_registerName("setTwoDigitStartDate:");
+    public static /*const*/ string sel_selectTextAtRow_1column_1 = sel_registerName("selectTextAtRow:column:");
+    public static /*const*/ string sel_splitView_1shouldHideDividerAtIndex_1 = sel_registerName("splitView:shouldHideDividerAtIndex:");
+    public static /*const*/ string sel_isExcludedFromWindowsMenu = sel_registerName("isExcludedFromWindowsMenu");
+    public static /*const*/ string sel_earlierDate_1 = sel_registerName("earlierDate:");
+    public static /*const*/ string sel_initWithLeftExpressions_1rightExpressionAttributeType_1modifier_1operators_1options_1 = sel_registerName("initWithLeftExpressions:rightExpressionAttributeType:modifier:operators:options:");
+    public static /*const*/ string sel_minItemSize = sel_registerName("minItemSize");
+    public static /*const*/ string sel_setSearchMenuTemplate_1 = sel_registerName("setSearchMenuTemplate:");
+    public static /*const*/ string sel_rightMouseUp_1 = sel_registerName("rightMouseUp:");
+    public static /*const*/ string sel_stopSpeaking_1 = sel_registerName("stopSpeaking:");
+    public static /*const*/ string sel_getObjectValue_1forString_1errorDescription_1 = sel_registerName("getObjectValue:forString:errorDescription:");
+    public static /*const*/ string sel_unarchiver_1didDecodeObject_1 = sel_registerName("unarchiver:didDecodeObject:");
+    public static /*const*/ string sel_endSpecifier = sel_registerName("endSpecifier");
+    public static /*const*/ string sel_ascending = sel_registerName("ascending");
+    public static /*const*/ string sel_sharedCoercionHandler = sel_registerName("sharedCoercionHandler");
+    public static /*const*/ string sel_textAttributesForPositiveInfinity = sel_registerName("textAttributesForPositiveInfinity");
+    public static /*const*/ string sel_isEqualToData_1 = sel_registerName("isEqualToData:");
+    public static /*const*/ string sel_setHighlightMode_1 = sel_registerName("setHighlightMode:");
+    public static /*const*/ string sel_valueWithNonretainedObject_1 = sel_registerName("valueWithNonretainedObject:");
+    public static /*const*/ string sel_textAttributesForNotANumber = sel_registerName("textAttributesForNotANumber");
+    public static /*const*/ string sel_getCFRunLoop = sel_registerName("getCFRunLoop");
+    public static /*const*/ string sel_invalidateGlyphsForCharacterRange_1changeInLength_1actualCharacterRange_1 = sel_registerName("invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:");
+    public static /*const*/ string sel_cachedResponse = sel_registerName("cachedResponse");
+    public static /*const*/ string sel_containerIsRangeContainerObject = sel_registerName("containerIsRangeContainerObject");
+    public static /*const*/ string sel_setLanguage_1 = sel_registerName("setLanguage:");
+    public static /*const*/ string sel_loadNibFile_1externalNameTable_1withZone_1 = sel_registerName("loadNibFile:externalNameTable:withZone:");
+    public static /*const*/ string sel_offsetInFile = sel_registerName("offsetInFile");
+    public static /*const*/ string sel_initWithRulerView_1markerLocation_1image_1imageOrigin_1 = sel_registerName("initWithRulerView:markerLocation:image:imageOrigin:");
+    public static /*const*/ string sel_commandDescriptionWithAppleEventClass_1andAppleEventCode_1 = sel_registerName("commandDescriptionWithAppleEventClass:andAppleEventCode:");
+    public static /*const*/ string sel_detachDrawingThread_1toTarget_1withObject_1 = sel_registerName("detachDrawingThread:toTarget:withObject:");
+    public static /*const*/ string sel_outlineView_1shouldShowCellExpansionForTableColumn_1item_1 = sel_registerName("outlineView:shouldShowCellExpansionForTableColumn:item:");
+    public static /*const*/ string sel_catalogNameComponent = sel_registerName("catalogNameComponent");
+    public static /*const*/ string sel_monthSymbols = sel_registerName("monthSymbols");
+    public static /*const*/ string sel_invalidateShadow = sel_registerName("invalidateShadow");
+    public static /*const*/ string sel_waitUntilDate_1 = sel_registerName("waitUntilDate:");
+    public static /*const*/ string sel_languageLevel = sel_registerName("languageLevel");
+    public static /*const*/ string sel_XMLData = sel_registerName("XMLData");
+    public static /*const*/ string sel_textView_1shouldChangeTextInRanges_1replacementStrings_1 = sel_registerName("textView:shouldChangeTextInRanges:replacementStrings:");
+    public static /*const*/ string sel_initWithPointerFunctions_1 = sel_registerName("initWithPointerFunctions:");
+    public static /*const*/ string sel_initWithTextureTarget_1textureInternalFormat_1textureMaxMipMapLevel_1pixelsWide_1pixelsHigh_1 = sel_registerName("initWithTextureTarget:textureInternalFormat:textureMaxMipMapLevel:pixelsWide:pixelsHigh:");
+    public static /*const*/ string sel_classForClassName_1 = sel_registerName("classForClassName:");
+    public static /*const*/ string sel_decodeInt64ForKey_1 = sel_registerName("decodeInt64ForKey:");
+    public static /*const*/ string sel_StringWithSavedFrame = sel_registerName("StringWithSavedFrame");
+    public static /*const*/ string sel_writeRTFDToFile_1atomically_1 = sel_registerName("writeRTFDToFile:atomically:");
+    public static /*const*/ string sel_initWithLocal_1connection_1 = sel_registerName("initWithLocal:connection:");
+    public static /*const*/ string sel_sendBeforeDate_1msgid_1components_1from_1reserved_1 = sel_registerName("sendBeforeDate:msgid:components:from:reserved:");
+    public static /*const*/ string sel_playsEveryFrame = sel_registerName("playsEveryFrame");
+    public static /*const*/ string sel_prependTransform_1 = sel_registerName("prependTransform:");
+    public static /*const*/ string sel_setUsesWeakReadAndWriteBarriers_1 = sel_registerName("setUsesWeakReadAndWriteBarriers:");
+    public static /*const*/ string sel_isContinuous = sel_registerName("isContinuous");
+    public static /*const*/ string sel_andPredicateWithSubpredicates_1 = sel_registerName("andPredicateWithSubpredicates:");
+    public static /*const*/ string sel_cookieWithProperties_1 = sel_registerName("cookieWithProperties:");
+    public static /*const*/ string sel_builtInPlugInsPath = sel_registerName("builtInPlugInsPath");
+    public static /*const*/ string sel_performSelector_1onThread_1withObject_1waitUntilDone_1 = sel_registerName("performSelector:onThread:withObject:waitUntilDone:");
+    public static /*const*/ string sel_sharedDocumentController = sel_registerName("sharedDocumentController");
+    public static /*const*/ string sel_setNeedsSizing_1 = sel_registerName("setNeedsSizing:");
+    public static /*const*/ string sel_selectorForCommand_1 = sel_registerName("selectorForCommand:");
+    public static /*const*/ string sel_displayIfNeededInRectIgnoringOpacity_1 = sel_registerName("displayIfNeededInRectIgnoringOpacity:");
+    public static /*const*/ string sel_draggingPasteboard = sel_registerName("draggingPasteboard");
+    public static /*const*/ string sel_unscriptRange_1 = sel_registerName("unscriptRange:");
+    public static /*const*/ string sel_launchApplication_1 = sel_registerName("launchApplication:");
+    public static /*const*/ string sel_inputClientBecomeActive_1 = sel_registerName("inputClientBecomeActive:");
+    public static /*const*/ string sel_getFirstUnlaidCharacterIndex_1glyphIndex_1 = sel_registerName("getFirstUnlaidCharacterIndex:glyphIndex:");
+    public static /*const*/ string sel_initWithContentsOfURL_1options_1error_1 = sel_registerName("initWithContentsOfURL:options:error:");
+    public static /*const*/ string sel_createSymbolicLinkAtPath_1withDestinationPath_1error_1 = sel_registerName("createSymbolicLinkAtPath:withDestinationPath:error:");
+    public static /*const*/ string sel_accessibilityAttributeValue_1forParameter_1 = sel_registerName("accessibilityAttributeValue:forParameter:");
+    public static /*const*/ string sel_setPlaceholderAttributedString_1 = sel_registerName("setPlaceholderAttributedString:");
+    public static /*const*/ string sel_initWithIndex_1 = sel_registerName("initWithIndex:");
+    public static /*const*/ string sel_readFromURL_1ofType_1error_1 = sel_registerName("readFromURL:ofType:error:");
+    public static /*const*/ string sel_preferredFilename = sel_registerName("preferredFilename");
+    public static /*const*/ string sel_smartInsertDeleteEnabled = sel_registerName("smartInsertDeleteEnabled");
+    public static /*const*/ string sel_horizontalLineScroll = sel_registerName("horizontalLineScroll");
+    public static /*const*/ string sel_doDoubleClick_1 = sel_registerName("doDoubleClick:");
+    public static /*const*/ string sel_fontDescriptorWithFace_1 = sel_registerName("fontDescriptorWithFace:");
+    public static /*const*/ string sel_pointerArrayWithPointerFunctions_1 = sel_registerName("pointerArrayWithPointerFunctions:");
+    public static /*const*/ string sel_defaultDate = sel_registerName("defaultDate");
+    public static /*const*/ string sel_typesetterBehavior = sel_registerName("typesetterBehavior");
+    public static /*const*/ string sel_setAllowsNonContiguousLayout_1 = sel_registerName("setAllowsNonContiguousLayout:");
+    public static /*const*/ string sel_control_1didFailToFormatString_1errorDescription_1 = sel_registerName("control:didFailToFormatString:errorDescription:");
+    public static /*const*/ string sel_isBaseFont = sel_registerName("isBaseFont");
+    public static /*const*/ string sel_removeDescriptorWithKeyword_1 = sel_registerName("removeDescriptorWithKeyword:");
+    public static /*const*/ string sel_substringFromIndex_1 = sel_registerName("substringFromIndex:");
+    public static /*const*/ string sel_componentsFromLocaleIdentifier_1 = sel_registerName("componentsFromLocaleIdentifier:");
+    public static /*const*/ string sel_setUsesFeedbackWindow_1 = sel_registerName("setUsesFeedbackWindow:");
+    public static /*const*/ string sel_setAnimates_1 = sel_registerName("setAnimates:");
+    public static /*const*/ string sel_initWithDomain_1code_1userInfo_1 = sel_registerName("initWithDomain:code:userInfo:");
+    public static /*const*/ string sel_setContentView_1 = sel_registerName("setContentView:");
+    public static /*const*/ string sel_allowedFileTypes = sel_registerName("allowedFileTypes");
+    public static /*const*/ string sel_leftExpressions = sel_registerName("leftExpressions");
+    public static /*const*/ string sel_isStandalone = sel_registerName("isStandalone");
+    public static /*const*/ string sel_floatForKey_1inTable_1 = sel_registerName("floatForKey:inTable:");
+    public static /*const*/ string sel_notANumber = sel_registerName("notANumber");
+    public static /*const*/ string sel_updateFromPMPrintSettings = sel_registerName("updateFromPMPrintSettings");
+    public static /*const*/ string sel_wantsToTrackMouse = sel_registerName("wantsToTrackMouse");
+    public static /*const*/ string sel_initWithName_1reason_1userInfo_1 = sel_registerName("initWithName:reason:userInfo:");
+    public static /*const*/ string sel_prepareOpenGL = sel_registerName("prepareOpenGL");
+    public static /*const*/ string sel_setAttributedStringForNil_1 = sel_registerName("setAttributedStringForNil:");
+    public static /*const*/ string sel_sizeToFit = sel_registerName("sizeToFit");
+    public static /*const*/ string sel_setSortDescriptorPrototype_1 = sel_registerName("setSortDescriptorPrototype:");
+    public static /*const*/ string sel_canHide = sel_registerName("canHide");
+    public static /*const*/ string sel_replacementObjectForArchiver_1 = sel_registerName("replacementObjectForArchiver:");
+    public static /*const*/ string sel_purpleColor = sel_registerName("purpleColor");
+    public static /*const*/ string sel_setProperty_1forKey_1 = sel_registerName("setProperty:forKey:");
+    public static /*const*/ string sel_separatorItem = sel_registerName("separatorItem");
+    public static /*const*/ string sel_loadedCellAtRow_1column_1 = sel_registerName("loadedCellAtRow:column:");
+    public static /*const*/ string sel_containerSpecifier = sel_registerName("containerSpecifier");
+    public static /*const*/ string sel_draggingSourceOperationMaskForLocal_1 = sel_registerName("draggingSourceOperationMaskForLocal:");
+    public static /*const*/ string sel_willPresentError_1 = sel_registerName("willPresentError:");
+    public static /*const*/ string sel_strikethroughGlyphRange_1strikethroughType_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1 = sel_registerName("strikethroughGlyphRange:strikethroughType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:");
+    public static /*const*/ string sel_elementWithName_1StringValue_1 = sel_registerName("elementWithName:StringValue:");
+    public static /*const*/ string sel_unsignedCharValue = sel_registerName("unsignedCharValue");
+    public static /*const*/ string sel_rangeOfComposedCharacterSequencesForRange_1 = sel_registerName("rangeOfComposedCharacterSequencesForRange:");
+    public static /*const*/ string sel_activate_1 = sel_registerName("activate:");
+    public static /*const*/ string sel_controlView = sel_registerName("controlView");
+    public static /*const*/ string sel_cachePolicy = sel_registerName("cachePolicy");
+    public static /*const*/ string sel_fontAttributesInRange_1 = sel_registerName("fontAttributesInRange:");
+    public static /*const*/ string sel_setPreservesSelection_1 = sel_registerName("setPreservesSelection:");
+    public static /*const*/ string sel_unscript_1 = sel_registerName("unscript:");
+    public static /*const*/ string sel_deltaZ = sel_registerName("deltaZ");
+    public static /*const*/ string sel_connection_1handleRequest_1 = sel_registerName("connection:handleRequest:");
+    public static /*const*/ string sel_caseSensitive = sel_registerName("caseSensitive");
+    public static /*const*/ string sel_tabViewItemAtPoint_1 = sel_registerName("tabViewItemAtPoint:");
+    public static /*const*/ string sel_setTextAttributesForNegativeValues_1 = sel_registerName("setTextAttributesForNegativeValues:");
+    public static /*const*/ string sel_underlineGlyphRange_1underlineType_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1 = sel_registerName("underlineGlyphRange:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:");
+    public static /*const*/ string sel_classForCoder = sel_registerName("classForCoder");
+    public static /*const*/ string sel_setContent_1 = sel_registerName("setContent:");
+    public static /*const*/ string sel_getLineStart_1end_1contentsEnd_1forRange_1 = sel_registerName("getLineStart:end:contentsEnd:forRange:");
+    public static /*const*/ string sel_removeRowsAtIndexes_1includeSubrows_1 = sel_registerName("removeRowsAtIndexes:includeSubrows:");
+    public static /*const*/ string sel_tokenFieldCell_1styleForRepresentedObject_1 = sel_registerName("tokenFieldCell:styleForRepresentedObject:");
+    public static /*const*/ string sel_setToolTip_1 = sel_registerName("setToolTip:");
+    public static /*const*/ string sel_titleHeight = sel_registerName("titleHeight");
+    public static /*const*/ string sel_setShowsStateBy_1 = sel_registerName("setShowsStateBy:");
+    public static /*const*/ string sel_URLWithString_1relativeToURL_1 = sel_registerName("URLWithString:relativeToURL:");
+    public static /*const*/ string sel_fileSystemRepresentationWithPath_1 = sel_registerName("fileSystemRepresentationWithPath:");
+    public static /*const*/ string sel_setRate_1 = sel_registerName("setRate:");
+    public static /*const*/ string sel_extraLineFragmentTextContainer = sel_registerName("extraLineFragmentTextContainer");
+    public static /*const*/ string sel_insertObjects_1atArrangedObjectIndexes_1 = sel_registerName("insertObjects:atArrangedObjectIndexes:");
+    public static /*const*/ string sel_fontDescriptorWithSymbolicTraits_1 = sel_registerName("fontDescriptorWithSymbolicTraits:");
+    public static /*const*/ string sel_topMargin = sel_registerName("topMargin");
+    public static /*const*/ string sel_tokenField_1representedObjectForEditingString_1 = sel_registerName("tokenField:representedObjectForEditingString:");
+    public static /*const*/ string sel_drawInsertionPointInRect_1color_1turnedOn_1 = sel_registerName("drawInsertionPointInRect:color:turnedOn:");
+    public static /*const*/ string sel_fontNamed_1hasTraits_1 = sel_registerName("fontNamed:hasTraits:");
+    public static /*const*/ string sel_revertToSavedFromFile_1ofType_1 = sel_registerName("revertToSavedFromFile:ofType:");
+    public static /*const*/ string sel_cString = sel_registerName("cString");
+    public static /*const*/ string sel_markerForItemNumber_1 = sel_registerName("markerForItemNumber:");
+    public static /*const*/ string sel_mapTableWithWeakToStrongObjects = sel_registerName("mapTableWithWeakToStrongObjects");
+    public static /*const*/ string sel_autosaveExpandedItems = sel_registerName("autosaveExpandedItems");
+    public static /*const*/ string sel_setMiterLimit_1 = sel_registerName("setMiterLimit:");
+    public static /*const*/ string sel_indentationLevel = sel_registerName("indentationLevel");
+    public static /*const*/ string sel_fileHandleForUpdatingAtPath_1 = sel_registerName("fileHandleForUpdatingAtPath:");
+    public static /*const*/ string sel_fontWithDescriptor_1textTransform_1 = sel_registerName("fontWithDescriptor:textTransform:");
+    public static /*const*/ string sel_selectLine_1 = sel_registerName("selectLine:");
+    public static /*const*/ string sel_deleteForward_1 = sel_registerName("deleteForward:");
+    public static /*const*/ string sel_getAdvancements_1forPackedGlyphs_1length_1 = sel_registerName("getAdvancements:forPackedGlyphs:length:");
+    public static /*const*/ string sel_usesRuler = sel_registerName("usesRuler");
+    public static /*const*/ string sel_performClose_1 = sel_registerName("performClose:");
+    public static /*const*/ string sel_trackRect = sel_registerName("trackRect");
+    public static /*const*/ string sel_setFont_1 = sel_registerName("setFont:");
+    public static /*const*/ string sel_conformsToProtocol_1 = sel_registerName("conformsToProtocol:");
+    public static /*const*/ string sel_appendBezierPathWithPoints_1count_1 = sel_registerName("appendBezierPathWithPoints:count:");
+    public static /*const*/ string sel_defaultLineHeightForFont_1 = sel_registerName("defaultLineHeightForFont:");
+    public static /*const*/ string sel_mouse_1inRect_1 = sel_registerName("mouse:inRect:");
+    public static /*const*/ string sel_portCoderWithReceivePort_1sendPort_1components_1 = sel_registerName("portCoderWithReceivePort:sendPort:components:");
+    public static /*const*/ string sel_inputClientDisabled_1 = sel_registerName("inputClientDisabled:");
+    public static /*const*/ string sel_widthForSegment_1 = sel_registerName("widthForSegment:");
+    public static /*const*/ string sel_performSelector_1 = sel_registerName("performSelector:");
+    public static /*const*/ string sel_recalculateKeyViewLoop = sel_registerName("recalculateKeyViewLoop");
+    public static /*const*/ string sel_initWithDrawSelector_1delegate_1 = sel_registerName("initWithDrawSelector:delegate:");
+    public static /*const*/ string sel_breakUndoCoalescing = sel_registerName("breakUndoCoalescing");
+    public static /*const*/ string sel_font = sel_registerName("font");
+    public static /*const*/ string sel_fontDescriptorWithSize_1 = sel_registerName("fontDescriptorWithSize:");
+    public static /*const*/ string sel_insertItemWithTitle_1atIndex_1 = sel_registerName("insertItemWithTitle:atIndex:");
+    public static /*const*/ string sel_contentAspectRatio = sel_registerName("contentAspectRatio");
+    public static /*const*/ string sel_currentHandler = sel_registerName("currentHandler");
+    public static /*const*/ string sel_sharedAppleEventManager = sel_registerName("sharedAppleEventManager");
+    public static /*const*/ string sel_pathForResource_1ofType_1 = sel_registerName("pathForResource:ofType:");
+    public static /*const*/ string sel_initWithRequest_1cachedResponse_1client_1 = sel_registerName("initWithRequest:cachedResponse:client:");
+    public static /*const*/ string sel_isTitled = sel_registerName("isTitled");
+    public static /*const*/ string sel_drawerWillOpen_1 = sel_registerName("drawerWillOpen:");
+    public static /*const*/ string sel_screenFont = sel_registerName("screenFont");
+    public static /*const*/ string sel_principalClass = sel_registerName("principalClass");
+    public static /*const*/ string sel_pathControl_1willDisplayOpenPanel_1 = sel_registerName("pathControl:willDisplayOpenPanel:");
+    public static /*const*/ string sel_setGroupingSeparator_1 = sel_registerName("setGroupingSeparator:");
+    public static /*const*/ string sel_fontWithDescriptor_1size_1 = sel_registerName("fontWithDescriptor:size:");
+    public static /*const*/ string sel_glyphInfoWithCharacterIdentifier_1collection_1baseString_1 = sel_registerName("glyphInfoWithCharacterIdentifier:collection:baseString:");
+    public static /*const*/ string sel_movieUnfilteredFileTypes = sel_registerName("movieUnfilteredFileTypes");
+    public static /*const*/ string sel_portList = sel_registerName("portList");
+    public static /*const*/ string sel_tokenField_1readFromPasteboard_1 = sel_registerName("tokenField:readFromPasteboard:");
+    public static /*const*/ string sel_setEndSpecifier_1 = sel_registerName("setEndSpecifier:");
+    public static /*const*/ string sel_textView_1willDisplayToolTip_1forCharacterAtIndex_1 = sel_registerName("textView:willDisplayToolTip:forCharacterAtIndex:");
+    public static /*const*/ string sel_applicationIconImage = sel_registerName("applicationIconImage");
+    public static /*const*/ string sel_target = sel_registerName("target");
+    public static /*const*/ string sel_replaceGlyphAtIndex_1withGlyph_1 = sel_registerName("replaceGlyphAtIndex:withGlyph:");
+    public static /*const*/ string sel_borderColorForEdge_1 = sel_registerName("borderColorForEdge:");
+    public static /*const*/ string sel_timeIntervalSinceDate_1 = sel_registerName("timeIntervalSinceDate:");
+    public static /*const*/ string sel_pathsForResourcesOfType_1inDirectory_1forLocalization_1 = sel_registerName("pathsForResourcesOfType:inDirectory:forLocalization:");
+    public static /*const*/ string sel_bitmapData = sel_registerName("bitmapData");
+    public static /*const*/ string sel_redComponent = sel_registerName("redComponent");
+    public static /*const*/ string sel_numberOfVisibleItems = sel_registerName("numberOfVisibleItems");
+    public static /*const*/ string sel_selectCell_1 = sel_registerName("selectCell:");
+    public static /*const*/ string sel_applicationWillHide_1 = sel_registerName("applicationWillHide:");
+    public static /*const*/ string sel_characterIsMember_1 = sel_registerName("characterIsMember:");
+    public static /*const*/ string sel_setArrowsPosition_1 = sel_registerName("setArrowsPosition:");
+    public static /*const*/ string sel_minusSign = sel_registerName("minusSign");
+    public static /*const*/ string sel_canSpawnSeparateThread = sel_registerName("canSpawnSeparateThread");
+    public static /*const*/ string sel_setContinuous_1 = sel_registerName("setContinuous:");
+    public static /*const*/ string sel_addSymbolicLinkWithDestination_1preferredFilename_1 = sel_registerName("addSymbolicLinkWithDestination:preferredFilename:");
+    public static /*const*/ string sel_destinationOfSymbolicLinkAtPath_1error_1 = sel_registerName("destinationOfSymbolicLinkAtPath:error:");
+    public static /*const*/ string sel_runUntilDate_1 = sel_registerName("runUntilDate:");
+    public static /*const*/ string sel_StringByAbbreviatingWithTildeInPath = sel_registerName("StringByAbbreviatingWithTildeInPath");
+    public static /*const*/ string sel_drawerWillResizeContents_1toSize_1 = sel_registerName("drawerWillResizeContents:toSize:");
+    public static /*const*/ string sel_imageRectForBounds_1 = sel_registerName("imageRectForBounds:");
+    public static /*const*/ string sel_indexGreaterThanIndex_1 = sel_registerName("indexGreaterThanIndex:");
+    public static /*const*/ string sel_setSelectionFrom_1to_1anchor_1highlight_1 = sel_registerName("setSelectionFrom:to:anchor:highlight:");
+    public static /*const*/ string sel_unsignedIntegerValue = sel_registerName("unsignedIntegerValue");
+    public static /*const*/ string sel_focusView = sel_registerName("focusView");
+    public static /*const*/ string sel_longCharacterIsMember_1 = sel_registerName("longCharacterIsMember:");
+    public static /*const*/ string sel_groupingSeparator = sel_registerName("groupingSeparator");
+    public static /*const*/ string sel_depthLimit = sel_registerName("depthLimit");
+    public static /*const*/ string sel_attributesAtIndex_1longestEffectiveRange_1inRange_1 = sel_registerName("attributesAtIndex:longestEffectiveRange:inRange:");
+    public static /*const*/ string sel_setAcceptsArrowKeys_1 = sel_registerName("setAcceptsArrowKeys:");
+    public static /*const*/ string sel_isGreaterThanOrEqualTo_1 = sel_registerName("isGreaterThanOrEqualTo:");
+    public static /*const*/ string sel_maxContentSize = sel_registerName("maxContentSize");
+    public static /*const*/ string sel_setParentWindow_1 = sel_registerName("setParentWindow:");
+    public static /*const*/ string sel_importsGraphics = sel_registerName("importsGraphics");
+    public static /*const*/ string sel_setPaddingPosition_1 = sel_registerName("setPaddingPosition:");
+    public static /*const*/ string sel_yearOfCommonEra = sel_registerName("yearOfCommonEra");
+    public static /*const*/ string sel_cells = sel_registerName("cells");
+    public static /*const*/ string sel_cyanComponent = sel_registerName("cyanComponent");
+    public static /*const*/ string sel_documentClassForType_1 = sel_registerName("documentClassForType:");
+    public static /*const*/ string sel_setSelectionHighlightStyle_1 = sel_registerName("setSelectionHighlightStyle:");
+    public static /*const*/ string sel_addWindowController_1 = sel_registerName("addWindowController:");
+    public static /*const*/ string sel_initWithXMLString_1error_1 = sel_registerName("initWithXMLString:error:");
+    public static /*const*/ string sel_authenticateComponents_1withData_1 = sel_registerName("authenticateComponents:withData:");
+    public static /*const*/ string sel_traitsOfFont_1 = sel_registerName("traitsOfFont:");
+    public static /*const*/ string sel_timeIntervalSinceReferenceDate = sel_registerName("timeIntervalSinceReferenceDate");
+    public static /*const*/ string sel_orderFrontCharacterPalette_1 = sel_registerName("orderFrontCharacterPalette:");
+    public static /*const*/ string sel_setServicesProvider_1 = sel_registerName("setServicesProvider:");
+    public static /*const*/ string sel_setMessage_1 = sel_registerName("setMessage:");
+    public static /*const*/ string sel_msgid = sel_registerName("msgid");
+    public static /*const*/ string sel_beginUndoGrouping = sel_registerName("beginUndoGrouping");
+    public static /*const*/ string sel_RTFDFromRange_1documentAttributes_1 = sel_registerName("RTFDFromRange:documentAttributes:");
+    public static /*const*/ string sel_selectedItem = sel_registerName("selectedItem");
+    public static /*const*/ string sel_addTabStop_1 = sel_registerName("addTabStop:");
+    public static /*const*/ string sel_scrollRect_1by_1 = sel_registerName("scrollRect:by:");
+    public static /*const*/ string sel_icon = sel_registerName("icon");
+    public static /*const*/ string sel_setValue_1forUndefinedKey_1 = sel_registerName("setValue:forUndefinedKey:");
+    public static /*const*/ string sel_decodeFloatForKey_1 = sel_registerName("decodeFloatForKey:");
+    public static /*const*/ string sel_commentURL = sel_registerName("commentURL");
+    public static /*const*/ string sel_shortStandaloneMonthSymbols = sel_registerName("shortStandaloneMonthSymbols");
+    public static /*const*/ string sel_browser_1titleOfColumn_1 = sel_registerName("browser:titleOfColumn:");
+    public static /*const*/ string sel_exit = sel_registerName("exit");
+    public static /*const*/ string sel_deselectAll_1 = sel_registerName("deselectAll:");
+    public static /*const*/ string sel_canRemove = sel_registerName("canRemove");
+    public static /*const*/ string sel_proxyType = sel_registerName("proxyType");
+    public static /*const*/ string sel_shouldCloseDocument = sel_registerName("shouldCloseDocument");
+    public static /*const*/ string sel_setMinimumLineHeight_1 = sel_registerName("setMinimumLineHeight:");
+    public static /*const*/ string sel_grayColor = sel_registerName("grayColor");
+    public static /*const*/ string sel_suspend = sel_registerName("suspend");
+    public static /*const*/ string sel_printJobTitle = sel_registerName("printJobTitle");
+    public static /*const*/ string sel_fileHandleWithStandardOutput = sel_registerName("fileHandleWithStandardOutput");
+    public static /*const*/ string sel_objCType = sel_registerName("objCType");
+    public static /*const*/ string sel_maximumIntegerDigits = sel_registerName("maximumIntegerDigits");
+    public static /*const*/ string sel_initWithKey_1ascending_1 = sel_registerName("initWithKey:ascending:");
+    public static /*const*/ string sel_paramDescriptorForKeyword_1 = sel_registerName("paramDescriptorForKeyword:");
+    public static /*const*/ string sel_cookiesForURL_1 = sel_registerName("cookiesForURL:");
+    public static /*const*/ string sel_currentTextContainer = sel_registerName("currentTextContainer");
+    public static /*const*/ string sel_removeAllCachedResponses = sel_registerName("removeAllCachedResponses");
+    public static /*const*/ string sel_setAllHTTPHeaderFields_1 = sel_registerName("setAllHTTPHeaderFields:");
+    public static /*const*/ string sel_setShortQuarterSymbols_1 = sel_registerName("setShortQuarterSymbols:");
+    public static /*const*/ string sel_removeItemWithObjectValue_1 = sel_registerName("removeItemWithObjectValue:");
+    public static /*const*/ string sel_reloadColumn_1 = sel_registerName("reloadColumn:");
+    public static /*const*/ string sel_initWithData_1 = sel_registerName("initWithData:");
+    public static /*const*/ string sel_textDidEndEditing_1 = sel_registerName("textDidEndEditing:");
+    public static /*const*/ string sel_descriptorForKeyword_1 = sel_registerName("descriptorForKeyword:");
+    public static /*const*/ string sel_gState = sel_registerName("gState");
+    public static /*const*/ string sel_setCellClass_1 = sel_registerName("setCellClass:");
+    public static /*const*/ string sel_requestUserAttention_1 = sel_registerName("requestUserAttention:");
+    public static /*const*/ string sel_disableUndoRegistration = sel_registerName("disableUndoRegistration");
+    public static /*const*/ string sel_currencySymbol = sel_registerName("currencySymbol");
+    public static /*const*/ string sel_defaultWritingDirectionForLanguage_1 = sel_registerName("defaultWritingDirectionForLanguage:");
+    public static /*const*/ string sel_selectedCellInColumn_1 = sel_registerName("selectedCellInColumn:");
+    public static /*const*/ string sel_spellServer_1didForgetWord_1inLanguage_1 = sel_registerName("spellServer:didForgetWord:inLanguage:");
+    public static /*const*/ string sel_initWithType_1error_1 = sel_registerName("initWithType:error:");
+    public static /*const*/ string sel_editedRow = sel_registerName("editedRow");
+    public static /*const*/ string sel_expressionForUnionSet_1with_1 = sel_registerName("expressionForUnionSet:with:");
+    public static /*const*/ string sel_verticalMotionCanBeginDrag = sel_registerName("verticalMotionCanBeginDrag");
+    public static /*const*/ string sel_selectNextKeyView_1 = sel_registerName("selectNextKeyView:");
+    public static /*const*/ string sel_lowercaseString = sel_registerName("lowercaseString");
+    public static /*const*/ string sel_intercellSpacing = sel_registerName("intercellSpacing");
+    public static /*const*/ string sel_selectedItemIdentifier = sel_registerName("selectedItemIdentifier");
+    public static /*const*/ string sel_getIndexes_1 = sel_registerName("getIndexes:");
+    public static /*const*/ string sel_contentRect = sel_registerName("contentRect");
+    public static /*const*/ string sel_addObjects_1 = sel_registerName("addObjects:");
+    public static /*const*/ string sel_selectedRowIndexes = sel_registerName("selectedRowIndexes");
+    public static /*const*/ string sel_setSecond_1 = sel_registerName("setSecond:");
+    public static /*const*/ string sel_setIgnoresMultiClick_1 = sel_registerName("setIgnoresMultiClick:");
+    public static /*const*/ string sel_hasMemberInPlane_1 = sel_registerName("hasMemberInPlane:");
+    public static /*const*/ string sel_setClientView_1 = sel_registerName("setClientView:");
+    public static /*const*/ string sel_setInitialFirstResponder_1 = sel_registerName("setInitialFirstResponder:");
+    public static /*const*/ string sel_defaultAnimationForKey_1 = sel_registerName("defaultAnimationForKey:");
+    public static /*const*/ string sel_systemTimeZone = sel_registerName("systemTimeZone");
+    public static /*const*/ string sel_pageSizeForPaper_1 = sel_registerName("pageSizeForPaper:");
+    public static /*const*/ string sel_windowBackgroundColor = sel_registerName("windowBackgroundColor");
+    public static /*const*/ string sel_prepareGState = sel_registerName("prepareGState");
+    public static /*const*/ string sel_willSetLineFragmentRect_1forGlyphRange_1usedRect_1baselineOffset_1 = sel_registerName("willSetLineFragmentRect:forGlyphRange:usedRect:baselineOffset:");
+    public static /*const*/ string sel_setScriptingProperties_1 = sel_registerName("setScriptingProperties:");
+    public static /*const*/ string sel_initWithScrollView_1orientation_1 = sel_registerName("initWithScrollView:orientation:");
+    public static /*const*/ string sel_canBecomeVisibleWithoutLogin = sel_registerName("canBecomeVisibleWithoutLogin");
+    public static /*const*/ string sel_scrollLineDown_1 = sel_registerName("scrollLineDown:");
+    public static /*const*/ string sel_setServicesMenu_1 = sel_registerName("setServicesMenu:");
+    public static /*const*/ string sel_appleEventCode = sel_registerName("appleEventCode");
+    public static /*const*/ string sel_replaceObjectsInRange_1withObjectsFromArray_1range_1 = sel_registerName("replaceObjectsInRange:withObjectsFromArray:range:");
+    public static /*const*/ string sel_autosizesCells = sel_registerName("autosizesCells");
+    public static /*const*/ string sel_tableView_1toolTipForCell_1rect_1tableColumn_1row_1mouseLocation_1 = sel_registerName("tableView:toolTipForCell:rect:tableColumn:row:mouseLocation:");
+    public static /*const*/ string sel_dateWithYear_1month_1day_1hour_1minute_1second_1timeZone_1 = sel_registerName("dateWithYear:month:day:hour:minute:second:timeZone:");
+    public static /*const*/ string sel_windowWillResize_1toSize_1 = sel_registerName("windowWillResize:toSize:");
+    public static /*const*/ string sel_initWithUnsignedChar_1 = sel_registerName("initWithUnsignedChar:");
+    public static /*const*/ string sel_suiteForAppleEventCode_1 = sel_registerName("suiteForAppleEventCode:");
+    public static /*const*/ string sel_setTrailingOffset_1 = sel_registerName("setTrailingOffset:");
+    public static /*const*/ string sel_canBecomeKeyWindow = sel_registerName("canBecomeKeyWindow");
+    public static /*const*/ string sel_setAnimationBlockingMode_1 = sel_registerName("setAnimationBlockingMode:");
+    public static /*const*/ string sel_formUnionWithCharacterSet_1 = sel_registerName("formUnionWithCharacterSet:");
+    public static /*const*/ string sel_typeForArgumentWithName_1 = sel_registerName("typeForArgumentWithName:");
+    public static /*const*/ string sel_setFileName_1 = sel_registerName("setFileName:");
+    public static /*const*/ string sel_createSymbolicLinkAtPath_1pathContent_1 = sel_registerName("createSymbolicLinkAtPath:pathContent:");
+    public static /*const*/ string sel_undoMenuTitleForUndoActionName_1 = sel_registerName("undoMenuTitleForUndoActionName:");
+    public static /*const*/ string sel_dateStyle = sel_registerName("dateStyle");
+    public static /*const*/ string sel_currentContext = sel_registerName("currentContext");
+    public static /*const*/ string sel_dequeueNotificationsMatching_1coalesceMask_1 = sel_registerName("dequeueNotificationsMatching:coalesceMask:");
+    public static /*const*/ string sel_thousandSeparator = sel_registerName("thousandSeparator");
+    public static /*const*/ string sel_writeData_1 = sel_registerName("writeData:");
+    public static /*const*/ string sel_selectedTag = sel_registerName("selectedTag");
+    public static /*const*/ string sel_drawWithRect_1options_1 = sel_registerName("drawWithRect:options:");
+    public static /*const*/ string sel_canonicalLocaleIdentifierFromString_1 = sel_registerName("canonicalLocaleIdentifierFromString:");
+    public static /*const*/ string sel_convertFontTraits_1 = sel_registerName("convertFontTraits:");
+    public static /*const*/ string sel_itemAdded_1 = sel_registerName("itemAdded:");
+    public static /*const*/ string sel_scriptErrorString = sel_registerName("scriptErrorString");
+    public static /*const*/ string sel_submenuAction_1 = sel_registerName("submenuAction:");
+    public static /*const*/ string sel_initWithType_1subpredicates_1 = sel_registerName("initWithType:subpredicates:");
+    public static /*const*/ string sel_subpathsOfDirectoryAtPath_1error_1 = sel_registerName("subpathsOfDirectoryAtPath:error:");
+    public static /*const*/ string sel_becomesKeyOnlyIfNeeded = sel_registerName("becomesKeyOnlyIfNeeded");
+    public static /*const*/ string sel_displayAllColumns = sel_registerName("displayAllColumns");
+    public static /*const*/ string sel_indexOfItemWithSubmenu_1 = sel_registerName("indexOfItemWithSubmenu:");
+    public static /*const*/ string sel_runModalSavePanelForSaveOperation_1delegate_1didSaveSelector_1contextInfo_1 = sel_registerName("runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:");
+    public static /*const*/ string sel_setCollectionBehavior_1 = sel_registerName("setCollectionBehavior:");
+    public static /*const*/ string sel_boundingRectWithSize_1options_1attributes_1 = sel_registerName("boundingRectWithSize:options:attributes:");
+    public static /*const*/ string sel_valueForAttribute_1 = sel_registerName("valueForAttribute:");
+    public static /*const*/ string sel_attributedStringForNotANumber = sel_registerName("attributedStringForNotANumber");
+    public static /*const*/ string sel_indicesOfObjectsByEvaluatingObjectSpecifier_1 = sel_registerName("indicesOfObjectsByEvaluatingObjectSpecifier:");
+    public static /*const*/ string sel_initWithPath_1 = sel_registerName("initWithPath:");
+    public static /*const*/ string sel_doCommandBySelector_1 = sel_registerName("doCommandBySelector:");
+    public static /*const*/ string sel_numberWithChar_1 = sel_registerName("numberWithChar:");
+    public static /*const*/ string sel_setAllowsMixedState_1 = sel_registerName("setAllowsMixedState:");
+    public static /*const*/ string sel_abortEditing = sel_registerName("abortEditing");
+    public static /*const*/ string sel_context = sel_registerName("context");
+    public static /*const*/ string sel_drawerShouldClose_1 = sel_registerName("drawerShouldClose:");
+    public static /*const*/ string sel_tabViewDidChangeNumberOfTabViewItems_1 = sel_registerName("tabViewDidChangeNumberOfTabViewItems:");
+    public static /*const*/ string sel_focusRingType = sel_registerName("focusRingType");
+    public static /*const*/ string sel_copyScriptingValue_1forKey_1withProperties_1 = sel_registerName("copyScriptingValue:forKey:withProperties:");
+    public static /*const*/ string sel_acceptsFirstMouse_1 = sel_registerName("acceptsFirstMouse:");
+    public static /*const*/ string sel_initWithPosition_1objectSpecifier_1 = sel_registerName("initWithPosition:objectSpecifier:");
+    public static /*const*/ string sel_selectionRangeForProposedRange_1granularity_1 = sel_registerName("selectionRangeForProposedRange:granularity:");
+    public static /*const*/ string sel_isNotEqualTo_1 = sel_registerName("isNotEqualTo:");
+    public static /*const*/ string sel_encodeRootObject_1 = sel_registerName("encodeRootObject:");
+    public static /*const*/ string sel_hasSuffix_1 = sel_registerName("hasSuffix:");
+    public static /*const*/ string sel_initWithFontAttributes_1 = sel_registerName("initWithFontAttributes:");
+    public static /*const*/ string sel_initWithRTFDFileWrapper_1documentAttributes_1 = sel_registerName("initWithRTFDFileWrapper:documentAttributes:");
+    public static /*const*/ string sel_miniwindowImage = sel_registerName("miniwindowImage");
+    public static /*const*/ string sel_developmentLocalization = sel_registerName("developmentLocalization");
+    public static /*const*/ string sel_localizedSummaryItems = sel_registerName("localizedSummaryItems");
+    public static /*const*/ string sel_intValue = sel_registerName("intValue");
+    public static /*const*/ string sel_setReturnValue_1 = sel_registerName("setReturnValue:");
+    public static /*const*/ string sel_selectedMenuItemColor = sel_registerName("selectedMenuItemColor");
+    public static /*const*/ string sel_editColumn_1row_1withEvent_1select_1 = sel_registerName("editColumn:row:withEvent:select:");
+    public static /*const*/ string sel_descriptionWithCalendarFormat_1timeZone_1locale_1 = sel_registerName("descriptionWithCalendarFormat:timeZone:locale:");
+    public static /*const*/ string sel_itemHeight = sel_registerName("itemHeight");
+    public static /*const*/ string sel_application_1openFiles_1 = sel_registerName("application:openFiles:");
+    public static /*const*/ string sel_window = sel_registerName("window");
+    public static /*const*/ string sel_setShortStandaloneMonthSymbols_1 = sel_registerName("setShortStandaloneMonthSymbols:");
+    public static /*const*/ string sel_setTag_1 = sel_registerName("setTag:");
+    public static /*const*/ string sel_ignoredWordsInSpellDocumentWithTag_1 = sel_registerName("ignoredWordsInSpellDocumentWithTag:");
+    public static /*const*/ string sel_preferredLocalizationsFromArray_1 = sel_registerName("preferredLocalizationsFromArray:");
+    public static /*const*/ string sel_intersectsIndexesInRange_1 = sel_registerName("intersectsIndexesInRange:");
+    public static /*const*/ string sel_scanLongLong_1 = sel_registerName("scanLongLong:");
+    public static /*const*/ string sel_characterSetWithContentsOfFile_1 = sel_registerName("characterSetWithContentsOfFile:");
+    public static /*const*/ string sel_elementWithName_1children_1attributes_1 = sel_registerName("elementWithName:children:attributes:");
+    public static /*const*/ string sel_removeItem_1 = sel_registerName("removeItem:");
+    public static /*const*/ string sel_classForKeyedArchiver = sel_registerName("classForKeyedArchiver");
+    public static /*const*/ string sel_initWithString_1locale_1 = sel_registerName("initWithString:locale:");
+    public static /*const*/ string sel_initWithData_1options_1error_1 = sel_registerName("initWithData:options:error:");
+    public static /*const*/ string sel_setIsPaneSplitter_1 = sel_registerName("setIsPaneSplitter:");
+    public static /*const*/ string sel_URLHandle_1resourceDataDidBecomeAvailable_1 = sel_registerName("URLHandle:resourceDataDidBecomeAvailable:");
+    public static /*const*/ string sel_systemDefaultPortNameServer = sel_registerName("systemDefaultPortNameServer");
+    public static /*const*/ string sel_controlTextDidEndEditing_1 = sel_registerName("controlTextDidEndEditing:");
+    public static /*const*/ string sel_commandDescription = sel_registerName("commandDescription");
+    public static /*const*/ string sel_collapseItem_1 = sel_registerName("collapseItem:");
+    public static /*const*/ string sel_setAutoresizesOutlineColumn_1 = sel_registerName("setAutoresizesOutlineColumn:");
+    public static /*const*/ string sel_isSubsetOfHashTable_1 = sel_registerName("isSubsetOfHashTable:");
+    public static /*const*/ string sel_discardEventsMatchingMask_1beforeEvent_1 = sel_registerName("discardEventsMatchingMask:beforeEvent:");
+    public static /*const*/ string sel_highlightSelectionInClipRect_1 = sel_registerName("highlightSelectionInClipRect:");
+    public static /*const*/ string sel_decodeSizeForKey_1 = sel_registerName("decodeSizeForKey:");
+    public static /*const*/ string sel_decimalNumberByRaisingToPower_1 = sel_registerName("decimalNumberByRaisingToPower:");
+    public static /*const*/ string sel_canBecomeMainWindow = sel_registerName("canBecomeMainWindow");
+    public static /*const*/ string sel_setMenuItem_1 = sel_registerName("setMenuItem:");
+    public static /*const*/ string sel_contentRectForFrameRect_1styleMask_1 = sel_registerName("contentRectForFrameRect:styleMask:");
+    public static /*const*/ string sel_clearGLContext = sel_registerName("clearGLContext");
+    public static /*const*/ string sel_setFileType_1 = sel_registerName("setFileType:");
+    public static /*const*/ string sel_expressionForIntersectSet_1with_1 = sel_registerName("expressionForIntersectSet:with:");
+    public static /*const*/ string sel_sharedHelpManager = sel_registerName("sharedHelpManager");
+    public static /*const*/ string sel_setMiniwindowTitle_1 = sel_registerName("setMiniwindowTitle:");
+    public static /*const*/ string sel_fontDescriptorWithName_1size_1 = sel_registerName("fontDescriptorWithName:size:");
+    public static /*const*/ string sel_cookies = sel_registerName("cookies");
+    public static /*const*/ string sel_detachNewThreadSelector_1toTarget_1withObject_1 = sel_registerName("detachNewThreadSelector:toTarget:withObject:");
+    public static /*const*/ string sel_needsPanelToBecomeKey = sel_registerName("needsPanelToBecomeKey");
+    public static /*const*/ string sel_retainArguments = sel_registerName("retainArguments");
+    public static /*const*/ string sel_textStorageWillProcessEditing_1 = sel_registerName("textStorageWillProcessEditing:");
+    public static /*const*/ string sel_location = sel_registerName("location");
+    public static /*const*/ string sel_shouldChangeTextInRange_1replacementString_1 = sel_registerName("shouldChangeTextInRange:replacementString:");
+    public static /*const*/ string sel_textView_1doubleClickedOnCell_1inRect_1 = sel_registerName("textView:doubleClickedOnCell:inRect:");
+    public static /*const*/ string sel_validateVisibleItems = sel_registerName("validateVisibleItems");
+    public static /*const*/ string sel_isOneway = sel_registerName("isOneway");
+    public static /*const*/ string sel_zone = sel_registerName("zone");
+    public static /*const*/ string sel_titleAlignment = sel_registerName("titleAlignment");
+    public static /*const*/ string sel_localNameForName_1 = sel_registerName("localNameForName:");
+    public static /*const*/ string sel_loopMode = sel_registerName("loopMode");
+    public static /*const*/ string sel_setFocusRingType_1 = sel_registerName("setFocusRingType:");
+    public static /*const*/ string sel_StringForKey_1 = sel_registerName("StringForKey:");
+    public static /*const*/ string sel_initWithDomain_1type_1name_1 = sel_registerName("initWithDomain:type:name:");
+    public static /*const*/ string sel_animationDidEnd_1 = sel_registerName("animationDidEnd:");
+    public static /*const*/ string sel_addSubview_1positioned_1relativeTo_1 = sel_registerName("addSubview:positioned:relativeTo:");
+    public static /*const*/ string sel_removeObjects_1 = sel_registerName("removeObjects:");
+    public static /*const*/ string sel_graphicsContextWithBitmapImageRep_1 = sel_registerName("graphicsContextWithBitmapImageRep:");
+    public static /*const*/ string sel_isDescendantOf_1 = sel_registerName("isDescendantOf:");
+    public static /*const*/ string sel_tableView_1nextTypeSelectMatchFromRow_1toRow_1forString_1 = sel_registerName("tableView:nextTypeSelectMatchFromRow:toRow:forString:");
+    public static /*const*/ string sel_initWithRequest_1delegate_1startImmediately_1 = sel_registerName("initWithRequest:delegate:startImmediately:");
+    public static /*const*/ string sel_reservedThicknessForMarkers = sel_registerName("reservedThicknessForMarkers");
+    public static /*const*/ string sel_movieRect = sel_registerName("movieRect");
+    public static /*const*/ string sel_portForName_1host_1 = sel_registerName("portForName:host:");
+    public static /*const*/ string sel_tabView_1willSelectTabViewItem_1 = sel_registerName("tabView:willSelectTabViewItem:");
+    public static /*const*/ string sel_isOneShot = sel_registerName("isOneShot");
+    public static /*const*/ string sel_usesThreadedAnimation = sel_registerName("usesThreadedAnimation");
+    public static /*const*/ string sel_shortStandaloneQuarterSymbols = sel_registerName("shortStandaloneQuarterSymbols");
+    public static /*const*/ string sel_browser_1validateDrop_1proposedRow_1column_1dropOperation_1 = sel_registerName("browser:validateDrop:proposedRow:column:dropOperation:");
+    public static /*const*/ string sel_setLineSpacing_1 = sel_registerName("setLineSpacing:");
+    public static /*const*/ string sel_indexOfItemWithTitle_1 = sel_registerName("indexOfItemWithTitle:");
+    public static /*const*/ string sel_subrowsKeyPath = sel_registerName("subrowsKeyPath");
+    public static /*const*/ string sel_showsResizeIndicator = sel_registerName("showsResizeIndicator");
+    public static /*const*/ string sel_setState_1 = sel_registerName("setState:");
+    public static /*const*/ string sel_fileAttributesAtPath_1traverseLink_1 = sel_registerName("fileAttributesAtPath:traverseLink:");
+    public static /*const*/ string sel_setHorizontal_1 = sel_registerName("setHorizontal:");
+    public static /*const*/ string sel_windowDidExpose_1 = sel_registerName("windowDidExpose:");
+    public static /*const*/ string sel_systemID = sel_registerName("systemID");
+    public static /*const*/ string sel_turnOffKerning_1 = sel_registerName("turnOffKerning:");
+    public static /*const*/ string sel_StringByReplacingPercentEscapesUsingEncoding_1 = sel_registerName("StringByReplacingPercentEscapesUsingEncoding:");
+    public static /*const*/ string sel_control_1textView_1completions_1forPartialWordRange_1indexOfSelectedItem_1 = sel_registerName("control:textView:completions:forPartialWordRange:indexOfSelectedItem:");
+    public static /*const*/ string sel_selectLastTabViewItem_1 = sel_registerName("selectLastTabViewItem:");
+    public static /*const*/ string sel_setKeyEquivalentFont_1 = sel_registerName("setKeyEquivalentFont:");
+    public static /*const*/ string sel_invalidateCursorRectsForView_1 = sel_registerName("invalidateCursorRectsForView:");
+    public static /*const*/ string sel_selectTextAtIndex_1 = sel_registerName("selectTextAtIndex:");
+    public static /*const*/ string sel_showPools = sel_registerName("showPools");
+    public static /*const*/ string sel_setPlaysSelectionOnly_1 = sel_registerName("setPlaysSelectionOnly:");
+    public static /*const*/ string sel_note = sel_registerName("note");
+    public static /*const*/ string sel_setDrawsCellBackground_1 = sel_registerName("setDrawsCellBackground:");
+    public static /*const*/ string sel_layoutCharactersInRange_1forLayoutManager_1maximumNumberOfLineFragments_1 = sel_registerName("layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments:");
+    public static /*const*/ string sel_lengthOfBytesUsingEncoding_1 = sel_registerName("lengthOfBytesUsingEncoding:");
+    public static /*const*/ string sel_columnResizingType = sel_registerName("columnResizingType");
+    public static /*const*/ string sel_paragraphSeparatorGlyphRange = sel_registerName("paragraphSeparatorGlyphRange");
+    public static /*const*/ string sel_floatValue = sel_registerName("floatValue");
+    public static /*const*/ string sel_setRoundingIncrement_1 = sel_registerName("setRoundingIncrement:");
+    public static /*const*/ string sel_dateFromString_1 = sel_registerName("dateFromString:");
+    public static /*const*/ string sel_panel_1shouldShowFilename_1 = sel_registerName("panel:shouldShowFilename:");
+    public static /*const*/ string sel_isEqualToDate_1 = sel_registerName("isEqualToDate:");
+    public static /*const*/ string sel_drawWithFrame_1inView_1characterIndex_1 = sel_registerName("drawWithFrame:inView:characterIndex:");
+    public static /*const*/ string sel_initWithInteger_1 = sel_registerName("initWithInteger:");
+    public static /*const*/ string sel_CGImage = sel_registerName("CGImage");
+    public static /*const*/ string sel_endDocument = sel_registerName("endDocument");
+    public static /*const*/ string sel_removeFile = sel_registerName("removeFile");
+    public static /*const*/ string sel_splitView_1shouldCollapseSubview_1forDoubleClickOnDividerAtIndex_1 = sel_registerName("splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:");
+    public static /*const*/ string sel_setDefaultMiterLimit_1 = sel_registerName("setDefaultMiterLimit:");
+    public static /*const*/ string sel_keyCode = sel_registerName("keyCode");
+    public static /*const*/ string sel_raise_1format_1 = sel_registerName("raise:format:");
+    public static /*const*/ string sel_cellSize = sel_registerName("cellSize");
+    public static /*const*/ string sel_runModalForWindow_1 = sel_registerName("runModalForWindow:");
+    public static /*const*/ string sel_colorListNamed_1 = sel_registerName("colorListNamed:");
+    public static /*const*/ string sel_detachColorList_1 = sel_registerName("detachColorList:");
+    public static /*const*/ string sel_postEvent_1atStart_1 = sel_registerName("postEvent:atStart:");
+    public static /*const*/ string sel_setMaximumFractionDigits_1 = sel_registerName("setMaximumFractionDigits:");
+    public static /*const*/ string sel_setVolatileDomain_1forName_1 = sel_registerName("setVolatileDomain:forName:");
+    public static /*const*/ string sel_imageInterpolation = sel_registerName("imageInterpolation");
+    public static /*const*/ string sel_setTitlePosition_1 = sel_registerName("setTitlePosition:");
+    public static /*const*/ string sel_leadingOffset = sel_registerName("leadingOffset");
+    public static /*const*/ string sel_invokeWithTarget_1 = sel_registerName("invokeWithTarget:");
+    public static /*const*/ string sel_negativeFormat = sel_registerName("negativeFormat");
+    public static /*const*/ string sel_windowController = sel_registerName("windowController");
+    public static /*const*/ string sel_setVerticalPageScroll_1 = sel_registerName("setVerticalPageScroll:");
+    public static /*const*/ string sel_applicationDidUpdate_1 = sel_registerName("applicationDidUpdate:");
+    public static /*const*/ string sel_valueForProperty_1 = sel_registerName("valueForProperty:");
+    public static /*const*/ string sel_tokenField_1hasMenuForRepresentedObject_1 = sel_registerName("tokenField:hasMenuForRepresentedObject:");
+    public static /*const*/ string sel_resolveClassMethod_1 = sel_registerName("resolveClassMethod:");
+    public static /*const*/ string sel_setAutomaticQuoteSubstitutionEnabled_1 = sel_registerName("setAutomaticQuoteSubstitutionEnabled:");
+    public static /*const*/ string sel_ordinalityOfUnit_1inUnit_1forDate_1 = sel_registerName("ordinalityOfUnit:inUnit:forDate:");
+    public static /*const*/ string sel_initWithHost_1port_1protocol_1realm_1authenticationMethod_1 = sel_registerName("initWithHost:port:protocol:realm:authenticationMethod:");
+    public static /*const*/ string sel_timeIntervalSinceNow = sel_registerName("timeIntervalSinceNow");
+    public static /*const*/ string sel_showFindIndicatorForRange_1 = sel_registerName("showFindIndicatorForRange:");
+    public static /*const*/ string sel_drawLabel_1inRect_1 = sel_registerName("drawLabel:inRect:");
+    public static /*const*/ string sel_startQuery = sel_registerName("startQuery");
+    public static /*const*/ string sel_initWithNibNamed_1bundle_1 = sel_registerName("initWithNibNamed:bundle:");
+    public static /*const*/ string sel_firstResponder = sel_registerName("firstResponder");
+    public static /*const*/ string sel_windowWillMove_1 = sel_registerName("windowWillMove:");
+    public static /*const*/ string sel_dictionaryForKey_1 = sel_registerName("dictionaryForKey:");
+    public static /*const*/ string sel_decodeValueOfObjCType_1at_1 = sel_registerName("decodeValueOfObjCType:at:");
+    public static /*const*/ string sel_activeApplication = sel_registerName("activeApplication");
+    public static /*const*/ string sel_initWithUnsignedLongLong_1 = sel_registerName("initWithUnsignedLongLong:");
+    public static /*const*/ string sel_decimalNumberWithString_1 = sel_registerName("decimalNumberWithString:");
+    public static /*const*/ string sel_replaceTextStorage_1 = sel_registerName("replaceTextStorage:");
+    public static /*const*/ string sel_relativePosition = sel_registerName("relativePosition");
+    public static /*const*/ string sel_objectValueOfSelectedItem = sel_registerName("objectValueOfSelectedItem");
+    public static /*const*/ string sel_timeInterval = sel_registerName("timeInterval");
+    public static /*const*/ string sel_getBytes_1range_1 = sel_registerName("getBytes:range:");
+    public static /*const*/ string sel_initWithViewAnimations_1 = sel_registerName("initWithViewAnimations:");
+    public static /*const*/ string sel_setHorizontalRulerView_1 = sel_registerName("setHorizontalRulerView:");
+    public static /*const*/ string sel_keyPathsForValuesAffectingPreview = sel_registerName("keyPathsForValuesAffectingPreview");
+    public static /*const*/ string sel_setWithObjects_1count_1 = sel_registerName("setWithObjects:count:");
+    public static /*const*/ string sel_bitsPerSample = sel_registerName("bitsPerSample");
+    public static /*const*/ string sel_dayOfYear = sel_registerName("dayOfYear");
+    public static /*const*/ string sel_maximumFractionDigits = sel_registerName("maximumFractionDigits");
+    public static /*const*/ string sel_isSelectionByRect = sel_registerName("isSelectionByRect");
+    public static /*const*/ string sel_getRed_1green_1blue_1alpha_1 = sel_registerName("getRed:green:blue:alpha:");
+    public static /*const*/ string sel_glyphIsEncoded_1 = sel_registerName("glyphIsEncoded:");
+    public static /*const*/ string sel_setStartSubelementIdentifier_1 = sel_registerName("setStartSubelementIdentifier:");
+    public static /*const*/ string sel_connection_1didFailWithError_1 = sel_registerName("connection:didFailWithError:");
+    public static /*const*/ string sel_parser_1foundExternalEntityDeclarationWithName_1publicID_1systemID_1 = sel_registerName("parser:foundExternalEntityDeclarationWithName:publicID:systemID:");
+    public static /*const*/ string sel_outlineView_1shouldTypeSelectForEvent_1withCurrentSearchString_1 = sel_registerName("outlineView:shouldTypeSelectForEvent:withCurrentSearchString:");
+    public static /*const*/ string sel_lowerBaseline_1 = sel_registerName("lowerBaseline:");
+    public static /*const*/ string sel_outlineView_1willDisplayCell_1forTableColumn_1item_1 = sel_registerName("outlineView:willDisplayCell:forTableColumn:item:");
+    public static /*const*/ string sel_notificationWithName_1object_1userInfo_1 = sel_registerName("notificationWithName:object:userInfo:");
+    public static /*const*/ string sel_setMaxConcurrentOperationCount_1 = sel_registerName("setMaxConcurrentOperationCount:");
+    public static /*const*/ string sel_closeSpellDocumentWithTag_1 = sel_registerName("closeSpellDocumentWithTag:");
+    public static /*const*/ string sel_popUpStatusItemMenu_1 = sel_registerName("popUpStatusItemMenu:");
+    public static /*const*/ string sel_itemPrototype = sel_registerName("itemPrototype");
+    public static /*const*/ string sel_commandName = sel_registerName("commandName");
+    public static /*const*/ string sel_setTextAttributesForZero_1 = sel_registerName("setTextAttributesForZero:");
+    public static /*const*/ string sel_dateFromComponents_1 = sel_registerName("dateFromComponents:");
+    public static /*const*/ string sel_outlineViewColumnDidResize_1 = sel_registerName("outlineViewColumnDidResize:");
+    public static /*const*/ string sel_setTailIndent_1 = sel_registerName("setTailIndent:");
+    public static /*const*/ string sel_setRowTemplates_1 = sel_registerName("setRowTemplates:");
+    public static /*const*/ string sel_objectsForXQuery_1constants_1error_1 = sel_registerName("objectsForXQuery:constants:error:");
+    public static /*const*/ string sel_mutableCopyWithZone_1 = sel_registerName("mutableCopyWithZone:");
+    public static /*const*/ string sel_initWithItemIdentifier_1 = sel_registerName("initWithItemIdentifier:");
+    public static /*const*/ string sel_minuteOfHour = sel_registerName("minuteOfHour");
+    public static /*const*/ string sel_setAutosavingDelay_1 = sel_registerName("setAutosavingDelay:");
+    public static /*const*/ string sel_nextKeyView = sel_registerName("nextKeyView");
+    public static /*const*/ string sel_orderFront_1 = sel_registerName("orderFront:");
+    public static /*const*/ string sel_encodeValueOfObjCType_1at_1 = sel_registerName("encodeValueOfObjCType:at:");
+    public static /*const*/ string sel_mode = sel_registerName("mode");
+    public static /*const*/ string sel_appleEventWithEventClass_1eventID_1targetDescriptor_1returnID_1transactionID_1 = sel_registerName("appleEventWithEventClass:eventID:targetDescriptor:returnID:transactionID:");
+    public static /*const*/ string sel_StringByDeletingPathExtension = sel_registerName("StringByDeletingPathExtension");
+    public static /*const*/ string sel_standardOutput = sel_registerName("standardOutput");
+    public static /*const*/ string sel_enumCodeValue = sel_registerName("enumCodeValue");
+    public static /*const*/ string sel_setResourceData_1 = sel_registerName("setResourceData:");
+    public static /*const*/ string sel_convertRectFromBase_1 = sel_registerName("convertRectFromBase:");
+    public static /*const*/ string sel_initWithContentRect_1styleMask_1backing_1defer_1screen_1 = sel_registerName("initWithContentRect:styleMask:backing:defer:screen:");
+    public static /*const*/ string sel_autoenablesItems = sel_registerName("autoenablesItems");
+    public static /*const*/ string sel_textContainerForGlyphAtIndex_1effectiveRange_1withoutAdditionalLayout_1 = sel_registerName("textContainerForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:");
+    public static /*const*/ string sel_QTMovie = sel_registerName("QTMovie");
+    public static /*const*/ string sel_addObserver_1selector_1name_1object_1suspensionBehavior_1 = sel_registerName("addObserver:selector:name:object:suspensionBehavior:");
+    public static /*const*/ string sel_getArgument_1atIndex_1 = sel_registerName("getArgument:atIndex:");
+    public static /*const*/ string sel_replaceChildAtIndex_1withNode_1 = sel_registerName("replaceChildAtIndex:withNode:");
+    public static /*const*/ string sel_beginForDirectory_1file_1types_1modelessDelegate_1didEndSelector_1contextInfo_1 = sel_registerName("beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:");
+    public static /*const*/ string sel_supportsMode_1 = sel_registerName("supportsMode:");
+    public static /*const*/ string sel_openFile_1 = sel_registerName("openFile:");
+    public static /*const*/ string sel_zero = sel_registerName("zero");
+    public static /*const*/ string sel_compositingFilter = sel_registerName("compositingFilter");
+    public static /*const*/ string sel_fileGroupOwnerAccountID = sel_registerName("fileGroupOwnerAccountID");
+    public static /*const*/ string sel_tokenField_1writeRepresentedObjects_1toPasteboard_1 = sel_registerName("tokenField:writeRepresentedObjects:toPasteboard:");
+    public static /*const*/ string sel_tabViewType = sel_registerName("tabViewType");
+    public static /*const*/ string sel_drawSortIndicatorWithFrame_1inView_1ascending_1priority_1 = sel_registerName("drawSortIndicatorWithFrame:inView:ascending:priority:");
+    public static /*const*/ string sel_spellCheckerDocumentTag = sel_registerName("spellCheckerDocumentTag");
+    public static /*const*/ string sel_updateFromPMPageFormat = sel_registerName("updateFromPMPageFormat");
+    public static /*const*/ string sel_colorSyncProfile = sel_registerName("colorSyncProfile");
+    public static /*const*/ string sel_flushBufferedKeyEvents = sel_registerName("flushBufferedKeyEvents");
+    public static /*const*/ string sel_removeAllObjects = sel_registerName("removeAllObjects");
+    public static /*const*/ string sel_selectItemWithTitle_1 = sel_registerName("selectItemWithTitle:");
+    public static /*const*/ string sel_textContainers = sel_registerName("textContainers");
+    public static /*const*/ string sel_isHorizontallyResizable = sel_registerName("isHorizontallyResizable");
+    public static /*const*/ string sel_selectionIndexPaths = sel_registerName("selectionIndexPaths");
+    public static /*const*/ string sel_setString_1forType_1 = sel_registerName("setString:forType:");
+    public static /*const*/ string sel_setWraps_1 = sel_registerName("setWraps:");
+    public static /*const*/ string sel_dataCell = sel_registerName("dataCell");
+    public static /*const*/ string sel_addPointer_1 = sel_registerName("addPointer:");
+    public static /*const*/ string sel_invalidate = sel_registerName("invalidate");
+    public static /*const*/ string sel_draggingImageForRowsWithIndexes_1inColumn_1withEvent_1offset_1 = sel_registerName("draggingImageForRowsWithIndexes:inColumn:withEvent:offset:");
+    public static /*const*/ string sel_horizontalEdgePadding = sel_registerName("horizontalEdgePadding");
+    public static /*const*/ string sel_view = sel_registerName("view");
+    public static /*const*/ string sel_showsPrintPanel = sel_registerName("showsPrintPanel");
+    public static /*const*/ string sel_hyphenationFactor = sel_registerName("hyphenationFactor");
+    public static /*const*/ string sel_setAcceptsGlyphInfo_1 = sel_registerName("setAcceptsGlyphInfo:");
+    public static /*const*/ string sel_formatWidth = sel_registerName("formatWidth");
+    public static /*const*/ string sel_StringByAppendingFormat_1 = sel_registerName("StringByAppendingFormat:");
+    public static /*const*/ string sel_documentForFileName_1 = sel_registerName("documentForFileName:");
+    public static /*const*/ string sel_outlineView_1nextTypeSelectMatchFromItem_1toItem_1forString_1 = sel_registerName("outlineView:nextTypeSelectMatchFromItem:toItem:forString:");
+    public static /*const*/ string sel_isItemExpanded_1 = sel_registerName("isItemExpanded:");
+    public static /*const*/ string sel_playbackDeviceIdentifier = sel_registerName("playbackDeviceIdentifier");
+    public static /*const*/ string sel_addButtonWithTitle_1 = sel_registerName("addButtonWithTitle:");
+    public static /*const*/ string sel_lowercaseLetterCharacterSet = sel_registerName("lowercaseLetterCharacterSet");
+    public static /*const*/ string sel_netService_1didNotResolve_1 = sel_registerName("netService:didNotResolve:");
+    public static /*const*/ string sel_copiesOnScroll = sel_registerName("copiesOnScroll");
+    public static /*const*/ string sel_unarchiver_1willReplaceObject_1withObject_1 = sel_registerName("unarchiver:willReplaceObject:withObject:");
+    public static /*const*/ string sel_setHasShadow_1 = sel_registerName("setHasShadow:");
+    public static /*const*/ string sel_addObserver_1selector_1name_1object_1 = sel_registerName("addObserver:selector:name:object:");
+    public static /*const*/ string sel_setDouble_1forKey_1 = sel_registerName("setDouble:forKey:");
+    public static /*const*/ string sel_positionOfGlyph_1struckOverRect_1metricsExist_1 = sel_registerName("positionOfGlyph:struckOverRect:metricsExist:");
+    public static /*const*/ string sel_sharedInstance = sel_registerName("sharedInstance");
+    public static /*const*/ string sel_setPaperSize_1 = sel_registerName("setPaperSize:");
+    public static /*const*/ string sel_data1 = sel_registerName("data1");
+    public static /*const*/ string sel_applicationWillBecomeActive_1 = sel_registerName("applicationWillBecomeActive:");
+    public static /*const*/ string sel_URLProtocol_1cachedResponseIsValid_1 = sel_registerName("URLProtocol:cachedResponseIsValid:");
+    public static /*const*/ string sel_mouseDown_1 = sel_registerName("mouseDown:");
+    public static /*const*/ string sel_setVeryShortStandaloneWeekdaySymbols_1 = sel_registerName("setVeryShortStandaloneWeekdaySymbols:");
+    public static /*const*/ string sel_setUsesStrongWriteBarrier_1 = sel_registerName("setUsesStrongWriteBarrier:");
+    public static /*const*/ string sel_second = sel_registerName("second");
+    public static /*const*/ string sel_predicateWithLeftExpression_1rightExpression_1modifier_1type_1options_1 = sel_registerName("predicateWithLeftExpression:rightExpression:modifier:type:options:");
+    public static /*const*/ string sel_setFloatingPanel_1 = sel_registerName("setFloatingPanel:");
+    public static /*const*/ string sel_parser_1didEndElement_1namespaceURI_1qualifiedName_1 = sel_registerName("parser:didEndElement:namespaceURI:qualifiedName:");
+    public static /*const*/ string sel_handlePortMessage_1 = sel_registerName("handlePortMessage:");
+    public static /*const*/ string sel_filteredSetUsingPredicate_1 = sel_registerName("filteredSetUsingPredicate:");
+    public static /*const*/ string sel_setLocalizedKeyDictionary_1 = sel_registerName("setLocalizedKeyDictionary:");
+    public static /*const*/ string sel_drawCellInside_1 = sel_registerName("drawCellInside:");
+    public static /*const*/ string sel_browserDidScroll_1 = sel_registerName("browserDidScroll:");
+    public static /*const*/ string sel_isDirectory = sel_registerName("isDirectory");
+    public static /*const*/ string sel_setEnvironment_1 = sel_registerName("setEnvironment:");
+    public static /*const*/ string sel_persistence = sel_registerName("persistence");
+    public static /*const*/ string sel_backingType = sel_registerName("backingType");
+    public static /*const*/ string sel_orderedDocuments = sel_registerName("orderedDocuments");
+    public static /*const*/ string sel_windowWillUseStandardFrame_1defaultFrame_1 = sel_registerName("windowWillUseStandardFrame:defaultFrame:");
+    public static /*const*/ string sel_toggleTraditionalCharacterShape_1 = sel_registerName("toggleTraditionalCharacterShape:");
+    public static /*const*/ string sel_fractionOfDistanceThroughGlyphForPoint_1 = sel_registerName("fractionOfDistanceThroughGlyphForPoint:");
+    public static /*const*/ string sel_netServiceWillPublish_1 = sel_registerName("netServiceWillPublish:");
+    public static /*const*/ string sel_drawInRect_1relativeCenterPosition_1 = sel_registerName("drawInRect:relativeCenterPosition:");
+    public static /*const*/ string sel_setShowsAlpha_1 = sel_registerName("setShowsAlpha:");
+    public static /*const*/ string sel_canDragRowsWithIndexes_1inColumn_1withEvent_1 = sel_registerName("canDragRowsWithIndexes:inColumn:withEvent:");
+    public static /*const*/ string sel_start = sel_registerName("start");
+    public static /*const*/ string sel_imageRectInRuler = sel_registerName("imageRectInRuler");
+    public static /*const*/ string sel_TXTRecordData = sel_registerName("TXTRecordData");
+    public static /*const*/ string sel_groupingLevel = sel_registerName("groupingLevel");
+    public static /*const*/ string sel_response = sel_registerName("response");
+    public static /*const*/ string sel_insertionIndex = sel_registerName("insertionIndex");
+    public static /*const*/ string sel_cancelPreviousPerformRequestsWithTarget_1selector_1object_1 = sel_registerName("cancelPreviousPerformRequestsWithTarget:selector:object:");
+    public static /*const*/ string sel_itemWithTitle_1 = sel_registerName("itemWithTitle:");
+    public static /*const*/ string sel_insertRow_1 = sel_registerName("insertRow:");
+    public static /*const*/ string sel_mutableChildNodes = sel_registerName("mutableChildNodes");
+    public static /*const*/ string sel_removeAllPoints = sel_registerName("removeAllPoints");
+    public static /*const*/ string sel_searchForRegistrationDomains = sel_registerName("searchForRegistrationDomains");
+    public static /*const*/ string sel_replacementObjectForCoder_1 = sel_registerName("replacementObjectForCoder:");
+    public static /*const*/ string sel_tangentialPressure = sel_registerName("tangentialPressure");
+    public static /*const*/ string sel_setMaxDate_1 = sel_registerName("setMaxDate:");
+    public static /*const*/ string sel_performMnemonic_1 = sel_registerName("performMnemonic:");
+    public static /*const*/ string sel_maximumRecentDocumentCount = sel_registerName("maximumRecentDocumentCount");
+    public static /*const*/ string sel_StringsByAppendingPaths_1 = sel_registerName("StringsByAppendingPaths:");
+    public static /*const*/ string sel_localTimeZone = sel_registerName("localTimeZone");
+    public static /*const*/ string sel_draggingLocation = sel_registerName("draggingLocation");
+    public static /*const*/ string sel_searchForAllDomains = sel_registerName("searchForAllDomains");
+    public static /*const*/ string sel_attributedStringWithAttachment_1 = sel_registerName("attributedStringWithAttachment:");
+    public static /*const*/ string sel_initWithContentsOfURL_1byReference_1 = sel_registerName("initWithContentsOfURL:byReference:");
+    public static /*const*/ string sel_exchangeObjectAtIndex_1withObjectAtIndex_1 = sel_registerName("exchangeObjectAtIndex:withObjectAtIndex:");
+    public static /*const*/ string sel_draw = sel_registerName("draw");
+    public static /*const*/ string sel_fileIsImmutable = sel_registerName("fileIsImmutable");
+    public static /*const*/ string sel_tokenField_1styleForRepresentedObject_1 = sel_registerName("tokenField:styleForRepresentedObject:");
+    public static /*const*/ string sel_setAutorecalculatesContentBorderThickness_1forEdge_1 = sel_registerName("setAutorecalculatesContentBorderThickness:forEdge:");
+    public static /*const*/ string sel_firstRectForCharacterRange_1actualRange_1 = sel_registerName("firstRectForCharacterRange:actualRange:");
+    public static /*const*/ string sel_targetForAction_1to_1from_1 = sel_registerName("targetForAction:to:from:");
+    public static /*const*/ string sel_setShouldCloseDocument_1 = sel_registerName("setShouldCloseDocument:");
+    public static /*const*/ string sel_originOffset = sel_registerName("originOffset");
+    public static /*const*/ string sel_sharedSupportPath = sel_registerName("sharedSupportPath");
+    public static /*const*/ string sel_disableScreenUpdatesUntilFlush = sel_registerName("disableScreenUpdatesUntilFlush");
+    public static /*const*/ string sel_setShortStandaloneQuarterSymbols_1 = sel_registerName("setShortStandaloneQuarterSymbols:");
+    public static /*const*/ string sel_filenames = sel_registerName("filenames");
+    public static /*const*/ string sel_numberOfItemsInComboBox_1 = sel_registerName("numberOfItemsInComboBox:");
+    public static /*const*/ string sel_hasBytesAvailable = sel_registerName("hasBytesAvailable");
+    public static /*const*/ string sel_currentConversation = sel_registerName("currentConversation");
+    public static /*const*/ string sel_setAllowsEditingTextAttributes_1 = sel_registerName("setAllowsEditingTextAttributes:");
+    public static /*const*/ string sel_initWithName_1StringValue_1 = sel_registerName("initWithName:StringValue:");
+    public static /*const*/ string sel_tableViewColumnDidResize_1 = sel_registerName("tableViewColumnDidResize:");
+    public static /*const*/ string sel_knowsPageRange_1 = sel_registerName("knowsPageRange:");
+    public static /*const*/ string sel_uppercaseLetterCharacterSet = sel_registerName("uppercaseLetterCharacterSet");
+    public static /*const*/ string sel_capitalizedLetterCharacterSet = sel_registerName("capitalizedLetterCharacterSet");
+    public static /*const*/ string sel_main = sel_registerName("main");
+    public static /*const*/ string sel_genericRGBColorSpace = sel_registerName("genericRGBColorSpace");
+    public static /*const*/ string sel_clearsFilterPredicateOnInsertion = sel_registerName("clearsFilterPredicateOnInsertion");
+    public static /*const*/ string sel_paragraphs = sel_registerName("paragraphs");
+    public static /*const*/ string sel_setJobDisposition_1 = sel_registerName("setJobDisposition:");
+    public static /*const*/ string sel_setContainerClassDescription_1 = sel_registerName("setContainerClassDescription:");
+    public static /*const*/ string sel_StringWithContentsOfURL_1 = sel_registerName("StringWithContentsOfURL:");
+    public static /*const*/ string sel_setTrackingMode_1 = sel_registerName("setTrackingMode:");
+    public static /*const*/ string sel_canCloseDocumentWithDelegate_1shouldCloseSelector_1contextInfo_1 = sel_registerName("canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:");
+    public static /*const*/ string sel_usesItemFromMenu = sel_registerName("usesItemFromMenu");
+    public static /*const*/ string sel_shortValue = sel_registerName("shortValue");
+    public static /*const*/ string sel_readDataOfLength_1 = sel_registerName("readDataOfLength:");
+    public static /*const*/ string sel_descriptorWithDescriptorType_1data_1 = sel_registerName("descriptorWithDescriptorType:data:");
+    public static /*const*/ string sel_setCanRemoveAllRows_1 = sel_registerName("setCanRemoveAllRows:");
+    public static /*const*/ string sel_defaultCenter = sel_registerName("defaultCenter");
+    public static /*const*/ string sel_scriptingIsGreaterThan_1 = sel_registerName("scriptingIsGreaterThan:");
+    public static /*const*/ string sel_splitView_1constrainSplitPosition_1ofSubviewAt_1 = sel_registerName("splitView:constrainSplitPosition:ofSubviewAt:");
+    public static /*const*/ string sel_setTokenStyle_1 = sel_registerName("setTokenStyle:");
+    public static /*const*/ string sel_initWithContentRect_1styleMask_1backing_1defer_1 = sel_registerName("initWithContentRect:styleMask:backing:defer:");
+    public static /*const*/ string sel_insertTabViewItem_1atIndex_1 = sel_registerName("insertTabViewItem:atIndex:");
+    public static /*const*/ string sel_rowForDisplayValue_1 = sel_registerName("rowForDisplayValue:");
+    public static /*const*/ string sel_isDrawingToScreen = sel_registerName("isDrawingToScreen");
+    public static /*const*/ string sel_encodeRect_1 = sel_registerName("encodeRect:");
+    public static /*const*/ string sel_controlDarkShadowColor = sel_registerName("controlDarkShadowColor");
+    public static /*const*/ string sel_maxDate = sel_registerName("maxDate");
+    public static /*const*/ string sel_lock = sel_registerName("lock");
+    public static /*const*/ string sel_resetSystemTimeZone = sel_registerName("resetSystemTimeZone");
+    public static /*const*/ string sel_coerceValue_1toClass_1 = sel_registerName("coerceValue:toClass:");
+    public static /*const*/ string sel_qdPort = sel_registerName("qdPort");
+    public static /*const*/ string sel_resultAtIndex_1 = sel_registerName("resultAtIndex:");
+    public static /*const*/ string sel_descriptorWithBoolean_1 = sel_registerName("descriptorWithBoolean:");
+    public static /*const*/ string sel_markedRange = sel_registerName("markedRange");
+    public static /*const*/ string sel_colorWithCalibratedHue_1saturation_1brightness_1alpha_1 = sel_registerName("colorWithCalibratedHue:saturation:brightness:alpha:");
+    public static /*const*/ string sel_setSharedPrintInfo_1 = sel_registerName("setSharedPrintInfo:");
+    public static /*const*/ string sel_setBorderColor_1 = sel_registerName("setBorderColor:");
+    public static /*const*/ string sel_parser_1foundCharacters_1 = sel_registerName("parser:foundCharacters:");
+    public static /*const*/ string sel_preferredPasteboardTypeFromArray_1restrictedToTypesFromArray_1 = sel_registerName("preferredPasteboardTypeFromArray:restrictedToTypesFromArray:");
+    public static /*const*/ string sel_resume = sel_registerName("resume");
+    public static /*const*/ string sel_iconForFiles_1 = sel_registerName("iconForFiles:");
+    public static /*const*/ string sel_drawKeyEquivalentWithFrame_1inView_1 = sel_registerName("drawKeyEquivalentWithFrame:inView:");
+    public static /*const*/ string sel_boxType = sel_registerName("boxType");
+    public static /*const*/ string sel_initWithContainerClassDescription_1containerSpecifier_1key_1name_1 = sel_registerName("initWithContainerClassDescription:containerSpecifier:key:name:");
+    public static /*const*/ string sel_setFill = sel_registerName("setFill");
+    public static /*const*/ string sel_setParagraphGlyphRange_1separatorGlyphRange_1 = sel_registerName("setParagraphGlyphRange:separatorGlyphRange:");
+    public static /*const*/ string sel_copyWithZone_1 = sel_registerName("copyWithZone:");
+    public static /*const*/ string sel_self = sel_registerName("self");
+    public static /*const*/ string sel_reservedSpaceLength = sel_registerName("reservedSpaceLength");
+    public static /*const*/ string sel_unsignedIntValue = sel_registerName("unsignedIntValue");
+    public static /*const*/ string sel_URLHandleResourceDidFinishLoading_1 = sel_registerName("URLHandleResourceDidFinishLoading:");
+    public static /*const*/ string sel_menuWillOpen_1 = sel_registerName("menuWillOpen:");
+    public static /*const*/ string sel_menuWillClose_1 = sel_registerName("menuWillClose:");
+    public static /*const*/ string sel_pointerArrayWithWeakObjects = sel_registerName("pointerArrayWithWeakObjects");
+    public static /*const*/ string sel_fetchPredicate = sel_registerName("fetchPredicate");
+    public static /*const*/ string sel_pathToColumn_1 = sel_registerName("pathToColumn:");
+    public static /*const*/ string sel_columnWithIdentifier_1 = sel_registerName("columnWithIdentifier:");
+    public static /*const*/ string sel_setShouldCreateUI_1 = sel_registerName("setShouldCreateUI:");
+    public static /*const*/ string sel_getGlyphs_1range_1 = sel_registerName("getGlyphs:range:");
+    public static /*const*/ string sel_returnID = sel_registerName("returnID");
+    public static /*const*/ string sel_miterLimit = sel_registerName("miterLimit");
+    public static /*const*/ string sel_hidesEmptyCells = sel_registerName("hidesEmptyCells");
+    public static /*const*/ string sel_userSpaceScaleFactor = sel_registerName("userSpaceScaleFactor");
+    public static /*const*/ string sel_xHeight = sel_registerName("xHeight");
+    public static /*const*/ string sel_decimalNumberByMultiplyingBy_1withBehavior_1 = sel_registerName("decimalNumberByMultiplyingBy:withBehavior:");
+    public static /*const*/ string sel_reloadData = sel_registerName("reloadData");
+    public static /*const*/ string sel_setShortWeekdaySymbols_1 = sel_registerName("setShortWeekdaySymbols:");
+    public static /*const*/ string sel_containsIndexesInRange_1 = sel_registerName("containsIndexesInRange:");
+    public static /*const*/ string sel_colorWithDeviceRed_1green_1blue_1alpha_1 = sel_registerName("colorWithDeviceRed:green:blue:alpha:");
+    public static /*const*/ string sel_screenFontWithRenderingMode_1 = sel_registerName("screenFontWithRenderingMode:");
+    public static /*const*/ string sel_suggestedFilename = sel_registerName("suggestedFilename");
+    public static /*const*/ string sel_fileNameExtensionForType_1saveOperation_1 = sel_registerName("fileNameExtensionForType:saveOperation:");
+    public static /*const*/ string sel_labelFontSize = sel_registerName("labelFontSize");
+    public static /*const*/ string sel_setAlphaValue_1 = sel_registerName("setAlphaValue:");
+    public static /*const*/ string sel_openGLContext = sel_registerName("openGLContext");
+    public static /*const*/ string sel_scriptingIsLessThan_1 = sel_registerName("scriptingIsLessThan:");
+    public static /*const*/ string sel_keysSortedByValueUsingSelector_1 = sel_registerName("keysSortedByValueUsingSelector:");
+    public static /*const*/ string sel_control_1didFailToValidatePartialString_1errorDescription_1 = sel_registerName("control:didFailToValidatePartialString:errorDescription:");
+    public static /*const*/ string sel_offStateImage = sel_registerName("offStateImage");
+    public static /*const*/ string sel_bidiProcessingEnabled = sel_registerName("bidiProcessingEnabled");
+    public static /*const*/ string sel_isKeyWindow = sel_registerName("isKeyWindow");
+    public static /*const*/ string sel_initWithIconRef_1 = sel_registerName("initWithIconRef:");
+    public static /*const*/ string sel_changeCurrentDirectoryPath_1 = sel_registerName("changeCurrentDirectoryPath:");
+    public static /*const*/ string sel_textView = sel_registerName("textView");
+    public static /*const*/ string sel_localizedStringForStatusCode_1 = sel_registerName("localizedStringForStatusCode:");
+    public static /*const*/ string sel_setWantsLayer_1 = sel_registerName("setWantsLayer:");
+    public static /*const*/ string sel_positivePrefix = sel_registerName("positivePrefix");
+    public static /*const*/ string sel_setDefaultFlatness_1 = sel_registerName("setDefaultFlatness:");
+    public static /*const*/ string sel_addChild_1 = sel_registerName("addChild:");
+    public static /*const*/ string sel_parser_1foundAttributeDeclarationWithName_1forElement_1type_1defaultValue_1 = sel_registerName("parser:foundAttributeDeclarationWithName:forElement:type:defaultValue:");
+    public static /*const*/ string sel_scannerWithString_1 = sel_registerName("scannerWithString:");
+    public static /*const*/ string sel_removeFileWrapper_1 = sel_registerName("removeFileWrapper:");
+    public static /*const*/ string sel_setTitleWidth_1 = sel_registerName("setTitleWidth:");
+    public static /*const*/ string sel_setTabKeyTraversesCells_1 = sel_registerName("setTabKeyTraversesCells:");
+    public static /*const*/ string sel_glyphRangeForBoundingRect_1inTextContainer_1 = sel_registerName("glyphRangeForBoundingRect:inTextContainer:");
+    public static /*const*/ string sel_fileHandleForWritingAtPath_1 = sel_registerName("fileHandleForWritingAtPath:");
+    public static /*const*/ string sel_initWithContainerClassDescription_1containerSpecifier_1key_1 = sel_registerName("initWithContainerClassDescription:containerSpecifier:key:");
+    public static /*const*/ string sel_fontAttributes = sel_registerName("fontAttributes");
+    public static /*const*/ string sel_reviewUnsavedDocumentsWithAlertTitle_1cancellable_1delegate_1didReviewAllSelector_1contextInfo_1 = sel_registerName("reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:");
+    public static /*const*/ string sel_minWidth = sel_registerName("minWidth");
+    public static /*const*/ string sel_getLineFragmentInsertionPointsForCharacterAtIndex_1alternatePositions_1inDisplayOrder_1positions_1characterIndexes_1 = sel_registerName("getLineFragmentInsertionPointsForCharacterAtIndex:alternatePositions:inDisplayOrder:positions:characterIndexes:");
+    public static /*const*/ string sel_finishDecoding = sel_registerName("finishDecoding");
+    public static /*const*/ string sel_currentContextDrawingToScreen = sel_registerName("currentContextDrawingToScreen");
+    public static /*const*/ string sel_setKeyEquivalent_1 = sel_registerName("setKeyEquivalent:");
+    public static /*const*/ string sel_smartInsertForString_1replacingRange_1beforeString_1afterString_1 = sel_registerName("smartInsertForString:replacingRange:beforeString:afterString:");
+    public static /*const*/ string sel_useStandardKerning_1 = sel_registerName("useStandardKerning:");
+    public static /*const*/ string sel_sharedSystemTypesetter = sel_registerName("sharedSystemTypesetter");
+    public static /*const*/ string sel_setDatePickerMode_1 = sel_registerName("setDatePickerMode:");
+    public static /*const*/ string sel_encodePoint_1forKey_1 = sel_registerName("encodePoint:forKey:");
+    public static /*const*/ string sel_colorSpace = sel_registerName("colorSpace");
+    public static /*const*/ string sel_pasteboardByFilteringTypesInPasteboard_1 = sel_registerName("pasteboardByFilteringTypesInPasteboard:");
+    public static /*const*/ string sel_sendDoubleAction = sel_registerName("sendDoubleAction");
+    public static /*const*/ string sel_isColumnSelected_1 = sel_registerName("isColumnSelected:");
+    public static /*const*/ string sel_unarchiveObjectWithFile_1 = sel_registerName("unarchiveObjectWithFile:");
+    public static /*const*/ string sel_usesEPSOnResolutionMismatch = sel_registerName("usesEPSOnResolutionMismatch");
+    public static /*const*/ string sel_encodeBycopyObject_1 = sel_registerName("encodeBycopyObject:");
+    public static /*const*/ string sel_removeAttributeForName_1 = sel_registerName("removeAttributeForName:");
+    public static /*const*/ string sel_keyCell = sel_registerName("keyCell");
+    public static /*const*/ string sel_allocWithZone_1 = sel_registerName("allocWithZone:");
+    public static /*const*/ string sel_getCompression_1factor_1 = sel_registerName("getCompression:factor:");
+    public static /*const*/ string sel_insertValue_1inPropertyWithKey_1 = sel_registerName("insertValue:inPropertyWithKey:");
+    public static /*const*/ string sel_drawAtPoint_1withAttributes_1 = sel_registerName("drawAtPoint:withAttributes:");
+    public static /*const*/ string sel_isTrue = sel_registerName("isTrue");
+    public static /*const*/ string sel_expectedContentLength = sel_registerName("expectedContentLength");
+    public static /*const*/ string sel_setTitle_1 = sel_registerName("setTitle:");
+    public static /*const*/ string sel_connection_1didReceiveAuthenticationChallenge_1 = sel_registerName("connection:didReceiveAuthenticationChallenge:");
+    public static /*const*/ string sel_isEnabledForSegment_1 = sel_registerName("isEnabledForSegment:");
+    public static /*const*/ string sel_speechSynthesizer_1willSpeakPhoneme_1 = sel_registerName("speechSynthesizer:willSpeakPhoneme:");
+    public static /*const*/ string sel_setShowsStateColumn_1 = sel_registerName("setShowsStateColumn:");
+    public static /*const*/ string sel_requiredFileType = sel_registerName("requiredFileType");
+    public static /*const*/ string sel_convertRect_1fromView_1 = sel_registerName("convertRect:fromView:");
+    public static /*const*/ string sel_visibleFrame = sel_registerName("visibleFrame");
+    public static /*const*/ string sel_concludeDragOperation_1 = sel_registerName("concludeDragOperation:");
+    public static /*const*/ string sel_minimumFractionDigits = sel_registerName("minimumFractionDigits");
+    public static /*const*/ string sel_reopenDocumentForURL_1withContentsOfURL_1error_1 = sel_registerName("reopenDocumentForURL:withContentsOfURL:error:");
+    public static /*const*/ string sel_roundingMode = sel_registerName("roundingMode");
+    public static /*const*/ string sel_colorWithCatalogName_1colorName_1 = sel_registerName("colorWithCatalogName:colorName:");
+    public static /*const*/ string sel_setWithSet_1 = sel_registerName("setWithSet:");
+    public static /*const*/ string sel_fileManager_1willProcessPath_1 = sel_registerName("fileManager:willProcessPath:");
+    public static /*const*/ string sel_setSuspended_1 = sel_registerName("setSuspended:");
+    public static /*const*/ string sel_currentInputManager = sel_registerName("currentInputManager");
+    public static /*const*/ string sel_operatingSystemVersionString = sel_registerName("operatingSystemVersionString");
+    public static /*const*/ string sel_resetBytesInRange_1 = sel_registerName("resetBytesInRange:");
+    public static /*const*/ string sel_sizeForKey_1inTable_1 = sel_registerName("sizeForKey:inTable:");
+    public static /*const*/ string sel_setFloat_1forKey_1 = sel_registerName("setFloat:forKey:");
+    public static /*const*/ string sel_enableUndoRegistration = sel_registerName("enableUndoRegistration");
+    public static /*const*/ string sel_initWithCGImage_1 = sel_registerName("initWithCGImage:");
+    public static /*const*/ string sel_initWithCIImage_1 = sel_registerName("initWithCIImage:");
+    public static /*const*/ string sel_addCharactersInRange_1 = sel_registerName("addCharactersInRange:");
+    public static /*const*/ string sel_initWithRect_1options_1owner_1userInfo_1 = sel_registerName("initWithRect:options:owner:userInfo:");
+    public static /*const*/ string sel_incrementalLoadFromData_1complete_1 = sel_registerName("incrementalLoadFromData:complete:");
+    public static /*const*/ string sel_tableView_1acceptDrop_1row_1dropOperation_1 = sel_registerName("tableView:acceptDrop:row:dropOperation:");
+    public static /*const*/ string sel_classNamed_1 = sel_registerName("classNamed:");
+    public static /*const*/ string sel_setIndeterminate_1 = sel_registerName("setIndeterminate:");
+    public static /*const*/ string sel_normalizeAdjacentTextNodesPreservingCDATA_1 = sel_registerName("normalizeAdjacentTextNodesPreservingCDATA:");
+    public static /*const*/ string sel_validateUserInterfaceItem_1 = sel_registerName("validateUserInterfaceItem:");
+    public static /*const*/ string sel_setPlaysEveryFrame_1 = sel_registerName("setPlaysEveryFrame:");
+    public static /*const*/ string sel_isCompiled = sel_registerName("isCompiled");
+    public static /*const*/ string sel_tokenFieldCell_1editingStringForRepresentedObject_1 = sel_registerName("tokenFieldCell:editingStringForRepresentedObject:");
+    public static /*const*/ string sel_tableView_1isGroupRow_1 = sel_registerName("tableView:isGroupRow:");
+    public static /*const*/ string sel_orderFrontLinkPanel_1 = sel_registerName("orderFrontLinkPanel:");
+    public static /*const*/ string sel_alphaControlAddedOrRemoved_1 = sel_registerName("alphaControlAddedOrRemoved:");
+    public static /*const*/ string sel_setShadowColor_1 = sel_registerName("setShadowColor:");
+    public static /*const*/ string sel_canBecomeKeyView = sel_registerName("canBecomeKeyView");
+    public static /*const*/ string sel_addTimer_1forMode_1 = sel_registerName("addTimer:forMode:");
+    public static /*const*/ string sel_clickedColumn = sel_registerName("clickedColumn");
+    public static /*const*/ string sel_initWithName_1URI_1 = sel_registerName("initWithName:URI:");
+    public static /*const*/ string sel_saveDocument_1 = sel_registerName("saveDocument:");
+    public static /*const*/ string sel_observationInfo = sel_registerName("observationInfo");
+    public static /*const*/ string sel_readFromURL_1options_1documentAttributes_1error_1 = sel_registerName("readFromURL:options:documentAttributes:error:");
+    public static /*const*/ string sel_addClient_1 = sel_registerName("addClient:");
+    public static /*const*/ string sel_appleEventForSuspensionID_1 = sel_registerName("appleEventForSuspensionID:");
+    public static /*const*/ string sel_setGeneratesCalendarDates_1 = sel_registerName("setGeneratesCalendarDates:");
+    public static /*const*/ string sel_tableView_1sortDescriptorsDidChange_1 = sel_registerName("tableView:sortDescriptorsDidChange:");
+    public static /*const*/ string sel_predicateFormat = sel_registerName("predicateFormat");
+    public static /*const*/ string sel_windowShouldZoom_1toFrame_1 = sel_registerName("windowShouldZoom:toFrame:");
+    public static /*const*/ string sel_usesFontPanel = sel_registerName("usesFontPanel");
+    public static /*const*/ string sel_encodeNXObject_1 = sel_registerName("encodeNXObject:");
+    public static /*const*/ string sel_colorAtX_1y_1 = sel_registerName("colorAtX:y:");
+    public static /*const*/ string sel_publishWithOptions_1 = sel_registerName("publishWithOptions:");
+    public static /*const*/ string sel_allHTTPHeaderFields = sel_registerName("allHTTPHeaderFields");
+    public static /*const*/ string sel_registerPort_1name_1 = sel_registerName("registerPort:name:");
+    public static /*const*/ string sel_lineFragmentUsedRectForGlyphAtIndex_1effectiveRange_1withoutAdditionalLayout_1 = sel_registerName("lineFragmentUsedRectForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:");
+    public static /*const*/ string sel_hour = sel_registerName("hour");
+    public static /*const*/ string sel_setTextLists_1 = sel_registerName("setTextLists:");
+    public static /*const*/ string sel_maximumAdvancement = sel_registerName("maximumAdvancement");
+    public static /*const*/ string sel_setHighlightedItemIndex_1 = sel_registerName("setHighlightedItemIndex:");
+    public static /*const*/ string sel_initWithMemoryCapacity_1diskCapacity_1diskPath_1 = sel_registerName("initWithMemoryCapacity:diskCapacity:diskPath:");
+    public static /*const*/ string sel_setDocumentContentKind_1 = sel_registerName("setDocumentContentKind:");
+    public static /*const*/ string sel_updateDragTypeRegistration = sel_registerName("updateDragTypeRegistration");
+    public static /*const*/ string sel_deviceDescription = sel_registerName("deviceDescription");
+    public static /*const*/ string sel_setMiniwindowImage_1 = sel_registerName("setMiniwindowImage:");
+    public static /*const*/ string sel_sharedTypesetter = sel_registerName("sharedTypesetter");
+    public static /*const*/ string sel_deleteToEndOfLine_1 = sel_registerName("deleteToEndOfLine:");
+    public static /*const*/ string sel_setState_1atRow_1column_1 = sel_registerName("setState:atRow:column:");
+    public static /*const*/ string sel_validModesForFontPanel_1 = sel_registerName("validModesForFontPanel:");
+    public static /*const*/ string sel_currentCalendar = sel_registerName("currentCalendar");
+    public static /*const*/ string sel_selectionIndexPath = sel_registerName("selectionIndexPath");
+    public static /*const*/ string sel_setTextFont_1 = sel_registerName("setTextFont:");
+    public static /*const*/ string sel_password = sel_registerName("password");
+    public static /*const*/ string sel_words = sel_registerName("words");
+    public static /*const*/ string sel_status = sel_registerName("status");
+    public static /*const*/ string sel_typingAttributes = sel_registerName("typingAttributes");
+    public static /*const*/ string sel_handleTakeValue_1forUnboundKey_1 = sel_registerName("handleTakeValue:forUnboundKey:");
+    public static /*const*/ string sel_image_1didLoadRepresentation_1withStatus_1 = sel_registerName("image:didLoadRepresentation:withStatus:");
+    public static /*const*/ string sel_setBitsPerSample_1 = sel_registerName("setBitsPerSample:");
+    public static /*const*/ string sel_sortSubviewsUsingFunction_1context_1 = sel_registerName("sortSubviewsUsingFunction:context:");
+    public static /*const*/ string sel_initWithProtocolFamily_1socketType_1protocol_1socket_1 = sel_registerName("initWithProtocolFamily:socketType:protocol:socket:");
+    public static /*const*/ string sel_numberOfItemsInMenu_1 = sel_registerName("numberOfItemsInMenu:");
+    public static /*const*/ string sel_numberWithUnsignedShort_1 = sel_registerName("numberWithUnsignedShort:");
+    public static /*const*/ string sel_textView_1menu_1forEvent_1atIndex_1 = sel_registerName("textView:menu:forEvent:atIndex:");
+    public static /*const*/ string sel_arrowCursor = sel_registerName("arrowCursor");
+    public static /*const*/ string sel_abbreviation = sel_registerName("abbreviation");
+    public static /*const*/ string sel_moveDown_1 = sel_registerName("moveDown:");
+    public static /*const*/ string sel_activateContextHelpMode_1 = sel_registerName("activateContextHelpMode:");
+    public static /*const*/ string sel_properties = sel_registerName("properties");
+    public static /*const*/ string sel_setObject_1forProperty_1error_1 = sel_registerName("setObject:forProperty:error:");
+    public static /*const*/ string sel_setAutodisplay_1 = sel_registerName("setAutodisplay:");
+    public static /*const*/ string sel_locationInWindow = sel_registerName("locationInWindow");
+    public static /*const*/ string sel_layoutManager = sel_registerName("layoutManager");
+    public static /*const*/ string sel_hyphenCharacterForGlyphAtIndex_1 = sel_registerName("hyphenCharacterForGlyphAtIndex:");
+    public static /*const*/ string sel_play = sel_registerName("play");
+    public static /*const*/ string sel_compositeToPoint_1fromRect_1operation_1fraction_1 = sel_registerName("compositeToPoint:fromRect:operation:fraction:");
+    public static /*const*/ string sel_cellBackgroundColor = sel_registerName("cellBackgroundColor");
+    public static /*const*/ string sel_shouldAntialias = sel_registerName("shouldAntialias");
+    public static /*const*/ string sel_windowWillReturnFieldEditor_1toObject_1 = sel_registerName("windowWillReturnFieldEditor:toObject:");
+    public static /*const*/ string sel_setValuesForKeysWithDictionary_1 = sel_registerName("setValuesForKeysWithDictionary:");
+    public static /*const*/ string sel_drawsGrid = sel_registerName("drawsGrid");
+    public static /*const*/ string sel_patternPhase = sel_registerName("patternPhase");
+    public static /*const*/ string sel_setFrame_1 = sel_registerName("setFrame:");
+    public static /*const*/ string sel_roundingIncrement = sel_registerName("roundingIncrement");
+    public static /*const*/ string sel_adjustScroll_1 = sel_registerName("adjustScroll:");
+    public static /*const*/ string sel_alertShowHelp_1 = sel_registerName("alertShowHelp:");
+    public static /*const*/ string sel_animate_1 = sel_registerName("animate:");
+    public static /*const*/ string sel_tabletID = sel_registerName("tabletID");
+    public static /*const*/ string sel_selectedRowEnumerator = sel_registerName("selectedRowEnumerator");
+    public static /*const*/ string sel_XMLString = sel_registerName("XMLString");
+    public static /*const*/ string sel_setWarningValue_1 = sel_registerName("setWarningValue:");
+    public static /*const*/ string sel_tableView_1validateDrop_1proposedRow_1proposedDropOperation_1 = sel_registerName("tableView:validateDrop:proposedRow:proposedDropOperation:");
+    public static /*const*/ string sel_checkSpelling_1 = sel_registerName("checkSpelling:");
+    public static /*const*/ string sel_setFormattingStringsFilename_1 = sel_registerName("setFormattingStringsFilename:");
+    public static /*const*/ string sel_displayIfNeeded = sel_registerName("displayIfNeeded");
+    public static /*const*/ string sel_localizedName = sel_registerName("localizedName");
+    public static /*const*/ string sel_isEqualToSet_1 = sel_registerName("isEqualToSet:");
+    public static /*const*/ string sel_initWithBytesNoCopy_1length_1encoding_1freeWhenDone_1 = sel_registerName("initWithBytesNoCopy:length:encoding:freeWhenDone:");
+    public static /*const*/ string sel_reloadPredicate = sel_registerName("reloadPredicate");
+    public static /*const*/ string sel_setNumberOfMajorTickMarks_1 = sel_registerName("setNumberOfMajorTickMarks:");
+    public static /*const*/ string sel_defaultPlaceholderForMarker_1withBinding_1 = sel_registerName("defaultPlaceholderForMarker:withBinding:");
+    public static /*const*/ string sel_encodeDataObject_1 = sel_registerName("encodeDataObject:");
+    public static /*const*/ string sel_writeToURL_1ofType_1 = sel_registerName("writeToURL:ofType:");
+    public static /*const*/ string sel_createContext = sel_registerName("createContext");
+    public static /*const*/ string sel_verticalScroller = sel_registerName("verticalScroller");
+    public static /*const*/ string sel_setShowsInvisibleCharacters_1 = sel_registerName("setShowsInvisibleCharacters:");
+    public static /*const*/ string sel_encodeConditionalObject_1forKey_1 = sel_registerName("encodeConditionalObject:forKey:");
+    public static /*const*/ string sel_isEqualTo_1 = sel_registerName("isEqualTo:");
+    public static /*const*/ string sel_translateXBy_1yBy_1 = sel_registerName("translateXBy:yBy:");
+    public static /*const*/ string sel_customizationPaletteIsRunning = sel_registerName("customizationPaletteIsRunning");
+    public static /*const*/ string sel_dictionaryWithDictionary_1 = sel_registerName("dictionaryWithDictionary:");
+    public static /*const*/ string sel_drawMarkersInRect_1 = sel_registerName("drawMarkersInRect:");
+    public static /*const*/ string sel_centerSelectionInVisibleArea_1 = sel_registerName("centerSelectionInVisibleArea:");
+    public static /*const*/ string sel_StringByAppendingString_1 = sel_registerName("StringByAppendingString:");
+    public static /*const*/ string sel_flushWindowIfNeeded = sel_registerName("flushWindowIfNeeded");
+    public static /*const*/ string sel_lockFocusOnRepresentation_1 = sel_registerName("lockFocusOnRepresentation:");
+    public static /*const*/ string sel_setNotShownAttribute_1forGlyphAtIndex_1 = sel_registerName("setNotShownAttribute:forGlyphAtIndex:");
+    public static /*const*/ string sel_currentReplyAppleEvent = sel_registerName("currentReplyAppleEvent");
+    public static /*const*/ string sel_setTitleAlignment_1 = sel_registerName("setTitleAlignment:");
+    public static /*const*/ string sel_removeSuiteNamed_1 = sel_registerName("removeSuiteNamed:");
+    public static /*const*/ string sel_capitalizedString = sel_registerName("capitalizedString");
+    public static /*const*/ string sel_typeFromFileExtension_1 = sel_registerName("typeFromFileExtension:");
+    public static /*const*/ string sel_allowsImageEditing = sel_registerName("allowsImageEditing");
+    public static /*const*/ string sel_loosenKerning_1 = sel_registerName("loosenKerning:");
+    public static /*const*/ string sel_decomposableCharacterSet = sel_registerName("decomposableCharacterSet");
+    public static /*const*/ string sel_subdataWithRange_1 = sel_registerName("subdataWithRange:");
+    public static /*const*/ string sel_attachPopUpWithFrame_1inView_1 = sel_registerName("attachPopUpWithFrame:inView:");
+    public static /*const*/ string sel_setColumnResizingType_1 = sel_registerName("setColumnResizingType:");
+    public static /*const*/ string sel_genericCMYKColorSpace = sel_registerName("genericCMYKColorSpace");
+    public static /*const*/ string sel_actionForControlCharacterAtIndex_1 = sel_registerName("actionForControlCharacterAtIndex:");
+    public static /*const*/ string sel_documentRect = sel_registerName("documentRect");
+    public static /*const*/ string sel_dataWithContentsOfFile_1 = sel_registerName("dataWithContentsOfFile:");
+    public static /*const*/ string sel_localizedDescriptionForType_1 = sel_registerName("localizedDescriptionForType:");
+    public static /*const*/ string sel_increment = sel_registerName("increment");
+    public static /*const*/ string sel_deleteToEndOfParagraph_1 = sel_registerName("deleteToEndOfParagraph:");
+    public static /*const*/ string sel_exceptionWithName_1reason_1userInfo_1 = sel_registerName("exceptionWithName:reason:userInfo:");
+    public static /*const*/ string sel_postscriptName = sel_registerName("postscriptName");
+    public static /*const*/ string sel_setPreferredFilename_1 = sel_registerName("setPreferredFilename:");
+    public static /*const*/ string sel_setPostsBoundsChangedNotifications_1 = sel_registerName("setPostsBoundsChangedNotifications:");
+    public static /*const*/ string sel_decimalNumberHandlerWithRoundingMode_1scale_1raiseOnExactness_1raiseOnOverflow_1raiseOnUnderflow_1raiseOnDivideByZero_1 = sel_registerName("decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:");
+    public static /*const*/ string sel_openDocumentWithContentsOfFile_1display_1 = sel_registerName("openDocumentWithContentsOfFile:display:");
+    public static /*const*/ string sel_objectForInfoDictionaryKey_1 = sel_registerName("objectForInfoDictionaryKey:");
+    public static /*const*/ string sel_setFrameOrigin_1 = sel_registerName("setFrameOrigin:");
+    public static /*const*/ string sel_pathControl_1willPopUpMenu_1 = sel_registerName("pathControl:willPopUpMenu:");
+    public static /*const*/ string sel_lineWidth = sel_registerName("lineWidth");
+    public static /*const*/ string sel_poseAsClass_1 = sel_registerName("poseAsClass:");
+    public static /*const*/ string sel_selectPreviousKeyView_1 = sel_registerName("selectPreviousKeyView:");
+    public static /*const*/ string sel_isKey_1inTable_1 = sel_registerName("isKey:inTable:");
+    public static /*const*/ string sel_isZoomed = sel_registerName("isZoomed");
+    public static /*const*/ string sel_setCompletionDelay_1 = sel_registerName("setCompletionDelay:");
+    public static /*const*/ string sel_mainMenu = sel_registerName("mainMenu");
+    public static /*const*/ string sel_scrollView = sel_registerName("scrollView");
+    public static /*const*/ string sel_dividerColor = sel_registerName("dividerColor");
+    public static /*const*/ string sel_requestModes = sel_registerName("requestModes");
+    public static /*const*/ string sel_setShowsResizeIndicator_1 = sel_registerName("setShowsResizeIndicator:");
+    public static /*const*/ string sel_setScrollable_1 = sel_registerName("setScrollable:");
+    public static /*const*/ string sel_setLineScroll_1 = sel_registerName("setLineScroll:");
+    public static /*const*/ string sel_resolvePrefixForNamespaceURI_1 = sel_registerName("resolvePrefixForNamespaceURI:");
+    public static /*const*/ string sel_bind_1toObject_1withKeyPath_1options_1 = sel_registerName("bind:toObject:withKeyPath:options:");
+    public static /*const*/ string sel_alignCenter_1 = sel_registerName("alignCenter:");
+    public static /*const*/ string sel_addTemporaryAttribute_1value_1forCharacterRange_1 = sel_registerName("addTemporaryAttribute:value:forCharacterRange:");
+    public static /*const*/ string sel_expressionForConstantValue_1 = sel_registerName("expressionForConstantValue:");
+    public static /*const*/ string sel_initWithContentSize_1preferredEdge_1 = sel_registerName("initWithContentSize:preferredEdge:");
+    public static /*const*/ string sel_setAccessoryView_1 = sel_registerName("setAccessoryView:");
+    public static /*const*/ string sel_setContentWidth_1type_1 = sel_registerName("setContentWidth:type:");
+    public static /*const*/ string sel_searchMenuTemplate = sel_registerName("searchMenuTemplate");
+    public static /*const*/ string sel_imageRepClassForType_1 = sel_registerName("imageRepClassForType:");
+    public static /*const*/ string sel_decimalValue = sel_registerName("decimalValue");
+    public static /*const*/ string sel_protocolSpecificInformation = sel_registerName("protocolSpecificInformation");
+    public static /*const*/ string sel_statusBar = sel_registerName("statusBar");
+    public static /*const*/ string sel_setTimeZone_1 = sel_registerName("setTimeZone:");
+    public static /*const*/ string sel_setWidth_1forSegment_1 = sel_registerName("setWidth:forSegment:");
+    public static /*const*/ string sel_objectIsForcedForKey_1inDomain_1 = sel_registerName("objectIsForcedForKey:inDomain:");
+    public static /*const*/ string sel_evaluationErrorSpecifier = sel_registerName("evaluationErrorSpecifier");
+    public static /*const*/ string sel_application_1openFile_1 = sel_registerName("application:openFile:");
+    public static /*const*/ string sel_changeDocumentBackgroundColor_1 = sel_registerName("changeDocumentBackgroundColor:");
+    public static /*const*/ string sel_volatileDomainNames = sel_registerName("volatileDomainNames");
+    public static /*const*/ string sel_changeInLength = sel_registerName("changeInLength");
+    public static /*const*/ string sel_autoresizingMask = sel_registerName("autoresizingMask");
+    public static /*const*/ string sel_setRepresentedObject_1 = sel_registerName("setRepresentedObject:");
+    public static /*const*/ string sel_isUndoRegistrationEnabled = sel_registerName("isUndoRegistrationEnabled");
+    public static /*const*/ string sel_alertWithError_1 = sel_registerName("alertWithError:");
+    public static /*const*/ string sel_saturationComponent = sel_registerName("saturationComponent");
+    public static /*const*/ string sel_spellServer_1didLearnWord_1inLanguage_1 = sel_registerName("spellServer:didLearnWord:inLanguage:");
+    public static /*const*/ string sel_performActionWithHighlightingForItemAtIndex_1 = sel_registerName("performActionWithHighlightingForItemAtIndex:");
+    public static /*const*/ string sel_loadSuitesFromBundle_1 = sel_registerName("loadSuitesFromBundle:");
+    public static /*const*/ string sel_firstTextView = sel_registerName("firstTextView");
+    public static /*const*/ string sel_targetForAction_1 = sel_registerName("targetForAction:");
+    public static /*const*/ string sel_enterExitEventWithType_1location_1modifierFlags_1timestamp_1windowNumber_1context_1eventNumber_1trackingNumber_1userData_1 = sel_registerName("enterExitEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:trackingNumber:userData:");
+    public static /*const*/ string sel_setHelpAnchor_1 = sel_registerName("setHelpAnchor:");
+    public static /*const*/ string sel_printerWithName_1 = sel_registerName("printerWithName:");
+    public static /*const*/ string sel_boundingBoxForControlGlyphAtIndex_1forTextContainer_1proposedLineFragment_1glyphPosition_1characterIndex_1 = sel_registerName("boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:");
+    public static /*const*/ string sel_initWithBytesNoCopy_1length_1freeWhenDone_1 = sel_registerName("initWithBytesNoCopy:length:freeWhenDone:");
+    public static /*const*/ string sel_getRow_1column_1ofCell_1 = sel_registerName("getRow:column:ofCell:");
+    public static /*const*/ string sel_smartDeleteRangeForProposedRange_1 = sel_registerName("smartDeleteRangeForProposedRange:");
+    public static /*const*/ string sel_getHue_1saturation_1brightness_1alpha_1 = sel_registerName("getHue:saturation:brightness:alpha:");
+    public static /*const*/ string sel_automaticallyNotifiesObserversForKey_1 = sel_registerName("automaticallyNotifiesObserversForKey:");
+    public static /*const*/ string sel_setAllowsImageEditing_1 = sel_registerName("setAllowsImageEditing:");
+    public static /*const*/ string sel_draggingUpdated_1 = sel_registerName("draggingUpdated:");
+    public static /*const*/ string sel_insertRowAtIndex_1withType_1asSubrowOfRow_1animate_1 = sel_registerName("insertRowAtIndex:withType:asSubrowOfRow:animate:");
+    public static /*const*/ string sel_getRectsExposedDuringLiveResize_1count_1 = sel_registerName("getRectsExposedDuringLiveResize:count:");
+    public static /*const*/ string sel_usesSignificantDigits = sel_registerName("usesSignificantDigits");
+    public static /*const*/ string sel_numberOfVirtualScreens = sel_registerName("numberOfVirtualScreens");
+    public static /*const*/ string sel_sendSynchronousRequest_1returningResponse_1error_1 = sel_registerName("sendSynchronousRequest:returningResponse:error:");
+    public static /*const*/ string sel_setBecomesKeyOnlyIfNeeded_1 = sel_registerName("setBecomesKeyOnlyIfNeeded:");
+    public static /*const*/ string sel_autorecalculatesKeyViewLoop = sel_registerName("autorecalculatesKeyViewLoop");
+    public static /*const*/ string sel_decodeDataObject = sel_registerName("decodeDataObject");
+    public static /*const*/ string sel_setOriginOffset_1 = sel_registerName("setOriginOffset:");
+    public static /*const*/ string sel_pointingDeviceSerialNumber = sel_registerName("pointingDeviceSerialNumber");
+    public static /*const*/ string sel_drawSegment_1inFrame_1withView_1 = sel_registerName("drawSegment:inFrame:withView:");
+    public static /*const*/ string sel_close = sel_registerName("close");
+    public static /*const*/ string sel_setAlignmentRect_1 = sel_registerName("setAlignmentRect:");
+    public static /*const*/ string sel_paragraphSeparatorCharacterRange = sel_registerName("paragraphSeparatorCharacterRange");
+    public static /*const*/ string sel_measurementUnits = sel_registerName("measurementUnits");
+    public static /*const*/ string sel_setUsesEPSOnResolutionMismatch_1 = sel_registerName("setUsesEPSOnResolutionMismatch:");
+    public static /*const*/ string sel_setLineFragmentPadding_1 = sel_registerName("setLineFragmentPadding:");
+    public static /*const*/ string sel_setLastComponentOfFileName_1 = sel_registerName("setLastComponentOfFileName:");
+    public static /*const*/ string sel_initWithSuiteName_1commandName_1dictionary_1 = sel_registerName("initWithSuiteName:commandName:dictionary:");
+    public static /*const*/ string sel_initWithContent_1 = sel_registerName("initWithContent:");
+    public static /*const*/ string sel_provideNewView_1 = sel_registerName("provideNewView:");
+    public static /*const*/ string sel_pathComponentCells = sel_registerName("pathComponentCells");
+    public static /*const*/ string sel_instanceMethodForSelector_1 = sel_registerName("instanceMethodForSelector:");
+    public static /*const*/ string sel_layoutManagerDidInvalidateLayout_1 = sel_registerName("layoutManagerDidInvalidateLayout:");
+    public static /*const*/ string sel_helpAnchor = sel_registerName("helpAnchor");
+    public static /*const*/ string sel_URLProtocol_1wasRedirectedToRequest_1redirectResponse_1 = sel_registerName("URLProtocol:wasRedirectedToRequest:redirectResponse:");
+    public static /*const*/ string sel_setIsVisible_1 = sel_registerName("setIsVisible:");
+    public static /*const*/ string sel_browser_1sizeToFitWidthOfColumn_1 = sel_registerName("browser:sizeToFitWidthOfColumn:");
+    public static /*const*/ string sel_handleFailureInMethod_1object_1file_1lineNumber_1description_1 = sel_registerName("handleFailureInMethod:object:file:lineNumber:description:");
+    public static /*const*/ string sel_serializedRepresentation = sel_registerName("serializedRepresentation");
+    public static /*const*/ string sel_replaceTextContainer_1 = sel_registerName("replaceTextContainer:");
+    public static /*const*/ string sel_speechSynthesizer_1willSpeakWord_1ofString_1 = sel_registerName("speechSynthesizer:willSpeakWord:ofString:");
+    public static /*const*/ string sel_startSpeaking_1 = sel_registerName("startSpeaking:");
+    public static /*const*/ string sel_setHyphenationFactor_1 = sel_registerName("setHyphenationFactor:");
+    public static /*const*/ string sel_retain = sel_registerName("retain");
+    public static /*const*/ string sel_insertItem_1atIndex_1 = sel_registerName("insertItem:atIndex:");
+    public static /*const*/ string sel_sortWithSortDescriptors_1recursively_1 = sel_registerName("sortWithSortDescriptors:recursively:");
+    public static /*const*/ string sel_selectTabViewItem_1 = sel_registerName("selectTabViewItem:");
+    public static /*const*/ string sel_clipRect_1 = sel_registerName("clipRect:");
+    public static /*const*/ string sel_close_1 = sel_registerName("close:");
+    public static /*const*/ string sel_didAddSubview_1 = sel_registerName("didAddSubview:");
+    public static /*const*/ string sel_markedTextSelectionChanged_1client_1 = sel_registerName("markedTextSelectionChanged:client:");
+    public static /*const*/ string sel_registerLanguage_1byVendor_1 = sel_registerName("registerLanguage:byVendor:");
+    public static /*const*/ string sel_removeClient_1 = sel_registerName("removeClient:");
+    public static /*const*/ string sel_setSendsWholeSearchString_1 = sel_registerName("setSendsWholeSearchString:");
+    public static /*const*/ string sel_localName = sel_registerName("localName");
+    public static /*const*/ string sel_setSelectedSegment_1 = sel_registerName("setSelectedSegment:");
+    public static /*const*/ string sel_setLineHeightMultiple_1 = sel_registerName("setLineHeightMultiple:");
+    public static /*const*/ string sel_setCanCreateDirectories_1 = sel_registerName("setCanCreateDirectories:");
+    public static /*const*/ string sel_setCookieAcceptPolicy_1 = sel_registerName("setCookieAcceptPolicy:");
+    public static /*const*/ string sel_convertFont_1toHaveTrait_1 = sel_registerName("convertFont:toHaveTrait:");
+    public static /*const*/ string sel_headerCell = sel_registerName("headerCell");
+    public static /*const*/ string sel_maximumDecimalNumber = sel_registerName("maximumDecimalNumber");
+    public static /*const*/ string sel_browser_1isColumnValid_1 = sel_registerName("browser:isColumnValid:");
+    public static /*const*/ string sel_tableViewSelectionIsChanging_1 = sel_registerName("tableViewSelectionIsChanging:");
+    public static /*const*/ string sel_setNotificationBatchingInterval_1 = sel_registerName("setNotificationBatchingInterval:");
+    public static /*const*/ string sel_isLeaf = sel_registerName("isLeaf");
+    public static /*const*/ string sel_valuesForAttributes_1 = sel_registerName("valuesForAttributes:");
+    public static /*const*/ string sel_removeTemporaryAttribute_1forCharacterRange_1 = sel_registerName("removeTemporaryAttribute:forCharacterRange:");
+    public static /*const*/ string sel_pixelsWide = sel_registerName("pixelsWide");
+    public static /*const*/ string sel_orderFrontStandardAboutPanel_1 = sel_registerName("orderFrontStandardAboutPanel:");
+    public static /*const*/ string sel_beginSheetModalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1 = sel_registerName("beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:");
+    public static /*const*/ string sel_setToolTip_1forSegment_1 = sel_registerName("setToolTip:forSegment:");
+    public static /*const*/ string sel_canonicalXMLStringPreservingComments_1 = sel_registerName("canonicalXMLStringPreservingComments:");
+    public static /*const*/ string sel_orderFrontListPanel_1 = sel_registerName("orderFrontListPanel:");
+    public static /*const*/ string sel_setIsMiniaturized_1 = sel_registerName("setIsMiniaturized:");
+    public static /*const*/ string sel_download_1didReceiveDataOfLength_1 = sel_registerName("download:didReceiveDataOfLength:");
+    public static /*const*/ string sel_layoutManager_1didCompleteLayoutForTextContainer_1atEnd_1 = sel_registerName("layoutManager:didCompleteLayoutForTextContainer:atEnd:");
+    public static /*const*/ string sel_standardWindowButton_1forStyleMask_1 = sel_registerName("standardWindowButton:forStyleMask:");
+    public static /*const*/ string sel_writeToURL_1atomically_1 = sel_registerName("writeToURL:atomically:");
+    public static /*const*/ string sel_useStandardLigatures_1 = sel_registerName("useStandardLigatures:");
+    public static /*const*/ string sel_currentRunLoop = sel_registerName("currentRunLoop");
+    public static /*const*/ string sel_setExtraLineFragmentRect_1usedRect_1textContainer_1 = sel_registerName("setExtraLineFragmentRect:usedRect:textContainer:");
+    public static /*const*/ string sel_rootElement = sel_registerName("rootElement");
+    public static /*const*/ string sel_setContentViewMargins_1 = sel_registerName("setContentViewMargins:");
+    public static /*const*/ string sel_cancelPerformSelector_1target_1argument_1 = sel_registerName("cancelPerformSelector:target:argument:");
+    public static /*const*/ string sel_outputFormat = sel_registerName("outputFormat");
+    public static /*const*/ string sel_arrayWithContentsOfFile_1 = sel_registerName("arrayWithContentsOfFile:");
+    public static /*const*/ string sel_applicationWillFinishLaunching_1 = sel_registerName("applicationWillFinishLaunching:");
+    public static /*const*/ string sel_prefixForName_1 = sel_registerName("prefixForName:");
+    public static /*const*/ string sel_decimalNumberByDividingBy_1 = sel_registerName("decimalNumberByDividingBy:");
+    public static /*const*/ string sel_mouseUpOnCharacterIndex_1atCoordinate_1withModifier_1client_1 = sel_registerName("mouseUpOnCharacterIndex:atCoordinate:withModifier:client:");
+    public static /*const*/ string sel_defaultVoice = sel_registerName("defaultVoice");
+    public static /*const*/ string sel_operand = sel_registerName("operand");
+    public static /*const*/ string sel_moveToEndOfLine_1 = sel_registerName("moveToEndOfLine:");
+    public static /*const*/ string sel_addEntry_1 = sel_registerName("addEntry:");
+    public static /*const*/ string sel_scaleBy_1 = sel_registerName("scaleBy:");
+    public static /*const*/ string sel_setMnemonicLocation_1 = sel_registerName("setMnemonicLocation:");
+    public static /*const*/ string sel_dateWithCalendarFormat_1timeZone_1 = sel_registerName("dateWithCalendarFormat:timeZone:");
+    public static /*const*/ string sel_setUsesFontLeading_1 = sel_registerName("setUsesFontLeading:");
+    public static /*const*/ string sel_CIContext = sel_registerName("CIContext");
+    public static /*const*/ string sel_isDaylightSavingTime = sel_registerName("isDaylightSavingTime");
+    public static /*const*/ string sel_setShowsBorderOnlyWhileMouseInside_1 = sel_registerName("setShowsBorderOnlyWhileMouseInside:");
+    public static /*const*/ string sel_isSetOnMouseEntered = sel_registerName("isSetOnMouseEntered");
+    public static /*const*/ string sel_StringFromDate_1 = sel_registerName("StringFromDate:");
+    public static /*const*/ string sel_deselectColumn_1 = sel_registerName("deselectColumn:");
+    public static /*const*/ string sel_requestHeaderFieldsWithCookies_1 = sel_registerName("requestHeaderFieldsWithCookies:");
+    public static /*const*/ string sel_outlineViewColumnDidMove_1 = sel_registerName("outlineViewColumnDidMove:");
+    public static /*const*/ string sel_fileExtensionsFromType_1 = sel_registerName("fileExtensionsFromType:");
+    public static /*const*/ string sel_setUsesScreenFonts_1 = sel_registerName("setUsesScreenFonts:");
+    public static /*const*/ string sel_commandDescriptionsInSuite_1 = sel_registerName("commandDescriptionsInSuite:");
+    public static /*const*/ string sel_notShownAttributeForGlyphAtIndex_1 = sel_registerName("notShownAttributeForGlyphAtIndex:");
+    public static /*const*/ string sel_isRunning = sel_registerName("isRunning");
+    public static /*const*/ string sel_sharedPrintInfo = sel_registerName("sharedPrintInfo");
+    public static /*const*/ string sel_isValid = sel_registerName("isValid");
+    public static /*const*/ string sel_handleFailureInFunction_1file_1lineNumber_1description_1 = sel_registerName("handleFailureInFunction:file:lineNumber:description:");
+    public static /*const*/ string sel_localizedRecoveryOptions = sel_registerName("localizedRecoveryOptions");
+    public static /*const*/ string sel_establishConnection = sel_registerName("establishConnection");
+    public static /*const*/ string sel_isMainWindow = sel_registerName("isMainWindow");
+    public static /*const*/ string sel_setDrawsBackground_1 = sel_registerName("setDrawsBackground:");
+    public static /*const*/ string sel_intAttribute_1forGlyphAtIndex_1 = sel_registerName("intAttribute:forGlyphAtIndex:");
+    public static /*const*/ string sel_shadowColor = sel_registerName("shadowColor");
+    public static /*const*/ string sel_keyEquivalentModifierMask = sel_registerName("keyEquivalentModifierMask");
+    public static /*const*/ string sel_textStorageDidProcessEditing_1 = sel_registerName("textStorageDidProcessEditing:");
+    public static /*const*/ string sel_setType_1 = sel_registerName("setType:");
+    public static /*const*/ string sel_previousSibling = sel_registerName("previousSibling");
+    public static /*const*/ string sel_dateByAddingYears_1months_1days_1hours_1minutes_1seconds_1 = sel_registerName("dateByAddingYears:months:days:hours:minutes:seconds:");
+    public static /*const*/ string sel_setMinimum_1 = sel_registerName("setMinimum:");
+    public static /*const*/ string sel_columnAutoresizingStyle = sel_registerName("columnAutoresizingStyle");
+    public static /*const*/ string sel_convertPointFromBase_1 = sel_registerName("convertPointFromBase:");
+    public static /*const*/ string sel_layout = sel_registerName("layout");
+    public static /*const*/ string sel_textStorage = sel_registerName("textStorage");
+    public static /*const*/ string sel_values = sel_registerName("values");
+    public static /*const*/ string sel_RTFFromRange_1documentAttributes_1 = sel_registerName("RTFFromRange:documentAttributes:");
+    public static /*const*/ string sel_isMiniaturizable = sel_registerName("isMiniaturizable");
+    public static /*const*/ string sel_opaqueAncestor = sel_registerName("opaqueAncestor");
+    public static /*const*/ string sel_notationName = sel_registerName("notationName");
+    public static /*const*/ string sel_setBaseWritingDirection_1range_1 = sel_registerName("setBaseWritingDirection:range:");
+    public static /*const*/ string sel_setManagedObjectContext_1 = sel_registerName("setManagedObjectContext:");
+    public static /*const*/ string sel_patternImage = sel_registerName("patternImage");
+    public static /*const*/ string sel_windowDidResize_1 = sel_registerName("windowDidResize:");
+    public static /*const*/ string sel_setFieldEditor_1 = sel_registerName("setFieldEditor:");
+    public static /*const*/ string sel_initWithContainerClassDescription_1containerSpecifier_1key_1relativePosition_1baseSpecifier_1 = sel_registerName("initWithContainerClassDescription:containerSpecifier:key:relativePosition:baseSpecifier:");
+    public static /*const*/ string sel_setMainMenu_1 = sel_registerName("setMainMenu:");
+    public static /*const*/ string sel_setObjectZone_1 = sel_registerName("setObjectZone:");
+    public static /*const*/ string sel_localizedDescription = sel_registerName("localizedDescription");
+    public static /*const*/ string sel_setImageScaling_1 = sel_registerName("setImageScaling:");
+    public static /*const*/ string sel_moveToBeginningOfLine_1 = sel_registerName("moveToBeginningOfLine:");
+    public static /*const*/ string sel_transposeWords_1 = sel_registerName("transposeWords:");
+    public static /*const*/ string sel_protocol = sel_registerName("protocol");
+    public static /*const*/ string sel_isHorizontallyCentered = sel_registerName("isHorizontallyCentered");
+    public static /*const*/ string sel_invert = sel_registerName("invert");
+    public static /*const*/ string sel_isEqualToValue_1 = sel_registerName("isEqualToValue:");
+    public static /*const*/ string sel_registerName_1withNameServer_1 = sel_registerName("registerName:withNameServer:");
+    public static /*const*/ string sel_writeToURL_1ofType_1error_1 = sel_registerName("writeToURL:ofType:error:");
+    public static /*const*/ string sel_rangeForUserTextChange = sel_registerName("rangeForUserTextChange");
+    public static /*const*/ string sel_configurePersistentStoreCoordinatorForURL_1ofType_1error_1 = sel_registerName("configurePersistentStoreCoordinatorForURL:ofType:error:");
+    public static /*const*/ string sel_setShouldAntialias_1 = sel_registerName("setShouldAntialias:");
+    public static /*const*/ string sel_alignmentRect = sel_registerName("alignmentRect");
+    public static /*const*/ string sel_zoom_1 = sel_registerName("zoom:");
+    public static /*const*/ string sel_rate = sel_registerName("rate");
+    public static /*const*/ string sel_maxVisibleColumns = sel_registerName("maxVisibleColumns");
+    public static /*const*/ string sel_splitViewDidResizeSubviews_1 = sel_registerName("splitViewDidResizeSubviews:");
+    public static /*const*/ string sel_maxWidth = sel_registerName("maxWidth");
+    public static /*const*/ string sel_setData_1 = sel_registerName("setData:");
+    public static /*const*/ string sel_isVisible = sel_registerName("isVisible");
+    public static /*const*/ string sel_isSelected = sel_registerName("isSelected");
+    public static /*const*/ string sel_rulerView_1shouldRemoveMarker_1 = sel_registerName("rulerView:shouldRemoveMarker:");
+    public static /*const*/ string sel_setURL_1 = sel_registerName("setURL:");
+    public static /*const*/ string sel_drawTitle_1withFrame_1inView_1 = sel_registerName("drawTitle:withFrame:inView:");
+    public static /*const*/ string sel_usesWeakReadAndWriteBarriers = sel_registerName("usesWeakReadAndWriteBarriers");
+    public static /*const*/ string sel_elementDeclarationForName_1 = sel_registerName("elementDeclarationForName:");
+    public static /*const*/ string sel_setOneShot_1 = sel_registerName("setOneShot:");
+    public static /*const*/ string sel_shouldProcessNamespaces = sel_registerName("shouldProcessNamespaces");
+    public static /*const*/ string sel_isEqualToArray_1 = sel_registerName("isEqualToArray:");
+    public static /*const*/ string sel_XMLStringWithOptions_1 = sel_registerName("XMLStringWithOptions:");
+    public static /*const*/ string sel_initFileURLWithPath_1isDirectory_1 = sel_registerName("initFileURLWithPath:isDirectory:");
+    public static /*const*/ string sel_datePickerElements = sel_registerName("datePickerElements");
+    public static /*const*/ string sel_willChange_1valuesAtIndexes_1forKey_1 = sel_registerName("willChange:valuesAtIndexes:forKey:");
+    public static /*const*/ string sel_setSelected_1forSegment_1 = sel_registerName("setSelected:forSegment:");
+    public static /*const*/ string sel_initWithFormat_1shareContext_1 = sel_registerName("initWithFormat:shareContext:");
+    public static /*const*/ string sel_browser_1shouldSizeColumn_1forUserResize_1toWidth_1 = sel_registerName("browser:shouldSizeColumn:forUserResize:toWidth:");
+    public static /*const*/ string sel_indexSetWithIndexesInRange_1 = sel_registerName("indexSetWithIndexesInRange:");
+    public static /*const*/ string sel_netServiceBrowser_1didFindService_1moreComing_1 = sel_registerName("netServiceBrowser:didFindService:moreComing:");
+    public static /*const*/ string sel_keyUp_1 = sel_registerName("keyUp:");
+    public static /*const*/ string sel_pageHeader = sel_registerName("pageHeader");
+    public static /*const*/ string sel_isCancelled = sel_registerName("isCancelled");
+    public static /*const*/ string sel_segmentStyle = sel_registerName("segmentStyle");
+    public static /*const*/ string sel_imageRepWithContentsOfURL_1 = sel_registerName("imageRepWithContentsOfURL:");
+    public static /*const*/ string sel_initWithNibName_1bundle_1 = sel_registerName("initWithNibName:bundle:");
+    public static /*const*/ string sel_removeObserver_1fromObjectsAtIndexes_1forKeyPath_1 = sel_registerName("removeObserver:fromObjectsAtIndexes:forKeyPath:");
+    public static /*const*/ string sel_setFetchPredicate_1 = sel_registerName("setFetchPredicate:");
+    public static /*const*/ string sel_compare_1options_1range_1 = sel_registerName("compare:options:range:");
+    public static /*const*/ string sel_validateVisibleColumns = sel_registerName("validateVisibleColumns");
+    public static /*const*/ string sel_initWithCGColorSpace_1 = sel_registerName("initWithCGColorSpace:");
+    public static /*const*/ string sel_mountNewRemovableMedia = sel_registerName("mountNewRemovableMedia");
+    public static /*const*/ string sel_compare_1options_1range_1locale_1 = sel_registerName("compare:options:range:locale:");
+    public static /*const*/ string sel_setTopMargin_1 = sel_registerName("setTopMargin:");
+    public static /*const*/ string sel_maximumLengthOfBytesUsingEncoding_1 = sel_registerName("maximumLengthOfBytesUsingEncoding:");
+    public static /*const*/ string sel_colorWithAlphaComponent_1 = sel_registerName("colorWithAlphaComponent:");
+    public static /*const*/ string sel_appendBezierPathWithRoundedRect_1xRadius_1yRadius_1 = sel_registerName("appendBezierPathWithRoundedRect:xRadius:yRadius:");
+    public static /*const*/ string sel_autosavedContentsFileURL = sel_registerName("autosavedContentsFileURL");
+    public static /*const*/ string sel_markedTextAttributes = sel_registerName("markedTextAttributes");
+    public static /*const*/ string sel_predicateWithValue_1 = sel_registerName("predicateWithValue:");
+    public static /*const*/ string sel_makeFirstResponder_1 = sel_registerName("makeFirstResponder:");
+    public static /*const*/ string sel_alternateTitle = sel_registerName("alternateTitle");
+    public static /*const*/ string sel_attribute = sel_registerName("attribute");
+    public static /*const*/ string sel_decodeIntegerForKey_1 = sel_registerName("decodeIntegerForKey:");
+    public static /*const*/ string sel_setSeparatesColumns_1 = sel_registerName("setSeparatesColumns:");
+    public static /*const*/ string sel_imageRepsWithContentsOfURL_1 = sel_registerName("imageRepsWithContentsOfURL:");
+    public static /*const*/ string sel_isPlanar = sel_registerName("isPlanar");
+    public static /*const*/ string sel_download_1didReceiveAuthenticationChallenge_1 = sel_registerName("download:didReceiveAuthenticationChallenge:");
+    public static /*const*/ string sel_startingRow = sel_registerName("startingRow");
+    public static /*const*/ string sel_evaluateWithObject_1substitutionVariables_1 = sel_registerName("evaluateWithObject:substitutionVariables:");
+    public static /*const*/ string sel_initWithRTFD_1documentAttributes_1 = sel_registerName("initWithRTFD:documentAttributes:");
+    public static /*const*/ string sel_ensureLayoutForTextContainer_1 = sel_registerName("ensureLayoutForTextContainer:");
+    public static /*const*/ string sel_runModalForWindow_1relativeToWindow_1 = sel_registerName("runModalForWindow:relativeToWindow:");
+    public static /*const*/ string sel_isResizable = sel_registerName("isResizable");
+    public static /*const*/ string sel_isSymbolicLink = sel_registerName("isSymbolicLink");
+    public static /*const*/ string sel_containsIndexes_1 = sel_registerName("containsIndexes:");
+    public static /*const*/ string sel_splitView_1constrainMaxCoordinate_1ofSubviewAt_1 = sel_registerName("splitView:constrainMaxCoordinate:ofSubviewAt:");
+    public static /*const*/ string sel_setImportsGraphics_1 = sel_registerName("setImportsGraphics:");
+    public static /*const*/ string sel_action = sel_registerName("action");
+    public static /*const*/ string sel_noteNumberOfItemsChanged = sel_registerName("noteNumberOfItemsChanged");
+    public static /*const*/ string sel_drawBackgroundInClipRect_1 = sel_registerName("drawBackgroundInClipRect:");
+    public static /*const*/ string sel_printInfo = sel_registerName("printInfo");
+    public static /*const*/ string sel_performSelector_1withObject_1afterDelay_1 = sel_registerName("performSelector:withObject:afterDelay:");
+    public static /*const*/ string sel_boundingRectForGlyphRange_1inTextContainer_1 = sel_registerName("boundingRectForGlyphRange:inTextContainer:");
+    public static /*const*/ string sel_currencyCode = sel_registerName("currencyCode");
+    public static /*const*/ string sel_splitView_1canCollapseSubview_1 = sel_registerName("splitView:canCollapseSubview:");
+    public static /*const*/ string sel_hide = sel_registerName("hide");
+    public static /*const*/ string sel_setMonth_1 = sel_registerName("setMonth:");
+    public static /*const*/ string sel_dataFromTXTRecordDictionary_1 = sel_registerName("dataFromTXTRecordDictionary:");
+    public static /*const*/ string sel_rulerView_1didAddMarker_1 = sel_registerName("rulerView:didAddMarker:");
+    public static /*const*/ string sel_deleteBackward_1 = sel_registerName("deleteBackward:");
+    public static /*const*/ string sel_setMaximumLineHeight_1 = sel_registerName("setMaximumLineHeight:");
+    public static /*const*/ string sel_orderedWindows = sel_registerName("orderedWindows");
+    public static /*const*/ string sel_standaloneWeekdaySymbols = sel_registerName("standaloneWeekdaySymbols");
+    public static /*const*/ string sel_isAttached = sel_registerName("isAttached");
+    public static /*const*/ string sel_resizeLeftRightCursor = sel_registerName("resizeLeftRightCursor");
+    public static /*const*/ string sel_methodSignature = sel_registerName("methodSignature");
+    public static /*const*/ string sel_setDiskCapacity_1 = sel_registerName("setDiskCapacity:");
+    public static /*const*/ string sel_lineFragmentRectForGlyphAtIndex_1effectiveRange_1withoutAdditionalLayout_1 = sel_registerName("lineFragmentRectForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:");
+    public static /*const*/ string sel_screen = sel_registerName("screen");
+    public static /*const*/ string sel_windowNumber = sel_registerName("windowNumber");
+    public static /*const*/ string sel_selectSegmentWithTag_1 = sel_registerName("selectSegmentWithTag:");
+    public static /*const*/ string sel_availableFontFamilies = sel_registerName("availableFontFamilies");
+    public static /*const*/ string sel_superclass = sel_registerName("superclass");
+    public static /*const*/ string sel_registeredImageRepClasses = sel_registerName("registeredImageRepClasses");
+    public static /*const*/ string sel_needsSizing = sel_registerName("needsSizing");
+    public static /*const*/ string sel_setUsesAlternatingRowBackgroundColors_1 = sel_registerName("setUsesAlternatingRowBackgroundColors:");
+    public static /*const*/ string sel_getBitmapDataPlanes_1 = sel_registerName("getBitmapDataPlanes:");
+    public static /*const*/ string sel_fontWithFamily_1traits_1weight_1size_1 = sel_registerName("fontWithFamily:traits:weight:size:");
+    public static /*const*/ string sel_borderColor = sel_registerName("borderColor");
+    public static /*const*/ string sel_colorUsingColorSpace_1 = sel_registerName("colorUsingColorSpace:");
+    public static /*const*/ string sel_propertyForKey_1 = sel_registerName("propertyForKey:");
+    public static /*const*/ string sel_setPublicID_1 = sel_registerName("setPublicID:");
+    public static /*const*/ string sel_forwardInvocation_1 = sel_registerName("forwardInvocation:");
+    public static /*const*/ string sel_deleteToBeginningOfLine_1 = sel_registerName("deleteToBeginningOfLine:");
+    public static /*const*/ string sel_hasNonContiguousLayout = sel_registerName("hasNonContiguousLayout");
+    public static /*const*/ string sel_getObjects_1 = sel_registerName("getObjects:");
+    public static /*const*/ string sel_clearRecentDocuments_1 = sel_registerName("clearRecentDocuments:");
+    public static /*const*/ string sel_paletteFontOfSize_1 = sel_registerName("paletteFontOfSize:");
+    public static /*const*/ string sel_rightMargin = sel_registerName("rightMargin");
+    public static /*const*/ string sel_browser_1createRowsForColumn_1inMatrix_1 = sel_registerName("browser:createRowsForColumn:inMatrix:");
+    public static /*const*/ string sel_removeItemAtPath_1error_1 = sel_registerName("removeItemAtPath:error:");
+    public static /*const*/ string sel_getRectsBeingDrawn_1count_1 = sel_registerName("getRectsBeingDrawn:count:");
+    public static /*const*/ string sel_numberWithUnsignedInt_1 = sel_registerName("numberWithUnsignedInt:");
+    public static /*const*/ string sel_complete_1 = sel_registerName("complete:");
+    public static /*const*/ string sel_synchronizeTitleAndSelectedItem = sel_registerName("synchronizeTitleAndSelectedItem");
+    public static /*const*/ string sel_archiverData = sel_registerName("archiverData");
+    public static /*const*/ string sel_selectNextTabViewItem_1 = sel_registerName("selectNextTabViewItem:");
+    public static /*const*/ string sel_displayNameForType_1 = sel_registerName("displayNameForType:");
+    public static /*const*/ string sel_defaultNameServerPortNumber = sel_registerName("defaultNameServerPortNumber");
+    public static /*const*/ string sel_setFireDate_1 = sel_registerName("setFireDate:");
+    public static /*const*/ string sel_selectFirstTabViewItem_1 = sel_registerName("selectFirstTabViewItem:");
+    public static /*const*/ string sel_setRightMargin_1 = sel_registerName("setRightMargin:");
+    public static /*const*/ string sel_menuView = sel_registerName("menuView");
+    public static /*const*/ string sel_removeObjectsFromIndices_1numIndices_1 = sel_registerName("removeObjectsFromIndices:numIndices:");
+    public static /*const*/ string sel_tabKeyTraversesCells = sel_registerName("tabKeyTraversesCells");
+    public static /*const*/ string sel_initToBuffer_1capacity_1 = sel_registerName("initToBuffer:capacity:");
+    public static /*const*/ string sel_endPage = sel_registerName("endPage");
+    public static /*const*/ string sel_setTextAttributesForNotANumber_1 = sel_registerName("setTextAttributesForNotANumber:");
+    public static /*const*/ string sel_makeNextSegmentKey = sel_registerName("makeNextSegmentKey");
+    public static /*const*/ string sel_addAttributes_1range_1 = sel_registerName("addAttributes:range:");
+    public static /*const*/ string sel_lineFragmentPadding = sel_registerName("lineFragmentPadding");
+    public static /*const*/ string sel_showController_1adjustingSize_1 = sel_registerName("showController:adjustingSize:");
+    public static /*const*/ string sel_glyphInfoWithGlyphName_1forFont_1baseString_1 = sel_registerName("glyphInfoWithGlyphName:forFont:baseString:");
+    public static /*const*/ string sel_initWithCondition_1 = sel_registerName("initWithCondition:");
+    public static /*const*/ string sel_handleMachMessage_1 = sel_registerName("handleMachMessage:");
+    public static /*const*/ string sel_setFontMenu_1 = sel_registerName("setFontMenu:");
+    public static /*const*/ string sel_invocationWithMethodSignature_1 = sel_registerName("invocationWithMethodSignature:");
+    public static /*const*/ string sel_textAttributesForPositiveValues = sel_registerName("textAttributesForPositiveValues");
+    public static /*const*/ string sel_decodePointForKey_1 = sel_registerName("decodePointForKey:");
+    public static /*const*/ string sel_doubleForKey_1 = sel_registerName("doubleForKey:");
+    public static /*const*/ string sel_application_1willPresentError_1 = sel_registerName("application:willPresentError:");
+    public static /*const*/ string sel_setFloatingPointFormat_1left_1right_1 = sel_registerName("setFloatingPointFormat:left:right:");
+    public static /*const*/ string sel_loadColumnZero = sel_registerName("loadColumnZero");
+    public static /*const*/ string sel_availableFonts = sel_registerName("availableFonts");
+    public static /*const*/ string sel_drawUnderlineForGlyphRange_1underlineType_1baselineOffset_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1 = sel_registerName("drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:");
+    public static /*const*/ string sel_highlightedTableColumn = sel_registerName("highlightedTableColumn");
+    public static /*const*/ string sel_removeObjectsInRange_1 = sel_registerName("removeObjectsInRange:");
+    public static /*const*/ string sel_rectForKey_1inTable_1 = sel_registerName("rectForKey:inTable:");
+    public static /*const*/ string sel_canStoreColor = sel_registerName("canStoreColor");
+    public static /*const*/ string sel_windowWillMiniaturize_1 = sel_registerName("windowWillMiniaturize:");
+    public static /*const*/ string sel_documentForWindow_1 = sel_registerName("documentForWindow:");
+    public static /*const*/ string sel_setAttributedStringForNotANumber_1 = sel_registerName("setAttributedStringForNotANumber:");
+    public static /*const*/ string sel_rangeOfString_1options_1range_1 = sel_registerName("rangeOfString:options:range:");
+    public static /*const*/ string sel_pause = sel_registerName("pause");
+    public static /*const*/ string sel_continueTracking_1at_1inView_1 = sel_registerName("continueTracking:at:inView:");
+    public static /*const*/ string sel_servicesProvider = sel_registerName("servicesProvider");
+    public static /*const*/ string sel_setIgnoredWords_1inSpellDocumentWithTag_1 = sel_registerName("setIgnoredWords:inSpellDocumentWithTag:");
+    public static /*const*/ string sel_clear_1 = sel_registerName("clear:");
+    public static /*const*/ string sel_readFromData_1options_1documentAttributes_1error_1 = sel_registerName("readFromData:options:documentAttributes:error:");
+    public static /*const*/ string sel_columnNumber = sel_registerName("columnNumber");
+    public static /*const*/ string sel_components = sel_registerName("components");
+    public static /*const*/ string sel_image = sel_registerName("image");
+    public static /*const*/ string sel_setDisplayMode_1 = sel_registerName("setDisplayMode:");
+    public static /*const*/ string sel_insertParagraphSeparator_1 = sel_registerName("insertParagraphSeparator:");
+    public static /*const*/ string sel_setPaperName_1 = sel_registerName("setPaperName:");
+    public static /*const*/ string sel_defaultFormatterBehavior = sel_registerName("defaultFormatterBehavior");
+    public static /*const*/ string sel_timeZoneWithAbbreviation_1 = sel_registerName("timeZoneWithAbbreviation:");
+    public static /*const*/ string sel_setHighlighted_1 = sel_registerName("setHighlighted:");
+    public static /*const*/ string sel_addFileWithPath_1 = sel_registerName("addFileWithPath:");
+    public static /*const*/ string sel_allowsDocumentBackgroundColorChange = sel_registerName("allowsDocumentBackgroundColorChange");
+    public static /*const*/ string sel_initWithURL_1documentAttributes_1 = sel_registerName("initWithURL:documentAttributes:");
+    public static /*const*/ string sel_allowsUndo = sel_registerName("allowsUndo");
+    public static /*const*/ string sel_localeIdentifierFromComponents_1 = sel_registerName("localeIdentifierFromComponents:");
+    public static /*const*/ string sel_allowsNonContiguousLayout = sel_registerName("allowsNonContiguousLayout");
+    public static /*const*/ string sel_arrayWithArray_1 = sel_registerName("arrayWithArray:");
+    public static /*const*/ string sel_setCompositingOperation_1 = sel_registerName("setCompositingOperation:");
+    public static /*const*/ string sel_netServiceBrowserDidStopSearch_1 = sel_registerName("netServiceBrowserDidStopSearch:");
+    public static /*const*/ string sel_setHorizontalEdgePadding_1 = sel_registerName("setHorizontalEdgePadding:");
+    public static /*const*/ string sel_accessibilityActionDescription_1 = sel_registerName("accessibilityActionDescription:");
+    public static /*const*/ string sel_localizedKeyDictionary = sel_registerName("localizedKeyDictionary");
+    public static /*const*/ string sel_initWithColorSyncProfile_1 = sel_registerName("initWithColorSyncProfile:");
+    public static /*const*/ string sel_displayedCommandsTitle = sel_registerName("displayedCommandsTitle");
+    public static /*const*/ string sel_flatness = sel_registerName("flatness");
+    public static /*const*/ string sel_localizations = sel_registerName("localizations");
+    public static /*const*/ string sel_mountedRemovableMedia = sel_registerName("mountedRemovableMedia");
+    public static /*const*/ string sel_topAutoreleasePoolCount = sel_registerName("topAutoreleasePoolCount");
+    public static /*const*/ string sel_postsFrameChangedNotifications = sel_registerName("postsFrameChangedNotifications");
+    public static /*const*/ string sel_performZoom_1 = sel_registerName("performZoom:");
+    public static /*const*/ string sel_moveBackward_1 = sel_registerName("moveBackward:");
+    public static /*const*/ string sel_verticalPageScroll = sel_registerName("verticalPageScroll");
+    public static /*const*/ string sel_setToolTip_1forCell_1 = sel_registerName("setToolTip:forCell:");
+    public static /*const*/ string sel_layoutManagerOwnsFirstResponderInWindow_1 = sel_registerName("layoutManagerOwnsFirstResponderInWindow:");
+    public static /*const*/ string sel_jobStyleHint = sel_registerName("jobStyleHint");
+    public static /*const*/ string sel_selectionIndexes = sel_registerName("selectionIndexes");
+    public static /*const*/ string sel_segmentCount = sel_registerName("segmentCount");
+    public static /*const*/ string sel_accessibilityIsIgnored = sel_registerName("accessibilityIsIgnored");
+    public static /*const*/ string sel_hasUnautosavedChanges = sel_registerName("hasUnautosavedChanges");
+    public static /*const*/ string sel_deactivate = sel_registerName("deactivate");
+    public static /*const*/ string sel_setSelectionIndexPaths_1 = sel_registerName("setSelectionIndexPaths:");
+    public static /*const*/ string sel_pathForSoundResource_1 = sel_registerName("pathForSoundResource:");
+    public static /*const*/ string sel_setUsesRuler_1 = sel_registerName("setUsesRuler:");
+    public static /*const*/ string sel_takeSelectedTabViewItemFromSender_1 = sel_registerName("takeSelectedTabViewItemFromSender:");
+    public static /*const*/ string sel_writeToFile_1ofType_1originalFile_1saveOperation_1 = sel_registerName("writeToFile:ofType:originalFile:saveOperation:");
+    public static /*const*/ string sel_numberWithLong_1 = sel_registerName("numberWithLong:");
+    public static /*const*/ string sel_interiorBackgroundStyle = sel_registerName("interiorBackgroundStyle");
+    public static /*const*/ string sel_insertionPointColor = sel_registerName("insertionPointColor");
+    public static /*const*/ string sel_prompt = sel_registerName("prompt");
+    public static /*const*/ string sel_finishLaunching = sel_registerName("finishLaunching");
+    public static /*const*/ string sel_addTextContainer_1 = sel_registerName("addTextContainer:");
+    public static /*const*/ string sel_setAutosavedContentsFileURL_1 = sel_registerName("setAutosavedContentsFileURL:");
+    public static /*const*/ string sel_initWithFrame_1textContainer_1 = sel_registerName("initWithFrame:textContainer:");
+    public static /*const*/ string sel_clearColor = sel_registerName("clearColor");
+    public static /*const*/ string sel_insertText_1 = sel_registerName("insertText:");
+    public static /*const*/ string sel_sendAction = sel_registerName("sendAction");
+    public static /*const*/ string sel_innerRect = sel_registerName("innerRect");
+    public static /*const*/ string sel_pointerFunctions = sel_registerName("pointerFunctions");
+    public static /*const*/ string sel_key = sel_registerName("key");
+    public static /*const*/ string sel_comboBoxSelectionDidChange_1 = sel_registerName("comboBoxSelectionDidChange:");
+    public static /*const*/ string sel_hasMarkedText = sel_registerName("hasMarkedText");
+    public static /*const*/ string sel_setDefaultLineCapStyle_1 = sel_registerName("setDefaultLineCapStyle:");
+    public static /*const*/ string sel_StringListForKey_1inTable_1 = sel_registerName("StringListForKey:inTable:");
+    public static /*const*/ string sel_defaultConnection = sel_registerName("defaultConnection");
+    public static /*const*/ string sel_pathContentOfSymbolicLinkAtPath_1 = sel_registerName("pathContentOfSymbolicLinkAtPath:");
+    public static /*const*/ string sel_StringWithContentsOfFile_1encoding_1error_1 = sel_registerName("StringWithContentsOfFile:encoding:error:");
+    public static /*const*/ string sel_detachSubmenu = sel_registerName("detachSubmenu");
+    public static /*const*/ string sel_isSecure = sel_registerName("isSecure");
+    public static /*const*/ string sel_movie = sel_registerName("movie");
+    public static /*const*/ string sel_outlineViewItemWillExpand_1 = sel_registerName("outlineViewItemWillExpand:");
+    public static /*const*/ string sel_sharedScriptSuiteRegistry = sel_registerName("sharedScriptSuiteRegistry");
+    public static /*const*/ string sel_removeCharactersInString_1 = sel_registerName("removeCharactersInString:");
+    public static /*const*/ string sel_setLocation_1withAdvancements_1forStartOfGlyphRange_1 = sel_registerName("setLocation:withAdvancements:forStartOfGlyphRange:");
+    public static /*const*/ string sel_moveDownAndModifySelection_1 = sel_registerName("moveDownAndModifySelection:");
+    public static /*const*/ string sel_fileAttributesToWriteToURL_1ofType_1forSaveOperation_1originalContentsURL_1error_1 = sel_registerName("fileAttributesToWriteToURL:ofType:forSaveOperation:originalContentsURL:error:");
+    public static /*const*/ string sel_classDescriptionForKey_1 = sel_registerName("classDescriptionForKey:");
+    public static /*const*/ string sel_addRequestMode_1 = sel_registerName("addRequestMode:");
+    public static /*const*/ string sel_setPullsDown_1 = sel_registerName("setPullsDown:");
+    public static /*const*/ string sel_setItemHeight_1 = sel_registerName("setItemHeight:");
+    public static /*const*/ string sel_printerFont = sel_registerName("printerFont");
+    public static /*const*/ string sel_linkTextAttributes = sel_registerName("linkTextAttributes");
+    public static /*const*/ string sel_state = sel_registerName("state");
+    public static /*const*/ string sel_shouldCloseWindowController_1delegate_1shouldCloseSelector_1contextInfo_1 = sel_registerName("shouldCloseWindowController:delegate:shouldCloseSelector:contextInfo:");
+    public static /*const*/ string sel_addIndex_1 = sel_registerName("addIndex:");
+    public static /*const*/ string sel_setChildSpecifier_1 = sel_registerName("setChildSpecifier:");
+    public static /*const*/ string sel_toolbarDidRemoveItem_1 = sel_registerName("toolbarDidRemoveItem:");
+    public static /*const*/ string sel_displayName = sel_registerName("displayName");
+    public static /*const*/ string sel_setInsertionPointColor_1 = sel_registerName("setInsertionPointColor:");
+    public static /*const*/ string sel_bezierPathByReversingPath = sel_registerName("bezierPathByReversingPath");
+    public static /*const*/ string sel_connection_1didReceiveData_1 = sel_registerName("connection:didReceiveData:");
+    public static /*const*/ string sel_eraSymbols = sel_registerName("eraSymbols");
+    public static /*const*/ string sel_removeObjectsForKeys_1 = sel_registerName("removeObjectsForKeys:");
+    public static /*const*/ string sel_subrowIndexesForRow_1 = sel_registerName("subrowIndexesForRow:");
+    public static /*const*/ string sel_increaseLengthBy_1 = sel_registerName("increaseLengthBy:");
+    public static /*const*/ string sel_viewDidEndLiveResize = sel_registerName("viewDidEndLiveResize");
+    public static /*const*/ string sel_encodeBool_1forKey_1 = sel_registerName("encodeBool:forKey:");
+    public static /*const*/ string sel_handleQueryWithUnboundKey_1 = sel_registerName("handleQueryWithUnboundKey:");
+    public static /*const*/ string sel_elementsForName_1 = sel_registerName("elementsForName:");
+    public static /*const*/ string sel_cascadeTopLeftFromPoint_1 = sel_registerName("cascadeTopLeftFromPoint:");
+    public static /*const*/ string sel_linkItemAtPath_1toPath_1error_1 = sel_registerName("linkItemAtPath:toPath:error:");
+    public static /*const*/ string sel_frameSizeForContentSize_1hasHorizontalScroller_1hasVerticalScroller_1borderType_1 = sel_registerName("frameSizeForContentSize:hasHorizontalScroller:hasVerticalScroller:borderType:");
+    public static /*const*/ string sel_initWithString_1attributes_1 = sel_registerName("initWithString:attributes:");
+    public static /*const*/ string sel_readFromData_1options_1documentAttributes_1 = sel_registerName("readFromData:options:documentAttributes:");
+    public static /*const*/ string sel_setAlpha_1 = sel_registerName("setAlpha:");
+    public static /*const*/ string sel_hash = sel_registerName("hash");
+    public static /*const*/ string sel_rangeForUserParagraphAttributeChange = sel_registerName("rangeForUserParagraphAttributeChange");
+    public static /*const*/ string sel_initWithData_1encoding_1 = sel_registerName("initWithData:encoding:");
+    public static /*const*/ string sel_newScriptingObjectOfClass_1forValueForKey_1withContentsValue_1properties_1 = sel_registerName("newScriptingObjectOfClass:forValueForKey:withContentsValue:properties:");
+    public static /*const*/ string sel_pageDown_1 = sel_registerName("pageDown:");
+    public static /*const*/ string sel_hasCloseBox = sel_registerName("hasCloseBox");
+    public static /*const*/ string sel_standardizedURL = sel_registerName("standardizedURL");
+    public static /*const*/ string sel_setAttributes_1range_1 = sel_registerName("setAttributes:range:");
+    public static /*const*/ string sel_setControlSize_1 = sel_registerName("setControlSize:");
+    public static /*const*/ string sel_revertToInitialValues_1 = sel_registerName("revertToInitialValues:");
+    public static /*const*/ string sel_setIntAttribute_1value_1forGlyphAtIndex_1 = sel_registerName("setIntAttribute:value:forGlyphAtIndex:");
+    public static /*const*/ string sel_stopTracking_1at_1inView_1mouseIsUp_1 = sel_registerName("stopTracking:at:inView:mouseIsUp:");
+    public static /*const*/ string sel_setParamDescriptor_1forKeyword_1 = sel_registerName("setParamDescriptor:forKeyword:");
+    public static /*const*/ string sel_textShouldBeginEditing_1 = sel_registerName("textShouldBeginEditing:");
+    public static /*const*/ string sel_applicationDidHide_1 = sel_registerName("applicationDidHide:");
+    public static /*const*/ string sel_beginSheetWithPrintInfo_1modalForWindow_1delegate_1didEndSelector_1contextInfo_1 = sel_registerName("beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:");
+    public static /*const*/ string sel_shiftIndexesStartingAtIndex_1by_1 = sel_registerName("shiftIndexesStartingAtIndex:by:");
+    public static /*const*/ string sel_getStreamsToHost_1port_1inputStream_1outputStream_1 = sel_registerName("getStreamsToHost:port:inputStream:outputStream:");
+    public static /*const*/ string sel_attributesOfFileSystemForPath_1error_1 = sel_registerName("attributesOfFileSystemForPath:error:");
+    public static /*const*/ string sel_setTemporaryAttributes_1forCharacterRange_1 = sel_registerName("setTemporaryAttributes:forCharacterRange:");
+    public static /*const*/ string sel_checkSpellingOfString_1startingAt_1language_1wrap_1inSpellDocumentWithTag_1wordCount_1 = sel_registerName("checkSpellingOfString:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:");
+    public static /*const*/ string sel_insertChild_1atIndex_1 = sel_registerName("insertChild:atIndex:");
+    public static /*const*/ string sel_defaultManager = sel_registerName("defaultManager");
+    public static /*const*/ string sel_invocation = sel_registerName("invocation");
+    public static /*const*/ string sel_setMinValue_1 = sel_registerName("setMinValue:");
+    public static /*const*/ string sel_decodeSize = sel_registerName("decodeSize");
+    public static /*const*/ string sel_replaceObject_1withObject_1 = sel_registerName("replaceObject:withObject:");
+    public static /*const*/ string sel_descriptionWithLocale_1 = sel_registerName("descriptionWithLocale:");
+    public static /*const*/ string sel_setSharingType_1 = sel_registerName("setSharingType:");
+    public static /*const*/ string sel_isLenient = sel_registerName("isLenient");
+    public static /*const*/ string sel_decimalNumberWithString_1locale_1 = sel_registerName("decimalNumberWithString:locale:");
+    public static /*const*/ string sel_allowedTypes = sel_registerName("allowedTypes");
+    public static /*const*/ string sel_superscript_1 = sel_registerName("superscript:");
+    public static /*const*/ string sel_initWithContentsOfFile_1encoding_1error_1 = sel_registerName("initWithContentsOfFile:encoding:error:");
+    public static /*const*/ string sel_windowsMenu = sel_registerName("windowsMenu");
+    public static /*const*/ string sel_performSelector_1target_1argument_1order_1modes_1 = sel_registerName("performSelector:target:argument:order:modes:");
+    public static /*const*/ string sel_unscheduleFromRunLoop_1forMode_1 = sel_registerName("unscheduleFromRunLoop:forMode:");
+    public static /*const*/ string sel_evaluatedArguments = sel_registerName("evaluatedArguments");
+    public static /*const*/ string sel_encodeSize_1forKey_1 = sel_registerName("encodeSize:forKey:");
+    public static /*const*/ string sel_sendBeforeDate_1components_1from_1reserved_1 = sel_registerName("sendBeforeDate:components:from:reserved:");
+    public static /*const*/ string sel_containerSize = sel_registerName("containerSize");
+    public static /*const*/ string sel_selectedTextColor = sel_registerName("selectedTextColor");
+    public static /*const*/ string sel_getGlyphsInRange_1glyphs_1characterIndexes_1glyphInscriptions_1elasticBits_1 = sel_registerName("getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:");
+    public static /*const*/ string sel_curveToPoint_1controlPoint1_1controlPoint2_1 = sel_registerName("curveToPoint:controlPoint1:controlPoint2:");
+    public static /*const*/ string sel_mutableBytes = sel_registerName("mutableBytes");
+    public static /*const*/ string sel_rangeOfUnit_1inUnit_1forDate_1 = sel_registerName("rangeOfUnit:inUnit:forDate:");
+    public static /*const*/ string sel_allowsNaturalLanguage = sel_registerName("allowsNaturalLanguage");
+    public static /*const*/ string sel_mouseLocation = sel_registerName("mouseLocation");
+    public static /*const*/ string sel_selectCellAtRow_1column_1 = sel_registerName("selectCellAtRow:column:");
+    public static /*const*/ string sel_toggleBaseWritingDirection_1 = sel_registerName("toggleBaseWritingDirection:");
+    public static /*const*/ string sel_maximum = sel_registerName("maximum");
+    public static /*const*/ string sel_initWithFocusedViewRect_1 = sel_registerName("initWithFocusedViewRect:");
+    public static /*const*/ string sel_thickness = sel_registerName("thickness");
+    public static /*const*/ string sel_setImageOrigin_1 = sel_registerName("setImageOrigin:");
+    public static /*const*/ string sel_color = sel_registerName("color");
+    public static /*const*/ string sel_capitalizeWord_1 = sel_registerName("capitalizeWord:");
+    public static /*const*/ string sel_imageRepClassForData_1 = sel_registerName("imageRepClassForData:");
+    public static /*const*/ string sel_outlineTableColumn = sel_registerName("outlineTableColumn");
+    public static /*const*/ string sel_runModalWithPrintInfo_1 = sel_registerName("runModalWithPrintInfo:");
+    public static /*const*/ string sel_flushCachedData = sel_registerName("flushCachedData");
+    public static /*const*/ string sel_exitFullScreenModeWithOptions_1 = sel_registerName("exitFullScreenModeWithOptions:");
+    public static /*const*/ string sel_alertStyle = sel_registerName("alertStyle");
+    public static /*const*/ string sel_runModalPageLayoutWithPrintInfo_1delegate_1didRunSelector_1contextInfo_1 = sel_registerName("runModalPageLayoutWithPrintInfo:delegate:didRunSelector:contextInfo:");
+    public static /*const*/ string sel_setDisplayedWhenStopped_1 = sel_registerName("setDisplayedWhenStopped:");
+    public static /*const*/ string sel_drawBackgroundWithFrame_1inView_1characterRange_1layoutManager_1 = sel_registerName("drawBackgroundWithFrame:inView:characterRange:layoutManager:");
+    public static /*const*/ string sel_addObject_1 = sel_registerName("addObject:");
+    public static /*const*/ string sel_dragPromisedFilesOfTypes_1fromRect_1source_1slideBack_1event_1 = sel_registerName("dragPromisedFilesOfTypes:fromRect:source:slideBack:event:");
+    public static /*const*/ string sel_samplesPerPixel = sel_registerName("samplesPerPixel");
+    public static /*const*/ string sel_negativePrefix = sel_registerName("negativePrefix");
+    public static /*const*/ string sel_initialKey = sel_registerName("initialKey");
+    public static /*const*/ string sel_orderFrontColorPanel_1 = sel_registerName("orderFrontColorPanel:");
+    public static /*const*/ string sel_hasLearnedWord_1 = sel_registerName("hasLearnedWord:");
+    public static /*const*/ string sel_setLineFragmentRect_1forGlyphRange_1usedRect_1baselineOffset_1 = sel_registerName("setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:");
+    public static /*const*/ string sel_setHidesOnDeactivate_1 = sel_registerName("setHidesOnDeactivate:");
+    public static /*const*/ string sel_setMsgid_1 = sel_registerName("setMsgid:");
+    public static /*const*/ string sel_elementCount = sel_registerName("elementCount");
+    public static /*const*/ string sel_dateWithString_1 = sel_registerName("dateWithString:");
+    public static /*const*/ string sel_rangeOfTextBlock_1atIndex_1 = sel_registerName("rangeOfTextBlock:atIndex:");
+    public static /*const*/ string sel_setMenuItemCell_1forItemAtIndex_1 = sel_registerName("setMenuItemCell:forItemAtIndex:");
+    public static /*const*/ string sel_defaultTimeZone = sel_registerName("defaultTimeZone");
+    public static /*const*/ string sel_gotoBeginning_1 = sel_registerName("gotoBeginning:");
+    public static /*const*/ string sel_setDrawsOutsideLineFragment_1forGlyphAtIndex_1 = sel_registerName("setDrawsOutsideLineFragment:forGlyphAtIndex:");
+    public static /*const*/ string sel_characterCollection = sel_registerName("characterCollection");
+    public static /*const*/ string sel_getValues_1forParameter_1 = sel_registerName("getValues:forParameter:");
+    public static /*const*/ string sel_removeColumn_1 = sel_registerName("removeColumn:");
+    public static /*const*/ string sel_descender = sel_registerName("descender");
+    public static /*const*/ string sel_fragment = sel_registerName("fragment");
+    public static /*const*/ string sel_setSelectionByRect_1 = sel_registerName("setSelectionByRect:");
+    public static /*const*/ string sel_colorWithColorSpace_1components_1count_1 = sel_registerName("colorWithColorSpace:components:count:");
+    public static /*const*/ string sel_windingRule = sel_registerName("windingRule");
+    public static /*const*/ string sel_insertColumn_1 = sel_registerName("insertColumn:");
+    public static /*const*/ string sel_resumeWithSuspensionID_1 = sel_registerName("resumeWithSuspensionID:");
+    public static /*const*/ string sel_seekToEndOfFile = sel_registerName("seekToEndOfFile");
+    public static /*const*/ string sel_initWithTarget_1connection_1 = sel_registerName("initWithTarget:connection:");
+    public static /*const*/ string sel_symbolCharacterSet = sel_registerName("symbolCharacterSet");
+    public static /*const*/ string sel_filterPredicate = sel_registerName("filterPredicate");
+    public static /*const*/ string sel_setAutoenablesItems_1 = sel_registerName("setAutoenablesItems:");
+    public static /*const*/ string sel_printShowingPrintPanel_1 = sel_registerName("printShowingPrintPanel:");
+    public static /*const*/ string sel_pathForResource_1ofType_1inDirectory_1forLocalization_1 = sel_registerName("pathForResource:ofType:inDirectory:forLocalization:");
+    public static /*const*/ string sel_objectByApplyingXSLTAtURL_1arguments_1error_1 = sel_registerName("objectByApplyingXSLTAtURL:arguments:error:");
+    public static /*const*/ string sel_setHidesEmptyCells_1 = sel_registerName("setHidesEmptyCells:");
+    public static /*const*/ string sel_date = sel_registerName("date");
+    public static /*const*/ string sel_writeToFile_1atomically_1 = sel_registerName("writeToFile:atomically:");
+    public static /*const*/ string sel_locale = sel_registerName("locale");
+    public static /*const*/ string sel_localizedKeyTable = sel_registerName("localizedKeyTable");
+    public static /*const*/ string sel_absoluteURL = sel_registerName("absoluteURL");
+    public static /*const*/ string sel_bundleWithPath_1 = sel_registerName("bundleWithPath:");
+    public static /*const*/ string sel_setHeaderCell_1 = sel_registerName("setHeaderCell:");
+    public static /*const*/ string sel_setAutoresizesSubviews_1 = sel_registerName("setAutoresizesSubviews:");
+    public static /*const*/ string sel_URI = sel_registerName("URI");
+    public static /*const*/ string sel_controlBackgroundColor = sel_registerName("controlBackgroundColor");
+    public static /*const*/ string sel_displayNameAtPath_1 = sel_registerName("displayNameAtPath:");
+    public static /*const*/ string sel_decodePortObject = sel_registerName("decodePortObject");
+    public static /*const*/ string sel_alpha = sel_registerName("alpha");
+    public static /*const*/ string sel_initWithLeftExpression_1rightExpression_1customSelector_1 = sel_registerName("initWithLeftExpression:rightExpression:customSelector:");
+    public static /*const*/ string sel_secondaryGroupingSize = sel_registerName("secondaryGroupingSize");
+    public static /*const*/ string sel_connectionDidFinishLoading_1 = sel_registerName("connectionDidFinishLoading:");
+    public static /*const*/ string sel_localObjects = sel_registerName("localObjects");
+    public static /*const*/ string sel_enableKeyEquivalentForDefaultButtonCell = sel_registerName("enableKeyEquivalentForDefaultButtonCell");
+    public static /*const*/ string sel_drawKnobSlotInRect_1highlight_1 = sel_registerName("drawKnobSlotInRect:highlight:");
+    public static /*const*/ string sel_dateWithString_1calendarFormat_1locale_1 = sel_registerName("dateWithString:calendarFormat:locale:");
+    public static /*const*/ string sel_stop = sel_registerName("stop");
+    public static /*const*/ string sel_appendBezierPathWithOvalInRect_1 = sel_registerName("appendBezierPathWithOvalInRect:");
+    public static /*const*/ string sel_componentsSeparatedByCharactersInSet_1 = sel_registerName("componentsSeparatedByCharactersInSet:");
+    public static /*const*/ string sel_tightenKerning_1 = sel_registerName("tightenKerning:");
+    public static /*const*/ string sel_verticalRulerView = sel_registerName("verticalRulerView");
+    public static /*const*/ string sel_setImageAlignment_1 = sel_registerName("setImageAlignment:");
+    public static /*const*/ string sel_removeFrameUsingName_1 = sel_registerName("removeFrameUsingName:");
+    public static /*const*/ string sel_insertColor_1key_1atIndex_1 = sel_registerName("insertColor:key:atIndex:");
+    public static /*const*/ string sel_terminate_1 = sel_registerName("terminate:");
+    public static /*const*/ string sel_textContainerChangedTextView_1 = sel_registerName("textContainerChangedTextView:");
+    public static /*const*/ string sel_removeFileAtPath_1handler_1 = sel_registerName("removeFileAtPath:handler:");
+    public static /*const*/ string sel_splitViewWillResizeSubviews_1 = sel_registerName("splitViewWillResizeSubviews:");
+    public static /*const*/ string sel_windowDidBecomeMain_1 = sel_registerName("windowDidBecomeMain:");
+    public static /*const*/ string sel_cellBaselineOffset = sel_registerName("cellBaselineOffset");
+    public static /*const*/ string sel_addEntriesFromDictionary_1 = sel_registerName("addEntriesFromDictionary:");
+    public static /*const*/ string sel_setOnStateImage_1 = sel_registerName("setOnStateImage:");
+    public static /*const*/ string sel_colorWithCIColor_1 = sel_registerName("colorWithCIColor:");
+    public static /*const*/ string sel_getCyan_1magenta_1yellow_1black_1alpha_1 = sel_registerName("getCyan:magenta:yellow:black:alpha:");
+    public static /*const*/ string sel_symbolicTraits = sel_registerName("symbolicTraits");
+    public static /*const*/ string sel_StringByAppendingPathExtension_1 = sel_registerName("StringByAppendingPathExtension:");
+    public static /*const*/ string sel_horizontalScroller = sel_registerName("horizontalScroller");
+    public static /*const*/ string sel_setInitialValue_1 = sel_registerName("setInitialValue:");
+    public static /*const*/ string sel_sizeForPaperName_1 = sel_registerName("sizeForPaperName:");
+    public static /*const*/ string sel_CGLContextObj = sel_registerName("CGLContextObj");
+    public static /*const*/ string sel_elementWithName_1 = sel_registerName("elementWithName:");
+    public static /*const*/ string sel_fileManager_1shouldMoveItemAtPath_1toPath_1 = sel_registerName("fileManager:shouldMoveItemAtPath:toPath:");
+    public static /*const*/ string sel_richTextSource = sel_registerName("richTextSource");
+    public static /*const*/ string sel_unregisterDraggedTypes = sel_registerName("unregisterDraggedTypes");
+    public static /*const*/ string sel_absoluteString = sel_registerName("absoluteString");
+    public static /*const*/ string sel_spellingPanel = sel_registerName("spellingPanel");
+    public static /*const*/ string sel_launchedApplications = sel_registerName("launchedApplications");
+    public static /*const*/ string sel_initWithContentsOfFile_1byReference_1 = sel_registerName("initWithContentsOfFile:byReference:");
+    public static /*const*/ string sel_setLoaded_1 = sel_registerName("setLoaded:");
+    public static /*const*/ string sel_setWindowFrameAutosaveName_1 = sel_registerName("setWindowFrameAutosaveName:");
+    public static /*const*/ string sel_initOrTestWithTests_1 = sel_registerName("initOrTestWithTests:");
+    public static /*const*/ string sel_drawsBackground = sel_registerName("drawsBackground");
+    public static /*const*/ string sel_numberWithDouble_1 = sel_registerName("numberWithDouble:");
+    public static /*const*/ string sel_textView_1writeCell_1atIndex_1toPasteboard_1type_1 = sel_registerName("textView:writeCell:atIndex:toPasteboard:type:");
+    public static /*const*/ string sel_defaultMiterLimit = sel_registerName("defaultMiterLimit");
+    public static /*const*/ string sel_containsObject_1 = sel_registerName("containsObject:");
+    public static /*const*/ string sel_headerTextColor = sel_registerName("headerTextColor");
+    public static /*const*/ string sel_textView_1doCommandBySelector_1 = sel_registerName("textView:doCommandBySelector:");
+    public static /*const*/ string sel_drawBorderAndBackgroundWithFrame_1inView_1 = sel_registerName("drawBorderAndBackgroundWithFrame:inView:");
+    public static /*const*/ string sel_quarterSymbols = sel_registerName("quarterSymbols");
+    public static /*const*/ string sel_setContainerSize_1 = sel_registerName("setContainerSize:");
+    public static /*const*/ string sel_sortUsingSelector_1 = sel_registerName("sortUsingSelector:");
+    public static /*const*/ string sel_setKey_1 = sel_registerName("setKey:");
+    public static /*const*/ string sel_headerView = sel_registerName("headerView");
+    public static /*const*/ string sel_isRegularFile = sel_registerName("isRegularFile");
+    public static /*const*/ string sel_userData = sel_registerName("userData");
+    public static /*const*/ string sel_documentCursor = sel_registerName("documentCursor");
+    public static /*const*/ string sel_textEncodingName = sel_registerName("textEncodingName");
+    public static /*const*/ string sel_performActionForItemAtIndex_1 = sel_registerName("performActionForItemAtIndex:");
+    public static /*const*/ string sel_isCaseInsensitiveLike_1 = sel_registerName("isCaseInsensitiveLike:");
+    public static /*const*/ string sel_isEditing = sel_registerName("isEditing");
+    public static /*const*/ string sel_selectFile_1inFileViewerRootedAtPath_1 = sel_registerName("selectFile:inFileViewerRootedAtPath:");
+    public static /*const*/ string sel_messageFontOfSize_1 = sel_registerName("messageFontOfSize:");
+    public static /*const*/ string sel_independentConversationQueueing = sel_registerName("independentConversationQueueing");
+    public static /*const*/ string sel_initWithCoder_1 = sel_registerName("initWithCoder:");
+    public static /*const*/ string sel_rangesForUserParagraphAttributeChange = sel_registerName("rangesForUserParagraphAttributeChange");
+    public static /*const*/ string sel_removeTrackingArea_1 = sel_registerName("removeTrackingArea:");
+    public static /*const*/ string sel_glyphGenerator = sel_registerName("glyphGenerator");
+    public static /*const*/ string sel_extraLineFragmentUsedRect = sel_registerName("extraLineFragmentUsedRect");
+    public static /*const*/ string sel_isButtonBordered = sel_registerName("isButtonBordered");
+    public static /*const*/ string sel_setDefaultFormatterBehavior_1 = sel_registerName("setDefaultFormatterBehavior:");
+    public static /*const*/ string sel_didChange_1valuesAtIndexes_1forKey_1 = sel_registerName("didChange:valuesAtIndexes:forKey:");
+    public static /*const*/ string sel_timeoutInterval = sel_registerName("timeoutInterval");
+    public static /*const*/ string sel_initialValues = sel_registerName("initialValues");
+    public static /*const*/ string sel_getRow_1column_1forPoint_1 = sel_registerName("getRow:column:forPoint:");
+    public static /*const*/ string sel_tabletPoint_1 = sel_registerName("tabletPoint:");
+    public static /*const*/ string sel_setAutorecalculatesKeyViewLoop_1 = sel_registerName("setAutorecalculatesKeyViewLoop:");
+    public static /*const*/ string sel_identifier = sel_registerName("identifier");
+    public static /*const*/ string sel_scheduleInRunLoop_1forMode_1 = sel_registerName("scheduleInRunLoop:forMode:");
+    public static /*const*/ string sel_baseURL = sel_registerName("baseURL");
+    public static /*const*/ string sel_initWithURL_1 = sel_registerName("initWithURL:");
+    public static /*const*/ string sel_setBackgroundColors_1 = sel_registerName("setBackgroundColors:");
+    public static /*const*/ string sel_addTableColumn_1 = sel_registerName("addTableColumn:");
+    public static /*const*/ string sel_fontDescriptorWithFontAttributes_1 = sel_registerName("fontDescriptorWithFontAttributes:");
+    public static /*const*/ string sel_dataCellForRow_1 = sel_registerName("dataCellForRow:");
+    public static /*const*/ string sel_speechSynthesizer_1didEncounterErrorAtIndex_1ofString_1message_1 = sel_registerName("speechSynthesizer:didEncounterErrorAtIndex:ofString:message:");
+    public static /*const*/ string sel_recoveryAttempter = sel_registerName("recoveryAttempter");
+    public static /*const*/ string sel_alignJustified_1 = sel_registerName("alignJustified:");
+    public static /*const*/ string sel_setCompression_1factor_1 = sel_registerName("setCompression:factor:");
+    public static /*const*/ string sel_elementsForLocalName_1URI_1 = sel_registerName("elementsForLocalName:URI:");
+    public static /*const*/ string sel_deviceGrayColorSpace = sel_registerName("deviceGrayColorSpace");
+    public static /*const*/ string sel_scheduledTimerWithTimeInterval_1target_1selector_1userInfo_1repeats_1 = sel_registerName("scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:");
+    public static /*const*/ string sel_runModalSession_1 = sel_registerName("runModalSession:");
+    public static /*const*/ string sel_awakeFromNib = sel_registerName("awakeFromNib");
+    public static /*const*/ string sel_connectionWithReceivePort_1sendPort_1 = sel_registerName("connectionWithReceivePort:sendPort:");
+    public static /*const*/ string sel_outlineView_1validateDrop_1proposedItem_1proposedChildIndex_1 = sel_registerName("outlineView:validateDrop:proposedItem:proposedChildIndex:");
+    public static /*const*/ string sel_remove_1 = sel_registerName("remove:");
+    public static /*const*/ string sel_setTimeInterval_1 = sel_registerName("setTimeInterval:");
+    public static /*const*/ string sel_splitView_1effectiveRect_1forDrawnRect_1ofDividerAtIndex_1 = sel_registerName("splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:");
+    public static /*const*/ string sel_setUpGState = sel_registerName("setUpGState");
+    public static /*const*/ string sel_initWithResponse_1data_1 = sel_registerName("initWithResponse:data:");
+    public static /*const*/ string sel_notificationCenter = sel_registerName("notificationCenter");
+    public static /*const*/ string sel_setAlternateImage_1 = sel_registerName("setAlternateImage:");
+    public static /*const*/ string sel_mainWindow = sel_registerName("mainWindow");
+    public static /*const*/ string sel_substringWithRange_1 = sel_registerName("substringWithRange:");
+    public static /*const*/ string sel_forgetWord_1 = sel_registerName("forgetWord:");
+    public static /*const*/ string sel_shouldCascadeWindows = sel_registerName("shouldCascadeWindows");
+    public static /*const*/ string sel_updateScroller = sel_registerName("updateScroller");
+    public static /*const*/ string sel_currentDirectoryPath = sel_registerName("currentDirectoryPath");
+    public static /*const*/ string sel_isPartialStringValidationEnabled = sel_registerName("isPartialStringValidationEnabled");
+    public static /*const*/ string sel_splitView_1constrainMinCoordinate_1ofSubviewAt_1 = sel_registerName("splitView:constrainMinCoordinate:ofSubviewAt:");
+    public static /*const*/ string sel_drawWithFrame_1inView_1 = sel_registerName("drawWithFrame:inView:");
+    public static /*const*/ string sel_encodingScheme = sel_registerName("encodingScheme");
+    public static /*const*/ string sel_namespaceWithName_1StringValue_1 = sel_registerName("namespaceWithName:StringValue:");
+    public static /*const*/ string sel_initWithLongLong_1 = sel_registerName("initWithLongLong:");
+    public static /*const*/ string sel_processIdentifier = sel_registerName("processIdentifier");
+    public static /*const*/ string sel_setSubmenu_1forItem_1 = sel_registerName("setSubmenu:forItem:");
+    public static /*const*/ string sel_textAttributesForNil = sel_registerName("textAttributesForNil");
+    public static /*const*/ string sel_lockWithPath_1 = sel_registerName("lockWithPath:");
+    public static /*const*/ string sel_removeFromSuperviewWithoutNeedingDisplay = sel_registerName("removeFromSuperviewWithoutNeedingDisplay");
+    public static /*const*/ string sel_cut_1 = sel_registerName("cut:");
+    public static /*const*/ string sel_nullDescriptor = sel_registerName("nullDescriptor");
+    public static /*const*/ string sel_menuFormRepresentation = sel_registerName("menuFormRepresentation");
+    public static /*const*/ string sel_removeObjectsAtIndexes_1 = sel_registerName("removeObjectsAtIndexes:");
+    public static /*const*/ string sel_initWithSource_1 = sel_registerName("initWithSource:");
+    public static /*const*/ string sel_acceptsGlyphInfo = sel_registerName("acceptsGlyphInfo");
+    public static /*const*/ string sel_borderType = sel_registerName("borderType");
+    public static /*const*/ string sel_initWithResumeData_1delegate_1path_1 = sel_registerName("initWithResumeData:delegate:path:");
+    public static /*const*/ string sel_attachedMenu = sel_registerName("attachedMenu");
+    public static /*const*/ string sel_stopAnimation = sel_registerName("stopAnimation");
+    public static /*const*/ string sel_setDoubleAction_1 = sel_registerName("setDoubleAction:");
+    public static /*const*/ string sel_returnType = sel_registerName("returnType");
+    public static /*const*/ string sel_fontDescriptorsInCollection_1 = sel_registerName("fontDescriptorsInCollection:");
+    public static /*const*/ string sel_setMeasurementUnits_1 = sel_registerName("setMeasurementUnits:");
+    public static /*const*/ string sel_baseWritingDirection = sel_registerName("baseWritingDirection");
+    public static /*const*/ string sel_currentPoint = sel_registerName("currentPoint");
+    public static /*const*/ string sel_initRemoteWithTCPPort_1host_1 = sel_registerName("initRemoteWithTCPPort:host:");
+    public static /*const*/ string sel_entityDeclarationForName_1 = sel_registerName("entityDeclarationForName:");
+    public static /*const*/ string sel_evaluate = sel_registerName("evaluate");
+    public static /*const*/ string sel_browser_1draggingImageForRowsWithIndexes_1inColumn_1withEvent_1offset_1 = sel_registerName("browser:draggingImageForRowsWithIndexes:inColumn:withEvent:offset:");
+    public static /*const*/ string sel_turnOffLigatures_1 = sel_registerName("turnOffLigatures:");
+    public static /*const*/ string sel_setTitleWithMnemonic_1 = sel_registerName("setTitleWithMnemonic:");
+    public static /*const*/ string sel_deepestScreen = sel_registerName("deepestScreen");
+    public static /*const*/ string sel_connection_1shouldMakeNewConnection_1 = sel_registerName("connection:shouldMakeNewConnection:");
+    public static /*const*/ string sel_selectionShouldChangeInOutlineView_1 = sel_registerName("selectionShouldChangeInOutlineView:");
+    public static /*const*/ string sel_preservesSelection = sel_registerName("preservesSelection");
+    public static /*const*/ string sel_preparePageLayout_1 = sel_registerName("preparePageLayout:");
+    public static /*const*/ string sel_setOpaque_1 = sel_registerName("setOpaque:");
+    public static /*const*/ string sel_insertObject_1atIndex_1 = sel_registerName("insertObject:atIndex:");
+    public static /*const*/ string sel_isActive = sel_registerName("isActive");
+    public static /*const*/ string sel_drawStrikethroughForGlyphRange_1strikethroughType_1baselineOffset_1lineFragmentRect_1lineFragmentGlyphRange_1containerOrigin_1 = sel_registerName("drawStrikethroughForGlyphRange:strikethroughType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:");
+    public static /*const*/ string sel_insertObject_1atArrangedObjectIndex_1 = sel_registerName("insertObject:atArrangedObjectIndex:");
+    public static /*const*/ string sel_initWithCStringNoCopy_1length_1freeWhenDone_1 = sel_registerName("initWithCStringNoCopy:length:freeWhenDone:");
+    public static /*const*/ string sel_previousKeyView = sel_registerName("previousKeyView");
+    public static /*const*/ string sel_performMiniaturize_1 = sel_registerName("performMiniaturize:");
+    public static /*const*/ string sel_decimalNumberWithDecimal_1 = sel_registerName("decimalNumberWithDecimal:");
+    public static /*const*/ string sel_autosaveTableColumns = sel_registerName("autosaveTableColumns");
+    public static /*const*/ string sel_baselineOffsetInLayoutManager_1glyphIndex_1 = sel_registerName("baselineOffsetInLayoutManager:glyphIndex:");
+    public static /*const*/ string sel_keyViewSelectionDirection = sel_registerName("keyViewSelectionDirection");
+    public static /*const*/ string sel_encodeBytes_1length_1 = sel_registerName("encodeBytes:length:");
+    public static /*const*/ string sel_fileManager_1shouldProceedAfterError_1copyingItemAtPath_1toPath_1 = sel_registerName("fileManager:shouldProceedAfterError:copyingItemAtPath:toPath:");
+    public static /*const*/ string sel_menuNeedsUpdate_1 = sel_registerName("menuNeedsUpdate:");
+    public static /*const*/ string sel_paragraphSpacingAfterGlyphAtIndex_1withProposedLineFragmentRect_1 = sel_registerName("paragraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:");
+    public static /*const*/ string sel_synchronize = sel_registerName("synchronize");
+    public static /*const*/ string sel_lockFocus = sel_registerName("lockFocus");
+    public static /*const*/ string sel_toggleSmartInsertDelete_1 = sel_registerName("toggleSmartInsertDelete:");
+    public static /*const*/ string sel_setMenu_1forSegment_1 = sel_registerName("setMenu:forSegment:");
+    public static /*const*/ string sel_removeParamDescriptorWithKeyword_1 = sel_registerName("removeParamDescriptorWithKeyword:");
+    public static /*const*/ string sel_applicationShouldOpenUntitledFile_1 = sel_registerName("applicationShouldOpenUntitledFile:");
+    public static /*const*/ string sel_DTD = sel_registerName("DTD");
+    public static /*const*/ string sel_cancelTracking = sel_registerName("cancelTracking");
+    public static /*const*/ string sel_fileSystemNumber = sel_registerName("fileSystemNumber");
+    public static /*const*/ string sel_setLevel_1 = sel_registerName("setLevel:");
+    public static /*const*/ string sel_setRequiredFileType_1 = sel_registerName("setRequiredFileType:");
+    public static /*const*/ string sel_presentError_1 = sel_registerName("presentError:");
+    public static /*const*/ string sel_allowsUserCustomization = sel_registerName("allowsUserCustomization");
+    public static /*const*/ string sel_childrenKeyPathForNode_1 = sel_registerName("childrenKeyPathForNode:");
+    public static /*const*/ string sel_setYear_1 = sel_registerName("setYear:");
+    public static /*const*/ string sel_movieController = sel_registerName("movieController");
+    public static /*const*/ string sel_unsignedLongValue = sel_registerName("unsignedLongValue");
+    public static /*const*/ string sel_hashTableWithOptions_1 = sel_registerName("hashTableWithOptions:");
+    public static /*const*/ string sel_setVerticalAlignment_1 = sel_registerName("setVerticalAlignment:");
+    public static /*const*/ string sel_cycleToNextInputServerInLanguage_1 = sel_registerName("cycleToNextInputServerInLanguage:");
+    public static /*const*/ string sel_sendAction_1to_1from_1 = sel_registerName("sendAction:to:from:");
+    public static /*const*/ string sel_numberFromString_1 = sel_registerName("numberFromString:");
+    public static /*const*/ string sel_setUndoManager_1 = sel_registerName("setUndoManager:");
+    public static /*const*/ string sel_imageDimsWhenDisabled = sel_registerName("imageDimsWhenDisabled");
+    public static /*const*/ string sel_autosavingFileType = sel_registerName("autosavingFileType");
+    public static /*const*/ string sel_unsignedLongLongValue = sel_registerName("unsignedLongLongValue");
+    public static /*const*/ string sel_initImageCell_1 = sel_registerName("initImageCell:");
+    public static /*const*/ string sel_invalidateDisplayForCharacterRange_1 = sel_registerName("invalidateDisplayForCharacterRange:");
+    public static /*const*/ string sel_setMaxContentSize_1 = sel_registerName("setMaxContentSize:");
+    public static /*const*/ string sel_outlineView_1isItemExpandable_1 = sel_registerName("outlineView:isItemExpandable:");
+    public static /*const*/ string sel_initWithUser_1password_1persistence_1 = sel_registerName("initWithUser:password:persistence:");
+    public static /*const*/ string sel_setBackgroundFilters_1 = sel_registerName("setBackgroundFilters:");
+    public static /*const*/ string sel_setAllowsDocumentBackgroundColorChange_1 = sel_registerName("setAllowsDocumentBackgroundColorChange:");
+    public static /*const*/ string sel_decodeNXObject = sel_registerName("decodeNXObject");
+    public static /*const*/ string sel_setMaximumSignificantDigits_1 = sel_registerName("setMaximumSignificantDigits:");
+    public static /*const*/ string sel_URLsFromRunningOpenPanel = sel_registerName("URLsFromRunningOpenPanel");
+    public static /*const*/ string sel_removeChildWindow_1 = sel_registerName("removeChildWindow:");
+    public static /*const*/ string sel_removeObjectForKey_1 = sel_registerName("removeObjectForKey:");
+    public static /*const*/ string sel_setCellSize_1 = sel_registerName("setCellSize:");
+    public static /*const*/ string sel_getParagraphStart_1end_1contentsEnd_1forRange_1 = sel_registerName("getParagraphStart:end:contentsEnd:forRange:");
+    public static /*const*/ string sel_connectionWithRequest_1delegate_1 = sel_registerName("connectionWithRequest:delegate:");
+    public static /*const*/ string sel_setNotShownAttribute_1forGlyphRange_1 = sel_registerName("setNotShownAttribute:forGlyphRange:");
+    public static /*const*/ string sel_collapsesBorders = sel_registerName("collapsesBorders");
+    public static /*const*/ string sel_setNegativeInfinitySymbol_1 = sel_registerName("setNegativeInfinitySymbol:");
+    public static /*const*/ string sel_initWithKind_1 = sel_registerName("initWithKind:");
+    public static /*const*/ string sel_appleEventCodeForArgumentWithName_1 = sel_registerName("appleEventCodeForArgumentWithName:");
+    public static /*const*/ string sel_moveUp_1 = sel_registerName("moveUp:");
+    public static /*const*/ string sel_initWithTextAlignment_1location_1options_1 = sel_registerName("initWithTextAlignment:location:options:");
+    public static /*const*/ string sel_systemVersion = sel_registerName("systemVersion");
+    public static /*const*/ string sel_numberOfItemsInComboBoxCell_1 = sel_registerName("numberOfItemsInComboBoxCell:");
+    public static /*const*/ string sel_readableTypes = sel_registerName("readableTypes");
+    public static /*const*/ string sel_setDraggingSourceOperationMask_1forLocal_1 = sel_registerName("setDraggingSourceOperationMask:forLocal:");
+    public static /*const*/ string sel_insertLineBreak_1 = sel_registerName("insertLineBreak:");
+    public static /*const*/ string sel_inLiveResize = sel_registerName("inLiveResize");
+    public static /*const*/ string sel_setCanHide_1 = sel_registerName("setCanHide:");
+    public static /*const*/ string sel_nextResponder = sel_registerName("nextResponder");
+    public static /*const*/ string sel_scrollClipView_1toPoint_1 = sel_registerName("scrollClipView:toPoint:");
+    public static /*const*/ string sel_positiveFormat = sel_registerName("positiveFormat");
+    public static /*const*/ string sel_redoMenuItemTitle = sel_registerName("redoMenuItemTitle");
+    public static /*const*/ string sel_addIndexesInRange_1 = sel_registerName("addIndexesInRange:");
+    public static /*const*/ string sel_lockBeforeDate_1 = sel_registerName("lockBeforeDate:");
+    public static /*const*/ string sel_unlockWithCondition_1 = sel_registerName("unlockWithCondition:");
+    public static /*const*/ string sel_nextWordFromIndex_1forward_1 = sel_registerName("nextWordFromIndex:forward:");
+    public static /*const*/ string sel_waitUntilAllOperationsAreFinished = sel_registerName("waitUntilAllOperationsAreFinished");
+    public static /*const*/ string sel_drawRow_1clipRect_1 = sel_registerName("drawRow:clipRect:");
+    public static /*const*/ string sel_setPartialStringValidationEnabled_1 = sel_registerName("setPartialStringValidationEnabled:");
+    public static /*const*/ string sel_methodSignatureForSelector_1 = sel_registerName("methodSignatureForSelector:");
+    public static /*const*/ string sel_setSecondaryGroupingSize_1 = sel_registerName("setSecondaryGroupingSize:");
+    public static /*const*/ string sel_criteriaForRow_1 = sel_registerName("criteriaForRow:");
+    public static /*const*/ string sel_setShadowBlurRadius_1 = sel_registerName("setShadowBlurRadius:");
+    public static /*const*/ string sel_expressionForFunction_1selectorName_1arguments_1 = sel_registerName("expressionForFunction:selectorName:arguments:");
+    public static /*const*/ string sel_initWithWindowNibName_1 = sel_registerName("initWithWindowNibName:");
+    public static /*const*/ string sel_selectItemWithTag_1 = sel_registerName("selectItemWithTag:");
+    public static /*const*/ string sel_characterIndexForPoint_1 = sel_registerName("characterIndexForPoint:");
+    public static /*const*/ string sel_validate = sel_registerName("validate");
+    public static /*const*/ string sel_setHorizontalPageScroll_1 = sel_registerName("setHorizontalPageScroll:");
+    public static /*const*/ string sel_localizedColorNameComponent = sel_registerName("localizedColorNameComponent");
+    public static /*const*/ string sel_setVoice_1 = sel_registerName("setVoice:");
+    public static /*const*/ string sel_setCachedSeparately_1 = sel_registerName("setCachedSeparately:");
+    public static /*const*/ string sel_frameRectForContentRect_1 = sel_registerName("frameRectForContentRect:");
+    public static /*const*/ string sel_bezelStyle = sel_registerName("bezelStyle");
+    public static /*const*/ string sel_setDecimalSeparator_1 = sel_registerName("setDecimalSeparator:");
+    public static /*const*/ string sel_conversationIdentifier = sel_registerName("conversationIdentifier");
+    public static /*const*/ string sel_setPrompt_1 = sel_registerName("setPrompt:");
+    public static /*const*/ string sel_setShowsFirstResponder_1 = sel_registerName("setShowsFirstResponder:");
+    public static /*const*/ string sel_setRootObject_1 = sel_registerName("setRootObject:");
+    public static /*const*/ string sel_menuBarVisible = sel_registerName("menuBarVisible");
+    public static /*const*/ string sel_netServiceBrowser_1didRemoveDomain_1moreComing_1 = sel_registerName("netServiceBrowser:didRemoveDomain:moreComing:");
+    public static /*const*/ string sel_threadPriority = sel_registerName("threadPriority");
+    public static /*const*/ string sel_countKeyPath = sel_registerName("countKeyPath");
+    public static /*const*/ string sel_runCustomizationPalette_1 = sel_registerName("runCustomizationPalette:");
+    public static /*const*/ string sel_fileHandleWithStandardError = sel_registerName("fileHandleWithStandardError");
+    public static /*const*/ string sel_documentContentKind = sel_registerName("documentContentKind");
+    public static /*const*/ string sel_view_1StringForToolTip_1point_1userData_1 = sel_registerName("view:StringForToolTip:point:userData:");
+    public static /*const*/ string sel_nameFieldLabel = sel_registerName("nameFieldLabel");
+    public static /*const*/ string sel_miniaturizeAll_1 = sel_registerName("miniaturizeAll:");
+    public static /*const*/ string sel_initWithRepresentedObject_1 = sel_registerName("initWithRepresentedObject:");
+    public static /*const*/ string sel_runOperation = sel_registerName("runOperation");
+    public static /*const*/ string sel_drawBackgroundForBlock_1withFrame_1inView_1characterRange_1layoutManager_1 = sel_registerName("drawBackgroundForBlock:withFrame:inView:characterRange:layoutManager:");
+    public static /*const*/ string sel_localizedInfoDictionary = sel_registerName("localizedInfoDictionary");
+    public static /*const*/ string sel_scanFloat_1 = sel_registerName("scanFloat:");
+    public static /*const*/ string sel_scanHexDouble_1 = sel_registerName("scanHexDouble:");
+    public static /*const*/ string sel_continueSpeaking = sel_registerName("continueSpeaking");
+    public static /*const*/ string sel_attachedMenuView = sel_registerName("attachedMenuView");
+    public static /*const*/ string sel_wantsToHandleMouseEvents = sel_registerName("wantsToHandleMouseEvents");
+    public static /*const*/ string sel_attemptRecoveryFromError_1optionIndex_1 = sel_registerName("attemptRecoveryFromError:optionIndex:");
+    public static /*const*/ string sel_window_1shouldDragDocumentWithEvent_1from_1withPasteboard_1 = sel_registerName("window:shouldDragDocumentWithEvent:from:withPasteboard:");
+    public static /*const*/ string sel_mouseEntered_1 = sel_registerName("mouseEntered:");
+    public static /*const*/ string sel_setNameFieldLabel_1 = sel_registerName("setNameFieldLabel:");
+    public static /*const*/ string sel_setIndentationPerLevel_1 = sel_registerName("setIndentationPerLevel:");
+    public static /*const*/ string sel_setMinColumnWidth_1 = sel_registerName("setMinColumnWidth:");
+    public static /*const*/ string sel_classNameForClass_1 = sel_registerName("classNameForClass:");
+    public static /*const*/ string sel_runLoopModes = sel_registerName("runLoopModes");
+    public static /*const*/ string sel_pullsDown = sel_registerName("pullsDown");
+    public static /*const*/ string sel_setOutlineTableColumn_1 = sel_registerName("setOutlineTableColumn:");
+    public static /*const*/ string sel_windowDidLoad = sel_registerName("windowDidLoad");
+    public static /*const*/ string sel_read_1maxLength_1 = sel_registerName("read:maxLength:");
+    public static /*const*/ string sel_removeItemAtIndex_1 = sel_registerName("removeItemAtIndex:");
+    public static /*const*/ string sel_initWithColor_1 = sel_registerName("initWithColor:");
+    public static /*const*/ string sel_compare_1options_1 = sel_registerName("compare:options:");
+    public static /*const*/ string sel_removeTableColumn_1 = sel_registerName("removeTableColumn:");
+    public static /*const*/ string sel_isRedoing = sel_registerName("isRedoing");
+    public static /*const*/ string sel_setTitleWithRepresentedFilename_1 = sel_registerName("setTitleWithRepresentedFilename:");
+    public static /*const*/ string sel_setDirectory_1 = sel_registerName("setDirectory:");
+    public static /*const*/ string sel_makeDocumentWithContentsOfURL_1ofType_1error_1 = sel_registerName("makeDocumentWithContentsOfURL:ofType:error:");
+    public static /*const*/ string sel_isSelectedForSegment_1 = sel_registerName("isSelectedForSegment:");
+    public static /*const*/ string sel_month = sel_registerName("month");
+    public static /*const*/ string sel_addRow = sel_registerName("addRow");
+    public static /*const*/ string sel_layoutOptions = sel_registerName("layoutOptions");
+    public static /*const*/ string sel_maxNumberOfRows = sel_registerName("maxNumberOfRows");
+    public static /*const*/ string sel_setUpPrintOperationDefaultValues = sel_registerName("setUpPrintOperationDefaultValues");
+    public static /*const*/ string sel_initByReferencingURL_1 = sel_registerName("initByReferencingURL:");
+    public static /*const*/ string sel_class = sel_registerName("class");
+    public static /*const*/ string sel_setFrameAutosaveName_1 = sel_registerName("setFrameAutosaveName:");
+    public static /*const*/ string sel_fileWrapperFromRange_1documentAttributes_1error_1 = sel_registerName("fileWrapperFromRange:documentAttributes:error:");
+    public static /*const*/ string sel_int32Value = sel_registerName("int32Value");
+    public static /*const*/ string sel_setControlView_1 = sel_registerName("setControlView:");
+    public static /*const*/ string sel_setCharacterEncoding_1 = sel_registerName("setCharacterEncoding:");
+    public static /*const*/ string sel_disableFlushWindow = sel_registerName("disableFlushWindow");
+    public static /*const*/ string sel_insertString_1atIndex_1 = sel_registerName("insertString:atIndex:");
+    public static /*const*/ string sel_childNodes = sel_registerName("childNodes");
+    public static /*const*/ string sel_rangeContainerObject = sel_registerName("rangeContainerObject");
+    public static /*const*/ string sel_kind = sel_registerName("kind");
+    public static /*const*/ string sel_title = sel_registerName("title");
+    public static /*const*/ string sel_bundleWithIdentifier_1 = sel_registerName("bundleWithIdentifier:");
+    public static /*const*/ string sel_initWithMovie_1 = sel_registerName("initWithMovie:");
+    public static /*const*/ string sel_unionHashTable_1 = sel_registerName("unionHashTable:");
+    public static /*const*/ string sel_setStartSpecifier_1 = sel_registerName("setStartSpecifier:");
+    public static /*const*/ string sel_browser_1nextTypeSelectMatchFromRow_1toRow_1inColumn_1forString_1 = sel_registerName("browser:nextTypeSelectMatchFromRow:toRow:inColumn:forString:");
+    public static /*const*/ string sel_tokenFieldCell_1representedObjectForEditingString_1 = sel_registerName("tokenFieldCell:representedObjectForEditingString:");
+    public static /*const*/ string sel_initWithContentsOfFile_1 = sel_registerName("initWithContentsOfFile:");
+    public static /*const*/ string sel_dataWithContentsOfURL_1 = sel_registerName("dataWithContentsOfURL:");
+    public static /*const*/ string sel_firstWeekday = sel_registerName("firstWeekday");
+    public static /*const*/ string sel_setInitialValues_1 = sel_registerName("setInitialValues:");
+    public static /*const*/ string sel_setIntegerValue_1 = sel_registerName("setIntegerValue:");
+    public static /*const*/ string sel_calcSize = sel_registerName("calcSize");
+    public static /*const*/ string sel_setTokenizingCharacterSet_1 = sel_registerName("setTokenizingCharacterSet:");
+    public static /*const*/ string sel_setRepresentedFilename_1 = sel_registerName("setRepresentedFilename:");
+    public static /*const*/ string sel_colorSpaceName = sel_registerName("colorSpaceName");
+    public static /*const*/ string sel_setLineBreakMode_1 = sel_registerName("setLineBreakMode:");
+    public static /*const*/ string sel_appliesImmediately = sel_registerName("appliesImmediately");
+    public static /*const*/ string sel_classDescriptionWithAppleEventCode_1 = sel_registerName("classDescriptionWithAppleEventCode:");
+    public static /*const*/ string sel_eventRef = sel_registerName("eventRef");
+    public static /*const*/ string sel_textAttributesForZero = sel_registerName("textAttributesForZero");
+    public static /*const*/ string sel_setAutosavesConfiguration_1 = sel_registerName("setAutosavesConfiguration:");
+    public static /*const*/ string sel_countOfIndexesInRange_1 = sel_registerName("countOfIndexesInRange:");
+    public static /*const*/ string sel_count = sel_registerName("count");
+    public static /*const*/ string sel_initWithSuiteName_1className_1dictionary_1 = sel_registerName("initWithSuiteName:className:dictionary:");
+    public static /*const*/ string sel_isReleasedWhenClosed = sel_registerName("isReleasedWhenClosed");
+    public static /*const*/ string sel_windowWithWindowNumber_1 = sel_registerName("windowWithWindowNumber:");
+    public static /*const*/ string sel_removeNamespaceForPrefix_1 = sel_registerName("removeNamespaceForPrefix:");
+    public static /*const*/ string sel_documentWithRootElement_1 = sel_registerName("documentWithRootElement:");
+    public static /*const*/ string sel_pageFooter = sel_registerName("pageFooter");
+    public static /*const*/ string sel_initWithOptions_1capacity_1 = sel_registerName("initWithOptions:capacity:");
+    public static /*const*/ string sel_insertBacktab_1 = sel_registerName("insertBacktab:");
+    public static /*const*/ string sel_changeWindowsItem_1title_1filename_1 = sel_registerName("changeWindowsItem:title:filename:");
+    public static /*const*/ string sel_changeCount = sel_registerName("changeCount");
+    public static /*const*/ string sel_paragraphCharacterRange = sel_registerName("paragraphCharacterRange");
+    public static /*const*/ string sel_currentProgress = sel_registerName("currentProgress");
+    public static /*const*/ string sel_parser_1didStartMappingPrefix_1toURI_1 = sel_registerName("parser:didStartMappingPrefix:toURI:");
+    public static /*const*/ string sel_setFormatWidth_1 = sel_registerName("setFormatWidth:");
+    public static /*const*/ string sel_cancelAllOperations = sel_registerName("cancelAllOperations");
+    public static /*const*/ string sel_beginLoadInBackground = sel_registerName("beginLoadInBackground");
+    public static /*const*/ string sel_draggedDistance = sel_registerName("draggedDistance");
+    public static /*const*/ string sel_setIndex_1 = sel_registerName("setIndex:");
+    public static /*const*/ string sel_initWithScheme_1host_1path_1 = sel_registerName("initWithScheme:host:path:");
+    public static /*const*/ string sel_toolTipForCell_1 = sel_registerName("toolTipForCell:");
+    public static /*const*/ string sel_predicateForRow_1 = sel_registerName("predicateForRow:");
+    public static /*const*/ string sel_predefinedEntityDeclarationForName_1 = sel_registerName("predefinedEntityDeclarationForName:");
+    public static /*const*/ string sel_replacePointerAtIndex_1withPointer_1 = sel_registerName("replacePointerAtIndex:withPointer:");
+    public static /*const*/ string sel_fileURLWithPath_1 = sel_registerName("fileURLWithPath:");
+    public static /*const*/ string sel_currentDocument = sel_registerName("currentDocument");
+    public static /*const*/ string sel_shouldDrawInsertionPoint = sel_registerName("shouldDrawInsertionPoint");
+    public static /*const*/ string sel_saveAllDocuments_1 = sel_registerName("saveAllDocuments:");
+    public static /*const*/ string sel_windowControllerWillLoadNib_1 = sel_registerName("windowControllerWillLoadNib:");
+    public static /*const*/ string sel_closeAllDocumentsWithDelegate_1didCloseAllSelector_1contextInfo_1 = sel_registerName("closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:");
+    public static /*const*/ string sel_tableView_1heightOfRow_1 = sel_registerName("tableView:heightOfRow:");
+    public static /*const*/ string sel_postNotificationName_1object_1userInfo_1options_1 = sel_registerName("postNotificationName:object:userInfo:options:");
+    public static /*const*/ string sel_imageTypes = sel_registerName("imageTypes");
+    public static /*const*/ string sel_setPreferredBackingLocation_1 = sel_registerName("setPreferredBackingLocation:");
+    public static /*const*/ string sel_netServiceDidPublish_1 = sel_registerName("netServiceDidPublish:");
+    public static /*const*/ string sel_diskCapacity = sel_registerName("diskCapacity");
+    public static /*const*/ string sel_initWithString_1calendarFormat_1locale_1 = sel_registerName("initWithString:calendarFormat:locale:");
+    public static /*const*/ string sel_preferredEdge = sel_registerName("preferredEdge");
+    public static /*const*/ string sel_comboBoxCell_1indexOfItemWithStringValue_1 = sel_registerName("comboBoxCell:indexOfItemWithStringValue:");
+    public static /*const*/ string sel_replaceCharactersInRange_1withString_1 = sel_registerName("replaceCharactersInRange:withString:");
+    public static /*const*/ string sel_initWithTimeIntervalSinceReferenceDate_1 = sel_registerName("initWithTimeIntervalSinceReferenceDate:");
+    public static /*const*/ string sel_secondsFromGMT = sel_registerName("secondsFromGMT");
+    public static /*const*/ string sel_hasOrderedToManyRelationshipForKey_1 = sel_registerName("hasOrderedToManyRelationshipForKey:");
+    public static /*const*/ string sel_resignFirstResponder = sel_registerName("resignFirstResponder");
+    public static /*const*/ string sel_netServiceDidStop_1 = sel_registerName("netServiceDidStop:");
+    public static /*const*/ string sel_absoluteY = sel_registerName("absoluteY");
+    public static /*const*/ string sel_beginModalSessionForWindow_1 = sel_registerName("beginModalSessionForWindow:");
+    public static /*const*/ string sel_alignment = sel_registerName("alignment");
+    public static /*const*/ string sel_setCharactersToBeSkipped_1 = sel_registerName("setCharactersToBeSkipped:");
+    public static /*const*/ string sel_requestWithURL_1cachePolicy_1timeoutInterval_1 = sel_registerName("requestWithURL:cachePolicy:timeoutInterval:");
+    public static /*const*/ string sel_ruler = sel_registerName("ruler");
+    public static /*const*/ string sel_isSetOnMouseExited = sel_registerName("isSetOnMouseExited");
+    public static /*const*/ string sel_setRemovable_1 = sel_registerName("setRemovable:");
+    public static /*const*/ string sel_draggingSource = sel_registerName("draggingSource");
+    public static /*const*/ string sel_textView_1clickedOnLink_1 = sel_registerName("textView:clickedOnLink:");
+    public static /*const*/ string sel_canBeVisibleOnAllSpaces = sel_registerName("canBeVisibleOnAllSpaces");
+    public static /*const*/ string sel_setBadgeLabel_1 = sel_registerName("setBadgeLabel:");
+    public static /*const*/ string sel_parser_1foundUnparsedEntityDeclarationWithName_1publicID_1systemID_1notationName_1 = sel_registerName("parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:");
+    public static /*const*/ string sel_operations = sel_registerName("operations");
+    public static /*const*/ string sel_setInteger_1forKey_1 = sel_registerName("setInteger:forKey:");
+    public static /*const*/ string sel_otherMouseUp_1 = sel_registerName("otherMouseUp:");
+    public static /*const*/ string sel_drawImageWithFrame_1inView_1 = sel_registerName("drawImageWithFrame:inView:");
+    public static /*const*/ string sel_getPixel_1atX_1y_1 = sel_registerName("getPixel:atX:y:");
+    public static /*const*/ string sel_standardError = sel_registerName("standardError");
+    public static /*const*/ string sel_setLabel_1 = sel_registerName("setLabel:");
+    public static /*const*/ string sel_initWithUnsignedInt_1 = sel_registerName("initWithUnsignedInt:");
+    public static /*const*/ string sel_isFinished = sel_registerName("isFinished");
+    public static /*const*/ string sel_drawSwatchInRect_1 = sel_registerName("drawSwatchInRect:");
+    public static /*const*/ string sel_descriptorAtIndex_1 = sel_registerName("descriptorAtIndex:");
+    public static /*const*/ string sel_cachedHandleForURL_1 = sel_registerName("cachedHandleForURL:");
+    public static /*const*/ string sel_classCode = sel_registerName("classCode");
+    public static /*const*/ string sel_resolvesAliases = sel_registerName("resolvesAliases");
+    public static /*const*/ string sel_textTypes = sel_registerName("textTypes");
+    public static /*const*/ string sel_invalidateTextContainerOrigin = sel_registerName("invalidateTextContainerOrigin");
+    public static /*const*/ string sel_document = sel_registerName("document");
+    public static /*const*/ string sel_interiorBackgroundStyleForSegment_1 = sel_registerName("interiorBackgroundStyleForSegment:");
+    public static /*const*/ string sel_transformedValue_1 = sel_registerName("transformedValue:");
+    public static /*const*/ string sel_substringToIndex_1 = sel_registerName("substringToIndex:");
+    public static /*const*/ string sel_addDocument_1 = sel_registerName("addDocument:");
+    public static /*const*/ string sel_numberWithInteger_1 = sel_registerName("numberWithInteger:");
+    public static /*const*/ string sel_setBoundsRotation_1 = sel_registerName("setBoundsRotation:");
+    public static /*const*/ string sel_convertFont_1toFace_1 = sel_registerName("convertFont:toFace:");
+    public static /*const*/ string sel_updateInsertionPointStateAndRestartTimer_1 = sel_registerName("updateInsertionPointStateAndRestartTimer:");
+    public static /*const*/ string sel_tryToPerform_1with_1 = sel_registerName("tryToPerform:with:");
+    public static /*const*/ string sel_defaultLineHeightForFont = sel_registerName("defaultLineHeightForFont");
+    public static /*const*/ string sel_scriptingIsEqualTo_1 = sel_registerName("scriptingIsEqualTo:");
+    public static /*const*/ string sel_setDoubleValue_1 = sel_registerName("setDoubleValue:");
+    public static /*const*/ string sel_AMSymbol = sel_registerName("AMSymbol");
+    public static /*const*/ string sel_valueWraps = sel_registerName("valueWraps");
+    public static /*const*/ string sel_allCredentials = sel_registerName("allCredentials");
+    public static /*const*/ string sel_editingDelegate = sel_registerName("editingDelegate");
+    public static /*const*/ string sel_maintainsInactiveSelection = sel_registerName("maintainsInactiveSelection");
+    public static /*const*/ string sel_policyDelegate = sel_registerName("policyDelegate");
+    public static /*const*/ string sel_preferences = sel_registerName("preferences");
+    public static /*const*/ string sel_registerViewClass_1representationClass_1forMIMEType_1 = sel_registerName("registerViewClass:representationClass:forMIMEType:");
+    public static /*const*/ string sel_setHostWindow_1 = sel_registerName("setHostWindow:");
+    public static /*const*/ string sel_hostWindow = sel_registerName("hostWindow");
+    public static /*const*/ string sel_searchFor_1direction_1caseSensitive_1wrap_1 = sel_registerName("searchFor:direction:caseSensitive:wrap:");
+    public static /*const*/ string sel_initWithFrame_1frameName_1groupName_1 = sel_registerName("initWithFrame:frameName:groupName:");
+    public static /*const*/ string sel_canGoBack = sel_registerName("canGoBack");
+    public static /*const*/ string sel_setFrameLoadDelegate_1 = sel_registerName("setFrameLoadDelegate:");
+    public static /*const*/ string sel_takeStringURLFrom_1 = sel_registerName("takeStringURLFrom:");
+    public static /*const*/ string sel_registerURLSchemeAsLocal_1 = sel_registerName("registerURLSchemeAsLocal:");
+    public static /*const*/ string sel_StringByEvaluatingJavaScriptFromString_1 = sel_registerName("StringByEvaluatingJavaScriptFromString:");
+    public static /*const*/ string sel_replaceSelectionWithMarkupString_1 = sel_registerName("replaceSelectionWithMarkupString:");
+    public static /*const*/ string sel_setPreferences_1 = sel_registerName("setPreferences:");
+    public static /*const*/ string sel_customUserAgent = sel_registerName("customUserAgent");
+    public static /*const*/ string sel_mainFrame = sel_registerName("mainFrame");
+    public static /*const*/ string sel_goToBackForwardItem_1 = sel_registerName("goToBackForwardItem:");
+    public static /*const*/ string sel_pasteboardTypesForElement_1 = sel_registerName("pasteboardTypesForElement:");
+    public static /*const*/ string sel_applyStyle_1 = sel_registerName("applyStyle:");
+    public static /*const*/ string sel_setResourceLoadDelegate_1 = sel_registerName("setResourceLoadDelegate:");
+    public static /*const*/ string sel_moveToBeginningOfSentenceAndModifySelection_1 = sel_registerName("moveToBeginningOfSentenceAndModifySelection:");
+    public static /*const*/ string sel_replaceSelectionWithArchive_1 = sel_registerName("replaceSelectionWithArchive:");
+    public static /*const*/ string sel_userAgentForURL_1 = sel_registerName("userAgentForURL:");
+    public static /*const*/ string sel_frameLoadDelegate = sel_registerName("frameLoadDelegate");
+    public static /*const*/ string sel_windowScriptObject = sel_registerName("windowScriptObject");
+    public static /*const*/ string sel_removeDragCaret = sel_registerName("removeDragCaret");
+    public static /*const*/ string sel_editableDOMRangeForPoint_1 = sel_registerName("editableDOMRangeForPoint:");
+    public static /*const*/ string sel_moveToEndOfSentence_1 = sel_registerName("moveToEndOfSentence:");
+    public static /*const*/ string sel_preferencesIdentifier = sel_registerName("preferencesIdentifier");
+    public static /*const*/ string sel_setPolicyDelegate_1 = sel_registerName("setPolicyDelegate:");
+    public static /*const*/ string sel_goBack = sel_registerName("goBack");
+    public static /*const*/ string sel_downloadDelegate = sel_registerName("downloadDelegate");
+    public static /*const*/ string sel_canShowMIMEType_1 = sel_registerName("canShowMIMEType:");
+    public static /*const*/ string sel_elementAtPoint_1 = sel_registerName("elementAtPoint:");
+    public static /*const*/ string sel_groupName = sel_registerName("groupName");
+    public static /*const*/ string sel_selectedFrame = sel_registerName("selectedFrame");
+    public static /*const*/ string sel_setMIMETypesShownAsHTML_1 = sel_registerName("setMIMETypesShownAsHTML:");
+    public static /*const*/ string sel_goForward = sel_registerName("goForward");
+    public static /*const*/ string sel_makeTextStandardSize_1 = sel_registerName("makeTextStandardSize:");
+    public static /*const*/ string sel_setMainFrameURL_1 = sel_registerName("setMainFrameURL:");
+    public static /*const*/ string sel_pasteboardTypesForSelection = sel_registerName("pasteboardTypesForSelection");
+    public static /*const*/ string sel_customTextEncodingName = sel_registerName("customTextEncodingName");
+    public static /*const*/ string sel_MIMETypesShownAsHTML = sel_registerName("MIMETypesShownAsHTML");
+    public static /*const*/ string sel_replaceSelectionWithText_1 = sel_registerName("replaceSelectionWithText:");
+    public static /*const*/ string sel_setTextSizeMultiplier_1 = sel_registerName("setTextSizeMultiplier:");
+    public static /*const*/ string sel_stopLoading_1 = sel_registerName("stopLoading:");
+    public static /*const*/ string sel_goBack_1 = sel_registerName("goBack:");
+    public static /*const*/ string sel_canMakeTextStandardSize = sel_registerName("canMakeTextStandardSize");
+    public static /*const*/ string sel_setCustomUserAgent_1 = sel_registerName("setCustomUserAgent:");
+    public static /*const*/ string sel_moveDragCaretToPoint_1 = sel_registerName("moveDragCaretToPoint:");
+    public static /*const*/ string sel_makeTextSmaller_1 = sel_registerName("makeTextSmaller:");
+    public static /*const*/ string sel_moveToBeginningOfSentence_1 = sel_registerName("moveToBeginningOfSentence:");
+    public static /*const*/ string sel_reload_1 = sel_registerName("reload:");
+    public static /*const*/ string sel_typingStyle = sel_registerName("typingStyle");
+    public static /*const*/ string sel_setShouldCloseWithWindow_1 = sel_registerName("setShouldCloseWithWindow:");
+    public static /*const*/ string sel_setMediaStyle_1 = sel_registerName("setMediaStyle:");
+    public static /*const*/ string sel_canMakeTextLarger = sel_registerName("canMakeTextLarger");
+    public static /*const*/ string sel_textSizeMultiplier = sel_registerName("textSizeMultiplier");
+    public static /*const*/ string sel_shouldCloseWithWindow = sel_registerName("shouldCloseWithWindow");
+    public static /*const*/ string sel_setPreferencesIdentifier_1 = sel_registerName("setPreferencesIdentifier:");
+    public static /*const*/ string sel_setApplicationNameForUserAgent_1 = sel_registerName("setApplicationNameForUserAgent:");
+    public static /*const*/ string sel_mainFrameURL = sel_registerName("mainFrameURL");
+    public static /*const*/ string sel_goForward_1 = sel_registerName("goForward:");
+    public static /*const*/ string sel_selectedDOMRange = sel_registerName("selectedDOMRange");
+    public static /*const*/ string sel_setDownloadDelegate_1 = sel_registerName("setDownloadDelegate:");
+    public static /*const*/ string sel_setEditingDelegate_1 = sel_registerName("setEditingDelegate:");
+    public static /*const*/ string sel_setUIDelegate_1 = sel_registerName("setUIDelegate:");
+    public static /*const*/ string sel_mainFrameTitle = sel_registerName("mainFrameTitle");
+    public static /*const*/ string sel_setSelectedDOMRange_1affinity_1 = sel_registerName("setSelectedDOMRange:affinity:");
+    public static /*const*/ string sel_setTypingStyle_1 = sel_registerName("setTypingStyle:");
+    public static /*const*/ string sel_backForwardList = sel_registerName("backForwardList");
+    public static /*const*/ string sel_deleteSelection = sel_registerName("deleteSelection");
+    public static /*const*/ string sel_canGoForward = sel_registerName("canGoForward");
+    public static /*const*/ string sel_styleDeclarationWithText_1 = sel_registerName("styleDeclarationWithText:");
+    public static /*const*/ string sel_moveToEndOfSentenceAndModifySelection_1 = sel_registerName("moveToEndOfSentenceAndModifySelection:");
+    public static /*const*/ string sel_replaceSelectionWithNode_1 = sel_registerName("replaceSelectionWithNode:");
+    public static /*const*/ string sel_URLTitleFromPasteboard_1 = sel_registerName("URLTitleFromPasteboard:");
+    public static /*const*/ string sel_UIDelegate = sel_registerName("UIDelegate");
+    public static /*const*/ string sel_setMaintainsBackForwardList_1 = sel_registerName("setMaintainsBackForwardList:");
+    public static /*const*/ string sel_mainFrameIcon = sel_registerName("mainFrameIcon");
+    public static /*const*/ string sel_setGroupName_1 = sel_registerName("setGroupName:");
+    public static /*const*/ string sel_canMakeTextSmaller = sel_registerName("canMakeTextSmaller");
+    public static /*const*/ string sel_applicationNameForUserAgent = sel_registerName("applicationNameForUserAgent");
+    public static /*const*/ string sel_supportsTextEncoding = sel_registerName("supportsTextEncoding");
+    public static /*const*/ string sel_canShowMIMETypeAsHTML_1 = sel_registerName("canShowMIMETypeAsHTML:");
+    public static /*const*/ string sel_mediaStyle = sel_registerName("mediaStyle");
+    public static /*const*/ string sel_makeTextLarger_1 = sel_registerName("makeTextLarger:");
+    public static /*const*/ string sel_writeElement_1withPasteboardTypes_1toPasteboard_1 = sel_registerName("writeElement:withPasteboardTypes:toPasteboard:");
+    public static /*const*/ string sel_estimatedProgress = sel_registerName("estimatedProgress");
+    public static /*const*/ string sel_setCustomTextEncodingName_1 = sel_registerName("setCustomTextEncodingName:");
+    public static /*const*/ string sel_mainFrameDocument = sel_registerName("mainFrameDocument");
+    public static /*const*/ string sel_isLoading = sel_registerName("isLoading");
+    public static /*const*/ string sel_selectSentence_1 = sel_registerName("selectSentence:");
+    public static /*const*/ string sel_computedStyleForElement_1pseudoElement_1 = sel_registerName("computedStyleForElement:pseudoElement:");
+    public static /*const*/ string sel_writeSelectionWithPasteboardTypes_1toPasteboard_1 = sel_registerName("writeSelectionWithPasteboardTypes:toPasteboard:");
+    public static /*const*/ string sel_resourceLoadDelegate = sel_registerName("resourceLoadDelegate");
+    public static /*const*/ string sel_reload = sel_registerName("reload");
+    public static /*const*/ string sel_loadAlternateHTMLString_1baseURL_1forUnreachableURL_1 = sel_registerName("loadAlternateHTMLString:baseURL:forUnreachableURL:");
+    public static /*const*/ string sel_loadHTMLString_1baseURL_1 = sel_registerName("loadHTMLString:baseURL:");
+    public static /*const*/ string sel_loadArchive_1 = sel_registerName("loadArchive:");
+    public static /*const*/ string sel_webView = sel_registerName("webView");
+    public static /*const*/ string sel_provisionalDataSource = sel_registerName("provisionalDataSource");
+    public static /*const*/ string sel_findFrameNamed_1 = sel_registerName("findFrameNamed:");
+    public static /*const*/ string sel_DOMDocument = sel_registerName("DOMDocument");
+    public static /*const*/ string sel_frameView = sel_registerName("frameView");
+    public static /*const*/ string sel_globalContext = sel_registerName("globalContext");
+    public static /*const*/ string sel_windowObject = sel_registerName("windowObject");
+    public static /*const*/ string sel_childFrames = sel_registerName("childFrames");
+    public static /*const*/ string sel_loadData_1MIMEType_1textEncodingName_1baseURL_1 = sel_registerName("loadData:MIMEType:textEncodingName:baseURL:");
+    public static /*const*/ string sel_initWithName_1webFrameView_1webView_1 = sel_registerName("initWithName:webFrameView:webView:");
+    public static /*const*/ string sel_frameElement = sel_registerName("frameElement");
+    public static /*const*/ string sel_loadRequest_1 = sel_registerName("loadRequest:");
+    public static /*const*/ string sel_parentFrame = sel_registerName("parentFrame");
+    public static /*const*/ string sel_representation = sel_registerName("representation");
+    public static /*const*/ string sel_documentSource = sel_registerName("documentSource");
+    public static /*const*/ string sel_webView_1didChangeLocationWithinPageForFrame_1 = sel_registerName("webView:didChangeLocationWithinPageForFrame:");
+    public static /*const*/ string sel_webView_1didFailProvisionalLoadWithError_1forFrame_1 = sel_registerName("webView:didFailProvisionalLoadWithError:forFrame:");
+    public static /*const*/ string sel_webView_1didFinishLoadForFrame_1 = sel_registerName("webView:didFinishLoadForFrame:");
+    public static /*const*/ string sel_webView_1didReceiveTitle_1forFrame_1 = sel_registerName("webView:didReceiveTitle:forFrame:");
+    public static /*const*/ string sel_webView_1didStartProvisionalLoadForFrame_1 = sel_registerName("webView:didStartProvisionalLoadForFrame:");
+    public static /*const*/ string sel_webView_1didCommitLoadForFrame_1 = sel_registerName("webView:didCommitLoadForFrame:");
+    public static /*const*/ string sel_webView_1resource_1didFinishLoadingFromDataSource_1 = sel_registerName("webView:resource:didFinishLoadingFromDataSource:");
+    public static /*const*/ string sel_webView_1resource_1didFailLoadingWithError_1fromDataSource_1 = sel_registerName("webView:resource:didFailLoadingWithError:fromDataSource:");
+    public static /*const*/ string sel_webView_1identifierForInitialRequest_1fromDataSource_1 = sel_registerName("webView:identifierForInitialRequest:fromDataSource:");
+    public static /*const*/ string sel_webView_1resource_1willSendRequest_1redirectResponse_1fromDataSource_1 = sel_registerName("webView:resource:willSendRequest:redirectResponse:fromDataSource:");
+    public static /*const*/ string sel_webView_1createWebViewWithRequest_1 = sel_registerName("webView:createWebViewWithRequest:");
+    public static /*const*/ string sel_webViewShow_1 = sel_registerName("webViewShow:");
+    public static /*const*/ string sel_webView_1setFrame_1 = sel_registerName("webView:setFrame:");
+    public static /*const*/ string sel_webViewClose_1 = sel_registerName("webViewClose:");
+    public static /*const*/ string sel_webView_1contextMenuItemsForElement_1defaultMenuItems_1 = sel_registerName("webView:contextMenuItemsForElement:defaultMenuItems:");
+    public static /*const*/ string sel_webView_1setStatusBarVisible_1 = sel_registerName("webView:setStatusBarVisible:");
+    public static /*const*/ string sel_webView_1setResizable_1 = sel_registerName("webView:setResizable:");
+    public static /*const*/ string sel_webView_1setToolbarsVisible_1 = sel_registerName("webView:setToolbarsVisible:");
+    public static /*const*/ string sel_webView_1setStatusText_1 = sel_registerName("webView:setStatusText:");
+    public static /*const*/ string sel_webViewFocus_1 = sel_registerName("webViewFocus:");
+    public static /*const*/ string sel_webViewUnfocus_1 = sel_registerName("webViewUnfocus:");
+    public static /*const*/ string sel_webView_1runJavaScriptAlertPanelWithMessage_1 = sel_registerName("webView:runJavaScriptAlertPanelWithMessage:");
+    public static /*const*/ string sel_webView_1runJavaScriptConfirmPanelWithMessage_1 = sel_registerName("webView:runJavaScriptConfirmPanelWithMessage:");
+    public static /*const*/ string sel_webView_1runOpenPanelForFileButtonWithResultListener_1 = sel_registerName("webView:runOpenPanelForFileButtonWithResultListener:");
+    public static /*const*/ string sel_webView_1mouseDidMoveOverElement_1modifierFlags_1 = sel_registerName("webView:mouseDidMoveOverElement:modifierFlags:");
+    public static /*const*/ string sel_webView_1printFrameView_1 = sel_registerName("webView:printFrameView:");
+    public static /*const*/ string sel_webView_1decidePolicyForMIMEType_1request_1frame_1decisionListener_1 = sel_registerName("webView:decidePolicyForMIMEType:request:frame:decisionListener:");
+    public static /*const*/ string sel_webView_1decidePolicyForNewWindowAction_1request_1newFrameName_1decisionListener_1 = sel_registerName("webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:");
+    public static /*const*/ string sel_webView_1unableToImplementPolicyWithError_1frame_1 = sel_registerName("webView:unableToImplementPolicyWithError:frame:");
+    public static /*const*/ string sel_webView_1decidePolicyForNavigationAction_1request_1frame_1decisionListener_1 = sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener::");
+    public static /*const*/ string sel_standardPreferences = sel_registerName("standardPreferences");
+    public static /*const*/ string sel_setJavaEnabled_1 = sel_registerName("setJavaEnabled:");
+    public static /*const*/ string sel_use = sel_registerName("use");
+    public static /*const*/ string sel_download = sel_registerName("download");
+    public static /*const*/ string sel_ignore = sel_registerName("ignore");
+    public static /*const*/ string sel_pageTitle = sel_registerName("pageTitle");
+    public static /*const*/ string sel_webFrame = sel_registerName("webFrame");
+    public static /*const*/ string sel_chooseFilename_1 = sel_registerName("chooseFilename:");
+    public static /*const*/ string sel_addEventListener_1listener_1useCapture_1 = sel_registerName("addEventListener:listener:useCapture:");
+    public static /*const*/ string sel_handleEvent_1 = sel_registerName("handleEvent:");
+    public static /*const*/ string sel_cancelable = sel_registerName("cancelable");
+    public static /*const*/ string sel_timeStamp = sel_registerName("timeStamp");
+    public static /*const*/ string sel_initEvent_1_1_1 = sel_registerName("initEvent:::");
+    public static /*const*/ string sel_bubbles = sel_registerName("bubbles");
+    public static /*const*/ string sel_stopPropagation = sel_registerName("stopPropagation");
+    public static /*const*/ string sel_initEvent_1canBubbleArg_1cancelableArg_1 = sel_registerName("initEvent:canBubbleArg:cancelableArg:");
+    public static /*const*/ string sel_eventPhase = sel_registerName("eventPhase");
+    public static /*const*/ string sel_currentTarget = sel_registerName("currentTarget");
+    public static /*const*/ string sel_preventDefault = sel_registerName("preventDefault");
+    public static /*const*/ string sel_screenX = sel_registerName("screenX");
+    public static /*const*/ string sel_initMouseEvent_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1 = sel_registerName("initMouseEvent:::::::::::::::");
+    public static /*const*/ string sel_clientY = sel_registerName("clientY");
+    public static /*const*/ string sel_charCode = sel_registerName("charCode");
+    public static /*const*/ string sel_relatedTarget = sel_registerName("relatedTarget");
+    public static /*const*/ string sel_button = sel_registerName("button");
+    public static /*const*/ string sel_clientX = sel_registerName("clientX");
+    public static /*const*/ string sel_initMouseEvent_1canBubble_1cancelable_1view_1detail_1screenX_1screenY_1clientX_1clientY_1ctrlKey_1altKey_1shiftKey_1metaKey_1button_1relatedTarget_1 = sel_registerName("initMouseEvent:canBubble:cancelable:view:detail:screenX:screenY:clientX:clientY:ctrlKey:altKey:shiftKey:metaKey:button:relatedTarget:");
+    public static /*const*/ string sel_shiftKey = sel_registerName("shiftKey");
+    public static /*const*/ string sel_ctrlKey = sel_registerName("ctrlKey");
+    public static /*const*/ string sel_metaKey = sel_registerName("metaKey");
+    public static /*const*/ string sel_altKey = sel_registerName("altKey");
+    public static /*const*/ string sel_keyLocation = sel_registerName("keyLocation");
+    public static /*const*/ string sel_getModifierState_1 = sel_registerName("getModifierState:");
+    public static /*const*/ string sel_screenY = sel_registerName("screenY");
+    public static /*const*/ string sel_detail = sel_registerName("detail");
+    public static /*const*/ string sel_handleNotification_1 = sel_registerName("handleNotification:");
+    public static /*const*/ string sel_setAllowsScrolling_1 = sel_registerName("setAllowsScrolling:");
+    public static /*const*/ string sel_allowsScrolling = sel_registerName("allowsScrolling");
+    public static /*const*/ string sel_printDocumentView = sel_registerName("printDocumentView");
+    public static /*const*/ string sel_documentViewShouldHandlePrint = sel_registerName("documentViewShouldHandlePrint");
+    public static /*const*/ string sel_printOperationWithPrintInfo_1 = sel_registerName("printOperationWithPrintInfo:");
+    public static /*const*/ string sel_canPrintHeadersAndFooters = sel_registerName("canPrintHeadersAndFooters");
+    public static /*const*/ string sel_wheelDelta = sel_registerName("wheelDelta");
+
+    /** Constants */
+    public static const int NSAWTEventType = 16;
+    public static const int NSAboveBottom = 4;
+    public static const int NSAboveTop = 1;
+    public static const int NSAddTraitFontAction = 2;
+    public static const int NSAdobeCNS1CharacterCollection = 1;
+    public static const int NSAdobeGB1CharacterCollection = 2;
+    public static const int NSAdobeJapan1CharacterCollection = 3;
+    public static const int NSAdobeJapan2CharacterCollection = 4;
+    public static const int NSAdobeKorea1CharacterCollection = 5;
+    public static const int NSAlertAlternateReturn = 0;
+    public static const int NSAlertDefaultReturn = 1;
+    public static const int NSAlertErrorReturn = -2;
+    public static const int NSAlertFirstButtonReturn = 1000;
+    public static const int NSAlertOtherReturn = -1;
+    public static const int NSAlertSecondButtonReturn = 1001;
+    public static const int NSAlertThirdButtonReturn = 1002;
+    public static const int NSAllScrollerParts = 2;
+    public static const int NSAlphaFirstBitmapFormat = 1;
+    public static const int NSAlphaNonpremultipliedBitmapFormat = 2;
+    public static const int NSAlphaShiftKeyMask = 65536;
+    public static const int NSAlternateKeyMask = 524288;
+    public static const int NSAnimationBlocking = 0;
+    public static const int NSAnimationEaseIn = 1;
+    public static const int NSAnimationEaseInOut = 0;
+    public static const int NSAnimationEaseOut = 2;
+    public static const int NSAnimationEffectDisappearingItemDefault = 0;
+    public static const int NSAnimationEffectPoof = 10;
+    public static const int NSAnimationLinear = 3;
+    public static const int NSAnimationNonblocking = 1;
+    public static const int NSAnimationNonblockingThreaded = 2;
+    public static const int NSAnyEventMask = -1;
+    public static const int NSAnyType = 0;
+    public static const int NSAppKitDefined = 13;
+    public static const int NSAppKitDefinedMask = 8192;
+    public static const int NSAppKitVersionNumber10_0 = 577;
+    public static const int NSAppKitVersionNumber10_1 = 620;
+    public static const int NSAppKitVersionNumber10_2 = 663;
+    public static const double NSAppKitVersionNumber10_2_3 = 663.60000000000002;
+    public static const int NSAppKitVersionNumber10_3 = 743;
+    public static const double NSAppKitVersionNumber10_3_2 = 743.13999999999999;
+    public static const double NSAppKitVersionNumber10_3_3 = 743.20000000000005;
+    public static const double NSAppKitVersionNumber10_3_5 = 743.24000000000001;
+    public static const double NSAppKitVersionNumber10_3_7 = 743.33000000000004;
+    public static const double NSAppKitVersionNumber10_3_9 = 743.36000000000001;
+    public static const int NSAppKitVersionNumber10_4 = 824;
+    public static const double NSAppKitVersionNumberWithColumnResizingBrowser = 685.00000000000000;
+    public static const double NSAppKitVersionNumberWithContinuousScrollingBrowser = 680.00000000000000;
+    public static const double NSAppKitVersionNumberWithCursorSizeSupport = 682.00000000000000;
+    public static const double NSAppKitVersionNumberWithCustomSheetPosition = 686.00000000000000;
+    public static const double NSAppKitVersionNumberWithDirectionalTabs = 631.00000000000000;
+    public static const double NSAppKitVersionNumberWithPatternColorLeakFix = 641.00000000000000;
+    public static const int NSApplicationActivatedEventType = 1;
+    public static const int NSApplicationDeactivatedEventType = 2;
+    public static const int NSApplicationDefined = 15;
+    public static const int NSApplicationDefinedMask = 32768;
+    public static const int NSApplicationDelegateReplyCancel = 1;
+    public static const int NSApplicationDelegateReplyFailure = 2;
+    public static const int NSApplicationDelegateReplySuccess = 0;
+    public static const int NSAscendingPageOrder = 1;
+    public static const int NSAtBottom = 5;
+    public static const int NSAtTop = 2;
+    public static const int NSAttachmentCharacter = 65532;
+    public static const int NSAutoPagination = 0;
+    public static const int NSAutosaveOperation = 3;
+    public static const int NSBMPFileType = 1;
+    public static const int NSBackTabCharacter = 25;
+    public static const int NSBackgroundStyleDark = 1;
+    public static const int NSBackgroundStyleLight = 0;
+    public static const int NSBackgroundStyleLowered = 3;
+    public static const int NSBackgroundStyleRaised = 2;
+    public static const int NSBackgroundTab = 1;
+    public static const int NSBackingStoreBuffered = 2;
+    public static const int NSBackingStoreNonretained = 1;
+    public static const int NSBackingStoreRetained = 0;
+    public static const int NSBackspaceCharacter = 8;
+    public static const int NSBacktabTextMovement = 18;
+    public static const int NSBeginFunctionKey = 63274;
+    public static const int NSBelowBottom = 6;
+    public static const int NSBelowTop = 3;
+    public static const int NSBevelLineJoinStyle = 2;
+    public static const int NSBezelBorder = 2;
+    public static const int NSBlueControlTint = 1;
+    public static const int NSBoldFontMask = 2;
+    public static const int NSBorderlessWindowMask = 0;
+    public static const int NSBottomTabsBezelBorder = 2;
+    public static const int NSBoxCustom = 4;
+    public static const int NSBoxOldStyle = 3;
+    public static const int NSBoxPrimary = 0;
+    public static const int NSBoxSecondary = 1;
+    public static const int NSBoxSeparator = 2;
+    public static const int NSBreakFunctionKey = 63282;
+    public static const int NSBrowserAutoColumnResizing = 1;
+    public static const int NSBrowserDropAbove = 1;
+    public static const int NSBrowserDropOn = 0;
+    public static const int NSBrowserNoColumnResizing = 0;
+    public static const int NSBrowserUserColumnResizing = 2;
+    public static const int NSButtLineCapStyle = 0;
+    public static const int NSCMYKColorSpaceModel = 2;
+    public static const int NSCMYKModeColorPanel = 2;
+    public static const int NSCancelButton = 0;
+    public static const int NSCancelTextMovement = 23;
+    public static const int NSCarriageReturnCharacter = 13;
+    public static const int NSCellAllowsMixedState = 16;
+    public static const int NSCellChangesContents = 14;
+    public static const int NSCellDisabled = 0;
+    public static const int NSCellEditable = 3;
+    public static const int NSCellHasImageHorizontal = 12;
+    public static const int NSCellHasImageOnLeftOrBottom = 13;
+    public static const int NSCellHasOverlappingImage = 11;
+    public static const int NSCellHighlighted = 5;
+    public static const int NSCellHitContentArea = 1;
+    public static const int NSCellHitEditableTextArea = 2;
+    public static const int NSCellHitNone = 0;
+    public static const int NSCellHitTrackableArea = 4;
+    public static const int NSCellIsBordered = 10;
+    public static const int NSCellIsInsetButton = 15;
+    public static const int NSCellLightsByBackground = 9;
+    public static const int NSCellLightsByContents = 6;
+    public static const int NSCellLightsByGray = 7;
+    public static const int NSCellState = 1;
+    public static const int NSCenterTabStopType = 2;
+    public static const int NSCenterTextAlignment = 2;
+    public static const int NSChangeAutosaved = 4;
+    public static const int NSChangeBackgroundCell = 8;
+    public static const int NSChangeBackgroundCellMask = 8;
+    public static const int NSChangeCleared = 2;
+    public static const int NSChangeDone = 0;
+    public static const int NSChangeGrayCell = 4;
+    public static const int NSChangeGrayCellMask = 4;
+    public static const int NSChangeReadOtherContents = 3;
+    public static const int NSChangeRedone = 5;
+    public static const int NSChangeUndone = 1;
+    public static const int NSCircularBezelStyle = 7;
+    public static const int NSCircularSlider = 1;
+    public static const int NSClearControlTint = 7;
+    public static const int NSClearDisplayFunctionKey = 63290;
+    public static const int NSClearLineFunctionKey = 63289;
+    public static const int NSClipPagination = 2;
+    public static const int NSClockAndCalendarDatePickerStyle = 1;
+    public static const int NSClosableWindowMask = 2;
+    public static const int NSClosePathBezierPathElement = 3;
+    public static const int NSColorListModeColorPanel = 5;
+    public static const int NSColorPanelAllModesMask = 65535;
+    public static const int NSColorPanelCMYKModeMask = 4;
+    public static const int NSColorPanelColorListModeMask = 32;
+    public static const int NSColorPanelCrayonModeMask = 128;
+    public static const int NSColorPanelCustomPaletteModeMask = 16;
+    public static const int NSColorPanelGrayModeMask = 1;
+    public static const int NSColorPanelHSBModeMask = 8;
+    public static const int NSColorPanelRGBModeMask = 2;
+    public static const int NSColorPanelWheelModeMask = 64;
+    public static const int NSColorRenderingIntentAbsoluteColorimetric = 1;
+    public static const int NSColorRenderingIntentDefault = 0;
+    public static const int NSColorRenderingIntentPerceptual = 3;
+    public static const int NSColorRenderingIntentRelativeColorimetric = 2;
+    public static const int NSColorRenderingIntentSaturation = 4;
+    public static const int NSCommandKeyMask = 1048576;
+    public static const int NSCompositeClear = 0;
+    public static const int NSCompositeCopy = 1;
+    public static const int NSCompositeDestinationAtop = 9;
+    public static const int NSCompositeDestinationIn = 7;
+    public static const int NSCompositeDestinationOut = 8;
+    public static const int NSCompositeDestinationOver = 6;
+    public static const int NSCompositeHighlight = 12;
+    public static const int NSCompositePlusDarker = 11;
+    public static const int NSCompositePlusLighter = 13;
+    public static const int NSCompositeSourceAtop = 5;
+    public static const int NSCompositeSourceIn = 3;
+    public static const int NSCompositeSourceOut = 4;
+    public static const int NSCompositeSourceOver = 2;
+    public static const int NSCompositeXOR = 10;
+    public static const int NSCompressedFontMask = 512;
+    public static const int NSCondensedFontMask = 64;
+    public static const int NSContentsCellMask = 1;
+    public static const int NSContinuousCapacityLevelIndicatorStyle = 1;
+    public static const int NSControlGlyph = 16777215;
+    public static const int NSControlKeyMask = 262144;
+    public static const int NSCrayonModeColorPanel = 7;
+    public static const int NSCriticalAlertStyle = 2;
+    public static const int NSCriticalRequest = 0;
+    public static const int NSCursorPointingDevice = 2;
+    public static const int NSCursorUpdate = 17;
+    public static const int NSCursorUpdateMask = 131072;
+    public static const int NSCurveToBezierPathElement = 2;
+    public static const int NSCustomPaletteModeColorPanel = 4;
+    public static const int NSDecimalTabStopType = 3;
+    public static const int NSDefaultControlTint = 0;
+    public static const int NSDefaultTokenStyle = 0;
+    public static const int NSDeleteCharFunctionKey = 63294;
+    public static const int NSDeleteCharacter = 127;
+    public static const int NSDeleteFunctionKey = 63272;
+    public static const int NSDeleteLineFunctionKey = 63292;
+    public static const int NSDescendingPageOrder = -1;
+    public static const int NSDeviceIndependentModifierFlagsMask = -65536;
+    public static const int NSDeviceNColorSpaceModel = 4;
+    public static const int NSDirectSelection = 0;
+    public static const int NSDisclosureBezelStyle = 5;
+    public static const int NSDiscreteCapacityLevelIndicatorStyle = 2;
+    public static const int NSDisplayWindowRunLoopOrdering = 600000;
+    public static const int NSDocModalWindowMask = 64;
+    public static const int NSDockWindowLevel = 20;
+    public static const int NSDoubleType = 6;
+    public static const int NSDownArrowFunctionKey = 63233;
+    public static const int NSDownTextMovement = 22;
+    public static const int NSDragOperationAll = 15;
+    public static const int NSDragOperationAll_Obsolete = 15;
+    public static const int NSDragOperationCopy = 1;
+    public static const int NSDragOperationDelete = 32;
+    public static const int NSDragOperationEvery = -1;
+    public static const int NSDragOperationGeneric = 4;
+    public static const int NSDragOperationLink = 2;
+    public static const int NSDragOperationMove = 16;
+    public static const int NSDragOperationNone = 0;
+    public static const int NSDragOperationPrivate = 8;
+    public static const int NSDrawerClosedState = 0;
+    public static const int NSDrawerClosingState = 3;
+    public static const int NSDrawerOpenState = 2;
+    public static const int NSDrawerOpeningState = 1;
+    public static const int NSEndFunctionKey = 63275;
+    public static const int NSEnterCharacter = 3;
+    public static const int NSEraDatePickerElementFlag = 256;
+    public static const int NSEraserPointingDevice = 3;
+    public static const int NSEvenOddWindingRule = 1;
+    public static const int NSExclude10_4ElementsIconCreationOption = 4;
+    public static const int NSExcludeQuickDrawElementsIconCreationOption = 2;
+    public static const int NSExecuteFunctionKey = 63298;
+    public static const int NSExpandedFontMask = 32;
+    public static const int NSF10FunctionKey = 63245;
+    public static const int NSF11FunctionKey = 63246;
+    public static const int NSF12FunctionKey = 63247;
+    public static const int NSF13FunctionKey = 63248;
+    public static const int NSF14FunctionKey = 63249;
+    public static const int NSF15FunctionKey = 63250;
+    public static const int NSF16FunctionKey = 63251;
+    public static const int NSF17FunctionKey = 63252;
+    public static const int NSF18FunctionKey = 63253;
+    public static const int NSF19FunctionKey = 63254;
+    public static const int NSF1FunctionKey = 63236;
+    public static const int NSF20FunctionKey = 63255;
+    public static const int NSF21FunctionKey = 63256;
+    public static const int NSF22FunctionKey = 63257;
+    public static const int NSF23FunctionKey = 63258;
+    public static const int NSF24FunctionKey = 63259;
+    public static const int NSF25FunctionKey = 63260;
+    public static const int NSF26FunctionKey = 63261;
+    public static const int NSF27FunctionKey = 63262;
+    public static const int NSF28FunctionKey = 63263;
+    public static const int NSF29FunctionKey = 63264;
+    public static const int NSF2FunctionKey = 63237;
+    public static const int NSF30FunctionKey = 63265;
+    public static const int NSF31FunctionKey = 63266;
+    public static const int NSF32FunctionKey = 63267;
+    public static const int NSF33FunctionKey = 63268;
+    public static const int NSF34FunctionKey = 63269;
+    public static const int NSF35FunctionKey = 63270;
+    public static const int NSF3FunctionKey = 63238;
+    public static const int NSF4FunctionKey = 63239;
+    public static const int NSF5FunctionKey = 63240;
+    public static const int NSF6FunctionKey = 63241;
+    public static const int NSF7FunctionKey = 63242;
+    public static const int NSF8FunctionKey = 63243;
+    public static const int NSF9FunctionKey = 63244;
+    public static const int NSFPCurrentField = 134;
+    public static const int NSFPPreviewButton = 131;
+    public static const int NSFPPreviewField = 128;
+    public static const int NSFPRevertButton = 130;
+    public static const int NSFPSetButton = 132;
+    public static const int NSFPSizeField = 129;
+    public static const int NSFPSizeTitle = 133;
+    public static const int NSFileHandlingPanelCancelButton = 0;
+    public static const int NSFileHandlingPanelOKButton = 1;
+    public static const int NSFindFunctionKey = 63301;
+    public static const int NSFindPanelActionNext = 2;
+    public static const int NSFindPanelActionPrevious = 3;
+    public static const int NSFindPanelActionReplace = 5;
+    public static const int NSFindPanelActionReplaceAll = 4;
+    public static const int NSFindPanelActionReplaceAllInSelection = 8;
+    public static const int NSFindPanelActionReplaceAndFind = 6;
+    public static const int NSFindPanelActionSelectAll = 9;
+    public static const int NSFindPanelActionSelectAllInSelection = 10;
+    public static const int NSFindPanelActionSetFindString = 7;
+    public static const int NSFindPanelActionShowFindPanel = 1;
+    public static const int NSFindPanelSubStringMatchTypeContains = 0;
+    public static const int NSFindPanelSubStringMatchTypeEndsWith = 3;
+    public static const int NSFindPanelSubStringMatchTypeFullWord = 2;
+    public static const int NSFindPanelSubStringMatchTypeStartsWith = 1;
+    public static const int NSFitPagination = 1;
+    public static const int NSFixedPitchFontMask = 1024;
+    public static const int NSFlagsChanged = 12;
+    public static const int NSFlagsChangedMask = 4096;
+    public static const int NSFloatType = 3;
+    public static const int NSFloatingPointSamplesBitmapFormat = 4;
+    public static const int NSFloatingWindowLevel = 3;
+    public static const int NSFocusRingAbove = 2;
+    public static const int NSFocusRingBelow = 1;
+    public static const int NSFocusRingOnly = 0;
+    public static const int NSFocusRingTypeDefault = 0;
+    public static const int NSFocusRingTypeExterior = 2;
+    public static const int NSFocusRingTypeNone = 1;
+    public static const int NSFontAntialiasedIntegerAdvancementsRenderingMode = 3;
+    public static const int NSFontAntialiasedRenderingMode = 1;
+    public static const int NSFontBoldTrait = 2;
+    public static const int NSFontClarendonSerifsClass = 1073741824;
+    public static const int NSFontCollectionApplicationOnlyMask = 1;
+    public static const int NSFontCondensedTrait = 64;
+    public static const int NSFontDefaultRenderingMode = 0;
+    public static const int NSFontExpandedTrait = 32;
+    public static const int NSFontFamilyClassMask = -268435456;
+    public static const int NSFontFreeformSerifsClass = 1879048192;
+    public static const int NSFontIntegerAdvancementsRenderingMode = 2;
+    public static const int NSFontItalicTrait = 1;
+    public static const int NSFontModernSerifsClass = 805306368;
+    public static const int NSFontMonoSpaceTrait = 1024;
+    public static const int NSFontOldStyleSerifsClass = 268435456;
+    public static const int NSFontOrnamentalsClass = -1879048192;
+    public static const int NSFontPanelAllEffectsModeMask = 1048320;
+    public static const int NSFontPanelAllModesMask = -1;
+    public static const int NSFontPanelCollectionModeMask = 4;
+    public static const int NSFontPanelDocumentColorEffectModeMask = 2048;
+    public static const int NSFontPanelFaceModeMask = 1;
+    public static const int NSFontPanelShadowEffectModeMask = 4096;
+    public static const int NSFontPanelSizeModeMask = 2;
+    public static const int NSFontPanelStandardModesMask = 65535;
+    public static const int NSFontPanelStrikethroughEffectModeMask = 512;
+    public static const int NSFontPanelTextColorEffectModeMask = 1024;
+    public static const int NSFontPanelUnderlineEffectModeMask = 256;
+    public static const int NSFontSansSerifClass = -2147483648;
+    public static const int NSFontScriptsClass = -1610612736;
+    public static const int NSFontSlabSerifsClass = 1342177280;
+    public static const int NSFontSymbolicClass = -1073741824;
+    public static const int NSFontTransitionalSerifsClass = 536870912;
+    public static const int NSFontUIOptimizedTrait = 4096;
+    public static const int NSFontUnknownClass = 0;
+    public static const int NSFontVerticalTrait = 2048;
+    public static const int NSFormFeedCharacter = 12;
+    public static const int NSFunctionKeyMask = 8388608;
+    public static const int NSGIFFileType = 2;
+    public static const int NSGlyphAttributeBidiLevel = 2;
+    public static const int NSGlyphAttributeElastic = 1;
+    public static const int NSGlyphAttributeInscribe = 5;
+    public static const int NSGlyphAttributeSoft = 0;
+    public static const int NSGlyphInscribeAbove = 2;
+    public static const int NSGlyphInscribeBase = 0;
+    public static const int NSGlyphInscribeBelow = 1;
+    public static const int NSGlyphInscribeOverBelow = 4;
+    public static const int NSGlyphInscribeOverstrike = 3;
+    public static const int NSGradientConcaveStrong = 2;
+    public static const int NSGradientConcaveWeak = 1;
+    public static const int NSGradientConvexStrong = 4;
+    public static const int NSGradientConvexWeak = 3;
+    public static const int NSGradientDrawsAfterEndingLocation = 2;
+    public static const int NSGradientDrawsBeforeStartingLocation = 1;
+    public static const int NSGradientNone = 0;
+    public static const int NSGraphiteControlTint = 6;
+    public static const int NSGrayColorSpaceModel = 0;
+    public static const int NSGrayModeColorPanel = 0;
+    public static const int NSGrooveBorder = 3;
+    public static const int NSHSBModeColorPanel = 3;
+    public static const int NSHUDWindowMask = 8192;
+    public static const int NSHeavierFontAction = 5;
+    public static const int NSHelpButtonBezelStyle = 9;
+    public static const int NSHelpFunctionKey = 63302;
+    public static const int NSHelpKeyMask = 4194304;
+    public static const int NSHighlightModeMatrix = 1;
+    public static const int NSHomeFunctionKey = 63273;
+    public static const int NSHorizontalRuler = 0;
+    public static const int NSHourMinuteDatePickerElementFlag = 12;
+    public static const int NSHourMinuteSecondDatePickerElementFlag = 14;
+    public static const int NSIdentityMappingCharacterCollection = 0;
+    public static const int NSIllegalTextMovement = 0;
+    public static const int NSImageAbove = 5;
+    public static const int NSImageAlignBottom = 5;
+    public static const int NSImageAlignBottomLeft = 6;
+    public static const int NSImageAlignBottomRight = 7;
+    public static const int NSImageAlignCenter = 0;
+    public static const int NSImageAlignLeft = 4;
+    public static const int NSImageAlignRight = 8;
+    public static const int NSImageAlignTop = 1;
+    public static const int NSImageAlignTopLeft = 2;
+    public static const int NSImageAlignTopRight = 3;
+    public static const int NSImageBelow = 4;
+    public static const int NSImageCacheAlways = 1;
+    public static const int NSImageCacheBySize = 2;
+    public static const int NSImageCacheDefault = 0;
+    public static const int NSImageCacheNever = 3;
+    public static const int NSImageCellType = 2;
+    public static const int NSImageFrameButton = 4;
+    public static const int NSImageFrameGrayBezel = 2;
+    public static const int NSImageFrameGroove = 3;
+    public static const int NSImageFrameNone = 0;
+    public static const int NSImageFramePhoto = 1;
+    public static const int NSImageInterpolationDefault = 0;
+    public static const int NSImageInterpolationHigh = 3;
+    public static const int NSImageInterpolationLow = 2;
+    public static const int NSImageInterpolationNone = 1;
+    public static const int NSImageLeft = 2;
+    public static const int NSImageLoadStatusCancelled = 1;
+    public static const int NSImageLoadStatusCompleted = 0;
+    public static const int NSImageLoadStatusInvalidData = 2;
+    public static const int NSImageLoadStatusReadError = 4;
+    public static const int NSImageLoadStatusUnexpectedEOF = 3;
+    public static const int NSImageOnly = 1;
+    public static const int NSImageOverlaps = 6;
+    public static const int NSImageRepLoadStatusCompleted = -6;
+    public static const int NSImageRepLoadStatusInvalidData = -4;
+    public static const int NSImageRepLoadStatusReadingHeader = -2;
+    public static const int NSImageRepLoadStatusUnexpectedEOF = -5;
+    public static const int NSImageRepLoadStatusUnknownType = -1;
+    public static const int NSImageRepLoadStatusWillNeedAllData = -3;
+    public static const int NSImageRepMatchesDevice = 0;
+    public static const int NSImageRight = 3;
+    public static const int NSImageScaleAxesIndependently = 1;
+    public static const int NSImageScaleNone = 2;
+    public static const int NSImageScaleProportionallyDown = 0;
+    public static const int NSImageScaleProportionallyUpOrDown = 3;
+    public static const int NSIndexedColorSpaceModel = 5;
+    public static const int NSInformationalAlertStyle = 1;
+    public static const int NSInformationalRequest = 10;
+    public static const int NSInsertCharFunctionKey = 63293;
+    public static const int NSInsertFunctionKey = 63271;
+    public static const int NSInsertLineFunctionKey = 63291;
+    public static const int NSIntType = 1;
+    public static const int NSItalicFontMask = 1;
+    public static const int NSJPEG2000FileType = 5;
+    public static const int NSJPEGFileType = 3;
+    public static const int NSJustifiedTextAlignment = 3;
+    public static const int NSKeyDown = 10;
+    public static const int NSKeyDownMask = 1024;
+    public static const int NSKeyUp = 11;
+    public static const int NSKeyUpMask = 2048;
+    public static const int NSLABColorSpaceModel = 3;
+    public static const int NSLandscapeOrientation = 1;
+    public static const int NSLeftArrowFunctionKey = 63234;
+    public static const int NSLeftMouseDown = 1;
+    public static const int NSLeftMouseDownMask = 2;
+    public static const int NSLeftMouseDragged = 6;
+    public static const int NSLeftMouseDraggedMask = 64;
+    public static const int NSLeftMouseUp = 2;
+    public static const int NSLeftMouseUpMask = 4;
+    public static const int NSLeftTabStopType = 0;
+    public static const int NSLeftTabsBezelBorder = 1;
+    public static const int NSLeftTextAlignment = 0;
+    public static const int NSLeftTextMovement = 19;
+    public static const int NSLighterFontAction = 6;
+    public static const int NSLineBorder = 1;
+    public static const int NSLineBreakByCharWrapping = 1;
+    public static const int NSLineBreakByClipping = 2;
+    public static const int NSLineBreakByTruncatingHead = 3;
+    public static const int NSLineBreakByTruncatingMiddle = 5;
+    public static const int NSLineBreakByTruncatingTail = 4;
+    public static const int NSLineBreakByWordWrapping = 0;
+    public static const int NSLineDoesntMove = 0;
+    public static const int NSLineMovesDown = 3;
+    public static const int NSLineMovesLeft = 1;
+    public static const int NSLineMovesRight = 2;
+    public static const int NSLineMovesUp = 4;
+    public static const int NSLineSeparatorCharacter = 8232;
+    public static const int NSLineSweepDown = 2;
+    public static const int NSLineSweepLeft = 0;
+    public static const int NSLineSweepRight = 1;
+    public static const int NSLineSweepUp = 3;
+    public static const int NSLineToBezierPathElement = 1;
+    public static const int NSLinearSlider = 0;
+    public static const int NSListModeMatrix = 2;
+    public static const int NSMacintoshInterfaceStyle = 3;
+    public static const int NSMainMenuWindowLevel = 24;
+    public static const int NSMenuFunctionKey = 63285;
+    public static const int NSMiniControlSize = 2;
+    public static const int NSMiniaturizableWindowMask = 4;
+    public static const int NSMiterLineJoinStyle = 0;
+    public static const int NSMixedState = -1;
+    public static const int NSModalPanelWindowLevel = 8;
+    public static const int NSModeSwitchFunctionKey = 63303;
+    public static const int NSMomentaryChangeButton = 5;
+    public static const int NSMomentaryLight = 7;
+    public static const int NSMomentaryLightButton = 0;
+    public static const int NSMomentaryPushButton = 0;
+    public static const int NSMomentaryPushInButton = 7;
+    public static const int NSMouseEntered = 8;
+    public static const int NSMouseEnteredMask = 256;
+    public static const int NSMouseEventSubtype = 0;
+    public static const int NSMouseExited = 9;
+    public static const int NSMouseExitedMask = 512;
+    public static const int NSMouseMoved = 5;
+    public static const int NSMouseMovedMask = 32;
+    public static const int NSMoveToBezierPathElement = 0;
+    public static const int NSNarrowFontMask = 16;
+    public static const int NSNativeShortGlyphPacking = 5;
+    public static const int NSNaturalTextAlignment = 4;
+    public static const int NSNewlineCharacter = 10;
+    public static const int NSNextFunctionKey = 63296;
+    public static const int NSNextStepInterfaceStyle = 1;
+    public static const int NSNoBorder = 0;
+    public static const int NSNoCellMask = 0;
+    public static const int NSNoFontChangeAction = 0;
+    public static const int NSNoImage = 0;
+    public static const int NSNoInterfaceStyle = 0;
+    public static const int NSNoModeColorPanel = -1;
+    public static const int NSNoScrollerParts = 0;
+    public static const int NSNoTabsBezelBorder = 4;
+    public static const int NSNoTabsLineBorder = 5;
+    public static const int NSNoTabsNoBorder = 6;
+    public static const int NSNoTitle = 0;
+    public static const int NSNoUnderlineStyle = 0;
+    public static const int NSNonStandardCharacterSetFontMask = 8;
+    public static const int NSNonZeroWindingRule = 0;
+    public static const int NSNonactivatingPanelMask = 128;
+    public static const int NSNormalWindowLevel = 0;
+    public static const int NSNullCellType = 0;
+    public static const int NSNullGlyph = 0;
+    public static const int NSNumericPadKeyMask = 2097152;
+    public static const int NSOKButton = 1;
+    public static const int NSOPENGL_CURRENT_VERSION = 1;
+    public static const int NSOffState = 0;
+    public static const int NSOnOffButton = 6;
+    public static const int NSOnState = 1;
+    public static const int NSOnlyScrollerArrows = 1;
+    public static const int NSOpenGLCPRasterizationEnable = 221;
+    public static const int NSOpenGLCPStateValidation = 301;
+    public static const int NSOpenGLCPSurfaceOpacity = 236;
+    public static const int NSOpenGLCPSurfaceOrder = 235;
+    public static const int NSOpenGLCPSwapInterval = 222;
+    public static const int NSOpenGLCPSwapRectangle = 200;
+    public static const int NSOpenGLCPSwapRectangleEnable = 201;
+    public static const int NSOpenGLGOClearFormatCache = 502;
+    public static const int NSOpenGLGOFormatCacheSize = 501;
+    public static const int NSOpenGLGOResetLibrary = 504;
+    public static const int NSOpenGLGORetainRenderers = 503;
+    public static const int NSOpenGLPFAAccelerated = 73;
+    public static const int NSOpenGLPFAAccumSize = 14;
+    public static const int NSOpenGLPFAAllRenderers = 1;
+    public static const int NSOpenGLPFAAllowOfflineRenderers = 96;
+    public static const int NSOpenGLPFAAlphaSize = 11;
+    public static const int NSOpenGLPFAAuxBuffers = 7;
+    public static const int NSOpenGLPFAAuxDepthStencil = 57;
+    public static const int NSOpenGLPFABackingStore = 76;
+    public static const int NSOpenGLPFAClosestPolicy = 74;
+    public static const int NSOpenGLPFAColorFloat = 58;
+    public static const int NSOpenGLPFAColorSize = 8;
+    public static const int NSOpenGLPFACompliant = 83;
+    public static const int NSOpenGLPFADepthSize = 12;
+    public static const int NSOpenGLPFADoubleBuffer = 5;
+    public static const int NSOpenGLPFAFullScreen = 54;
+    public static const int NSOpenGLPFAMPSafe = 78;
+    public static const int NSOpenGLPFAMaximumPolicy = 52;
+    public static const int NSOpenGLPFAMinimumPolicy = 51;
+    public static const int NSOpenGLPFAMultiScreen = 81;
+    public static const int NSOpenGLPFAMultisample = 59;
+    public static const int NSOpenGLPFANoRecovery = 72;
+    public static const int NSOpenGLPFAOffScreen = 53;
+    public static const int NSOpenGLPFAPixelBuffer = 90;
+    public static const int NSOpenGLPFARendererID = 70;
+    public static const int NSOpenGLPFARobust = 75;
+    public static const int NSOpenGLPFASampleAlpha = 61;
+    public static const int NSOpenGLPFASampleBuffers = 55;
+    public static const int NSOpenGLPFASamples = 56;
+    public static const int NSOpenGLPFAScreenMask = 84;
+    public static const int NSOpenGLPFASingleRenderer = 71;
+    public static const int NSOpenGLPFAStencilSize = 13;
+    public static const int NSOpenGLPFAStereo = 6;
+    public static const int NSOpenGLPFASupersample = 60;
+    public static const int NSOpenGLPFAVirtualScreenCount = 128;
+    public static const int NSOpenGLPFAWindow = 80;
+    public static const int NSOtherMouseDown = 25;
+    public static const int NSOtherMouseDownMask = 33554432;
+    public static const int NSOtherMouseDragged = 27;
+    public static const int NSOtherMouseDraggedMask = 134217728;
+    public static const int NSOtherMouseUp = 26;
+    public static const int NSOtherMouseUpMask = 67108864;
+    public static const int NSOtherTextMovement = 0;
+    public static const int NSOutlineViewDropOnItemIndex = -1;
+    public static const int NSPNGFileType = 4;
+    public static const int NSPageDownFunctionKey = 63277;
+    public static const int NSPageUpFunctionKey = 63276;
+    public static const int NSParagraphSeparatorCharacter = 8233;
+    public static const int NSPathStyleNavigationBar = 1;
+    public static const int NSPathStylePopUp = 2;
+    public static const int NSPathStyleStandard = 0;
+    public static const int NSPatternColorSpaceModel = 6;
+    public static const int NSPauseFunctionKey = 63280;
+    public static const int NSPenLowerSideMask = 2;
+    public static const int NSPenPointingDevice = 1;
+    public static const int NSPenTipMask = 1;
+    public static const int NSPenUpperSideMask = 4;
+    public static const int NSPeriodic = 16;
+    public static const int NSPeriodicMask = 65536;
+    public static const int NSPlainTextTokenStyle = 1;
+    public static const int NSPopUpArrowAtBottom = 2;
+    public static const int NSPopUpArrowAtCenter = 1;
+    public static const int NSPopUpMenuWindowLevel = 101;
+    public static const int NSPopUpNoArrow = 0;
+    public static const int NSPortraitOrientation = 0;
+    public static const int NSPositiveDoubleType = 7;
+    public static const int NSPositiveFloatType = 4;
+    public static const int NSPositiveIntType = 2;
+    public static const int NSPosterFontMask = 256;
+    public static const int NSPowerOffEventType = 1;
+    public static const int NSPressedTab = 2;
+    public static const int NSPrevFunctionKey = 63295;
+    public static const int NSPrintFunctionKey = 63288;
+    public static const int NSPrintPanelShowsCopies = 1;
+    public static const int NSPrintPanelShowsOrientation = 8;
+    public static const int NSPrintPanelShowsPageRange = 2;
+    public static const int NSPrintPanelShowsPageSetupAccessory = 256;
+    public static const int NSPrintPanelShowsPaperSize = 4;
+    public static const int NSPrintPanelShowsPreview = 131072;
+    public static const int NSPrintPanelShowsScaling = 16;
+    public static const int NSPrintScreenFunctionKey = 63278;
+    public static const int NSPrinterTableError = 2;
+    public static const int NSPrinterTableNotFound = 1;
+    public static const int NSPrinterTableOK = 0;
+    public static const int NSPrintingCancelled = 0;
+    public static const int NSPrintingFailure = 3;
+    public static const int NSPrintingReplyLater = 2;
+    public static const int NSPrintingSuccess = 1;
+    public static const int NSProgressIndicatorBarStyle = 0;
+    public static const int NSProgressIndicatorPreferredAquaThickness = 12;
+    public static const int NSProgressIndicatorPreferredLargeThickness = 18;
+    public static const int NSProgressIndicatorPreferredSmallThickness = 10;
+    public static const int NSProgressIndicatorPreferredThickness = 14;
+    public static const int NSProgressIndicatorSpinningStyle = 1;
+    public static const int NSPushInCell = 2;
+    public static const int NSPushInCellMask = 2;
+    public static const int NSPushOnPushOffButton = 1;
+    public static const int NSQTMovieLoopingBackAndForthPlayback = 2;
+    public static const int NSQTMovieLoopingPlayback = 1;
+    public static const int NSQTMovieNormalPlayback = 0;
+    public static const int NSRGBColorSpaceModel = 1;
+    public static const int NSRGBModeColorPanel = 1;
+    public static const int NSRadioButton = 4;
+    public static const int NSRadioModeMatrix = 0;
+    public static const int NSRangeDateMode = 1;
+    public static const int NSRatingLevelIndicatorStyle = 3;
+    public static const int NSRecessedBezelStyle = 13;
+    public static const int NSRedoFunctionKey = 63300;
+    public static const int NSRegularControlSize = 0;
+    public static const int NSRegularSquareBezelStyle = 2;
+    public static const int NSRelevancyLevelIndicatorStyle = 0;
+    public static const int NSRemoveTraitFontAction = 7;
+    public static const int NSResetCursorRectsRunLoopOrdering = 700000;
+    public static const int NSResetFunctionKey = 63283;
+    public static const int NSResizableWindowMask = 8;
+    public static const int NSReturnTextMovement = 16;
+    public static const int NSRightArrowFunctionKey = 63235;
+    public static const int NSRightMouseDown = 3;
+    public static const int NSRightMouseDownMask = 8;
+    public static const int NSRightMouseDragged = 7;
+    public static const int NSRightMouseDraggedMask = 128;
+    public static const int NSRightMouseUp = 4;
+    public static const int NSRightMouseUpMask = 16;
+    public static const int NSRightTabStopType = 1;
+    public static const int NSRightTabsBezelBorder = 3;
+    public static const int NSRightTextAlignment = 1;
+    public static const int NSRightTextMovement = 20;
+    public static const int NSRoundLineCapStyle = 1;
+    public static const int NSRoundLineJoinStyle = 1;
+    public static const int NSRoundRectBezelStyle = 12;
+    public static const int NSRoundedBezelStyle = 1;
+    public static const int NSRoundedDisclosureBezelStyle = 14;
+    public static const int NSRoundedTokenStyle = 2;
+    public static const int NSRuleEditorNestingModeCompound = 2;
+    public static const int NSRuleEditorNestingModeList = 1;
+    public static const int NSRuleEditorNestingModeSimple = 3;
+    public static const int NSRuleEditorNestingModeSingle = 0;
+    public static const int NSRuleEditorRowTypeCompound = 1;
+    public static const int NSRuleEditorRowTypeSimple = 0;
+    public static const int NSRunAbortedResponse = -1001;
+    public static const int NSRunContinuesResponse = -1002;
+    public static const int NSRunStoppedResponse = -1000;
+    public static const int NSSaveAsOperation = 1;
+    public static const int NSSaveOperation = 0;
+    public static const int NSSaveToOperation = 2;
+    public static const int NSScaleNone = 2;
+    public static const int NSScaleProportionally = 0;
+    public static const int NSScaleToFit = 1;
+    public static const int NSScreenChangedEventType = 8;
+    public static const int NSScreenSaverWindowLevel = 1000;
+    public static const int NSScrollLockFunctionKey = 63279;
+    public static const int NSScrollWheel = 22;
+    public static const int NSScrollWheelMask = 4194304;
+    public static const int NSScrollerArrowsDefaultSetting = 0;
+    public static const int NSScrollerArrowsMaxEnd = 0;
+    public static const int NSScrollerArrowsMinEnd = 1;
+    public static const int NSScrollerArrowsNone = 2;
+    public static const int NSScrollerDecrementArrow = 1;
+    public static const int NSScrollerDecrementLine = 4;
+    public static const int NSScrollerDecrementPage = 1;
+    public static const int NSScrollerIncrementArrow = 0;
+    public static const int NSScrollerIncrementLine = 5;
+    public static const int NSScrollerIncrementPage = 3;
+    public static const int NSScrollerKnob = 2;
+    public static const int NSScrollerKnobSlot = 6;
+    public static const int NSScrollerNoPart = 0;
+    public static const int NSSearchFieldClearRecentsMenuItemTag = 1002;
+    public static const int NSSearchFieldNoRecentsMenuItemTag = 1003;
+    public static const int NSSearchFieldRecentsMenuItemTag = 1001;
+    public static const int NSSearchFieldRecentsTitleMenuItemTag = 1000;
+    public static const int NSSegmentStyleAutomatic = 0;
+    public static const int NSSegmentStyleCapsule = 5;
+    public static const int NSSegmentStyleRoundRect = 3;
+    public static const int NSSegmentStyleRounded = 1;
+    public static const int NSSegmentStyleSmallSquare = 6;
+    public static const int NSSegmentStyleTexturedRounded = 2;
+    public static const int NSSegmentStyleTexturedSquare = 4;
+    public static const int NSSegmentSwitchTrackingMomentary = 2;
+    public static const int NSSegmentSwitchTrackingSelectAny = 1;
+    public static const int NSSegmentSwitchTrackingSelectOne = 0;
+    public static const int NSSelectByCharacter = 0;
+    public static const int NSSelectByParagraph = 2;
+    public static const int NSSelectByWord = 1;
+    public static const int NSSelectFunctionKey = 63297;
+    public static const int NSSelectedTab = 0;
+    public static const int NSSelectingNext = 1;
+    public static const int NSSelectingPrevious = 2;
+    public static const int NSSelectionAffinityDownstream = 1;
+    public static const int NSSelectionAffinityUpstream = 0;
+    public static const int NSServiceApplicationLaunchFailedError = 66561;
+    public static const int NSServiceApplicationNotFoundError = 66560;
+    public static const int NSServiceErrorMaximum = 66817;
+    public static const int NSServiceErrorMinimum = 66560;
+    public static const int NSServiceInvalidPasteboardDataError = 66563;
+    public static const int NSServiceMalformedServiceDictionaryError = 66564;
+    public static const int NSServiceMiscellaneousError = 66800;
+    public static const int NSServiceRequestTimedOutError = 66562;
+    public static const int NSShadowlessSquareBezelStyle = 6;
+    public static const int NSShiftKeyMask = 131072;
+    public static const int NSShowControlGlyphs = 1;
+    public static const int NSShowInvisibleGlyphs = 2;
+    public static const int NSSingleDateMode = 0;
+    public static const int NSSingleUnderlineStyle = 1;
+    public static const int NSSizeDownFontAction = 4;
+    public static const int NSSizeUpFontAction = 3;
+    public static const int NSSmallCapsFontMask = 128;
+    public static const int NSSmallControlSize = 1;
+    public static const int NSSmallIconButtonBezelStyle = 2;
+    public static const int NSSmallSquareBezelStyle = 10;
+    public static const int NSSpecialPageOrder = 0;
+    public static const int NSSpeechImmediateBoundary = 0;
+    public static const int NSSpeechSentenceBoundary = 2;
+    public static const int NSSpeechWordBoundary = 1;
+    public static const int NSSpellingStateGrammarFlag = 2;
+    public static const int NSSpellingStateSpellingFlag = 1;
+    public static const int NSSplitViewDividerStyleThick = 1;
+    public static const int NSSplitViewDividerStyleThin = 2;
+    public static const int NSSquareLineCapStyle = 2;
+    public static const int NSSquareStatusItemLength = -2;
+    public static const int NSStatusWindowLevel = 25;
+    public static const int NSStopFunctionKey = 63284;
+    public static const int NSStringDrawingDisableScreenFontSubstitution = 4;
+    public static const int NSStringDrawingOneShot = 16;
+    public static const int NSStringDrawingTruncatesLastVisibleLine = 32;
+    public static const int NSStringDrawingUsesDeviceMetrics = 8;
+    public static const int NSStringDrawingUsesFontLeading = 2;
+    public static const int NSStringDrawingUsesLineFragmentOrigin = 1;
+    public static const int NSSubmenuWindowLevel = 3;
+    public static const int NSSwitchButton = 3;
+    public static const int NSSysReqFunctionKey = 63281;
+    public static const int NSSystemDefined = 14;
+    public static const int NSSystemDefinedMask = 16384;
+    public static const int NSSystemFunctionKey = 63287;
+    public static const int NSTIFFCompressionCCITTFAX3 = 3;
+    public static const int NSTIFFCompressionCCITTFAX4 = 4;
+    public static const int NSTIFFCompressionJPEG = 6;
+    public static const int NSTIFFCompressionLZW = 5;
+    public static const int NSTIFFCompressionNEXT = 32766;
+    public static const int NSTIFFCompressionNone = 1;
+    public static const int NSTIFFCompressionOldJPEG = 32865;
+    public static const int NSTIFFCompressionPackBits = 32773;
+    public static const int NSTIFFFileType = 0;
+    public static const int NSTabCharacter = 9;
+    public static const int NSTabTextMovement = 17;
+    public static const int NSTableColumnAutoresizingMask = 1;
+    public static const int NSTableColumnNoResizing = 0;
+    public static const int NSTableColumnUserResizingMask = 2;
+    public static const int NSTableViewDropAbove = 1;
+    public static const int NSTableViewDropOn = 0;
+    public static const int NSTableViewFirstColumnOnlyAutoresizingStyle = 5;
+    public static const int NSTableViewGridNone = 0;
+    public static const int NSTableViewLastColumnOnlyAutoresizingStyle = 4;
+    public static const int NSTableViewNoColumnAutoresizing = 0;
+    public static const int NSTableViewReverseSequentialColumnAutoresizingStyle = 3;
+    public static const int NSTableViewSelectionHighlightStyleRegular = 0;
+    public static const int NSTableViewSelectionHighlightStyleSourceList = 1;
+    public static const int NSTableViewSequentialColumnAutoresizingStyle = 2;
+    public static const int NSTableViewSolidHorizontalGridLineMask = 2;
+    public static const int NSTableViewSolidVerticalGridLineMask = 1;
+    public static const int NSTableViewUniformColumnAutoresizingStyle = 1;
+    public static const int NSTabletPoint = 23;
+    public static const int NSTabletPointEventSubtype = 1;
+    public static const int NSTabletPointMask = 8388608;
+    public static const int NSTabletProximity = 24;
+    public static const int NSTabletProximityEventSubtype = 2;
+    public static const int NSTabletProximityMask = 16777216;
+    public static const int NSTerminateCancel = 0;
+    public static const int NSTerminateLater = 2;
+    public static const int NSTerminateNow = 1;
+    public static const int NSTextBlockAbsoluteValueType = 0;
+    public static const int NSTextBlockBaselineAlignment = 3;
+    public static const int NSTextBlockBorder = 0;
+    public static const int NSTextBlockBottomAlignment = 2;
+    public static const int NSTextBlockHeight = 4;
+    public static const int NSTextBlockMargin = 1;
+    public static const int NSTextBlockMaximumHeight = 6;
+    public static const int NSTextBlockMaximumWidth = 2;
+    public static const int NSTextBlockMiddleAlignment = 1;
+    public static const int NSTextBlockMinimumHeight = 5;
+    public static const int NSTextBlockMinimumWidth = 1;
+    public static const int NSTextBlockPadding = -1;
+    public static const int NSTextBlockPercentageValueType = 1;
+    public static const int NSTextBlockTopAlignment = 0;
+    public static const int NSTextBlockWidth = 0;
+    public static const int NSTextCellType = 1;
+    public static const int NSTextFieldAndStepperDatePickerStyle = 0;
+    public static const int NSTextFieldDatePickerStyle = 2;
+    public static const int NSTextFieldRoundedBezel = 1;
+    public static const int NSTextFieldSquareBezel = 0;
+    public static const int NSTextListPrependEnclosingMarker = 1;
+    public static const int NSTextReadInapplicableDocumentTypeError = 65806;
+    public static const int NSTextReadWriteErrorMaximum = 66303;
+    public static const int NSTextReadWriteErrorMinimum = 65792;
+    public static const int NSTextStorageEditedAttributes = 1;
+    public static const int NSTextStorageEditedCharacters = 2;
+    public static const int NSTextTableAutomaticLayoutAlgorithm = 0;
+    public static const int NSTextTableFixedLayoutAlgorithm = 1;
+    public static const int NSTextWriteInapplicableDocumentTypeError = 66062;
+    public static const int NSTexturedBackgroundWindowMask = 256;
+    public static const int NSTexturedRoundedBezelStyle = 11;
+    public static const int NSTexturedSquareBezelStyle = 8;
+    public static const int NSThickSquareBezelStyle = 3;
+    public static const int NSThickerSquareBezelStyle = 4;
+    public static const int NSTickMarkAbove = 1;
+    public static const int NSTickMarkBelow = 0;
+    public static const int NSTickMarkLeft = 1;
+    public static const int NSTickMarkRight = 0;
+    public static const int NSTimeZoneDatePickerElementFlag = 16;
+    public static const int NSTitledWindowMask = 1;
+    public static const int NSToggleButton = 2;
+    public static const int NSToolbarDisplayModeDefault = 0;
+    public static const int NSToolbarDisplayModeIconAndLabel = 1;
+    public static const int NSToolbarDisplayModeIconOnly = 2;
+    public static const int NSToolbarDisplayModeLabelOnly = 3;
+    public static const int NSToolbarItemVisibilityPriorityHigh = 1000;
+    public static const int NSToolbarItemVisibilityPriorityLow = -1000;
+    public static const int NSToolbarItemVisibilityPriorityStandard = 0;
+    public static const int NSToolbarItemVisibilityPriorityUser = 2000;
+    public static const int NSToolbarSizeModeDefault = 0;
+    public static const int NSToolbarSizeModeRegular = 1;
+    public static const int NSToolbarSizeModeSmall = 2;
+    public static const int NSTopTabsBezelBorder = 0;
+    public static const int NSTornOffMenuWindowLevel = 3;
+    public static const int NSTrackModeMatrix = 3;
+    public static const int NSTrackingActiveAlways = 128;
+    public static const int NSTrackingActiveInActiveApp = 64;
+    public static const int NSTrackingActiveInKeyWindow = 32;
+    public static const int NSTrackingActiveWhenFirstResponder = 16;
+    public static const int NSTrackingAssumeInside = 256;
+    public static const int NSTrackingCursorUpdate = 4;
+    public static const int NSTrackingEnabledDuringMouseDrag = 1024;
+    public static const int NSTrackingInVisibleRect = 512;
+    public static const int NSTrackingMouseEnteredAndExited = 1;
+    public static const int NSTrackingMouseMoved = 2;
+    public static const int NSTypesetterBehavior_10_2 = 2;
+    public static const int NSTypesetterBehavior_10_2_WithCompatibility = 1;
+    public static const int NSTypesetterBehavior_10_3 = 3;
+    public static const int NSTypesetterBehavior_10_4 = 4;
+    public static const int NSTypesetterContainerBreakAction = 32;
+    public static const int NSTypesetterHorizontalTabAction = 4;
+    public static const int NSTypesetterLatestBehavior = -1;
+    public static const int NSTypesetterLineBreakAction = 8;
+    public static const int NSTypesetterOriginalBehavior = 0;
+    public static const int NSTypesetterParagraphBreakAction = 16;
+    public static const int NSTypesetterWhitespaceAction = 2;
+    public static const int NSTypesetterZeroAdvancementAction = 1;
+    public static const int NSUnboldFontMask = 4;
+    public static const int NSUnderlinePatternDash = 512;
+    public static const int NSUnderlinePatternDashDot = 768;
+    public static const int NSUnderlinePatternDashDotDot = 1024;
+    public static const int NSUnderlinePatternDot = 256;
+    public static const int NSUnderlinePatternSolid = 0;
+    public static const int NSUnderlineStyleDouble = 9;
+    public static const int NSUnderlineStyleNone = 0;
+    public static const int NSUnderlineStyleSingle = 1;
+    public static const int NSUnderlineStyleThick = 2;
+    public static const int NSUndoFunctionKey = 63299;
+    public static const int NSUnifiedTitleAndToolbarWindowMask = 4096;
+    public static const int NSUnitalicFontMask = 16777216;
+    public static const int NSUnknownColorSpaceModel = -1;
+    public static const int NSUnknownPageOrder = 2;
+    public static const int NSUnknownPointingDevice = 0;
+    public static const int NSUnscaledWindowMask = 2048;
+    public static const int NSUpArrowFunctionKey = 63232;
+    public static const int NSUpTextMovement = 21;
+    public static const int NSUpdateWindowsRunLoopOrdering = 500000;
+    public static const int NSUserFunctionKey = 63286;
+    public static const int NSUtilityWindowMask = 16;
+    public static const int NSVariableStatusItemLength = -1;
+    public static const int NSVerticalRuler = 1;
+    public static const int NSViaPanelFontAction = 1;
+    public static const int NSViewHeightSizable = 16;
+    public static const int NSViewMaxXMargin = 4;
+    public static const int NSViewMaxYMargin = 32;
+    public static const int NSViewMinXMargin = 1;
+    public static const int NSViewMinYMargin = 8;
+    public static const int NSViewNotSizable = 0;
+    public static const int NSViewWidthSizable = 2;
+    public static const int NSWantsBidiLevels = 4;
+    public static const int NSWarningAlertStyle = 0;
+    public static const int NSWheelModeColorPanel = 6;
+    public static const int NSWindowAbove = 1;
+    public static const int NSWindowBackingLocationDefault = 0;
+    public static const int NSWindowBackingLocationMainMemory = 2;
+    public static const int NSWindowBackingLocationVideoMemory = 1;
+    public static const int NSWindowBelow = -1;
+    public static const int NSWindowCloseButton = 0;
+    public static const int NSWindowCollectionBehaviorCanJoinAllSpaces = 1;
+    public static const int NSWindowCollectionBehaviorDefault = 0;
+    public static const int NSWindowCollectionBehaviorMoveToActiveSpace = 2;
+    public static const int NSWindowDocumentIconButton = 4;
+    public static const int NSWindowExposedEventType = 0;
+    public static const int NSWindowMiniaturizeButton = 1;
+    public static const int NSWindowMovedEventType = 4;
+    public static const int NSWindowOut = 0;
+    public static const int NSWindowSharingNone = 0;
+    public static const int NSWindowSharingReadOnly = 1;
+    public static const int NSWindowSharingReadWrite = 2;
+    public static const int NSWindowToolbarButton = 3;
+    public static const int NSWindowZoomButton = 2;
+    public static const int NSWindows95InterfaceStyle = 2;
+    public static const int NSWorkspaceLaunchAllowingClassicStartup = 131072;
+    public static const int NSWorkspaceLaunchAndHide = 1048576;
+    public static const int NSWorkspaceLaunchAndHideOthers = 2097152;
+    public static const int NSWorkspaceLaunchAndPrint = 2;
+    public static const int NSWorkspaceLaunchAsync = 65536;
+    public static const int NSWorkspaceLaunchDefault = 196608;
+    public static const int NSWorkspaceLaunchInhibitingBackgroundOnly = 128;
+    public static const int NSWorkspaceLaunchNewInstance = 524288;
+    public static const int NSWorkspaceLaunchPreferringClassic = 262144;
+    public static const int NSWorkspaceLaunchWithoutActivation = 512;
+    public static const int NSWorkspaceLaunchWithoutAddingToRecents = 256;
+    public static const int NSWritingDirectionLeftToRight = 0;
+    public static const int NSWritingDirectionNatural = -1;
+    public static const int NSWritingDirectionRightToLeft = 1;
+    public static const int NSYearMonthDatePickerElementFlag = 192;
+    public static const int NSYearMonthDayDatePickerElementFlag = 224;
+    public static const int NSASCIIStringEncoding = 1;
+    public static const int NSAdminApplicationDirectory = 4;
+    public static const int NSAggregateExpressionType = 14;
+    public static const int NSAllApplicationsDirectory = 100;
+    public static const int NSAllDomainsMask = 65535;
+    public static const int NSAllLibrariesDirectory = 101;
+    public static const int NSAllPredicateModifier = 1;
+    public static const int NSAnchoredSearch = 8;
+    public static const int NSAndPredicateType = 1;
+    public static const int NSAnyPredicateModifier = 2;
+    public static const int NSApplicationDirectory = 1;
+    public static const int NSApplicationSupportDirectory = 14;
+    public static const int NSArgumentEvaluationScriptError = 3;
+    public static const int NSArgumentsWrongScriptError = 6;
+    public static const int NSAtomicWrite = 1;
+    public static const int NSBackwardsSearch = 4;
+    public static const int NSBeginsWithComparison = 5;
+    public static const int NSBeginsWithPredicateOperatorType = 8;
+    public static const int NSBetweenPredicateOperatorType = 100;
+    public static const int NSBundleExecutableArchitectureI386 = 7;
+    public static const int NSBundleExecutableArchitecturePPC = 18;
+    public static const int NSBundleExecutableArchitecturePPC64 = 16777234;
+    public static const int NSBundleExecutableArchitectureX86_64 = 16777223;
+    public static const int NSCachesDirectory = 13;
+    public static const int NSCalculationDivideByZero = 4;
+    public static const int NSCalculationLossOfPrecision = 1;
+    public static const int NSCalculationNoError = 0;
+    public static const int NSCalculationOverflow = 3;
+    public static const int NSCalculationUnderflow = 2;
+    public static const int NSCannotCreateScriptCommandError = 10;
+    public static const int NSCaseInsensitivePredicateOption = 1;
+    public static const int NSCaseInsensitiveSearch = 1;
+    public static const int NSCollectorDisabledOption = 2;
+    public static const int NSConstantValueExpressionType = 0;
+    public static const int NSContainerSpecifierError = 2;
+    public static const int NSContainsComparison = 7;
+    public static const int NSContainsPredicateOperatorType = 99;
+    public static const int NSCoreServiceDirectory = 10;
+    public static const int NSCustomSelectorPredicateOperatorType = 11;
+    public static const int NSDateFormatterBehavior10_0 = 1000;
+    public static const int NSDateFormatterBehavior10_4 = 1040;
+    public static const int NSDateFormatterBehaviorDefault = 0;
+    public static const int NSDateFormatterFullStyle = 4;
+    public static const int NSDateFormatterLongStyle = 3;
+    public static const int NSDateFormatterMediumStyle = 2;
+    public static const int NSDateFormatterNoStyle = 0;
+    public static const int NSDateFormatterShortStyle = 1;
+    public static const int NSDayCalendarUnit = 16;
+    public static const int NSDecimalMaxSize = 8;
+    public static const int NSDecimalNoScale = 32767;
+    public static const int NSDemoApplicationDirectory = 2;
+    public static const int NSDesktopDirectory = 12;
+    public static const int NSDeveloperApplicationDirectory = 3;
+    public static const int NSDeveloperDirectory = 6;
+    public static const int NSDiacriticInsensitivePredicateOption = 2;
+    public static const int NSDiacriticInsensitiveSearch = 128;
+    public static const int NSDirectPredicateModifier = 0;
+    public static const int NSDocumentDirectory = 9;
+    public static const int NSDocumentationDirectory = 8;
+    public static const int NSDownloadsDirectory = 15;
+    public static const int NSEndsWithComparison = 6;
+    public static const int NSEndsWithPredicateOperatorType = 9;
+    public static const int NSEqualToComparison = 0;
+    public static const int NSEqualToPredicateOperatorType = 4;
+    public static const int NSEraCalendarUnit = 2;
+    public static const int NSEvaluatedObjectExpressionType = 1;
+    public static const int NSEverySubelement = 1;
+    public static const int NSExecutableArchitectureMismatchError = 3585;
+    public static const int NSExecutableErrorMaximum = 3839;
+    public static const int NSExecutableErrorMinimum = 3584;
+    public static const int NSExecutableLinkError = 3588;
+    public static const int NSExecutableLoadError = 3587;
+    public static const int NSExecutableNotLoadableError = 3584;
+    public static const int NSExecutableRuntimeMismatchError = 3586;
+    public static const int NSFileErrorMaximum = 1023;
+    public static const int NSFileErrorMinimum = 0;
+    public static const int NSFileLockingError = 255;
+    public static const int NSFileNoSuchFileError = 4;
+    public static const int NSFileReadCorruptFileError = 259;
+    public static const int NSFileReadInapplicableStringEncodingError = 261;
+    public static const int NSFileReadInvalidFileNameError = 258;
+    public static const int NSFileReadNoPermissionError = 257;
+    public static const int NSFileReadNoSuchFileError = 260;
+    public static const int NSFileReadTooLargeError = 263;
+    public static const int NSFileReadUnknownError = 256;
+    public static const int NSFileReadUnknownStringEncodingError = 264;
+    public static const int NSFileReadUnsupportedSchemeError = 262;
+    public static const int NSFileWriteInapplicableStringEncodingError = 517;
+    public static const int NSFileWriteInvalidFileNameError = 514;
+    public static const int NSFileWriteNoPermissionError = 513;
+    public static const int NSFileWriteOutOfSpaceError = 640;
+    public static const int NSFileWriteUnknownError = 512;
+    public static const int NSFileWriteUnsupportedSchemeError = 518;
+    public static const int NSForcedOrderingSearch = 512;
+    public static const int NSFormattingError = 2048;
+    public static const int NSFormattingErrorMaximum = 2559;
+    public static const int NSFormattingErrorMinimum = 2048;
+    public static const double NSFoundationVersionNumber10_0 = 397.39999999999998;
+    public static const double NSFoundationVersionNumber10_1 = 425.00000000000000;
+    public static const double NSFoundationVersionNumber10_1_1 = 425.00000000000000;
+    public static const double NSFoundationVersionNumber10_1_2 = 425.00000000000000;
+    public static const double NSFoundationVersionNumber10_1_3 = 425.00000000000000;
+    public static const double NSFoundationVersionNumber10_1_4 = 425.00000000000000;
+    public static const double NSFoundationVersionNumber10_2 = 462.00000000000000;
+    public static const double NSFoundationVersionNumber10_2_1 = 462.00000000000000;
+    public static const double NSFoundationVersionNumber10_2_2 = 462.00000000000000;
+    public static const double NSFoundationVersionNumber10_2_3 = 462.00000000000000;
+    public static const double NSFoundationVersionNumber10_2_4 = 462.00000000000000;
+    public static const double NSFoundationVersionNumber10_2_5 = 462.00000000000000;
+    public static const double NSFoundationVersionNumber10_2_6 = 462.00000000000000;
+    public static const double NSFoundationVersionNumber10_2_7 = 462.69999999999999;
+    public static const double NSFoundationVersionNumber10_2_8 = 462.69999999999999;
+    public static const double NSFoundationVersionNumber10_3 = 500.00000000000000;
+    public static const double NSFoundationVersionNumber10_3_1 = 500.00000000000000;
+    public static const double NSFoundationVersionNumber10_3_2 = 500.30000000000001;
+    public static const double NSFoundationVersionNumber10_3_3 = 500.54000000000002;
+    public static const double NSFoundationVersionNumber10_3_4 = 500.56000000000000;
+    public static const double NSFoundationVersionNumber10_3_5 = 500.56000000000000;
+    public static const double NSFoundationVersionNumber10_3_6 = 500.56000000000000;
+    public static const double NSFoundationVersionNumber10_3_7 = 500.56000000000000;
+    public static const double NSFoundationVersionNumber10_3_8 = 500.56000000000000;
+    public static const double NSFoundationVersionNumber10_3_9 = 500.57999999999998;
+    public static const double NSFoundationVersionNumber10_4 = 567.00000000000000;
+    public static const double NSFoundationVersionNumber10_4_1 = 567.00000000000000;
+    public static const double NSFoundationVersionNumber10_4_10 = 567.28999999999996;
+    public static const double NSFoundationVersionNumber10_4_11 = 567.36000000000001;
+    public static const double NSFoundationVersionNumber10_4_2 = 567.12000000000000;
+    public static const double NSFoundationVersionNumber10_4_3 = 567.21000000000004;
+    public static const double NSFoundationVersionNumber10_4_4_Intel = 567.23000000000002;
+    public static const double NSFoundationVersionNumber10_4_4_PowerPC = 567.21000000000004;
+    public static const double NSFoundationVersionNumber10_4_5 = 567.25000000000000;
+    public static const double NSFoundationVersionNumber10_4_6 = 567.25999999999999;
+    public static const double NSFoundationVersionNumber10_4_7 = 567.26999999999998;
+    public static const double NSFoundationVersionNumber10_4_8 = 567.27999999999997;
+    public static const double NSFoundationVersionNumber10_4_9 = 567.28999999999996;
+    public static const int NSFoundationVersionWithFileManagerResourceForkSupport = 412;
+    public static const int NSFunctionExpressionType = 4;
+    public static const int NSGreaterThanComparison = 4;
+    public static const int NSGreaterThanOrEqualToComparison = 3;
+    public static const int NSGreaterThanOrEqualToPredicateOperatorType = 3;
+    public static const int NSGreaterThanPredicateOperatorType = 2;
+    public static const int NSHPUXOperatingSystem = 4;
+    public static const int NSHTTPCookieAcceptPolicyAlways = 0;
+    public static const int NSHTTPCookieAcceptPolicyNever = 1;
+    public static const int NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain = 2;
+    public static const int NSHashTableCopyIn = 65536;
+    public static const int NSHashTableObjectPointerPersonality = 512;
+    public static const int NSHashTableStrongMemory = 0;
+    public static const int NSHashTableZeroingWeakMemory = 1;
+    public static const int NSHourCalendarUnit = 32;
+    public static const int NSINTEGER_DEFINED = 1;
+    public static const int NSISO2022JPStringEncoding = 21;
+    public static const int NSISOLatin1StringEncoding = 5;
+    public static const int NSISOLatin2StringEncoding = 9;
+    public static const int NSInPredicateOperatorType = 10;
+    public static const int NSIndexSubelement = 0;
+    public static const int NSIntegerMax = 2147483647;
+    public static const int NSIntegerMin = -2147483648;
+    public static const int NSInternalScriptError = 8;
+    public static const int NSInternalSpecifierError = 5;
+    public static const int NSIntersectSetExpressionType = 6;
+    public static const int NSInvalidIndexSpecifierError = 4;
+    public static const int NSJapaneseEUCStringEncoding = 3;
+    public static const int NSKeyPathExpressionType = 3;
+    public static const int NSKeySpecifierEvaluationScriptError = 2;
+    public static const int NSKeyValueChangeInsertion = 2;
+    public static const int NSKeyValueChangeRemoval = 3;
+    public static const int NSKeyValueChangeReplacement = 4;
+    public static const int NSKeyValueChangeSetting = 1;
+    public static const int NSKeyValueIntersectSetMutation = 3;
+    public static const int NSKeyValueMinusSetMutation = 2;
+    public static const int NSKeyValueObservingOptionInitial = 4;
+    public static const int NSKeyValueObservingOptionNew = 1;
+    public static const int NSKeyValueObservingOptionOld = 2;
+    public static const int NSKeyValueObservingOptionPrior = 8;
+    public static const int NSKeyValueSetSetMutation = 4;
+    public static const int NSKeyValueUnionSetMutation = 1;
+    public static const int NSKeyValueValidationError = 1024;
+    public static const int NSLessThanComparison = 2;
+    public static const int NSLessThanOrEqualToComparison = 1;
+    public static const int NSLessThanOrEqualToPredicateOperatorType = 1;
+    public static const int NSLessThanPredicateOperatorType = 0;
+    public static const int NSLibraryDirectory = 5;
+    public static const int NSLikePredicateOperatorType = 7;
+    public static const int NSLiteralSearch = 2;
+    public static const int NSLocalDomainMask = 2;
+    public static const int NSMACHOperatingSystem = 5;
+    public static const int NSMacOSRomanStringEncoding = 30;
+    public static const int NSMachPortDeallocateNone = 0;
+    public static const int NSMachPortDeallocateReceiveRight = 2;
+    public static const int NSMachPortDeallocateSendRight = 1;
+    public static const int NSMapTableCopyIn = 65536;
+    public static const int NSMapTableObjectPointerPersonality = 512;
+    public static const int NSMapTableStrongMemory = 0;
+    public static const int NSMapTableZeroingWeakMemory = 1;
+    public static const int NSMappedRead = 1;
+    public static const int NSMatchesPredicateOperatorType = 6;
+    public static const int NSMaxXEdge = 2;
+    public static const int NSMaxYEdge = 3;
+    public static const int NSMiddleSubelement = 2;
+    public static const int NSMinXEdge = 0;
+    public static const int NSMinYEdge = 1;
+    public static const int NSMinusSetExpressionType = 7;
+    public static const int NSMinuteCalendarUnit = 64;
+    public static const int NSMonthCalendarUnit = 8;
+    public static const int NSNEXTSTEPStringEncoding = 2;
+    public static const int NSNetServiceNoAutoRename = 1;
+    public static const int NSNetServicesActivityInProgress = -72003;
+    public static const int NSNetServicesBadArgumentError = -72004;
+    public static const int NSNetServicesCancelledError = -72005;
+    public static const int NSNetServicesCollisionError = -72001;
+    public static const int NSNetServicesInvalidError = -72006;
+    public static const int NSNetServicesNotFoundError = -72002;
+    public static const int NSNetServicesTimeoutError = -72007;
+    public static const int NSNetServicesUnknownError = -72000;
+    public static const int NSNetworkDomainMask = 4;
+    public static const int NSNoScriptError = 0;
+    public static const int NSNoSpecifierError = 0;
+    public static const int NSNoSubelement = 4;
+    public static const int NSNoTopLevelContainersSpecifierError = 1;
+    public static const int NSNonLossyASCIIStringEncoding = 7;
+    public static const int NSNotEqualToPredicateOperatorType = 5;
+    public static const int NSNotFound = 2147483647;
+    public static const int NSNotPredicateType = 0;
+    public static const int NSNotificationCoalescingOnName = 1;
+    public static const int NSNotificationCoalescingOnSender = 2;
+    public static const int NSNotificationDeliverImmediately = 1;
+    public static const int NSNotificationNoCoalescing = 0;
+    public static const int NSNotificationPostToAllSessions = 2;
+    public static const int NSNotificationSuspensionBehaviorCoalesce = 2;
+    public static const int NSNotificationSuspensionBehaviorDeliverImmediately = 4;
+    public static const int NSNotificationSuspensionBehaviorDrop = 1;
+    public static const int NSNotificationSuspensionBehaviorHold = 3;
+    public static const int NSNumberFormatterBehavior10_0 = 1000;
+    public static const int NSNumberFormatterBehavior10_4 = 1040;
+    public static const int NSNumberFormatterBehaviorDefault = 0;
+    public static const int NSNumberFormatterCurrencyStyle = 2;
+    public static const int NSNumberFormatterDecimalStyle = 1;
+    public static const int NSNumberFormatterNoStyle = 0;
+    public static const int NSNumberFormatterPadAfterPrefix = 1;
+    public static const int NSNumberFormatterPadAfterSuffix = 3;
+    public static const int NSNumberFormatterPadBeforePrefix = 0;
+    public static const int NSNumberFormatterPadBeforeSuffix = 2;
+    public static const int NSNumberFormatterPercentStyle = 3;
+    public static const int NSNumberFormatterRoundCeiling = 0;
+    public static const int NSNumberFormatterRoundDown = 2;
+    public static const int NSNumberFormatterRoundFloor = 1;
+    public static const int NSNumberFormatterRoundHalfDown = 5;
+    public static const int NSNumberFormatterRoundHalfEven = 4;
+    public static const int NSNumberFormatterRoundHalfUp = 6;
+    public static const int NSNumberFormatterRoundUp = 3;
+    public static const int NSNumberFormatterScientificStyle = 4;
+    public static const int NSNumberFormatterSpellOutStyle = 5;
+    public static const int NSNumericSearch = 64;
+    public static const int NSOSF1OperatingSystem = 7;
+    public static const int NSObjCArrayType = 91;
+    public static const int NSObjCBitfield = 98;
+    public static const int NSObjCBoolType = 66;
+    public static const int NSObjCCharType = 99;
+    public static const int NSObjCDoubleType = 100;
+    public static const int NSObjCFloatType = 102;
+    public static const int NSObjCLongType = 108;
+    public static const int NSObjCLonglongType = 113;
+    public static const int NSObjCNoType = 0;
+    public static const int NSObjCObjectType = 64;
+    public static const int NSObjCPointerType = 94;
+    public static const int NSObjCSelectorType = 58;
+    public static const int NSObjCShortType = 115;
+    public static const int NSObjCStringType = 42;
+    public static const int NSObjCStructType = 123;
+    public static const int NSObjCUnionType = 40;
+    public static const int NSObjCVoidType = 118;
+    public static const int NSObjectAutoreleasedEvent = 3;
+    public static const int NSObjectExtraRefDecrementedEvent = 5;
+    public static const int NSObjectExtraRefIncrementedEvent = 4;
+    public static const int NSObjectInternalRefDecrementedEvent = 7;
+    public static const int NSObjectInternalRefIncrementedEvent = 6;
+    public static const int NSOpenStepUnicodeReservedBase = 62464;
+    public static const int NSOperationNotSupportedForKeyScriptError = 9;
+    public static const int NSOperationNotSupportedForKeySpecifierError = 6;
+    public static const int NSOperationQueueDefaultMaxConcurrentOperationCount = -1;
+    public static const int NSOperationQueuePriorityHigh = 4;
+    public static const int NSOperationQueuePriorityLow = -4;
+    public static const int NSOperationQueuePriorityNormal = 0;
+    public static const int NSOperationQueuePriorityVeryHigh = 8;
+    public static const int NSOperationQueuePriorityVeryLow = -8;
+    public static const int NSOrPredicateType = 2;
+    public static const int NSOrderedAscending = -1;
+    public static const int NSOrderedDescending = 1;
+    public static const int NSOrderedSame = 0;
+    public static const int NSPointerFunctionsCStringPersonality = 768;
+    public static const int NSPointerFunctionsCopyIn = 65536;
+    public static const int NSPointerFunctionsIntegerPersonality = 1280;
+    public static const int NSPointerFunctionsMachVirtualMemory = 4;
+    public static const int NSPointerFunctionsMallocMemory = 3;
+    public static const int NSPointerFunctionsObjectPersonality = 0;
+    public static const int NSPointerFunctionsObjectPointerPersonality = 512;
+    public static const int NSPointerFunctionsOpaqueMemory = 2;
+    public static const int NSPointerFunctionsOpaquePersonality = 256;
+    public static const int NSPointerFunctionsStrongMemory = 0;
+    public static const int NSPointerFunctionsStructPersonality = 1024;
+    public static const int NSPointerFunctionsZeroingWeakMemory = 1;
+    public static const int NSPositionAfter = 0;
+    public static const int NSPositionBefore = 1;
+    public static const int NSPositionBeginning = 2;
+    public static const int NSPositionEnd = 3;
+    public static const int NSPositionReplace = 4;
+    public static const int NSPostASAP = 2;
+    public static const int NSPostNow = 3;
+    public static const int NSPostWhenIdle = 1;
+    public static const int NSPropertyListBinaryFormat_v1_0 = 200;
+    public static const int NSPropertyListImmutable = 0;
+    public static const int NSPropertyListMutableContainers = 1;
+    public static const int NSPropertyListMutableContainersAndLeaves = 2;
+    public static const int NSPropertyListOpenStepFormat = 1;
+    public static const int NSPropertyListXMLFormat_v1_0 = 100;
+    public static const int NSRandomSubelement = 3;
+    public static const int NSReceiverEvaluationScriptError = 1;
+    public static const int NSReceiversCantHandleCommandScriptError = 4;
+    public static const int NSRelativeAfter = 0;
+    public static const int NSRelativeBefore = 1;
+    public static const int NSRequiredArgumentsMissingScriptError = 5;
+    public static const int NSRoundBankers = 3;
+    public static const int NSRoundDown = 1;
+    public static const int NSRoundPlain = 0;
+    public static const int NSRoundUp = 2;
+    public static const int NSSaveOptionsAsk = 2;
+    public static const int NSSaveOptionsNo = 1;
+    public static const int NSSaveOptionsYes = 0;
+    public static const int NSScannedOption = 1;
+    public static const int NSSecondCalendarUnit = 128;
+    public static const int NSShiftJISStringEncoding = 8;
+    public static const int NSSolarisOperatingSystem = 3;
+    public static const int NSStreamEventEndEncountered = 16;
+    public static const int NSStreamEventErrorOccurred = 8;
+    public static const int NSStreamEventHasBytesAvailable = 2;
+    public static const int NSStreamEventHasSpaceAvailable = 4;
+    public static const int NSStreamEventNone = 0;
+    public static const int NSStreamEventOpenCompleted = 1;
+    public static const int NSStreamStatusAtEnd = 5;
+    public static const int NSStreamStatusClosed = 6;
+    public static const int NSStreamStatusError = 7;
+    public static const int NSStreamStatusNotOpen = 0;
+    public static const int NSStreamStatusOpen = 2;
+    public static const int NSStreamStatusOpening = 1;
+    public static const int NSStreamStatusReading = 3;
+    public static const int NSStreamStatusWriting = 4;
+    public static const int NSStringEncodingConversionAllowLossy = 1;
+    public static const int NSStringEncodingConversionExternalRepresentation = 2;
+    public static const int NSSubqueryExpressionType = 13;
+    public static const int NSSunOSOperatingSystem = 6;
+    public static const int NSSymbolStringEncoding = 6;
+    public static const int NSSystemDomainMask = 8;
+    public static const double NSTimeIntervalSince1970 = 978307200.00000000;
+    public static const int NSTimeZoneNameStyleDaylightSaving = 2;
+    public static const int NSTimeZoneNameStyleShortDaylightSaving = 3;
+    public static const int NSTimeZoneNameStyleShortStandard = 1;
+    public static const int NSTimeZoneNameStyleStandard = 0;
+    public static const long NSUIntegerMax = 4294967295L;
+    public static const int NSURLCacheStorageAllowed = 0;
+    public static const int NSURLCacheStorageAllowedInMemoryOnly = 1;
+    public static const int NSURLCacheStorageNotAllowed = 2;
+    public static const int NSURLCredentialPersistenceForSession = 1;
+    public static const int NSURLCredentialPersistenceNone = 0;
+    public static const int NSURLCredentialPersistencePermanent = 2;
+    public static const int NSURLErrorBadServerResponse = -1011;
+    public static const int NSURLErrorBadURL = -1000;
+    public static const int NSURLErrorCancelled = -999;
+    public static const int NSURLErrorCannotCloseFile = -3002;
+    public static const int NSURLErrorCannotConnectToHost = -1004;
+    public static const int NSURLErrorCannotCreateFile = -3000;
+    public static const int NSURLErrorCannotDecodeContentData = -1016;
+    public static const int NSURLErrorCannotDecodeRawData = -1015;
+    public static const int NSURLErrorCannotFindHost = -1003;
+    public static const int NSURLErrorCannotLoadFromNetwork = -2000;
+    public static const int NSURLErrorCannotMoveFile = -3005;
+    public static const int NSURLErrorCannotOpenFile = -3001;
+    public static const int NSURLErrorCannotParseResponse = -1017;
+    public static const int NSURLErrorCannotRemoveFile = -3004;
+    public static const int NSURLErrorCannotWriteToFile = -3003;
+    public static const int NSURLErrorClientCertificateRejected = -1205;
+    public static const int NSURLErrorDNSLookupFailed = -1006;
+    public static const int NSURLErrorDataLengthExceedsMaximum = -1103;
+    public static const int NSURLErrorDownloadDecodingFailedMidStream = -3006;
+    public static const int NSURLErrorDownloadDecodingFailedToComplete = -3007;
+    public static const int NSURLErrorFileDoesNotExist = -1100;
+    public static const int NSURLErrorFileIsDirectory = -1101;
+    public static const int NSURLErrorHTTPTooManyRedirects = -1007;
+    public static const int NSURLErrorNetworkConnectionLost = -1005;
+    public static const int NSURLErrorNoPermissionsToReadFile = -1102;
+    public static const int NSURLErrorNotConnectedToInternet = -1009;
+    public static const int NSURLErrorRedirectToNonExistentLocation = -1010;
+    public static const int NSURLErrorResourceUnavailable = -1008;
+    public static const int NSURLErrorSecureConnectionFailed = -1200;
+    public static const int NSURLErrorServerCertificateHasBadDate = -1201;
+    public static const int NSURLErrorServerCertificateHasUnknownRoot = -1203;
+    public static const int NSURLErrorServerCertificateNotYetValid = -1204;
+    public static const int NSURLErrorServerCertificateUntrusted = -1202;
+    public static const int NSURLErrorTimedOut = -1001;
+    public static const int NSURLErrorUnknown = -1;
+    public static const int NSURLErrorUnsupportedURL = -1002;
+    public static const int NSURLErrorUserAuthenticationRequired = -1013;
+    public static const int NSURLErrorUserCancelledAuthentication = -1012;
+    public static const int NSURLErrorZeroByteResource = -1014;
+    public static const int NSURLHandleLoadFailed = 3;
+    public static const int NSURLHandleLoadInProgress = 2;
+    public static const int NSURLHandleLoadSucceeded = 1;
+    public static const int NSURLHandleNotLoaded = 0;
+    public static const int NSURLRequestReloadIgnoringCacheData = 1;
+    public static const int NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4;
+    public static const int NSURLRequestReloadIgnoringLocalCacheData = 1;
+    public static const int NSURLRequestReloadRevalidatingCacheData = 5;
+    public static const int NSURLRequestReturnCacheDataDontLoad = 3;
+    public static const int NSURLRequestReturnCacheDataElseLoad = 2;
+    public static const int NSURLRequestUseProtocolCachePolicy = 0;
+    public static const int NSUTF16BigEndianStringEncoding = -1879047936;
+    public static const int NSUTF16LittleEndianStringEncoding = -1811939072;
+    public static const int NSUTF16StringEncoding = 10;
+    public static const int NSUTF32BigEndianStringEncoding = -1744830208;
+    public static const int NSUTF32LittleEndianStringEncoding = -1677721344;
+    public static const int NSUTF32StringEncoding = -1946156800;
+    public static const int NSUTF8StringEncoding = 4;
+    public static const int NSUncachedRead = 2;
+    public static const int NSUndefinedDateComponent = 2147483647;
+    public static const int NSUndoCloseGroupingRunLoopOrdering = 350000;
+    public static const int NSUnicodeStringEncoding = 10;
+    public static const int NSUnionSetExpressionType = 5;
+    public static const int NSUnknownKeyScriptError = 7;
+    public static const int NSUnknownKeySpecifierError = 3;
+    public static const int NSUserCancelledError = 3072;
+    public static const int NSUserDirectory = 7;
+    public static const int NSUserDomainMask = 1;
+    public static const int NSValidationErrorMaximum = 2047;
+    public static const int NSValidationErrorMinimum = 1024;
+    public static const int NSVariableExpressionType = 2;
+    public static const int NSWeekCalendarUnit = 256;
+    public static const int NSWeekdayCalendarUnit = 512;
+    public static const int NSWeekdayOrdinalCalendarUnit = 1024;
+    public static const int NSWidthInsensitiveSearch = 256;
+    public static const int NSWindows95OperatingSystem = 2;
+    public static const int NSWindowsCP1250StringEncoding = 15;
+    public static const int NSWindowsCP1251StringEncoding = 11;
+    public static const int NSWindowsCP1252StringEncoding = 12;
+    public static const int NSWindowsCP1253StringEncoding = 13;
+    public static const int NSWindowsCP1254StringEncoding = 14;
+    public static const int NSWindowsNTOperatingSystem = 1;
+    public static const int NSWrapCalendarComponents = 1;
+    public static const int NSXMLAttributeCDATAKind = 6;
+    public static const int NSXMLAttributeDeclarationKind = 10;
+    public static const int NSXMLAttributeEntitiesKind = 11;
+    public static const int NSXMLAttributeEntityKind = 10;
+    public static const int NSXMLAttributeEnumerationKind = 14;
+    public static const int NSXMLAttributeIDKind = 7;
+    public static const int NSXMLAttributeIDRefKind = 8;
+    public static const int NSXMLAttributeIDRefsKind = 9;
+    public static const int NSXMLAttributeKind = 3;
+    public static const int NSXMLAttributeNMTokenKind = 12;
+    public static const int NSXMLAttributeNMTokensKind = 13;
+    public static const int NSXMLAttributeNotationKind = 15;
+    public static const int NSXMLCommentKind = 6;
+    public static const int NSXMLDTDKind = 8;
+    public static const int NSXMLDocumentHTMLKind = 2;
+    public static const int NSXMLDocumentIncludeContentTypeDeclaration = 262144;
+    public static const int NSXMLDocumentKind = 1;
+    public static const int NSXMLDocumentTextKind = 3;
+    public static const int NSXMLDocumentTidyHTML = 512;
+    public static const int NSXMLDocumentTidyXML = 1024;
+    public static const int NSXMLDocumentValidate = 8192;
+    public static const int NSXMLDocumentXHTMLKind = 1;
+    public static const int NSXMLDocumentXInclude = 65536;
+    public static const int NSXMLDocumentXMLKind = 0;
+    public static const int NSXMLElementDeclarationAnyKind = 18;
+    public static const int NSXMLElementDeclarationElementKind = 20;
+    public static const int NSXMLElementDeclarationEmptyKind = 17;
+    public static const int NSXMLElementDeclarationKind = 11;
+    public static const int NSXMLElementDeclarationMixedKind = 19;
+    public static const int NSXMLElementDeclarationUndefinedKind = 16;
+    public static const int NSXMLElementKind = 2;
+    public static const int NSXMLEntityDeclarationKind = 9;
+    public static const int NSXMLEntityGeneralKind = 1;
+    public static const int NSXMLEntityParameterKind = 4;
+    public static const int NSXMLEntityParsedKind = 2;
+    public static const int NSXMLEntityPredefined = 5;
+    public static const int NSXMLEntityUnparsedKind = 3;
+    public static const int NSXMLInvalidKind = 0;
+    public static const int NSXMLNamespaceKind = 4;
+    public static const int NSXMLNodeCompactEmptyElement = 4;
+    public static const int NSXMLNodeExpandEmptyElement = 2;
+    public static const int NSXMLNodeIsCDATA = 1;
+    public static const int NSXMLNodeOptionsNone = 0;
+    public static const int NSXMLNodePreserveAll = -1048546;
+    public static const int NSXMLNodePreserveAttributeOrder = 2097152;
+    public static const int NSXMLNodePreserveCDATA = 16777216;
+    public static const int NSXMLNodePreserveCharacterReferences = 134217728;
+    public static const int NSXMLNodePreserveDTD = 67108864;
+    public static const int NSXMLNodePreserveEmptyElements = 6;
+    public static const int NSXMLNodePreserveEntities = 4194304;
+    public static const int NSXMLNodePreserveNamespaceOrder = 1048576;
+    public static const int NSXMLNodePreservePrefixes = 8388608;
+    public static const int NSXMLNodePreserveQuotes = 24;
+    public static const int NSXMLNodePreserveWhitespace = 33554432;
+    public static const int NSXMLNodePrettyPrint = 131072;
+    public static const int NSXMLNodeUseDoubleQuotes = 16;
+    public static const int NSXMLNodeUseSingleQuotes = 8;
+    public static const int NSXMLNotationDeclarationKind = 12;
+    public static const int NSXMLParserAttributeHasNoValueError = 41;
+    public static const int NSXMLParserAttributeListNotFinishedError = 51;
+    public static const int NSXMLParserAttributeListNotStartedError = 50;
+    public static const int NSXMLParserAttributeNotFinishedError = 40;
+    public static const int NSXMLParserAttributeNotStartedError = 39;
+    public static const int NSXMLParserAttributeRedefinedError = 42;
+    public static const int NSXMLParserCDATANotFinishedError = 63;
+    public static const int NSXMLParserCharacterRefAtEOFError = 10;
+    public static const int NSXMLParserCharacterRefInDTDError = 13;
+    public static const int NSXMLParserCharacterRefInEpilogError = 12;
+    public static const int NSXMLParserCharacterRefInPrologError = 11;
+    public static const int NSXMLParserCommentContainsDoubleHyphenError = 80;
+    public static const int NSXMLParserCommentNotFinishedError = 45;
+    public static const int NSXMLParserConditionalSectionNotFinishedError = 59;
+    public static const int NSXMLParserConditionalSectionNotStartedError = 58;
+    public static const int NSXMLParserDOCTYPEDeclNotFinishedError = 61;
+    public static const int NSXMLParserDelegateAbortedParseError = 512;
+    public static const int NSXMLParserDocumentStartError = 3;
+    public static const int NSXMLParserElementContentDeclNotFinishedError = 55;
+    public static const int NSXMLParserElementContentDeclNotStartedError = 54;
+    public static const int NSXMLParserEmptyDocumentError = 4;
+    public static const int NSXMLParserEncodingNotSupportedError = 32;
+    public static const int NSXMLParserEntityBoundaryError = 90;
+    public static const int NSXMLParserEntityIsExternalError = 29;
+    public static const int NSXMLParserEntityIsParameterError = 30;
+    public static const int NSXMLParserEntityNotFinishedError = 37;
+    public static const int NSXMLParserEntityNotStartedError = 36;
+    public static const int NSXMLParserEntityRefAtEOFError = 14;
+    public static const int NSXMLParserEntityRefInDTDError = 17;
+    public static const int NSXMLParserEntityRefInEpilogError = 16;
+    public static const int NSXMLParserEntityRefInPrologError = 15;
+    public static const int NSXMLParserEntityRefLoopError = 89;
+    public static const int NSXMLParserEntityReferenceMissingSemiError = 23;
+    public static const int NSXMLParserEntityReferenceWithoutNameError = 22;
+    public static const int NSXMLParserEntityValueRequiredError = 84;
+    public static const int NSXMLParserEqualExpectedError = 75;
+    public static const int NSXMLParserExternalStandaloneEntityError = 82;
+    public static const int NSXMLParserExternalSubsetNotFinishedError = 60;
+    public static const int NSXMLParserExtraContentError = 86;
+    public static const int NSXMLParserGTRequiredError = 73;
+    public static const int NSXMLParserInternalError = 1;
+    public static const int NSXMLParserInvalidCharacterError = 9;
+    public static const int NSXMLParserInvalidCharacterInEntityError = 87;
+    public static const int NSXMLParserInvalidCharacterRefError = 8;
+    public static const int NSXMLParserInvalidConditionalSectionError = 83;
+    public static const int NSXMLParserInvalidDecimalCharacterRefError = 7;
+    public static const int NSXMLParserInvalidEncodingError = 81;
+    public static const int NSXMLParserInvalidEncodingNameError = 79;
+    public static const int NSXMLParserInvalidHexCharacterRefError = 6;
+    public static const int NSXMLParserInvalidURIError = 91;
+    public static const int NSXMLParserLTRequiredError = 72;
+    public static const int NSXMLParserLTSlashRequiredError = 74;
+    public static const int NSXMLParserLessThanSymbolInAttributeError = 38;
+    public static const int NSXMLParserLiteralNotFinishedError = 44;
+    public static const int NSXMLParserLiteralNotStartedError = 43;
+    public static const int NSXMLParserMisplacedCDATAEndStringError = 62;
+    public static const int NSXMLParserMisplacedXMLDeclarationError = 64;
+    public static const int NSXMLParserMixedContentDeclNotFinishedError = 53;
+    public static const int NSXMLParserMixedContentDeclNotStartedError = 52;
+    public static const int NSXMLParserNAMERequiredError = 68;
+    public static const int NSXMLParserNMTOKENRequiredError = 67;
+    public static const int NSXMLParserNamespaceDeclarationError = 35;
+    public static const int NSXMLParserNoDTDError = 94;
+    public static const int NSXMLParserNotWellBalancedError = 85;
+    public static const int NSXMLParserNotationNotFinishedError = 49;
+    public static const int NSXMLParserNotationNotStartedError = 48;
+    public static const int NSXMLParserOutOfMemoryError = 2;
+    public static const int NSXMLParserPCDATARequiredError = 69;
+    public static const int NSXMLParserParsedEntityRefAtEOFError = 18;
+    public static const int NSXMLParserParsedEntityRefInEpilogError = 20;
+    public static const int NSXMLParserParsedEntityRefInInternalError = 88;
+    public static const int NSXMLParserParsedEntityRefInInternalSubsetError = 21;
+    public static const int NSXMLParserParsedEntityRefInPrologError = 19;
+    public static const int NSXMLParserParsedEntityRefMissingSemiError = 25;
+    public static const int NSXMLParserParsedEntityRefNoNameError = 24;
+    public static const int NSXMLParserPrematureDocumentEndError = 5;
+    public static const int NSXMLParserProcessingInstructionNotFinishedError = 47;
+    public static const int NSXMLParserProcessingInstructionNotStartedError = 46;
+    public static const int NSXMLParserPublicIdentifierRequiredError = 71;
+    public static const int NSXMLParserSeparatorRequiredError = 66;
+    public static const int NSXMLParserSpaceRequiredError = 65;
+    public static const int NSXMLParserStandaloneValueError = 78;
+    public static const int NSXMLParserStringNotClosedError = 34;
+    public static const int NSXMLParserStringNotStartedError = 33;
+    public static const int NSXMLParserTagNameMismatchError = 76;
+    public static const int NSXMLParserURIFragmentError = 92;
+    public static const int NSXMLParserURIRequiredError = 70;
+    public static const int NSXMLParserUndeclaredEntityError = 26;
+    public static const int NSXMLParserUnfinishedTagError = 77;
+    public static const int NSXMLParserUnknownEncodingError = 31;
+    public static const int NSXMLParserUnparsedEntityError = 28;
+    public static const int NSXMLParserXMLDeclNotFinishedError = 57;
+    public static const int NSXMLParserXMLDeclNotStartedError = 56;
+    public static const int NSXMLProcessingInstructionKind = 5;
+    public static const int NSXMLTextKind = 7;
+    public static const int NSYearCalendarUnit = 4;
+    public static const int NS_BigEndian = 2;
+    public static const int NS_LittleEndian = 1;
+    public static const int NS_UNICHAR_IS_EIGHT_BIT = 0;
+    public static const int NS_UnknownByteOrder = 0;
+    public static const int DOM_ADDITION = 2;
+    public static const int DOM_ANY_TYPE = 0;
+    public static const int DOM_ANY_UNORDERED_NODE_TYPE = 8;
+    public static const int DOM_ATTRIBUTE_NODE = 2;
+    public static const int DOM_AT_TARGET = 2;
+    public static const int DOM_BAD_BOUNDARYPOINTS_ERR = 1;
+    public static const int DOM_BOOLEAN_TYPE = 3;
+    public static const int DOM_BOTH = 2;
+    public static const int DOM_BUBBLING_PHASE = 3;
+    public static const int DOM_CAPTURING_PHASE = 1;
+    public static const int DOM_CDATA_SECTION_NODE = 4;
+    public static const int DOM_CHARSET_RULE = 2;
+    public static const int DOM_COMMENT_NODE = 8;
+    public static const int DOM_CSS_ATTR = 22;
+    public static const int DOM_CSS_CM = 6;
+    public static const int DOM_CSS_COUNTER = 23;
+    public static const int DOM_CSS_CUSTOM = 3;
+    public static const int DOM_CSS_DEG = 11;
+    public static const int DOM_CSS_DIMENSION = 18;
+    public static const int DOM_CSS_EMS = 3;
+    public static const int DOM_CSS_EXS = 4;
+    public static const int DOM_CSS_GRAD = 13;
+    public static const int DOM_CSS_HZ = 16;
+    public static const int DOM_CSS_IDENT = 21;
+    public static const int DOM_CSS_IN = 8;
+    public static const int DOM_CSS_INHERIT = 0;
+    public static const int DOM_CSS_KHZ = 17;
+    public static const int DOM_CSS_MM = 7;
+    public static const int DOM_CSS_MS = 14;
+    public static const int DOM_CSS_NUMBER = 1;
+    public static const int DOM_CSS_PC = 10;
+    public static const int DOM_CSS_PERCENTAGE = 2;
+    public static const int DOM_CSS_PRIMITIVE_VALUE = 1;
+    public static const int DOM_CSS_PT = 9;
+    public static const int DOM_CSS_PX = 5;
+    public static const int DOM_CSS_RAD = 12;
+    public static const int DOM_CSS_RECT = 24;
+    public static const int DOM_CSS_RGBCOLOR = 25;
+    public static const int DOM_CSS_S = 15;
+    public static const int DOM_CSS_STRING = 19;
+    public static const int DOM_CSS_UNKNOWN = 0;
+    public static const int DOM_CSS_URI = 20;
+    public static const int DOM_CSS_VALUE_LIST = 2;
+    public static const int DOM_DOCUMENT_FRAGMENT_NODE = 11;
+    public static const int DOM_DOCUMENT_NODE = 9;
+    public static const int DOM_DOCUMENT_TYPE_NODE = 10;
+    public static const int DOM_DOMSTRING_SIZE_ERR = 2;
+    public static const int DOM_ELEMENT_NODE = 1;
+    public static const int DOM_END_TO_END = 2;
+    public static const int DOM_END_TO_START = 3;
+    public static const int DOM_ENTITY_NODE = 6;
+    public static const int DOM_ENTITY_REFERENCE_NODE = 5;
+    public static const int DOM_FILTER_ACCEPT = 1;
+    public static const int DOM_FILTER_REJECT = 2;
+    public static const int DOM_FILTER_SKIP = 3;
+    public static const int DOM_FIRST_ORDERED_NODE_TYPE = 9;
+    public static const int DOM_FONT_FACE_RULE = 5;
+    public static const int DOM_HIERARCHY_REQUEST_ERR = 3;
+    public static const int DOM_HORIZONTAL = 0;
+    public static const int DOM_IMPORT_RULE = 3;
+    public static const int DOM_INDEX_SIZE_ERR = 1;
+    public static const int DOM_INUSE_ATTRIBUTE_ERR = 10;
+    public static const int DOM_INVALID_ACCESS_ERR = 15;
+    public static const int DOM_INVALID_CHARACTER_ERR = 5;
+    public static const int DOM_INVALID_EXPRESSION_ERR = 51;
+    public static const int DOM_INVALID_MODIFICATION_ERR = 13;
+    public static const int DOM_INVALID_NODE_TYPE_ERR = 2;
+    public static const int DOM_INVALID_STATE_ERR = 11;
+    public static const int DOM_KEY_LOCATION_LEFT = 1;
+    public static const int DOM_KEY_LOCATION_NUMPAD = 3;
+    public static const int DOM_KEY_LOCATION_RIGHT = 2;
+    public static const int DOM_KEY_LOCATION_STANDARD = 0;
+    public static const int DOM_MEDIA_RULE = 4;
+    public static const int DOM_MODIFICATION = 1;
+    public static const int DOM_NAMESPACE_ERR = 14;
+    public static const int DOM_NODE_AFTER = 1;
+    public static const int DOM_NODE_BEFORE = 0;
+    public static const int DOM_NODE_BEFORE_AND_AFTER = 2;
+    public static const int DOM_NODE_INSIDE = 3;
+    public static const int DOM_NOTATION_NODE = 12;
+    public static const int DOM_NOT_FOUND_ERR = 8;
+    public static const int DOM_NOT_SUPPORTED_ERR = 9;
+    public static const int DOM_NO_DATA_ALLOWED_ERR = 6;
+    public static const int DOM_NO_MODIFICATION_ALLOWED_ERR = 7;
+    public static const int DOM_NUMBER_TYPE = 1;
+    public static const int DOM_ORDERED_NODE_ITERATOR_TYPE = 5;
+    public static const int DOM_ORDERED_NODE_SNAPSHOT_TYPE = 7;
+    public static const int DOM_PAGE_RULE = 6;
+    public static const int DOM_PROCESSING_INSTRUCTION_NODE = 7;
+    public static const int DOM_REMOVAL = 3;
+    public static const int DOM_SHOW_ALL = -1;
+    public static const int DOM_SHOW_ATTRIBUTE = 2;
+    public static const int DOM_SHOW_CDATA_SECTION = 8;
+    public static const int DOM_SHOW_COMMENT = 128;
+    public static const int DOM_SHOW_DOCUMENT = 256;
+    public static const int DOM_SHOW_DOCUMENT_FRAGMENT = 1024;
+    public static const int DOM_SHOW_DOCUMENT_TYPE = 512;
+    public static const int DOM_SHOW_ELEMENT = 1;
+    public static const int DOM_SHOW_ENTITY = 32;
+    public static const int DOM_SHOW_ENTITY_REFERENCE = 16;
+    public static const int DOM_SHOW_NOTATION = 2048;
+    public static const int DOM_SHOW_PROCESSING_INSTRUCTION = 64;
+    public static const int DOM_SHOW_TEXT = 4;
+    public static const int DOM_START_TO_END = 1;
+    public static const int DOM_START_TO_START = 0;
+    public static const int DOM_STRING_TYPE = 2;
+    public static const int DOM_STYLE_RULE = 1;
+    public static const int DOM_SYNTAX_ERR = 12;
+    public static const int DOM_TEXT_NODE = 3;
+    public static const int DOM_TYPE_ERR = 52;
+    public static const int DOM_UNKNOWN_RULE = 0;
+    public static const int DOM_UNORDERED_NODE_ITERATOR_TYPE = 4;
+    public static const int DOM_UNORDERED_NODE_SNAPSHOT_TYPE = 6;
+    public static const int DOM_UNSPECIFIED_EVENT_TYPE_ERR = 0;
+    public static const int DOM_VERTICAL = 1;
+    public static const int DOM_WRONG_DOCUMENT_ERR = 4;
+    public static const int WebCacheModelDocumentBrowser = 1;
+    public static const int WebCacheModelDocumentViewer = 0;
+    public static const int WebCacheModelPrimaryWebBrowser = 2;
+    public static const int WebDragDestinationActionAny = -1;
+    public static const int WebDragDestinationActionDHTML = 1;
+    public static const int WebDragDestinationActionEdit = 2;
+    public static const int WebDragDestinationActionLoad = 4;
+    public static const int WebDragDestinationActionNone = 0;
+    public static const int WebDragSourceActionAny = -1;
+    public static const int WebDragSourceActionDHTML = 1;
+    public static const int WebDragSourceActionImage = 2;
+    public static const int WebDragSourceActionLink = 4;
+    public static const int WebDragSourceActionNone = 0;
+    public static const int WebDragSourceActionSelection = 8;
+    public static const int WebJNIReturnTypeBoolean = 3;
+    public static const int WebJNIReturnTypeByte = 4;
+    public static const int WebJNIReturnTypeChar = 5;
+    public static const int WebJNIReturnTypeDouble = 10;
+    public static const int WebJNIReturnTypeFloat = 9;
+    public static const int WebJNIReturnTypeInt = 7;
+    public static const int WebJNIReturnTypeInvalid = 0;
+    public static const int WebJNIReturnTypeLong = 8;
+    public static const int WebJNIReturnTypeObject = 2;
+    public static const int WebJNIReturnTypeShort = 6;
+    public static const int WebJNIReturnTypeVoid = 1;
+    public static const int WebKitErrorCannotFindPlugIn = 200;
+    public static const int WebKitErrorCannotLoadPlugIn = 201;
+    public static const int WebKitErrorCannotShowMIMEType = 100;
+    public static const int WebKitErrorCannotShowURL = 101;
+    public static const int WebKitErrorFrameLoadInterruptedByPolicyChange = 102;
+    public static const int WebKitErrorJavaUnavailable = 202;
+    public static const int WebMenuItemPDFActualSize = 24;
+    public static const int WebMenuItemPDFAutoSize = 27;
+    public static const int WebMenuItemPDFContinuous = 30;
+    public static const int WebMenuItemPDFFacingPages = 29;
+    public static const int WebMenuItemPDFNextPage = 31;
+    public static const int WebMenuItemPDFPreviousPage = 32;
+    public static const int WebMenuItemPDFSinglePage = 28;
+    public static const int WebMenuItemPDFZoomIn = 25;
+    public static const int WebMenuItemPDFZoomOut = 26;
+    public static const int WebMenuItemTagCopy = 8;
+    public static const int WebMenuItemTagCopyImageToClipboard = 6;
+    public static const int WebMenuItemTagCopyLinkToClipboard = 3;
+    public static const int WebMenuItemTagCut = 13;
+    public static const int WebMenuItemTagDownloadImageToDisk = 5;
+    public static const int WebMenuItemTagDownloadLinkToDisk = 2;
+    public static const int WebMenuItemTagGoBack = 9;
+    public static const int WebMenuItemTagGoForward = 10;
+    public static const int WebMenuItemTagIgnoreSpelling = 17;
+    public static const int WebMenuItemTagLearnSpelling = 18;
+    public static const int WebMenuItemTagLookUpInDictionary = 22;
+    public static const int WebMenuItemTagNoGuessesFound = 16;
+    public static const int WebMenuItemTagOpenFrameInNewWindow = 7;
+    public static const int WebMenuItemTagOpenImageInNewWindow = 4;
+    public static const int WebMenuItemTagOpenLinkInNewWindow = 1;
+    public static const int WebMenuItemTagOpenWithDefaultApplication = 23;
+    public static const int WebMenuItemTagOther = 19;
+    public static const int WebMenuItemTagPaste = 14;
+    public static const int WebMenuItemTagReload = 12;
+    public static const int WebMenuItemTagSearchInSpotlight = 20;
+    public static const int WebMenuItemTagSearchWeb = 21;
+    public static const int WebMenuItemTagSpellingGuess = 15;
+    public static const int WebMenuItemTagStop = 11;
+    public static const int WebNavigationTypeBackForward = 2;
+    public static const int WebNavigationTypeFormResubmitted = 4;
+    public static const int WebNavigationTypeFormSubmitted = 1;
+    public static const int WebNavigationTypeLinkClicked = 0;
+    public static const int WebNavigationTypeOther = 5;
+    public static const int WebNavigationTypeReload = 3;
+    public static const int WebViewInsertActionDropped = 2;
+    public static const int WebViewInsertActionPasted = 1;
+    public static const int WebViewInsertActionTyped = 0;
+
+
+    /** Globals */
+//  public static const native int NSAbortModalException();
+//  public static const native int NSAbortPrintingException();
+//  public static const native int NSAccessibilityAllowedValuesAttribute();
+//  public static const native int NSAccessibilityApplicationActivatedNotification();
+//  public static const native int NSAccessibilityApplicationDeactivatedNotification();
+//  public static const native int NSAccessibilityApplicationHiddenNotification();
+//  public static const native int NSAccessibilityApplicationRole();
+//  public static const native int NSAccessibilityApplicationShownNotification();
+//  public static const native int NSAccessibilityAscendingSortDirectionValue();
+//  public static const native int NSAccessibilityAttachmentTextAttribute();
+//  public static const native int NSAccessibilityAttributedStringForRangeParameterizedAttribute();
+//  public static const native int NSAccessibilityBackgroundColorTextAttribute();
+//  public static const native int NSAccessibilityBoundsForRangeParameterizedAttribute();
+//  public static const native int NSAccessibilityBrowserRole();
+//  public static const native int NSAccessibilityBusyIndicatorRole();
+//  public static const native int NSAccessibilityButtonRole();
+//  public static const native int NSAccessibilityCancelAction();
+//  public static const native int NSAccessibilityCancelButtonAttribute();
+//  public static const native int NSAccessibilityCenterTabStopMarkerTypeValue();
+//  public static const native int NSAccessibilityCentimetersUnitValue();
+//  public static const native int NSAccessibilityCheckBoxRole();
+//  public static const native int NSAccessibilityChildrenAttribute();
+//  public static const native int NSAccessibilityClearButtonAttribute();
+//  public static const native int NSAccessibilityCloseButtonAttribute();
+//  public static const native int NSAccessibilityCloseButtonSubrole();
+//  public static const native int NSAccessibilityColorWellRole();
+//  public static const native int NSAccessibilityColumnCountAttribute();
+//  public static const native int NSAccessibilityColumnRole();
+//  public static const native int NSAccessibilityColumnTitlesAttribute();
+//  public static const native int NSAccessibilityColumnsAttribute();
+//  public static const native int NSAccessibilityComboBoxRole();
+//  public static const native int NSAccessibilityConfirmAction();
+//  public static const native int NSAccessibilityContentsAttribute();
+//  public static const native int NSAccessibilityCreatedNotification();
+//  public static const native int NSAccessibilityDecimalTabStopMarkerTypeValue();
+//  public static const native int NSAccessibilityDecrementAction();
+//  public static const native int NSAccessibilityDecrementArrowSubrole();
+//  public static const native int NSAccessibilityDecrementButtonAttribute();
+//  public static const native int NSAccessibilityDecrementPageSubrole();
+//  public static const native int NSAccessibilityDefaultButtonAttribute();
+//  public static const native int NSAccessibilityDeleteAction();
+//  public static const native int NSAccessibilityDescendingSortDirectionValue();
+//  public static const native int NSAccessibilityDescriptionAttribute();
+//  public static const native int NSAccessibilityDialogSubrole();
+//  public static const native int NSAccessibilityDisclosedByRowAttribute();
+//  public static const native int NSAccessibilityDisclosedRowsAttribute();
+//  public static const native int NSAccessibilityDisclosingAttribute();
+//  public static const native int NSAccessibilityDisclosureLevelAttribute();
+//  public static const native int NSAccessibilityDisclosureTriangleRole();
+//  public static const native int NSAccessibilityDocumentAttribute();
+//  public static const native int NSAccessibilityDrawerCreatedNotification();
+//  public static const native int NSAccessibilityDrawerRole();
+//  public static const native int NSAccessibilityEditedAttribute();
+//  public static const native int NSAccessibilityEnabledAttribute();
+//  public static const native int NSAccessibilityErrorCodeExceptionInfo();
+//  public static const native int NSAccessibilityException();
+//  public static const native int NSAccessibilityExpandedAttribute();
+//  public static const native int NSAccessibilityFilenameAttribute();
+//  public static const native int NSAccessibilityFirstLineIndentMarkerTypeValue();
+//  public static const native int NSAccessibilityFloatingWindowSubrole();
+//  public static const native int NSAccessibilityFocusedAttribute();
+//  public static const native int NSAccessibilityFocusedUIElementAttribute();
+//  public static const native int NSAccessibilityFocusedUIElementChangedNotification();
+//  public static const native int NSAccessibilityFocusedWindowAttribute();
+//  public static const native int NSAccessibilityFocusedWindowChangedNotification();
+//  public static const native int NSAccessibilityFontFamilyKey();
+//  public static const native int NSAccessibilityFontNameKey();
+//  public static const native int NSAccessibilityFontSizeKey();
+//  public static const native int NSAccessibilityFontTextAttribute();
+//  public static const native int NSAccessibilityForegroundColorTextAttribute();
+//  public static const native int NSAccessibilityFrontmostAttribute();
+//  public static const native int NSAccessibilityGridRole();
+//  public static const native int NSAccessibilityGroupRole();
+//  public static const native int NSAccessibilityGrowAreaAttribute();
+//  public static const native int NSAccessibilityGrowAreaRole();
+//  public static const native int NSAccessibilityHeadIndentMarkerTypeValue();
+//  public static const native int NSAccessibilityHeaderAttribute();
+//  public static const native int NSAccessibilityHelpAttribute();
+//  public static const native int NSAccessibilityHelpTagCreatedNotification();
+//  public static const native int NSAccessibilityHelpTagRole();
+//  public static const native int NSAccessibilityHiddenAttribute();
+//  public static const native int NSAccessibilityHorizontalOrientationValue();
+//  public static const native int NSAccessibilityHorizontalScrollBarAttribute();
+//  public static const native int NSAccessibilityImageRole();
+//  public static const native int NSAccessibilityInchesUnitValue();
+//  public static const native int NSAccessibilityIncrementAction();
+//  public static const native int NSAccessibilityIncrementArrowSubrole();
+//  public static const native int NSAccessibilityIncrementButtonAttribute();
+//  public static const native int NSAccessibilityIncrementPageSubrole();
+//  public static const native int NSAccessibilityIncrementorRole();
+//  public static const native int NSAccessibilityIndexAttribute();
+//  public static const native int NSAccessibilityInsertionPointLineNumberAttribute();
+//  public static const native int NSAccessibilityLabelUIElementsAttribute();
+//  public static const native int NSAccessibilityLabelValueAttribute();
+//  public static const native int NSAccessibilityLeftTabStopMarkerTypeValue();
+//  public static const native int NSAccessibilityLineForIndexParameterizedAttribute();
+//  public static const native int NSAccessibilityLinkRole();
+//  public static const native int NSAccessibilityLinkTextAttribute();
+//  public static const native int NSAccessibilityLinkedUIElementsAttribute();
+//  public static const native int NSAccessibilityListRole();
+//  public static const native int NSAccessibilityMainAttribute();
+//  public static const native int NSAccessibilityMainWindowAttribute();
+//  public static const native int NSAccessibilityMainWindowChangedNotification();
+//  public static const native int NSAccessibilityMarkerGroupUIElementAttribute();
+//  public static const native int NSAccessibilityMarkerTypeAttribute();
+//  public static const native int NSAccessibilityMarkerTypeDescriptionAttribute();
+//  public static const native int NSAccessibilityMarkerUIElementsAttribute();
+//  public static const native int NSAccessibilityMarkerValuesAttribute();
+//  public static const native int NSAccessibilityMatteContentUIElementAttribute();
+//  public static const native int NSAccessibilityMatteHoleAttribute();
+//  public static const native int NSAccessibilityMatteRole();
+//  public static const native int NSAccessibilityMaxValueAttribute();
+//  public static const native int NSAccessibilityMenuBarAttribute();
+//  public static const native int NSAccessibilityMenuBarRole();
+//  public static const native int NSAccessibilityMenuButtonRole();
+//  public static const native int NSAccessibilityMenuItemRole();
+//  public static const native int NSAccessibilityMenuRole();
+//  public static const native int NSAccessibilityMinValueAttribute();
+//  public static const native int NSAccessibilityMinimizeButtonAttribute();
+//  public static const native int NSAccessibilityMinimizeButtonSubrole();
+//  public static const native int NSAccessibilityMinimizedAttribute();
+//  public static const native int NSAccessibilityMisspelledTextAttribute();
+//  public static const native int NSAccessibilityModalAttribute();
+//  public static const native int NSAccessibilityMovedNotification();
+//  public static const native int NSAccessibilityNextContentsAttribute();
+//  public static const native int NSAccessibilityNumberOfCharactersAttribute();
+//  public static const native int NSAccessibilityOrderedByRowAttribute();
+//  public static const native int NSAccessibilityOrientationAttribute();
+//  public static const native int NSAccessibilityOutlineRole();
+//  public static const native int NSAccessibilityOutlineRowSubrole();
+//  public static const native int NSAccessibilityOverflowButtonAttribute();
+//  public static const native int NSAccessibilityParentAttribute();
+//  public static const native int NSAccessibilityPicasUnitValue();
+//  public static const native int NSAccessibilityPickAction();
+//  public static const native int NSAccessibilityPointsUnitValue();
+//  public static const native int NSAccessibilityPopUpButtonRole();
+//  public static const native int NSAccessibilityPositionAttribute(); commented by Jacob Carlborg
+//  public static const native int NSAccessibilityPressAction();
+//  public static const native int NSAccessibilityPreviousContentsAttribute();
+//  public static const native int NSAccessibilityProgressIndicatorRole();
+//  public static const native int NSAccessibilityProxyAttribute();
+//  public static const native int NSAccessibilityRTFForRangeParameterizedAttribute();
+//  public static const native int NSAccessibilityRadioButtonRole();
+//  public static const native int NSAccessibilityRadioGroupRole();
+//  public static const native int NSAccessibilityRaiseAction();
+//  public static const native int NSAccessibilityRangeForIndexParameterizedAttribute();
+//  public static const native int NSAccessibilityRangeForLineParameterizedAttribute();
+//  public static const native int NSAccessibilityRangeForPositionParameterizedAttribute();
+//  public static const native int NSAccessibilityResizedNotification();
+//  public static const native int NSAccessibilityRightTabStopMarkerTypeValue();
+//  public static const native int NSAccessibilityRoleAttribute();
+//  public static const native int NSAccessibilityRoleDescriptionAttribute();
+//  public static const native int NSAccessibilityRowCountAttribute();
+//  public static const native int NSAccessibilityRowCountChangedNotification();
+//  public static const native int NSAccessibilityRowRole();
+//  public static const native int NSAccessibilityRowsAttribute();
+//  public static const native int NSAccessibilityRulerMarkerRole();
+//  public static const native int NSAccessibilityRulerRole();
+//  public static const native int NSAccessibilityScrollAreaRole();
+//  public static const native int NSAccessibilityScrollBarRole();
+//  public static const native int NSAccessibilitySearchButtonAttribute();
+//  public static const native int NSAccessibilitySearchFieldSubrole();
+//  public static const native int NSAccessibilitySearchMenuAttribute();
+//  public static const native int NSAccessibilitySecureTextFieldSubrole();
+//  public static const native int NSAccessibilitySelectedAttribute();
+//  public static const native int NSAccessibilitySelectedChildrenAttribute();
+//  public static const native int NSAccessibilitySelectedChildrenChangedNotification();
+//  public static const native int NSAccessibilitySelectedColumnsAttribute();
+//  public static const native int NSAccessibilitySelectedColumnsChangedNotification();
+//  public static const native int NSAccessibilitySelectedRowsAttribute();
+//  public static const native int NSAccessibilitySelectedRowsChangedNotification();
+//  public static const native int NSAccessibilitySelectedTextAttribute();
+//  public static const native int NSAccessibilitySelectedTextChangedNotification();
+//  public static const native int NSAccessibilitySelectedTextRangeAttribute();
+//  public static const native int NSAccessibilitySelectedTextRangesAttribute();
+//  public static const native int NSAccessibilityServesAsTitleForUIElementsAttribute();
+//  public static const native int NSAccessibilityShadowTextAttribute();
+//  public static const native int NSAccessibilitySharedCharacterRangeAttribute();
+//  public static const native int NSAccessibilitySharedTextUIElementsAttribute();
+//  public static const native int NSAccessibilitySheetCreatedNotification();
+//  public static const native int NSAccessibilitySheetRole();
+//  public static const native int NSAccessibilityShowMenuAction();
+//  public static const native int NSAccessibilityShownMenuAttribute();
+//  public static const native int NSAccessibilitySizeAttribute(); commented by Jacob Carlborg
+//  public static const native int NSAccessibilitySliderRole();
+//  public static const native int NSAccessibilitySortButtonRole();
+//  public static const native int NSAccessibilitySortDirectionAttribute();
+//  public static const native int NSAccessibilitySplitGroupRole();
+//  public static const native int NSAccessibilitySplitterRole();
+//  public static const native int NSAccessibilitySplittersAttribute();
+//  public static const native int NSAccessibilityStandardWindowSubrole();
+//  public static const native int NSAccessibilityStaticTextRole();
+//  public static const native int NSAccessibilityStrikethroughColorTextAttribute();
+//  public static const native int NSAccessibilityStrikethroughTextAttribute();
+//  public static const native int NSAccessibilityStringForRangeParameterizedAttribute();
+//  public static const native int NSAccessibilityStyleRangeForIndexParameterizedAttribute();
+//  public static const native int NSAccessibilitySubroleAttribute();
+//  public static const native int NSAccessibilitySuperscriptTextAttribute();
+//  public static const native int NSAccessibilitySystemDialogSubrole();
+//  public static const native int NSAccessibilitySystemFloatingWindowSubrole();
+//  public static const native int NSAccessibilitySystemWideRole();
+//  public static const native int NSAccessibilityTabGroupRole();
+//  public static const native int NSAccessibilityTableRole();
+//  public static const native int NSAccessibilityTableRowSubrole();
+//  public static const native int NSAccessibilityTabsAttribute();
+//  public static const native int NSAccessibilityTailIndentMarkerTypeValue();
+//  public static const native int NSAccessibilityTextAreaRole();
+//  public static const native int NSAccessibilityTextAttachmentSubrole();
+//  public static const native int NSAccessibilityTextFieldRole();
+//  public static const native int NSAccessibilityTextLinkSubrole();
+//  public static const native int NSAccessibilityTimelineSubrole();
+//  public static const native int NSAccessibilityTitleAttribute();
+//  public static const native int NSAccessibilityTitleChangedNotification();
+//  public static const native int NSAccessibilityTitleUIElementAttribute();
+//  public static const native int NSAccessibilityToolbarButtonAttribute();
+//  public static const native int NSAccessibilityToolbarButtonSubrole();
+//  public static const native int NSAccessibilityToolbarRole();
+//  public static const native int NSAccessibilityTopLevelUIElementAttribute();
+//  public static const native int NSAccessibilityUIElementDestroyedNotification();
+//  public static const native int NSAccessibilityURLAttribute();
+//  public static const native int NSAccessibilityUnderlineColorTextAttribute();
+//  public static const native int NSAccessibilityUnderlineTextAttribute();
+//  public static const native int NSAccessibilityUnitDescriptionAttribute();
+//  public static const native int NSAccessibilityUnitsAttribute();
+//  public static const native int NSAccessibilityUnknownMarkerTypeValue();
+//  public static const native int NSAccessibilityUnknownRole();
+//  public static const native int NSAccessibilityUnknownSortDirectionValue();
+//  public static const native int NSAccessibilityUnknownSubrole();
+//  public static const native int NSAccessibilityUnknownUnitValue();
+//  public static const native int NSAccessibilityValueAttribute();
+//  public static const native int NSAccessibilityValueChangedNotification();
+//  public static const native int NSAccessibilityValueDescriptionAttribute();
+//  public static const native int NSAccessibilityValueIndicatorRole();
+//  public static const native int NSAccessibilityVerticalOrientationValue();
+//  public static const native int NSAccessibilityVerticalScrollBarAttribute();
+//  public static const native int NSAccessibilityVisibleCharacterRangeAttribute();
+//  public static const native int NSAccessibilityVisibleChildrenAttribute();
+//  public static const native int NSAccessibilityVisibleColumnsAttribute();
+//  public static const native int NSAccessibilityVisibleNameKey();
+//  public static const native int NSAccessibilityVisibleRowsAttribute();
+//  public static const native int NSAccessibilityWindowAttribute();
+//  public static const native int NSAccessibilityWindowCreatedNotification();
+//  public static const native int NSAccessibilityWindowDeminiaturizedNotification();
+//  public static const native int NSAccessibilityWindowMiniaturizedNotification();
+//  public static const native int NSAccessibilityWindowMovedNotification();
+//  public static const native int NSAccessibilityWindowResizedNotification();
+//  public static const native int NSAccessibilityWindowRole();
+//  public static const native int NSAccessibilityWindowsAttribute();
+//  public static const native int NSAccessibilityZoomButtonAttribute();
+//  public static const native int NSAccessibilityZoomButtonSubrole();
+//  public static const native int NSAlignmentBinding();
+//  public static const native int NSAllRomanInputSourcesLocaleIdentifier();
+//  public static const native int NSAllowsEditingMultipleValuesSelectionBindingOption();
+//  public static const native int NSAllowsNullArgumentBindingOption();
+//  public static const native int NSAlternateImageBinding();
+//  public static const native int NSAlternateTitleBinding();
+//  public static const native int NSAlwaysPresentsApplicationModalAlertsBindingOption();
+//  public static const native int NSAnimateBinding();
+//  public static const native int NSAnimationDelayBinding();
+//  public static const native int NSAnimationProgressMark();
+//  public static const native int NSAnimationProgressMarkNotification();
+//  public static const native int NSAnimationTriggerOrderIn();
+//  public static const native int NSAnimationTriggerOrderOut();
+//  public static const native int NSAntialiasThresholdChangedNotification();
+//  public static const native int NSApp();
+//  public static const native int NSAppKitIgnoredException();
+//  public static const native int NSAppKitVersionNumber();
+//  public static const native int NSAppKitVirtualMemoryException();
+//  public static const native int NSApplicationDidBecomeActiveNotification();
+//  public static const native int NSApplicationDidChangeScreenParametersNotification();
+//  public static const native int NSApplicationDidFinishLaunchingNotification();
+//  public static const native int NSApplicationDidHideNotification();
+//  public static const native int NSApplicationDidResignActiveNotification();
+//  public static const native int NSApplicationDidUnhideNotification();
+//  public static const native int NSApplicationDidUpdateNotification();
+//  public static const native int NSApplicationFileType();
+//  public static const native int NSApplicationWillBecomeActiveNotification();
+//  public static const native int NSApplicationWillFinishLaunchingNotification();
+//  public static const native int NSApplicationWillHideNotification();
+//  public static const native int NSApplicationWillResignActiveNotification();
+//  public static const native int NSApplicationWillTerminateNotification();
+//  public static const native int NSApplicationWillUnhideNotification();
+//  public static const native int NSApplicationWillUpdateNotification();
+//  public static const native int NSArgumentBinding();
+//  public static const native int NSAttachmentAttributeName();
+//  public static const native int NSAttributedStringBinding();
+//  public static const native int NSAuthorDocumentAttribute();
+//  public static const NSString NSBackgroundColorAttributeName = new NSString(OS.NSBackgroundColorAttributeName()); commented by Jacob Carlborg
+//  public static const native int NSBackgroundColorAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSBackgroundColorDocumentAttribute();
+//  public static const native int NSBadBitmapParametersException();
+//  public static const native int NSBadComparisonException();
+//  public static const native int NSBadRTFColorTableException();
+//  public static const native int NSBadRTFDirectiveException();
+//  public static const native int NSBadRTFFontTableException();
+//  public static const native int NSBadRTFStyleSheetException();
+//  public static const native int NSBaseURLDocumentOption();
+//  public static const native int NSBaselineOffsetAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSBlack();
+//  public static const native int NSBottomMarginDocumentAttribute();
+//  public static const native int NSBrowserColumnConfigurationDidChangeNotification();
+//  public static const native int NSBrowserIllegalDelegateException();
+//  public static const native int NSCalibratedBlackColorSpace();
+//  public static const native int NSCalibratedRGBColorSpace();
+//  public static const native int NSCalibratedWhiteColorSpace();
+//  public static const native int NSCharacterEncodingDocumentAttribute();
+//  public static const native int NSCharacterEncodingDocumentOption();
+//  public static const native int NSCharacterShapeAttributeName();
+//  public static const native int NSCocoaVersionDocumentAttribute();
+//  public static const native int NSColorListDidChangeNotification();
+//  public static const native int NSColorListIOException();
+//  public static const native int NSColorListNotEditableException();
+//  public static const native int NSColorPanelColorDidChangeNotification();
+//  public static const native int NSColorPboardType();
+//  public static const native int NSComboBoxSelectionDidChangeNotification();
+//  public static const native int NSComboBoxSelectionIsChangingNotification();
+//  public static const native int NSComboBoxWillDismissNotification();
+//  public static const native int NSComboBoxWillPopUpNotification();
+//  public static const native int NSCommentDocumentAttribute();
+//  public static const native int NSCompanyDocumentAttribute();
+//  public static const native int NSConditionallySetsEditableBindingOption();
+//  public static const native int NSConditionallySetsEnabledBindingOption();
+//  public static const native int NSConditionallySetsHiddenBindingOption();
+//  public static const native int NSContentArrayBinding();
+//  public static const native int NSContentArrayForMultipleSelectionBinding();
+//  public static const native int NSContentBinding();
+//  public static const native int NSContentDictionaryBinding();
+//  public static const native int NSContentHeightBinding();
+//  public static const native int NSContentObjectBinding();
+//  public static const native int NSContentObjectsBinding();
+//  public static const native int NSContentPlacementTagBindingOption();
+//  public static const native int NSContentSetBinding();
+//  public static const native int NSContentValuesBinding();
+//  public static const native int NSContentWidthBinding();
+//  public static const native int NSContextHelpModeDidActivateNotification();
+//  public static const native int NSContextHelpModeDidDeactivateNotification();
+//  public static const native int NSContinuouslyUpdatesValueBindingOption();
+//  public static const native int NSControlTextDidBeginEditingNotification();
+//  public static const native int NSControlTextDidChangeNotification();
+//  public static const native int NSControlTextDidEndEditingNotification();
+//  public static const native int NSControlTintDidChangeNotification();
+//  public static const native int NSConvertedDocumentAttribute();
+//  public static const native int NSCopyrightDocumentAttribute();
+//  public static const native int NSCreatesSortDescriptorBindingOption();
+//  public static const native int NSCreationTimeDocumentAttribute();
+//  public static const native int NSCriticalValueBinding();
+//  public static const native int NSCursorAttributeName();
+//  public static const native int NSCustomColorSpace();
+//  public static const native int NSDarkGray();
+//  public static const native int NSDataBinding();
+//  public static const native int NSDefaultAttributesDocumentOption();
+//  public static const native int NSDefaultTabIntervalDocumentAttribute();
+//  public static const native int NSDeletesObjectsOnRemoveBindingsOption();
+//  public static const native int NSDeviceBitsPerSample();
+//  public static const native int NSDeviceBlackColorSpace();
+//  public static const native int NSDeviceCMYKColorSpace();
+//  public static const native int NSDeviceColorSpaceName();
+//  public static const native int NSDeviceIsPrinter();
+//  public static const native int NSDeviceIsScreen();
+//  public static const native int NSDeviceRGBColorSpace();
+//  public static const native int NSDeviceResolution(); commented by Jacob Carlborg
+//  public static const native int NSDeviceSize();
+//  public static const native int NSDeviceWhiteColorSpace();
+//  public static const native int NSDirectoryFileType();
+//  public static const native int NSDisplayNameBindingOption();
+//  public static const native int NSDisplayPatternBindingOption();
+//  public static const native int NSDisplayPatternTitleBinding();
+//  public static const native int NSDisplayPatternValueBinding();
+//  public static const native int NSDocFormatTextDocumentType();
+//  public static const native int NSDocumentEditedBinding();
+//  public static const native int NSDocumentTypeDocumentAttribute();
+//  public static const native int NSDocumentTypeDocumentOption();
+//  public static const native int NSDoubleClickArgumentBinding();
+//  public static const native int NSDoubleClickTargetBinding();
+//  public static const native int NSDragPboard();
+//  public static const native int NSDraggingException();
+//  public static const native int NSDrawerDidCloseNotification();
+//  public static const native int NSDrawerDidOpenNotification();
+//  public static const native int NSDrawerWillCloseNotification();
+//  public static const native int NSDrawerWillOpenNotification();
+//  public static const native int NSEditableBinding();
+//  public static const native int NSEditorDocumentAttribute();
+//  public static const native int NSEnabledBinding();
+//  public static const native int NSEventTrackingRunLoopMode();
+//  public static const native int NSExcludedElementsDocumentAttribute();
+//  public static const native int NSExcludedKeysBinding();
+//  public static const native int NSExpansionAttributeName();
+//  public static const native int NSFileContentsPboardType();
+//  public static const native int NSFilenamesPboardType();
+//  public static const native int NSFilesPromisePboardType();
+//  public static const native int NSFilesystemFileType();
+//  public static const native int NSFilterPredicateBinding();
+//  public static const native int NSFindPanelCaseInsensitiveSearch();
+//  public static const native int NSFindPanelSearchOptionsPboardType();
+//  public static const native int NSFindPanelSubStringMatch();
+//  public static const native int NSFindPboard();
+//  public static const native int NSFontAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSFontBinding();
+//  public static const native int NSFontBoldBinding();
+//  public static const native int NSFontCascadeListAttribute();
+//  public static const native int NSFontCharacterSetAttribute();
+//  public static const native int NSFontFaceAttribute();
+//  public static const native int NSFontFamilyAttribute();
+//  public static const native int NSFontFamilyNameBinding();
+//  public static const native int NSFontFeatureSelectorIdentifierKey();
+//  public static const native int NSFontFeatureSettingsAttribute();
+//  public static const native int NSFontFeatureTypeIdentifierKey();
+//  public static const native int NSFontFixedAdvanceAttribute();
+//  public static const native int NSFontIdentityMatrix();
+//  public static const native int NSFontItalicBinding();
+//  public static const native int NSFontMatrixAttribute();
+//  public static const native int NSFontNameAttribute();
+//  public static const native int NSFontNameBinding();
+//  public static const native int NSFontPboard();
+//  public static const native int NSFontPboardType();
+//  public static const native int NSFontSetChangedNotification();
+//  public static const native int NSFontSizeAttribute();
+//  public static const native int NSFontSizeBinding();
+//  public static const native int NSFontSlantTrait();
+//  public static const native int NSFontSymbolicTrait();
+//  public static const native int NSFontTraitsAttribute();
+//  public static const native int NSFontUnavailableException();
+//  public static const native int NSFontVariationAttribute();
+//  public static const native int NSFontVariationAxisDefaultValueKey();
+//  public static const native int NSFontVariationAxisIdentifierKey();
+//  public static const native int NSFontVariationAxisMaximumValueKey();
+//  public static const native int NSFontVariationAxisMinimumValueKey();
+//  public static const native int NSFontVariationAxisNameKey();
+//  public static const native int NSFontVisibleNameAttribute();
+//  public static const native int NSFontWeightTrait();
+//  public static const native int NSFontWidthTrait();
+//  public static const native int NSForegroundColorAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSFullScreenModeAllScreens();
+//  public static const native int NSFullScreenModeSetting();
+//  public static const native int NSFullScreenModeWindowLevel();
+//  public static const native int NSGeneralPboard();
+//  public static const native int NSGlyphInfoAttributeName();
+//  public static const native int NSGraphicsContextDestinationAttributeName();
+//  public static const native int NSGraphicsContextPDFFormat();
+//  public static const native int NSGraphicsContextPSFormat();
+//  public static const native int NSGraphicsContextRepresentationFormatAttributeName();
+//  public static const native int NSHTMLPboardType();
+//  public static const native int NSHTMLTextDocumentType();
+//  public static const native int NSHandlesContentAsCompoundValueBindingOption();
+//  public static const native int NSHeaderTitleBinding();
+//  public static const native int NSHiddenBinding();
+//  public static const native int NSHyphenationFactorDocumentAttribute();
+//  public static const native int NSIllegalSelectorException();
+//  public static const native int NSImageBinding();
+//  public static const native int NSImageCacheException();
+//  public static const native int NSImageColorSyncProfileData();
+//  public static const native int NSImageCompressionFactor();
+//  public static const native int NSImageCompressionMethod();
+//  public static const native int NSImageCurrentFrame();
+//  public static const native int NSImageCurrentFrameDuration();
+//  public static const native int NSImageDitherTransparency();
+//  public static const native int NSImageEXIFData();
+//  public static const native int NSImageFallbackBackgroundColor();
+//  public static const native int NSImageFrameCount();
+//  public static const native int NSImageGamma();
+//  public static const native int NSImageInterlaced();
+//  public static const native int NSImageLoopCount();
+//  public static const native int NSImageNameActionTemplate();
+//  public static const native int NSImageNameAddTemplate();
+//  public static const native int NSImageNameAdvanced();
+//  public static const native int NSImageNameBluetoothTemplate();
+//  public static const native int NSImageNameBonjour();
+//  public static const native int NSImageNameColorPanel();
+//  public static const native int NSImageNameColumnViewTemplate();
+//  public static const native int NSImageNameComputer();
+//  public static const native int NSImageNameDotMac();
+//  public static const native int NSImageNameEnterFullScreenTemplate();
+//  public static const native int NSImageNameEveryone();
+//  public static const native int NSImageNameExitFullScreenTemplate();
+//  public static const native int NSImageNameFlowViewTemplate();
+//  public static const native int NSImageNameFolderBurnable();
+//  public static const native int NSImageNameFolderSmart();
+//  public static const native int NSImageNameFollowLinkFreestandingTemplate();
+//  public static const native int NSImageNameFontPanel();
+//  public static const native int NSImageNameGoLeftTemplate();
+//  public static const native int NSImageNameGoRightTemplate();
+//  public static const native int NSImageNameIChatTheaterTemplate();
+//  public static const native int NSImageNameIconViewTemplate();
+//  public static const native int NSImageNameInfo();
+//  public static const native int NSImageNameInvalidDataFreestandingTemplate();
+//  public static const native int NSImageNameLeftFacingTriangleTemplate();
+//  public static const native int NSImageNameListViewTemplate();
+//  public static const native int NSImageNameLockLockedTemplate();
+//  public static const native int NSImageNameLockUnlockedTemplate();
+//  public static const native int NSImageNameMultipleDocuments();
+//  public static const native int NSImageNameNetwork();
+//  public static const native int NSImageNamePathTemplate();
+//  public static const native int NSImageNamePreferencesGeneral();
+//  public static const native int NSImageNameQuickLookTemplate();
+//  public static const native int NSImageNameRefreshFreestandingTemplate();
+//  public static const native int NSImageNameRefreshTemplate();
+//  public static const native int NSImageNameRemoveTemplate();
+//  public static const native int NSImageNameRevealFreestandingTemplate();
+//  public static const native int NSImageNameRightFacingTriangleTemplate();
+//  public static const native int NSImageNameSlideshowTemplate();
+//  public static const native int NSImageNameSmartBadgeTemplate();
+//  public static const native int NSImageNameStopProgressFreestandingTemplate();
+//  public static const native int NSImageNameStopProgressTemplate();
+//  public static const native int NSImageNameUser();
+//  public static const native int NSImageNameUserAccounts();
+//  public static const native int NSImageNameUserGroup();
+//  public static const native int NSImageProgressive();
+//  public static const native int NSImageRGBColorTable();
+//  public static const native int NSImageRepRegistryDidChangeNotification();
+//  public static const native int NSIncludedKeysBinding();
+//  public static const native int NSInitialKeyBinding();
+//  public static const native int NSInitialValueBinding();
+//  public static const native int NSInkTextPboardType();
+//  public static const native int NSInsertsNullPlaceholderBindingOption();
+//  public static const native int NSInterfaceStyleDefault();
+//  public static const native int NSInvokesSeparatelyWithArrayObjectsBindingOption();
+//  public static const native int NSIsIndeterminateBinding();
+//  public static const native int NSKernAttributeName();
+//  public static const native int NSKeywordsDocumentAttribute();
+//  public static const native int NSLabelBinding();
+//  public static const native int NSLeftMarginDocumentAttribute();
+//  public static const native int NSLigatureAttributeName();
+//  public static const native int NSLightGray();
+//  public static const native int NSLinkAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSLocalizedKeyDictionaryBinding();
+//  public static const native int NSMacSimpleTextDocumentType();
+//  public static const native int NSManagedObjectContextBinding();
+//  public static const native int NSMarkedClauseSegmentAttributeName();
+//  public static const native int NSMaxValueBinding();
+//  public static const native int NSMaxWidthBinding();
+//  public static const native int NSMaximumRecentsBinding();
+//  public static const native int NSMenuDidAddItemNotification();
+//  public static const native int NSMenuDidBeginTrackingNotification();
+//  public static const native int NSMenuDidChangeItemNotification();
+//  public static const native int NSMenuDidEndTrackingNotification();
+//  public static const native int NSMenuDidRemoveItemNotification();
+//  public static const native int NSMenuDidSendActionNotification();
+//  public static const native int NSMenuWillSendActionNotification();
+//  public static const native int NSMinValueBinding();
+//  public static const native int NSMinWidthBinding();
+//  public static const native int NSMixedStateImageBinding();
+//  public static const native int NSModalPanelRunLoopMode();
+//  public static const native int NSModificationTimeDocumentAttribute();
+//  public static const native int NSMultipleTextSelectionPboardType();
+//  public static const native int NSMultipleValuesMarker();
+//  public static const native int NSMultipleValuesPlaceholderBindingOption();
+//  public static const native int NSNamedColorSpace();
+//  public static const native int NSNibLoadingException();
+//  public static const native int NSNibOwner();
+//  public static const native int NSNibTopLevelObjects();
+//  public static const native int NSNoSelectionMarker();
+//  public static const native int NSNoSelectionPlaceholderBindingOption();
+//  public static const native int NSNotApplicableMarker();
+//  public static const native int NSNotApplicablePlaceholderBindingOption();
+//  public static const native int NSNullPlaceholderBindingOption();
+//  public static const native int NSObliquenessAttributeName();
+//  public static const native int NSObservedKeyPathKey();
+//  public static const native int NSObservedObjectKey();
+//  public static const native int NSOffStateImageBinding();
+//  public static const native int NSOfficeOpenXMLTextDocumentType();
+//  public static const native int NSOnStateImageBinding();
+//  public static const native int NSOpenDocumentTextDocumentType();
+//  public static const native int NSOptionsKey();
+//  public static const native int NSOutlineViewColumnDidMoveNotification();
+//  public static const native int NSOutlineViewColumnDidResizeNotification();
+//  public static const native int NSOutlineViewItemDidCollapseNotification();
+//  public static const native int NSOutlineViewItemDidExpandNotification();
+//  public static const native int NSOutlineViewItemWillCollapseNotification();
+//  public static const native int NSOutlineViewItemWillExpandNotification();
+//  public static const native int NSOutlineViewSelectionDidChangeNotification();
+//  public static const native int NSOutlineViewSelectionIsChangingNotification();
+//  public static const native int NSPDFPboardType();
+//  public static const native int NSPICTPboardType();
+//  public static const native int NSPPDIncludeNotFoundException();
+//  public static const native int NSPPDIncludeStackOverflowException();
+//  public static const native int NSPPDIncludeStackUnderflowException();
+//  public static const native int NSPPDParseException();
+//  public static const native int NSPaperSizeDocumentAttribute();
+//  public static const native int NSParagraphStyleAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSPasteboardCommunicationException();
+//  public static const native int NSPatternColorSpace();
+//  public static const native int NSPlainFileType();
+//  public static const native int NSPlainTextDocumentType();
+//  public static const native int NSPopUpButtonCellWillPopUpNotification();
+//  public static const native int NSPopUpButtonWillPopUpNotification();
+//  public static const native int NSPostScriptPboardType();
+//  public static const native int NSPredicateBinding();
+//  public static const native int NSPredicateFormatBindingOption();
+//  public static const native int NSPrefixSpacesDocumentAttribute();
+//  public static const native int NSPrintAllPages();
+//  public static const native int NSPrintBottomMargin();
+//  public static const native int NSPrintCancelJob();
+//  public static const native int NSPrintCopies();
+//  public static const native int NSPrintDetailedErrorReporting();
+//  public static const native int NSPrintFaxCoverSheetName();
+//  public static const native int NSPrintFaxHighResolution();
+//  public static const native int NSPrintFaxJob();
+//  public static const native int NSPrintFaxModem();
+//  public static const native int NSPrintFaxNumber();
+//  public static const native int NSPrintFaxReceiverNames();
+//  public static const native int NSPrintFaxReceiverNumbers();
+//  public static const native int NSPrintFaxReturnReceipt();
+//  public static const native int NSPrintFaxSendTime();
+//  public static const native int NSPrintFaxTrimPageEnds();
+//  public static const native int NSPrintFaxUseCoverSheet();
+//  public static const native int NSPrintFirstPage();
+//  public static const native int NSPrintFormName();
+//  public static const native int NSPrintHeaderAndFooter();
+//  public static const native int NSPrintHorizontalPagination();
+//  public static const native int NSPrintHorizontallyCentered();
+//  public static const native int NSPrintJobDisposition();
+//  public static const native int NSPrintJobFeatures();
+//  public static const native int NSPrintLastPage();
+//  public static const native int NSPrintLeftMargin();
+//  public static const native int NSPrintManualFeed();
+//  public static const native int NSPrintMustCollate();
+//  public static const native int NSPrintOperationExistsException();
+//  public static const native int NSPrintOrientation();
+//  public static const native int NSPrintPackageException();
+//  public static const native int NSPrintPagesAcross();
+//  public static const native int NSPrintPagesDown();
+//  public static const native int NSPrintPagesPerSheet();
+//  public static const native int NSPrintPanelAccessorySummaryItemDescriptionKey();
+//  public static const native int NSPrintPanelAccessorySummaryItemNameKey();
+//  public static const native int NSPrintPaperFeed();
+//  public static const native int NSPrintPaperName();
+//  public static const native int NSPrintPaperSize();
+//  public static const native int NSPrintPhotoJobStyleHint();
+//  public static const native int NSPrintPreviewJob();
+//  public static const native int NSPrintPrinter();
+//  public static const native int NSPrintPrinterName();
+//  public static const native int NSPrintReversePageOrder();
+//  public static const native int NSPrintRightMargin();
+//  public static const native int NSPrintSaveJob();
+//  public static const native int NSPrintSavePath();
+//  public static const native int NSPrintScalingFactor();
+//  public static const native int NSPrintSpoolJob();
+//  public static const native int NSPrintTime();
+//  public static const native int NSPrintTopMargin();
+//  public static const native int NSPrintVerticalPagination();
+//  public static const native int NSPrintVerticallyCentered();
+//  public static const native int NSPrintingCommunicationException();
+//  public static const native int NSRTFDPboardType();
+//  public static const native int NSRTFDTextDocumentType();
+//  public static const native int NSRTFPboardType();
+//  public static const native int NSRTFPropertyStackOverflowException();
+//  public static const native int NSRTFTextDocumentType();
+//  public static const native int NSRaisesForNotApplicableKeysBindingOption();
+//  public static const native int NSReadOnlyDocumentAttribute();
+//  public static const native int NSRecentSearchesBinding();
+//  public static const native int NSRepresentedFilenameBinding();
+//  public static const native int NSRightMarginDocumentAttribute();
+//  public static const native int NSRowHeightBinding();
+//  public static const native int NSRuleEditorPredicateComparisonModifier();
+//  public static const native int NSRuleEditorPredicateCompoundType();
+//  public static const native int NSRuleEditorPredicateCustomSelector();
+//  public static const native int NSRuleEditorPredicateLeftExpression();
+//  public static const native int NSRuleEditorPredicateOperatorType();
+//  public static const native int NSRuleEditorPredicateOptions();
+//  public static const native int NSRuleEditorPredicateRightExpression();
+//  public static const native int NSRuleEditorRowsDidChangeNotification();
+//  public static const native int NSRulerPboard();
+//  public static const native int NSRulerPboardType();
+//  public static const native int NSSelectedIdentifierBinding();
+//  public static const native int NSSelectedIndexBinding();
+//  public static const native int NSSelectedLabelBinding();
+//  public static const native int NSSelectedObjectBinding();
+//  public static const native int NSSelectedObjectsBinding();
+//  public static const native int NSSelectedTagBinding();
+//  public static const native int NSSelectedValueBinding();
+//  public static const native int NSSelectedValuesBinding();
+//  public static const native int NSSelectionIndexPathsBinding();
+//  public static const native int NSSelectionIndexesBinding();
+//  public static const native int NSSelectorNameBindingOption();
+//  public static const native int NSSelectsAllWhenSettingContentBindingOption();
+//  public static const native int NSShadowAttributeName();
+//  public static const native int NSShellCommandFileType();
+//  public static const native int NSSortDescriptorsBinding();
+//  public static const native int NSSoundPboardType();
+//  public static const native int NSSpeechCharacterModeProperty();
+//  public static const native int NSSpeechCommandDelimiterProperty();
+//  public static const native int NSSpeechCommandPrefix();
+//  public static const native int NSSpeechCommandSuffix();
+//  public static const native int NSSpeechCurrentVoiceProperty();
+//  public static const native int NSSpeechDictionaryAbbreviations();
+//  public static const native int NSSpeechDictionaryEntryPhonemes();
+//  public static const native int NSSpeechDictionaryEntrySpelling();
+//  public static const native int NSSpeechDictionaryLocaleIdentifier();
+//  public static const native int NSSpeechDictionaryModificationDate();
+//  public static const native int NSSpeechDictionaryPronunciations();
+//  public static const native int NSSpeechErrorCount();
+//  public static const native int NSSpeechErrorNewestCharacterOffset();
+//  public static const native int NSSpeechErrorNewestCode();
+//  public static const native int NSSpeechErrorOldestCharacterOffset();
+//  public static const native int NSSpeechErrorOldestCode();
+//  public static const native int NSSpeechErrorsProperty();
+//  public static const native int NSSpeechInputModeProperty();
+//  public static const native int NSSpeechModeLiteral();
+//  public static const native int NSSpeechModeNormal();
+//  public static const native int NSSpeechModePhoneme();
+//  public static const native int NSSpeechModeText();
+//  public static const native int NSSpeechNumberModeProperty();
+//  public static const native int NSSpeechOutputToFileURLProperty();
+//  public static const native int NSSpeechPhonemeInfoExample();
+//  public static const native int NSSpeechPhonemeInfoHiliteEnd();
+//  public static const native int NSSpeechPhonemeInfoHiliteStart();
+//  public static const native int NSSpeechPhonemeInfoOpcode();
+//  public static const native int NSSpeechPhonemeInfoSymbol();
+//  public static const native int NSSpeechPhonemeSymbolsProperty();
+//  public static const native int NSSpeechPitchBaseProperty();
+//  public static const native int NSSpeechPitchModProperty();
+//  public static const native int NSSpeechRateProperty();
+//  public static const native int NSSpeechRecentSyncProperty();
+//  public static const native int NSSpeechResetProperty();
+//  public static const native int NSSpeechStatusNumberOfCharactersLeft();
+//  public static const native int NSSpeechStatusOutputBusy();
+//  public static const native int NSSpeechStatusOutputPaused();
+//  public static const native int NSSpeechStatusPhonemeCode();
+//  public static const native int NSSpeechStatusProperty();
+//  public static const native int NSSpeechSynthesizerInfoIdentifier();
+//  public static const native int NSSpeechSynthesizerInfoProperty();
+//  public static const native int NSSpeechSynthesizerInfoVersion();
+//  public static const native int NSSpeechVolumeProperty();
+//  public static const native int NSSpellingStateAttributeName();
+//  public static const native int NSSplitViewDidResizeSubviewsNotification();
+//  public static const native int NSSplitViewWillResizeSubviewsNotification();
+//  public static const native int NSStrikethroughColorAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSStrikethroughStyleAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSStringPboardType();
+//  public static const native int NSStrokeColorAttributeName();
+//  public static const native int NSStrokeWidthAttributeName();
+//  public static const native int NSSubjectDocumentAttribute();
+//  public static const native int NSSuperscriptAttributeName();
+//  public static const native int NSSystemColorsDidChangeNotification();
+//  public static const native int NSTIFFException();
+//  public static const native int NSTIFFPboardType();
+//  public static const native int NSTabColumnTerminatorsAttributeName();
+//  public static const native int NSTableViewColumnDidMoveNotification();
+//  public static const native int NSTableViewColumnDidResizeNotification();
+//  public static const native int NSTableViewSelectionDidChangeNotification();
+//  public static const native int NSTableViewSelectionIsChangingNotification();
+//  public static const native int NSTabularTextPboardType();
+//  public static const native int NSTargetBinding();
+//  public static const native int NSTextColorBinding();
+//  public static const native int NSTextDidBeginEditingNotification();
+//  public static const native int NSTextDidChangeNotification();
+//  public static const native int NSTextDidEndEditingNotification();
+//  public static const native int NSTextEncodingNameDocumentAttribute();
+//  public static const native int NSTextEncodingNameDocumentOption();
+//  public static const native int NSTextLineTooLongException();
+//  public static const native int NSTextNoSelectionException();
+//  public static const native int NSTextReadException();
+//  public static const native int NSTextSizeMultiplierDocumentOption();
+//  public static const native int NSTextStorageDidProcessEditingNotification();
+//  public static const native int NSTextStorageWillProcessEditingNotification();
+//  public static const native int NSTextViewDidChangeSelectionNotification();
+//  public static const native int NSTextViewDidChangeTypingAttributesNotification();
+//  public static const native int NSTextViewWillChangeNotifyingTextViewNotification();
+//  public static const native int NSTextWriteException();
+//  public static const native int NSTimeoutDocumentOption();
+//  public static const native int NSTitleBinding();
+//  public static const native int NSTitleDocumentAttribute();
+//  public static const native int NSToolTipAttributeName();
+//  public static const native int NSToolTipBinding();
+//  public static const native int NSToolbarCustomizeToolbarItemIdentifier();
+//  public static const native int NSToolbarDidRemoveItemNotification();
+//  public static const native int NSToolbarFlexibleSpaceItemIdentifier();
+//  public static const native int NSToolbarPrintItemIdentifier();
+//  public static const native int NSToolbarSeparatorItemIdentifier();
+//  public static const native int NSToolbarShowColorsItemIdentifier();
+//  public static const native int NSToolbarShowFontsItemIdentifier();
+//  public static const native int NSToolbarSpaceItemIdentifier();
+//  public static const native int NSToolbarWillAddItemNotification();
+//  public static const native int NSTopMarginDocumentAttribute();
+//  public static const native int NSTransparentBinding();
+//  public static const native int NSTypedStreamVersionException();
+//  public static const native int NSURLPboardType();
+//  public static const native int NSUnderlineByWordMask();
+//  public static const native int NSUnderlineColorAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSUnderlineStrikethroughMask();
+//  public static const native int NSUnderlineStyleAttributeName(); commented by Jacob Carlborg
+//  public static const native int NSVCardPboardType();
+//  public static const native int NSValidatesImmediatelyBindingOption();
+//  public static const native int NSValueBinding();
+//  public static const native int NSValuePathBinding();
+//  public static const native int NSValueTransformerBindingOption();
+//  public static const native int NSValueTransformerNameBindingOption();
+//  public static const native int NSValueURLBinding();
+//  public static const native int NSViewAnimationEffectKey();
+//  public static const native int NSViewAnimationEndFrameKey();
+//  public static const native int NSViewAnimationFadeInEffect();
+//  public static const native int NSViewAnimationFadeOutEffect();
+//  public static const native int NSViewAnimationStartFrameKey();
+//  public static const native int NSViewAnimationTargetKey();
+//  public static const native int NSViewBoundsDidChangeNotification();
+//  public static const native int NSViewDidUpdateTrackingAreasNotification();
+//  public static const native int NSViewFocusDidChangeNotification();
+//  public static const native int NSViewFrameDidChangeNotification();
+//  public static const native int NSViewGlobalFrameDidChangeNotification();
+//  public static const native int NSViewModeDocumentAttribute();
+//  public static const native int NSViewSizeDocumentAttribute();
+//  public static const native int NSViewZoomDocumentAttribute();
+//  public static const native int NSVisibleBinding();
+//  public static const native int NSVoiceAge();
+//  public static const native int NSVoiceDemoText();
+//  public static const native int NSVoiceGender();
+//  public static const native int NSVoiceGenderFemale();
+//  public static const native int NSVoiceGenderMale();
+//  public static const native int NSVoiceGenderNeuter();
+//  public static const native int NSVoiceIdentifier();
+//  public static const native int NSVoiceIndividuallySpokenCharacters();
+//  public static const native int NSVoiceLocaleIdentifier();
+//  public static const native int NSVoiceName();
+//  public static const native int NSVoiceSupportedCharacters();
+//  public static const native int NSWarningValueBinding();
+//  public static const native int NSWebArchiveTextDocumentType();
+//  public static const native int NSWebPreferencesDocumentOption();
+//  public static const native int NSWebResourceLoadDelegateDocumentOption();
+//  public static const native int NSWhite();
+//  public static const native int NSWidthBinding();
+//  public static const native int NSWindowDidBecomeKeyNotification();
+//  public static const native int NSWindowDidBecomeMainNotification();
+//  public static const native int NSWindowDidChangeScreenNotification();
+//  public static const native int NSWindowDidChangeScreenProfileNotification();
+//  public static const native int NSWindowDidDeminiaturizeNotification();
+//  public static const native int NSWindowDidEndSheetNotification();
+//  public static const native int NSWindowDidExposeNotification();
+//  public static const native int NSWindowDidMiniaturizeNotification();
+//  public static const native int NSWindowDidMoveNotification();
+//  public static const native int NSWindowDidResignKeyNotification();
+//  public static const native int NSWindowDidResignMainNotification();
+//  public static const native int NSWindowDidResizeNotification();
+//  public static const native int NSWindowDidUpdateNotification();
+//  public static const native int NSWindowServerCommunicationException();
+//  public static const native int NSWindowWillBeginSheetNotification();
+//  public static const native int NSWindowWillCloseNotification();
+//  public static const native int NSWindowWillMiniaturizeNotification();
+//  public static const native int NSWindowWillMoveNotification();
+//  public static const native int NSWordMLTextDocumentType();
+//  public static const native int NSWordTablesReadException();
+//  public static const native int NSWordTablesWriteException();
+//  public static const native int NSWorkspaceCompressOperation();
+//  public static const native int NSWorkspaceCopyOperation();
+//  public static const native int NSWorkspaceDecompressOperation();
+//  public static const native int NSWorkspaceDecryptOperation();
+//  public static const native int NSWorkspaceDestroyOperation();
+//  public static const native int NSWorkspaceDidLaunchApplicationNotification();
+//  public static const native int NSWorkspaceDidMountNotification();
+//  public static const native int NSWorkspaceDidPerformFileOperationNotification();
+//  public static const native int NSWorkspaceDidTerminateApplicationNotification();
+//  public static const native int NSWorkspaceDidUnmountNotification();
+//  public static const native int NSWorkspaceDidWakeNotification();
+//  public static const native int NSWorkspaceDuplicateOperation();
+//  public static const native int NSWorkspaceEncryptOperation();
+//  public static const native int NSWorkspaceLinkOperation();
+//  public static const native int NSWorkspaceMoveOperation();
+//  public static const native int NSWorkspaceRecycleOperation();
+//  public static const native int NSWorkspaceSessionDidBecomeActiveNotification();
+//  public static const native int NSWorkspaceSessionDidResignActiveNotification();
+//  public static const native int NSWorkspaceWillLaunchApplicationNotification();
+//  public static const native int NSWorkspaceWillPowerOffNotification();
+//  public static const native int NSWorkspaceWillSleepNotification();
+//  public static const native int NSWorkspaceWillUnmountNotification();
+//  public static const native int NSAppleEventManagerWillProcessFirstEventNotification();
+//  public static const native int NSAppleEventTimeOutDefault();
+//  public static const native int NSAppleEventTimeOutNone();
+//  public static const native int NSAppleScriptErrorAppName();
+//  public static const native int NSAppleScriptErrorBriefMessage();
+//  public static const native int NSAppleScriptErrorMessage();
+//  public static const native int NSAppleScriptErrorNumber();
+//  public static const native int NSAppleScriptErrorRange();
+//  public static const native int NSArgumentDomain();
+//  public static const native int NSAverageKeyValueOperator();
+//  public static const native int NSBuddhistCalendar();
+//  public static const native int NSBundleDidLoadNotification();
+//  public static const native int NSCharacterConversionException();
+//  public static const native int NSChineseCalendar();
+//  public static const native int NSClassDescriptionNeededForClassNotification();
+//  public static const native int NSCocoaErrorDomain();
+//  public static const native int NSConnectionDidDieNotification();
+//  public static const native int NSConnectionDidInitializeNotification();
+//  public static const native int NSConnectionReplyMode();
+//  public static const native int NSCountKeyValueOperator();
+//  public static const native int NSCurrentLocaleDidChangeNotification();
+//  public static const native int NSDeallocateZombies();
+//  public static const native int NSDebugEnabled();
+//  public static const native int NSDecimalNumberDivideByZeroException();
+//  public static const native int NSDecimalNumberExactnessException();
+//  public static const native int NSDecimalNumberOverflowException();
+//  public static const native int NSDecimalNumberUnderflowException();
+//  public static const NSString NSDefaultRunLoopMode = new NSString(OS.NSDefaultRunLoopMode()); commented by Jacob Carlborg
+//  public static const native int NSDefaultRunLoopMode(); commented by Jacob Carlborg
+//  public static const native int NSDestinationInvalidException();
+//  public static const native int NSDidBecomeSingleThreadedNotification();
+//  public static const native int NSDistinctUnionOfArraysKeyValueOperator();
+//  public static const native int NSDistinctUnionOfObjectsKeyValueOperator();
+//  public static const native int NSDistinctUnionOfSetsKeyValueOperator();
+//  public static const native int NSErrorFailingURLStringKey();
+//  public static const native int NSFailedAuthenticationException();
+//  public static const native int NSFileAppendOnly();
+//  public static const native int NSFileBusy();
+//  public static const native int NSFileCreationDate();
+//  public static const native int NSFileDeviceIdentifier();
+//  public static const native int NSFileExtensionHidden();
+//  public static const native int NSFileGroupOwnerAccountID();
+//  public static const native int NSFileGroupOwnerAccountName();
+//  public static const native int NSFileHFSCreatorCode();
+//  public static const native int NSFileHFSTypeCode();
+//  public static const native int NSFileHandleConnectionAcceptedNotification();
+//  public static const native int NSFileHandleDataAvailableNotification();
+//  public static const native int NSFileHandleNotificationDataItem();
+//  public static const native int NSFileHandleNotificationFileHandleItem();
+//  public static const native int NSFileHandleNotificationMonitorModes();
+//  public static const native int NSFileHandleOperationException();
+//  public static const native int NSFileHandleReadCompletionNotification();
+//  public static const native int NSFileHandleReadToEndOfFileCompletionNotification();
+//  public static const native int NSFileImmutable();
+//  public static const native int NSFileModificationDate();
+//  public static const native int NSFileOwnerAccountID();
+//  public static const native int NSFileOwnerAccountName();
+//  public static const native int NSFilePathErrorKey();
+//  public static const native int NSFilePosixPermissions();
+//  public static const native int NSFileReferenceCount();
+//  public static const native int NSFileSize();
+//  public static const native int NSFileSystemFileNumber();
+//  public static const native int NSFileSystemFreeNodes();
+//  public static const native int NSFileSystemFreeSize();
+//  public static const native int NSFileSystemNodes();
+//  public static const native int NSFileSystemNumber();
+//  public static const native int NSFileSystemSize();
+//  public static const native int NSFileType();
+//  public static const native int NSFileTypeBlockSpecial();
+//  public static const native int NSFileTypeCharacterSpecial();
+//  public static const native int NSFileTypeDirectory();
+//  public static const native int NSFileTypeRegular();
+//  public static const native int NSFileTypeSocket();
+//  public static const native int NSFileTypeSymbolicLink();
+//  public static const native int NSFileTypeUnknown();
+//  public static const native int NSFoundationVersionNumber();
+//  public static const native int NSGenericException();
+//  public static const native int NSGlobalDomain();
+//  public static const native int NSGrammarCorrections();
+//  public static const native int NSGrammarRange();
+//  public static const native int NSGrammarUserDescription();
+//  public static const native int NSGregorianCalendar();
+//  public static const native int NSHTTPCookieComment();
+//  public static const native int NSHTTPCookieCommentURL();
+//  public static const native int NSHTTPCookieDiscard();
+//  public static const native int NSHTTPCookieDomain();
+//  public static const native int NSHTTPCookieExpires();
+//  public static const native int NSHTTPCookieManagerAcceptPolicyChangedNotification();
+//  public static const native int NSHTTPCookieManagerCookiesChangedNotification();
+//  public static const native int NSHTTPCookieMaximumAge();
+//  public static const native int NSHTTPCookieName();
+//  public static const native int NSHTTPCookieOriginURL();
+//  public static const native int NSHTTPCookiePath();
+//  public static const native int NSHTTPCookiePort();
+//  public static const native int NSHTTPCookieSecure();
+//  public static const native int NSHTTPCookieValue();
+//  public static const native int NSHTTPCookieVersion();
+//  public static const native int NSHangOnUncaughtException();
+//  public static const native int NSHebrewCalendar();
+//  public static const native int NSInconsistentArchiveException();
+//  public static const native int NSIntegerHashCallBacks();
+//  public static const native int NSIntegerMapKeyCallBacks();
+//  public static const native int NSIntegerMapValueCallBacks();
+//  public static const native int NSInternalInconsistencyException();
+//  public static const native int NSInvalidArchiveOperationException();
+//  public static const native int NSInvalidArgumentException();
+//  public static const native int NSInvalidReceivePortException();
+//  public static const native int NSInvalidSendPortException();
+//  public static const native int NSInvalidUnarchiveOperationException();
+//  public static const native int NSInvocationOperationCancelledException();
+//  public static const native int NSInvocationOperationVoidResultException();
+//  public static const native int NSIsNilTransformerName();
+//  public static const native int NSIsNotNilTransformerName();
+//  public static const native int NSIslamicCalendar();
+//  public static const native int NSIslamicCivilCalendar();
+//  public static const native int NSJapaneseCalendar();
+//  public static const native int NSKeepAllocationStatistics();
+//  public static const native int NSKeyValueChangeIndexesKey();
+//  public static const native int NSKeyValueChangeKindKey();
+//  public static const native int NSKeyValueChangeNewKey();
+//  public static const native int NSKeyValueChangeNotificationIsPriorKey();
+//  public static const native int NSKeyValueChangeOldKey();
+//  public static const native int NSKeyedUnarchiveFromDataTransformerName();
+//  public static const native int NSLoadedClasses();
+//  public static const native int NSLocalNotificationCenterType();
+//  public static const native int NSLocaleCalendar();
+//  public static const native int NSLocaleCollationIdentifier();
+//  public static const native int NSLocaleCountryCode();
+//  public static const native int NSLocaleCurrencyCode();
+//  public static const native int NSLocaleCurrencySymbol();
+//  public static const native int NSLocaleDecimalSeparator();
+//  public static const native int NSLocaleExemplarCharacterSet();
+//  public static const native int NSLocaleGroupingSeparator();
+//  public static const native int NSLocaleIdentifier();
+//  public static const native int NSLocaleLanguageCode();
+//  public static const native int NSLocaleMeasurementSystem();
+//  public static const native int NSLocaleScriptCode();
+//  public static const native int NSLocaleUsesMetricSystem();
+//  public static const native int NSLocaleVariantCode();
+//  public static const native int NSLocalizedDescriptionKey();
+//  public static const native int NSLocalizedFailureReasonErrorKey();
+//  public static const native int NSLocalizedRecoveryOptionsErrorKey();
+//  public static const native int NSLocalizedRecoverySuggestionErrorKey();
+//  public static const native int NSMachErrorDomain();
+//  public static const native int NSMallocException();
+//  public static const native int NSMaximumKeyValueOperator();
+//  public static const native int NSMetadataQueryDidFinishGatheringNotification();
+//  public static const native int NSMetadataQueryDidStartGatheringNotification();
+//  public static const native int NSMetadataQueryDidUpdateNotification();
+//  public static const native int NSMetadataQueryGatheringProgressNotification();
+//  public static const native int NSMetadataQueryLocalComputerScope();
+//  public static const native int NSMetadataQueryNetworkScope();
+//  public static const native int NSMetadataQueryResultContentRelevanceAttribute();
+//  public static const native int NSMetadataQueryUserHomeScope();
+//  public static const native int NSMinimumKeyValueOperator();
+//  public static const native int NSNegateBooleanTransformerName();
+//  public static const native int NSNetServicesErrorCode();
+//  public static const native int NSNetServicesErrorDomain();
+//  public static const native int NSNonOwnedPointerHashCallBacks();
+//  public static const native int NSNonOwnedPointerMapKeyCallBacks();
+//  public static const native int NSNonOwnedPointerMapValueCallBacks();
+//  public static const native int NSNonOwnedPointerOrNullMapKeyCallBacks();
+//  public static const native int NSNonRetainedObjectHashCallBacks();
+//  public static const native int NSNonRetainedObjectMapKeyCallBacks();
+//  public static const native int NSNonRetainedObjectMapValueCallBacks();
+//  public static const native int NSOSStatusErrorDomain();
+//  public static const native int NSObjectHashCallBacks();
+//  public static const native int NSObjectInaccessibleException();
+//  public static const native int NSObjectMapKeyCallBacks();
+//  public static const native int NSObjectMapValueCallBacks();
+//  public static const native int NSObjectNotAvailableException();
+//  public static const native int NSOldStyleException();
+//  public static const native int NSOperationNotSupportedForKeyException();
+//  public static const native int NSOwnedObjectIdentityHashCallBacks();
+//  public static const native int NSOwnedPointerHashCallBacks();
+//  public static const native int NSOwnedPointerMapKeyCallBacks();
+//  public static const native int NSOwnedPointerMapValueCallBacks();
+//  public static const native int NSPOSIXErrorDomain();
+//  public static const native int NSParseErrorException();
+//  public static const native int NSPointerToStructHashCallBacks();
+//  public static const native int NSPortDidBecomeInvalidNotification();
+//  public static const native int NSPortReceiveException();
+//  public static const native int NSPortSendException();
+//  public static const native int NSPortTimeoutException();
+//  public static const native int NSRangeException();
+//  public static const native int NSRecoveryAttempterErrorKey();
+//  public static const native int NSRegistrationDomain();
+//  public static const native int NSRunLoopCommonModes();
+//  public static const native int NSStreamDataWrittenToMemoryStreamKey();
+//  public static const native int NSStreamFileCurrentOffsetKey();
+//  public static const native int NSStreamSOCKSErrorDomain();
+//  public static const native int NSStreamSOCKSProxyConfigurationKey();
+//  public static const native int NSStreamSOCKSProxyHostKey();
+//  public static const native int NSStreamSOCKSProxyPasswordKey();
+//  public static const native int NSStreamSOCKSProxyPortKey();
+//  public static const native int NSStreamSOCKSProxyUserKey();
+//  public static const native int NSStreamSOCKSProxyVersion4();
+//  public static const native int NSStreamSOCKSProxyVersion5();
+//  public static const native int NSStreamSOCKSProxyVersionKey();
+//  public static const native int NSStreamSocketSSLErrorDomain();
+//  public static const native int NSStreamSocketSecurityLevelKey();
+//  public static const native int NSStreamSocketSecurityLevelNegotiatedSSL();
+//  public static const native int NSStreamSocketSecurityLevelNone();
+//  public static const native int NSStreamSocketSecurityLevelSSLv2();
+//  public static const native int NSStreamSocketSecurityLevelSSLv3();
+//  public static const native int NSStreamSocketSecurityLevelTLSv1();
+//  public static const native int NSStringEncodingErrorKey();
+//  public static const native int NSSumKeyValueOperator();
+//  public static const native int NSSystemTimeZoneDidChangeNotification();
+//  public static const native int NSTaskDidTerminateNotification();
+//  public static const native int NSThreadWillExitNotification();
+//  public static const native int NSURLAuthenticationMethodDefault();
+//  public static const native int NSURLAuthenticationMethodHTMLForm();
+//  public static const native int NSURLAuthenticationMethodHTTPBasic();
+//  public static const native int NSURLAuthenticationMethodHTTPDigest();
+//  public static const native int NSURLCredentialStorageChangedNotification();
+//  public static const native int NSURLErrorDomain();
+//  public static const native int NSURLErrorKey();
+//  public static const native int NSURLFileScheme();
+//  public static const native int NSURLProtectionSpaceFTPProxy();
+//  public static const native int NSURLProtectionSpaceHTTPProxy();
+//  public static const native int NSURLProtectionSpaceHTTPSProxy();
+//  public static const native int NSURLProtectionSpaceSOCKSProxy();
+//  public static const native int NSUnarchiveFromDataTransformerName();
+//  public static const native int NSUndefinedKeyException();
+//  public static const native int NSUnderlyingErrorKey();
+//  public static const native int NSUndoManagerCheckpointNotification();
+//  public static const native int NSUndoManagerDidOpenUndoGroupNotification();
+//  public static const native int NSUndoManagerDidRedoChangeNotification();
+//  public static const native int NSUndoManagerDidUndoChangeNotification();
+//  public static const native int NSUndoManagerWillCloseUndoGroupNotification();
+//  public static const native int NSUndoManagerWillRedoChangeNotification();
+//  public static const native int NSUndoManagerWillUndoChangeNotification();
+//  public static const native int NSUnionOfArraysKeyValueOperator();
+//  public static const native int NSUnionOfObjectsKeyValueOperator();
+//  public static const native int NSUnionOfSetsKeyValueOperator();
+//  public static const native int NSUserDefaultsDidChangeNotification();
+//  public static const native int NSWillBecomeMultiThreadedNotification();
+//  public static const native int NSXMLParserErrorDomain();
+//  public static const native int NSZeroPoint();
+//  public static const native int NSZeroRect();
+//  public static const native int NSZeroSize();
+//  public static const native int NSZombieEnabled();
+//  public static const native int DOMEventException();
+//  public static const native int DOMException();
+//  public static const native int DOMRangeException();
+//  public static const native int DOMXPathException();
+//  public static const native int WebActionButtonKey();
+//  public static const native int WebActionElementKey();
+//  public static const native int WebActionModifierFlagsKey();
+//  public static const native int WebActionNavigationTypeKey();
+//  public static const native int WebActionOriginalURLKey();
+//  public static const native int WebArchivePboardType();
+//  public static const native int WebElementDOMNodeKey();
+//  public static const native int WebElementFrameKey();
+//  public static const native int WebElementImageAltStringKey();
+//  public static const native int WebElementImageKey();
+//  public static const native int WebElementImageRectKey();
+//  public static const native int WebElementImageURLKey();
+//  public static const native int WebElementIsSelectedKey();
+//  public static const native int WebElementLinkLabelKey();
+//  public static const native int WebElementLinkTargetFrameKey();
+//  public static const native int WebElementLinkTitleKey();
+//  public static const native int WebElementLinkURLKey();
+//  public static const native int WebHistoryAllItemsRemovedNotification();
+//  public static const native int WebHistoryItemChangedNotification();
+//  public static const native int WebHistoryItemsAddedNotification();
+//  public static const native int WebHistoryItemsKey();
+//  public static const native int WebHistoryItemsRemovedNotification();
+//  public static const native int WebHistoryLoadedNotification();
+//  public static const native int WebHistorySavedNotification();
+//  public static const native int WebKitErrorDomain();
+//  public static const native int WebKitErrorMIMETypeKey();
+//  public static const native int WebKitErrorPlugInNameKey();
+//  public static const native int WebKitErrorPlugInPageURLStringKey();
+//  public static const native int WebPlugInAttributesKey();
+//  public static const native int WebPlugInBaseURLKey();
+//  public static const native int WebPlugInContainerKey();
+//  public static const native int WebPlugInContainingElementKey();
+//  public static const native int WebPreferencesChangedNotification();
+//  public static const native int WebViewDidBeginEditingNotification();
+//  public static const native int WebViewDidChangeNotification();
+//  public static const native int WebViewDidChangeSelectionNotification();
+//  public static const native int WebViewDidChangeTypingStyleNotification();
+//  public static const native int WebViewDidEndEditingNotification();
+//  public static const native int WebViewProgressEstimateChangedNotification();
+//  public static const native int WebViewProgressFinishedNotification();
+//  public static const native int WebViewProgressStartedNotification();
+
+    /** Functions */
+//  public static const native int NSAccessibilityActionDescription(int action);
+//  public static const native void NSAccessibilityPostNotification(int element, int notification);
+//  public static const native void NSAccessibilityRaiseBadArgumentException(int element, int attribute, int value);
+//  public static const native int NSAccessibilityRoleDescription(int role, int subrole);
+//  public static const native int NSAccessibilityRoleDescriptionForUIElement(int element);
+//  public static const native int NSAccessibilityUnignoredAncestor(int element);
+//  public static const native int NSAccessibilityUnignoredChildren(int originalChildren);
+//  public static const native int NSAccessibilityUnignoredChildrenForOnlyChild(int originalChild);
+//  public static const native int NSAccessibilityUnignoredDescendant(int element);
+//  public static const native bool NSApplicationLoad();
+//  public static const native int NSApplicationMain(int argc, int argv);
+//  public static const native int NSAvailableWindowDepths();
+//  public static const native void NSBeep();
+//  public static const native void NSBeginAlertSheet(int title, int defaultButton, int alternateButton, int otherButton, int docWindow, int modalDelegate, int didEndSelector, int didDismissSelector, int contextInfo, int msgFormat);
+//  public static const native void NSBeginCriticalAlertSheet(int title, int defaultButton, int alternateButton, int otherButton, int docWindow, int modalDelegate, int didEndSelector, int didDismissSelector, int contextInfo, int msgFormat);
+//  public static const native void NSBeginInformationalAlertSheet(int title, int defaultButton, int alternateButton, int otherButton, int docWindow, int modalDelegate, int didEndSelector, int didDismissSelector, int contextInfo, int msgFormat);
+//  public static const native int NSBestDepth(int colorSpace, int bps, int bpp, bool planar, int exactMatch);
+//  public static const native int NSBitsPerPixelFromDepth(int depth); commented by Jacob Calborg
+//  public static const native int NSBitsPerSampleFromDepth(int depth);
+//  public static const native int NSColorSpaceFromDepth(int depth);
+//  public static const native int NSConvertGlyphsToPackedGlyphs(int glBuf, int count, int packing, int packedGlyphs);
+//  public static const native void NSCopyBits(int srcGState, NSRect srcRect, NSPoint destPoint);
+//  public static const native void NSCountWindows(int count);
+//  public static const native void NSCountWindowsForContext(int context, int count);
+//  public static const native int NSCreateFileContentsPboardType(int fileType);
+//  public static const native int NSCreateFilenamePboardType(int fileType);
+//  public static const native void NSDisableScreenUpdates();
+//  public static const native void NSDottedFrameRect(NSRect aRect);
+//  public static const native void NSDrawBitmap(NSRect rect, int width, int height, int bps, int spp, int bpp, int bpr, bool isPlanar, bool hasAlpha, int colorSpaceName, int data);
+//  public static const native void NSDrawButton(NSRect aRect, NSRect clipRect);
+////    public static const native NSRect NSDrawColorTiledRects(NSRect boundsRect, NSRect clipRect, int sides, int colors, int count);
+//  public static const native void NSDrawDarkBezel(NSRect aRect, NSRect clipRect);
+//  public static const native void NSDrawGrayBezel(NSRect aRect, NSRect clipRect);
+//  public static const native void NSDrawGroove(NSRect aRect, NSRect clipRect);
+//  public static const native void NSDrawLightBezel(NSRect aRect, NSRect clipRect);
+//  public static const native void NSDrawNinePartImage(NSRect frame, int topLeftCorner, int topEdgeFill, int topRightCorner, int leftEdgeFill, int centerFill, int rightEdgeFill, int bottomLeftCorner, int bottomEdgeFill, int bottomRightCorner, int op, float alphaFraction, bool flipped);
+//  public static const native void NSDrawThreePartImage(NSRect frame, int startCap, int centerFill, int endCap, bool vertical, int op, float alphaFraction, bool flipped);
+////    public static const native NSRect NSDrawTiledRects(NSRect boundsRect, NSRect clipRect, int sides, int grays, int count);
+//  public static const native void NSDrawWhiteBezel(NSRect aRect, NSRect clipRect);
+//  public static const native void NSDrawWindowBackground(NSRect aRect);
+//  public static const native void NSEnableScreenUpdates();
+//  public static const native void NSEraseRect(NSRect aRect);
+//  public static const native int NSEventMaskFromType(int type);
+//  public static const native void NSFrameRect(NSRect aRect);
+//  public static const native void NSFrameRectWithWidth(NSRect aRect, float frameWidth);
+//  public static const native void NSFrameRectWithWidthUsingOperation(NSRect aRect, float frameWidth, int op);
+//  public static const native int NSGetAlertPanel(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton);
+//  public static const native int NSGetCriticalAlertPanel(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton);
+//  public static const native int NSGetFileType(int pboardType);
+//  public static const native int NSGetFileTypes(int pboardTypes);
+//  public static const native int NSGetInformationalAlertPanel(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton);
+//  public static const native int NSGetWindowServerMemory(int context, int virtualMemory, int windowBackingMemory, int windowDumpString);
+//  public static const native void NSHighlightRect(NSRect aRect);
+//  public static const native int NSInterfaceStyleForKey(int key, int responder);
+//  public static const native bool NSIsControllerMarker(int object);
+//  public static const native int NSNumberOfColorComponents(int colorSpaceName);
+//  public static const native void NSOpenGLGetOption(int pname, int param);
+//  public static const native void NSOpenGLGetVersion(int major, int minor);
+//  public static const native void NSOpenGLSetOption(int pname, int param);
+//  public static const native bool NSPerformService(int itemName, int pboard);
+//  public static const native bool NSPlanarFromDepth(int depth);
+//  public static const native int NSReadPixel(NSPoint passedPoint);
+//  public static const native void NSRectClip(NSRect aRect);
+//  public static const native void NSRectClipList(int rects, int count);
+//  public static const native void NSRectFill(NSRect aRect);
+//  public static const native void NSRectFillList(int rects, int count);
+//  public static const native void NSRectFillListUsingOperation(int rects, int count, int op);
+//  public static const native void NSRectFillListWithColors(int rects, int colors, int num);
+//  public static const native void NSRectFillListWithColorsUsingOperation(int rects, int colors, int num, int op);
+//  public static const native void NSRectFillListWithGrays(int rects, int grays, int num);
+//  public static const native void NSRectFillUsingOperation(NSRect aRect, int op);
+//  public static const native void NSRegisterServicesProvider(int provider, int name);
+//  public static const native void NSReleaseAlertPanel(int panel);
+//  public static const native int NSRunAlertPanel(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton);
+//  public static const native int NSRunAlertPanelRelativeToWindow(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton, int docWindow);
+//  public static const native int NSRunCriticalAlertPanel(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton);
+//  public static const native int NSRunCriticalAlertPanelRelativeToWindow(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton, int docWindow);
+//  public static const native int NSRunInformationalAlertPanel(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton);
+//  public static const native int NSRunInformationalAlertPanelRelativeToWindow(int title, int msgFormat, int defaultButton, int alternateButton, int otherButton, int docWindow);
+//  public static const native void NSSetFocusRingStyle(int placement);
+//  public static const native int NSSetShowsServicesMenuItem(int itemName, bool enabled);
+////    public static const native void NSShowAnimationEffect(int animationEffect, NSPoint centerLocation, NSSize size, int animationDelegate, int didEndSelector, int contextInfo);
+//  public static const native bool NSShowsServicesMenuItem(int itemName);
+//  public static const native void NSUnregisterServicesProvider(int name);
+//  public static const native void NSUpdateDynamicServices();
+//  public static const native void NSWindowList(int size, int list);
+//  public static const native void NSWindowListForContext(int context, int size, int list);
+//  public static const native int NSAllHashTableObjects(int table);
+//  public static const native int NSAllMapTableKeys(int table);
+//  public static const native int NSAllMapTableValues(int table);
+//  public static const native int NSAllocateCollectable(int size, int options);
+//  public static const native int NSAllocateMemoryPages(int bytes);
+//  public static const native int NSAllocateObject(int aClass, int extraBytes, int zone);
+//  public static const native int NSClassFromString(int aClassName);
+//  public static const native bool NSCompareHashTables(int table1, int table2);
+//  public static const native bool NSCompareMapTables(int table1, int table2);
+//  public static const native bool NSContainsRect(NSRect aRect, NSRect bRect);
+////    public static const native NSSwappedDouble NSConvertHostDoubleToSwapped(double x);
+////    public static const native NSSwappedFloat NSConvertHostFloatToSwapped(float x);
+//  public static const native double NSConvertSwappedDoubleToHost(NSSwappedDouble x);
+//  public static const native float NSConvertSwappedFloatToHost(NSSwappedFloat x);
+//  public static const native int NSCopyHashTableWithZone(int table, int zone);
+//  public static const native int NSCopyMapTableWithZone(int table, int zone);
+//  public static const native void NSCopyMemoryPages(int source, int dest, int bytes);
+//  public static const native int NSCopyObject(int object, int extraBytes, int zone);
+//  public static const native int NSCountFrames();
+//  public static const native int NSCountHashTable(int table);
+//  public static const native int NSCountMapTable(int table);
+//  public static const native int NSCreateHashTable(NSHashTableCallBacks callBacks, int capacity);
+//  public static const native int NSCreateHashTableWithZone(NSHashTableCallBacks callBacks, int capacity, int zone);
+//  public static const native int NSCreateMapTable(NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, int capacity);
+//  public static const native int NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks, NSMapTableValueCallBacks valueCallBacks, int capacity, int zone);
+//  public static const native int NSCreateZone(int startSize, int granularity, bool canFree);
+//  public static const native void NSDeallocateMemoryPages(int ptr, int bytes);
+//  public static const native void NSDeallocateObject(int object);
+//  public static const native int NSDecimalAdd(int result, int leftOperand, int rightOperand, int roundingMode);
+//  public static const native void NSDecimalCompact(int number);
+//  public static const native int NSDecimalCompare(int leftOperand, int rightOperand);
+//  public static const native void NSDecimalCopy(int destination, int source);
+//  public static const native int NSDecimalDivide(int result, int leftOperand, int rightOperand, int roundingMode);
+//  public static const native bool NSDecimalIsNotANumber(int dcm);
+//  public static const native int NSDecimalMultiply(int result, int leftOperand, int rightOperand, int roundingMode);
+//  public static const native int NSDecimalMultiplyByPowerOf10(int result, int number, short power, int roundingMode);
+//  public static const native int NSDecimalNormalize(int number1, int number2, int roundingMode);
+//  public static const native int NSDecimalPower(int result, int number, int power, int roundingMode);
+//  public static const native void NSDecimalRound(int result, int number, int scale, int roundingMode);
+//  public static const native int NSDecimalString(int dcm, int locale);
+//  public static const native int NSDecimalSubtract(int result, int leftOperand, int rightOperand, int roundingMode);
+//  public static const native bool NSDecrementExtraRefCountWasZero(int object);
+//  public static const native int NSDefaultMallocZone();
+//  public static const native void NSDivideRect(NSRect inRect, int slice, int rem, float amount, int edge);
+//  public static const native void NSEndHashTableEnumeration(int enumerator);
+//  public static const native void NSEndMapTableEnumeration(int enumerator);
+////    public static const native NSHashEnumerator NSEnumerateHashTable(int table);
+////    public static const native NSMapEnumerator NSEnumerateMapTable(int table);
+//  public static const native bool NSEqualPoints(NSPoint aPoint, NSPoint bPoint);
+//  public static const native bool NSEqualRanges(NSRange range1, NSRange range2);
+//  public static const native bool NSEqualRects(NSRect aRect, NSRect bRect);
+//  public static const native bool NSEqualSizes(NSSize aSize, NSSize bSize);
+//  public static const native int NSExtraRefCount(int object);
+//  public static const native int NSFileTypeForHFSTypeCode(int hfsFileTypeCode); commented by Jacob Carlborg
+//  public static const native int NSFrameAddress(int frame);
+//  public static const native void NSFreeHashTable(int table);
+//  public static const native void NSFreeMapTable(int table);
+//  public static const native int NSFullUserName();
+//  public static const native int NSGetSizeAndAlignment(int typePtr, int sizep, int alignp);
+//  public static const native int NSGetUncaughtExceptionHandler();
+//  public static const native int NSHFSTypeCodeFromFileType(int fileTypeString);
+//  public static const native int NSHFSTypeOfFile(int fullFilePath);
+//  public static const native int NSHashGet(int table, int pointer);
+//  public static const native void NSHashInsert(int table, int pointer);
+//  public static const native int NSHashInsertIfAbsent(int table, int pointer);
+//  public static const native void NSHashInsertKnownAbsent(int table, int pointer);
+//  public static const native void NSHashRemove(int table, int pointer);
+//  public static const native float NSHeight(NSRect aRect);
+//  public static const native int NSHomeDirectory();
+//  public static const native int NSHomeDirectoryForUser(int userName);
+//  public static const native int NSHostByteOrder();
+//  public static const native void NSIncrementExtraRefCount(int object);
+////    public static const native NSRect NSInsetRect(NSRect aRect, float dX, float dY);
+////    public static const native NSRect NSIntegralRect(NSRect aRect);
+////    public static const native NSRange NSIntersectionRange(NSRange range1, NSRange range2);
+////    public static const native NSRect NSIntersectionRect(NSRect aRect, NSRect bRect);
+//  public static const native bool NSIntersectsRect(NSRect aRect, NSRect bRect);
+//  public static const native bool NSIsEmptyRect(NSRect aRect);
+//  public static const native bool NSIsFreedObject(int anObject);
+//  public static const native bool NSLocationInRange(int loc, NSRange range);
+//  public static const native void NSLog(int format);
+//  public static const native int NSLogPageSize();
+//  public static const native void NSLogv(int format, int args);
+//  public static const native int NSMakeCollectable(int cf);
+////    public static const native NSPoint NSMakePoint(float x, float y);
+////    public static const native NSRange NSMakeRange(int loc, int len);
+////    public static const native NSRect NSMakeRect(float x, float y, float w, float h);
+////    public static const native NSSize NSMakeSize(float w, float h);
+//  public static const native int NSMapGet(int table, int key);
+//  public static const native void NSMapInsert(int table, int key, int value);
+//  public static const native int NSMapInsertIfAbsent(int table, int key, int value);
+//  public static const native void NSMapInsertKnownAbsent(int table, int key, int value);
+//  public static const native bool NSMapMember(int table, int key, int originalKey, int value);
+//  public static const native void NSMapRemove(int table, int key);
+//  public static const native int NSMaxRange(NSRange range);
+//  public static const native float NSMaxX(NSRect aRect);
+//  public static const native float NSMaxY(NSRect aRect);
+//  public static const native float NSMidX(NSRect aRect);
+//  public static const native float NSMidY(NSRect aRect);
+//  public static const native float NSMinX(NSRect aRect);
+//  public static const native float NSMinY(NSRect aRect);
+//  public static const native bool NSMouseInRect(NSPoint aPoint, NSRect aRect, bool flipped);
+//  public static const native int NSNextHashEnumeratorItem(int enumerator);
+//  public static const native bool NSNextMapEnumeratorPair(int enumerator, int key, int value);
+////    public static const native NSRect NSOffsetRect(NSRect aRect, float dX, float dY);
+//  public static const native int NSOpenStepRootDirectory();
+//  public static const native int NSPageSize();
+////    public static const native NSPoint NSPointFromCGPoint(CGPoint cgpoint);
+////    public static const native NSPoint NSPointFromString(int aString);
+//  public static const native bool NSPointInRect(NSPoint aPoint, NSRect aRect);
+////    public static const native CGPoint NSPointToCGPoint(NSPoint nspoint);
+//  public static const native int NSProtocolFromString(int namestr);
+////    public static const native NSRange NSRangeFromString(int aString);
+//  public static const native int NSRealMemoryAvailable();
+//  public static const native int NSReallocateCollectable(int ptr, int size, int options);
+//  public static const native void NSRecordAllocationEvent(int eventType, int object);
+////    public static const native NSRect NSRectFromCGRect(CGRect cgrect);
+////    public static const native NSRect NSRectFromString(int aString);
+////    public static const native CGRect NSRectToCGRect(NSRect nsrect);
+//  public static const native void NSRecycleZone(int zone);
+//  public static const native void NSResetHashTable(int table);
+//  public static const native void NSResetMapTable(int table);
+//  public static const native int NSReturnAddress(int frame);
+//  public static const native int NSRoundDownToMultipleOfPageSize(int bytes);
+//  public static const native int NSRoundUpToMultipleOfPageSize(int bytes);
+//  public static const native int NSSearchPathForDirectoriesInDomains(int directory, int domainMask, bool expandTilde);
+//  public static const native int NSSelectorFromString(int aSelectorName);
+//  public static const native void NSSetUncaughtExceptionHandler(int dummy);
+//  public static const native void NSSetZoneName(int zone, int name);
+//  public static const native bool NSShouldRetainWithZone(int anObject, int requestedZone);
+////    public static const native NSSize NSSizeFromCGSize(CGSize cgsize);
+////    public static const native NSSize NSSizeFromString(int aString);
+////    public static const native CGSize NSSizeToCGSize(NSSize nssize);
+//  public static const native int NSStringFromClass(int aClass);
+//  public static const native int NSStringFromHashTable(int table);
+//  public static const native int NSStringFromMapTable(int table);
+//  public static const native int NSStringFromPoint(NSPoint aPoint);
+//  public static const native int NSStringFromProtocol(int proto);
+//  public static const native int NSStringFromRange(NSRange range);
+//  public static const native int NSStringFromRect(NSRect aRect);
+//  public static const native int NSStringFromSelector(int aSelector);
+//  public static const native int NSStringFromSize(NSSize aSize);
+//  public static const native double NSSwapBigDoubleToHost(NSSwappedDouble x);
+//  public static const native float NSSwapBigFloatToHost(NSSwappedFloat x);
+//  public static const native int NSSwapBigIntToHost(int x);
+//  public static const native long NSSwapBigLongLongToHost(long x);
+//  public static const native int NSSwapBigLongToHost(int x);
+//  public static const native short NSSwapBigShortToHost(short x);
+////    public static const native NSSwappedDouble NSSwapDouble(NSSwappedDouble x);
+////    public static const native NSSwappedFloat NSSwapFloat(NSSwappedFloat x);
+////    public static const native NSSwappedDouble NSSwapHostDoubleToBig(double x);
+////    public static const native NSSwappedDouble NSSwapHostDoubleToLittle(double x);
+////    public static const native NSSwappedFloat NSSwapHostFloatToBig(float x);
+////    public static const native NSSwappedFloat NSSwapHostFloatToLittle(float x);
+//  public static const native int NSSwapHostIntToBig(int x);
+//  public static const native int NSSwapHostIntToLittle(int x);
+//  public static const native long NSSwapHostLongLongToBig(long x);
+//  public static const native long NSSwapHostLongLongToLittle(long x);
+//  public static const native int NSSwapHostLongToBig(int x);
+//  public static const native int NSSwapHostLongToLittle(int x);
+//  public static const native short NSSwapHostShortToBig(short x);
+//  public static const native short NSSwapHostShortToLittle(short x);
+//  public static const native int NSSwapInt(int inv);
+//  public static const native double NSSwapLittleDoubleToHost(NSSwappedDouble x);
+//  public static const native float NSSwapLittleFloatToHost(NSSwappedFloat x);
+//  public static const native int NSSwapLittleIntToHost(int x);
+//  public static const native long NSSwapLittleLongLongToHost(long x);
+//  public static const native int NSSwapLittleLongToHost(int x);
+//  public static const native short NSSwapLittleShortToHost(short x);
+//  public static const native int NSSwapLong(int inv);
+//  public static const native long NSSwapLongLong(long inv);
+//  public static const native short NSSwapShort(short inv);
+//  public static const native int NSTemporaryDirectory();
+//  public static const native NSRange NSUnionRange(NSRange range1, NSRange range2);
+//  public static const native NSRect NSUnionRect(NSRect aRect, NSRect bRect);
+//  public static const native int NSUserName();
+//  public static const native float NSWidth(NSRect aRect);
+//  public static const native int NSZoneCalloc(int zone, int numElems, int byteSize);
+//  public static const native void NSZoneFree(int zone, int ptr);
+//  public static const native int NSZoneFromPointer(int ptr);
+//  public static const native int NSZoneMalloc(int zone, int size);
+//  public static const native int NSZoneName(int zone);
+//  public static const native int NSZoneRealloc(int zone, int ptr, int size);
+//  public static const native int NXReadNSObjectFromCoder(int decoder);
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTApplicationDelegate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTApplicationDelegate;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSObject;
+
+public class DWTApplicationDelegate : NSObject {
+    public this () {
+        super(0);
+    }
+
+    public this (int id) {
+        super(id);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTBox.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTBox;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSBox;
+import dwt.internal.cocoa.OS;
+
+public class DWTBox : NSBox {
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTButton.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTButton;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSButton;
+
+public class DWTButton : NSButton {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTComboBox.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTComboBox;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSComboBox;
+
+public class DWTComboBox : NSComboBox {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTDatePicker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTDatePicker;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSDatePicker;
+
+public class DWTDatePicker : NSDatePicker {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTImageView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTImageView;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSImageView;
+
+public class DWTImageView : NSImageView {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTMenu.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTMenu;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.OS;
+
+public class DWTMenu : NSMenu {
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTMenuItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTMenuItem;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSMenuItem;
+
+public class DWTMenuItem : NSMenuItem {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTOutlineView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTOutlineView;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSOutlineView;
+
+public class DWTOutlineView : NSOutlineView {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTPanelDelegate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTPanelDelegate;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.OS;
+
+public class DWTPanelDelegate : NSObject {
+
+    public this () {
+        super(0);
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public int tag () {
+        return OS.objc_msgSend(id, OS.sel_tag);
+    }
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTPopUpButton.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTPopUpButton;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSPopUpButton;
+
+public class DWTPopUpButton : NSPopUpButton {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTProgressIndicator.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTProgressIndicator;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSProgressIndicator;
+import dwt.internal.cocoa.OS;
+
+public class DWTProgressIndicator : NSProgressIndicator {
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTScrollView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTScrollView;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSScrollView;
+import dwt.internal.cocoa.OS;
+
+public class DWTScrollView : NSScrollView {
+
+    public this () {
+        super(0);
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTScroller.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTScroller;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSScroller;
+
+public class DWTScroller : NSScroller {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTSlider.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTSlider;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSSlider;
+
+public class DWTSlider : NSSlider {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTStepper.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTStepper;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSStepper;
+
+public class DWTStepper : NSStepper {
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTTabView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTTabView;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSTabView;
+import dwt.internal.cocoa.OS;
+
+public class DWTTabView : NSTabView {
+
+    public this () {
+        super(0);
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTTableView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTTableView;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSTableView;
+
+public class DWTTableView : NSTableView {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTTextField.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTTextField;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSTextField;
+
+public class DWTTextField : NSTextField {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTTextView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTTextView;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSTextView;
+import dwt.internal.cocoa.OS;
+
+public class DWTTextView : NSTextView {
+
+    public this () {
+        super(0);
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTTreeItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTTreeItem;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSObject;
+
+public class DWTTreeItem : NSObject {
+
+    public int tag () {
+        return OS.objc_msgSend(id, OS.sel_tag);
+    }
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTView;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+
+public class DWTView : NSView {
+
+    public this () {
+        super(0);
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTWebViewDelegate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTWebViewDelegate;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSObject;
+
+public class DWTWebViewDelegate : NSObject {
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTWindow.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.SWTWindow;
+
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+
+public class DWTWindow : NSWindow {
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/SWTWindowDelegate.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.DWTWindowDelegate;
+
+import dwt.internal.cocoa.NSObject;
+
+public class DWTWindowDelegate : NSObject {
+
+    public this () {
+        super(0);
+    }
+
+    public this (int id) {
+        super(id);
+    }
+
+    public int tag () {
+        return OS.objc_msgSend(id, OS.sel_tag);
+    }
+
+    public void setTag (int tag) {
+        OS.objc_msgSend(id, OS.sel_setTag_1, tag);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebDataSource.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa;
+
+public class WebDataSource : NSObject {
+
+public WebDataSource() {
+    super();
+}
+
+public WebDataSource(int id) {
+    super(id);
+}
+
+//public void addSubresource(WebResource subresource) {
+//  OS.objc_msgSend(this.id, OS.sel_addSubresource_1, subresource !is null ? subresource.id : 0);
+//}
+
+public NSData data() {
+    int result = OS.objc_msgSend(this.id, OS.sel_data);
+    return result !is 0 ? new NSData(result) : null;
+}
+
+//public id initWithRequest(NSURLRequest request) {
+//  int result = OS.objc_msgSend(this.id, OS.sel_initWithRequest_1, request !is null ? request.id : 0);
+//  return result !is 0 ? new id(result) : null;
+//}
+
+//public NSURLRequest initialRequest() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_initialRequest);
+//  return result !is 0 ? new NSURLRequest(result) : null;
+//}
+
+public bool isLoading() {
+    return OS.objc_msgSend(this.id, OS.sel_isLoading) !is 0;
+}
+
+//public WebResource mainResource() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_mainResource);
+//  return result !is 0 ? new WebResource(result) : null;
+//}
+
+public NSString pageTitle() {
+    int result = OS.objc_msgSend(this.id, OS.sel_pageTitle);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public WebDocumentRepresentation representation() {
+    int result = OS.objc_msgSend(this.id, OS.sel_representation);
+    return result !is 0 ? new WebDocumentRepresentation (result) : null;
+}
+
+public NSMutableURLRequest request() {
+    int result = OS.objc_msgSend(this.id, OS.sel_request);
+    return result !is 0 ? new NSMutableURLRequest(result) : null;
+}
+
+public NSURLResponse response() {
+    int result = OS.objc_msgSend(this.id, OS.sel_response);
+    return result !is 0 ? new NSURLResponse(result) : null;
+}
+
+//public WebResource subresourceForURL(NSURL URL) {
+//  int result = OS.objc_msgSend(this.id, OS.sel_subresourceForURL_1, URL !is null ? URL.id : 0);
+//  return result !is 0 ? new WebResource(result) : null;
+//}
+
+//public NSArray subresources() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_subresources);
+//  return result !is 0 ? new NSArray(result) : null;
+//}
+
+public NSString textEncodingName() {
+    int result = OS.objc_msgSend(this.id, OS.sel_textEncodingName);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+//public NSURL unreachableURL() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_unreachableURL);
+//  return result !is 0 ? new NSURL(result) : null;
+//}
+
+//public WebArchive webArchive() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_webArchive);
+//  return result !is 0 ? new WebArchive(result) : null;
+//}
+
+public WebFrame webFrame() {
+    int result = OS.objc_msgSend(this.id, OS.sel_webFrame);
+    return result !is 0 ? new WebFrame(result) : null;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebDocumentRepresentation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa;
+
+public class WebDocumentRepresentation : NSObject {
+
+public WebDocumentRepresentation(int id) {
+    super(id);
+}
+
+public NSString documentSource() {
+    int id = OS.objc_msgSend(this.id, OS.sel_documentSource);
+    return id !is 0 ? new NSString(id) : null;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebFrame.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa;
+
+public class WebFrame : NSObject {
+
+public WebFrame() {
+    super();
+}
+
+public WebFrame(int id) {
+    super(id);
+}
+
+public DOMDocument DOMDocument() {
+    int result = OS.objc_msgSend(this.id, OS.sel_DOMDocument);
+    return result !is 0 ? new DOMDocument(result) : null;
+}
+
+public NSArray childFrames() {
+    int result = OS.objc_msgSend(this.id, OS.sel_childFrames);
+    return result !is 0 ? new NSArray(result) : null;
+}
+
+public WebDataSource dataSource() {
+    int result = OS.objc_msgSend(this.id, OS.sel_dataSource);
+    return result !is 0 ? new WebDataSource(result) : null;
+}
+
+public WebFrame findFrameNamed(NSString name) {
+    int result = OS.objc_msgSend(this.id, OS.sel_findFrameNamed_1, name !is null ? name.id : 0);
+    return result is this.id ? this : (result !is 0 ? new WebFrame(result) : null);
+}
+
+//public DOMHTMLElement frameElement() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_frameElement);
+//  return result !is 0 ? new DOMHTMLElement(result) : null;
+//}
+
+//public WebFrameView frameView() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_frameView);
+//  return result !is 0 ? new WebFrameView(result) : null;
+//}
+
+public int globalContext() {
+    return OS.objc_msgSend(this.id, OS.sel_globalContext);
+}
+
+//public id initWithName(NSString name, WebFrameView view, WebView webView) {
+//  int result = OS.objc_msgSend(this.id, OS.sel_initWithName_1webFrameView_1webView_1, name !is null ? name.id : 0, view !is null ? view.id : 0, webView !is null ? webView.id : 0);
+//  return result !is 0 ? new id(result) : null;
+//}
+
+public void loadAlternateHTMLString(NSString String, NSURL baseURL, NSURL unreachableURL) {
+    OS.objc_msgSend(this.id, OS.sel_loadAlternateHTMLString_1baseURL_1forUnreachableURL_1, String !is null ? String.id : 0, baseURL !is null ? baseURL.id : 0, unreachableURL !is null ? unreachableURL.id : 0);
+}
+//
+//public void loadArchive(WebArchive archive) {
+//  OS.objc_msgSend(this.id, OS.sel_loadArchive_1, archive !is null ? archive.id : 0);
+//}
+
+public void loadData(NSData data, NSString MIMEType, NSString encodingName, NSURL URL) {
+    OS.objc_msgSend(this.id, OS.sel_loadData_1MIMEType_1textEncodingName_1baseURL_1, data !is null ? data.id : 0, MIMEType !is null ? MIMEType.id : 0, encodingName !is null ? encodingName.id : 0, URL !is null ? URL.id : 0);
+}
+
+public void loadHTMLString(NSString String, NSURL URL) {
+    OS.objc_msgSend(this.id, OS.sel_loadHTMLString_1baseURL_1, String !is null ? String.id : 0, URL !is null ? URL.id : 0);
+}
+
+public void loadRequest(NSURLRequest request) {
+    OS.objc_msgSend(this.id, OS.sel_loadRequest_1, request !is null ? request.id : 0);
+}
+
+public NSString name() {
+    int result = OS.objc_msgSend(this.id, OS.sel_name);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public WebFrame parentFrame() {
+    int result = OS.objc_msgSend(this.id, OS.sel_parentFrame);
+    return result is this.id ? this : (result !is 0 ? new WebFrame(result) : null);
+}
+
+public WebDataSource provisionalDataSource() {
+    int result = OS.objc_msgSend(this.id, OS.sel_provisionalDataSource);
+    return result !is 0 ? new WebDataSource(result) : null;
+}
+
+public void reload() {
+    OS.objc_msgSend(this.id, OS.sel_reload);
+}
+
+public void stopLoading() {
+    OS.objc_msgSend(this.id, OS.sel_stopLoading);
+}
+
+public WebView webView() {
+    int result = OS.objc_msgSend(this.id, OS.sel_webView);
+    return result !is 0 ? new WebView(result) : null;
+}
+
+//public WebScriptObject windowObject() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_windowObject);
+//  return result !is 0 ? new WebScriptObject(result) : null;
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebFrameView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,48 @@
+module dwt.internal.cocoa;
+
+public class WebFrameView : NSObject {
+
+public WebFrameView() {
+    super();
+}
+
+public WebFrameView(int id) {
+    super(id);
+}
+
+public bool allowsScrolling() {
+    return OS.objc_msgSend(this.id, OS.sel_allowsScrolling) !is 0;
+}
+
+public bool canPrintHeadersAndFooters() {
+    return OS.objc_msgSend(this.id, OS.sel_canPrintHeadersAndFooters) !is 0;
+}
+
+public NSView  documentView() {
+    int result = OS.objc_msgSend(this.id, OS.sel_documentView);
+    return result !is 0 ? new NSView (result) : null;
+}
+
+public bool documentViewShouldHandlePrint() {
+    return OS.objc_msgSend(this.id, OS.sel_documentViewShouldHandlePrint) !is 0;
+}
+
+public void printDocumentView() {
+    OS.objc_msgSend(this.id, OS.sel_printDocumentView);
+}
+
+public NSPrintOperation printOperationWithPrintInfo(NSPrintInfo printInfo) {
+    int result = OS.objc_msgSend(this.id, OS.sel_printOperationWithPrintInfo_1, printInfo !is null ? printInfo.id : 0);
+    return result !is 0 ? new NSPrintOperation(result) : null;
+}
+
+public void setAllowsScrolling(bool flag) {
+    OS.objc_msgSend(this.id, OS.sel_setAllowsScrolling_1, flag);
+}
+
+public WebFrame webFrame() {
+    int result = OS.objc_msgSend(this.id, OS.sel_webFrame);
+    return result !is 0 ? new WebFrame(result) : null;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebOpenPanelResultListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa;
+
+public class WebOpenPanelResultListener : NSObject {
+
+public WebOpenPanelResultListener(int id) {
+    super(id);
+}
+
+public void cancel() {
+    OS.objc_msgSend(id, OS.sel_cancel);
+}
+
+public void chooseFilename(NSString String) {
+    OS.objc_msgSend(id, OS.sel_chooseFilename_1, String !is null ? String.id : 0);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebPolicyDecisionListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa;
+
+public class WebPolicyDecisionListener : NSObject {
+
+public WebPolicyDecisionListener(int id) {
+    super(id);
+}
+    
+public void download() {
+    OS.objc_msgSend(id, OS.sel_download);
+}
+
+public void use() {
+    OS.objc_msgSend(id, OS.sel_use);
+}
+
+public void ignore() {
+    OS.objc_msgSend(id, OS.sel_ignore);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebPreferences.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,254 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa;
+
+public class WebPreferences : NSObject {
+
+public WebPreferences() {
+    super();
+}
+
+public WebPreferences(int id) {
+    super(id);
+}
+
+//public bool allowsAnimatedImageLooping() {
+//  return OS.objc_msgSend(this.id, OS.sel_allowsAnimatedImageLooping) !is 0;
+//}
+//
+//public bool allowsAnimatedImages() {
+//  return OS.objc_msgSend(this.id, OS.sel_allowsAnimatedImages) !is 0;
+//}
+
+//public bool arePlugInsEnabled() {
+//  return OS.objc_msgSend(this.id, OS.sel_arePlugInsEnabled) !is 0;
+//}
+//
+//public bool autosaves() {
+//  return OS.objc_msgSend(this.id, OS.sel_autosaves) !is 0;
+//}
+
+//public int cacheModel() {
+//  return OS.objc_msgSend(this.id, OS.sel_cacheModel);
+//}
+//
+//public NSString cursiveFontFamily() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_cursiveFontFamily);
+//  return result !is 0 ? new NSString(result) : null;
+//}
+
+//public int defaultFixedFontSize() {
+//  return OS.objc_msgSend(this.id, OS.sel_defaultFixedFontSize);
+//}
+//
+//public int defaultFontSize() {
+//  return OS.objc_msgSend(this.id, OS.sel_defaultFontSize);
+//}
+//
+//public NSString defaultTextEncodingName() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_defaultTextEncodingName);
+//  return result !is 0 ? new NSString(result) : null;
+//}
+
+//public NSString fantasyFontFamily() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_fantasyFontFamily);
+//  return result !is 0 ? new NSString(result) : null;
+//}
+//
+//public NSString fixedFontFamily() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_fixedFontFamily);
+//  return result !is 0 ? new NSString(result) : null;
+//}
+
+public NSString identifier() {
+    int result = OS.objc_msgSend(this.id, OS.sel_identifier);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public id initWithIdentifier(NSString anIdentifier) {
+    int result = OS.objc_msgSend(this.id, OS.sel_initWithIdentifier_1, anIdentifier !is null ? anIdentifier.id : 0);
+    return result !is 0 ? new id(result) : null;
+}
+
+//public bool isJavaEnabled() {
+//  return OS.objc_msgSend(this.id, OS.sel_isJavaEnabled) !is 0;
+//}
+
+//public bool isJavaScriptEnabled() {
+//  return OS.objc_msgSend(this.id, OS.sel_isJavaScriptEnabled) !is 0;
+//}
+//
+//public bool javaScriptCanOpenWindowsAutomatically() {
+//  return OS.objc_msgSend(this.id, OS.sel_javaScriptCanOpenWindowsAutomatically) !is 0;
+//}
+//
+//public bool loadsImagesAutomatically() {
+//  return OS.objc_msgSend(this.id, OS.sel_loadsImagesAutomatically) !is 0;
+//}
+//
+//public int minimumFontSize() {
+//  return OS.objc_msgSend(this.id, OS.sel_minimumFontSize);
+//}
+//
+//public int minimumLogicalFontSize() {
+//  return OS.objc_msgSend(this.id, OS.sel_minimumLogicalFontSize);
+//}
+//
+//public bool privateBrowsingEnabled() {
+//  return OS.objc_msgSend(this.id, OS.sel_privateBrowsingEnabled) !is 0;
+//}
+//
+//public NSString sansSerifFontFamily() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_sansSerifFontFamily);
+//  return result !is 0 ? new NSString(result) : null;
+//}
+//
+//public NSString serifFontFamily() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_serifFontFamily);
+//  return result !is 0 ? new NSString(result) : null;
+//}
+//
+//public void setAllowsAnimatedImageLooping(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setAllowsAnimatedImageLooping_1, flag);
+//}
+//
+//public void setAllowsAnimatedImages(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setAllowsAnimatedImages_1, flag);
+//}
+//
+//public void setAutosaves(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setAutosaves_1, flag);
+//}
+//
+//public void setCacheModel(int cacheModel) {
+//  OS.objc_msgSend(this.id, OS.sel_setCacheModel_1, cacheModel);
+//}
+//
+//public void setCursiveFontFamily(NSString family) {
+//  OS.objc_msgSend(this.id, OS.sel_setCursiveFontFamily_1, family !is null ? family.id : 0);
+//}
+//
+//public void setDefaultFixedFontSize(int size) {
+//  OS.objc_msgSend(this.id, OS.sel_setDefaultFixedFontSize_1, size);
+//}
+//
+//public void setDefaultFontSize(int size) {
+//  OS.objc_msgSend(this.id, OS.sel_setDefaultFontSize_1, size);
+//}
+//
+//public void setDefaultTextEncodingName(NSString encoding) {
+//  OS.objc_msgSend(this.id, OS.sel_setDefaultTextEncodingName_1, encoding !is null ? encoding.id : 0);
+//}
+//
+//public void setFantasyFontFamily(NSString family) {
+//  OS.objc_msgSend(this.id, OS.sel_setFantasyFontFamily_1, family !is null ? family.id : 0);
+//}
+//
+//public void setFixedFontFamily(NSString family) {
+//  OS.objc_msgSend(this.id, OS.sel_setFixedFontFamily_1, family !is null ? family.id : 0);
+//}
+
+public void setJavaEnabled(bool flag) {
+    OS.objc_msgSend(this.id, OS.sel_setJavaEnabled_1, flag);
+}
+
+//public void setJavaScriptCanOpenWindowsAutomatically(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setJavaScriptCanOpenWindowsAutomatically_1, flag);
+//}
+//
+//public void setJavaScriptEnabled(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setJavaScriptEnabled_1, flag);
+//}
+//
+//public void setLoadsImagesAutomatically(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setLoadsImagesAutomatically_1, flag);
+//}
+//
+//public void setMinimumFontSize(int size) {
+//  OS.objc_msgSend(this.id, OS.sel_setMinimumFontSize_1, size);
+//}
+//
+//public void setMinimumLogicalFontSize(int size) {
+//  OS.objc_msgSend(this.id, OS.sel_setMinimumLogicalFontSize_1, size);
+//}
+//
+//public void setPlugInsEnabled(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setPlugInsEnabled_1, flag);
+//}
+//
+//public void setPrivateBrowsingEnabled(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setPrivateBrowsingEnabled_1, flag);
+//}
+//
+//public void setSansSerifFontFamily(NSString family) {
+//  OS.objc_msgSend(this.id, OS.sel_setSansSerifFontFamily_1, family !is null ? family.id : 0);
+//}
+//
+//public void setSerifFontFamily(NSString family) {
+//  OS.objc_msgSend(this.id, OS.sel_setSerifFontFamily_1, family !is null ? family.id : 0);
+//}
+//
+//public void setShouldPrintBackgrounds(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setShouldPrintBackgrounds_1, flag);
+//}
+//
+//public void setStandardFontFamily(NSString family) {
+//  OS.objc_msgSend(this.id, OS.sel_setStandardFontFamily_1, family !is null ? family.id : 0);
+//}
+//
+//public void setTabsToLinks(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setTabsToLinks_1, flag);
+//}
+//
+//public void setUserStyleSheetEnabled(bool flag) {
+//  OS.objc_msgSend(this.id, OS.sel_setUserStyleSheetEnabled_1, flag);
+//}
+//
+//public void setUserStyleSheetLocation(NSURL URL) {
+//  OS.objc_msgSend(this.id, OS.sel_setUserStyleSheetLocation_1, URL !is null ? URL.id : 0);
+//}
+//
+//public void setUsesPageCache(bool usesPageCache) {
+//  OS.objc_msgSend(this.id, OS.sel_setUsesPageCache_1, usesPageCache);
+//}
+//
+//public bool shouldPrintBackgrounds() {
+//  return OS.objc_msgSend(this.id, OS.sel_shouldPrintBackgrounds) !is 0;
+//}
+//
+//public NSString standardFontFamily() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_standardFontFamily);
+//  return result !is 0 ? new NSString(result) : null;
+//}
+//
+public static WebPreferences standardPreferences() {
+    int result = OS.objc_msgSend(OS.class_WebPreferences, OS.sel_standardPreferences);
+    return result !is 0 ? new WebPreferences(result) : null;
+}
+//
+//public bool tabsToLinks() {
+//  return OS.objc_msgSend(this.id, OS.sel_tabsToLinks) !is 0;
+//}
+//
+//public bool userStyleSheetEnabled() {
+//  return OS.objc_msgSend(this.id, OS.sel_userStyleSheetEnabled) !is 0;
+//}
+//
+//public NSURL userStyleSheetLocation() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_userStyleSheetLocation);
+//  return result !is 0 ? new NSURL(result) : null;
+//}
+//
+//public bool usesPageCache() {
+//  return OS.objc_msgSend(this.id, OS.sel_usesPageCache) !is 0;
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/WebView.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,596 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.internal.cocoa;
+
+public class WebView : NSView {
+
+public WebView() {
+    super();
+}
+
+public WebView(int id) {
+    super(id);
+}
+
+public static NSArray MIMETypesShownAsHTML() {
+    int result = OS.objc_msgSend(OS.class_WebView, OS.sel_MIMETypesShownAsHTML);
+    return result !is 0 ? new NSArray(result) : null;
+}
+
+public id UIDelegate() {
+    int result = OS.objc_msgSend(this.id, OS.sel_UIDelegate);
+    return result !is 0 ? new id(result) : null;
+}
+
+public static NSURL URLFromPasteboard(NSPasteboard pasteboard) {
+    int result = OS.objc_msgSend(OS.class_WebView, OS.sel_URLFromPasteboard_1, pasteboard !is null ? pasteboard.id : 0);
+    return result !is 0 ? new NSURL(result) : null;
+}
+
+public static NSString URLTitleFromPasteboard(NSPasteboard pasteboard) {
+    int result = OS.objc_msgSend(OS.class_WebView, OS.sel_URLTitleFromPasteboard_1, pasteboard !is null ? pasteboard.id : 0);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public void alignCenter(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_alignCenter_1, sender !is null ? sender.id : 0);
+}
+
+public void alignJustified(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_alignJustified_1, sender !is null ? sender.id : 0);
+}
+
+public void alignLeft(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_alignLeft_1, sender !is null ? sender.id : 0);
+}
+
+public void alignRight(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_alignRight_1, sender !is null ? sender.id : 0);
+}
+
+public NSString applicationNameForUserAgent() {
+    int result = OS.objc_msgSend(this.id, OS.sel_applicationNameForUserAgent);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+//public void applyStyle(DOMCSSStyleDeclaration style) {
+//  OS.objc_msgSend(this.id, OS.sel_applyStyle_1, style !is null ? style.id : 0);
+//}
+//
+//public WebBackForwardList backForwardList() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_backForwardList);
+//  return result !is 0 ? new WebBackForwardList(result) : null;
+//}
+
+public bool canGoBack() {
+    return OS.objc_msgSend(this.id, OS.sel_canGoBack) !is 0;
+}
+
+public bool canGoForward() {
+    return OS.objc_msgSend(this.id, OS.sel_canGoForward) !is 0;
+}
+
+public bool canMakeTextLarger() {
+    return OS.objc_msgSend(this.id, OS.sel_canMakeTextLarger) !is 0;
+}
+
+public bool canMakeTextSmaller() {
+    return OS.objc_msgSend(this.id, OS.sel_canMakeTextSmaller) !is 0;
+}
+
+public bool canMakeTextStandardSize() {
+    return OS.objc_msgSend(this.id, OS.sel_canMakeTextStandardSize) !is 0;
+}
+
+public static bool canShowMIMEType(NSString MIMEType) {
+    return OS.objc_msgSend(OS.class_WebView, OS.sel_canShowMIMEType_1, MIMEType !is null ? MIMEType.id : 0) !is 0;
+}
+
+public static bool canShowMIMETypeAsHTML(NSString MIMEType) {
+    return OS.objc_msgSend(OS.class_WebView, OS.sel_canShowMIMETypeAsHTML_1, MIMEType !is null ? MIMEType.id : 0) !is 0;
+}
+
+public void changeAttributes(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_changeAttributes_1, sender !is null ? sender.id : 0);
+}
+
+public void changeColor(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_changeColor_1, sender !is null ? sender.id : 0);
+}
+
+public void changeDocumentBackgroundColor(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_changeDocumentBackgroundColor_1, sender !is null ? sender.id : 0);
+}
+
+public void changeFont(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_changeFont_1, sender !is null ? sender.id : 0);
+}
+
+public void checkSpelling(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_checkSpelling_1, sender !is null ? sender.id : 0);
+}
+
+public void close() {
+    OS.objc_msgSend(this.id, OS.sel_close);
+}
+
+//public DOMCSSStyleDeclaration computedStyleForElement(DOMElement element, NSString pseudoElement) {
+//  int result = OS.objc_msgSend(this.id, OS.sel_computedStyleForElement_1pseudoElement_1, element !is null ? element.id : 0, pseudoElement !is null ? pseudoElement.id : 0);
+//  return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+//}
+
+public void copy(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_copy_1, sender !is null ? sender.id : 0);
+}
+
+public void copyFont(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_copyFont_1, sender !is null ? sender.id : 0);
+}
+
+public NSString customTextEncodingName() {
+    int result = OS.objc_msgSend(this.id, OS.sel_customTextEncodingName);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public NSString customUserAgent() {
+    int result = OS.objc_msgSend(this.id, OS.sel_customUserAgent);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public void cut(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_cut_1, sender !is null ? sender.id : 0);
+}
+
+public void delete(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_delete_1, sender !is null ? sender.id : 0);
+}
+
+public void deleteSelection() {
+    OS.objc_msgSend(this.id, OS.sel_deleteSelection);
+}
+
+public id downloadDelegate() {
+    int result = OS.objc_msgSend(this.id, OS.sel_downloadDelegate);
+    return result !is 0 ? new id(result) : null;
+}
+
+public bool drawsBackground() {
+    return OS.objc_msgSend(this.id, OS.sel_drawsBackground) !is 0;
+}
+
+//public DOMRange editableDOMRangeForPoint(NSPoint point) {
+//  int result = OS.objc_msgSend(this.id, OS.sel_editableDOMRangeForPoint_1, point);
+//  return result !is 0 ? new DOMRange(result) : null;
+//}
+
+public id editingDelegate() {
+    int result = OS.objc_msgSend(this.id, OS.sel_editingDelegate);
+    return result !is 0 ? new id(result) : null;
+}
+
+public NSDictionary elementAtPoint(NSPoint point) {
+    int result = OS.objc_msgSend(this.id, OS.sel_elementAtPoint_1, point);
+    return result !is 0 ? new NSDictionary(result) : null;
+}
+
+public double estimatedProgress() {
+    return OS.objc_msgSend_fpret(this.id, OS.sel_estimatedProgress);
+}
+
+public id frameLoadDelegate() {
+    int result = OS.objc_msgSend(this.id, OS.sel_frameLoadDelegate);
+    return result !is 0 ? new id(result) : null;
+}
+
+public bool goBack() {
+    return OS.objc_msgSend(this.id, OS.sel_goBack) !is 0;
+}
+
+public void goBack_(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_goBack_1, sender !is null ? sender.id : 0);
+}
+
+public bool goForward() {
+    return OS.objc_msgSend(this.id, OS.sel_goForward) !is 0;
+}
+
+public void goForward_(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_goForward_1, sender !is null ? sender.id : 0);
+}
+//
+//public bool goToBackForwardItem(WebHistoryItem item) {
+//  return OS.objc_msgSend(this.id, OS.sel_goToBackForwardItem_1, item !is null ? item.id : 0) !is 0;
+//}
+
+public NSString groupName() {
+    int result = OS.objc_msgSend(this.id, OS.sel_groupName);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public NSWindow hostWindow() {
+    int result = OS.objc_msgSend(this.id, OS.sel_hostWindow);
+    return result !is 0 ? new NSWindow(result) : null;
+}
+
+public id initWithFrame(NSRect frame, NSString frameName, NSString groupName) {
+    int result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_1frameName_1groupName_1, frame, frameName !is null ? frameName.id : 0, groupName !is null ? groupName.id : 0);
+    return result !is 0 ? new id(result) : null;
+}
+
+public bool isContinuousSpellCheckingEnabled() {
+    return OS.objc_msgSend(this.id, OS.sel_isContinuousSpellCheckingEnabled) !is 0;
+}
+
+public bool isEditable() {
+    return OS.objc_msgSend(this.id, OS.sel_isEditable) !is 0;
+}
+
+public bool isLoading() {
+    return OS.objc_msgSend(this.id, OS.sel_isLoading) !is 0;
+}
+
+public WebFrame mainFrame() {
+    int result = OS.objc_msgSend(this.id, OS.sel_mainFrame);
+    return result !is 0 ? new WebFrame(result) : null;
+}
+
+//public DOMDocument mainFrameDocument() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_mainFrameDocument);
+//  return result !is 0 ? new DOMDocument(result) : null;
+//}
+
+public NSImage mainFrameIcon() {
+    int result = OS.objc_msgSend(this.id, OS.sel_mainFrameIcon);
+    return result !is 0 ? new NSImage(result) : null;
+}
+
+public NSString mainFrameTitle() {
+    int result = OS.objc_msgSend(this.id, OS.sel_mainFrameTitle);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public NSString mainFrameURL() {
+    int result = OS.objc_msgSend(this.id, OS.sel_mainFrameURL);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public bool maintainsInactiveSelection() {
+    return OS.objc_msgSend(this.id, OS.sel_maintainsInactiveSelection) !is 0;
+}
+
+public void makeTextLarger(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_makeTextLarger_1, sender !is null ? sender.id : 0);
+}
+
+public void makeTextSmaller(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_makeTextSmaller_1, sender !is null ? sender.id : 0);
+}
+
+public void makeTextStandardSize(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_makeTextStandardSize_1, sender !is null ? sender.id : 0);
+}
+
+public NSString mediaStyle() {
+    int result = OS.objc_msgSend(this.id, OS.sel_mediaStyle);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public void moveDragCaretToPoint(NSPoint point) {
+    OS.objc_msgSend(this.id, OS.sel_moveDragCaretToPoint_1, point);
+}
+
+public void moveToBeginningOfSentence(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_moveToBeginningOfSentence_1, sender !is null ? sender.id : 0);
+}
+
+public void moveToBeginningOfSentenceAndModifySelection(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_moveToBeginningOfSentenceAndModifySelection_1, sender !is null ? sender.id : 0);
+}
+
+public void moveToEndOfSentence(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_moveToEndOfSentence_1, sender !is null ? sender.id : 0);
+}
+
+public void moveToEndOfSentenceAndModifySelection(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_moveToEndOfSentenceAndModifySelection_1, sender !is null ? sender.id : 0);
+}
+
+public void paste(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_paste_1, sender !is null ? sender.id : 0);
+}
+
+public void pasteAsPlainText(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_pasteAsPlainText_1, sender !is null ? sender.id : 0);
+}
+
+public void pasteAsRichText(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_pasteAsRichText_1, sender !is null ? sender.id : 0);
+}
+
+public void pasteFont(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_pasteFont_1, sender !is null ? sender.id : 0);
+}
+
+public NSArray pasteboardTypesForElement(NSDictionary element) {
+    int result = OS.objc_msgSend(this.id, OS.sel_pasteboardTypesForElement_1, element !is null ? element.id : 0);
+    return result !is 0 ? new NSArray(result) : null;
+}
+
+public NSArray pasteboardTypesForSelection() {
+    int result = OS.objc_msgSend(this.id, OS.sel_pasteboardTypesForSelection);
+    return result !is 0 ? new NSArray(result) : null;
+}
+
+public void performFindPanelAction(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_performFindPanelAction_1, sender !is null ? sender.id : 0);
+}
+
+public id policyDelegate() {
+    int result = OS.objc_msgSend(this.id, OS.sel_policyDelegate);
+    return result !is 0 ? new id(result) : null;
+}
+
+//public WebPreferences preferences() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_preferences);
+//  return result !is 0 ? new WebPreferences(result) : null;
+//}
+
+public NSString preferencesIdentifier() {
+    int result = OS.objc_msgSend(this.id, OS.sel_preferencesIdentifier);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+public static void registerURLSchemeAsLocal(NSString scheme) {
+    OS.objc_msgSend(OS.class_WebView, OS.sel_registerURLSchemeAsLocal_1, scheme !is null ? scheme.id : 0);
+}
+
+public static void registerViewClass(int viewClass, int representationClass, NSString MIMEType) {
+    OS.objc_msgSend(OS.class_WebView, OS.sel_registerViewClass_1representationClass_1forMIMEType_1, viewClass, representationClass, MIMEType !is null ? MIMEType.id : 0);
+}
+
+public void reload(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_reload_1, sender !is null ? sender.id : 0);
+}
+
+public void removeDragCaret() {
+    OS.objc_msgSend(this.id, OS.sel_removeDragCaret);
+}
+
+//public void replaceSelectionWithArchive(WebArchive archive) {
+//  OS.objc_msgSend(this.id, OS.sel_replaceSelectionWithArchive_1, archive !is null ? archive.id : 0);
+//}
+
+public void replaceSelectionWithMarkupString(NSString markupString) {
+    OS.objc_msgSend(this.id, OS.sel_replaceSelectionWithMarkupString_1, markupString !is null ? markupString.id : 0);
+}
+
+//public void replaceSelectionWithNode(DOMNode node) {
+//  OS.objc_msgSend(this.id, OS.sel_replaceSelectionWithNode_1, node !is null ? node.id : 0);
+//}
+
+public void replaceSelectionWithText(NSString text) {
+    OS.objc_msgSend(this.id, OS.sel_replaceSelectionWithText_1, text !is null ? text.id : 0);
+}
+
+public id resourceLoadDelegate() {
+    int result = OS.objc_msgSend(this.id, OS.sel_resourceLoadDelegate);
+    return result !is 0 ? new id(result) : null;
+}
+
+//public bool searchFor(NSString String, bool forward, bool caseFlag, bool wrapFlag) {
+//  return OS.objc_msgSend(this.id, OS.sel_searchFor_1direction_1caseSensitive_1wrap_1, String !is null ? String.id : 0, forward, caseFlag, wrapFlag) !is 0;
+//}
+
+public void selectSentence(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_selectSentence_1, sender !is null ? sender.id : 0);
+}
+
+//public DOMRange selectedDOMRange() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_selectedDOMRange);
+//  return result !is 0 ? new DOMRange(result) : null;
+//}
+
+//public WebFrame selectedFrame() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_selectedFrame);
+//  return result !is 0 ? new WebFrame(result) : null;
+//}
+
+public int selectionAffinity() {
+    return OS.objc_msgSend(this.id, OS.sel_selectionAffinity);
+}
+
+public void setApplicationNameForUserAgent(NSString applicationName) {
+    OS.objc_msgSend(this.id, OS.sel_setApplicationNameForUserAgent_1, applicationName !is null ? applicationName.id : 0);
+}
+
+public void setContinuousSpellCheckingEnabled(bool flag) {
+    OS.objc_msgSend(this.id, OS.sel_setContinuousSpellCheckingEnabled_1, flag);
+}
+
+public void setCustomTextEncodingName(NSString encodingName) {
+    OS.objc_msgSend(this.id, OS.sel_setCustomTextEncodingName_1, encodingName !is null ? encodingName.id : 0);
+}
+
+public void setCustomUserAgent(NSString userAgentString) {
+    OS.objc_msgSend(this.id, OS.sel_setCustomUserAgent_1, userAgentString !is null ? userAgentString.id : 0);
+}
+
+public void setDownloadDelegate(id delegate) {
+    OS.objc_msgSend(this.id, OS.sel_setDownloadDelegate_1, delegate !is null ? delegate.id : 0);
+}
+
+public void setDrawsBackground(bool drawsBackround) {
+    OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_1, drawsBackround);
+}
+
+public void setEditable(bool flag) {
+    OS.objc_msgSend(this.id, OS.sel_setEditable_1, flag);
+}
+
+public void setEditingDelegate(id delegate) {
+    OS.objc_msgSend(this.id, OS.sel_setEditingDelegate_1, delegate !is null ? delegate.id : 0);
+}
+
+public void setFrameLoadDelegate(id delegate) {
+    OS.objc_msgSend(this.id, OS.sel_setFrameLoadDelegate_1, delegate !is null ? delegate.id : 0);
+}
+
+public void setGroupName(NSString groupName) {
+    OS.objc_msgSend(this.id, OS.sel_setGroupName_1, groupName !is null ? groupName.id : 0);
+}
+
+public void setHostWindow(NSWindow hostWindow) {
+    OS.objc_msgSend(this.id, OS.sel_setHostWindow_1, hostWindow !is null ? hostWindow.id : 0);
+}
+
+public static void setMIMETypesShownAsHTML(NSArray MIMETypes) {
+    OS.objc_msgSend(OS.class_WebView, OS.sel_setMIMETypesShownAsHTML_1, MIMETypes !is null ? MIMETypes.id : 0);
+}
+
+public void setMainFrameURL(NSString URLString) {
+    OS.objc_msgSend(this.id, OS.sel_setMainFrameURL_1, URLString !is null ? URLString.id : 0);
+}
+
+public void setMaintainsBackForwardList(bool flag) {
+    OS.objc_msgSend(this.id, OS.sel_setMaintainsBackForwardList_1, flag);
+}
+
+public void setMediaStyle(NSString mediaStyle) {
+    OS.objc_msgSend(this.id, OS.sel_setMediaStyle_1, mediaStyle !is null ? mediaStyle.id : 0);
+}
+
+public void setPolicyDelegate(id delegate) {
+    OS.objc_msgSend(this.id, OS.sel_setPolicyDelegate_1, delegate !is null ? delegate.id : 0);
+}
+
+//public void setPreferences(WebPreferences prefs) {
+//  OS.objc_msgSend(this.id, OS.sel_setPreferences_1, prefs !is null ? prefs.id : 0);
+//}
+
+public void setPreferencesIdentifier(NSString anIdentifier) {
+    OS.objc_msgSend(this.id, OS.sel_setPreferencesIdentifier_1, anIdentifier !is null ? anIdentifier.id : 0);
+}
+
+public void setResourceLoadDelegate(id delegate) {
+    OS.objc_msgSend(this.id, OS.sel_setResourceLoadDelegate_1, delegate !is null ? delegate.id : 0);
+}
+
+//public void setSelectedDOMRange(DOMRange range, int selectionAffinity) {
+//  OS.objc_msgSend(this.id, OS.sel_setSelectedDOMRange_1affinity_1, range !is null ? range.id : 0, selectionAffinity);
+//}
+
+public void setShouldCloseWithWindow(bool close) {
+    OS.objc_msgSend(this.id, OS.sel_setShouldCloseWithWindow_1, close);
+}
+
+public void setSmartInsertDeleteEnabled(bool flag) {
+    OS.objc_msgSend(this.id, OS.sel_setSmartInsertDeleteEnabled_1, flag);
+}
+
+public void setTextSizeMultiplier(float multiplier) {
+    OS.objc_msgSend(this.id, OS.sel_setTextSizeMultiplier_1, multiplier);
+}
+
+//public void setTypingStyle(DOMCSSStyleDeclaration style) {
+//  OS.objc_msgSend(this.id, OS.sel_setTypingStyle_1, style !is null ? style.id : 0);
+//}
+
+public void setUIDelegate(id delegate) {
+    OS.objc_msgSend(this.id, OS.sel_setUIDelegate_1, delegate !is null ? delegate.id : 0);
+}
+
+public bool shouldCloseWithWindow() {
+    return OS.objc_msgSend(this.id, OS.sel_shouldCloseWithWindow) !is 0;
+}
+
+public void showGuessPanel(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_showGuessPanel_1, sender !is null ? sender.id : 0);
+}
+
+public bool smartInsertDeleteEnabled() {
+    return OS.objc_msgSend(this.id, OS.sel_smartInsertDeleteEnabled) !is 0;
+}
+
+public int spellCheckerDocumentTag() {
+    return OS.objc_msgSend(this.id, OS.sel_spellCheckerDocumentTag);
+}
+
+public void startSpeaking(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_startSpeaking_1, sender !is null ? sender.id : 0);
+}
+
+public void stopLoading(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_stopLoading_1, sender !is null ? sender.id : 0);
+}
+
+public void stopSpeaking(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_stopSpeaking_1, sender !is null ? sender.id : 0);
+}
+
+public NSString StringByEvaluatingJavaScriptFromString(NSString script) {
+    int result = OS.objc_msgSend(this.id, OS.sel_StringByEvaluatingJavaScriptFromString_1, script !is null ? script.id : 0);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+//public DOMCSSStyleDeclaration styleDeclarationWithText(NSString text) {
+//  int result = OS.objc_msgSend(this.id, OS.sel_styleDeclarationWithText_1, text !is null ? text.id : 0);
+//  return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+//}
+
+public bool supportsTextEncoding() {
+    return OS.objc_msgSend(this.id, OS.sel_supportsTextEncoding) !is 0;
+}
+
+public void takeStringURLFrom(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_takeStringURLFrom_1, sender !is null ? sender.id : 0);
+}
+
+public float textSizeMultiplier() {
+    return (float)OS.objc_msgSend_fpret(this.id, OS.sel_textSizeMultiplier);
+}
+
+public void toggleContinuousSpellChecking(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_toggleContinuousSpellChecking_1, sender !is null ? sender.id : 0);
+}
+
+public void toggleSmartInsertDelete(id sender) {
+    OS.objc_msgSend(this.id, OS.sel_toggleSmartInsertDelete_1, sender !is null ? sender.id : 0);
+}
+
+//public DOMCSSStyleDeclaration typingStyle() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_typingStyle);
+//  return result !is 0 ? new DOMCSSStyleDeclaration(result) : null;
+//}
+
+public NSUndoManager undoManager() {
+    int result = OS.objc_msgSend(this.id, OS.sel_undoManager);
+    return result !is 0 ? new NSUndoManager(result) : null;
+}
+
+public NSString userAgentForURL(NSURL URL) {
+    int result = OS.objc_msgSend(this.id, OS.sel_userAgentForURL_1, URL !is null ? URL.id : 0);
+    return result !is 0 ? new NSString(result) : null;
+}
+
+//public WebScriptObject windowScriptObject() {
+//  int result = OS.objc_msgSend(this.id, OS.sel_windowScriptObject);
+//  return result !is 0 ? new WebScriptObject(result) : null;
+//}
+
+public void writeElement(NSDictionary element, NSArray types, NSPasteboard pasteboard) {
+    OS.objc_msgSend(this.id, OS.sel_writeElement_1withPasteboardTypes_1toPasteboard_1, element !is null ? element.id : 0, types !is null ? types.id : 0, pasteboard !is null ? pasteboard.id : 0);
+}
+
+public void writeSelectionWithPasteboardTypes(NSArray types, NSPasteboard pasteboard) {
+    OS.objc_msgSend(this.id, OS.sel_writeSelectionWithPasteboardTypes_1toPasteboard_1, types !is null ? types.id : 0, pasteboard !is null ? pasteboard.id : 0);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/gl.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,27 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.cocoa.gl;
+
+alias uint GLenum;
+alias ubyte GLboolean;
+alias uint GLbitfield;
+alias byte GLbyte;
+alias short GLshort;
+alias int GLint;
+alias int GLsizei;
+alias ubyte GLubyte;
+alias ushort GLushort;
+alias uint GLuint;
+alias float GLfloat;
+alias float GLclampf;
+alias double GLdouble;
+alias double GLclampd;
+alias void GLvoid;
+
+alias int GLintptr;
+alias int GLsizeiptr;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/id.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.id;
+
+import objc = dwt.internal.objc.runtime;
+
+public class id
+{
+    public objc.id id_;
+
+    public this ()
+    {
+    }
+
+    public this (objc.id id_)
+    {
+        this.id_ = id_;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/objc_super.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 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:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.objc_super;
+
+import dwt.dwthelper.utils;
+import dwt.internal.objc.objc : id;
+
+public class objc_super {
+    public id receiver;
+    public id cls;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/FileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+
+/**
+ * Abstract factory class for loading/unloading images from files or streams
+ * in various image file formats.
+ *
+ */
+public abstract class FileFormat {
+    static final String FORMAT_PACKAGE = "dwt.internal.image"; //$NON-NLS-1$
+    static final String FORMAT_SUFFIX = "FileFormat"; //$NON-NLS-1$
+    static final String[] FORMATS = {"WinBMP", "WinBMP", "GIF", "WinICO", "JPEG", "PNG", "TIFF", "OS2BMP"}; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$//$NON-NLS-7$//$NON-NLS-8$
+    
+    LEDataInputStream inputStream;
+    LEDataOutputStream outputStream;
+    ImageLoader loader;
+    int compression;
+
+/**
+ * Return whether or not the specified input stream
+ * represents a supported file format.
+ */
+abstract bool isFileFormat(LEDataInputStream stream);
+
+abstract ImageData[] loadFromByteStream();
+
+/**
+ * Read the specified input stream, and return the
+ * device independent image array represented by the stream.
+ */ 
+public ImageData[] loadFromStream(LEDataInputStream stream) {
+    try {
+        inputStream = stream;
+        return loadFromByteStream();
+    } catch (Exception e) {
+        if (e instanceof IOException) {
+            DWT.error(DWT.ERROR_IO, e);
+        } else {
+            DWT.error(DWT.ERROR_INVALID_IMAGE, e);
+        }
+        return null;
+    }
+}
+
+/**
+ * Read the specified input stream using the specified loader, and
+ * return the device independent image array represented by the stream.
+ */ 
+public static ImageData[] load(InputStream is, ImageLoader loader) {
+    FileFormat fileFormat = null;
+    LEDataInputStream stream = new LEDataInputStream(is);
+    bool isSupported = false;   
+    for (int i = 1; i < FORMATS.length; i++) {
+        if (FORMATS[i] !is null) {
+            try {
+                Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[i] + FORMAT_SUFFIX);
+                fileFormat = (FileFormat) clazz.newInstance();
+                if (fileFormat.isFileFormat(stream)) {
+                    isSupported = true;
+                    break;
+                }
+            } catch (ClassNotFoundException e) {
+                FORMATS[i] = null;
+            } catch (Exception e) {
+            }
+        }
+    }
+    if (!isSupported) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+    fileFormat.loader = loader;
+    return fileFormat.loadFromStream(stream);
+}
+
+/**
+ * Write the device independent image array stored in the specified loader
+ * to the specified output stream using the specified file format.
+ */ 
+public static void save(OutputStream os, int format, ImageLoader loader) {
+    if (format < 0 || format >= FORMATS.length) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+    if (FORMATS[format] is null) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+    if (loader.data is null || loader.data.length < 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+
+    LEDataOutputStream stream = new LEDataOutputStream(os);
+    FileFormat fileFormat = null;
+    try {
+        Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[format] + FORMAT_SUFFIX);
+        fileFormat = (FileFormat) clazz.newInstance();
+    } catch (Exception e) {
+        DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+    }
+    if (format is DWT.IMAGE_BMP_RLE) {
+        switch (loader.data[0].depth) {
+            case 8: fileFormat.compression = 1; break;
+            case 4: fileFormat.compression = 2; break;
+        }
+    }
+    fileFormat.unloadIntoStream(loader, stream);
+}
+
+abstract void unloadIntoByteStream(ImageLoader loader);
+
+/**
+ * Write the device independent image array stored in the specified loader
+ * to the specified output stream.
+ */ 
+public void unloadIntoStream(ImageLoader loader, LEDataOutputStream stream) {
+    try {
+        outputStream = stream;
+        unloadIntoByteStream(loader);
+        outputStream.flush();
+    } catch (Exception e) {
+        try {outputStream.flush();} catch (Exception f) {}
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/GIFFileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,619 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.ImageLoaderEvent;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+
+public final class GIFFileFormat : FileFormat {
+    String signature;
+    int screenWidth, screenHeight, backgroundPixel, bitsPerPixel, defaultDepth;
+    int disposalMethod = 0;
+    int delayTime = 0;
+    int transparentPixel = -1;
+    int repeatCount = 1;
+    
+    static final int GIF_APPLICATION_EXTENSION_BLOCK_ID = 0xFF;
+    static final int GIF_GRAPHICS_CONTROL_BLOCK_ID = 0xF9;
+    static final int GIF_PLAIN_TEXT_BLOCK_ID = 0x01;
+    static final int GIF_COMMENT_BLOCK_ID = 0xFE;
+    static final int GIF_EXTENSION_BLOCK_ID = 0x21;
+    static final int GIF_IMAGE_BLOCK_ID = 0x2C;
+    static final int GIF_TRAILER_ID = 0x3B;
+    static final byte [] GIF89a = new byte[] { (byte)'G', (byte)'I', (byte)'F', (byte)'8', (byte)'9', (byte)'a' };
+    static final byte [] NETSCAPE2_0 = new byte[] { (byte)'N', (byte)'E', (byte)'T', (byte)'S', (byte)'C', (byte)'A', (byte)'P', (byte)'E', (byte)'2', (byte)'.', (byte)'0' };
+    
+    /**
+     * Answer a palette containing numGrays
+     * shades of gray, ranging from black to white.
+     */
+    static PaletteData grayRamp(int numGrays) {
+        int n = numGrays - 1;
+        RGB[] colors = new RGB[numGrays];
+        for (int i = 0; i < numGrays; i++) {
+            int intensity = (byte)((i * 3) * 256 / n);
+            colors[i] = new RGB(intensity, intensity, intensity);
+        }
+        return new PaletteData(colors);
+    }
+
+    bool isFileFormat(LEDataInputStream stream) {
+        try {
+            byte[] signature = new byte[3];
+            stream.read(signature);
+            stream.unread(signature);
+            return signature[0] is 'G' && signature[1] is 'I' && signature[2] is 'F';
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * Load the GIF image(s) stored in the input stream.
+     * Return an array of ImageData representing the image(s).
+     */
+    ImageData[] loadFromByteStream() {
+        byte[] signature = new byte[3];
+        byte[] versionBytes = new byte[3];
+        byte[] block = new byte[7];
+        try {
+            inputStream.read(signature);
+            if (!(signature[0] is 'G' && signature[1] is 'I' && signature[2] is 'F'))
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+
+            inputStream.read(versionBytes);
+
+            inputStream.read(block);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        screenWidth = (block[0] & 0xFF) | ((block[1] & 0xFF) << 8);
+        loader.logicalScreenWidth = screenWidth;
+        screenHeight = (block[2] & 0xFF) | ((block[3] & 0xFF) << 8);
+        loader.logicalScreenHeight = screenHeight;
+        byte bitField = block[4];
+        backgroundPixel = block[5] & 0xFF;
+        //aspect = block[6] & 0xFF;
+        bitsPerPixel = ((bitField >> 4) & 0x07) + 1;
+        defaultDepth = (bitField & 0x7) + 1;
+        PaletteData palette = null;
+        if ((bitField & 0x80) !is 0) {
+            // Global palette.
+            //sorted = (bitField & 0x8) !is 0;
+            palette = readPalette(1 << defaultDepth);
+        } else {
+            // No global palette.
+            //sorted = false;
+            backgroundPixel = -1;
+            defaultDepth = bitsPerPixel;
+        }
+        loader.backgroundPixel = backgroundPixel;
+
+        getExtensions();
+        int id = readID();
+        ImageData[] images = new ImageData[0];
+        while (id is GIF_IMAGE_BLOCK_ID) {
+            ImageData image = readImageBlock(palette);
+            if (loader.hasListeners()) {
+                loader.notifyListeners(new ImageLoaderEvent(loader, image, 3, true));
+            }
+            ImageData[] oldImages = images;
+            images = new ImageData[oldImages.length + 1];
+            System.arraycopy(oldImages, 0, images, 0, oldImages.length);
+            images[images.length - 1] = image;
+            try {
+                /* Read the 0-byte terminator at the end of the image. */
+                id = inputStream.read();
+                if (id > 0) {
+                    /* We read the terminator earlier. */
+                    inputStream.unread(new byte[] {(byte)id});
+                }
+            } catch (IOException e) {
+                DWT.error(DWT.ERROR_IO, e);
+            }
+            getExtensions();
+            id = readID();
+        }
+        return images;
+    }
+
+    /**
+     * Read and return the next block or extension identifier from the file.
+     */
+    int readID() {
+        try {
+            return inputStream.read();
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        return -1;
+    }
+
+    /**
+     * Read extensions until an image descriptor appears.
+     * In the future, if we care about the extensions, they
+     * should be properly grouped with the image data before
+     * which they appeared. Right now, the interesting parts
+     * of some extensions are kept, but the rest is discarded.
+     * Throw an error if an error occurs.
+     */
+    void getExtensions() {
+        int id = readID();
+        while (id !is GIF_IMAGE_BLOCK_ID && id !is GIF_TRAILER_ID && id > 0) {
+            if (id is GIF_EXTENSION_BLOCK_ID) {
+                readExtension();
+            } else {
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+            }
+            id = readID();
+        }
+        if (id is GIF_IMAGE_BLOCK_ID || id is GIF_TRAILER_ID) {
+            try {
+                inputStream.unread(new byte[] {(byte)id});
+            } catch (IOException e) {
+                DWT.error(DWT.ERROR_IO, e);
+            }
+        }
+    }
+
+    /**
+     * Read a control extension.
+     * Return the extension block data.
+     */
+    byte[] readExtension() {
+        int extensionID = readID();
+        if (extensionID is GIF_COMMENT_BLOCK_ID)
+            return readCommentExtension();
+        if (extensionID is GIF_PLAIN_TEXT_BLOCK_ID)
+            return readPlainTextExtension();
+        if (extensionID is GIF_GRAPHICS_CONTROL_BLOCK_ID)
+            return readGraphicsControlExtension();
+        if (extensionID is GIF_APPLICATION_EXTENSION_BLOCK_ID)
+            return readApplicationExtension();
+        // Otherwise, we don't recognize the block. If the
+        // field size is correct, we can just skip over
+        // the block contents.
+        try {
+            int extSize = inputStream.read();
+            if (extSize < 0) {
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+            }
+            byte[] ext = new byte[extSize];
+            inputStream.read(ext, 0, extSize);
+            return ext;
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+            return null;
+        }
+    }
+
+    /**
+     * We have just read the Comment extension identifier
+     * from the input stream. Read in the rest of the comment
+     * and return it. GIF comment blocks are variable size.
+     */
+    byte[] readCommentExtension() {
+        try {
+            byte[] comment = new byte[0];
+            byte[] block = new byte[255];
+            int size = inputStream.read();
+            while ((size > 0) && (inputStream.read(block, 0, size) !is -1)) {
+                byte[] oldComment = comment;
+                comment = new byte[oldComment.length + size];
+                System.arraycopy(oldComment, 0, comment, 0, oldComment.length);
+                System.arraycopy(block, 0, comment, oldComment.length, size);
+                size = inputStream.read();
+            }
+            return comment;
+        } catch (Exception e) {
+            DWT.error(DWT.ERROR_IO, e);
+            return null;
+        }
+    }
+
+    /**
+     * We have just read the PlainText extension identifier
+     * from the input stream. Read in the plain text info and text,
+     * and return the text. GIF plain text blocks are variable size.
+     */
+    byte[] readPlainTextExtension() {
+        try {
+            // Read size of block = 0x0C.
+            inputStream.read();
+            // Read the text information (x, y, width, height, colors).
+            byte[] info = new byte[12];
+            inputStream.read(info);
+            // Read the text.
+            byte[] text = new byte[0];
+            byte[] block = new byte[255];
+            int size = inputStream.read();
+            while ((size > 0) && (inputStream.read(block, 0, size) !is -1)) {
+                byte[] oldText = text;
+                text = new byte[oldText.length + size];
+                System.arraycopy(oldText, 0, text, 0, oldText.length);
+                System.arraycopy(block, 0, text, oldText.length, size);
+                size = inputStream.read();
+            }
+            return text;
+        } catch (Exception e) {
+            DWT.error(DWT.ERROR_IO, e);
+            return null;
+        }
+    }
+
+    /**
+     * We have just read the GraphicsControl extension identifier
+     * from the input stream. Read in the control information, store
+     * it, and return it.
+     */
+    byte[] readGraphicsControlExtension() {
+        try {
+            // Read size of block = 0x04.
+            inputStream.read();
+            // Read the control block.
+            byte[] controlBlock = new byte[4];
+            inputStream.read(controlBlock);
+            byte bitField = controlBlock[0];
+            // Store the user input field.
+            //userInput = (bitField & 0x02) !is 0;
+            // Store the disposal method.
+            disposalMethod = (bitField >> 2) & 0x07;
+            // Store the delay time.
+            delayTime = (controlBlock[1] & 0xFF) | ((controlBlock[2] & 0xFF) << 8);
+            // Store the transparent color.
+            if ((bitField & 0x01) !is 0) {
+                transparentPixel = controlBlock[3] & 0xFF;
+            } else {
+                transparentPixel = -1;
+            }
+            // Read block terminator.
+            inputStream.read();
+            return controlBlock;
+        } catch (Exception e) {
+            DWT.error(DWT.ERROR_IO, e);
+            return null;
+        }
+    }
+
+    /**
+     * We have just read the Application extension identifier
+     * from the input stream.  Read in the rest of the extension,
+     * look for and store 'number of repeats', and return the data.
+     */
+    byte[] readApplicationExtension() {
+        try {
+            // Read size of block = 0x0B.
+            inputStream.read();
+            // Read application identifier.
+            byte[] application = new byte[8];
+            inputStream.read(application);
+            // Read authentication code.
+            byte[] authentication = new byte[3];
+            inputStream.read(authentication);
+            // Read application data.
+            byte[] data = new byte[0];
+            byte[] block = new byte[255];
+            int size = inputStream.read();
+            while ((size > 0) && (inputStream.read(block, 0, size) !is -1)) {
+                byte[] oldData = data;
+                data = new byte[oldData.length + size];
+                System.arraycopy(oldData, 0, data, 0, oldData.length);
+                System.arraycopy(block, 0, data, oldData.length, size);
+                size = inputStream.read();
+            }
+            // Look for the NETSCAPE 'repeat count' field for an animated GIF.
+            bool netscape =
+                application[0] is 'N' &&
+                application[1] is 'E' &&
+                application[2] is 'T' &&
+                application[3] is 'S' &&
+                application[4] is 'C' &&
+                application[5] is 'A' &&
+                application[6] is 'P' &&
+                application[7] is 'E';
+            bool authentic =
+                authentication[0] is '2' &&
+                authentication[1] is '.' &&
+                authentication[2] is '0';
+            if (netscape && authentic && data[0] is 01) { //$NON-NLS-1$ //$NON-NLS-2$
+                repeatCount = (data[1] & 0xFF) | ((data[2] & 0xFF) << 8);
+                loader.repeatCount = repeatCount;
+            }
+            return data;
+        } catch (Exception e) {
+            DWT.error(DWT.ERROR_IO, e);
+            return null;
+        }
+    }
+
+    /**
+     * Return a DeviceIndependentImage representing the
+     * image block at the current position in the input stream.
+     * Throw an error if an error occurs.
+     */
+    ImageData readImageBlock(PaletteData defaultPalette) {
+        int depth;
+        PaletteData palette;
+        byte[] block = new byte[9];
+        try {
+            inputStream.read(block);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        int left = (block[0] & 0xFF) | ((block[1] & 0xFF) << 8);
+        int top = (block[2] & 0xFF) | ((block[3] & 0xFF) << 8);
+        int width = (block[4] & 0xFF) | ((block[5] & 0xFF) << 8);
+        int height = (block[6] & 0xFF) | ((block[7] & 0xFF) << 8);
+        byte bitField = block[8];
+        bool interlaced = (bitField & 0x40) !is 0;
+        //bool sorted = (bitField & 0x20) !is 0;
+        if ((bitField & 0x80) !is 0) {
+            // Local palette.
+            depth = (bitField & 0x7) + 1;
+            palette = readPalette(1 << depth);
+        } else {
+            // No local palette.
+            depth = defaultDepth;
+            palette = defaultPalette;
+        }
+        /* Work around: Ignore the case where a GIF specifies an
+         * invalid index for the transparent pixel that is larger
+         * than the number of entries in the palette. */
+        if (transparentPixel > 1 << depth) {
+            transparentPixel = -1;
+        }
+        // Promote depth to next highest supported value.
+        if (!(depth is 1 || depth is 4 || depth is 8)) {
+            if (depth < 4)
+                depth = 4;
+            else
+                depth = 8;
+        }
+        if (palette is null) {
+            palette = grayRamp(1 << depth);
+        }
+        int initialCodeSize = -1;
+        try {
+            initialCodeSize = inputStream.read();
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        if (initialCodeSize < 0) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+        ImageData image = ImageData.internal_new(
+            width,
+            height,
+            depth,
+            palette,
+            4,
+            null,
+            0,
+            null,
+            null,
+            -1,
+            transparentPixel,
+            DWT.IMAGE_GIF,
+            left,
+            top,
+            disposalMethod,
+            delayTime); 
+        LZWCodec codec = new LZWCodec();
+        codec.decode(inputStream, loader, image, interlaced, initialCodeSize);
+        return image;
+    }
+
+    /**
+     * Read a palette from the input stream.
+     */
+    PaletteData readPalette(int numColors) {
+        byte[] bytes = new byte[numColors * 3];
+        try {
+            if (inputStream.read(bytes) !is bytes.length)
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        RGB[] colors = new RGB[numColors];
+        for (int i = 0; i < numColors; i++)
+            colors[i] = new RGB(bytes[i*3] & 0xFF, 
+                bytes[i*3+1] & 0xFF, bytes[i*3+2] & 0xFF);
+        return new PaletteData(colors);
+    }
+
+    void unloadIntoByteStream(ImageLoader loader) {
+        
+        /* Step 1: Acquire GIF parameters. */
+        ImageData[] data = loader.data;
+        int frameCount = data.length;
+        bool multi = frameCount > 1;
+        ImageData firstImage = data[0];
+        int logicalScreenWidth = multi ? loader.logicalScreenWidth : firstImage.width;
+        int logicalScreenHeight = multi ? loader.logicalScreenHeight : firstImage.height;
+        int backgroundPixel = loader.backgroundPixel;
+        int depth = firstImage.depth;
+        PaletteData palette = firstImage.palette;
+        RGB[] colors = palette.getRGBs();
+        short globalTable = 1;
+                
+        /* Step 2: Check for validity and global/local color map. */
+        if (!(depth is 1 || depth is 4 || depth is 8)) {
+            DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+        }
+        for (int i=0; i<frameCount; i++) {
+            if (data[i].palette.isDirect) {
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+            }
+            if (multi) {
+                if (!(data[i].height <= logicalScreenHeight && data[i].width <= logicalScreenWidth && data[i].depth is depth)) {
+                    DWT.error(DWT.ERROR_INVALID_IMAGE);
+                }
+                if (globalTable is 1) {
+                    RGB rgbs[] = data[i].palette.getRGBs();
+                    if (rgbs.length !is colors.length) {
+                        globalTable = 0;
+                    } else { 
+                        for (int j=0; j<colors.length; j++) {
+                            if (!(rgbs[j].red is colors[j].red &&
+                                rgbs[j].green is colors[j].green &&
+                                rgbs[j].blue is colors[j].blue))
+                                    globalTable = 0;
+                        }
+                    }
+                }
+            }
+        }
+        
+        try {
+            /* Step 3: Write the GIF89a Header and Logical Screen Descriptor. */
+            outputStream.write(GIF89a);
+            int bitField = globalTable*128 + (depth-1)*16 + depth-1;
+            outputStream.writeShort((short)logicalScreenWidth);
+            outputStream.writeShort((short)logicalScreenHeight);
+            outputStream.write(bitField);
+            outputStream.write(backgroundPixel);
+            outputStream.write(0); // Aspect ratio is 1:1
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        
+        /* Step 4: Write Global Color Table if applicable. */
+        if (globalTable is 1) {
+            writePalette(palette, depth);
+        }
+
+        /* Step 5: Write Application Extension if applicable. */
+        if (multi) {
+            int repeatCount = loader.repeatCount;
+            try {
+                outputStream.write(GIF_EXTENSION_BLOCK_ID);
+                outputStream.write(GIF_APPLICATION_EXTENSION_BLOCK_ID);
+                outputStream.write(NETSCAPE2_0.length);
+                outputStream.write(NETSCAPE2_0);
+                outputStream.write(3); // Three bytes follow
+                outputStream.write(1); // Extension type
+                outputStream.writeShort((short) repeatCount);
+                outputStream.write(0); // Block terminator
+            } catch (IOException e) {
+                DWT.error(DWT.ERROR_IO, e);
+            }
+        }
+        
+        for (int frame=0; frame<frameCount; frame++) {
+            
+            /* Step 6: Write Graphics Control Block for each frame if applicable. */
+            if (multi || data[frame].transparentPixel !is -1) {
+                writeGraphicsControlBlock(data[frame]);
+            }
+            
+            /* Step 7: Write Image Header for each frame. */
+            int x = data[frame].x;
+            int y = data[frame].y;
+            int width = data[frame].width;
+            int height = data[frame].height;
+            try {
+                outputStream.write(GIF_IMAGE_BLOCK_ID);
+                byte[] block = new byte[9];
+                block[0] = (byte)(x & 0xFF);
+                block[1] = (byte)((x >> 8) & 0xFF);
+                block[2] = (byte)(y & 0xFF);
+                block[3] = (byte)((y >> 8) & 0xFF);
+                block[4] = (byte)(width & 0xFF);
+                block[5] = (byte)((width >> 8) & 0xFF);
+                block[6] = (byte)(height & 0xFF);
+                block[7] = (byte)((height >> 8) & 0xFF); 
+                block[8] = (byte)(globalTable is 0 ? (depth-1) | 0x80 : 0x00);
+                outputStream.write(block);
+            } catch (IOException e) {
+                DWT.error(DWT.ERROR_IO, e);
+            }
+            
+            /* Step 8: Write Local Color Table for each frame if applicable. */
+            if (globalTable is 0) {
+                writePalette(data[frame].palette, depth);
+            }
+            
+            /* Step 9: Write the actual data for each frame. */
+            try {
+                outputStream.write(depth); // Minimum LZW Code size
+            } catch (IOException e) {
+                DWT.error(DWT.ERROR_IO, e);
+            }
+            new LZWCodec().encode(outputStream, data[frame]);
+        }
+
+        /* Step 10: Write GIF terminator. */
+        try {
+            outputStream.write(0x3B);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+
+    /**
+     * Write out a GraphicsControlBlock to describe
+     * the specified device independent image.
+     */
+    void writeGraphicsControlBlock(ImageData image) {
+        try {
+            outputStream.write(GIF_EXTENSION_BLOCK_ID);
+            outputStream.write(GIF_GRAPHICS_CONTROL_BLOCK_ID);
+            byte[] gcBlock = new byte[4];
+            gcBlock[0] = 0;
+            gcBlock[1] = 0;
+            gcBlock[2] = 0;
+            gcBlock[3] = 0;
+            if (image.transparentPixel !is -1) {
+                gcBlock[0] = (byte)0x01;
+                gcBlock[3] = (byte)image.transparentPixel;
+            }
+            if (image.disposalMethod !is 0) {
+                gcBlock[0] |= (byte)((image.disposalMethod & 0x07) << 2);
+            }
+            if (image.delayTime !is 0) {
+                gcBlock[1] = (byte)(image.delayTime & 0xFF);
+                gcBlock[2] = (byte)((image.delayTime >> 8) & 0xFF);
+            }
+            outputStream.write((byte)gcBlock.length);
+            outputStream.write(gcBlock);
+            outputStream.write(0); // Block terminator
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+
+    /**
+     * Write the specified palette to the output stream.
+     */
+    void writePalette(PaletteData palette, int depth) {
+        byte[] bytes = new byte[(1 << depth) * 3];
+        int offset = 0;
+        for (int i = 0; i < palette.colors.length; i++) {
+            RGB color = palette.colors[i];
+            bytes[offset] = (byte)color.red;
+            bytes[offset + 1] = (byte)color.green;
+            bytes[offset + 2] = (byte)color.blue;
+            offset += 3;
+        }
+        try {
+            outputStream.write(bytes);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGAppn.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class JPEGAppn : JPEGVariableSizeSegment {
+
+    public JPEGAppn(byte[] reference) {
+        super(reference);
+    }
+    
+    public JPEGAppn(LEDataInputStream byteStream) {
+        super(byteStream);
+    }
+    
+    public bool verify() {
+        int marker = getSegmentMarker();
+        return marker >= JPEGFileFormat.APP0 && marker <= JPEGFileFormat.APP15;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGArithmeticConditioningTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class JPEGArithmeticConditioningTable : JPEGVariableSizeSegment {
+
+    public JPEGArithmeticConditioningTable(LEDataInputStream byteStream) {
+        super(byteStream);
+    }
+    
+    public int signature() {
+        return JPEGFileFormat.DAC;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGComment.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class JPEGComment : JPEGVariableSizeSegment {
+
+    public JPEGComment(byte[] reference) {
+        super(reference);
+    }
+    
+    public JPEGComment(LEDataInputStream byteStream) {
+        super(byteStream);
+    }
+    
+    public int signature() {
+        return JPEGFileFormat.COM;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGDecoder.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,6365 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.ImageLoaderEvent;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+
+public class JPEGDecoder {
+    
+    static final int DCTSIZE = 8;
+    static final int DCTSIZE2 = 64;
+    static final int NUM_QUANT_TBLS = 4;
+    static final int NUM_HUFF_TBLS = 4;
+    static final int NUM_ARITH_TBLS = 16;
+    static final int MAX_COMPS_IN_SCAN = 4;
+    static final int MAX_COMPONENTS = 10;
+    static final int MAX_SAMP_FACTOR = 4;
+    static final int D_MAX_BLOCKS_IN_MCU = 10;
+    static final int HUFF_LOOKAHEAD = 8;
+    static final int MAX_Q_COMPS = 4;
+    static final int IFAST_SCALE_BITS = 2;
+    static final int MAXJSAMPLE = 255;
+    static final int CENTERJSAMPLE = 128;
+    static final int MIN_GET_BITS = 32-7;
+    static final int INPUT_BUFFER_SIZE = 4096;
+
+    static final int SCALEBITS = 16;    /* speediest right-shift on some machines */
+    static final int ONE_HALF = 1 << (SCALEBITS-1);
+    
+    static final int RGB_RED = 2;   /* Offset of Red in an RGB scanline element */
+    static final int RGB_GREEN = 1; /* Offset of Green */
+    static final int RGB_BLUE = 0;  /* Offset of Blue */
+    static final int RGB_PIXELSIZE = 3;
+    
+    static final int JBUF_PASS_THRU = 0;
+    static final int JBUF_SAVE_SOURCE = 1;  /* Run source subobject only, save output */
+    static final int JBUF_CRANK_DEST = 2;   /* Run dest subobject only, using saved data */
+    static final int JBUF_SAVE_AND_PASS = 3;    
+    
+    static final int JPEG_MAX_DIMENSION = 65500;
+    static final int BITS_IN_JSAMPLE = 8;
+    
+    static final int JDITHER_NONE = 0;      /* no dithering */
+    static final int JDITHER_ORDERED = 1;   /* simple ordered dither */
+    static final int JDITHER_FS = 2;    
+    
+    static final int JDCT_ISLOW = 0;    /* slow but accurate integer algorithm */
+    static final int JDCT_IFAST = 1;    /* faster, less accurate integer method */
+    static final int JDCT_FLOAT = 2;    /* floating-point: accurate, fast on fast HW */
+    static final int JDCT_DEFAULT = JDCT_ISLOW;
+
+    static final int JCS_UNKNOWN = 0;       /* error/unspecified */
+    static final int JCS_GRAYSCALE = 1;     /* monochrome */
+    static final int JCS_RGB = 2;       /* red/green/blue */
+    static final int JCS_YCbCr = 3;     /* Y/Cb/Cr (also known as YUV) */
+    static final int JCS_CMYK = 4;      /* C/M/Y/K */
+    static final int JCS_YCCK = 5;      /* Y/Cb/Cr/K */
+
+    static final int SAVED_COEFS = 6;
+    static final int Q01_POS = 1;
+    static final int Q10_POS = 8;
+    static final int Q20_POS = 16;
+    static final int Q11_POS = 9;
+    static final int Q02_POS = 2;
+    
+    static final int CTX_PREPARE_FOR_IMCU = 0;  /* need to prepare for MCU row */
+    static final int CTX_PROCESS_IMCU = 1;  /* feeding iMCU to postprocessor */
+    static final int CTX_POSTPONED_ROW = 2; /* feeding postponed row group */
+    
+    static final int APP0_DATA_LEN = 14;    /* Length of interesting data in APP0 */
+    static final int APP14_DATA_LEN = 12;   /* Length of interesting data in APP14 */
+    static final int APPN_DATA_LEN = 14;    /* Must be the largest of the above!! */
+
+    /* markers */
+    static final int M_SOF0 = 0xc0;
+    static final int M_SOF1 = 0xc1;
+    static final int M_SOF2 = 0xc2;
+    static final int M_SOF3 = 0xc3;
+    static final int M_SOF5 = 0xc5;
+    static final int M_SOF6 = 0xc6;
+    static final int M_SOF7 = 0xc7;
+    static final int M_JPG = 0xc8;
+    static final int M_SOF9 = 0xc9;
+    static final int M_SOF10 = 0xca;
+    static final int M_SOF11 = 0xcb;
+    static final int M_SOF13 = 0xcd;
+    static final int M_SOF14 = 0xce;
+    static final int M_SOF15 = 0xcf;
+    static final int M_DHT = 0xc4;
+    static final int M_DAC = 0xcc;
+    static final int M_RST0 = 0xd0;
+    static final int M_RST1 = 0xd1;
+    static final int M_RST2 = 0xd2;
+    static final int M_RST3 = 0xd3;
+    static final int M_RST4 = 0xd4;
+    static final int M_RST5 = 0xd5;
+    static final int M_RST6 = 0xd6;
+    static final int M_RST7 = 0xd7;
+    static final int M_SOI = 0xd8;
+    static final int M_EOI = 0xd9;
+    static final int M_SOS = 0xda;
+    static final int M_DQT = 0xdb;
+    static final int M_DNL = 0xdc;
+    static final int M_DRI = 0xdd;
+    static final int M_DHP = 0xde;
+    static final int M_EXP = 0xdf;
+    static final int M_APP0 = 0xe0;
+    static final int M_APP1 = 0xe1;
+    static final int M_APP2 = 0xe2;
+    static final int M_APP3 = 0xe3;
+    static final int M_APP4 = 0xe4;
+    static final int M_APP5 = 0xe5;
+    static final int M_APP6 = 0xe6;
+    static final int M_APP7 = 0xe7;
+    static final int M_APP8 = 0xe8;
+    static final int M_APP9 = 0xe9;
+    static final int M_APP10 = 0xea;
+    static final int M_APP11 = 0xeb;
+    static final int M_APP12 = 0xec;
+    static final int M_APP13 = 0xed;
+    static final int M_APP14 = 0xee;
+    static final int M_APP15 = 0xef;
+    static final int M_JPG0 = 0xf0;
+    static final int M_JPG13 = 0xfd;
+    static final int M_COM = 0xfe;
+    static final int M_TEM = 0x01;
+    static final int M_ERROR = 0x100;
+    
+    /* Values of global_state field (jdapi.c has some dependencies on ordering!) */
+    static final int CSTATE_START = 100;    /* after create_compress */
+    static final int CSTATE_SCANNING = 101; /* start_compress done, write_scanlines OK */
+    static final int CSTATE_RAW_OK = 102;   /* start_compress done, write_raw_data OK */
+    static final int CSTATE_WRCOEFS = 103;  /* jpeg_write_coefficients done */
+    static final int DSTATE_START = 200;    /* after create_decompress */
+    static final int DSTATE_INHEADER = 201; /* reading header markers, no SOS yet */
+    static final int DSTATE_READY = 202;    /* found SOS, ready for start_decompress */
+    static final int DSTATE_PRELOAD = 203;  /* reading multiscan file in start_decompress*/
+    static final int DSTATE_PRESCAN = 204;  /* performing dummy pass for 2-pass quant */
+    static final int DSTATE_SCANNING = 205; /* start_decompress done, read_scanlines OK */
+    static final int DSTATE_RAW_OK = 206;   /* start_decompress done, read_raw_data OK */
+    static final int DSTATE_BUFIMAGE = 207; /* expecting jpeg_start_output */
+    static final int DSTATE_BUFPOST = 208;  /* looking for SOS/EOI in jpeg_finish_output */
+    static final int DSTATE_RDCOEFS = 209;  /* reading file in jpeg_read_coefficients */
+    static final int DSTATE_STOPPING = 210; /* looking for EOI in jpeg_finish_decompress */
+
+    static final int JPEG_REACHED_SOS = 1; /* Reached start of new scan */
+    static final int JPEG_REACHED_EOI = 2; /* Reached end of image */
+    static final int JPEG_ROW_COMPLETED = 3; /* Completed one iMCU row */
+    static final int JPEG_SCAN_COMPLETED = 4; /* Completed last iMCU row of a scan */
+    
+    static final int JPEG_SUSPENDED = 0; /* Suspended due to lack of input data */
+    static final int JPEG_HEADER_OK = 1; /* Found valid image datastream */
+    static final int JPEG_HEADER_TABLES_ONLY = 2; /* Found valid table-specs-only datastream */
+
+    /* Function pointers */
+    static final int DECOMPRESS_DATA = 0;
+    static final int DECOMPRESS_SMOOTH_DATA = 1;
+    static final int DECOMPRESS_ONEPASS = 2;
+    
+    static final int CONSUME_DATA = 0;
+    static final int DUMMY_CONSUME_DATA = 1;
+    
+    static final int PROCESS_DATA_SIMPLE_MAIN = 0;
+    static final int PROCESS_DATA_CONTEXT_MAIN = 1;
+    static final int PROCESS_DATA_CRANK_POST = 2;
+    
+    static final int POST_PROCESS_1PASS = 0;
+    static final int POST_PROCESS_DATA_UPSAMPLE = 1;
+    
+    static final int NULL_CONVERT = 0;
+    static final int GRAYSCALE_CONVERT = 1;
+    static final int YCC_RGB_CONVERT = 2;
+    static final int GRAY_RGB_CONVERT = 3;
+    static final int YCCK_CMYK_CONVERT = 4;
+    
+    static final int NOOP_UPSAMPLE = 0;
+    static final int FULLSIZE_UPSAMPLE = 1;
+    static final int H2V1_FANCY_UPSAMPLE = 2;
+    static final int H2V1_UPSAMPLE = 3;
+    static final int H2V2_FANCY_UPSAMPLE = 4;
+    static final int H2V2_UPSAMPLE = 5;
+    static final int INT_UPSAMPLE = 6;
+    
+    static final int INPUT_CONSUME_INPUT = 0;
+    static final int COEF_CONSUME_INPUT = 1;
+    
+    static int extend_test[] =   /* entry n is 2**(n-1) */
+    {
+        0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
+        0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
+    };
+
+    static int extend_offset[] = /* entry n is (-1 << n) + 1 */
+    {
+        0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
+        ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
+        ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
+        ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1
+    };
+    
+    static int jpeg_natural_order[] = {
+        0,  1,  8, 16,  9,  2,  3, 10,
+        17, 24, 32, 25, 18, 11, 4,  5,
+        12, 19, 26, 33, 40, 48, 41, 34,
+        27, 20, 13, 6,  7, 14, 21, 28,
+        35, 42, 49, 56, 57, 50, 43, 36,
+        29, 22, 15, 23, 30, 37, 44, 51,
+        58, 59, 52, 45, 38, 31, 39, 46,
+        53, 60, 61, 54, 47, 55, 62, 63,
+        63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
+        63, 63, 63, 63, 63, 63, 63, 63
+    };
+    
+    static final class JQUANT_TBL {
+        /* This array gives the coefficient quantizers in natural array order
+         * (not the zigzag order in which they are stored in a JPEG DQT marker).
+         * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
+         */
+        short[] quantval = new short[DCTSIZE2]; /* quantization step for each coefficient */
+        /* This field is used only during compression.  It's initialized false when
+         * the table is created, and set true when it's been output to the file.
+         * You could suppress output of a table by setting this to true.
+         * (See jpeg_suppress_tables for an example.)
+         */
+        bool sent_table;        /* true when table has been output */
+    }
+    
+    static final class JHUFF_TBL {
+        /* These two fields directly represent the contents of a JPEG DHT marker */
+        byte[] bits = new byte[17]; /* bits[k] = # of symbols with codes of */
+                                    /* length k bits; bits[0] is unused */
+        byte[] huffval = new byte[256];     /* The symbols, in order of incr code length */
+        /* This field is used only during compression.  It's initialized false when
+         * the table is created, and set true when it's been output to the file.
+         * You could suppress output of a table by setting this to true.
+         * (See jpeg_suppress_tables for an example.)
+         */
+        bool sent_table;        /* true when table has been output */
+    }
+    
+    static final class bitread_perm_state {     /* Bitreading state saved across MCUs */
+        int get_buffer; /* current bit-extraction buffer */
+        int bits_left;      /* # of unused bits in it */
+    }
+    
+    static final class bitread_working_state {      /* Bitreading working state within an MCU */
+        /* Current data source location */
+        /* We need a copy, rather than munging the original, in case of suspension */
+        byte[] buffer; /* => next byte to read from source */
+        int bytes_offset;
+        int bytes_in_buffer;    /* # of bytes remaining in source buffer */
+        /* Bit input buffer --- note these values are kept in register variables,
+         * not in this struct, inside the inner loops.
+         */
+        int get_buffer; /* current bit-extraction buffer */
+        int bits_left;      /* # of unused bits in it */
+        /* Pointer needed by jpeg_fill_bit_buffer. */
+        jpeg_decompress_struct cinfo;   /* back link to decompress master record */
+    } 
+    
+    static final class savable_state {
+        int EOBRUN; //Note that this is only used in the progressive case
+        int[] last_dc_val = new int[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
+    }
+    
+    static final class d_derived_tbl {
+        /* Basic tables: (element [0] of each array is unused) */
+        int[] maxcode = new int[18];        /* largest code of length k (-1 if none) */
+        /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */
+        int[] valoffset = new int[17];      /* huffval[] offset for codes of length k */
+        /* valoffset[k] = huffval[] index of 1st symbol of code length k, less
+         * the smallest code of length k; so given a code of length k, the
+         * corresponding symbol is huffval[code + valoffset[k]]
+         */
+
+        /* Link to public Huffman table (needed only in jpeg_huff_decode) */
+        JHUFF_TBL pub;
+
+        /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of
+         * the input data stream.   If the next Huffman code is no more
+         * than HUFF_LOOKAHEAD bits long, we can obtain its length and
+         * the corresponding symbol directly from these tables.
+         */
+        int[] look_nbits = new int[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */
+        byte[] look_sym = new byte[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */
+    } 
+    
+    static final class jpeg_d_coef_controller {
+        int consume_data;
+        int decompress_data;
+
+        /* Pointer to array of coefficient virtual arrays, or null if none */
+        short[][][] coef_arrays;
+    
+        /* These variables keep track of the current location of the input side. */
+        /* cinfo.input_iMCU_row is also used for this. */
+        int MCU_ctr;        /* counts MCUs processed in current row */
+        int MCU_vert_offset;        /* counts MCU rows within iMCU row */
+        int MCU_rows_per_iMCU_row;  /* number of such rows needed */
+
+        /* The output side's location is represented by cinfo.output_iMCU_row. */
+
+        /* In single-pass modes, it's sufficient to buffer just one MCU.
+         * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
+         * and let the entropy decoder write into that workspace each time.
+         * (On 80x86, the workspace is FAR even though it's not really very big;
+         * this is to keep the module interfaces unchanged when a large coefficient
+         * buffer is necessary.)
+         * In multi-pass modes, this array points to the current MCU's blocks
+         * within the virtual arrays; it is used only by the input side.
+         */
+        short[][] MCU_buffer = new short[D_MAX_BLOCKS_IN_MCU][];
+
+        /* In multi-pass modes, we need a virtual block array for each component. */
+        short[][][][] whole_image = new short[MAX_COMPONENTS][][][];
+
+        /* When doing block smoothing, we latch coefficient Al values here */
+        int[] coef_bits_latch;
+        
+        short[] workspace;
+
+        void start_input_pass (jpeg_decompress_struct cinfo) {
+            cinfo.input_iMCU_row = 0;
+            start_iMCU_row(cinfo);
+        }
+        
+        /* Reset within-iMCU-row counters for a new row (input side) */
+        void start_iMCU_row (jpeg_decompress_struct cinfo) {
+            jpeg_d_coef_controller coef = cinfo.coef;
+
+            /* In an interleaved scan, an MCU row is the same as an iMCU row.
+             * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
+             * But at the bottom of the image, process only what's left.
+             */
+            if (cinfo.comps_in_scan > 1) {
+                coef.MCU_rows_per_iMCU_row = 1;
+            } else {
+                if (cinfo.input_iMCU_row < (cinfo.total_iMCU_rows-1))
+                    coef.MCU_rows_per_iMCU_row = cinfo.cur_comp_info[0].v_samp_factor;
+                else
+                    coef.MCU_rows_per_iMCU_row = cinfo.cur_comp_info[0].last_row_height;
+            }
+
+            coef.MCU_ctr = 0;
+            coef.MCU_vert_offset = 0;
+        }
+        
+    }
+    
+    static abstract class jpeg_entropy_decoder {
+        abstract void start_pass (jpeg_decompress_struct cinfo);
+        abstract bool decode_mcu (jpeg_decompress_struct cinfo, short[][] MCU_data);
+
+        /* This is here to share code between baseline and progressive decoders; */
+        /* other modules probably should not use it */
+        bool insufficient_data; /* set true after emitting warning */
+        
+        bitread_working_state br_state_local = new bitread_working_state();
+        savable_state state_local = new savable_state();
+    }   
+
+    static final class huff_entropy_decoder : jpeg_entropy_decoder {
+        bitread_perm_state bitstate = new bitread_perm_state(); /* Bit buffer at start of MCU */
+        savable_state saved = new savable_state();      /* Other state at start of MCU */
+
+        /* These fields are NOT loaded into local working state. */
+        int restarts_to_go; /* MCUs left in this restart interval */
+
+        /* Pointers to derived tables (these workspaces have image lifespan) */
+        d_derived_tbl[] dc_derived_tbls = new d_derived_tbl[NUM_HUFF_TBLS];
+        d_derived_tbl[] ac_derived_tbls = new d_derived_tbl[NUM_HUFF_TBLS];
+
+        /* Precalculated info set up by start_pass for use in decode_mcu: */
+
+        /* Pointers to derived tables to be used for each block within an MCU */
+        d_derived_tbl[] dc_cur_tbls = new d_derived_tbl[D_MAX_BLOCKS_IN_MCU];
+        d_derived_tbl[] ac_cur_tbls = new d_derived_tbl[D_MAX_BLOCKS_IN_MCU];
+        /* Whether we care about the DC and AC coefficient values for each block */
+        bool[] dc_needed = new bool[D_MAX_BLOCKS_IN_MCU];
+        bool[] ac_needed = new bool[D_MAX_BLOCKS_IN_MCU];
+        
+        void start_pass (jpeg_decompress_struct cinfo) {
+            start_pass_huff_decoder(cinfo);
+        }
+
+        bool decode_mcu (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+            huff_entropy_decoder entropy = this;
+            int blkn;
+//          BITREAD_STATE_VARS;
+            int get_buffer;
+            int bits_left;
+//          bitread_working_state br_state = new bitread_working_state();
+//          savable_state state = new savable_state();
+            bitread_working_state br_state = br_state_local;
+            savable_state state = state_local;
+
+                /* Process restart marker if needed; may have to suspend */
+            if (cinfo.restart_interval !is 0) {
+                if (entropy.restarts_to_go is 0)
+                    if (! process_restart(cinfo))
+                        return false;
+            }
+
+            /* If we've run out of data, just leave the MCU set to zeroes.
+             * This way, we return uniform gray for the remainder of the segment.
+             */
+            if (! entropy.insufficient_data) {
+
+                /* Load up working state */
+//              BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+                br_state.cinfo = cinfo;
+                br_state.buffer = cinfo.buffer; 
+                br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+                br_state.bytes_offset = cinfo.bytes_offset;
+                get_buffer = entropy.bitstate.get_buffer;
+                bits_left = entropy.bitstate.bits_left;
+                    
+//              ASSIGN_STATE(state, entropy.saved);
+                state.last_dc_val[0] = entropy.saved.last_dc_val[0];
+                state.last_dc_val[1] = entropy.saved.last_dc_val[1];
+                state.last_dc_val[2] = entropy.saved.last_dc_val[2];
+                state.last_dc_val[3] = entropy.saved.last_dc_val[3];
+
+                /* Outer loop handles each block in the MCU */
+
+                for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+                    short[] block = MCU_data[blkn];
+                    d_derived_tbl dctbl = entropy.dc_cur_tbls[blkn];
+                    d_derived_tbl actbl = entropy.ac_cur_tbls[blkn];
+                    int s = 0, k, r;
+
+                    /* Decode a single block's worth of coefficients */
+
+                    /* Section F.2.2.1: decode the DC coefficient difference */
+//                  HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
+                    {
+                    int nb = 0, look;
+                    if (bits_left < HUFF_LOOKAHEAD) {
+                        if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+                            return false;
+                        }
+                        get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                        if (bits_left < HUFF_LOOKAHEAD) {
+                            nb = 1;
+//                          goto slowlabel;
+                            if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,dctbl,nb)) < 0) {
+                                return false;
+                            }
+                            get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                        }
+                    }
+//                  look = PEEK_BITS(HUFF_LOOKAHEAD);
+                    if (nb !is 1) {
+                        look = (( (get_buffer >> (bits_left -   (HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+                        if ((nb = dctbl.look_nbits[look]) !is 0) {
+//                          DROP_BITS(nb);
+                            bits_left -= nb;
+                            s = dctbl.look_sym[look] & 0xFF;
+                        } else {
+                            nb = HUFF_LOOKAHEAD+1;
+//                          slowlabel:
+                            if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,dctbl,nb)) < 0) {
+                                return false;
+                            }
+                            get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                        }
+                    }
+                    }
+
+                    if (s !is 0) {
+//                      CHECK_BIT_BUFFER(br_state, s, return FALSE);
+                        {
+                        if (bits_left < (s)) {
+                            if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,s)) {
+                                return false;
+                            }
+                            get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                        }
+                        }
+//                      r = GET_BITS(s);
+                        r = (( (get_buffer >> (bits_left -= (s)))) & ((1<<(s))-1));
+//                      s = HUFF_EXTEND(r, s);
+                        s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+                    }
+
+                    if (entropy.dc_needed[blkn]) {
+                        /* Convert DC difference to actual value, update last_dc_val */
+                        int ci = cinfo.MCU_membership[blkn];
+                        s += state.last_dc_val[ci];
+                        state.last_dc_val[ci] = s;
+                        /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
+                        block[0] = (short) s;
+                    }
+
+                    if (entropy.ac_needed[blkn]) {
+
+                        /* Section F.2.2.2: decode the AC coefficients */
+                        /* Since zeroes are skipped, output area must be cleared beforehand */
+                        for (k = 1; k < DCTSIZE2; k++) {
+//                          HUFF_DECODE(s, br_state, actbl, return FALSE, label2);  
+                            {
+                            int nb = 0, look;
+                            if (bits_left < HUFF_LOOKAHEAD) {
+                                if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+                                    return false;
+                                }
+                                get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                                if (bits_left < HUFF_LOOKAHEAD) {
+                                    nb = 1; 
+//                                  goto slowlabel;
+                                    if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+                                        return false;
+                                    }
+                                    get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                                }
+                            }
+                            if (nb !is 1) {
+//                              look = PEEK_BITS(HUFF_LOOKAHEAD);
+                                look = (( (get_buffer >> (bits_left -   (HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+                                if ((nb = actbl.look_nbits[look]) !is 0) {
+//                                  DROP_BITS(nb);
+                                    bits_left -= (nb);
+                                    s = actbl.look_sym[look] & 0xFF;
+                                } else {
+                                    nb = HUFF_LOOKAHEAD+1;
+//                                  slowlabel:
+                                    if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+                                        return false;
+                                    }
+                                    get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                                }
+                            }
+                            }           
+                            r = s >> 4;
+                            s &= 15;
+                        
+                            if (s !is 0) {
+                                k += r;
+//                              CHECK_BIT_BUFFER(br_state, s, return FALSE);
+                                {
+                                if (bits_left < (s)) {
+                                    if (!jpeg_fill_bit_buffer(br_state, get_buffer, bits_left, s)) {
+                                        return false;
+                                    }
+                                    get_buffer = (br_state).get_buffer;
+                                    bits_left = (br_state).bits_left;
+                                }
+                                }
+//                              r = GET_BITS(s);
+                                r = (((get_buffer >> (bits_left -= (s)))) & ((1 << (s)) - 1));
+//                              s = HUFF_EXTEND(r, s);
+                                s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+                                /*
+                                 * Output coefficient in natural (dezigzagged)
+                                 * order. Note: the extra entries in
+                                 * jpeg_natural_order[] will save us if k >=
+                                 * DCTSIZE2, which could happen if the data is
+                                 * corrupted.
+                                 */
+                                block[jpeg_natural_order[k]] = (short) s;
+                            } else {
+                                if (r !is 15)
+                                    break;
+                                k += 15;
+                            }
+                        }
+
+                    } else {
+
+                        /* Section F.2.2.2: decode the AC coefficients */
+                        /* In this path we just discard the values */
+                        for (k = 1; k < DCTSIZE2; k++) {
+//                          HUFF_DECODE(s, br_state, actbl, return FALSE, label3);
+                            {
+                            int nb = 0, look;
+                            if (bits_left < HUFF_LOOKAHEAD) {
+                                if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+                                    return false;
+                                }
+                                get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                                if (bits_left < HUFF_LOOKAHEAD) {
+                                    nb = 1;
+//                                  goto slowlabel;
+                                    if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+                                        return false;
+                                    }
+                                    get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                                }
+                            }
+                            if (nb !is 1) {
+//                              look = PEEK_BITS(HUFF_LOOKAHEAD);
+                                look = (( (get_buffer >> (bits_left -   (HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+                                if ((nb = actbl.look_nbits[look]) !is 0) {
+//                                  DROP_BITS(nb);
+                                    bits_left -= (nb);
+                                    s = actbl.look_sym[look] & 0xFF;
+                                } else {
+                                    nb = HUFF_LOOKAHEAD+1;
+//                                  slowlabel:
+                                    if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+                                        return false;
+                                    }
+                                    get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                                }
+                            }
+                            }           
+                            r = s >> 4;
+                            s &= 15;
+                        
+                            if (s !is 0) {
+                                k += r;
+//                              CHECK_BIT_BUFFER(br_state, s, return FALSE);
+                                {
+                                if (bits_left < (s)) {
+                                    if (!jpeg_fill_bit_buffer((br_state),get_buffer,bits_left,s)) {
+                                        return false;
+                                    }
+                                    get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                                    }
+                                }
+//                              DROP_BITS(s);
+                                bits_left -= s;
+                            } else {
+                                if (r !is 15)
+                                    break;
+                                k += 15;
+                            }
+                        }
+
+                    }
+                }
+
+                /* Completed MCU, so update state */
+//              BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+                cinfo.buffer = br_state.buffer;
+                cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+                cinfo.bytes_offset = br_state.bytes_offset;
+                entropy.bitstate.get_buffer = get_buffer;
+                entropy.bitstate.bits_left = bits_left;
+//              ASSIGN_STATE(entropy.saved, state);
+                entropy.saved.last_dc_val[0] = state.last_dc_val[0];
+                entropy.saved.last_dc_val[1] = state.last_dc_val[1];
+                entropy.saved.last_dc_val[2] = state.last_dc_val[2];
+                entropy.saved.last_dc_val[3] = state.last_dc_val[3];
+            }
+
+            /* Account for restart interval (no-op if not using restarts) */
+            entropy.restarts_to_go--;
+
+            return true;
+        }
+
+        void start_pass_huff_decoder (jpeg_decompress_struct cinfo) {
+            huff_entropy_decoder entropy = this;
+            int ci, blkn, dctbl, actbl;
+            jpeg_component_info compptr;
+
+            /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
+             * This ought to be an error condition, but we make it a warning because
+             * there are some baseline files out there with all zeroes in these bytes.
+             */
+            if (cinfo.Ss !is 0 || cinfo.Se !is DCTSIZE2-1 || cinfo.Ah !is 0 || cinfo.Al !is 0) {
+//              WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
+            }
+
+            for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+                compptr = cinfo.cur_comp_info[ci];
+                dctbl = compptr.dc_tbl_no;
+                actbl = compptr.ac_tbl_no;
+                /* Compute derived values for Huffman tables */
+                /* We may do this more than once for a table, but it's not expensive */
+                jpeg_make_d_derived_tbl(cinfo, true, dctbl, entropy.dc_derived_tbls[dctbl] = new d_derived_tbl());
+                jpeg_make_d_derived_tbl(cinfo, false, actbl, entropy.ac_derived_tbls[actbl] = new d_derived_tbl());
+                /* Initialize DC predictions to 0 */
+                entropy.saved.last_dc_val[ci] = 0;
+            }
+
+            /* Precalculate decoding info for each block in an MCU of this scan */
+            for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+                ci = cinfo.MCU_membership[blkn];
+                compptr = cinfo.cur_comp_info[ci];
+                /* Precalculate which table to use for each block */
+                entropy.dc_cur_tbls[blkn] = entropy.dc_derived_tbls[compptr.dc_tbl_no];
+                entropy.ac_cur_tbls[blkn] = entropy.ac_derived_tbls[compptr.ac_tbl_no];
+                /* Decide whether we really care about the coefficient values */
+                if (compptr.component_needed) {
+                    entropy.dc_needed[blkn] = true;
+                    /* we don't need the ACs if producing a 1/8th-size image */
+                    entropy.ac_needed[blkn] = (compptr.DCT_scaled_size > 1);
+                } else {
+                    entropy.dc_needed[blkn] = entropy.ac_needed[blkn] = false;
+                }
+            }
+
+            /* Initialize bitread state variables */
+            entropy.bitstate.bits_left = 0;
+            entropy.bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
+            entropy.insufficient_data = false;
+
+            /* Initialize restart counter */
+            entropy.restarts_to_go = cinfo.restart_interval;
+        }
+    
+        bool process_restart (jpeg_decompress_struct cinfo) {
+            huff_entropy_decoder entropy = this;
+            int ci;
+
+            /* Throw away any unused bits remaining in bit buffer; */
+            /* include any full bytes in next_marker's count of discarded bytes */
+            cinfo.marker.discarded_bytes += entropy.bitstate.bits_left / 8;
+            entropy.bitstate.bits_left = 0;
+
+            /* Advance past the RSTn marker */
+            if (! read_restart_marker (cinfo))
+                return false;
+
+            /* Re-initialize DC predictions to 0 */
+            for (ci = 0; ci < cinfo.comps_in_scan; ci++)
+                entropy.saved.last_dc_val[ci] = 0;
+
+            /* Reset restart counter */
+            entropy.restarts_to_go = cinfo.restart_interval;
+
+            /* Reset out-of-data flag, unless read_restart_marker left us smack up
+             * against a marker.    In that case we will end up treating the next data
+             * segment as empty, and we can avoid producing bogus output pixels by
+             * leaving the flag set.
+             */
+            if (cinfo.unread_marker is 0)
+                entropy.insufficient_data = false;
+
+            return true;
+        }
+    }
+    
+    static final class phuff_entropy_decoder : jpeg_entropy_decoder {
+
+        /* These fields are loaded into local variables at start of each MCU.
+         * In case of suspension, we exit WITHOUT updating them.
+         */
+        bitread_perm_state bitstate = new bitread_perm_state(); /* Bit buffer at start of MCU */
+        savable_state saved = new savable_state();      /* Other state at start of MCU */
+
+        /* These fields are NOT loaded into local working state. */
+        int restarts_to_go; /* MCUs left in this restart interval */
+
+        /* Pointers to derived tables (these workspaces have image lifespan) */
+        d_derived_tbl[] derived_tbls = new d_derived_tbl[NUM_HUFF_TBLS];
+
+        d_derived_tbl ac_derived_tbl; /* active table during an AC scan */
+        
+        int[] newnz_pos = new int[DCTSIZE2];
+            
+        void start_pass (jpeg_decompress_struct cinfo) {
+            start_pass_phuff_decoder(cinfo);
+        }
+            
+        bool decode_mcu (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+            bool is_DC_band = (cinfo.Ss is 0);
+            if (cinfo.Ah is 0) {
+                if (is_DC_band)
+                    return decode_mcu_DC_first(cinfo, MCU_data);
+                else
+                    return decode_mcu_AC_first(cinfo, MCU_data);
+            } else {
+                if (is_DC_band)
+                    return decode_mcu_DC_refine(cinfo, MCU_data);
+                else
+                    return decode_mcu_AC_refine(cinfo, MCU_data);
+            }
+        }
+            
+        bool decode_mcu_DC_refine (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+            phuff_entropy_decoder entropy = this;
+            int p1 = 1 << cinfo.Al; /* 1 in the bit position being coded */
+            int blkn;
+            short[] block;
+//          BITREAD_STATE_VARS;
+            int get_buffer;
+            int bits_left;
+//          bitread_working_state br_state = new bitread_working_state();
+            bitread_working_state br_state = br_state_local;
+                    
+            /* Process restart marker if needed; may have to suspend */
+            if (cinfo.restart_interval !is 0) {
+                if (entropy.restarts_to_go is 0)
+                    if (! process_restart(cinfo))
+                        return false;
+            }
+
+            /* Not worth the cycles to check insufficient_data here,
+             * since we will not change the data anyway if we read zeroes.
+             */
+
+            /* Load up working state */
+//          BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+            br_state.cinfo = cinfo;
+            br_state.buffer = cinfo.buffer; 
+            br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+            br_state.bytes_offset = cinfo.bytes_offset;
+            get_buffer = entropy.bitstate.get_buffer;
+            bits_left = entropy.bitstate.bits_left;
+                    
+            /* Outer loop handles each block in the MCU */
+
+            for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+                block = MCU_data[blkn];
+
+                /* Encoded data is simply the next bit of the two's-complement DC value */
+//              CHECK_BIT_BUFFER(br_state, 1, return FALSE);
+                {
+                if (bits_left < (1)) {
+                    if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+                         return false;
+                    }
+                    get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                }
+                }
+//              if (GET_BITS(1))
+                if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) !is 0)
+                    block[0] |= p1;
+                    /* Note: since we use |=, repeating the assignment later is safe */
+            }
+
+            /* Completed MCU, so update state */
+//          BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+            cinfo.buffer = br_state.buffer;
+            cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+            cinfo.bytes_offset = br_state.bytes_offset;
+            entropy.bitstate.get_buffer = get_buffer;
+            entropy.bitstate.bits_left = bits_left;
+                    
+            /* Account for restart interval (no-op if not using restarts) */
+            entropy.restarts_to_go--;
+
+            return true;
+
+        }
+            
+        bool decode_mcu_AC_refine (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+            phuff_entropy_decoder entropy = this;
+            int Se = cinfo.Se;
+            int p1 = 1 << cinfo.Al; /* 1 in the bit position being coded */
+            int m1 = (-1) << cinfo.Al;  /* -1 in the bit position being coded */
+            int s = 0, k, r;
+            int EOBRUN;
+            short[] block;
+            short[] thiscoef;
+//          BITREAD_STATE_VARS;
+            int get_buffer;
+            int bits_left;
+//          bitread_working_state br_state = new bitread_working_state();
+            bitread_working_state br_state = br_state_local;
+                
+            d_derived_tbl tbl;
+            int num_newnz;
+            int[] newnz_pos = entropy.newnz_pos;
+
+                /* Process restart marker if needed; may have to suspend */
+            if (cinfo.restart_interval !is 0) {
+                if (entropy.restarts_to_go is 0)
+                    if (! process_restart(cinfo))
+                        return false;
+            }
+
+            /* If we've run out of data, don't modify the MCU.
+             */
+            if (! entropy.insufficient_data) {
+
+                /* Load up working state */
+//              BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+                br_state.cinfo = cinfo;
+                br_state.buffer = cinfo.buffer; 
+                br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+                br_state.bytes_offset = cinfo.bytes_offset;
+                get_buffer = entropy.bitstate.get_buffer;
+                bits_left = entropy.bitstate.bits_left;
+                    
+                EOBRUN = entropy.saved.EOBRUN; /* only part of saved state we need */
+
+                /* There is always only one block per MCU */
+                block = MCU_data[0];
+                tbl = entropy.ac_derived_tbl;
+
+                /* If we are forced to suspend, we must undo the assignments to any newly
+                 * nonzero coefficients in the block, because otherwise we'd get confused
+                 * next time about which coefficients were already nonzero.
+                 * But we need not undo addition of bits to already-nonzero coefficients;
+                 * instead, we can test the current bit to see if we already did it.
+                 */
+                num_newnz = 0;
+
+                /* initialize coefficient loop counter to start of band */
+                k = cinfo.Ss;
+
+                if (EOBRUN is 0) {
+                    for (; k <= Se; k++) {
+//                      HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
+                        {
+                        int nb = 0, look;
+                        if (bits_left < HUFF_LOOKAHEAD) {
+                            if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+//                              failaction;
+                                while (num_newnz > 0)
+                                    block[newnz_pos[--num_newnz]] = 0;
+
+                                return false;
+                            }
+                            get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                            if (bits_left < HUFF_LOOKAHEAD) {
+                                nb = 1; 
+//                              goto slowlabel;
+                                if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+//                                  failaction;
+                                    while (num_newnz > 0)
+                                        block[newnz_pos[--num_newnz]] = 0;
+
+                                    return false;
+                                }
+                                get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                            }
+                        }
+                        if (nb !is 1) {
+//                          look = PEEK_BITS(HUFF_LOOKAHEAD);
+                            look = (( (get_buffer >> (bits_left -   (HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+                            if ((nb = tbl.look_nbits[look]) !is 0) {
+//                              DROP_BITS(nb);
+                                bits_left -= nb;
+                                s = tbl.look_sym[look] & 0xFF;
+                            } else {
+                                nb = HUFF_LOOKAHEAD+1;
+//                              slowlabel:
+                                if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) { 
+//                                  failaction;
+                                    while (num_newnz > 0)
+                                        block[newnz_pos[--num_newnz]] = 0;
+
+                                    return false;
+                                }
+                                get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                            }
+                        }
+                        }
+                        r = s >> 4;
+                        s &= 15;
+                        if (s !is 0) {
+                            if (s !is 1) {      /* size of new coef should always be 1 */
+//                              WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
+                            }
+//                          CHECK_BIT_BUFFER(br_state, 1, goto undoit);
+                            {
+                            if (bits_left < (1)) {
+                                if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+//                                  failaction;
+                                    while (num_newnz > 0)
+                                        block[newnz_pos[--num_newnz]] = 0;
+
+                                    return false;
+                                }
+                                get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                                }
+                            }
+//                          if (GET_BITS(1))
+                            if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) !is 0)
+                                s = p1;     /* newly nonzero coef is positive */
+                            else
+                                s = m1;     /* newly nonzero coef is negative */
+                        } else {
+                            if (r !is 15) {
+                                EOBRUN = 1 << r;    /* EOBr, run length is 2^r + appended bits */
+                                if (r !is 0) {
+//                                  CHECK_BIT_BUFFER(br_state, r, goto undoit);
+                                    {
+                                    if (bits_left < (r)) {
+                                        if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,r)) {
+//                                          failaction;
+                                            while (num_newnz > 0)
+                                                block[newnz_pos[--num_newnz]] = 0;
+
+                                            return false;
+                                        }
+                                        get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                                    }
+                                    }
+//                                  r = GET_BITS(r);
+                                    r = (( (get_buffer >> (bits_left -= (r)))) & ((1<<(r))-1));
+                                    EOBRUN += r;
+                                }
+                                break;      /* rest of block is handled by EOB logic */
+                            }
+                            /* note s = 0 for processing ZRL */
+                        }
+                        /* Advance over already-nonzero coefs and r still-zero coefs,
+                         * appending correction bits to the nonzeroes.  A correction bit is 1
+                         * if the absolute value of the coefficient must be increased.
+                         */
+                        do {
+                            thiscoef = block;
+                            int thiscoef_offset = jpeg_natural_order[k];
+                            if (thiscoef[thiscoef_offset] !is 0) {
+//                              CHECK_BIT_BUFFER(br_state, 1, goto undoit);
+                                {
+                                if (bits_left < (1)) {
+                                    if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+//                                      failaction;
+                                        while (num_newnz > 0)
+                                            block[newnz_pos[--num_newnz]] = 0;
+
+                                        return false;
+                                    }
+                                    get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                                }
+                                }
+//                              if (GET_BITS(1)) {
+                                if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) !is 0) {
+                                    if ((thiscoef[thiscoef_offset] & p1) is 0) { /* do nothing if already set it */
+                                        if (thiscoef[thiscoef_offset] >= 0)
+                                            thiscoef[thiscoef_offset] += p1;
+                                        else
+                                            thiscoef[thiscoef_offset] += m1;
+                                    }
+                                }
+                            } else {
+                                if (--r < 0)
+                                    break;      /* reached target zero coefficient */
+                            }
+                            k++;
+                        } while (k <= Se);
+                        if (s !is 0) {
+                            int pos = jpeg_natural_order[k];
+                            /* Output newly nonzero coefficient */
+                            block[pos] = (short) s;
+                            /* Remember its position in case we have to suspend */
+                            newnz_pos[num_newnz++] = pos;
+                        }
+                    }
+                }
+
+                if (EOBRUN > 0) {
+                    /* Scan any remaining coefficient positions after the end-of-band
+                     * (the last newly nonzero coefficient, if any).    Append a correction
+                     * bit to each already-nonzero coefficient. A correction bit is 1
+                     * if the absolute value of the coefficient must be increased.
+                     */
+                    for (; k <= Se; k++) {
+                        thiscoef = block;
+                        int thiscoef_offset = jpeg_natural_order[k];
+                        if (thiscoef[thiscoef_offset] !is 0) {
+//                          CHECK_BIT_BUFFER(br_state, 1, goto undoit);
+                            {
+                            if (bits_left < (1)) {
+                                if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+//                                  failaction;
+                                    while (num_newnz > 0)
+                                        block[newnz_pos[--num_newnz]] = 0;
+    
+                                    return false;
+                                }
+                                get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                            }
+                            }
+//                          if (GET_BITS(1)) {
+                            if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) !is 0) {
+                                if ((thiscoef[thiscoef_offset] & p1) is 0) { /* do nothing if already changed it */
+                                    if (thiscoef[thiscoef_offset] >= 0)
+                                        thiscoef[thiscoef_offset] += p1;
+                                    else
+                                        thiscoef[thiscoef_offset] += m1;
+                                }
+                            }
+                        }
+                    }
+                        /* Count one block completed in EOB run */
+                    EOBRUN--;
+                }
+
+                /* Completed MCU, so update state */
+//              BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+                cinfo.buffer = br_state.buffer;
+                cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+                cinfo.bytes_offset = br_state.bytes_offset;
+                entropy.bitstate.get_buffer = get_buffer;
+                entropy.bitstate.bits_left = bits_left;
+                        
+                entropy.saved.EOBRUN = EOBRUN; /* only part of saved state we need */
+            }
+
+            /* Account for restart interval (no-op if not using restarts) */
+            entropy.restarts_to_go--;
+
+            return true;
+
+//          undoit:
+//              /* Re-zero any output coefficients that we made newly nonzero */
+//              while (num_newnz > 0)
+//                  (*block)[newnz_pos[--num_newnz]] = 0;
+//
+//              return false;
+
+        }           
+            
+        bool decode_mcu_AC_first (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+            phuff_entropy_decoder entropy = this;
+            int Se = cinfo.Se;
+            int Al = cinfo.Al;
+            int s = 0, k, r;
+            int EOBRUN;
+            short[] block;
+//          BITREAD_STATE_VARS;
+            int get_buffer;
+            int bits_left;
+//          bitread_working_state br_state = new bitread_working_state();
+            bitread_working_state br_state = br_state_local;
+                    
+            d_derived_tbl tbl;
+
+            /* Process restart marker if needed; may have to suspend */
+            if (cinfo.restart_interval !is 0) {
+                if (entropy.restarts_to_go is 0)
+                    if (! process_restart(cinfo))
+                        return false;
+            }
+
+            /* If we've run out of data, just leave the MCU set to zeroes.
+             * This way, we return uniform gray for the remainder of the segment.
+             */
+            if (! entropy.insufficient_data) {
+
+                /* Load up working state.
+                 * We can avoid loading/saving bitread state if in an EOB run.
+                 */
+                EOBRUN = entropy.saved.EOBRUN;  /* only part of saved state we need */
+
+                /* There is always only one block per MCU */
+
+                if (EOBRUN > 0)     /* if it's a band of zeroes... */
+                    EOBRUN--;           /* ...process it now (we do nothing) */
+                else {
+//                  BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+                    br_state.cinfo = cinfo;
+                    br_state.buffer = cinfo.buffer; 
+                    br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+                    br_state.bytes_offset = cinfo.bytes_offset;
+                    get_buffer = entropy.bitstate.get_buffer;
+                    bits_left = entropy.bitstate.bits_left;
+                        
+                    block = MCU_data[0];
+                    tbl = entropy.ac_derived_tbl;
+
+                    for (k = cinfo.Ss; k <= Se; k++) {
+//                      HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
+                        {
+                        int nb = 0, look;
+                        if (bits_left < HUFF_LOOKAHEAD) {
+                            if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+                                return false;
+                            }
+                            get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                            if (bits_left < HUFF_LOOKAHEAD) {
+                                nb = 1;
+//                              goto slowlabel;
+                                if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+                                    return false;
+                                }
+                                get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                            }
+                        }
+                        if (nb !is 1) {
+//                          look = PEEK_BITS(HUFF_LOOKAHEAD);
+                            look = (( (get_buffer >> (bits_left -   (HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+
+                            if ((nb = tbl.look_nbits[look]) !is 0) {
+//                              DROP_BITS(nb);
+                                bits_left -= nb;
+                                s = tbl.look_sym[look] & 0xFF;
+                            } else {
+                                nb = HUFF_LOOKAHEAD+1;
+//                              slowlabel:
+                                if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+                                    return false;
+                                }
+                                get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                            }
+                        }
+                        }
+                        r = s >> 4;
+                        s &= 15;
+                        if (s !is 0) {
+                            k += r;
+//                          CHECK_BIT_BUFFER(br_state, s, return FALSE);
+                            {
+                            if (bits_left < (s)) {
+                                if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,s)) {
+                                    return false;
+                                }
+                                get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                            }
+                            }
+//                          r = GET_BITS(s);
+                            r = (( (get_buffer >> (bits_left -= (s)))) & ((1<<(s))-1));
+//                          s = HUFF_EXTEND(r, s);
+                            s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+                            /* Scale and output coefficient in natural (dezigzagged) order */
+                            block[jpeg_natural_order[k]] = (short) (s << Al);
+                        } else {
+                            if (r is 15) {  /* ZRL */
+                                k += 15;        /* skip 15 zeroes in band */
+                            } else {        /* EOBr, run length is 2^r + appended bits */
+                                EOBRUN = 1 << r;
+                                if (r !is 0) {      /* EOBr, r > 0 */
+//                                  CHECK_BIT_BUFFER(br_state, r, return FALSE);
+                                    {
+                                    if (bits_left < (r)) {
+                                        if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,r)) {
+                                            return false;
+                                        }
+                                        get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                                    }
+                                    }
+//                                  r = GET_BITS(r);
+                                    r = (( (get_buffer >> (bits_left -= (r)))) & ((1<<(r))-1));
+                                    EOBRUN += r;
+                                }
+                                EOBRUN--;       /* this band is processed at this moment */
+                                break;      /* force end-of-band */
+                            }
+                        }
+                    }
+
+//                  BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+                    cinfo.buffer = br_state.buffer;
+                    cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+                    cinfo.bytes_offset = br_state.bytes_offset;
+                    entropy.bitstate.get_buffer = get_buffer;
+                    entropy.bitstate.bits_left = bits_left;
+                }
+
+                /* Completed MCU, so update state */
+                entropy.saved.EOBRUN = EOBRUN;  /* only part of saved state we need */
+            }
+
+            /* Account for restart interval (no-op if not using restarts) */
+            entropy.restarts_to_go--;
+
+            return true;
+        }
+            
+        bool decode_mcu_DC_first (jpeg_decompress_struct cinfo, short[][] MCU_data) {    
+            phuff_entropy_decoder entropy = this;
+            int Al = cinfo.Al;
+            int s = 0, r;
+            int blkn, ci;
+            short[] block;
+//          BITREAD_STATE_VARS;
+            int get_buffer;
+            int bits_left;
+//          bitread_working_state br_state = new bitread_working_state();
+            bitread_working_state br_state = br_state_local;
+                
+//          savable_state state = new savable_state();
+            savable_state state = state_local;
+            d_derived_tbl tbl;
+            jpeg_component_info compptr;
+
+            /* Process restart marker if needed; may have to suspend */
+            if (cinfo.restart_interval !is 0) {
+                if (entropy.restarts_to_go is 0)
+                    if (! process_restart(cinfo))
+                        return false;
+            }
+
+            /* If we've run out of data, just leave the MCU set to zeroes.
+             * This way, we return uniform gray for the remainder of the segment.
+             */
+            if (! entropy.insufficient_data) {
+
+                /* Load up working state */
+//              BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+                br_state.cinfo = cinfo;
+                br_state.buffer = cinfo.buffer; 
+                br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+                br_state.bytes_offset = cinfo.bytes_offset;
+                get_buffer = entropy.bitstate.get_buffer;
+                bits_left = entropy.bitstate.bits_left;
+                    
+//              ASSIGN_STATE(state, entropy.saved);
+                state.EOBRUN = entropy.saved.EOBRUN;
+                state.last_dc_val[0] = entropy.saved.last_dc_val[0];
+                state.last_dc_val[1] = entropy.saved.last_dc_val[1];
+                state.last_dc_val[2] = entropy.saved.last_dc_val[2];
+                state.last_dc_val[3] = entropy.saved.last_dc_val[3];
+                    
+                /* Outer loop handles each block in the MCU */
+
+                for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+                    block = MCU_data[blkn];
+                    ci = cinfo.MCU_membership[blkn];
+                    compptr = cinfo.cur_comp_info[ci];
+                    tbl = entropy.derived_tbls[compptr.dc_tbl_no];
+
+                    /* Decode a single block's worth of coefficients */
+
+                    /* Section F.2.2.1: decode the DC coefficient difference */
+//                  HUFF_DECODE(s, br_state, tbl, return FALSE, label1);
+                    {
+                    int nb = 0, look;
+                    if (bits_left < HUFF_LOOKAHEAD) {
+                        if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+                            return false;
+                        }
+                        get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                        if (bits_left < HUFF_LOOKAHEAD) {
+                            nb = 1;
+//                          goto slowlabel;
+                            if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+                                return false;
+                            }
+                            get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                        }
+                    }
+                    if (nb !is 1) {
+//                      look = PEEK_BITS(HUFF_LOOKAHEAD);
+                        look = (( (get_buffer >> (bits_left -   (HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+
+                        if ((nb = tbl.look_nbits[look]) !is 0) {
+//                          DROP_BITS(nb);
+                            bits_left -= nb;
+                            s = tbl.look_sym[look] & 0xFF;
+                        } else {
+                            nb = HUFF_LOOKAHEAD+1;
+//                          slowlabel:
+                            if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+                                return false;
+                            }
+                            get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+                        }
+                    }
+                    }
+                    if (s !is 0) {
+//                      CHECK_BIT_BUFFER(br_state, s, return FALSE);
+                        {
+                        if (bits_left < (s)) {
+                            if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,s)) {
+                                return false;
+                            }
+                            get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+                        }
+                        }
+//                      r = GET_BITS(s);
+                        r = (( (get_buffer >> (bits_left -= (s)))) & ((1<<(s))-1));
+//                      s = HUFF_EXTEND(r, s);
+                        s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+                    }
+
+                        /* Convert DC difference to actual value, update last_dc_val */
+                    s += state.last_dc_val[ci];
+                    state.last_dc_val[ci] = s;
+                    /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
+                    block[0] = (short) (s << Al);
+                }
+
+                /* Completed MCU, so update state */
+//              BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+                cinfo.buffer = br_state.buffer;
+                cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+                cinfo.bytes_offset = br_state.bytes_offset;
+                entropy.bitstate.get_buffer = get_buffer;
+                entropy.bitstate.bits_left = bits_left;
+//              ASSIGN_STATE(entropy.saved, state);
+                entropy.saved.EOBRUN = state.EOBRUN;
+                entropy.saved.last_dc_val[0] = state.last_dc_val[0];
+                entropy.saved.last_dc_val[1] = state.last_dc_val[1];
+                entropy.saved.last_dc_val[2] = state.last_dc_val[2];
+                entropy.saved.last_dc_val[3] = state.last_dc_val[3];
+            }
+
+            /* Account for restart interval (no-op if not using restarts) */
+            entropy.restarts_to_go--;
+
+            return true;
+        }
+            
+        bool process_restart (jpeg_decompress_struct cinfo) {
+            phuff_entropy_decoder entropy = this;
+            int ci;
+
+            /* Throw away any unused bits remaining in bit buffer; */
+            /* include any full bytes in next_marker's count of discarded bytes */
+            cinfo.marker.discarded_bytes += entropy.bitstate.bits_left / 8;
+            entropy.bitstate.bits_left = 0;
+
+            /* Advance past the RSTn marker */
+            if (! read_restart_marker (cinfo))
+                return false;
+
+            /* Re-initialize DC predictions to 0 */
+            for (ci = 0; ci < cinfo.comps_in_scan; ci++)
+                entropy.saved.last_dc_val[ci] = 0;
+                /* Re-init EOB run count, too */
+            entropy.saved.EOBRUN = 0;
+
+            /* Reset restart counter */
+            entropy.restarts_to_go = cinfo.restart_interval;
+
+            /* Reset out-of-data flag, unless read_restart_marker left us smack up
+             * against a marker.    In that case we will end up treating the next data
+             * segment as empty, and we can avoid producing bogus output pixels by
+             * leaving the flag set.
+             */
+            if (cinfo.unread_marker is 0)
+                entropy.insufficient_data = false;
+
+            return true;
+        }
+
+        void start_pass_phuff_decoder (jpeg_decompress_struct cinfo) {
+            phuff_entropy_decoder entropy = this;
+            bool is_DC_band, bad;
+            int ci, coefi, tbl;
+            int[] coef_bit_ptr;
+            jpeg_component_info compptr;
+
+            is_DC_band = (cinfo.Ss is 0);
+
+            /* Validate scan parameters */
+            bad = false;
+            if (is_DC_band) {
+                if (cinfo.Se !is 0)
+                    bad = true;
+            } else {
+                /* need not check Ss/Se < 0 since they came from unsigned bytes */
+                if (cinfo.Ss > cinfo.Se || cinfo.Se >= DCTSIZE2)
+                    bad = true;
+                /* AC scans may have only one component */
+                if (cinfo.comps_in_scan !is 1)
+                    bad = true;
+            }
+            if (cinfo.Ah !is 0) {
+                /* Successive approximation refinement scan: must have Al = Ah-1. */
+                if (cinfo.Al !is cinfo.Ah-1)
+                    bad = true;
+            }
+            if (cinfo.Al > 13)      /* need not check for < 0 */
+                bad = true;
+            /* Arguably the maximum Al value should be less than 13 for 8-bit precision,
+             * but the spec doesn't say so, and we try to be liberal about what we
+             * accept.  Note: large Al values could result in out-of-range DC
+             * coefficients during early scans, leading to bizarre displays due to
+             * overflows in the IDCT math.  But we won't crash.
+             */
+            if (bad)
+                error();
+//              ERREXIT4(cinfo, JERR_BAD_PROGRESSION, cinfo.Ss, cinfo.Se, cinfo.Ah, cinfo.Al);
+            /* Update progression status, and verify that scan order is legal.
+             * Note that inter-scan inconsistencies are treated as warnings
+             * not fatal errors ... not clear if this is right way to behave.
+             */
+            for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+                int cindex = cinfo.cur_comp_info[ci].component_index;
+                coef_bit_ptr = cinfo.coef_bits[cindex];
+                if (!is_DC_band && coef_bit_ptr[0] < 0) {/* AC without prior DC scan */
+//                  WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
+                }
+                for (coefi = cinfo.Ss; coefi <= cinfo.Se; coefi++) {
+                    int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
+                    if (cinfo.Ah !is expected) {
+//                      WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
+                    }
+                    coef_bit_ptr[coefi] = cinfo.Al;
+                }
+            }
+
+            /* Select MCU decoding routine */
+//          if (cinfo.Ah is 0) {
+//              if (is_DC_band)
+//                  entropy.pub.decode_mcu = decode_mcu_DC_first;
+//              else
+//                  entropy.pub.decode_mcu = decode_mcu_AC_first;
+//          } else {
+//              if (is_DC_band)
+//                  entropy.pub.decode_mcu = decode_mcu_DC_refine;
+//              else
+//                  entropy.pub.decode_mcu = decode_mcu_AC_refine;
+//          }
+
+            for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+                compptr = cinfo.cur_comp_info[ci];
+                /* Make sure requested tables are present, and compute derived tables.
+                 * We may build same derived table more than once, but it's not expensive.
+                 */
+                if (is_DC_band) {
+                    if (cinfo.Ah is 0) {    /* DC refinement needs no table */
+                        tbl = compptr.dc_tbl_no;
+                        jpeg_make_d_derived_tbl(cinfo, true, tbl, entropy.derived_tbls[tbl] = new d_derived_tbl());
+                    }
+                } else {
+                    tbl = compptr.ac_tbl_no;
+                    jpeg_make_d_derived_tbl(cinfo, false, tbl, entropy.derived_tbls[tbl] = new d_derived_tbl());
+                    /* remember the single active table */
+                    entropy.ac_derived_tbl = entropy.derived_tbls[tbl];
+                }
+                /* Initialize DC predictions to 0 */
+                entropy.saved.last_dc_val[ci] = 0;
+            }
+
+            /* Initialize bitread state variables */
+            entropy.bitstate.bits_left = 0;
+            entropy.bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
+            entropy.insufficient_data = false;
+
+            /* Initialize private state variables */
+            entropy.saved.EOBRUN = 0;
+
+            /* Initialize restart counter */
+            entropy.restarts_to_go = cinfo.restart_interval;
+        }
+
+    }
+    
+    static final class jpeg_component_info {
+        /* These values are fixed over the whole image. */
+        /* For compression, they must be supplied by parameter setup; */
+        /* for decompression, they are read from the SOF marker. */
+        int component_id;       /* identifier for this component (0..255) */
+        int component_index;        /* its index in SOF or cinfo.comp_info[] */
+        int h_samp_factor;      /* horizontal sampling factor (1..4) */
+        int v_samp_factor;      /* vertical sampling factor (1..4) */
+        int quant_tbl_no;       /* quantization table selector (0..3) */
+        /* These values may vary between scans. */
+        /* For compression, they must be supplied by parameter setup; */
+        /* for decompression, they are read from the SOS marker. */
+        /* The decompressor output side may not use these variables. */
+        int dc_tbl_no;      /* DC entropy table selector (0..3) */
+        int ac_tbl_no;      /* AC entropy table selector (0..3) */
+        
+        /* Remaining fields should be treated as private by applications. */
+        
+        /* These values are computed during compression or decompression startup: */
+        /* Component's size in DCT blocks.
+         * Any dummy blocks added to complete an MCU are not counted; therefore
+         * these values do not depend on whether a scan is interleaved or not.
+         */
+        int width_in_blocks;
+        int height_in_blocks;
+        /* Size of a DCT block in samples.  Always DCTSIZE for compression.
+         * For decompression this is the size of the output from one DCT block,
+         * reflecting any scaling we choose to apply during the IDCT step.
+         * Values of 1,2,4,8 are likely to be supported.    Note that different
+         * components may receive different IDCT scalings.
+         */
+        int DCT_scaled_size;
+        /* The downsampled dimensions are the component's actual, unpadded number
+         * of samples at the main buffer (preprocessing/compression interface), thus
+         * downsampled_width = ceil(image_width * Hi/Hmax)
+         * and similarly for height.    For decompression, IDCT scaling is included, so
+         * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)
+         */
+        int downsampled_width;   /* actual width in samples */
+        int downsampled_height; /* actual height in samples */
+        /* This flag is used only for decompression.    In cases where some of the
+         * components will be ignored (eg grayscale output from YCbCr image),
+         * we can skip most computations for the unused components.
+         */
+        bool component_needed;  /* do we need the value of this component? */
+
+        /* These values are computed before starting a scan of the component. */
+        /* The decompressor output side may not use these variables. */
+        int MCU_width;      /* number of blocks per MCU, horizontally */
+        int MCU_height;     /* number of blocks per MCU, vertically */
+        int MCU_blocks;     /* MCU_width * MCU_height */
+        int MCU_sample_width;       /* MCU width in samples, MCU_width*DCT_scaled_size */
+        int last_col_width;     /* # of non-dummy blocks across in last MCU */
+        int last_row_height;        /* # of non-dummy blocks down in last MCU */
+
+        /* Saved quantization table for component; null if none yet saved.
+         * See jdinput.c comments about the need for this information.
+         * This field is currently used only for decompression.
+         */
+        JQUANT_TBL quant_table;
+
+        /* Private per-component storage for DCT or IDCT subsystem. */
+        int[] dct_table;
+    }
+    
+    static final class jpeg_color_quantizer {
+//      JMETHOD(void, start_pass, (j_decompress_ptr cinfo, bool is_pre_scan));
+//      JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
+//                   JSAMPARRAY input_buf, JSAMPARRAY output_buf,
+//                   int num_rows));
+//      JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
+//      JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
+        
+        /* Initially allocated colormap is saved here */
+        int[][] sv_colormap;    /* The color map as a 2-D pixel array */
+        int sv_actual;      /* number of entries in use */
+
+        int[][] colorindex; /* Precomputed mapping for speed */
+        /* colorindex[i][j] = index of color closest to pixel value j in component i,
+         * premultiplied as described above.    Since colormap indexes must fit into
+         * JSAMPLEs, the entries of this array will too.
+         */
+        bool is_padded;     /* is the colorindex padded for odither? */
+
+        int[] Ncolors = new int [MAX_Q_COMPS];  /* # of values alloced to each component */
+
+        /* Variables for ordered dithering */
+        int row_index;      /* cur row's vertical index in dither matrix */
+//          ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */
+
+        /* Variables for Floyd-Steinberg dithering */
+//          FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */
+        bool on_odd_row;    
+            
+        void start_pass (jpeg_decompress_struct cinfo, bool is_pre_scan) {
+            error();
+        }
+    }
+    
+    static final class jpeg_upsampler {
+//      JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+//      JMETHOD(void, upsample, (j_decompress_ptr cinfo,
+//                   JSAMPIMAGE input_buf,
+//                   JDIMENSION *in_row_group_ctr,
+//                   JDIMENSION in_row_groups_avail,
+//                   JSAMPARRAY output_buf,
+//                   JDIMENSION *out_row_ctr,
+//                   JDIMENSION out_rows_avail));
+
+        bool need_context_rows; /* TRUE if need rows above & below */
+            
+        /* Color conversion buffer. When using separate upsampling and color
+         * conversion steps, this buffer holds one upsampled row group until it
+         * has been color converted and output.
+         * Note: we do not allocate any storage for component(s) which are full-size,
+         * ie do not need rescaling.    The corresponding entry of color_buf[] is
+         * simply set to point to the input data array, thereby avoiding copying.
+         */
+        byte[][][] color_buf = new byte[MAX_COMPONENTS][][];
+        int[] color_buf_offset = new int[MAX_COMPONENTS];
+
+        /* Per-component upsampling method pointers */
+        int[] methods = new int[MAX_COMPONENTS];
+
+        int next_row_out;       /* counts rows emitted from color_buf */
+        int rows_to_go; /* counts rows remaining in image */
+
+        /* Height of an input row group for each component. */
+        int[] rowgroup_height = new int[MAX_COMPONENTS];
+
+        /* These arrays save pixel expansion factors so that int_expand need not
+         * recompute them each time.    They are unused for other upsampling methods.
+         */
+        byte[] h_expand = new byte[MAX_COMPONENTS];
+        byte[] v_expand = new byte[MAX_COMPONENTS];
+            
+        void start_pass (jpeg_decompress_struct cinfo) {
+            jpeg_upsampler upsample = cinfo.upsample;
+
+            /* Mark the conversion buffer empty */
+            upsample.next_row_out = cinfo.max_v_samp_factor;
+            /* Initialize total-height counter for detecting bottom of image */
+            upsample.rows_to_go = cinfo.output_height;
+        }
+            
+    }
+    
+    static final class jpeg_marker_reader {
+        /* Read a restart marker --- exported for use by entropy decoder only */
+//      jpeg_marker_parser_method read_restart_marker;
+
+        /* State of marker reader --- nominally internal, but applications
+         * supplying COM or APPn handlers might like to know the state.
+         */
+        bool saw_SOI;       /* found SOI? */
+        bool saw_SOF;       /* found SOF? */
+        int next_restart_num;       /* next restart number expected (0-7) */
+        int discarded_bytes;    /* # of bytes skipped looking for a marker */
+        
+        /* Application-overridable marker processing methods */
+//      jpeg_marker_parser_method process_COM;
+//      jpeg_marker_parser_method process_APPn[16];
+
+        /* Limit on marker data length to save for each marker type */
+        int length_limit_COM;
+        int[] length_limit_APPn = new int[16];
+
+        /* Status of COM/APPn marker saving */
+//      jpeg_marker_reader cur_marker;  /* null if not processing a marker */
+//      int bytes_read;     /* data bytes read so far in marker */
+        /* Note: cur_marker is not linked into marker_list until it's all read. */
+    }
+    
+    
+    static final class jpeg_d_main_controller {
+//      JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
+        int process_data;
+                
+         /* Pointer to allocated workspace (M or M+2 row groups). */
+        byte[][][] buffer = new byte[MAX_COMPONENTS][][];
+        int[] buffer_offset = new int[MAX_COMPONENTS];
+
+        bool buffer_full;       /* Have we gotten an iMCU row from decoder? */
+        int[] rowgroup_ctr = new int[1];    /* counts row groups output to postprocessor */
+
+        /* Remaining fields are only used in the context case. */
+
+        /* These are the master pointers to the funny-order pointer lists. */
+        byte[][][][] xbuffer = new byte[2][][][];   /* pointers to weird pointer lists */
+        int[][] xbuffer_offset = new int[2][];
+
+        int whichptr;           /* indicates which pointer set is now in use */
+        int context_state;      /* process_data state machine status */
+        int rowgroups_avail;    /* row groups available to postprocessor */
+        int iMCU_row_ctr;   /* counts iMCU rows to detect image top/bot */
+                    
+        void start_pass (jpeg_decompress_struct cinfo, int pass_mode) {
+            jpeg_d_main_controller main = cinfo.main;
+
+            switch (pass_mode) {
+                case JBUF_PASS_THRU:
+                    if (cinfo.upsample.need_context_rows) {
+                        main.process_data = PROCESS_DATA_CONTEXT_MAIN;
+                        make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
+                        main.whichptr = 0;  /* Read first iMCU row into xbuffer[0] */
+                        main.context_state = CTX_PREPARE_FOR_IMCU;
+                        main.iMCU_row_ctr = 0;
+                    } else {
+                        /* Simple case with no context needed */
+                        main.process_data = PROCESS_DATA_SIMPLE_MAIN;
+                    }
+                    main.buffer_full = false;   /* Mark buffer empty */
+                    main.rowgroup_ctr[0] = 0;
+                    break;
+//              #ifdef QUANT_2PASS_SUPPORTED
+//              case JBUF_CRANK_DEST:
+//                  /* For last pass of 2-pass quantization, just crank the postprocessor */
+//                  main.process_data = PROCESS_DATA_CRANK_POST;
+//                  break;
+//              #endif
+                default:
+                    error();
+//                  ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+                    break;
+            }
+        }
+                    
+    }
+
+    static final class jpeg_decomp_master {
+//      JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
+//      JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
+
+        /* State variables made visible to other modules */
+        bool is_dummy_pass;
+
+        int pass_number;        /* # of passes completed */
+
+        bool using_merged_upsample; /* true if using merged upsample/cconvert */
+
+        /* Saved references to initialized quantizer modules,
+         * in case we need to switch modes.
+         */
+        jpeg_color_quantizer quantizer_1pass;
+        jpeg_color_quantizer quantizer_2pass;
+    }
+    
+    static final class jpeg_inverse_dct {
+//      JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+//      /* It is useful to allow each component to have a separate IDCT method. */
+//      inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
+        int[] cur_method = new int[MAX_COMPONENTS];
+            
+        void start_pass (jpeg_decompress_struct cinfo) {
+            jpeg_inverse_dct idct = cinfo.idct;
+            int ci, i;
+            jpeg_component_info compptr;
+            int method = 0;
+//          inverse_DCT_method_ptr method_ptr = NULL;
+            JQUANT_TBL qtbl;
+
+            for (ci = 0; ci < cinfo.num_components; ci++) {
+                compptr = cinfo.comp_info[ci];
+                /* Select the proper IDCT routine for this component's scaling */
+                switch (compptr.DCT_scaled_size) {
+//                  #ifdef IDCT_SCALING_SUPPORTED
+//                  case 1:
+//                      method_ptr = jpeg_idct_1x1;
+//                      method = JDCT_ISLOW;    /* jidctred uses islow-style table */
+//                      break;
+//                  case 2:
+//                      method_ptr = jpeg_idct_2x2;
+//                      method = JDCT_ISLOW;    /* jidctred uses islow-style table */
+//                      break;
+//                  case 4:
+//                      method_ptr = jpeg_idct_4x4;
+//                      method = JDCT_ISLOW;    /* jidctred uses islow-style table */
+//                      break;
+//                  #endif
+                    case DCTSIZE:
+                        switch (cinfo.dct_method) {
+//                          #ifdef DCT_ISLOW_SUPPORTED
+                            case JDCT_ISLOW:
+//                              method_ptr = jpeg_idct_islow;
+                                method = JDCT_ISLOW;
+                                break;
+//                          #endif
+//                          #ifdef DCT_IFAST_SUPPORTED
+//                          case JDCT_IFAST:
+//                              method_ptr = jpeg_idct_ifast;
+//                              method = JDCT_IFAST;
+//                              break;
+//                          #endif
+//                          #ifdef DCT_FLOAT_SUPPORTED
+//                          case JDCT_FLOAT:
+//                              method_ptr = jpeg_idct_float;
+//                              method = JDCT_FLOAT;
+//                              break;
+//                          #endif
+                            default:
+                                error();
+//                              ERREXIT(cinfo, JERR_NOT_COMPILED);
+                                break;
+                        }
+                        break;
+                    default:
+                        error();
+//                      ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr.DCT_scaled_size);
+                        break;
+                    }
+//                  idct.inverse_DCT[ci] = method_ptr;
+                    /* Create multiplier table from quant table.
+                     * However, we can skip this if the component is uninteresting
+                     * or if we already built the table.    Also, if no quant table
+                     * has yet been saved for the component, we leave the
+                     * multiplier table all-zero; we'll be reading zeroes from the
+                     * coefficient controller's buffer anyway.
+                     */
+                    if (! compptr.component_needed || idct.cur_method[ci] is method)
+                        continue;
+                    qtbl = compptr.quant_table;
+                    if (qtbl is null)       /* happens if no data yet for component */
+                        continue;
+                    idct.cur_method[ci] = method;
+                    switch (method) {
+//                      #ifdef PROVIDE_ISLOW_TABLES
+                        case JDCT_ISLOW:
+                        {
+                            /* For LL&M IDCT method, multipliers are equal to raw quantization
+                             * coefficients, but are stored as ints to ensure access efficiency.
+                             */
+                            int[] ismtbl = compptr.dct_table;
+                            for (i = 0; i < DCTSIZE2; i++) {
+                                ismtbl[i] = qtbl.quantval[i];
+                            }
+                        }
+                        break;
+//                      #endif
+//                      #ifdef DCT_IFAST_SUPPORTED
+//                      case JDCT_IFAST:
+//                      {
+//                          /* For AA&N IDCT method, multipliers are equal to quantization
+//                           * coefficients scaled by scalefactor[row]*scalefactor[col], where
+//                           *   scalefactor[0] = 1
+//                           *   scalefactor[k] = cos(k*PI/16) * sqrt(2)        for k=1..7
+//                           * For integer operation, the multiplier table is to be scaled by
+//                           * IFAST_SCALE_BITS.
+//                           */
+//                          int[] ifmtbl = compptr.dct_table;
+//                          short aanscales[] = {
+//                              /* precomputed values scaled up by 14 bits */
+//                              16384, 22725, 21407, 19266, 16384, 12873,   8867,   4520,
+//                              22725, 31521, 29692, 26722, 22725, 17855, 12299,    6270,
+//                              21407, 29692, 27969, 25172, 21407, 16819, 11585,    5906,
+//                              19266, 26722, 25172, 22654, 19266, 15137, 10426,    5315,
+//                              16384, 22725, 21407, 19266, 16384, 12873,   8867,   4520,
+//                              12873, 17855, 16819, 15137, 12873, 10114,   6967,   3552,
+//                              8867, 12299, 11585, 10426,  8867,   6967,   4799,   2446,
+//                              4520,   6270,   5906,   5315,   4520,   3552,   2446,   1247
+//                          };
+//                          SHIFT_TEMPS
+//                          
+//                          for (i = 0; i < DCTSIZE2; i++) {
+//                              ifmtbl[i] = DESCALE(MULTIPLY16V16( qtbl.quantval[i], aanscales[i]), CONST_BITS-IFAST_SCALE_BITS);
+//                          }
+//                      }
+//                      break;
+//                      #endif
+//                      #ifdef DCT_FLOAT_SUPPORTED
+//                      case JDCT_FLOAT:
+//                      {
+//                          /* For float AA&N IDCT method, multipliers are equal to quantization
+//                           * coefficients scaled by scalefactor[row]*scalefactor[col], where
+//                           *   scalefactor[0] = 1
+//                           *   scalefactor[k] = cos(k*PI/16) * sqrt(2)        for k=1..7
+//                           */
+//                          FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr.dct_table;
+//                          int row, col;
+//                          static const double aanscalefactor[DCTSIZE] = {
+//                              1.0, 1.387039845, 1.306562965, 1.175875602,
+//                              1.0, 0.785694958, 0.541196100, 0.275899379
+//                          };
+//
+//                          i = 0;
+//                          for (row = 0; row < DCTSIZE; row++) {
+//                              for (col = 0; col < DCTSIZE; col++) {
+//                                  fmtbl[i] = (FLOAT_MULT_TYPE)
+//                                      ((double) qtbl.quantval[i] *
+//                                   aanscalefactor[row] * aanscalefactor[col]);
+//                                  i++;
+//                              }
+//                          }
+//                      }
+//                      break;
+//                      #endif
+                    default:
+                        error();
+//                      ERREXIT(cinfo, JERR_NOT_COMPILED);
+                        break;
+                }
+            }
+        }
+    }
+            
+    static final class jpeg_input_controller {
+        int consume_input;
+        bool has_multiple_scans;    /* True if file has multiple scans */
+        bool eoi_reached;
+
+        bool inheaders;     /* true until first SOS is reached */
+    }
+    
+    static final class  jpeg_color_deconverter {
+//      JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+        int color_convert;
+        
+        /* Private state for YCC.RGB conversion */
+        int[] Cr_r_tab;     /* => table for Cr to R conversion */
+        int[] Cb_b_tab;     /* => table for Cb to B conversion */
+        int[] Cr_g_tab;     /* => table for Cr to G conversion */
+        int[] Cb_g_tab;     /* => table for Cb to G conversion */
+            
+        void start_pass (jpeg_decompress_struct cinfo) {
+            /* no work needed */
+        }
+
+    }
+        
+    static final class jpeg_d_post_controller {
+//      JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
+        int post_process_data;
+            
+        /* Color quantization source buffer: this holds output data from
+         * the upsample/color conversion step to be passed to the quantizer.
+         * For two-pass color quantization, we need a full-image buffer;
+         * for one-pass operation, a strip buffer is sufficient.
+         */
+        int[] whole_image;  /* virtual array, or NULL if one-pass */
+        int[][] buffer;     /* strip buffer, or current strip of virtual */
+        int strip_height;   /* buffer size in rows */
+        /* for two-pass mode only: */
+        int starting_row;   /* row # of first row in current strip */
+        int next_row;       /* index of next row to fill/empty in strip */
+                
+        void start_pass (jpeg_decompress_struct cinfo, int pass_mode) {
+            jpeg_d_post_controller post = cinfo.post;
+
+            switch (pass_mode) {
+                case JBUF_PASS_THRU:
+                    if (cinfo.quantize_colors) {
+                        error(DWT.ERROR_NOT_IMPLEMENTED);
+//                      /* Single-pass processing with color quantization. */
+//                      post.post_process_data = POST_PROCESS_1PASS;
+//                      /* We could be doing buffered-image output before starting a 2-pass
+//                       * color quantization; in that case, jinit_d_post_controller did not
+//                       * allocate a strip buffer. Use the virtual-array buffer as workspace.
+//                       */
+//                      if (post.buffer is null) {
+//                          post.buffer = (*cinfo.mem.access_virt_sarray)
+//                              ((j_common_ptr) cinfo, post.whole_image,
+//                              (JDIMENSION) 0, post.strip_height, TRUE);
+//                      }
+                    } else {
+                        /* For single-pass processing without color quantization,
+                         * I have no work to do; just call the upsampler directly.
+                         */
+                        post.post_process_data = POST_PROCESS_DATA_UPSAMPLE;
+                    }
+                    break;
+//              #ifdef QUANT_2PASS_SUPPORTED
+//              case JBUF_SAVE_AND_PASS:
+//                  /* First pass of 2-pass quantization */
+//                  if (post.whole_image is NULL)
+//                      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+//                  post.pub.post_process_data = post_process_prepass;
+//                  break;
+//              case JBUF_CRANK_DEST:
+//                  /* Second pass of 2-pass quantization */
+//                  if (post.whole_image is NULL)
+//                      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+//                  post.pub.post_process_data = post_process_2pass;
+//                  break;
+//              #endif /* QUANT_2PASS_SUPPORTED */
+                    default:
+                        error();
+//                      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+                        break;
+            }
+            post.starting_row = post.next_row = 0;
+        }
+
+    }
+    
+    static final class jpeg_decompress_struct {
+//      jpeg_error_mgr * err;   /* Error handler module */\
+//      struct jpeg_memory_mgr * mem;   /* Memory manager module */\
+//      struct jpeg_progress_mgr * progress; /* Progress monitor, or null if none */\
+//      void * client_data;     /* Available for use by application */\
+        bool is_decompressor;   /* So common code can tell which is which */
+        int global_state;       /* For checking call sequence validity */
+
+//      /* Source of compressed data */
+//      struct jpeg_source_mgr * src;
+        InputStream inputStream;
+        byte[] buffer;
+        int bytes_in_buffer;
+        int bytes_offset;
+        bool start_of_file;
+
+        /* Basic description of image --- filled in by jpeg_read_header(). */
+        /* Application may inspect these values to decide how to process image. */
+
+        int image_width;    /* nominal image width (from SOF marker) */
+        int image_height;   /* nominal image height */
+        int num_components;     /* # of color components in JPEG image */
+        int jpeg_color_space; /* colorspace of JPEG image */
+
+        /* Decompression processing parameters --- these fields must be set before
+         * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes
+         * them to default values.
+         */
+
+        int out_color_space; /* colorspace for output */
+
+        int scale_num, scale_denom; /* fraction by which to scale image */
+
+        double output_gamma;        /* image gamma wanted in output */
+
+        bool buffered_image;    /* true=multiple output passes */
+        bool raw_data_out;      /* true=downsampled data wanted */
+
+        int dct_method; /* IDCT algorithm selector */
+        bool do_fancy_upsampling;   /* true=apply fancy upsampling */
+        bool do_block_smoothing;    /* true=apply interblock smoothing */
+
+        bool quantize_colors;   /* true=colormapped output wanted */
+        /* the following are ignored if not quantize_colors: */
+        int dither_mode;    /* type of color dithering to use */
+        bool two_pass_quantize; /* true=use two-pass color quantization */
+        int desired_number_of_colors;   /* max # colors to use in created colormap */
+        /* these are significant only in buffered-image mode: */
+        bool enable_1pass_quant;    /* enable future use of 1-pass quantizer */
+        bool enable_external_quant;/* enable future use of external colormap */
+        bool enable_2pass_quant;    /* enable future use of 2-pass quantizer */
+
+        /* Description of actual output image that will be returned to application.
+         * These fields are computed by jpeg_start_decompress().
+         * You can also use jpeg_calc_output_dimensions() to determine these values
+         * in advance of calling jpeg_start_decompress().
+         */
+
+        int output_width;   /* scaled image width */
+        int output_height;  /* scaled image height */
+        int out_color_components;   /* # of color components in out_color_space */
+        int output_components;  /* # of color components returned */
+        /* output_components is 1 (a colormap index) when quantizing colors;
+         * otherwise it opEquals out_color_components.
+         */
+        int rec_outbuf_height;  /* min recommended height of scanline buffer */
+        /* If the buffer passed to jpeg_read_scanlines() is less than this many rows
+         * high, space and time will be wasted due to unnecessary data copying.
+         * Usually rec_outbuf_height will be 1 or 2, at most 4.
+         */
+
+        /* When quantizing colors, the output colormap is described by these fields.
+         * The application can supply a colormap by setting colormap non-null before
+         * calling jpeg_start_decompress; otherwise a colormap is created during
+         * jpeg_start_decompress or jpeg_start_output.
+         * The map has out_color_components rows and actual_number_of_colors columns.
+         */
+        int actual_number_of_colors;    /* number of entries in use */
+        int[] colormap;     /* The color map as a 2-D pixel array */
+
+        /* State variables: these variables indicate the progress of decompression.
+         * The application may examine these but must not modify them.
+         */
+
+        /* Row index of next scanline to be read from jpeg_read_scanlines().
+         * Application may use this to control its processing loop, e.g.,
+         * "while (output_scanline < output_height)".
+         */
+        int output_scanline;    /* 0 .. output_height-1 */
+
+        /* Current input scan number and number of iMCU rows completed in scan.
+         * These indicate the progress of the decompressor input side.
+         */
+        int input_scan_number;  /* Number of SOS markers seen so far */
+        int input_iMCU_row; /* Number of iMCU rows completed */
+
+        /* The "output scan number" is the notional scan being displayed by the
+         * output side. The decompressor will not allow output scan/row number
+         * to get ahead of input scan/row, but it can fall arbitrarily far behind.
+         */
+        int output_scan_number; /* Nominal scan number being displayed */
+        int output_iMCU_row;    /* Number of iMCU rows read */
+
+        /* Current progression status.  coef_bits[c][i] indicates the precision
+         * with which component c's DCT coefficient i (in zigzag order) is known.
+         * It is -1 when no data has yet been received, otherwise it is the point
+         * transform (shift) value for the most recent scan of the coefficient
+         * (thus, 0 at completion of the progression).
+         * This pointer is null when reading a non-progressive file.
+         */
+        int[][] coef_bits;  /* -1 or current Al value for each coef */
+
+        /* Internal JPEG parameters --- the application usually need not look at
+         * these fields.    Note that the decompressor output side may not use
+         * any parameters that can change between scans.
+         */
+
+        /* Quantization and Huffman tables are carried forward across input
+         * datastreams when processing abbreviated JPEG datastreams.
+         */
+
+        JQUANT_TBL[] quant_tbl_ptrs = new JQUANT_TBL[NUM_QUANT_TBLS];
+        /* ptrs to coefficient quantization tables, or null if not defined */
+
+        JHUFF_TBL[] dc_huff_tbl_ptrs = new JHUFF_TBL[NUM_HUFF_TBLS];
+        JHUFF_TBL[] ac_huff_tbl_ptrs = new JHUFF_TBL[NUM_HUFF_TBLS];
+        /* ptrs to Huffman coding tables, or null if not defined */
+
+        /* These parameters are never carried across datastreams, since they
+         * are given in SOF/SOS markers or defined to be reset by SOI.
+         */
+
+        int data_precision;     /* bits of precision in image data */
+
+        jpeg_component_info[] comp_info;
+        /* comp_info[i] describes component that appears i'th in SOF */
+
+        bool progressive_mode;  /* true if SOFn specifies progressive mode */
+        bool arith_code;        /* true=arithmetic coding, false=Huffman */
+
+        byte[] arith_dc_L = new byte[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+        byte[] arith_dc_U = new byte[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+        byte[] arith_ac_K = new byte[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+        int restart_interval; /* MCUs per restart interval, or 0 for no restart */
+
+        /* These fields record data obtained from optional markers recognized by
+         * the JPEG library.
+         */
+        bool saw_JFIF_marker;   /* true iff a JFIF APP0 marker was found */
+        /* Data copied from JFIF marker; only valid if saw_JFIF_marker is true: */
+        byte JFIF_major_version;    /* JFIF version number */
+        byte JFIF_minor_version;
+        byte density_unit;      /* JFIF code for pixel size units */
+        short X_density;        /* Horizontal pixel density */
+        short Y_density;        /* Vertical pixel density */
+        bool saw_Adobe_marker;  /* true iff an Adobe APP14 marker was found */
+        byte Adobe_transform;   /* Color transform code from Adobe marker */
+
+        bool CCIR601_sampling;  /* true=first samples are cosited */
+
+        /* Aside from the specific data retained from APPn markers known to the
+         * library, the uninterpreted contents of any or all APPn and COM markers
+         * can be saved in a list for examination by the application.
+         */
+        jpeg_marker_reader marker_list; /* Head of list of saved markers */
+
+        /* Remaining fields are known throughout decompressor, but generally
+         * should not be touched by a surrounding application.
+         */
+
+        /*
+         * These fields are computed during decompression startup
+         */
+        int max_h_samp_factor;  /* largest h_samp_factor */
+        int max_v_samp_factor;  /* largest v_samp_factor */
+
+        int min_DCT_scaled_size;    /* smallest DCT_scaled_size of any component */
+
+        int total_iMCU_rows;    /* # of iMCU rows in image */
+        /* The coefficient controller's input and output progress is measured in
+         * units of "iMCU" (interleaved MCU) rows.  These are the same as MCU rows
+         * in fully interleaved JPEG scans, but are used whether the scan is
+         * interleaved or not.  We define an iMCU row as v_samp_factor DCT block
+         * rows of each component.  Therefore, the IDCT output contains
+         * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.
+         */
+
+        byte[] sample_range_limit; /* table for fast range-limiting */
+        int sample_range_limit_offset;
+
+        /*
+         * These fields are valid during any one scan.
+         * They describe the components and MCUs actually appearing in the scan.
+         * Note that the decompressor output side must not use these fields.
+         */
+        int comps_in_scan;      /* # of JPEG components in this scan */
+        jpeg_component_info[] cur_comp_info = new jpeg_component_info[MAX_COMPS_IN_SCAN];
+        /* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+        int MCUs_per_row;   /* # of MCUs across the image */
+        int MCU_rows_in_scan;   /* # of MCU rows in the image */
+
+        int blocks_in_MCU;      /* # of DCT blocks per MCU */
+        int[] MCU_membership = new int[D_MAX_BLOCKS_IN_MCU];
+        /* MCU_membership[i] is index in cur_comp_info of component owning */
+        /* i'th block in an MCU */
+
+        int Ss, Se, Ah, Al;     /* progressive JPEG parameters for scan */
+
+        /* This field is shared between entropy decoder and marker parser.
+         * It is either zero or the code of a JPEG marker that has been
+         * read from the data source, but has not yet been processed.
+         */
+        int unread_marker;
+        
+        int[] workspace = new int[DCTSIZE2];
+        int[] row_ctr = new int[1];
+
+        /*
+         * Links to decompression subobjects (methods, private variables of modules)
+         */
+        jpeg_decomp_master master;
+        jpeg_d_main_controller main;
+        jpeg_d_coef_controller coef;
+        jpeg_d_post_controller post;
+        jpeg_input_controller inputctl;
+        jpeg_marker_reader marker;
+        jpeg_entropy_decoder entropy;
+        jpeg_inverse_dct idct;
+        jpeg_upsampler upsample;
+        jpeg_color_deconverter cconvert;
+        jpeg_color_quantizer cquantize;
+    }
+
+static void error() {
+    DWT.error(DWT.ERROR_INVALID_IMAGE);
+}
+
+static void error(int code) {
+    DWT.error(code);
+}
+
+static void error(String msg) {
+    DWT.error(DWT.ERROR_INVALID_IMAGE, null, msg);
+}
+
+static void jinit_marker_reader (jpeg_decompress_struct cinfo) {
+    jpeg_marker_reader marker = cinfo.marker = new jpeg_marker_reader();
+//  int i;
+
+    /* Initialize COM/APPn processing.
+     * By default, we examine and then discard APP0 and APP14,
+     * but simply discard COM and all other APPn.
+     */
+//  marker.process_COM = skip_variable;
+    marker.length_limit_COM = 0;
+//  for (i = 0; i < 16; i++) {
+//      marker.process_APPn[i] = skip_variable;
+//      marker.length_limit_APPn[i] = 0;
+//  }
+//  marker.process_APPn[0] = get_interesting_appn;
+//  marker.process_APPn[14] = get_interesting_appn;
+    /* Reset marker processing state */
+    reset_marker_reader(cinfo);
+}
+
+static void jinit_d_coef_controller (jpeg_decompress_struct cinfo, bool need_full_buffer) {
+    jpeg_d_coef_controller coef = new jpeg_d_coef_controller();
+    cinfo.coef = coef;
+//  coef.pub.start_input_pass = start_input_pass;
+//  coef.pub.start_output_pass = start_output_pass;
+    coef.coef_bits_latch = null;
+
+    /* Create the coefficient buffer. */
+    if (need_full_buffer) {
+//#ifdef D_MULTISCAN_FILES_SUPPORTED
+        /* Allocate a full-image virtual array for each component, */
+        /* padded to a multiple of samp_factor DCT blocks in each direction. */
+        /* Note we ask for a pre-zeroed array. */
+        int ci, access_rows;
+        jpeg_component_info compptr;
+
+        for (ci = 0; ci < cinfo.num_components; ci++) {
+            compptr = cinfo.comp_info[ci];
+            access_rows = compptr.v_samp_factor;
+//#ifdef BLOCK_SMOOTHING_SUPPORTED
+            /* If block smoothing could be used, need a bigger window */
+            if (cinfo.progressive_mode)
+                access_rows *= 3;
+//#endif
+            coef.whole_image[ci] = 
+                new short
+                    [(int)jround_up( compptr.height_in_blocks, compptr.v_samp_factor)]
+                    [(int)jround_up( compptr.width_in_blocks, compptr.h_samp_factor)]
+                    [DCTSIZE2];
+        }
+//      coef.consume_data = consume_data;
+        coef.decompress_data = DECOMPRESS_DATA;
+        coef.coef_arrays = coef.whole_image[0]; /* link to virtual arrays */
+//      #else
+//              ERREXIT(cinfo, JERR_NOT_COMPILED);
+//      #endif
+    } else {
+        /* We only need a single-MCU buffer. */
+        coef.MCU_buffer = new short[D_MAX_BLOCKS_IN_MCU][DCTSIZE2];
+//      coef.consume_data = dummy_consume_data;
+        coef.decompress_data = DECOMPRESS_ONEPASS;
+        coef.coef_arrays = null; /* flag for no virtual arrays */
+    }
+}
+
+static void start_output_pass (jpeg_decompress_struct cinfo) {
+//#ifdef BLOCK_SMOOTHING_SUPPORTED
+    jpeg_d_coef_controller coef = cinfo.coef;
+
+    /* If multipass, check to see whether to use block smoothing on this pass */
+    if (coef.coef_arrays !is null) {
+        if (cinfo.do_block_smoothing && smoothing_ok(cinfo))
+            coef.decompress_data = DECOMPRESS_SMOOTH_DATA;
+        else
+            coef.decompress_data = DECOMPRESS_DATA;
+    }
+//#endif
+    cinfo.output_iMCU_row = 0;
+}
+
+static void jpeg_create_decompress(jpeg_decompress_struct cinfo) {
+    cinfo.is_decompressor = true;
+
+
+    /* Initialize marker processor so application can override methods
+     * for COM, APPn markers before calling jpeg_read_header.
+     */
+    cinfo.marker_list = null;
+    jinit_marker_reader(cinfo);
+
+    /* And initialize the overall input controller. */
+    jinit_input_controller(cinfo);
+
+    /* OK, I'm ready */
+    cinfo.global_state = DSTATE_START;
+}
+
+static void jpeg_calc_output_dimensions (jpeg_decompress_struct cinfo)
+/* Do computations that are needed before master selection phase */
+{
+//#ifdef IDCT_SCALING_SUPPORTED
+//  int ci;
+//  jpeg_component_info compptr;
+//#endif
+
+    /* Prevent application from calling me at wrong times */
+    if (cinfo.global_state !is DSTATE_READY)
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+
+//#ifdef IDCT_SCALING_SUPPORTED
+//
+//  /* Compute actual output image dimensions and DCT scaling choices. */
+//  if (cinfo.scale_num * 8 <= cinfo.scale_denom) {
+//      /* Provide 1/8 scaling */
+//      cinfo.output_width = (int)
+//          jdiv_round_up(cinfo.image_width, 8L);
+//      cinfo.output_height = (int)
+//          jdiv_round_up(cinfo.image_height, 8L);
+//      cinfo.min_DCT_scaled_size = 1;
+//  } else if (cinfo.scale_num * 4 <= cinfo.scale_denom) {
+//      /* Provide 1/4 scaling */
+//      cinfo.output_width = (int)
+//          jdiv_round_up(cinfo.image_width, 4L);
+//      cinfo.output_height = (int)
+//          jdiv_round_up(cinfo.image_height, 4L);
+//      cinfo.min_DCT_scaled_size = 2;
+//  } else if (cinfo.scale_num * 2 <= cinfo.scale_denom) {
+//      /* Provide 1/2 scaling */
+//      cinfo.output_width = (int)
+//          jdiv_round_up(cinfo.image_width, 2L);
+//      cinfo.output_height = (int)
+//          jdiv_round_up(cinfo.image_height, 2L);
+//      cinfo.min_DCT_scaled_size = 4;
+//  } else {
+//      /* Provide 1/1 scaling */
+//      cinfo.output_width = cinfo.image_width;
+//      cinfo.output_height = cinfo.image_height;
+//      cinfo.min_DCT_scaled_size = DCTSIZE;
+//  }
+//  /* In selecting the actual DCT scaling for each component, we try to
+//   * scale up the chroma components via IDCT scaling rather than upsampling.
+//   * This saves time if the upsampler gets to use 1:1 scaling.
+//   * Note this code assumes that the supported DCT scalings are powers of 2.
+//   */
+//  for (ci = 0; ci < cinfo.num_components; ci++) {
+//      compptr = cinfo.comp_info[ci];
+//      int ssize = cinfo.min_DCT_scaled_size;
+//      while (ssize < DCTSIZE &&
+//          (compptr.h_samp_factor * ssize * 2 <= cinfo.max_h_samp_factor * cinfo.min_DCT_scaled_size) &&
+//          (compptr.v_samp_factor * ssize * 2 <= cinfo.max_v_samp_factor * cinfo.min_DCT_scaled_size))
+//      {
+//          ssize = ssize * 2;
+//      }
+//      compptr.DCT_scaled_size = ssize;
+//  }
+//
+//  /* Recompute downsampled dimensions of components;
+//   * application needs to know these if using raw downsampled data.
+//   */
+//  for (ci = 0; ci < cinfo.num_components; ci++) {
+//      compptr = cinfo.comp_info[ci];
+//      /* Size in samples, after IDCT scaling */
+//      compptr.downsampled_width = (int)
+//          jdiv_round_up((long) cinfo.image_width * (long) (compptr.h_samp_factor * compptr.DCT_scaled_size),
+//              (cinfo.max_h_samp_factor * DCTSIZE));
+//      compptr.downsampled_height = (int)
+//          jdiv_round_up((long) cinfo.image_height * (long) (compptr.v_samp_factor * compptr.DCT_scaled_size),
+//              (cinfo.max_v_samp_factor * DCTSIZE));
+//  }
+//
+//#else /* !IDCT_SCALING_SUPPORTED */
+
+    /* Hardwire it to "no scaling" */
+    cinfo.output_width = cinfo.image_width;
+    cinfo.output_height = cinfo.image_height;
+    /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
+     * and has computed unscaled downsampled_width and downsampled_height.
+     */
+
+//#endif /* IDCT_SCALING_SUPPORTED */
+
+    /* Report number of components in selected colorspace. */
+    /* Probably this should be in the color conversion module... */
+    switch (cinfo.out_color_space) {
+        case JCS_GRAYSCALE:
+            cinfo.out_color_components = 1;
+            break;
+        case JCS_RGB:
+            if (RGB_PIXELSIZE !is 3) {
+                cinfo.out_color_components = RGB_PIXELSIZE;
+                break;
+            }
+            //FALLTHROUGH
+        case JCS_YCbCr:
+            cinfo.out_color_components = 3;
+            break;
+        case JCS_CMYK:
+        case JCS_YCCK:
+            cinfo.out_color_components = 4;
+            break;
+        default:            /* else must be same colorspace as in file */
+            cinfo.out_color_components = cinfo.num_components;
+            break;
+    }
+    cinfo.output_components = (cinfo.quantize_colors ? 1 : cinfo.out_color_components);
+
+    /* See if upsampler will want to emit more than one row at a time */
+    if (use_merged_upsample(cinfo))
+        cinfo.rec_outbuf_height = cinfo.max_v_samp_factor;
+    else
+        cinfo.rec_outbuf_height = 1;
+}
+
+static bool use_merged_upsample (jpeg_decompress_struct cinfo) {
+//#ifdef UPSAMPLE_MERGING_SUPPORTED
+    /* Merging is the equivalent of plain box-filter upsampling */
+    if (cinfo.do_fancy_upsampling || cinfo.CCIR601_sampling)
+        return false;
+    /* jdmerge.c only supports YCC=>RGB color conversion */
+    if (cinfo.jpeg_color_space !is JCS_YCbCr || cinfo.num_components !is 3 ||
+            cinfo.out_color_space !is JCS_RGB ||
+            cinfo.out_color_components !is RGB_PIXELSIZE)
+        return false;
+    /* and it only handles 2h1v or 2h2v sampling ratios */
+    if (cinfo.comp_info[0].h_samp_factor !is 2 ||
+            cinfo.comp_info[1].h_samp_factor !is 1 ||
+            cinfo.comp_info[2].h_samp_factor !is 1 ||
+            cinfo.comp_info[0].v_samp_factor >  2 ||
+            cinfo.comp_info[1].v_samp_factor !is 1 ||
+            cinfo.comp_info[2].v_samp_factor !is 1)
+        return false;
+    /* furthermore, it doesn't work if we've scaled the IDCTs differently */
+    if (cinfo.comp_info[0].DCT_scaled_size !is cinfo.min_DCT_scaled_size ||
+            cinfo.comp_info[1].DCT_scaled_size !is cinfo.min_DCT_scaled_size ||
+            cinfo.comp_info[2].DCT_scaled_size !is cinfo.min_DCT_scaled_size)
+        return false;
+    /* ??? also need to test for upsample-time rescaling, when & if supported */
+    return true;            /* by golly, it'll work... */
+//#else
+//  return false;
+//#endif
+}
+
+static void prepare_range_limit_table (jpeg_decompress_struct cinfo)
+/* Allocate and fill in the sample_range_limit table */
+{
+    byte[] table;
+    int i;
+
+    table = new byte[5 * (MAXJSAMPLE+1) + CENTERJSAMPLE];
+    int offset = (MAXJSAMPLE+1);    /* allow negative subscripts of simple table */
+    cinfo.sample_range_limit_offset = offset;
+    cinfo.sample_range_limit = table;
+    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
+    /* Main part of "simple" table: limit[x] = x */
+    for (i = 0; i <= MAXJSAMPLE; i++)
+        table[i + offset] = (byte)i;
+    offset += CENTERJSAMPLE;    /* Point to where post-IDCT table starts */
+    /* End of simple table, rest of first half of post-IDCT table */
+    for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
+        table[i+offset] = (byte)MAXJSAMPLE;
+    /* Second half of post-IDCT table */
+    System.arraycopy(cinfo.sample_range_limit, cinfo.sample_range_limit_offset, table, offset + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), CENTERJSAMPLE);
+}
+
+static void build_ycc_rgb_table (jpeg_decompress_struct cinfo) {
+    jpeg_color_deconverter cconvert = cinfo.cconvert;
+    int i;
+    int x;
+//  SHIFT_TEMPS
+
+    cconvert.Cr_r_tab = new int[MAXJSAMPLE+1];
+    cconvert.Cb_b_tab = new int[MAXJSAMPLE+1];
+    cconvert.Cr_g_tab = new int[MAXJSAMPLE+1];
+    cconvert.Cb_g_tab = new int[MAXJSAMPLE+1];
+
+    for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
+        /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
+        /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
+        /* Cr=>R value is nearest int to 1.40200 * x */
+        cconvert.Cr_r_tab[i] = ((int)(1.40200f * (1<<SCALEBITS) + 0.5f) * x + ONE_HALF) >> SCALEBITS;
+        /* Cb=>B value is nearest int to 1.77200 * x */
+        cconvert.Cb_b_tab[i] = ((int)(1.77200f * (1<<SCALEBITS) + 0.5f) * x + ONE_HALF) >> SCALEBITS;
+        /* Cr=>G value is scaled-up -0.71414 * x */
+        cconvert.Cr_g_tab[i] = ((int)(- (0.71414f * (1<<SCALEBITS) + 0.5f)) * x);
+        /* Cb=>G value is scaled-up -0.34414 * x */
+        /* We also add in ONE_HALF so that need not do it in inner loop */
+        cconvert.Cb_g_tab[i] = ((int)(- (0.34414f* (1<<SCALEBITS) + 0.5f)) * x + ONE_HALF);
+    }
+}
+
+static void jinit_color_deconverter (jpeg_decompress_struct cinfo) {
+    jpeg_color_deconverter cconvert = cinfo.cconvert = new jpeg_color_deconverter();
+//  cconvert.start_pass = start_pass_dcolor;
+
+    /* Make sure num_components agrees with jpeg_color_space */
+    switch (cinfo.jpeg_color_space) {
+        case JCS_GRAYSCALE:
+            if (cinfo.num_components !is 1)
+                error();
+//              ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+            break;
+
+        case JCS_RGB:
+        case JCS_YCbCr:
+            if (cinfo.num_components !is 3)
+                error();
+//              ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+            break;
+
+        case JCS_CMYK:
+        case JCS_YCCK:
+            if (cinfo.num_components !is 4)
+                error();
+//              ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+            break;
+
+        default:            /* JCS_UNKNOWN can be anything */
+            if (cinfo.num_components < 1)
+                error();
+//              ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+            break;
+    }
+
+    /* Set out_color_components and conversion method based on requested space.
+     * Also clear the component_needed flags for any unused components,
+     * so that earlier pipeline stages can avoid useless computation.
+     */
+
+    int ci;
+    switch (cinfo.out_color_space) {
+        case JCS_GRAYSCALE:
+            cinfo.out_color_components = 1;
+            if (cinfo.jpeg_color_space is JCS_GRAYSCALE || cinfo.jpeg_color_space is JCS_YCbCr) {
+                cconvert.color_convert = GRAYSCALE_CONVERT;
+                /* For color.grayscale conversion, only the Y (0) component is needed */
+                for (ci = 1; ci < cinfo.num_components; ci++)
+                    cinfo.comp_info[ci].component_needed = false;
+            } else
+                error();
+//              ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+            break;
+
+        case JCS_RGB:
+            cinfo.out_color_components = RGB_PIXELSIZE;
+            if (cinfo.jpeg_color_space is JCS_YCbCr) {
+                cconvert.color_convert = YCC_RGB_CONVERT;
+                build_ycc_rgb_table(cinfo);
+            } else if (cinfo.jpeg_color_space is JCS_GRAYSCALE) {
+                cconvert.color_convert = GRAY_RGB_CONVERT;
+            } else if (cinfo.jpeg_color_space is JCS_RGB && RGB_PIXELSIZE is 3) {
+                cconvert.color_convert = NULL_CONVERT;
+            } else
+                error();
+//              ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+                break;
+
+        case JCS_CMYK:
+            cinfo.out_color_components = 4;
+            if (cinfo.jpeg_color_space is JCS_YCCK) {
+                cconvert.color_convert = YCCK_CMYK_CONVERT;
+                build_ycc_rgb_table(cinfo);
+            } else if (cinfo.jpeg_color_space is JCS_CMYK) {
+                cconvert.color_convert = NULL_CONVERT;
+            } else
+                error();
+//              ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+            break;
+
+        default:
+            /* Permit null conversion to same output space */
+            if (cinfo.out_color_space is cinfo.jpeg_color_space) {
+                cinfo.out_color_components = cinfo.num_components;
+                cconvert.color_convert = NULL_CONVERT;
+            } else  /* unsupported non-null conversion */
+                error();
+//              ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+            break;
+    }
+
+    if (cinfo.quantize_colors)
+        cinfo.output_components = 1; /* single colormapped output component */
+    else
+        cinfo.output_components = cinfo.out_color_components;
+}
+
+static void jinit_d_post_controller (jpeg_decompress_struct cinfo, bool need_full_buffer) {
+    jpeg_d_post_controller post = cinfo.post = new jpeg_d_post_controller();
+//  post.pub.start_pass = start_pass_dpost;
+    post.whole_image = null;    /* flag for no virtual arrays */
+    post.buffer = null;     /* flag for no strip buffer */
+
+    /* Create the quantization buffer, if needed */
+    if (cinfo.quantize_colors) {
+        error(DWT.ERROR_NOT_IMPLEMENTED);
+//      /* The buffer strip height is max_v_samp_factor, which is typically
+//       * an efficient number of rows for upsampling to return.
+//       * (In the presence of output rescaling, we might want to be smarter?)
+//       */
+//      post.strip_height = cinfo.max_v_samp_factor;
+//      if (need_full_buffer) {
+//          /* Two-pass color quantization: need full-image storage. */
+//          /* We round up the number of rows to a multiple of the strip height. */
+//#ifdef QUANT_2PASS_SUPPORTED
+//          post.whole_image = (*cinfo.mem.request_virt_sarray)
+//              ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
+//              cinfo.output_width * cinfo.out_color_components,
+//              (JDIMENSION) jround_up((long) cinfo.output_height,
+//              (long) post.strip_height),
+//   post.strip_height);
+//#else
+//          ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+//#endif /* QUANT_2PASS_SUPPORTED */
+//      } else {
+//          /* One-pass color quantization: just make a strip buffer. */
+//          post.buffer = (*cinfo.mem.alloc_sarray)
+//              ((j_common_ptr) cinfo, JPOOL_IMAGE,
+//              cinfo.output_width * cinfo.out_color_components,
+//              post.strip_height);
+//      }
+    }
+}
+
+static void make_funny_pointers (jpeg_decompress_struct cinfo)
+/* Create the funny pointer lists discussed in the comments above.
+ * The actual workspace is already allocated (in main.buffer),
+ * and the space for the pointer lists is allocated too.
+ * This routine just fills in the curiously ordered lists.
+ * This will be repeated at the beginning of each pass.
+ */
+{
+    jpeg_d_main_controller main = cinfo.main;
+    int ci, i, rgroup;
+    int M = cinfo.min_DCT_scaled_size;
+    jpeg_component_info compptr;
+    byte[][] buf, xbuf0, xbuf1;
+    
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) /
+            cinfo.min_DCT_scaled_size; /* height of a row group of component */
+        xbuf0 = main.xbuffer[0][ci];
+        int xbuf0_offset = main.xbuffer_offset[0][ci];
+        xbuf1 = main.xbuffer[1][ci];
+        int xbuf1_offset = main.xbuffer_offset[1][ci];
+        /* First copy the workspace pointers as-is */
+        buf = main.buffer[ci];
+        for (i = 0; i < rgroup * (M + 2); i++) {
+            xbuf0[i + xbuf0_offset] = xbuf1[i + xbuf1_offset] = buf[i];
+        }
+        /* In the second list, put the last four row groups in swapped order */
+        for (i = 0; i < rgroup * 2; i++) {
+            xbuf1[rgroup*(M-2) + i + xbuf1_offset] = buf[rgroup*M + i];
+            xbuf1[rgroup*M + i + xbuf1_offset] = buf[rgroup*(M-2) + i];
+        }
+        /* The wraparound pointers at top and bottom will be filled later
+         * (see set_wraparound_pointers, below).    Initially we want the "above"
+         * pointers to duplicate the first actual data line.    This only needs
+         * to happen in xbuffer[0].
+         */
+        for (i = 0; i < rgroup; i++) {
+            xbuf0[i - rgroup + xbuf0_offset] = xbuf0[0 + xbuf0_offset];
+        }
+    }
+}
+
+static void alloc_funny_pointers (jpeg_decompress_struct cinfo)
+/* Allocate space for the funny pointer lists.
+ * This is done only once, not once per pass.
+ */
+{
+    jpeg_d_main_controller main = cinfo.main;
+    int ci, rgroup;
+    int M = cinfo.min_DCT_scaled_size;
+    jpeg_component_info compptr;
+    byte[][] xbuf;
+
+    /* Get top-level space for component array pointers.
+     * We alloc both arrays with one call to save a few cycles.
+     */
+    main.xbuffer[0] = new byte[cinfo.num_components][][];
+    main.xbuffer[1] = new byte[cinfo.num_components][][];
+    main.xbuffer_offset[0] = new int[cinfo.num_components];
+    main.xbuffer_offset[1] = new int[cinfo.num_components];
+
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) / cinfo.min_DCT_scaled_size; /* height of a row group of component */
+        /* Get space for pointer lists --- M+4 row groups in each list.
+         * We alloc both pointer lists with one call to save a few cycles.
+         */
+        xbuf = new byte[2 * (rgroup * (M + 4))][];
+        int offset = rgroup;
+        main.xbuffer_offset[0][ci] = offset;
+        main.xbuffer[0][ci] = xbuf;
+        offset += rgroup * (M + 4);
+        main.xbuffer_offset[1][ci] = offset;
+        main.xbuffer[1][ci] = xbuf;
+    }
+}
+
+
+static void jinit_d_main_controller (jpeg_decompress_struct cinfo, bool need_full_buffer) {
+    int ci, rgroup, ngroups;
+    jpeg_component_info compptr;
+
+    jpeg_d_main_controller main = cinfo.main = new jpeg_d_main_controller();
+//  main.pub.start_pass = start_pass_main;
+
+    if (need_full_buffer)       /* shouldn't happen */
+        error();
+//      ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+
+    /* Allocate the workspace.
+     * ngroups is the number of row groups we need.
+     */
+    if (cinfo.upsample.need_context_rows) {
+        if (cinfo.min_DCT_scaled_size < 2) /* unsupported, see comments above */
+            error();
+//          ERREXIT(cinfo, JERR_NOTIMPL);
+        alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
+        ngroups = cinfo.min_DCT_scaled_size + 2;
+    } else {
+        ngroups = cinfo.min_DCT_scaled_size;
+    }
+
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) / cinfo.min_DCT_scaled_size; /* height of a row group of component */
+        main.buffer[ci] = new byte[rgroup * ngroups][compptr.width_in_blocks * compptr.DCT_scaled_size];
+    }
+}
+
+static long jround_up (long a, long b)
+/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
+/* Assumes a >= 0, b > 0 */
+{
+    a += b - 1L;
+    return a - (a % b);
+}
+
+static void jinit_upsampler (jpeg_decompress_struct cinfo) {
+    int ci;
+    jpeg_component_info compptr;
+    bool need_buffer, do_fancy;
+    int h_in_group, v_in_group, h_out_group, v_out_group;
+
+    jpeg_upsampler upsample = new jpeg_upsampler();
+    cinfo.upsample = upsample;
+//  upsample.start_pass = start_pass_upsample;
+//  upsample.upsample = sep_upsample;
+    upsample.need_context_rows = false; /* until we find out differently */
+
+    if (cinfo.CCIR601_sampling) /* this isn't supported */
+        error();
+//      ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
+
+    /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
+     * so don't ask for it.
+     */
+    do_fancy = cinfo.do_fancy_upsampling && cinfo.min_DCT_scaled_size > 1;
+
+    /* Verify we can handle the sampling factors, select per-component methods,
+     * and create storage as needed.
+     */
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        /* Compute size of an "input group" after IDCT scaling. This many samples
+         * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
+         */
+        h_in_group = (compptr.h_samp_factor * compptr.DCT_scaled_size) /
+         cinfo.min_DCT_scaled_size;
+        v_in_group = (compptr.v_samp_factor * compptr.DCT_scaled_size) /
+         cinfo.min_DCT_scaled_size;
+        h_out_group = cinfo.max_h_samp_factor;
+        v_out_group = cinfo.max_v_samp_factor;
+        upsample.rowgroup_height[ci] = v_in_group; /* save for use later */
+        need_buffer = true;
+        if (! compptr.component_needed) {
+            /* Don't bother to upsample an uninteresting component. */
+            upsample.methods[ci] = NOOP_UPSAMPLE;
+            need_buffer = false;
+        } else if (h_in_group is h_out_group && v_in_group is v_out_group) {
+            /* Fullsize components can be processed without any work. */
+            upsample.methods[ci] = FULLSIZE_UPSAMPLE;
+            need_buffer = false;
+        } else if (h_in_group * 2 is h_out_group && v_in_group is v_out_group) {
+            /* Special cases for 2h1v upsampling */
+            if (do_fancy && compptr.downsampled_width > 2)
+                upsample.methods[ci] = H2V1_FANCY_UPSAMPLE;
+            else
+                upsample.methods[ci] = H2V1_UPSAMPLE;
+        } else if (h_in_group * 2 is h_out_group && v_in_group * 2 is v_out_group) {
+            /* Special cases for 2h2v upsampling */
+            if (do_fancy && compptr.downsampled_width > 2) {
+                upsample.methods[ci] = H2V2_FANCY_UPSAMPLE;
+                upsample.need_context_rows = true;
+            } else
+                upsample.methods[ci] = H2V2_UPSAMPLE;
+        } else if ((h_out_group % h_in_group) is 0 && (v_out_group % v_in_group) is 0) {
+            /* Generic integral-factors upsampling method */
+            upsample.methods[ci] = INT_UPSAMPLE;
+            upsample.h_expand[ci] = (byte) (h_out_group / h_in_group);
+            upsample.v_expand[ci] = (byte) (v_out_group / v_in_group);
+        } else
+            error();
+//          ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
+        if (need_buffer) {
+            upsample.color_buf[ci] = new byte[cinfo.max_v_samp_factor]
+                         [(int) jround_up(cinfo.output_width, cinfo.max_h_samp_factor)];
+        }
+    }
+}
+
+static void jinit_phuff_decoder (jpeg_decompress_struct cinfo) {
+    int[][] coef_bit_ptr;
+    int ci, i;
+
+    cinfo.entropy = new phuff_entropy_decoder();
+//  entropy.pub.start_pass = start_pass_phuff_decoder;
+
+    /* Create progression status table */
+    cinfo.coef_bits = new int[cinfo.num_components][DCTSIZE2];
+    coef_bit_ptr = cinfo.coef_bits;
+    for (ci = 0; ci < cinfo.num_components; ci++) 
+        for (i = 0; i < DCTSIZE2; i++)
+            coef_bit_ptr[ci][i] = -1;
+}
+
+
+static void jinit_huff_decoder (jpeg_decompress_struct cinfo) {
+
+    cinfo.entropy = new huff_entropy_decoder();
+//  entropy.pub.start_pass = start_pass_huff_decoder;
+//  entropy.pub.decode_mcu = decode_mcu;
+
+}
+
+static void jinit_inverse_dct (jpeg_decompress_struct cinfo) {
+    int ci;
+    jpeg_component_info compptr;
+
+    jpeg_inverse_dct idct = cinfo.idct = new jpeg_inverse_dct();
+//  idct.pub.start_pass = start_pass;
+
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        /* Allocate and pre-zero a multiplier table for each component */
+        compptr.dct_table = new int[DCTSIZE2];
+        /* Mark multiplier table not yet set up for any method */
+        idct.cur_method[ci] = -1;
+    }
+}
+
+static final int CONST_BITS = 13;
+static final int PASS1_BITS = 2;
+static final int RANGE_MASK =(MAXJSAMPLE * 4 + 3);
+static void jpeg_idct_islow (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+    short[] coef_block,
+    byte[][] output_buf, int output_buf_offset, int output_col)
+{
+    int tmp0, tmp1, tmp2, tmp3;
+    int tmp10, tmp11, tmp12, tmp13;
+    int z1, z2, z3, z4, z5;
+    short[] inptr;
+    int[] quantptr;
+    int[] wsptr;
+    byte[] outptr;
+    byte[] range_limit = cinfo.sample_range_limit;
+    int range_limit_offset = cinfo.sample_range_limit_offset + CENTERJSAMPLE;
+    int ctr;
+    int[] workspace = cinfo.workspace;  /* buffers data between passes */
+//  SHIFT_TEMPS
+    
+    /* Pass 1: process columns from input, store into work array. */
+    /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
+    /* furthermore, we scale the results by 2**PASS1_BITS. */
+    
+    inptr = coef_block;
+    quantptr = compptr.dct_table;
+    wsptr = workspace;
+    int inptr_offset = 0, quantptr_offset = 0, wsptr_offset = 0;
+    for (ctr = DCTSIZE; ctr > 0; ctr--) {
+        /* Due to quantization, we will usually find that many of the input
+         * coefficients are zero, especially the AC terms.  We can exploit this
+         * by short-circuiting the IDCT calculation for any column in which all
+         * the AC terms are zero.   In that case each output is equal to the
+         * DC coefficient (with scale factor as needed).
+         * With typical images and quantization tables, half or more of the
+         * column DCT calculations can be simplified this way.
+         */
+        
+        if (inptr[DCTSIZE*1+inptr_offset] is 0 && inptr[DCTSIZE*2+inptr_offset] is 0 &&
+            inptr[DCTSIZE*3+inptr_offset] is 0 && inptr[DCTSIZE*4+inptr_offset] is 0 &&
+            inptr[DCTSIZE*5+inptr_offset] is 0 && inptr[DCTSIZE*6+inptr_offset] is 0 &&
+            inptr[DCTSIZE*7+inptr_offset] is 0)
+        {
+            /* AC terms all zero */
+            int dcval = ((inptr[DCTSIZE*0+inptr_offset]) * quantptr[DCTSIZE*0+quantptr_offset]) << PASS1_BITS;
+            
+            wsptr[DCTSIZE*0+wsptr_offset] = dcval;
+            wsptr[DCTSIZE*1+wsptr_offset] = dcval;
+            wsptr[DCTSIZE*2+wsptr_offset] = dcval;
+            wsptr[DCTSIZE*3+wsptr_offset] = dcval;
+            wsptr[DCTSIZE*4+wsptr_offset] = dcval;
+            wsptr[DCTSIZE*5+wsptr_offset] = dcval;
+            wsptr[DCTSIZE*6+wsptr_offset] = dcval;
+            wsptr[DCTSIZE*7+wsptr_offset] = dcval;
+            
+            inptr_offset++;         /* advance pointers to next column */
+            quantptr_offset++;
+            wsptr_offset++;
+            continue;
+        }
+        
+        /* Even part: reverse the even part of the forward DCT. */
+        /* The rotator is sqrt(2)*c(-6). */
+        
+        z2 = ((inptr[DCTSIZE*2+inptr_offset]) * quantptr[DCTSIZE*2+quantptr_offset]);
+        z3 = ((inptr[DCTSIZE*6+inptr_offset]) * quantptr[DCTSIZE*6+quantptr_offset]);
+        
+        z1 = ((z2 + z3) * 4433/*FIX_0_541196100*/);
+        tmp2 = z1 + (z3 * - 15137/*FIX_1_847759065*/);
+        tmp3 = z1 + (z2 * 6270/*FIX_0_765366865*/);
+        
+        z2 = ((inptr[DCTSIZE*0+inptr_offset]) * quantptr[DCTSIZE*0+quantptr_offset]);
+        z3 = ((inptr[DCTSIZE*4+inptr_offset]) * quantptr[DCTSIZE*4+quantptr_offset]);
+
+        tmp0 = (z2 + z3) << CONST_BITS;
+        tmp1 = (z2 - z3) << CONST_BITS;
+        
+        tmp10 = tmp0 + tmp3;
+        tmp13 = tmp0 - tmp3;
+        tmp11 = tmp1 + tmp2;
+        tmp12 = tmp1 - tmp2;
+        
+        /* Odd part per figure 8; the matrix is unitary and hence its
+         * transpose is its inverse.    i0..i3 are y7,y5,y3,y1 respectively.
+         */
+        
+        tmp0 = ((inptr[DCTSIZE*7+inptr_offset]) * quantptr[DCTSIZE*7+quantptr_offset]);
+        tmp1 = ((inptr[DCTSIZE*5+inptr_offset]) * quantptr[DCTSIZE*5+quantptr_offset]);
+        tmp2 = ((inptr[DCTSIZE*3+inptr_offset]) * quantptr[DCTSIZE*3+quantptr_offset]);
+        tmp3 = ((inptr[DCTSIZE*1+inptr_offset]) * quantptr[DCTSIZE*1+quantptr_offset]);
+        
+        z1 = tmp0 + tmp3;
+        z2 = tmp1 + tmp2;
+        z3 = tmp0 + tmp2;
+        z4 = tmp1 + tmp3;
+        z5 = ((z3 + z4) * 9633/*FIX_1_175875602*/); /* sqrt(2) * c3 */
+        
+        tmp0 = (tmp0 * 2446/*FIX_0_298631336*/); /* sqrt(2) * (-c1+c3+c5-c7) */
+        tmp1 = (tmp1 * 16819/*FIX_2_053119869*/); /* sqrt(2) * ( c1+c3-c5+c7) */
+        tmp2 = (tmp2 * 25172/*FIX_3_072711026*/); /* sqrt(2) * ( c1+c3+c5-c7) */
+        tmp3 = (tmp3 * 12299/*FIX_1_501321110*/); /* sqrt(2) * ( c1+c3-c5-c7) */
+        z1 = (z1 * - 7373/*FIX_0_899976223*/); /* sqrt(2) * (c7-c3) */
+        z2 = (z2 * - 20995/*FIX_2_562915447*/); /* sqrt(2) * (-c1-c3) */
+        z3 = (z3 * - 16069/*FIX_1_961570560*/); /* sqrt(2) * (-c3-c5) */
+        z4 = (z4 * - 3196/*FIX_0_390180644*/); /* sqrt(2) * (c5-c3) */
+        
+        z3 += z5;
+        z4 += z5;
+        
+        tmp0 += z1 + z3;
+        tmp1 += z2 + z4;
+        tmp2 += z2 + z3;
+        tmp3 += z1 + z4;
+        
+        /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
+        
+//      #define DESCALE(x,n)    RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
+        wsptr[DCTSIZE*0+wsptr_offset] = (((tmp10 + tmp3) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        wsptr[DCTSIZE*7+wsptr_offset] = (((tmp10 - tmp3) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        wsptr[DCTSIZE*1+wsptr_offset] = (((tmp11 + tmp2) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        wsptr[DCTSIZE*6+wsptr_offset] = (((tmp11 - tmp2) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        wsptr[DCTSIZE*2+wsptr_offset] = (((tmp12 + tmp1) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        wsptr[DCTSIZE*5+wsptr_offset] = (((tmp12 - tmp1) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        wsptr[DCTSIZE*3+wsptr_offset] = (((tmp13 + tmp0) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        wsptr[DCTSIZE*4+wsptr_offset] = (((tmp13 - tmp0) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+        
+        inptr_offset++;         /* advance pointers to next column */
+        quantptr_offset++;
+        wsptr_offset++;
+    }
+
+    
+    /* Pass 2: process rows from work array, store into output array. */
+    /* Note that we must descale the results by a factor of 8 is 2**3, */
+    /* and also undo the PASS1_BITS scaling. */
+
+    int outptr_offset = 0;
+    wsptr = workspace;
+    wsptr_offset =0;
+    for (ctr = 0; ctr < DCTSIZE; ctr++) {
+        outptr = output_buf[ctr+output_buf_offset];
+        outptr_offset = output_col;
+        /* Rows of zeroes can be exploited in the same way as we did with columns.
+         * However, the column calculation has created many nonzero AC terms, so
+         * the simplification applies less often (typically 5% to 10% of the time).
+         * On machines with very fast multiplication, it's possible that the
+         * test takes more time than it's worth.    In that case this section
+         * may be commented out.
+         */
+        
+//#ifndef NO_ZERO_ROW_TEST
+        if (wsptr[1+wsptr_offset] is 0 && wsptr[2+wsptr_offset] is 0 && wsptr[3+wsptr_offset] is 0 && wsptr[4+wsptr_offset] is 0 &&
+            wsptr[5+wsptr_offset] is 0 && wsptr[6+wsptr_offset] is 0 && wsptr[7+wsptr_offset] is 0)
+        {
+            /* AC terms all zero */
+//          #define DESCALE(x,n)    RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
+            byte dcval = range_limit[range_limit_offset + ((((wsptr[0+wsptr_offset]) + (1 << ((PASS1_BITS+3)-1))) >> PASS1_BITS+3)
+                    & RANGE_MASK)];
+            
+            outptr[0+outptr_offset] = dcval;
+            outptr[1+outptr_offset] = dcval;
+            outptr[2+outptr_offset] = dcval;
+            outptr[3+outptr_offset] = dcval;
+            outptr[4+outptr_offset] = dcval;
+            outptr[5+outptr_offset] = dcval;
+            outptr[6+outptr_offset] = dcval;
+            outptr[7+outptr_offset] = dcval;
+
+            wsptr_offset += DCTSIZE;        /* advance pointer to next row */
+            continue;
+        }
+//#endif
+        
+        /* Even part: reverse the even part of the forward DCT. */
+        /* The rotator is sqrt(2)*c(-6). */
+        
+        z2 = wsptr[2+wsptr_offset];
+        z3 = wsptr[6+wsptr_offset];
+        
+        z1 = ((z2 + z3) * 4433/*FIX_0_541196100*/);
+        tmp2 = z1 + (z3 * - 15137/*FIX_1_847759065*/);
+        tmp3 = z1 + (z2 * 6270/*FIX_0_765366865*/);
+        
+        tmp0 = (wsptr[0+wsptr_offset] + wsptr[4+wsptr_offset]) << CONST_BITS;
+        tmp1 = (wsptr[0+wsptr_offset] - wsptr[4+wsptr_offset]) << CONST_BITS;
+        
+        tmp10 = tmp0 + tmp3;
+        tmp13 = tmp0 - tmp3;
+        tmp11 = tmp1 + tmp2;
+        tmp12 = tmp1 - tmp2;
+        
+        /* Odd part per figure 8; the matrix is unitary and hence its
+         * transpose is its inverse.    i0..i3 are y7,y5,y3,y1 respectively.
+         */
+        
+        tmp0 = wsptr[7+wsptr_offset];
+        tmp1 = wsptr[5+wsptr_offset];
+        tmp2 = wsptr[3+wsptr_offset];
+        tmp3 = wsptr[1+wsptr_offset];
+        
+        z1 = tmp0 + tmp3;
+        z2 = tmp1 + tmp2;
+        z3 = tmp0 + tmp2;
+        z4 = tmp1 + tmp3;
+        z5 = ((z3 + z4) * 9633/*FIX_1_175875602*/); /* sqrt(2) * c3 */
+        
+        tmp0 = (tmp0 * 2446/*FIX_0_298631336*/); /* sqrt(2) * (-c1+c3+c5-c7) */
+        tmp1 = (tmp1 * 16819/*FIX_2_053119869*/); /* sqrt(2) * ( c1+c3-c5+c7) */
+        tmp2 = (tmp2 * 25172/*FIX_3_072711026*/); /* sqrt(2) * ( c1+c3+c5-c7) */
+        tmp3 = (tmp3 * 12299/*FIX_1_501321110*/); /* sqrt(2) * ( c1+c3-c5-c7) */
+        z1 = (z1 * - 7373/*FIX_0_899976223*/); /* sqrt(2) * (c7-c3) */
+        z2 = (z2 * - 20995/*FIX_2_562915447*/); /* sqrt(2) * (-c1-c3) */
+        z3 = (z3 * - 16069/*FIX_1_961570560*/); /* sqrt(2) * (-c3-c5) */
+        z4 = (z4 * - 3196/*FIX_0_390180644*/); /* sqrt(2) * (c5-c3) */
+        
+        z3 += z5;
+        z4 += z5;
+        
+        tmp0 += z1 + z3;
+        tmp1 += z2 + z4;
+        tmp2 += z2 + z3;
+        tmp3 += z1 + z4;
+        
+        /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
+        
+
+//      #define DESCALE(x,n)    RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
+        outptr[0+outptr_offset] = range_limit[range_limit_offset + ((((tmp10 + tmp3) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                        CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+        outptr[7+outptr_offset] = range_limit[range_limit_offset + ((((tmp10 - tmp3) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                                    CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+        outptr[1+outptr_offset] = range_limit[range_limit_offset + ((((tmp11 + tmp2) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                                    CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+        outptr[6+outptr_offset] = range_limit[range_limit_offset + ((((tmp11 - tmp2) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                                    CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+        outptr[2+outptr_offset] = range_limit[range_limit_offset + ((((tmp12 + tmp1) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                                    CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+        outptr[5+outptr_offset] = range_limit[range_limit_offset + ((((tmp12 - tmp1) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                                    CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+        outptr[3+outptr_offset] = range_limit[range_limit_offset + ((((tmp13 + tmp0) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                                    CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+        outptr[4+outptr_offset] = range_limit[range_limit_offset + ((((tmp13 - tmp0) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+                                    CONST_BITS+PASS1_BITS+3)
+                    & RANGE_MASK)];
+
+        wsptr_offset += DCTSIZE;        /* advance pointer to next row */
+    }
+}
+
+static void upsample (jpeg_decompress_struct cinfo,
+    byte[][][] input_buf, int[] input_buf_offset, int[] in_row_group_ctr,
+    int in_row_groups_avail,
+    byte[][] output_buf, int[] out_row_ctr,
+    int out_rows_avail)
+{
+    sep_upsample(cinfo, input_buf, input_buf_offset, in_row_group_ctr, in_row_groups_avail, output_buf, out_row_ctr, out_rows_avail);
+}
+
+static bool smoothing_ok (jpeg_decompress_struct cinfo) {
+    jpeg_d_coef_controller coef = cinfo.coef;
+    bool smoothing_useful = false;
+    int ci, coefi;
+    jpeg_component_info compptr;
+    JQUANT_TBL qtable;
+    int[] coef_bits;
+    int[] coef_bits_latch;
+
+    if (! cinfo.progressive_mode || cinfo.coef_bits is null)
+        return false;
+
+    /* Allocate latch area if not already done */
+    if (coef.coef_bits_latch is null)
+        coef.coef_bits_latch = new int[cinfo.num_components * SAVED_COEFS];
+    coef_bits_latch = coef.coef_bits_latch;
+    int coef_bits_latch_offset = 0;
+
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        /* All components' quantization values must already be latched. */
+        if ((qtable = compptr.quant_table) is null)
+            return false;
+        /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */
+        if (qtable.quantval[0] is 0 ||
+            qtable.quantval[Q01_POS] is 0 ||
+            qtable.quantval[Q10_POS] is 0 ||
+            qtable.quantval[Q20_POS] is 0 ||
+            qtable.quantval[Q11_POS] is 0 ||
+            qtable.quantval[Q02_POS] is 0)
+                return false;
+        /* DC values must be at least partly known for all components. */
+        coef_bits = cinfo.coef_bits[ci];
+        if (coef_bits[0] < 0)
+            return false;
+        /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
+        for (coefi = 1; coefi <= 5; coefi++) {
+            coef_bits_latch[coefi+coef_bits_latch_offset] = coef_bits[coefi];
+            if (coef_bits[coefi] !is 0)
+                smoothing_useful = true;
+        }
+        coef_bits_latch_offset += SAVED_COEFS;
+    }
+
+    return smoothing_useful;
+}
+
+static void master_selection (jpeg_decompress_struct cinfo) {
+    jpeg_decomp_master master = cinfo.master;
+    bool use_c_buffer;
+    long samplesperrow;
+    int jd_samplesperrow;
+
+    /* Initialize dimensions and other stuff */
+    jpeg_calc_output_dimensions(cinfo);
+    prepare_range_limit_table(cinfo);
+
+    /* Width of an output scanline must be representable as JDIMENSION. */
+    samplesperrow = (long) cinfo.output_width * (long) cinfo.out_color_components;
+    jd_samplesperrow = (int) samplesperrow;
+    if ( jd_samplesperrow !is samplesperrow)
+        error();
+//      ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
+
+    /* Initialize my private state */
+    master.pass_number = 0;
+    master.using_merged_upsample = use_merged_upsample(cinfo);
+
+    /* Color quantizer selection */
+    master.quantizer_1pass = null;
+    master.quantizer_2pass = null;
+    /* No mode changes if not using buffered-image mode. */
+    if (! cinfo.quantize_colors || ! cinfo.buffered_image) {
+        cinfo.enable_1pass_quant = false;
+        cinfo.enable_external_quant = false;
+        cinfo.enable_2pass_quant = false;
+    }
+    if (cinfo.quantize_colors) {
+        error(DWT.ERROR_NOT_IMPLEMENTED);
+//      if (cinfo.raw_data_out)
+//          ERREXIT(cinfo, JERR_NOTIMPL);
+//      /* 2-pass quantizer only works in 3-component color space. */
+//      if (cinfo.out_color_components !is 3) {
+//          cinfo.enable_1pass_quant = true;
+//          cinfo.enable_external_quant = false;
+//          cinfo.enable_2pass_quant = false;
+//          cinfo.colormap = null;
+//      } else if (cinfo.colormap !is null) {
+//          cinfo.enable_external_quant = true;
+//      } else if (cinfo.two_pass_quantize) {
+//          cinfo.enable_2pass_quant = true;
+//      } else {
+//          cinfo.enable_1pass_quant = true;
+//      }
+//
+//      if (cinfo.enable_1pass_quant) {
+//#ifdef QUANT_1PASS_SUPPORTED
+//          jinit_1pass_quantizer(cinfo);
+//          master.quantizer_1pass = cinfo.cquantize;
+//#else
+//          ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+//      }
+//
+//      /* We use the 2-pass code to map to external colormaps. */
+//      if (cinfo.enable_2pass_quant || cinfo.enable_external_quant) {
+//#ifdef QUANT_2PASS_SUPPORTED
+//          jinit_2pass_quantizer(cinfo);
+//          master.quantizer_2pass = cinfo.cquantize;
+//#else
+//          ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+//      }
+//      /* If both quantizers are initialized, the 2-pass one is left active;
+//       * this is necessary for starting with quantization to an external map.
+//       */
+    }
+
+    /* Post-processing: in particular, color conversion first */
+    if (! cinfo.raw_data_out) {
+        if (master.using_merged_upsample) {
+//#ifdef UPSAMPLE_MERGING_SUPPORTED
+//          jinit_merged_upsampler(cinfo); /* does color conversion too */
+//#else
+            error();
+//          ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+        } else {
+            jinit_color_deconverter(cinfo);
+            jinit_upsampler(cinfo);
+        }
+        jinit_d_post_controller(cinfo, cinfo.enable_2pass_quant);
+    }
+    /* Inverse DCT */
+    jinit_inverse_dct(cinfo);
+    /* Entropy decoding: either Huffman or arithmetic coding. */
+    if (cinfo.arith_code) {
+        error();
+//      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
+    } else {
+        if (cinfo.progressive_mode) {
+//#ifdef D_PROGRESSIVE_SUPPORTED
+            jinit_phuff_decoder(cinfo);
+//#else
+//          ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+        } else
+            jinit_huff_decoder(cinfo);
+    }
+
+    /* Initialize principal buffer controllers. */
+    use_c_buffer = cinfo.inputctl.has_multiple_scans || cinfo.buffered_image;
+    jinit_d_coef_controller(cinfo, use_c_buffer);
+
+    if (! cinfo.raw_data_out)
+        jinit_d_main_controller(cinfo, false /* never need full buffer here */);
+
+    /* Initialize input side of decompressor to consume first scan. */
+    start_input_pass (cinfo);
+
+//#ifdef D_MULTISCAN_FILES_SUPPORTED
+    /* If jpeg_start_decompress will read the whole file, initialize
+     * progress monitoring appropriately.   The input step is counted
+     * as one pass.
+     */
+//  if (cinfo.progress !is null && ! cinfo.buffered_image &&
+//          cinfo.inputctl.has_multiple_scans) {
+//      int nscans;
+//      /* Estimate number of scans to set pass_limit. */
+//      if (cinfo.progressive_mode) {
+//          /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
+//          nscans = 2 + 3 * cinfo.num_components;
+//      } else {
+//          /* For a nonprogressive multiscan file, estimate 1 scan per component. */
+//          nscans = cinfo.num_components;
+//      }
+//      cinfo.progress.pass_counter = 0L;
+//      cinfo.progress.pass_limit = (long) cinfo.total_iMCU_rows * nscans;
+//      cinfo.progress.completed_passes = 0;
+//      cinfo.progress.total_passes = (cinfo.enable_2pass_quant ? 3 : 2);
+//      /* Count the input pass as done */
+//      master.pass_number++;
+//  }
+//#endif /* D_MULTISCAN_FILES_SUPPORTED */
+}
+
+static void jinit_master_decompress (jpeg_decompress_struct cinfo) {
+    jpeg_decomp_master master = new jpeg_decomp_master();
+    cinfo.master = master;
+//  master.prepare_for_output_pass = prepare_for_output_pass;
+//  master.finish_output_pass = finish_output_pass;
+
+    master.is_dummy_pass = false;
+
+    master_selection(cinfo);
+}
+
+static void
+jcopy_sample_rows (byte[][] input_array, int source_row,
+           byte[][] output_array, int dest_row,
+           int num_rows, int num_cols)
+/* Copy some rows of samples from one place to another.
+ * num_rows rows are copied from input_array[source_row++]
+ * to output_array[dest_row++]; these areas may overlap for duplication.
+ * The source and destination arrays must be at least as wide as num_cols.
+ */
+{
+  byte[] inptr, outptr;
+  int count = num_cols;
+  int row;
+
+  int input_array_offset = source_row;
+  int output_array_offset = dest_row;
+
+  for (row = num_rows; row > 0; row--) {
+    inptr = input_array[input_array_offset++];
+    outptr = output_array[output_array_offset++];
+    System.arraycopy(inptr, 0, outptr, 0, count);
+  }
+}
+
+static bool jpeg_start_decompress (jpeg_decompress_struct cinfo) {
+    if (cinfo.global_state is DSTATE_READY) {
+        /* First call: initialize master control, select active modules */
+        jinit_master_decompress(cinfo);
+        if (cinfo.buffered_image) {
+            /* No more work here; expecting jpeg_start_output next */
+            cinfo.global_state = DSTATE_BUFIMAGE;
+            return true;
+        }
+        cinfo.global_state = DSTATE_PRELOAD;
+    }
+    if (cinfo.global_state is DSTATE_PRELOAD) {
+        /* If file has multiple scans, absorb them all into the coef buffer */
+        if (cinfo.inputctl.has_multiple_scans) {
+//#ifdef D_MULTISCAN_FILES_SUPPORTED
+            for (;;) {
+                int retcode;
+                /* Call progress monitor hook if present */
+//              if (cinfo.progress !is null)
+//                  (*cinfo.progress.progress_monitor) ((j_common_ptr) cinfo);
+                /* Absorb some more input */
+                retcode = consume_input (cinfo);
+                if (retcode is JPEG_SUSPENDED)
+                    return false;
+                if (retcode is JPEG_REACHED_EOI)
+                    break;
+                /* Advance progress counter if appropriate */
+//              if (cinfo.progress !is null && (retcode is JPEG_ROW_COMPLETED || retcode is JPEG_REACHED_SOS)) {
+//                  if (++cinfo.progress.pass_counter >= cinfo.progress.pass_limit) {
+//                      /* jdmaster underestimated number of scans; ratchet up one scan */
+//                      cinfo.progress.pass_limit += (long) cinfo.total_iMCU_rows;
+//                  }
+//              }
+            }
+//#else
+//          ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif /* D_MULTISCAN_FILES_SUPPORTED */
+        }
+        cinfo.output_scan_number = cinfo.input_scan_number;
+    } else if (cinfo.global_state !is DSTATE_PRESCAN)
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+    /* Perform any dummy output passes, and set up for the final pass */
+    return output_pass_setup(cinfo);
+}
+
+static void prepare_for_output_pass (jpeg_decompress_struct cinfo) {
+    jpeg_decomp_master master = cinfo.master;
+
+    if (master.is_dummy_pass) {
+//#ifdef QUANT_2PASS_SUPPORTED
+//      /* Final pass of 2-pass quantization */
+//      master.pub.is_dummy_pass = FALSE;
+//      (*cinfo.cquantize.start_pass) (cinfo, FALSE);
+//      (*cinfo.post.start_pass) (cinfo, JBUF_CRANK_DEST);
+//      (*cinfo.main.start_pass) (cinfo, JBUF_CRANK_DEST);
+//#else
+        error(DWT.ERROR_NOT_IMPLEMENTED);
+//      ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif /* QUANT_2PASS_SUPPORTED */
+    } else {
+        if (cinfo.quantize_colors && cinfo.colormap is null) {
+            /* Select new quantization method */
+            if (cinfo.two_pass_quantize && cinfo.enable_2pass_quant) {
+                cinfo.cquantize = master.quantizer_2pass;
+                master.is_dummy_pass = true;
+            } else if (cinfo.enable_1pass_quant) {
+                cinfo.cquantize = master.quantizer_1pass;
+            } else {
+                error();
+//  ERREXIT(cinfo, JERR_MODE_CHANGE);
+            }
+        }
+        cinfo.idct.start_pass (cinfo);
+        start_output_pass (cinfo);
+        if (! cinfo.raw_data_out) {
+            if (! master.using_merged_upsample)
+                cinfo.cconvert.start_pass (cinfo);
+            cinfo.upsample.start_pass (cinfo);
+            if (cinfo.quantize_colors) 
+                cinfo.cquantize.start_pass (cinfo, master.is_dummy_pass);
+            cinfo.post.start_pass (cinfo, (master.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
+            cinfo.main.start_pass (cinfo, JBUF_PASS_THRU);
+        }
+    }
+
+//  /* Set up progress monitor's pass info if present */
+//  if (cinfo.progress !is NULL) {
+//      cinfo.progress.completed_passes = master.pass_number;
+//      cinfo.progress.total_passes = master.pass_number +
+//                      (master.pub.is_dummy_pass ? 2 : 1);
+//      /* In buffered-image mode, we assume one more output pass if EOI not
+//       * yet reached, but no more passes if EOI has been reached.
+//       */
+//      if (cinfo.buffered_image && ! cinfo.inputctl.eoi_reached) {
+//          cinfo.progress.total_passes += (cinfo.enable_2pass_quant ? 2 : 1);
+//      }
+//  }
+}
+
+
+static bool jpeg_resync_to_restart (jpeg_decompress_struct cinfo, int desired) {
+    int marker = cinfo.unread_marker;
+    int action = 1;
+    
+    /* Always put up a warning. */
+//  WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
+    
+    /* Outer loop handles repeated decision after scanning forward. */
+    for (;;) {
+        if (marker < M_SOF0)
+            action = 2;     /* invalid marker */
+        else if (marker < M_RST0 || marker > M_RST7)
+            action = 3;     /* valid non-restart marker */
+        else {
+            if (marker is (M_RST0 + ((desired+1) & 7)) || marker is ( M_RST0 + ((desired+2) & 7)))
+                action = 3;     /* one of the next two expected restarts */
+            else if (marker is (M_RST0 + ((desired-1) & 7)) || marker is ( M_RST0 + ((desired-2) & 7)))
+                action = 2;     /* a prior restart, so advance */
+            else
+                action = 1;     /* desired restart or too far away */
+        }
+//      TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
+        switch (action) {
+            case 1:
+                /* Discard marker and let entropy decoder resume processing. */
+                cinfo.unread_marker = 0;
+                return true;
+            case 2:
+                /* Scan to the next marker, and repeat the decision loop. */
+                if (! next_marker(cinfo))
+                    return false;
+                marker = cinfo.unread_marker;
+                break;
+            case 3:
+                /* Return without advancing past this marker. */
+                /* Entropy decoder will be forced to process an empty segment. */
+                return true;
+        }
+    } /* end loop */
+}
+
+static bool read_restart_marker (jpeg_decompress_struct cinfo) {
+    /* Obtain a marker unless we already did. */
+    /* Note that next_marker will complain if it skips any data. */
+    if (cinfo.unread_marker is 0) {
+        if (! next_marker(cinfo))
+            return false;
+    }
+
+    if (cinfo.unread_marker is (M_RST0 + cinfo.marker.next_restart_num)) {
+        /* Normal case --- swallow the marker and let entropy decoder continue */
+//      TRACEMS1(cinfo, 3, JTRC_RST, cinfo.marker.next_restart_num);
+        cinfo.unread_marker = 0;
+    } else {
+        /* Uh-oh, the restart markers have been messed up. */
+        /* Let the data source manager determine how to resync. */
+        if (! jpeg_resync_to_restart (cinfo, cinfo.marker.next_restart_num))
+            return false;
+    }
+
+    /* Update next-restart state */
+    cinfo.marker.next_restart_num = (cinfo.marker.next_restart_num + 1) & 7;
+
+    return true;
+}
+
+static bool jpeg_fill_bit_buffer (bitread_working_state state, int get_buffer, int bits_left, int nbits)
+/* Load up the bit buffer to a depth of at least nbits */
+{
+    /* Copy heavily used state fields into locals (hopefully registers) */
+    byte[] buffer = state.buffer;
+    int bytes_in_buffer = state.bytes_in_buffer;
+    int bytes_offset = state.bytes_offset;
+    jpeg_decompress_struct cinfo = state.cinfo;
+
+    /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */
+    /* (It is assumed that no request will be for more than that many bits.) */
+    /* We fail to do so only if we hit a marker or are forced to suspend. */
+
+    if (cinfo.unread_marker is 0) { /* cannot advance past a marker */
+        while (bits_left < MIN_GET_BITS) {
+            int c;
+
+            /* Attempt to read a byte */
+            if (bytes_offset is bytes_in_buffer) {
+                if (! fill_input_buffer (cinfo))
+                    return false;
+                buffer = cinfo.buffer;
+                bytes_in_buffer = cinfo.bytes_in_buffer;
+                bytes_offset = cinfo.bytes_offset;
+            }
+            c = buffer[bytes_offset++] & 0xFF;
+
+            /* If it's 0xFF, check and discard stuffed zero byte */
+            if (c is 0xFF) {
+                /* Loop here to discard any padding FF's on terminating marker,
+                 * so that we can save a valid unread_marker value. NOTE: we will
+                 * accept multiple FF's followed by a 0 as meaning a single FF data
+                 * byte.    This data pattern is not valid according to the standard.
+                 */
+                do {
+                    if (bytes_offset is bytes_in_buffer) {
+                        if (! fill_input_buffer (cinfo))
+                            return false;
+                        buffer = cinfo.buffer;
+                        bytes_in_buffer = cinfo.bytes_in_buffer;
+                        bytes_offset = cinfo.bytes_offset;
+                    }
+                    c = buffer[bytes_offset++] & 0xFF;
+                } while (c is 0xFF);
+
+                if (c is 0) {
+                    /* Found FF/00, which represents an FF data byte */
+                    c = 0xFF;
+                } else {
+                    /* Oops, it's actually a marker indicating end of compressed data.
+                     * Save the marker code for later use.
+                     * Fine point: it might appear that we should save the marker into
+                     * bitread working state, not straight into permanent state.    But
+                     * once we have hit a marker, we cannot need to suspend within the
+                     * current MCU, because we will read no more bytes from the data
+                     * source.  So it is OK to update permanent state right away.
+                     */
+                    cinfo.unread_marker = c;
+                    /* See if we need to insert some fake zero bits. */
+//                  goto no_more_bytes;
+                    if (nbits > bits_left) {
+                        /* Uh-oh.   Report corrupted data to user and stuff zeroes into
+                         * the data stream, so that we can produce some kind of image.
+                         * We use a nonvolatile flag to ensure that only one warning message
+                         * appears per data segment.
+                         */
+                        if (! cinfo.entropy.insufficient_data) {
+//                          WARNMS(cinfo, JWRN_HIT_MARKER);
+                            cinfo.entropy.insufficient_data = true;
+                        }
+                    /* Fill the buffer with zero bits */
+                        get_buffer <<= MIN_GET_BITS - bits_left;
+                        bits_left = MIN_GET_BITS;
+                    }
+
+                    /* Unload the local registers */
+                    state.buffer = buffer;
+                    state.bytes_in_buffer = bytes_in_buffer;
+                    state.bytes_offset = bytes_offset;
+                    state.get_buffer = get_buffer;
+                    state.bits_left = bits_left;
+
+                    return true;
+        
+                }
+            }
+
+            /* OK, load c into get_buffer */
+            get_buffer = (get_buffer << 8) | c;
+            bits_left += 8;
+        } /* end while */
+    } else {
+//      no_more_bytes:
+        /* We get here if we've read the marker that terminates the compressed
+         * data segment.    There should be enough bits in the buffer register
+         * to satisfy the request; if so, no problem.
+         */
+        if (nbits > bits_left) {
+            /* Uh-oh.   Report corrupted data to user and stuff zeroes into
+             * the data stream, so that we can produce some kind of image.
+             * We use a nonvolatile flag to ensure that only one warning message
+             * appears per data segment.
+             */
+            if (! cinfo.entropy.insufficient_data) {
+//              WARNMS(cinfo, JWRN_HIT_MARKER);
+                cinfo.entropy.insufficient_data = true;
+            }
+            /* Fill the buffer with zero bits */
+            get_buffer <<= MIN_GET_BITS - bits_left;
+            bits_left = MIN_GET_BITS;
+        }
+    }
+
+    /* Unload the local registers */
+    state.buffer = buffer;
+    state.bytes_in_buffer = bytes_in_buffer;
+    state.bytes_offset = bytes_offset;
+    state.get_buffer = get_buffer;
+    state.bits_left = bits_left;
+
+    return true;
+}
+
+static int jpeg_huff_decode (bitread_working_state state, int get_buffer, int bits_left, d_derived_tbl htbl, int min_bits) {
+    int l = min_bits;
+    int code;
+
+    /* HUFF_DECODE has determined that the code is at least min_bits */
+    /* bits long, so fetch that many bits in one swoop. */
+
+//  CHECK_BIT_BUFFER(*state, l, return -1);
+    {
+    if (bits_left < (l)) {
+        if (! jpeg_fill_bit_buffer(state,get_buffer,bits_left,l)) { 
+            return -1;
+        }
+        get_buffer = (state).get_buffer; bits_left = (state).bits_left;
+    }
+    }
+//  code = GET_BITS(l);
+    code = (( (get_buffer >> (bits_left -= (l)))) & ((1<<(l))-1));
+
+    /* Collect the rest of the Huffman code one bit at a time. */
+    /* This is per Figure F.16 in the JPEG spec. */
+
+    while (code > htbl.maxcode[l]) {
+        code <<= 1;
+//      CHECK_BIT_BUFFER(*state, 1, return -1);
+        {
+        if (bits_left < (1)) {
+            if (! jpeg_fill_bit_buffer(state,get_buffer,bits_left,1)) { 
+                return -1;
+            }
+            get_buffer = (state).get_buffer; bits_left = (state).bits_left;
+        }
+        }
+//      code |= GET_BITS(1);
+        code |= (( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1));
+        l++;
+    }
+
+    /* Unload the local registers */
+    state.get_buffer = get_buffer;
+    state.bits_left = bits_left;
+
+    /* With garbage input we may reach the sentinel value l = 17. */
+
+    if (l > 16) {
+//      WARNMS(state.cinfo, JWRN_HUFF_BAD_CODE);
+        return 0;           /* fake a zero as the safest result */
+    }
+
+    return htbl.pub.huffval[ (code + htbl.valoffset[l]) ] & 0xFF;
+}
+
+static int decompress_onepass (jpeg_decompress_struct cinfo, byte[][][] output_buf, int[] output_buf_offset) {
+    jpeg_d_coef_controller coef = cinfo.coef;
+    int MCU_col_num;    /* index of current MCU within row */
+    int last_MCU_col = cinfo.MCUs_per_row - 1;
+    int last_iMCU_row = cinfo.total_iMCU_rows - 1;
+    int blkn, ci, xindex, yindex, yoffset, useful_width;
+    byte[][] output_ptr;
+    int start_col, output_col;
+    jpeg_component_info compptr;
+//  inverse_DCT_method_ptr inverse_DCT;
+
+    /* Loop to process as much as one whole iMCU row */
+    for (yoffset = coef.MCU_vert_offset; yoffset < coef.MCU_rows_per_iMCU_row; yoffset++) {
+        for (MCU_col_num = coef.MCU_ctr; MCU_col_num <= last_MCU_col; MCU_col_num++) {
+            /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
+            for (int i = 0; i < cinfo.blocks_in_MCU; i++) {
+                short[] blk = coef.MCU_buffer[i];
+                for (int j = 0; j < blk.length; j++) {
+                    blk[j] = 0;
+                }
+            }
+            if (! cinfo.entropy.decode_mcu (cinfo, coef.MCU_buffer)) {
+                /* Suspension forced; update state counters and exit */
+                coef.MCU_vert_offset = yoffset;
+                coef.MCU_ctr = MCU_col_num;
+                return JPEG_SUSPENDED;
+            }
+            /* Determine where data should go in output_buf and do the IDCT thing.
+             * We skip dummy blocks at the right and bottom edges (but blkn gets
+             * incremented past them!). Note the inner loop relies on having
+             * allocated the MCU_buffer[] blocks sequentially.
+             */
+            blkn = 0;           /* index of current DCT block within MCU */
+            for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+                compptr = cinfo.cur_comp_info[ci];
+                /* Don't bother to IDCT an uninteresting component. */
+                if (! compptr.component_needed) {
+                    blkn += compptr.MCU_blocks;
+                    continue;
+                }
+//              inverse_DCT = cinfo.idct.inverse_DCT[compptr.component_index];
+                useful_width = (MCU_col_num < last_MCU_col) ? compptr.MCU_width : compptr.last_col_width;
+                output_ptr = output_buf[compptr.component_index];
+                int output_ptr_offset = output_buf_offset[compptr.component_index] + yoffset * compptr.DCT_scaled_size;
+                start_col = MCU_col_num * compptr.MCU_sample_width;
+                for (yindex = 0; yindex < compptr.MCU_height; yindex++) {
+                    if (cinfo.input_iMCU_row < last_iMCU_row || yoffset+yindex < compptr.last_row_height) {
+                        output_col = start_col;
+                        for (xindex = 0; xindex < useful_width; xindex++) {
+                            jpeg_idct_islow(cinfo, compptr, coef.MCU_buffer[blkn+xindex], output_ptr, output_ptr_offset, output_col);
+                            output_col += compptr.DCT_scaled_size;
+                        }
+                    }
+                    blkn += compptr.MCU_width;
+                    output_ptr_offset += compptr.DCT_scaled_size;
+                }
+            }
+        }
+        /* Completed an MCU row, but perhaps not an iMCU row */
+        coef.MCU_ctr = 0;
+    }
+    /* Completed the iMCU row, advance counters for next one */
+    cinfo.output_iMCU_row++;
+    if (++(cinfo.input_iMCU_row) < cinfo.total_iMCU_rows) {
+        coef.start_iMCU_row(cinfo);
+        return JPEG_ROW_COMPLETED;
+    }
+    /* Completed the scan */
+    finish_input_pass (cinfo);
+    return JPEG_SCAN_COMPLETED;
+}
+
+static int decompress_smooth_data (jpeg_decompress_struct cinfo, byte[][][] output_buf, int[] output_buf_offset) {
+    jpeg_d_coef_controller coef = cinfo.coef;
+    int last_iMCU_row = cinfo.total_iMCU_rows - 1;
+    int block_num, last_block_column;
+    int ci, block_row, block_rows, access_rows;
+    short[][][] buffer;
+    short[][] buffer_ptr, prev_block_row, next_block_row;
+    byte[][] output_ptr;
+    int output_col;
+    jpeg_component_info compptr;
+//  inverse_DCT_method_ptr inverse_DCT;
+    bool first_row, last_row;
+    short[] workspace = coef.workspace;
+    if (workspace is null) workspace = coef.workspace = new short[DCTSIZE2];
+    int[] coef_bits;
+    JQUANT_TBL quanttbl;
+    int Q00,Q01,Q02,Q10,Q11,Q20, num;
+    int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
+    int Al, pred;
+
+    /* Force some input to be done if we are getting ahead of the input. */
+    while (cinfo.input_scan_number <= cinfo.output_scan_number && ! cinfo.inputctl.eoi_reached) {
+        if (cinfo.input_scan_number is cinfo.output_scan_number) {
+            /* If input is working on current scan, we ordinarily want it to
+             * have completed the current row.  But if input scan is DC,
+             * we want it to keep one row ahead so that next block row's DC
+             * values are up to date.
+             */
+            int delta = (cinfo.Ss is 0) ? 1 : 0;
+            if (cinfo.input_iMCU_row > cinfo.output_iMCU_row+delta)
+                break;
+        }
+        if (consume_input(cinfo) is JPEG_SUSPENDED)
+            return JPEG_SUSPENDED;
+    }
+
+    /* OK, output from the virtual arrays. */
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        /* Don't bother to IDCT an uninteresting component. */
+        if (! compptr.component_needed)
+            continue;
+        /* Count non-dummy DCT block rows in this iMCU row. */
+        if (cinfo.output_iMCU_row < last_iMCU_row) {
+            block_rows = compptr.v_samp_factor;
+            access_rows = block_rows * 2; /* this and next iMCU row */
+            last_row = false;
+        } else {
+            /* NB: can't use last_row_height here; it is input-side-dependent! */
+            block_rows = (compptr.height_in_blocks % compptr.v_samp_factor);
+            if (block_rows is 0) block_rows = compptr.v_samp_factor;
+            access_rows = block_rows; /* this iMCU row only */
+            last_row = true;
+        }
+        /* Align the virtual buffer for this component. */
+        int buffer_offset;
+        if (cinfo.output_iMCU_row > 0) {
+            access_rows += compptr.v_samp_factor; /* prior iMCU row too */
+            buffer = coef.whole_image[ci];
+            buffer_offset = (cinfo.output_iMCU_row - 1) * compptr.v_samp_factor;
+            buffer_offset += compptr.v_samp_factor; /* point to current iMCU row */
+            first_row = false;
+        } else {
+            buffer = coef.whole_image[ci];
+            buffer_offset = 0;
+            first_row = true;
+        }
+        /* Fetch component-dependent info */
+        coef_bits = coef.coef_bits_latch;
+        int coef_offset = (ci * SAVED_COEFS);
+        quanttbl = compptr.quant_table;
+        Q00 = quanttbl.quantval[0];
+        Q01 = quanttbl.quantval[Q01_POS];
+        Q10 = quanttbl.quantval[Q10_POS];
+        Q20 = quanttbl.quantval[Q20_POS];
+        Q11 = quanttbl.quantval[Q11_POS];
+        Q02 = quanttbl.quantval[Q02_POS];
+//      inverse_DCT = cinfo.idct.inverse_DCT[ci];
+        output_ptr = output_buf[ci];
+        int output_ptr_offset = output_buf_offset[ci];
+        /* Loop over all DCT blocks to be processed. */
+        for (block_row = 0; block_row < block_rows; block_row++) {
+            buffer_ptr = buffer[block_row+buffer_offset];
+            int buffer_ptr_offset = 0, prev_block_row_offset = 0, next_block_row_offset = 0;
+            if (first_row && block_row is 0) {
+                prev_block_row = buffer_ptr;
+                prev_block_row_offset = buffer_ptr_offset;
+            } else {
+                prev_block_row = buffer[block_row-1+buffer_offset];
+                prev_block_row_offset = 0;
+            }
+            if (last_row && block_row is block_rows-1) {
+                next_block_row = buffer_ptr;
+                next_block_row_offset = buffer_ptr_offset;
+            } else {
+                next_block_row = buffer[block_row+1+buffer_offset];
+                next_block_row_offset = 0;
+            }
+            /* We fetch the surrounding DC values using a sliding-register approach.
+             * Initialize all nine here so as to do the right thing on narrow pics.
+             */
+            DC1 = DC2 = DC3 = prev_block_row[0+prev_block_row_offset][0];
+            DC4 = DC5 = DC6 = buffer_ptr[0+buffer_ptr_offset][0];
+            DC7 = DC8 = DC9 = next_block_row[0+next_block_row_offset][0];
+            output_col = 0;
+            last_block_column = compptr.width_in_blocks - 1;
+            for (block_num = 0; block_num <= last_block_column; block_num++) {
+                /* Fetch current DCT block into workspace so we can modify it. */
+//              jcopy_block_row(buffer_ptr, workspace, 1);
+                System.arraycopy(buffer_ptr[buffer_ptr_offset], 0, workspace, 0, workspace.length);
+                /* Update DC values */
+                if (block_num < last_block_column) {
+                    DC3 = prev_block_row[1+prev_block_row_offset][0];
+                    DC6 = buffer_ptr[1+buffer_ptr_offset][0];
+                    DC9 = next_block_row[1+next_block_row_offset][0];
+                }
+                /* Compute coefficient estimates per K.8.
+                 * An estimate is applied only if coefficient is still zero,
+                 * and is not known to be fully accurate.
+                 */
+                /* AC01 */
+                if ((Al=coef_bits[1+coef_offset]) !is 0 && workspace[1] is 0) {
+                    num = 36 * Q00 * (DC4 - DC6);
+                    if (num >= 0) {
+                        pred = (((Q01<<7) + num) / (Q01<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                    } else {
+                        pred = (((Q01<<7) - num) / (Q01<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                        pred = -pred;
+                    }
+                    workspace[1] = (short) pred;
+                }
+                /* AC10 */
+                if ((Al=coef_bits[2+coef_offset]) !is 0 && workspace[8] is 0) {
+                    num = 36 * Q00 * (DC2 - DC8);
+                    if (num >= 0) {
+                        pred = (((Q10<<7) + num) / (Q10<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                    } else {
+                        pred = (((Q10<<7) - num) / (Q10<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                        pred = -pred;
+                    }
+                    workspace[8] = (short) pred;
+                }
+                /* AC20 */
+                if ((Al=coef_bits[3+coef_offset]) !is 0 && workspace[16] is 0) {
+                    num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
+                    if (num >= 0) {
+                        pred = (((Q20<<7) + num) / (Q20<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                    } else {
+                        pred = (((Q20<<7) - num) / (Q20<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                        pred = -pred;
+                    }
+                    workspace[16] = (short) pred;
+                }
+                /* AC11 */
+                if ((Al=coef_bits[4+coef_offset]) !is 0 && workspace[9] is 0) {
+                    num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
+                    if (num >= 0) {
+                        pred = (((Q11<<7) + num) / (Q11<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                    } else {
+                        pred = (((Q11<<7) - num) / (Q11<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                        pred = -pred;
+                    }
+                    workspace[9] = (short) pred;
+                }
+                /* AC02 */
+                if ((Al=coef_bits[5+coef_offset]) !is 0 && workspace[2] is 0) {
+                    num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
+                    if (num >= 0) {
+                        pred = (((Q02<<7) + num) / (Q02<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                    } else {
+                        pred = (((Q02<<7) - num) / (Q02<<8));
+                        if (Al > 0 && pred >= (1<<Al))
+                            pred = (1<<Al)-1;
+                        pred = -pred;
+                    }
+                    workspace[2] = (short) pred;
+                }
+                /* OK, do the IDCT */
+                jpeg_idct_islow(cinfo, compptr, workspace, output_ptr, output_ptr_offset, output_col);
+                /* Advance for next column */
+                DC1 = DC2; DC2 = DC3;
+                DC4 = DC5; DC5 = DC6;
+                DC7 = DC8; DC8 = DC9;
+                buffer_ptr_offset++; prev_block_row_offset++; next_block_row_offset++;
+                output_col += compptr.DCT_scaled_size;
+            }
+            output_ptr_offset += compptr.DCT_scaled_size;
+        }
+    }
+
+    if (++(cinfo.output_iMCU_row) < cinfo.total_iMCU_rows)
+        return JPEG_ROW_COMPLETED;
+    return JPEG_SCAN_COMPLETED;
+}
+
+static int decompress_data (jpeg_decompress_struct cinfo, byte[][][] output_buf, int[] output_buf_offset) {
+    jpeg_d_coef_controller coef = cinfo.coef;
+    int last_iMCU_row = cinfo.total_iMCU_rows - 1;
+    int block_num;
+    int ci, block_row, block_rows;
+    short[][][] buffer;
+    short[][] buffer_ptr;
+    byte[][] output_ptr;
+    int output_col;
+    jpeg_component_info compptr;
+//  inverse_DCT_method_ptr inverse_DCT;
+
+    /* Force some input to be done if we are getting ahead of the input. */
+    while (cinfo.input_scan_number < cinfo.output_scan_number ||
+     (cinfo.input_scan_number is cinfo.output_scan_number &&
+        cinfo.input_iMCU_row <= cinfo.output_iMCU_row))
+    {
+        if (consume_input(cinfo) is JPEG_SUSPENDED)
+            return JPEG_SUSPENDED;
+    }
+
+    /* OK, output from the virtual arrays. */
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        /* Don't bother to IDCT an uninteresting component. */
+        if (! compptr.component_needed)
+            continue;
+        /* Align the virtual buffer for this component. */
+        buffer = coef.whole_image[ci];
+        int buffer_offset = cinfo.output_iMCU_row * compptr.v_samp_factor;
+        /* Count non-dummy DCT block rows in this iMCU row. */
+        if (cinfo.output_iMCU_row < last_iMCU_row)
+            block_rows = compptr.v_samp_factor;
+        else {
+            /* NB: can't use last_row_height here; it is input-side-dependent! */
+            block_rows = (compptr.height_in_blocks % compptr.v_samp_factor);
+            if (block_rows is 0) block_rows = compptr.v_samp_factor;
+        }
+//      inverse_DCT = cinfo.idct.inverse_DCT[ci];
+        output_ptr = output_buf[ci];
+        int output_ptr_offset = output_buf_offset[ci];
+        /* Loop over all DCT blocks to be processed. */
+        for (block_row = 0; block_row < block_rows; block_row++) {
+            buffer_ptr = buffer[block_row+buffer_offset];
+            int buffer_ptr_offset = 0;
+            output_col = 0;
+            for (block_num = 0; block_num < compptr.width_in_blocks; block_num++) {
+                jpeg_idct_islow(cinfo, compptr, buffer_ptr[buffer_ptr_offset], output_ptr, output_ptr_offset, output_col);
+
+                buffer_ptr_offset++;
+                output_col += compptr.DCT_scaled_size;
+            }
+            output_ptr_offset += compptr.DCT_scaled_size;
+        }
+    }
+
+    if (++(cinfo.output_iMCU_row) < cinfo.total_iMCU_rows)
+        return JPEG_ROW_COMPLETED;
+    return JPEG_SCAN_COMPLETED;
+}
+
+static void post_process_data (jpeg_decompress_struct cinfo,
+                byte[][][] input_buf, int[] input_buf_offset, int[] in_row_group_ctr,
+                int in_row_groups_avail,
+                byte[][] output_buf, int[] out_row_ctr,
+                int out_rows_avail)
+{
+    upsample(cinfo, input_buf, input_buf_offset, in_row_group_ctr, in_row_groups_avail, output_buf, out_row_ctr, out_rows_avail);
+}
+
+static void set_bottom_pointers (jpeg_decompress_struct cinfo)
+/* Change the pointer lists to duplicate the last sample row at the bottom
+ * of the image.    whichptr indicates which xbuffer holds the final iMCU row.
+ * Also sets rowgroups_avail to indicate number of nondummy row groups in row.
+ */
+{
+    jpeg_d_main_controller main = cinfo.main;
+    int ci, i, rgroup, iMCUheight, rows_left;
+    jpeg_component_info compptr;
+    byte[][] xbuf;
+
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        /* Count sample rows in one iMCU row and in one row group */
+        iMCUheight = compptr.v_samp_factor * compptr.DCT_scaled_size;
+        rgroup = iMCUheight / cinfo.min_DCT_scaled_size;
+        /* Count nondummy sample rows remaining for this component */
+        rows_left = (compptr.downsampled_height % iMCUheight);
+        if (rows_left is 0) rows_left = iMCUheight;
+        /* Count nondummy row groups.   Should get same answer for each component,
+         * so we need only do it once.
+         */
+        if (ci is 0) {
+            main.rowgroups_avail = ((rows_left-1) / rgroup + 1);
+        }
+        /* Duplicate the last real sample row rgroup*2 times; this pads out the
+         * last partial rowgroup and ensures at least one full rowgroup of context.
+         */
+        xbuf = main.xbuffer[main.whichptr][ci];
+        int xbuf_offset = main.xbuffer_offset[main.whichptr][ci];
+        for (i = 0; i < rgroup * 2; i++) {
+            xbuf[rows_left + i + xbuf_offset] = xbuf[rows_left-1 + xbuf_offset];
+        }
+    }
+}
+
+static void set_wraparound_pointers (jpeg_decompress_struct cinfo)
+/* Set up the "wraparound" pointers at top and bottom of the pointer lists.
+ * This changes the pointer list state from top-of-image to the normal state.
+ */
+{
+    jpeg_d_main_controller main = cinfo.main;
+    int ci, i, rgroup;
+    int M = cinfo.min_DCT_scaled_size;
+    jpeg_component_info compptr;
+    byte[][] xbuf0, xbuf1;
+
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) / cinfo.min_DCT_scaled_size; /* height of a row group of component */
+        xbuf0 = main.xbuffer[0][ci];
+        int xbuf0_offset = main.xbuffer_offset[0][ci];
+        xbuf1 = main.xbuffer[1][ci];
+        int xbuf1_offset = main.xbuffer_offset[1][ci];
+        for (i = 0; i < rgroup; i++) {
+            xbuf0[i - rgroup + xbuf0_offset] = xbuf0[rgroup*(M+1) + i + xbuf0_offset];
+            xbuf1[i - rgroup + xbuf1_offset] = xbuf1[rgroup*(M+1) + i + xbuf1_offset];
+            xbuf0[rgroup*(M+2) + i + xbuf0_offset] = xbuf0[i + xbuf0_offset];
+            xbuf1[rgroup*(M+2) + i + xbuf1_offset] = xbuf1[i + xbuf1_offset];
+        }
+    }
+}
+
+static void process_data_crank_post (jpeg_decompress_struct cinfo,
+    byte[][] output_buf, int[] out_row_ctr,
+    int out_rows_avail)
+{
+    error();
+}
+
+static void process_data_context_main (jpeg_decompress_struct cinfo,
+    byte[][] output_buf, int[] out_row_ctr,
+    int out_rows_avail)
+{
+    jpeg_d_main_controller main = cinfo.main;
+
+    /* Read input data if we haven't filled the main buffer yet */
+    if (! main.buffer_full) {
+        int result;
+        switch (cinfo.coef.decompress_data) {
+            case DECOMPRESS_DATA:
+                result = decompress_data(cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr]);
+                break;
+            case DECOMPRESS_SMOOTH_DATA:
+                result = decompress_smooth_data(cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr]);
+                break;
+            case DECOMPRESS_ONEPASS:
+                result = decompress_onepass(cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr]);
+                break;
+            default: result = 0;
+        }
+        if (result is 0)
+            return;         /* suspension forced, can do nothing more */
+        main.buffer_full = true;    /* OK, we have an iMCU row to work with */
+        main.iMCU_row_ctr++;    /* count rows received */
+    }
+
+    /* Postprocessor typically will not swallow all the input data it is handed
+     * in one call (due to filling the output buffer first).    Must be prepared
+     * to exit and restart. This switch lets us keep track of how far we got.
+     * Note that each case falls through to the next on successful completion.
+     */
+    switch (main.context_state) {
+        case CTX_POSTPONED_ROW:
+            /* Call postprocessor using previously set pointers for postponed row */
+            post_process_data (cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr], main.rowgroup_ctr, main.rowgroups_avail, output_buf, out_row_ctr, out_rows_avail);
+            if (main.rowgroup_ctr[0] < main.rowgroups_avail)
+                return;         /* Need to suspend */
+            main.context_state = CTX_PREPARE_FOR_IMCU;
+            if (out_row_ctr[0] >= out_rows_avail)
+                return;         /* Postprocessor exactly filled output buf */
+            /*FALLTHROUGH*/
+        case CTX_PREPARE_FOR_IMCU:
+            /* Prepare to process first M-1 row groups of this iMCU row */
+            main.rowgroup_ctr[0] = 0;
+            main.rowgroups_avail = (cinfo.min_DCT_scaled_size - 1);
+            /* Check for bottom of image: if so, tweak pointers to "duplicate"
+             * the last sample row, and adjust rowgroups_avail to ignore padding rows.
+             */
+            if (main.iMCU_row_ctr is cinfo.total_iMCU_rows)
+                set_bottom_pointers(cinfo);
+            main.context_state = CTX_PROCESS_IMCU;
+            /*FALLTHROUGH*/
+        case CTX_PROCESS_IMCU:
+            /* Call postprocessor using previously set pointers */
+            post_process_data (cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr], main.rowgroup_ctr, main.rowgroups_avail, output_buf, out_row_ctr, out_rows_avail);
+            if (main.rowgroup_ctr[0] < main.rowgroups_avail)
+                return;         /* Need to suspend */
+            /* After the first iMCU, change wraparound pointers to normal state */
+            if (main.iMCU_row_ctr is 1)
+                set_wraparound_pointers(cinfo);
+            /* Prepare to load new iMCU row using other xbuffer list */
+            main.whichptr ^= 1; /* 0=>1 or 1=>0 */
+            main.buffer_full = false;
+            /* Still need to process last row group of this iMCU row, */
+            /* which is saved at index M+1 of the other xbuffer */
+            main.rowgroup_ctr[0] = (cinfo.min_DCT_scaled_size + 1);
+            main.rowgroups_avail =  (cinfo.min_DCT_scaled_size + 2);
+            main.context_state = CTX_POSTPONED_ROW;
+    }
+}
+
+static void process_data_simple_main (jpeg_decompress_struct cinfo, byte[][] output_buf, int[] out_row_ctr, int out_rows_avail) {
+    jpeg_d_main_controller main = cinfo.main;
+    int rowgroups_avail;
+
+    /* Read input data if we haven't filled the main buffer yet */
+    if (! main.buffer_full) {
+        int result;
+        switch (cinfo.coef.decompress_data) {
+            case DECOMPRESS_DATA:
+                result = decompress_data(cinfo, main.buffer, main.buffer_offset);
+                break;
+            case DECOMPRESS_SMOOTH_DATA:
+                result = decompress_smooth_data(cinfo, main.buffer, main.buffer_offset);
+                break;
+            case DECOMPRESS_ONEPASS: 
+                result = decompress_onepass(cinfo, main.buffer, main.buffer_offset);
+                break;
+            default: result = 0;
+        }
+        if (result is 0)
+            return;         /* suspension forced, can do nothing more */
+        main.buffer_full = true;    /* OK, we have an iMCU row to work with */
+    }
+
+    /* There are always min_DCT_scaled_size row groups in an iMCU row. */
+    rowgroups_avail = cinfo.min_DCT_scaled_size;
+    /* Note: at the bottom of the image, we may pass extra garbage row groups
+     * to the postprocessor.    The postprocessor has to check for bottom
+     * of image anyway (at row resolution), so no point in us doing it too.
+     */
+
+    /* Feed the postprocessor */
+    post_process_data (cinfo, main.buffer, main.buffer_offset, main.rowgroup_ctr, rowgroups_avail, output_buf, out_row_ctr, out_rows_avail);
+
+    /* Has postprocessor consumed all the data yet? If so, mark buffer empty */
+    if (main.rowgroup_ctr[0] >= rowgroups_avail) {
+        main.buffer_full = false;
+        main.rowgroup_ctr[0] = 0;
+    }
+}
+
+static int jpeg_read_scanlines (jpeg_decompress_struct cinfo, byte[][] scanlines, int max_lines) {
+
+    if (cinfo.global_state !is DSTATE_SCANNING)
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+    if (cinfo.output_scanline >= cinfo.output_height) {
+//      WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
+        return 0;
+    }
+
+    /* Call progress monitor hook if present */
+//  if (cinfo.progress !is NULL) {
+//      cinfo.progress.pass_counter = (long) cinfo.output_scanline;
+//      cinfo.progress.pass_limit = (long) cinfo.output_height;
+//      (*cinfo.progress.progress_monitor) ((j_common_ptr) cinfo);
+//  }
+
+    /* Process some data */
+    cinfo.row_ctr[0] = 0;
+    switch (cinfo.main.process_data) {
+        case PROCESS_DATA_SIMPLE_MAIN:
+            process_data_simple_main (cinfo, scanlines, cinfo.row_ctr, max_lines);
+            break;
+        case PROCESS_DATA_CONTEXT_MAIN:
+            process_data_context_main (cinfo, scanlines, cinfo.row_ctr, max_lines);
+            break;
+        case PROCESS_DATA_CRANK_POST:
+            process_data_crank_post (cinfo, scanlines, cinfo.row_ctr, max_lines);
+            break;
+        default: error();
+    }
+    cinfo.output_scanline += cinfo.row_ctr[0];
+    return cinfo.row_ctr[0];
+}
+
+
+static bool output_pass_setup (jpeg_decompress_struct cinfo) {
+    if (cinfo.global_state !is DSTATE_PRESCAN) {
+        /* First call: do pass setup */
+        prepare_for_output_pass (cinfo);
+        cinfo.output_scanline = 0;
+        cinfo.global_state = DSTATE_PRESCAN;
+    }
+    /* Loop over any required dummy passes */
+    while (cinfo.master.is_dummy_pass) {
+        error();
+//#ifdef QUANT_2PASS_SUPPORTED
+//      /* Crank through the dummy pass */
+//      while (cinfo.output_scanline < cinfo.output_height) {
+//          JDIMENSION last_scanline;
+//          /* Call progress monitor hook if present */
+//          if (cinfo.progress !is NULL) {
+//  cinfo.progress.pass_counter = (long) cinfo.output_scanline;
+//  cinfo.progress.pass_limit = (long) cinfo.output_height;
+//  (*cinfo.progress.progress_monitor) ((j_common_ptr) cinfo);
+//          }
+//          /* Process some data */
+//          last_scanline = cinfo.output_scanline;
+//          (*cinfo.main.process_data) (cinfo, (JSAMPARRAY) NULL,
+//                      &cinfo.output_scanline, (JDIMENSION) 0);
+//          if (cinfo.output_scanline is last_scanline)
+//  return FALSE;       /* No progress made, must suspend */
+//      }
+//      /* Finish up dummy pass, and set up for another one */
+//      (*cinfo.master.finish_output_pass) (cinfo);
+//      (*cinfo.master.prepare_for_output_pass) (cinfo);
+//      cinfo.output_scanline = 0;
+//#else
+//      ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif /* QUANT_2PASS_SUPPORTED */
+    }
+    /* Ready for application to drive output pass through
+     * jpeg_read_scanlines or jpeg_read_raw_data.
+     */
+    cinfo.global_state = cinfo.raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
+    return true;
+}
+
+static bool get_dht (jpeg_decompress_struct cinfo)
+/* Process a DHT marker */
+{
+    int length;
+    byte[] bits = new byte[17];
+    byte[] huffval = new byte[256];
+    int i, index, count;
+    JHUFF_TBL htblptr;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    length -= 2;
+    
+    while (length > 16) {
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        index = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//      TRACEMS1(cinfo, 1, JTRC_DHT, index);
+            
+        bits[0] = 0;
+        count = 0;
+        for (i = 1; i <= 16; i++) {
+            if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        bits[i] = cinfo.buffer[cinfo.bytes_offset++];
+            count += bits[i] & 0xFF;
+        }
+
+        length -= 1 + 16;
+
+//      TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
+//           bits[1], bits[2], bits[3], bits[4],
+//           bits[5], bits[6], bits[7], bits[8]);
+//      TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
+//           bits[9], bits[10], bits[11], bits[12],
+//           bits[13], bits[14], bits[15], bits[16]);
+
+        /* Here we just do minimal validation of the counts to avoid walking
+         * off the end of our table space.  jdhuff.c will check more carefully.
+         */
+        if (count > 256 || (count) > length)
+            error();
+//          ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+
+        for (i = 0; i < count; i++) {
+            if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+            huffval[i] = cinfo.buffer[cinfo.bytes_offset++];
+        }
+
+        length -= count;
+
+        if ((index & 0x10) !is 0) {     /* AC table definition */
+            index -= 0x10;
+            htblptr = cinfo.ac_huff_tbl_ptrs[index] = new JHUFF_TBL();
+        } else {            /* DC table definition */
+            htblptr = cinfo.dc_huff_tbl_ptrs[index] = new JHUFF_TBL();
+        }
+
+        if (index < 0 || index >= NUM_HUFF_TBLS)
+            error();
+//          ERREXIT1(cinfo, JERR_DHT_INDEX, index);
+
+        System.arraycopy(bits, 0, htblptr.bits, 0, bits.length);
+        System.arraycopy(huffval, 0, htblptr.huffval, 0, huffval.length);
+    }
+
+    if (length !is 0)
+        error();
+//      ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+    return true;
+}
+
+
+static bool get_dqt (jpeg_decompress_struct cinfo)
+/* Process a DQT marker */
+{
+    int length;
+    int n, i, prec;
+    int tmp;
+    JQUANT_TBL quant_ptr;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    length -= 2;
+
+    while (length > 0) {
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    n = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        prec = n >> 4;
+        n &= 0x0F;
+
+//      TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
+
+        if (n >= NUM_QUANT_TBLS)
+            error();
+//          ERREXIT1(cinfo, JERR_DQT_INDEX, n);
+            
+        if (cinfo.quant_tbl_ptrs[n] is null)
+            cinfo.quant_tbl_ptrs[n] = new JQUANT_TBL();
+        quant_ptr = cinfo.quant_tbl_ptrs[n];
+
+        for (i = 0; i < DCTSIZE2; i++) {
+            if (prec !is 0) {
+                if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+                tmp = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+                if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+                tmp |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+            } else {
+                    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+                tmp = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+            }
+            /* We convert the zigzag-order table to natural array order. */
+            quant_ptr.quantval[jpeg_natural_order[i]] = (short) tmp;
+        }
+
+//      if (cinfo.err.trace_level >= 2) {
+//          for (i = 0; i < DCTSIZE2; i += 8) {
+//              TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
+//                  quant_ptr.quantval[i],   quant_ptr.quantval[i+1],
+//                   quant_ptr.quantval[i+2], quant_ptr.quantval[i+3],
+//                   quant_ptr.quantval[i+4], quant_ptr.quantval[i+5],
+//                   quant_ptr.quantval[i+6], quant_ptr.quantval[i+7]);
+//          }
+//      }
+
+        length -= (DCTSIZE2+1);
+        if (prec !is 0) length -= DCTSIZE2;
+    }
+
+    if (length !is 0)
+        error();
+//      ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+    return true;
+}
+
+static bool get_dri (jpeg_decompress_struct cinfo)
+/* Process a DRI marker */
+{
+    int length;
+    int tmp;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    
+    if (length !is 4)
+    error();
+//      ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    tmp = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    tmp |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//  TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
+
+    cinfo.restart_interval = tmp;
+
+    return true;
+}
+
+static bool get_dac (jpeg_decompress_struct cinfo)
+/* Process a DAC marker */
+{
+    int length;
+    int index, val;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    length -= 2;
+    
+    while (length > 0) {
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        index = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        val = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+        length -= 2;
+
+//      TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
+
+        if (index < 0 || index >= (2*NUM_ARITH_TBLS))
+            error();
+//          ERREXIT1(cinfo, JERR_DAC_INDEX, index);
+
+        if (index >= NUM_ARITH_TBLS) { /* define AC table */
+            cinfo.arith_ac_K[index-NUM_ARITH_TBLS] = (byte) val;
+        } else {            /* define DC table */
+            cinfo.arith_dc_L[index] = (byte) (val & 0x0F);
+            cinfo.arith_dc_U[index] = (byte) (val >> 4);
+            if (cinfo.arith_dc_L[index] > cinfo.arith_dc_U[index])
+                error();
+//  ERREXIT1(cinfo, JERR_DAC_VALUE, val);
+        }
+    }
+
+    if (length !is 0)
+        error();
+//      ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+    return true;
+}
+
+
+static bool get_sos (jpeg_decompress_struct cinfo)
+/* Process a SOS marker */
+{
+    int length;
+    int i, ci, n, c, cc;
+    jpeg_component_info compptr = null;
+
+    if (! cinfo.marker.saw_SOF)
+        error();
+//      ERREXIT(cinfo, JERR_SOS_NO_SOF);
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    n = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//  TRACEMS1(cinfo, 1, JTRC_SOS, n);
+
+    if (length !is (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
+        error();
+//      ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+    cinfo.comps_in_scan = n;
+
+    /* Collect the component-spec parameters */
+
+    for (i = 0; i < n; i++) {
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        cc = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        
+        for (ci = 0; ci < cinfo.num_components; ci++) {
+            compptr = cinfo.comp_info[ci];
+            if (cc is compptr.component_id)
+                break;
+        }
+
+        if (ci is cinfo.num_components)
+            error();
+//          ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
+
+        cinfo.cur_comp_info[i] = compptr;
+        compptr.dc_tbl_no = (c >> 4) & 15;
+        compptr.ac_tbl_no = (c       ) & 15;
+        
+//      TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, compptr.dc_tbl_no, compptr.ac_tbl_no);
+    }
+
+    /* Collect the additional scan parameters Ss, Se, Ah/Al. */
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    cinfo.Ss = c;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    cinfo.Se = c;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    cinfo.Ah = (c >> 4) & 15;
+    cinfo.Al = (c        ) & 15;
+
+//  TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo.Ss, cinfo.Se, cinfo.Ah, cinfo.Al);
+
+    /* Prepare to scan data & restart markers */
+    cinfo.marker.next_restart_num = 0;
+
+    /* Count another SOS marker */
+    cinfo.input_scan_number++;
+
+    return true;
+}
+
+static bool get_sof (jpeg_decompress_struct cinfo, bool is_prog, bool is_arith) {
+    int length;
+    int c, ci;
+
+    cinfo.progressive_mode = is_prog;
+    cinfo.arith_code = is_arith;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    cinfo.data_precision = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    cinfo.image_height = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    cinfo.image_height |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    cinfo.image_width = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    cinfo.image_width |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    cinfo.num_components = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+    length -= 8;
+
+//  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo.unread_marker,
+//       (int) cinfo.image_width, (int) cinfo.image_height,
+//       cinfo.num_components);
+
+    if (cinfo.marker.saw_SOF)
+        error();
+//      ERREXIT(cinfo, JERR_SOF_DUPLICATE);
+
+    /* We don't support files in which the image height is initially specified */
+    /* as 0 and is later redefined by DNL.  As long as we have to check that,   */
+    /* might as well have a general sanity check. */
+    if (cinfo.image_height <= 0 || cinfo.image_width <= 0 || cinfo.num_components <= 0)
+        error();
+//      ERREXIT(cinfo, JERR_EMPTY_IMAGE);
+
+    if (length !is (cinfo.num_components * 3))
+        error();
+//      ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+    if (cinfo.comp_info is null)    /* do only once, even if suspend */
+        cinfo.comp_info = new jpeg_component_info[cinfo.num_components];
+    
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        jpeg_component_info compptr = cinfo.comp_info[ci] = new jpeg_component_info();
+        compptr.component_index = ci;
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        compptr.component_id = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        compptr.h_samp_factor = (c >> 4) & 15;
+        compptr.v_samp_factor = (c       ) & 15;
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        compptr.quant_tbl_no = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//      TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
+//           compptr.component_id, compptr.h_samp_factor,
+//           compptr.v_samp_factor, compptr.quant_tbl_no);
+    }
+
+    cinfo.marker.saw_SOF = true;
+
+    return true;
+}
+
+static void sep_upsample (jpeg_decompress_struct cinfo, byte[][][] input_buf, int[] input_buf_offset,
+        int[] in_row_group_ctr, int in_row_groups_avail,
+        byte[][] output_buf, int[] out_row_ctr, int out_rows_avail)
+{
+    jpeg_upsampler upsample = cinfo.upsample;
+    int ci;
+    jpeg_component_info compptr;
+    int num_rows;
+
+    /* Fill the conversion buffer, if it's empty */
+    if (upsample.next_row_out >= cinfo.max_v_samp_factor) {
+        for (ci = 0; ci < cinfo.num_components; ci++) {
+            compptr = cinfo.comp_info[ci];
+            /* Invoke per-component upsample method.    Notice we pass a POINTER
+             * to color_buf[ci], so that fullsize_upsample can change it.
+             */
+            int offset = input_buf_offset[ci] + (in_row_group_ctr[0] * upsample.rowgroup_height[ci]);
+            switch (upsample.methods[ci]) {
+                case NOOP_UPSAMPLE: noop_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+                case FULLSIZE_UPSAMPLE: fullsize_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+                case H2V1_FANCY_UPSAMPLE: h2v1_fancy_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+                case H2V1_UPSAMPLE: h2v1_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+                case H2V2_FANCY_UPSAMPLE: h2v2_fancy_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+                case H2V2_UPSAMPLE: h2v2_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+                case INT_UPSAMPLE: int_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+            }
+        }
+        upsample.next_row_out = 0;
+    }
+
+    /* Color-convert and emit rows */
+
+    /* How many we have in the buffer: */
+    num_rows =  (cinfo.max_v_samp_factor - upsample.next_row_out);
+    /* Not more than the distance to the end of the image.  Need this test
+     * in case the image height is not a multiple of max_v_samp_factor:
+     */
+    if (num_rows > upsample.rows_to_go) 
+        num_rows = upsample.rows_to_go;
+    /* And not more than what the client can accept: */
+    out_rows_avail -= out_row_ctr[0];
+    if (num_rows > out_rows_avail)
+        num_rows = out_rows_avail;
+
+    switch (cinfo.cconvert.color_convert) {
+        case NULL_CONVERT: null_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+        case GRAYSCALE_CONVERT: grayscale_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+        case YCC_RGB_CONVERT: ycc_rgb_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+        case GRAY_RGB_CONVERT: gray_rgb_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+        case YCCK_CMYK_CONVERT: error(); break;
+    }
+
+    /* Adjust counts */
+    out_row_ctr[0] += num_rows;
+    upsample.rows_to_go -= num_rows;
+    upsample.next_row_out += num_rows;
+    /* When the buffer is emptied, declare this input row group consumed */
+    if (upsample.next_row_out >= cinfo.max_v_samp_factor) {
+        in_row_group_ctr[0]++;
+    }
+}
+    
+static void noop_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+     byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+    output_data_ptr[output_data_index] = null;  /* safety check */
+}
+    
+static void fullsize_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+     byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+    output_data_ptr[output_data_index] = input_data;
+    output_data_offset[output_data_index] = input_data_offset;
+}
+    
+static void h2v1_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+     byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+    byte[][] output_data = output_data_ptr[output_data_index];
+    byte[] inptr, outptr;
+    byte invalue;
+    int outend;
+    int inrow;
+    output_data_offset[output_data_index] = 0;
+
+    for (inrow = 0; inrow < cinfo.max_v_samp_factor; inrow++) {
+        inptr = input_data[inrow+input_data_offset];
+        outptr = output_data[inrow];
+        int inptr_offset = 0, outptr_offset = 0;
+        outend = outptr_offset + cinfo.output_width;
+        while (outptr_offset < outend) {
+            invalue = inptr[inptr_offset++];    /* don't need GETJSAMPLE() here */
+            outptr[outptr_offset++] = invalue;
+            outptr[outptr_offset++] = invalue;
+        }
+    }
+}
+    
+static void h2v2_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+    byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+    byte[][] output_data = output_data_ptr[output_data_index];
+    byte[] inptr, outptr;
+    byte invalue;
+    int outend;
+    int inrow, outrow;
+    output_data_offset[output_data_index] = 0;
+
+    inrow = outrow = 0;
+    while (outrow < cinfo.max_v_samp_factor) {
+        inptr = input_data[inrow+input_data_offset];
+        outptr = output_data[outrow];
+        int inptr_offset = 0, outptr_offset = 0;
+        outend = outptr_offset + cinfo.output_width;
+        while (outptr_offset < outend) {
+            invalue = inptr[inptr_offset++];    /* don't need GETJSAMPLE() here */
+            outptr[outptr_offset++] = invalue;
+            outptr[outptr_offset++] = invalue;
+        }
+        jcopy_sample_rows(output_data, outrow, output_data, outrow+1, 1, cinfo.output_width);
+        inrow++;
+        outrow += 2;
+    }
+}
+    
+static void h2v1_fancy_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+     byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+    byte[][] output_data = output_data_ptr[output_data_index];
+    byte[] inptr, outptr;
+    int invalue;
+    int colctr;
+    int inrow;                  
+    output_data_offset[output_data_index] = 0;
+
+    for (inrow = 0; inrow < cinfo.max_v_samp_factor; inrow++) {
+        inptr = input_data[inrow+input_data_offset];
+        outptr = output_data[inrow];
+        int inptr_offset = 0, outptr_offset = 0;
+        /* Special case for first column */
+        invalue = inptr[inptr_offset++] & 0xFF;
+        outptr[outptr_offset++] = (byte) invalue;
+        outptr[outptr_offset++] = (byte) ((invalue * 3 + (inptr[inptr_offset] & 0xFF) + 2) >> 2);
+
+        for (colctr = compptr.downsampled_width - 2; colctr > 0; colctr--) {
+            /* General case: 3/4 * nearer pixel + 1/4 * further pixel */
+            invalue = (inptr[inptr_offset++] & 0xFF) * 3;
+            outptr[outptr_offset++] = (byte) ((invalue + (inptr[inptr_offset-2] & 0xFF) + 1) >> 2);
+            outptr[outptr_offset++] = (byte) ((invalue + (inptr[inptr_offset] & 0xFF) + 2) >> 2);
+        }
+
+        /* Special case for last column */
+        invalue = (inptr[inptr_offset] & 0xFF);
+        outptr[outptr_offset++] = (byte) ((invalue * 3 + (inptr[inptr_offset-1] & 0xFF) + 1) >> 2);
+        outptr[outptr_offset++] = (byte) invalue;
+    }
+}
+    
+static void h2v2_fancy_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+    byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+    byte[][] output_data = output_data_ptr[output_data_index];
+    byte[] inptr0, inptr1, outptr;
+    int thiscolsum, lastcolsum, nextcolsum;
+    int colctr;
+    int inrow, outrow, v;
+    output_data_offset[output_data_index] = 0;
+
+    inrow = outrow = 0;
+    while (outrow < cinfo.max_v_samp_factor) {
+        for (v = 0; v < 2; v++) {
+            /* inptr0 points to nearest input row, inptr1 points to next nearest */
+            inptr0 = input_data[inrow+input_data_offset];
+            if (v is 0)     /* next nearest is row above */
+                inptr1 = input_data[inrow-1+input_data_offset];
+            else            /* next nearest is row below */
+                inptr1 = input_data[inrow+1+input_data_offset];
+            outptr = output_data[outrow++];
+                
+            int inptr0_offset = 0, inptr1_offset = 0, outptr_offset = 0;
+
+            /* Special case for first column */
+            thiscolsum = (inptr0[inptr0_offset++] & 0xFF) * 3 + (inptr1[inptr1_offset++] & 0xFF);
+            nextcolsum = (inptr0[inptr0_offset++] & 0xFF) * 3 + (inptr1[inptr1_offset++] & 0xFF);
+            outptr[outptr_offset++] = (byte) ((thiscolsum * 4 + 8) >> 4);
+            outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
+            lastcolsum = thiscolsum; thiscolsum = nextcolsum;
+
+            for (colctr = compptr.downsampled_width - 2; colctr > 0; colctr--) {
+                /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
+                /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
+                nextcolsum = (inptr0[inptr0_offset++] & 0xFF) * 3 + (inptr1[inptr1_offset++] & 0xFF);
+                outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
+                outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
+                lastcolsum = thiscolsum; thiscolsum = nextcolsum;
+            }
+
+            /* Special case for last column */
+            outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
+            outptr[outptr_offset++] = (byte) ((thiscolsum * 4 + 7) >> 4);
+        }
+        inrow++;
+    }
+}
+    
+static void int_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+     byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+    jpeg_upsampler upsample = cinfo.upsample;
+    byte[][] output_data = output_data_ptr[output_data_index];
+    byte[] inptr, outptr;
+    byte invalue;
+    int h;
+    int outend;
+    int h_expand, v_expand;
+    int inrow, outrow;
+    output_data_offset[output_data_index] = 0;
+        
+    h_expand = upsample.h_expand[compptr.component_index];
+    v_expand = upsample.v_expand[compptr.component_index];
+
+    inrow = outrow = 0;
+    while (outrow < cinfo.max_v_samp_factor) {
+        /* Generate one output row with proper horizontal expansion */
+        inptr = input_data[inrow+input_data_offset];
+        int inptr_offset = 0;
+        outptr = output_data[outrow];
+        int outptr_offset = 0;
+        outend = outptr_offset + cinfo.output_width;
+        while (outptr_offset < outend) {
+            invalue = inptr[inptr_offset++];    /* don't need GETJSAMPLE() here */
+            for (h = h_expand; h > 0; h--) {
+                outptr[outptr_offset++] = invalue;
+            }
+        }
+        /* Generate any additional output rows by duplicating the first one */
+        if (v_expand > 1) {
+            jcopy_sample_rows(output_data, outrow, output_data, outrow+1, v_expand-1, cinfo.output_width);
+        }
+        inrow++;
+        outrow += v_expand;
+    }
+}
+
+static void null_convert (jpeg_decompress_struct cinfo,
+    byte[][][] input_buf, int[] input_buf_offset, int input_row,
+    byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+    byte[] inptr, outptr;
+    int count;
+    int num_components = cinfo.num_components;
+    int num_cols = cinfo.output_width;
+    int ci;
+
+    while (--num_rows >= 0) {
+        for (ci = 0; ci < num_components; ci++) {
+            inptr = input_buf[ci][input_row+input_buf_offset[0]];
+            outptr = output_buf[output_buf_offset];
+            /* BGR instead of RGB */
+            int offset = 0;
+            switch (ci) {
+                case 2: offset = RGB_BLUE; break;
+                case 1: offset = RGB_GREEN; break;
+                case 0: offset = RGB_RED; break;
+            }
+            int outptr_offset = offset, inptr_offset = 0;
+            for (count = num_cols; count > 0; count--) {
+                outptr[outptr_offset] = inptr[inptr_offset++];  /* needn't bother with GETJSAMPLE() here */
+                outptr_offset += num_components;
+            }
+        }
+        input_row++;
+        output_buf_offset++;
+    }
+}
+    
+static void grayscale_convert (jpeg_decompress_struct cinfo,
+    byte[][][] input_buf, int[] input_buf_offset, int input_row,
+    byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+  jcopy_sample_rows(input_buf[0], input_row+input_buf_offset[0], output_buf, output_buf_offset,
+            num_rows, cinfo.output_width);
+}
+
+static void gray_rgb_convert (jpeg_decompress_struct cinfo,
+    byte[][][] input_buf, int[] input_buf_offset, int input_row,
+    byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+    byte[] inptr, outptr;
+    int col;
+    int num_cols = cinfo.output_width;
+
+    while (--num_rows >= 0) {
+        inptr = input_buf[0][input_row+++input_buf_offset[0]];
+        outptr = output_buf[output_buf_offset++];
+        int outptr_offset = 0;
+        for (col = 0; col < num_cols; col++) {
+            /* We can dispense with GETJSAMPLE() here */
+            outptr[RGB_RED+outptr_offset] = outptr[RGB_GREEN+outptr_offset] = outptr[RGB_BLUE+outptr_offset] = inptr[col];
+            outptr_offset += RGB_PIXELSIZE;
+        }
+    }
+}
+    
+static void ycc_rgb_convert (jpeg_decompress_struct cinfo,
+    byte[][][] input_buf, int[] input_buf_offset, int input_row,
+    byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+    jpeg_color_deconverter cconvert = cinfo.cconvert;
+    int y, cb, cr;
+    byte[] outptr;
+    byte[] inptr0, inptr1, inptr2;
+    int col;
+    int num_cols = cinfo.output_width;
+    /* copy these pointers into registers if possible */
+    byte[] range_limit = cinfo.sample_range_limit;
+    int range_limit_offset = cinfo.sample_range_limit_offset;
+    int[] Crrtab = cconvert.Cr_r_tab;
+    int[] Cbbtab = cconvert.Cb_b_tab;
+    int[] Crgtab = cconvert.Cr_g_tab;
+    int[] Cbgtab = cconvert.Cb_g_tab;
+//      SHIFT_TEMPS
+
+    while (--num_rows >= 0) {
+        inptr0 = input_buf[0][input_row+input_buf_offset[0]];
+        inptr1 = input_buf[1][input_row+input_buf_offset[1]];
+        inptr2 = input_buf[2][input_row+input_buf_offset[2]];
+        input_row++;
+        outptr = output_buf[output_buf_offset++];
+        int outptr_offset = 0;
+        for (col = 0; col < num_cols; col++) {
+            y = (inptr0[col] & 0xFF);
+            cb = (inptr1[col] & 0xFF);
+            cr = (inptr2[col] & 0xFF);
+            /* Range-limiting is essential due to noise introduced by DCT losses. */
+            outptr[outptr_offset + RGB_RED] =   range_limit[y + Crrtab[cr] + range_limit_offset];
+            outptr[outptr_offset + RGB_GREEN] = range_limit[y + ((Cbgtab[cb] + Crgtab[cr]>>SCALEBITS)) + range_limit_offset];
+            outptr[outptr_offset + RGB_BLUE] =  range_limit[y + Cbbtab[cb] + range_limit_offset];
+            outptr_offset += RGB_PIXELSIZE;
+        }
+    }
+}
+
+static bool process_APPn(int n, jpeg_decompress_struct cinfo) {
+    if (n is 0 || n is 14) {
+        return get_interesting_appn(cinfo);
+    }
+    return skip_variable(cinfo);
+}
+
+static bool process_COM(jpeg_decompress_struct cinfo) {
+    return skip_variable(cinfo);
+}
+
+static void skip_input_data (jpeg_decompress_struct cinfo, int num_bytes) {
+    if (num_bytes > 0) {
+        while (num_bytes > cinfo.bytes_in_buffer - cinfo.bytes_offset) {
+            num_bytes -= cinfo.bytes_in_buffer - cinfo.bytes_offset;
+            if (!fill_input_buffer(cinfo)) error();
+            /* note we assume that fill_input_buffer will never return FALSE,
+             * so suspension need not be handled.
+             */
+        }
+        cinfo.bytes_offset += num_bytes;
+    }
+}
+
+static bool skip_variable (jpeg_decompress_struct cinfo)
+/* Skip over an unknown or uninteresting variable-length marker */
+{
+    int length;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+    length -= 2;
+    
+//  TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo.unread_marker, (int) length);
+
+    if (length > 0) {
+        skip_input_data (cinfo, length);
+    }
+    
+    return true;
+}
+
+static bool get_interesting_appn (jpeg_decompress_struct cinfo)
+/* Process an APP0 or APP14 marker without saving it */
+{
+    int length;
+    byte[] b = new byte[APPN_DATA_LEN];
+    int i, numtoread;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    length -= 2;
+
+    /* get the interesting part of the marker data */
+    if (length >= APPN_DATA_LEN)
+        numtoread = APPN_DATA_LEN;
+    else if (length > 0)
+        numtoread = length;
+    else
+        numtoread = 0;
+    for (i = 0; i < numtoread; i++) {
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        b[i] = cinfo.buffer[cinfo.bytes_offset++];
+    }
+    length -= numtoread;
+
+    /* process it */
+    switch (cinfo.unread_marker) {
+        case M_APP0:
+            examine_app0(cinfo, b, numtoread, length);
+            break;
+        case M_APP14:
+            examine_app14(cinfo, b, numtoread, length);
+            break;
+        default:
+            /* can't get here unless jpeg_save_markers chooses wrong processor */
+            error();
+//          ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo.unread_marker);
+            break;
+    }
+
+    /* skip any remaining data -- could be lots */
+    if (length > 0)
+        skip_input_data (cinfo, length);
+
+    return true;
+}
+
+static void examine_app0 (jpeg_decompress_struct cinfo, byte[] data, int datalen, int remaining)
+/* Examine first few bytes from an APP0.
+ * Take appropriate action if it is a JFIF marker.
+ * datalen is # of bytes at data[], remaining is length of rest of marker data.
+ */
+{
+    int totallen = datalen + remaining;
+
+    if (datalen >= APP0_DATA_LEN &&
+            (data[0] & 0xFF) is 0x4A &&
+            (data[1] & 0xFF) is 0x46 &&
+            (data[2] & 0xFF) is 0x49 &&
+            (data[3] & 0xFF) is 0x46 &&
+            (data[4] & 0xFF) is 0)
+    {
+        /* Found JFIF APP0 marker: save info */
+        cinfo.saw_JFIF_marker = true;
+        cinfo.JFIF_major_version = (data[5]);
+        cinfo.JFIF_minor_version = (byte)(data[6] & 0xFF);
+        cinfo.density_unit = (byte)(data[7] & 0xFF);
+        cinfo.X_density = (short)(((data[8] & 0xFF) << 8) + (data[9] & 0xFF));
+        cinfo.Y_density = (short)(((data[10] & 0xFF) << 8) + (data[11] & 0xFF));
+        /* Check version.
+         * Major version must be 1, anything else signals an incompatible change.
+         * (We used to treat this as an error, but now it's a nonfatal warning,
+         * because some bozo at Hijaak couldn't read the spec.)
+         * Minor version should be 0..2, but process anyway if newer.
+         */
+        if (cinfo.JFIF_major_version !is 1) {
+//          WARNMS2(cinfo, JWRN_JFIF_MAJOR,
+//              cinfo.JFIF_major_version, cinfo.JFIF_minor_version);
+        }
+        /* Generate trace messages */
+//      TRACEMS5(cinfo, 1, JTRC_JFIF,
+//           cinfo.JFIF_major_version, cinfo.JFIF_minor_version,
+//           cinfo.X_density, cinfo.Y_density, cinfo.density_unit);
+        /* Validate thumbnail dimensions and issue appropriate messages */
+        if (((data[12] & 0xFF) | (data[13]) & 0xFF) !is 0) {
+//          TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL,
+//               GETJOCTET(data[12]), GETJOCTET(data[13]));
+        }
+        totallen -= APP0_DATA_LEN;
+        if (totallen != ((data[12] & 0xFF) * (data[13] & 0xFF) * 3)) {
+//          TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen);
+        }
+    } else if (datalen >= 6 &&
+            (data[0] & 0xFF) is 0x4A &&
+            (data[1] & 0xFF) is 0x46 &&
+            (data[2] & 0xFF) is 0x58 &&
+            (data[3] & 0xFF) is 0x58 &&
+            (data[4] & 0xFF) is 0)
+    {
+        /* Found JFIF "JFXX" extension APP0 marker */
+        /* The library doesn't actually do anything with these,
+         * but we try to produce a helpful trace message.
+         */
+        switch ((data[5]) & 0xFF) {
+            case 0x10:
+//              TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen);
+                break;
+            case 0x11:
+//              TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen);
+                break;
+            case 0x13:
+//              TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen);
+                break;
+            default:
+//              TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, GETJOCTET(data[5]), (int) totallen);
+            break;
+        }
+    } else {
+        /* Start of APP0 does not match "JFIF" or "JFXX", or too short */
+//      TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen);
+    }
+}
+
+static void examine_app14 (jpeg_decompress_struct cinfo, byte[] data, int datalen, int remaining)
+/* Examine first few bytes from an APP14.
+ * Take appropriate action if it is an Adobe marker.
+ * datalen is # of bytes at data[], remaining is length of rest of marker data.
+ */
+{
+    int /*version, flags0, flags1, */transform;
+
+    if (datalen >= APP14_DATA_LEN &&
+            (data[0] & 0xFF) is 0x41 &&
+            (data[1] & 0xFF) is 0x64 &&
+            (data[2] & 0xFF) is 0x6F &&
+            (data[3] & 0xFF) is 0x62 &&
+            (data[4] & 0xFF) is 0x65)
+    {
+        /* Found Adobe APP14 marker */
+//      version = ((data[5] & 0xFF) << 8) + (data[6] & 0xFF);
+//      flags0 = ((data[7] & 0xFF) << 8) + (data[8] & 0xFF);
+//      flags1 = ((data[9] & 0xFF) << 8) + (data[10] & 0xFF);
+        transform = (data[11] & 0xFF);
+//      TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
+        cinfo.saw_Adobe_marker = true;
+        cinfo.Adobe_transform = (byte) transform;
+    } else {
+        /* Start of APP14 does not match "Adobe", or too short */
+//      TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining));
+    }
+}
+
+static bool get_soi (jpeg_decompress_struct cinfo) /* Process an SOI marker */ {
+    int i;
+    
+//  TRACEMS(cinfo, 1, JTRC_SOI);
+
+    if (cinfo.marker.saw_SOI)
+        error();
+//      ERREXIT(cinfo, JERR_SOI_DUPLICATE);
+
+    /* Reset all parameters that are defined to be reset by SOI */
+
+    for (i = 0; i < NUM_ARITH_TBLS; i++) {
+        cinfo.arith_dc_L[i] = 0;
+        cinfo.arith_dc_U[i] = 1;
+        cinfo.arith_ac_K[i] = 5;
+    }
+    cinfo.restart_interval = 0;
+
+    /* Set initial assumptions for colorspace etc */
+
+    cinfo.jpeg_color_space = JCS_UNKNOWN;
+    cinfo.CCIR601_sampling = false; /* Assume non-CCIR sampling??? */
+
+    cinfo.saw_JFIF_marker = false;
+    cinfo.JFIF_major_version = 1; /* set default JFIF APP0 values */
+    cinfo.JFIF_minor_version = 1;
+    cinfo.density_unit = 0;
+    cinfo.X_density = 1;
+    cinfo.Y_density = 1;
+    cinfo.saw_Adobe_marker = false;
+    cinfo.Adobe_transform = 0;
+
+    cinfo.marker.saw_SOI = true;
+
+    return true;
+}
+
+static void jinit_input_controller (jpeg_decompress_struct cinfo)
+{
+    /* Initialize state: can't use reset_input_controller since we don't
+     * want to try to reset other modules yet.
+     */
+    jpeg_input_controller inputctl = cinfo.inputctl = new jpeg_input_controller();
+    inputctl.has_multiple_scans = false; /* "unknown" would be better */
+    inputctl.eoi_reached = false;
+    inputctl.inheaders = true;
+}
+
+static void reset_marker_reader (jpeg_decompress_struct cinfo) {
+    jpeg_marker_reader marker = cinfo.marker;
+
+    cinfo.comp_info = null;     /* until allocated by get_sof */
+    cinfo.input_scan_number = 0;        /* no SOS seen yet */
+    cinfo.unread_marker = 0;        /* no pending marker */
+    marker.saw_SOI = false;     /* set internal state too */
+    marker.saw_SOF = false;
+    marker.discarded_bytes = 0;
+//  marker.cur_marker = null;
+}
+
+static void reset_input_controller (jpeg_decompress_struct cinfo) {
+    jpeg_input_controller inputctl = cinfo.inputctl;
+
+    inputctl.has_multiple_scans = false; /* "unknown" would be better */
+    inputctl.eoi_reached = false;
+    inputctl.inheaders = true;
+    /* Reset other modules */
+    reset_marker_reader (cinfo);
+    /* Reset progression state -- would be cleaner if entropy decoder did this */
+    cinfo.coef_bits = null;
+}
+
+static void finish_output_pass (jpeg_decompress_struct cinfo) {
+    jpeg_decomp_master master = cinfo.master;
+
+    if (cinfo.quantize_colors) {
+        error(DWT.ERROR_NOT_IMPLEMENTED);
+//      (*cinfo.cquantize.finish_pass) (cinfo);
+    }
+    master.pass_number++;
+}
+
+static void jpeg_destroy (jpeg_decompress_struct cinfo) {
+    /* We need only tell the memory manager to release everything. */
+    /* NB: mem pointer is NULL if memory mgr failed to initialize. */
+//  if (cinfo.mem !is NULL)
+//      (*cinfo.mem.self_destruct) (cinfo);
+//  cinfo.mem = NULL;       /* be safe if jpeg_destroy is called twice */
+    cinfo.global_state = 0; /* mark it destroyed */
+}
+
+static void jpeg_destroy_decompress (jpeg_decompress_struct cinfo) {
+    jpeg_destroy(cinfo); /* use common routine */
+}
+
+static bool jpeg_input_complete (jpeg_decompress_struct cinfo) {
+    /* Check for valid jpeg object */
+    if (cinfo.global_state < DSTATE_START || cinfo.global_state > DSTATE_STOPPING)
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+    return cinfo.inputctl.eoi_reached;
+}
+
+static bool jpeg_start_output (jpeg_decompress_struct cinfo, int scan_number) {
+    if (cinfo.global_state !is DSTATE_BUFIMAGE && cinfo.global_state !is DSTATE_PRESCAN)
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+    /* Limit scan number to valid range */
+    if (scan_number <= 0)
+        scan_number = 1;
+    if (cinfo.inputctl.eoi_reached && scan_number > cinfo.input_scan_number)
+        scan_number = cinfo.input_scan_number;
+    cinfo.output_scan_number = scan_number;
+    /* Perform any dummy output passes, and set up for the real pass */
+    return output_pass_setup(cinfo);
+}
+
+static bool jpeg_finish_output (jpeg_decompress_struct cinfo) {
+    if ((cinfo.global_state is DSTATE_SCANNING || cinfo.global_state is DSTATE_RAW_OK) && cinfo.buffered_image) {
+        /* Terminate this pass. */
+        /* We do not require the whole pass to have been completed. */
+        finish_output_pass (cinfo);
+        cinfo.global_state = DSTATE_BUFPOST;
+    } else if (cinfo.global_state !is DSTATE_BUFPOST) {
+        /* BUFPOST = repeat call after a suspension, anything else is error */
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+    }
+    /* Read markers looking for SOS or EOI */
+    while (cinfo.input_scan_number <= cinfo.output_scan_number && !cinfo.inputctl.eoi_reached) {
+        if (consume_input (cinfo) is JPEG_SUSPENDED)
+            return false;       /* Suspend, come back later */
+    }
+    cinfo.global_state = DSTATE_BUFIMAGE;
+    return true;
+}
+
+static bool jpeg_finish_decompress (jpeg_decompress_struct cinfo) {
+    if ((cinfo.global_state is DSTATE_SCANNING || cinfo.global_state is DSTATE_RAW_OK) && ! cinfo.buffered_image) {
+        /* Terminate final pass of non-buffered mode */
+        if (cinfo.output_scanline < cinfo.output_height)
+            error();
+//          ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
+        finish_output_pass (cinfo);
+        cinfo.global_state = DSTATE_STOPPING;
+    } else if (cinfo.global_state is DSTATE_BUFIMAGE) {
+        /* Finishing after a buffered-image operation */
+        cinfo.global_state = DSTATE_STOPPING;
+    } else if (cinfo.global_state !is DSTATE_STOPPING) {
+        /* STOPPING = repeat call after a suspension, anything else is error */
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+    }
+    /* Read until EOI */
+    while (! cinfo.inputctl.eoi_reached) {
+        if (consume_input (cinfo) is JPEG_SUSPENDED)
+            return false;       /* Suspend, come back later */
+    }
+    /* Do final cleanup */
+//  (*cinfo.src.term_source) (cinfo);
+    /* We can use jpeg_abort to release memory and reset global_state */
+    jpeg_abort(cinfo);
+    return true;
+}
+
+
+static int jpeg_read_header (jpeg_decompress_struct cinfo, bool require_image) {
+    int retcode;
+
+    if (cinfo.global_state !is DSTATE_START && cinfo.global_state !is DSTATE_INHEADER)
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+
+    retcode = jpeg_consume_input(cinfo);
+
+    switch (retcode) {
+        case JPEG_REACHED_SOS:
+            retcode = JPEG_HEADER_OK;
+            break;
+        case JPEG_REACHED_EOI:
+            if (require_image)      /* Complain if application wanted an image */
+                error();
+//              ERREXIT(cinfo, JERR_NO_IMAGE);
+            /* Reset to start state; it would be safer to require the application to
+             * call jpeg_abort, but we can't change it now for compatibility reasons.
+             * A side effect is to free any temporary memory (there shouldn't be any).
+             */
+            jpeg_abort(cinfo); /* sets state = DSTATE_START */
+            retcode = JPEG_HEADER_TABLES_ONLY;
+            break;
+        case JPEG_SUSPENDED:
+            /* no work */
+            break;
+    }
+
+    return retcode;
+}
+
+static int dummy_consume_data (jpeg_decompress_struct cinfo) {
+    return JPEG_SUSPENDED;  /* Always indicate nothing was done */
+}
+
+static int consume_data (jpeg_decompress_struct cinfo) {
+    jpeg_d_coef_controller coef = cinfo.coef;
+    int MCU_col_num;    /* index of current MCU within row */
+    int blkn, ci, xindex, yindex, yoffset;
+    int start_col;
+//  short[][][][] buffer = new short[MAX_COMPS_IN_SCAN][][][];
+    short[][] buffer_ptr;
+    jpeg_component_info compptr;
+
+//  /* Align the virtual buffers for the components used in this scan. */
+//  for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+//      compptr = cinfo.cur_comp_info[ci];
+//      buffer[ci] = coef.whole_image[compptr.component_index];
+//      /* Note: entropy decoder expects buffer to be zeroed,
+//       * but this is handled automatically by the memory manager
+//       * because we requested a pre-zeroed array.
+//       */
+//  }
+
+    /* Loop to process one whole iMCU row */
+    for (yoffset = coef.MCU_vert_offset; yoffset < coef.MCU_rows_per_iMCU_row; yoffset++) {
+        for (MCU_col_num = coef.MCU_ctr; MCU_col_num < cinfo.MCUs_per_row; MCU_col_num++) {
+            /* Construct list of pointers to DCT blocks belonging to this MCU */
+            blkn = 0; /* index of current DCT block within MCU */
+            for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+                compptr = cinfo.cur_comp_info[ci];
+                start_col = MCU_col_num * compptr.MCU_width;
+                for (yindex = 0; yindex < compptr.MCU_height; yindex++) {
+//                  buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
+                    buffer_ptr = coef.whole_image[compptr.component_index][yindex+yoffset+cinfo.input_iMCU_row*compptr.v_samp_factor];
+                    int buffer_ptr_offset = start_col;
+                    for (xindex = 0; xindex < compptr.MCU_width; xindex++) {
+                        coef.MCU_buffer[blkn++] = buffer_ptr[buffer_ptr_offset++];
+                    }
+                }
+            }
+            /* Try to fetch the MCU. */
+            if (! cinfo.entropy.decode_mcu (cinfo, coef.MCU_buffer)) {
+                /* Suspension forced; update state counters and exit */
+                coef.MCU_vert_offset = yoffset;
+                coef.MCU_ctr = MCU_col_num;
+                return JPEG_SUSPENDED;
+            }
+        }
+        /* Completed an MCU row, but perhaps not an iMCU row */
+        coef.MCU_ctr = 0;
+    }
+    /* Completed the iMCU row, advance counters for next one */
+    if (++(cinfo.input_iMCU_row) < cinfo.total_iMCU_rows) {
+        coef.start_iMCU_row(cinfo);
+        return JPEG_ROW_COMPLETED;
+    }
+    /* Completed the scan */
+    finish_input_pass (cinfo);
+    return JPEG_SCAN_COMPLETED;
+}
+
+static int consume_input (jpeg_decompress_struct cinfo) {
+    switch (cinfo.inputctl.consume_input) {
+        case COEF_CONSUME_INPUT:
+             switch (cinfo.coef.consume_data) {
+                case CONSUME_DATA: return consume_data(cinfo);
+                case DUMMY_CONSUME_DATA: return dummy_consume_data(cinfo);
+                default: error();
+             }
+             break;
+        case INPUT_CONSUME_INPUT:
+            return consume_markers(cinfo);
+        default:
+            error();
+    }
+    return 0;   
+}
+
+static bool fill_input_buffer(jpeg_decompress_struct cinfo) {
+    try {
+        InputStream inputStream = cinfo.inputStream;
+        int nbytes = inputStream.read(cinfo.buffer);
+        if (nbytes <= 0) {
+            if (cinfo.start_of_file)    /* Treat empty input file as fatal error */
+                error();
+//              ERREXIT(cinfo, JERR_INPUT_EMPTY);
+//          WARNMS(cinfo, JWRN_JPEG_EOF);
+            /* Insert a fake EOI marker */
+            cinfo.buffer[0] = (byte)0xFF;
+            cinfo.buffer[1] = (byte)M_EOI;
+            nbytes = 2;
+        }
+        cinfo.bytes_in_buffer = nbytes;
+        cinfo.bytes_offset = 0;
+        cinfo.start_of_file = false;
+    } catch (IOException e) {
+        error(DWT.ERROR_IO);
+        return false;
+    }
+    return true;
+}
+
+static bool first_marker (jpeg_decompress_struct cinfo) {
+    /* Like next_marker, but used to obtain the initial SOI marker. */
+    /* For this marker, we do not allow preceding garbage or fill; otherwise,
+     * we might well scan an entire input file before realizing it ain't JPEG.
+     * If an application wants to process non-JFIF files, it must seek to the
+     * SOI before calling the JPEG library.
+     */
+    int c, c2;
+
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+    c2 = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+    if (c !is 0xFF || c2 !is M_SOI)
+        error();
+//      ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
+
+    cinfo.unread_marker = c2;
+
+    return true;
+}
+
+static bool next_marker (jpeg_decompress_struct cinfo) {
+    int c;
+
+    for (;;) {
+        if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+        c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        /* Skip any non-FF bytes.
+         * This may look a bit inefficient, but it will not occur in a valid file.
+         * We sync after each discarded byte so that a suspending data source
+         * can discard the byte from its buffer.
+         */
+        while (c !is 0xFF) {
+            cinfo.marker.discarded_bytes++;
+            if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+            c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        }
+        /* This loop swallows any duplicate FF bytes.   Extra FFs are legal as
+         * pad bytes, so don't count them in discarded_bytes.   We assume there
+         * will not be so many consecutive FF bytes as to overflow a suspending
+         * data source's input buffer.
+         */
+        do {
+             if (cinfo.bytes_offset is cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+                c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+        } while (c is 0xFF);
+        if (c !is 0)
+            break;          /* found a valid marker, exit loop */
+        /* Reach here if we found a stuffed-zero data sequence (FF/00).
+         * Discard it and loop back to try again.
+         */
+        cinfo.marker.discarded_bytes += 2;
+    }
+
+    if (cinfo.marker.discarded_bytes !is 0) {
+//      WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo.marker.discarded_bytes, c);
+        cinfo.marker.discarded_bytes = 0;
+    }
+
+    cinfo.unread_marker = c;
+
+    return true;
+}
+
+static int read_markers (jpeg_decompress_struct cinfo) {
+    /* Outer loop repeats once for each marker. */
+    for (;;) {
+        /* Collect the marker proper, unless we already did. */
+        /* NB: first_marker() enforces the requirement that SOI appear first. */
+        if (cinfo.unread_marker is 0) {
+            if (! cinfo.marker.saw_SOI) {
+                if (! first_marker(cinfo))
+                    return JPEG_SUSPENDED;
+                } else {
+                    if (! next_marker(cinfo))
+                        return JPEG_SUSPENDED;
+                }
+        }
+        /* At this point cinfo.unread_marker contains the marker code and the
+         * input point is just past the marker proper, but before any parameters.
+         * A suspension will cause us to return with this state still true.
+         */
+        switch (cinfo.unread_marker) {
+            case M_SOI:
+                if (! get_soi(cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+
+            case M_SOF0:        /* Baseline */
+            case M_SOF1:        /* Extended sequential, Huffman */
+                if (! get_sof(cinfo, false, false))
+                    return JPEG_SUSPENDED;
+                break;
+
+            case M_SOF2:        /* Progressive, Huffman */
+                if (! get_sof(cinfo, true, false))
+                    return JPEG_SUSPENDED;
+                break;
+
+            case M_SOF9:        /* Extended sequential, arithmetic */
+                if (! get_sof(cinfo, false, true))
+                    return JPEG_SUSPENDED;
+                break;
+
+            case M_SOF10:       /* Progressive, arithmetic */
+                if (! get_sof(cinfo, true, true))
+                    return JPEG_SUSPENDED;
+                break;
+
+            /* Currently unsupported SOFn types */
+            case M_SOF3:        /* Lossless, Huffman */
+            case M_SOF5:        /* Differential sequential, Huffman */
+            case M_SOF6:        /* Differential progressive, Huffman */
+            case M_SOF7:        /* Differential lossless, Huffman */
+            case M_JPG:         /* Reserved for JPEG extensions */
+            case M_SOF11:       /* Lossless, arithmetic */
+            case M_SOF13:       /* Differential sequential, arithmetic */
+            case M_SOF14:       /* Differential progressive, arithmetic */
+            case M_SOF15:       /* Differential lossless, arithmetic */
+                error();
+//              ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo.unread_marker);
+                break;
+
+            case M_SOS:
+                if (! get_sos(cinfo))
+                    return JPEG_SUSPENDED;
+                cinfo.unread_marker = 0;    /* processed the marker */
+                return JPEG_REACHED_SOS;
+    
+            case M_EOI:
+//              TRACEMS(cinfo, 1, JTRC_EOI);
+                cinfo.unread_marker = 0;    /* processed the marker */
+                return JPEG_REACHED_EOI;
+        
+            case M_DAC:
+                if (! get_dac(cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+        
+            case M_DHT:
+                if (! get_dht(cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+        
+            case M_DQT:
+                if (! get_dqt(cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+        
+            case M_DRI:
+                if (! get_dri(cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+        
+            case M_APP0:
+            case M_APP1:
+            case M_APP2:
+            case M_APP3:
+            case M_APP4:
+            case M_APP5:
+            case M_APP6:
+            case M_APP7:
+            case M_APP8:
+            case M_APP9:
+            case M_APP10:
+            case M_APP11:
+            case M_APP12:
+            case M_APP13:
+            case M_APP14:
+            case M_APP15:
+                if (! process_APPn(cinfo.unread_marker - M_APP0, cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+        
+            case M_COM:
+                if (! process_COM(cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+
+            case M_RST0:        /* these are all parameterless */
+            case M_RST1:
+            case M_RST2:
+            case M_RST3:
+            case M_RST4:
+            case M_RST5:
+            case M_RST6:
+            case M_RST7:
+            case M_TEM:
+//              TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo.unread_marker);
+                break;
+
+            case M_DNL:         /* Ignore DNL ... perhaps the wrong thing */
+                if (! skip_variable(cinfo))
+                    return JPEG_SUSPENDED;
+                break;
+
+            default:            /* must be DHP, EXP, JPGn, or RESn */
+                /* For now, we treat the reserved markers as fatal errors since they are
+                 * likely to be used to signal incompatible JPEG Part 3 extensions.
+                 * Once the JPEG 3 version-number marker is well defined, this code
+                 * ought to change!
+                 */
+                error();
+ //             ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo.unread_marker);
+                break;
+        }
+        /* Successfully processed marker, so reset state variable */
+        cinfo.unread_marker = 0;
+    } /* end loop */
+}
+
+static long jdiv_round_up (long a, long b)
+/* Compute a/b rounded up to next integer, ie, ceil(a/b) */
+/* Assumes a >= 0, b > 0 */
+{
+    return (a + b - 1) / b;
+}
+
+static void initial_setup (jpeg_decompress_struct cinfo)
+/* Called once, when first SOS marker is reached */
+{
+    int ci;
+    jpeg_component_info compptr;
+
+    /* Make sure image isn't bigger than I can handle */
+    if (cinfo.image_height >    JPEG_MAX_DIMENSION || cinfo.image_width > JPEG_MAX_DIMENSION)
+        error();
+//      ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
+
+    /* For now, precision must match compiled-in value... */
+    if (cinfo.data_precision !is BITS_IN_JSAMPLE)
+        error(" [data precision=" + cinfo.data_precision + "]");
+//      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo.data_precision);
+
+    /* Check that number of components won't exceed internal array sizes */
+    if (cinfo.num_components > MAX_COMPONENTS)
+        error();
+//      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo.num_components, MAX_COMPONENTS);
+
+    /* Compute maximum sampling factors; check factor validity */
+    cinfo.max_h_samp_factor = 1;
+    cinfo.max_v_samp_factor = 1;
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        if (compptr.h_samp_factor<=0 || compptr.h_samp_factor>MAX_SAMP_FACTOR || compptr.v_samp_factor<=0 || compptr.v_samp_factor>MAX_SAMP_FACTOR)
+            error();
+//          ERREXIT(cinfo, JERR_BAD_SAMPLING);
+        cinfo.max_h_samp_factor = Math.max(cinfo.max_h_samp_factor, compptr.h_samp_factor);
+        cinfo.max_v_samp_factor = Math.max(cinfo.max_v_samp_factor, compptr.v_samp_factor);
+    }
+
+    /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
+     * In the full decompressor, this will be overridden by jdmaster.c;
+     * but in the transcoder, jdmaster.c is not used, so we must do it here.
+     */
+    cinfo.min_DCT_scaled_size = DCTSIZE;
+
+    /* Compute dimensions of components */
+    for (ci = 0; ci < cinfo.num_components; ci++) {
+        compptr = cinfo.comp_info[ci];
+        compptr.DCT_scaled_size = DCTSIZE;
+        /* Size in DCT blocks */
+        compptr.width_in_blocks = (int)jdiv_round_up((long) cinfo.image_width * (long) compptr.h_samp_factor, (cinfo.max_h_samp_factor * DCTSIZE));
+        compptr.height_in_blocks = (int)jdiv_round_up((long) cinfo.image_height * (long) compptr.v_samp_factor, (cinfo.max_v_samp_factor * DCTSIZE));
+        /* downsampled_width and downsampled_height will also be overridden by
+         * jdmaster.c if we are doing full decompression.   The transcoder library
+         * doesn't use these values, but the calling application might.
+         */
+        /* Size in samples */
+        compptr.downsampled_width = (int)jdiv_round_up((long) cinfo.image_width * (long) compptr.h_samp_factor, cinfo.max_h_samp_factor);
+        compptr.downsampled_height = (int)jdiv_round_up((long) cinfo.image_height * (long) compptr.v_samp_factor, cinfo.max_v_samp_factor);
+        /* Mark component needed, until color conversion says otherwise */
+        compptr.component_needed = true;
+        /* Mark no quantization table yet saved for component */
+        compptr.quant_table = null;
+    }
+
+    /* Compute number of fully interleaved MCU rows. */
+    cinfo.total_iMCU_rows = (int)jdiv_round_up( cinfo.image_height, (cinfo.max_v_samp_factor*DCTSIZE));
+
+    /* Decide whether file contains multiple scans */
+    if (cinfo.comps_in_scan < cinfo.num_components || cinfo.progressive_mode)
+        cinfo.inputctl.has_multiple_scans = true;
+    else
+        cinfo.inputctl.has_multiple_scans = false;
+}
+
+
+static void per_scan_setup (jpeg_decompress_struct cinfo)
+/* Do computations that are needed before processing a JPEG scan */
+/* cinfo.comps_in_scan and cinfo.cur_comp_info[] were set from SOS marker */
+{
+    int ci, mcublks, tmp = 0;
+    jpeg_component_info compptr;
+    
+    if (cinfo.comps_in_scan is 1) {
+        
+        /* Noninterleaved (single-component) scan */
+        compptr = cinfo.cur_comp_info[0];
+        
+        /* Overall image size in MCUs */
+        cinfo.MCUs_per_row = compptr.width_in_blocks;
+        cinfo.MCU_rows_in_scan = compptr.height_in_blocks;
+        
+        /* For noninterleaved scan, always one block per MCU */
+        compptr.MCU_width = 1;
+        compptr.MCU_height = 1;
+        compptr.MCU_blocks = 1;
+        compptr.MCU_sample_width = compptr.DCT_scaled_size;
+        compptr.last_col_width = 1;
+        /* For noninterleaved scans, it is convenient to define last_row_height
+         * as the number of block rows present in the last iMCU row.
+         */
+        tmp = (compptr.height_in_blocks % compptr.v_samp_factor);
+        if (tmp is 0) tmp = compptr.v_samp_factor;
+        compptr.last_row_height = tmp;
+        
+        /* Prepare array describing MCU composition */
+        cinfo.blocks_in_MCU = 1;
+        cinfo.MCU_membership[0] = 0;
+        
+    } else {
+        
+        /* Interleaved (multi-component) scan */
+        if (cinfo.comps_in_scan <= 0 || cinfo.comps_in_scan > MAX_COMPS_IN_SCAN)
+            error();
+//          ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo.comps_in_scan, MAX_COMPS_IN_SCAN);
+        
+        /* Overall image size in MCUs */
+        cinfo.MCUs_per_row = (int)jdiv_round_up( cinfo.image_width, (cinfo.max_h_samp_factor*DCTSIZE));
+        cinfo.MCU_rows_in_scan = (int)jdiv_round_up( cinfo.image_height, (cinfo.max_v_samp_factor*DCTSIZE));
+        
+        cinfo.blocks_in_MCU = 0;
+        
+        for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+            compptr = cinfo.cur_comp_info[ci];
+            /* Sampling factors give # of blocks of component in each MCU */
+            compptr.MCU_width = compptr.h_samp_factor;
+            compptr.MCU_height = compptr.v_samp_factor;
+            compptr.MCU_blocks = compptr.MCU_width * compptr.MCU_height;
+            compptr.MCU_sample_width = compptr.MCU_width * compptr.DCT_scaled_size;
+            /* Figure number of non-dummy blocks in last MCU column & row */
+            tmp = (compptr.width_in_blocks % compptr.MCU_width);
+            if (tmp is 0) tmp = compptr.MCU_width;
+            compptr.last_col_width = tmp;
+            tmp = (compptr.height_in_blocks % compptr.MCU_height);
+            if (tmp is 0) tmp = compptr.MCU_height;
+            compptr.last_row_height = tmp;
+            /* Prepare array describing MCU composition */
+            mcublks = compptr.MCU_blocks;
+            if (cinfo.blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
+                error();
+//  ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
+            while (mcublks-- > 0) {
+                cinfo.MCU_membership[cinfo.blocks_in_MCU++] = ci;
+            }
+        }
+        
+    }
+}
+
+static void latch_quant_tables (jpeg_decompress_struct cinfo) {
+    int ci, qtblno;
+    jpeg_component_info compptr;
+    JQUANT_TBL qtbl;
+
+    for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+        compptr = cinfo.cur_comp_info[ci];
+        /* No work if we already saved Q-table for this component */
+        if (compptr.quant_table !is null)
+            continue;
+        /* Make sure specified quantization table is present */
+        qtblno = compptr.quant_tbl_no;
+        if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || cinfo.quant_tbl_ptrs[qtblno] is null)
+            error();
+//          ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
+        /* OK, save away the quantization table */
+        qtbl = new JQUANT_TBL();
+        System.arraycopy(cinfo.quant_tbl_ptrs[qtblno].quantval, 0, qtbl.quantval, 0, qtbl.quantval.length);
+        qtbl.sent_table = cinfo.quant_tbl_ptrs[qtblno].sent_table;
+        compptr.quant_table = qtbl;
+    }
+}
+
+static void jpeg_make_d_derived_tbl (jpeg_decompress_struct cinfo, bool isDC, int tblno, d_derived_tbl dtbl) {
+    JHUFF_TBL htbl;
+    int p, i = 0, l, si, numsymbols;
+    int lookbits, ctr;
+    byte[] huffsize = new byte[257];
+    int[] huffcode = new int[257];
+    int code;
+
+    /* Note that huffsize[] and huffcode[] are filled in code-length order,
+     * paralleling the order of the symbols themselves in htbl.huffval[].
+     */
+
+    /* Find the input Huffman table */
+    if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
+        error();
+//      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
+    htbl = isDC ? cinfo.dc_huff_tbl_ptrs[tblno] : cinfo.ac_huff_tbl_ptrs[tblno];
+    if (htbl is null)
+        error();
+//      ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
+
+    /* Allocate a workspace if we haven't already done so. */
+    dtbl.pub = htbl;        /* fill in back link */
+    
+    /* Figure C.1: make table of Huffman code length for each symbol */
+
+    p = 0;
+    for (l = 1; l <= 16; l++) {
+        i = htbl.bits[l] & 0xFF;
+        if (i < 0 || p + i > 256)   /* protect against table overrun */
+            error();
+//          ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+        while (i-- !is 0)
+            huffsize[p++] = (byte) l;
+    }
+    huffsize[p] = 0;
+    numsymbols = p;
+    
+    /* Figure C.2: generate the codes themselves */
+    /* We also validate that the counts represent a legal Huffman code tree. */
+    
+    code = 0;
+    si = huffsize[0];
+    p = 0;
+    while ((huffsize[p]) !is 0) {
+        while (( huffsize[p]) is si) {
+            huffcode[p++] = code;
+            code++;
+        }
+        /* code is now 1 more than the last code used for codelength si; but
+         * it must still fit in si bits, since no code is allowed to be all ones.
+         */
+        if (( code) >= (( 1) << si))
+            error();
+//          ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+        code <<= 1;
+        si++;
+    }
+
+    /* Figure F.15: generate decoding tables for bit-sequential decoding */
+
+    p = 0;
+    for (l = 1; l <= 16; l++) {
+        if ((htbl.bits[l] & 0xFF) !is 0) {
+            /* valoffset[l] = huffval[] index of 1st symbol of code length l,
+             * minus the minimum code of length l
+             */
+            dtbl.valoffset[l] = p - huffcode[p];
+            p += (htbl.bits[l] & 0xFF);
+            dtbl.maxcode[l] = huffcode[p-1]; /* maximum code of length l */
+        } else {
+            dtbl.maxcode[l] = -1;   /* -1 if no codes of this length */
+        }
+    }
+    dtbl.maxcode[17] = 0xFFFFF; /* ensures jpeg_huff_decode terminates */
+
+    /* Compute lookahead tables to speed up decoding.
+     * First we set all the table entries to 0, indicating "too long";
+     * then we iterate through the Huffman codes that are short enough and
+     * fill in all the entries that correspond to bit sequences starting
+     * with that code.
+     */
+
+    for (int j = 0; j < dtbl.look_nbits.length; j++) {
+        dtbl.look_nbits[j] = 0;
+    }
+
+    p = 0;
+    for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
+        for (i = 1; i <= (htbl.bits[l] & 0xFF); i++, p++) {
+            /* l = current code's length, p = its index in huffcode[] & huffval[]. */
+            /* Generate left-justified code followed by all possible bit sequences */
+            lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
+            for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
+                dtbl.look_nbits[lookbits] = l;
+                dtbl.look_sym[lookbits] = htbl.huffval[p];
+                lookbits++;
+            }
+        }
+    }
+
+    /* Validate symbols as being reasonable.
+     * For AC tables, we make no check, but accept all byte values 0..255.
+     * For DC tables, we require the symbols to be in range 0..15.
+     * (Tighter bounds could be applied depending on the data depth and mode,
+     * but this is sufficient to ensure safe decoding.)
+     */
+    if (isDC) {
+        for (i = 0; i < numsymbols; i++) {
+            int sym = htbl.huffval[i] & 0xFF;
+            if (sym < 0 || sym > 15)
+                error();
+//              ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+        }
+    }
+}
+
+static void start_input_pass (jpeg_decompress_struct cinfo) {
+    per_scan_setup(cinfo);
+    latch_quant_tables(cinfo);
+    cinfo.entropy.start_pass(cinfo);
+    cinfo.coef.start_input_pass (cinfo);
+    cinfo.inputctl.consume_input = COEF_CONSUME_INPUT;
+}
+
+static void finish_input_pass (jpeg_decompress_struct cinfo) {
+    cinfo.inputctl.consume_input = INPUT_CONSUME_INPUT;
+}
+
+static int consume_markers (jpeg_decompress_struct cinfo) {
+    jpeg_input_controller inputctl = cinfo.inputctl;
+    int val;
+
+    if (inputctl.eoi_reached) /* After hitting EOI, read no further */
+        return JPEG_REACHED_EOI;
+
+    val = read_markers (cinfo);
+
+    switch (val) {
+    case JPEG_REACHED_SOS:  /* Found SOS */
+        if (inputctl.inheaders) {   /* 1st SOS */
+            initial_setup(cinfo);
+            inputctl.inheaders = false;
+            /* Note: start_input_pass must be called by jdmaster.c
+             * before any more input can be consumed.   jdapimin.c is
+             * responsible for enforcing this sequencing.
+             */
+        } else {            /* 2nd or later SOS marker */
+            if (! inputctl.has_multiple_scans)
+                error();
+//              ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
+            start_input_pass(cinfo);
+        }
+        break;
+    case JPEG_REACHED_EOI:  /* Found EOI */
+        inputctl.eoi_reached = true;
+        if (inputctl.inheaders) {   /* Tables-only datastream, apparently */
+            if (cinfo.marker.saw_SOF)
+                error();
+//              ERREXIT(cinfo, JERR_SOF_NO_SOS);
+        } else {
+            /* Prevent infinite loop in coef ctlr's decompress_data routine
+             * if user set output_scan_number larger than number of scans.
+             */
+            if (cinfo.output_scan_number > cinfo.input_scan_number)
+                cinfo.output_scan_number = cinfo.input_scan_number;
+        }
+        break;
+    case JPEG_SUSPENDED:
+        break;
+    }
+
+    return val;
+}
+
+static void default_decompress_parms (jpeg_decompress_struct cinfo) {
+    /* Guess the input colorspace, and set output colorspace accordingly. */
+    /* (Wish JPEG committee had provided a real way to specify this...) */
+    /* Note application may override our guesses. */
+    switch (cinfo.num_components) {
+        case 1:
+            cinfo.jpeg_color_space = JCS_GRAYSCALE;
+            cinfo.out_color_space = JCS_GRAYSCALE;
+            break;
+            
+        case 3:
+            if (cinfo.saw_JFIF_marker) {
+                cinfo.jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
+            } else if (cinfo.saw_Adobe_marker) {
+                switch (cinfo.Adobe_transform) {
+                    case 0:
+                        cinfo.jpeg_color_space = JCS_RGB;
+                        break;
+                    case 1:
+                        cinfo.jpeg_color_space = JCS_YCbCr;
+                        break;
+                    default:    
+//                      WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo.Adobe_transform);
+                        cinfo.jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
+                    break;
+                }
+            } else {
+                /* Saw no special markers, try to guess from the component IDs */
+                int cid0 = cinfo.comp_info[0].component_id;
+                int cid1 = cinfo.comp_info[1].component_id;
+                int cid2 = cinfo.comp_info[2].component_id;
+    
+                if (cid0 is 1 && cid1 is 2 && cid2 is 3)
+                    cinfo.jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
+                else if (cid0 is 82 && cid1 is 71 && cid2 is 66)
+                    cinfo.jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
+                else {
+//                  TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
+                    cinfo.jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
+                }
+            }
+            /* Always guess RGB is proper output colorspace. */
+            cinfo.out_color_space = JCS_RGB;
+            break;
+            
+        case 4:
+            if (cinfo.saw_Adobe_marker) {
+                switch (cinfo.Adobe_transform) {
+                    case 0:
+                        cinfo.jpeg_color_space = JCS_CMYK;
+                        break;
+                    case 2:
+                        cinfo.jpeg_color_space = JCS_YCCK;
+                        break;
+                    default:
+//                      WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo.Adobe_transform);
+                        cinfo.jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
+                        break;
+                }
+            } else {
+                /* No special markers, assume straight CMYK. */
+                cinfo.jpeg_color_space = JCS_CMYK;
+            }
+            cinfo.out_color_space = JCS_CMYK;
+            break;
+            
+        default:
+            cinfo.jpeg_color_space = JCS_UNKNOWN;
+            cinfo.out_color_space = JCS_UNKNOWN;
+            break;
+    }
+
+    /* Set defaults for other decompression parameters. */
+    cinfo.scale_num = 1;        /* 1:1 scaling */
+    cinfo.scale_denom = 1;
+    cinfo.output_gamma = 1.0;
+    cinfo.buffered_image = false;
+    cinfo.raw_data_out = false;
+    cinfo.dct_method = JDCT_DEFAULT;
+    cinfo.do_fancy_upsampling = true;
+    cinfo.do_block_smoothing = true;
+    cinfo.quantize_colors = false;
+    /* We set these in case application only sets quantize_colors. */
+    cinfo.dither_mode = JDITHER_FS;
+    cinfo.two_pass_quantize = true;
+    cinfo.desired_number_of_colors = 256;
+    cinfo.colormap = null;
+    /* Initialize for no mode change in buffered-image mode. */
+    cinfo.enable_1pass_quant = false;
+    cinfo.enable_external_quant = false;
+    cinfo.enable_2pass_quant = false;
+}
+
+static void init_source(jpeg_decompress_struct cinfo) {
+    cinfo.buffer = new byte[INPUT_BUFFER_SIZE];
+    cinfo.bytes_in_buffer = 0;
+    cinfo.bytes_offset = 0;
+    cinfo.start_of_file = true;
+}
+
+static int jpeg_consume_input (jpeg_decompress_struct cinfo) {
+    int retcode = JPEG_SUSPENDED;
+
+    /* NB: every possible DSTATE value should be listed in this switch */
+    switch (cinfo.global_state) {
+    case DSTATE_START:
+        /* Start-of-datastream actions: reset appropriate modules */
+        reset_input_controller(cinfo);
+        /* Initialize application's data source module */
+        init_source (cinfo);
+        cinfo.global_state = DSTATE_INHEADER;
+        /*FALLTHROUGH*/
+    case DSTATE_INHEADER:
+        retcode = consume_input(cinfo);
+        if (retcode is JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */
+            /* Set up default parameters based on header data */
+            default_decompress_parms(cinfo);
+            /* Set global state: ready for start_decompress */
+            cinfo.global_state = DSTATE_READY;
+        }
+        break;
+    case DSTATE_READY:
+        /* Can't advance past first SOS until start_decompress is called */
+        retcode = JPEG_REACHED_SOS;
+        break;
+    case DSTATE_PRELOAD:
+    case DSTATE_PRESCAN:
+    case DSTATE_SCANNING:
+    case DSTATE_RAW_OK:
+    case DSTATE_BUFIMAGE:
+    case DSTATE_BUFPOST:
+    case DSTATE_STOPPING:
+        retcode = consume_input (cinfo);
+        break;
+    default:
+        error();
+//      ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+    }
+    return retcode;
+}
+
+
+static void jpeg_abort (jpeg_decompress_struct cinfo) {
+//  int pool;
+//
+//  /* Releasing pools in reverse order might help avoid fragmentation
+//   * with some (brain-damaged) malloc libraries.
+//   */
+//  for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
+//      (*cinfo.mem.free_pool) (cinfo, pool);
+//  }
+
+    /* Reset overall state for possible reuse of object */
+    if (cinfo.is_decompressor) {
+        cinfo.global_state = DSTATE_START;
+        /* Try to keep application from accessing now-deleted marker list.
+         * A bit kludgy to do it here, but this is the most central place.
+         */
+//      ((j_decompress_ptr) cinfo).marker_list = null;
+    } else {
+        cinfo.global_state = CSTATE_START;
+    }
+}
+
+
+static bool isFileFormat(LEDataInputStream stream) {
+    try {
+        byte[] buffer = new byte[2];
+        stream.read(buffer);
+        stream.unread(buffer);
+        return (buffer[0] & 0xFF) is 0xFF && (buffer[1] & 0xFF) is M_SOI;
+    } catch (Exception e) {
+        return false;
+    }
+}
+    
+static ImageData[] loadFromByteStream(InputStream inputStream, ImageLoader loader) {
+    jpeg_decompress_struct cinfo = new jpeg_decompress_struct();
+    cinfo.inputStream = inputStream;
+    jpeg_create_decompress(cinfo);
+    jpeg_read_header(cinfo, true);
+    cinfo.buffered_image = cinfo.progressive_mode && loader.hasListeners();
+    jpeg_start_decompress(cinfo);
+    PaletteData palette = null;
+    switch (cinfo.out_color_space) {
+        case JCS_RGB:
+            palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+            break;
+        case JCS_GRAYSCALE:
+            RGB[] colors = new RGB[256];
+            for (int i = 0; i < colors.length; i++) {
+                colors[i] = new RGB(i, i, i);
+            }
+            palette = new PaletteData(colors);
+            break;
+        default:
+            error();
+    }
+    int scanlinePad = 4;
+    int row_stride = (((cinfo.output_width * cinfo.out_color_components * 8 + 7) / 8) + (scanlinePad - 1)) / scanlinePad * scanlinePad;
+    byte[][] buffer = new byte[1][row_stride];
+    byte[] data = new byte[row_stride * cinfo.output_height];
+    ImageData imageData = ImageData.internal_new(
+            cinfo.output_width, cinfo.output_height, palette.isDirect ? 24 : 8, palette, scanlinePad, data,
+            0, null, null, -1, -1, DWT.IMAGE_JPEG, 0, 0, 0, 0);
+    if (cinfo.buffered_image) {
+        bool done;
+        do {
+            int incrementCount = cinfo.input_scan_number - 1;
+            jpeg_start_output(cinfo, cinfo.input_scan_number);
+            while (cinfo.output_scanline < cinfo.output_height) {
+                int offset = row_stride * cinfo.output_scanline;
+                jpeg_read_scanlines(cinfo, buffer, 1);
+                System.arraycopy(buffer[0], 0, data, offset, row_stride);
+            }
+            jpeg_finish_output(cinfo);
+            loader.notifyListeners(new ImageLoaderEvent(loader, (ImageData)imageData.clone(), incrementCount, done = jpeg_input_complete(cinfo)));
+        } while (!done);
+    } else {
+        while (cinfo.output_scanline < cinfo.output_height) {
+            int offset = row_stride * cinfo.output_scanline;
+            jpeg_read_scanlines(cinfo, buffer, 1);
+            System.arraycopy(buffer[0], 0, data, offset, row_stride);
+        }
+    }
+    jpeg_finish_decompress(cinfo);
+    jpeg_destroy_decompress(cinfo);
+    return new ImageData[]{imageData};
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGEndOfImage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class JPEGEndOfImage : JPEGFixedSizeSegment {
+
+    public JPEGEndOfImage() {
+        super();
+    }
+    
+    public JPEGEndOfImage(byte[] reference) {
+        super(reference);
+    }
+    
+    public int signature() {
+        return JPEGFileFormat.EOI;
+    }
+    
+    public int fixedSize() {
+        return 2;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGFileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1887 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved.  This source file is made available under the terms contained in the README file
+ * accompanying this program.  The README file should be located in the about_files directory of the
+ * plug-in that contains this source file.
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.ImageLoaderEvent;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+
+public final class JPEGFileFormat : FileFormat {
+    int restartInterval;
+    JPEGFrameHeader frameHeader;
+    int imageWidth, imageHeight;
+    int interleavedMcuCols, interleavedMcuRows;
+    int maxV, maxH;
+    bool progressive;
+    int samplePrecision;
+    int nComponents;
+    int[][] frameComponents;
+    int[] componentIds;
+    byte[][] imageComponents;
+    int[] dataUnit;
+    int[][][] dataUnits;
+    int[] precedingDCs;
+    JPEGScanHeader scanHeader;
+    byte[] dataBuffer;
+    int currentBitCount;
+    int bufferCurrentPosition;
+    int restartsToGo;
+    int nextRestartNumber;
+    JPEGHuffmanTable[] acHuffmanTables;
+    JPEGHuffmanTable[] dcHuffmanTables;
+    int[][] quantizationTables;
+    int currentByte;
+    int encoderQFactor = 75;
+    int eobrun = 0;
+    /* JPEGConstants */
+    public static final int DCTSIZE = 8;
+    public static final int DCTSIZESQR = 64;
+    /* JPEGFixedPointConstants */
+    public static final int FIX_0_899976223 = 7373;
+    public static final int FIX_1_961570560 = 16069;
+    public static final int FIX_2_053119869 = 16819;
+    public static final int FIX_0_298631336 = 2446;
+    public static final int FIX_1_847759065 = 15137;
+    public static final int FIX_1_175875602 = 9633;
+    public static final int FIX_3_072711026 = 25172;
+    public static final int FIX_0_765366865 = 6270;
+    public static final int FIX_2_562915447 = 20995;
+    public static final int FIX_0_541196100 = 4433;
+    public static final int FIX_0_390180644 = 3196;
+    public static final int FIX_1_501321110 = 12299;
+    /* JPEGMarkerCodes */
+    public static final int APP0  = 0xFFE0;
+    public static final int APP15 = 0xFFEF;
+    public static final int COM   = 0xFFFE;
+    public static final int DAC   = 0xFFCC;
+    public static final int DHP   = 0xFFDE;
+    public static final int DHT   = 0xFFC4;
+    public static final int DNL   = 0xFFDC;
+    public static final int DRI   = 0xFFDD;
+    public static final int DQT   = 0xFFDB;
+    public static final int EOI   = 0xFFD9;
+    public static final int EXP   = 0xFFDF;
+    public static final int JPG   = 0xFFC8;
+    public static final int JPG0  = 0xFFF0;
+    public static final int JPG13 = 0xFFFD;
+    public static final int RST0  = 0xFFD0;
+    public static final int RST1  = 0xFFD1;
+    public static final int RST2  = 0xFFD2;
+    public static final int RST3  = 0xFFD3;
+    public static final int RST4  = 0xFFD4;
+    public static final int RST5  = 0xFFD5;
+    public static final int RST6  = 0xFFD6;
+    public static final int RST7  = 0xFFD7;
+    public static final int SOF0  = 0xFFC0;
+    public static final int SOF1  = 0xFFC1;
+    public static final int SOF2  = 0xFFC2;
+    public static final int SOF3  = 0xFFC3;
+    public static final int SOF5  = 0xFFC5;
+    public static final int SOF6  = 0xFFC6;
+    public static final int SOF7  = 0xFFC7;
+    public static final int SOF9  = 0xFFC9;
+    public static final int SOF10 = 0xFFCA;
+    public static final int SOF11 = 0xFFCB;
+    public static final int SOF13 = 0xFFCD;
+    public static final int SOF14 = 0xFFCE;
+    public static final int SOF15 = 0xFFCF;
+    public static final int SOI   = 0xFFD8;
+    public static final int SOS   = 0xFFDA;
+    public static final int TEM   = 0xFF01;
+    /* JPEGFrameComponentParameterConstants */
+    public static final int TQI = 0;
+    public static final int HI  = 1;
+    public static final int VI  = 2;
+    public static final int CW  = 3;
+    public static final int CH  = 4;
+    /* JPEGScanComponentParameterConstants */
+    public static final int DC  = 0;
+    public static final int AC  = 1;
+    /* JFIF Component Constants */
+    public static final int ID_Y        = 1 - 1;
+    public static final int ID_CB   = 2 - 1;
+    public static final int ID_CR   = 3 - 1;
+    public static final RGB[] RGB16 = new RGB[] {
+        new RGB(0,0,0),
+        new RGB(0x80,0,0),
+        new RGB(0,0x80,0),
+        new RGB(0x80,0x80,0),
+        new RGB(0,0,0x80),
+        new RGB(0x80,0,0x80),
+        new RGB(0,0x80,0x80),
+        new RGB(0xC0,0xC0,0xC0),
+        new RGB(0x80,0x80,0x80),
+        new RGB(0xFF,0,0),
+        new RGB(0,0xFF,0),
+        new RGB(0xFF,0xFF,0),
+        new RGB(0,0,0xFF),
+        new RGB(0xFF,0,0xFF),
+        new RGB(0,0xFF,0xFF),
+        new RGB(0xFF,0xFF,0xFF),
+    };
+    public static final int[] ExtendTest = {
+        0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 
+        4096, 8192, 16384, 32768, 65536, 131072, 262144
+    };
+    public static final int[] ExtendOffset = new int[] {
+        0, -1, -3, -7, -15, -31, -63, -127, -255, -511, -1023, -2047, 
+        -4095, -8191, -16383, -32767, -65535, -131071, -262143
+    };
+    public static final int[] ZigZag8x8 = {
+        0, 1, 8, 16, 9, 2, 3, 10,
+        17, 24, 32, 25, 18, 11, 4, 5,
+        12, 19, 26, 33, 40, 48, 41, 34,
+        27, 20, 13, 6, 7, 14, 21, 28,
+        35, 42, 49, 56, 57, 50, 43, 36,
+        29, 22, 15, 23, 30, 37, 44, 51,
+        58, 59, 52, 45, 38, 31, 39, 46,
+        53, 60, 61, 54, 47, 55, 62, 63
+    };
+
+    public static final int[] CrRTable, CbBTable, CrGTable, CbGTable;
+    public static final int[] RYTable, GYTable, BYTable,
+        RCbTable, GCbTable, BCbTable, RCrTable, GCrTable, BCrTable, NBitsTable;
+    static {
+        /* Initialize RGB-YCbCr Tables */
+        int [] rYTable = new int[256];
+        int [] gYTable = new int[256];
+        int [] bYTable = new int[256];
+        int [] rCbTable = new int[256];
+        int [] gCbTable = new int[256];
+        int [] bCbTable = new int[256];
+        int [] gCrTable = new int[256];
+        int [] bCrTable = new int[256];
+        for (int i = 0; i < 256; i++) {
+            rYTable[i] = i * 19595;
+            gYTable[i] = i * 38470;
+            bYTable[i] = i * 7471 + 32768;
+            rCbTable[i] = i * -11059;
+            gCbTable[i] = i * -21709;
+            bCbTable[i] = i * 32768 + 8388608;
+            gCrTable[i] = i * -27439;
+            bCrTable[i] = i * -5329;
+        }
+        RYTable = rYTable;
+        GYTable = gYTable;
+        BYTable = bYTable;
+        RCbTable = rCbTable;
+        GCbTable = gCbTable;
+        BCbTable = bCbTable;
+        RCrTable = bCbTable;
+        GCrTable = gCrTable;
+        BCrTable = bCrTable;
+
+        /* Initialize YCbCr-RGB Tables */
+        int [] crRTable = new int[256];
+        int [] cbBTable = new int[256];
+        int [] crGTable = new int[256];
+        int [] cbGTable = new int[256];
+        for (int i = 0; i < 256; i++) {
+            int x2 = 2 * i - 255;
+            crRTable[i] = (45941 * x2 + 32768) >> 16;
+            cbBTable[i] = (58065 * x2 + 32768) >> 16;
+            crGTable[i] = -23401 * x2;
+            cbGTable[i] = -11277 * x2 + 32768;
+        }
+        CrRTable = crRTable;
+        CbBTable = cbBTable;
+        CrGTable = crGTable;
+        CbGTable = cbGTable;
+
+        /* Initialize BitCount Table */
+        int nBits = 1;
+        int power2 = 2;
+        int [] nBitsTable = new int[2048];
+        nBitsTable[0] = 0;
+        for (int i = 1; i < nBitsTable.length; i++) {
+            if (!(i < power2)) {
+                nBits++;
+                power2 *= 2;
+            }
+            nBitsTable[i] = nBits;
+        }
+        NBitsTable = nBitsTable;
+    }
+void compress(ImageData image, byte[] dataYComp, byte[] dataCbComp, byte[] dataCrComp) {
+    int srcWidth = image.width;
+    int srcHeight = image.height;
+    int vhFactor = maxV * maxH;
+    int[] frameComponent;
+    imageComponents = new byte[nComponents][];
+    for (int i = 0; i < nComponents; i++) {
+        frameComponent = frameComponents[componentIds[i]];
+        imageComponents[i] = new byte[frameComponent[CW] * frameComponent[CH]];
+    }
+    frameComponent = frameComponents[componentIds[ID_Y]];
+    for (int yPos = 0; yPos < srcHeight; yPos++) {
+        int srcOfs = yPos * srcWidth;
+        int dstOfs = yPos * frameComponent[CW];
+        System.arraycopy(dataYComp, srcOfs, imageComponents[ID_Y], dstOfs, srcWidth);
+    }
+    frameComponent = frameComponents[componentIds[ID_CB]];
+    for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
+        int destRowIndex = yPos * frameComponent[CW];
+        for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
+            int sum = 0;
+            for (int iv = 0; iv < maxV; iv++) {
+                int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
+                for (int ih = 0; ih < maxH; ih++) {
+                    sum += dataCbComp[srcIndex + ih] & 0xFF;
+                }
+            }
+            imageComponents[ID_CB][destRowIndex + xPos] = (byte)(sum / vhFactor);
+        }
+    }
+    frameComponent = frameComponents[componentIds[ID_CR]];
+    for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
+        int destRowIndex = yPos * frameComponent[CW];
+        for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
+            int sum = 0;
+            for (int iv = 0; iv < maxV; iv++) {
+                int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
+                for (int ih = 0; ih < maxH; ih++) {
+                    sum += dataCrComp[srcIndex + ih] & 0xFF;
+                }
+            }
+            imageComponents[ID_CR][destRowIndex + xPos] = (byte)(sum / vhFactor);
+        }
+    }
+    for (int iComp = 0; iComp < nComponents; iComp++) {
+        byte[] imageComponent = imageComponents[iComp];
+        frameComponent = frameComponents[componentIds[iComp]];
+        int hFactor = frameComponent[HI];
+        int vFactor = frameComponent[VI];
+        int componentWidth = frameComponent[CW];
+        int componentHeight = frameComponent[CH];
+        int compressedWidth = srcWidth / (maxH / hFactor);
+        int compressedHeight = srcHeight / (maxV / vFactor);
+        if (compressedWidth < componentWidth) {
+            int delta = componentWidth - compressedWidth;
+            for (int yPos = 0; yPos < compressedHeight; yPos++) {
+                int dstOfs = ((yPos + 1) * componentWidth - delta);
+                int dataValue = imageComponent[(dstOfs > 0) ? dstOfs - 1 : 0] & 0xFF;
+                for (int i = 0; i < delta; i++) {
+                    imageComponent[dstOfs + i] = (byte)dataValue;
+                }
+            }
+        }
+        if (compressedHeight < componentHeight) {
+            int srcOfs = (compressedHeight > 0) ? (compressedHeight - 1) * componentWidth : 1;
+            for (int yPos = (compressedHeight > 0) ? compressedHeight : 1; yPos <= componentHeight; yPos++) {
+                int dstOfs = (yPos - 1) * componentWidth;
+                System.arraycopy(imageComponent, srcOfs, imageComponent, dstOfs, componentWidth);
+            }
+        }
+    }
+}
+void convert4BitRGBToYCbCr(ImageData image) {
+    RGB[] rgbs = image.getRGBs();
+    int paletteSize = rgbs.length;
+    byte[] yComp = new byte[paletteSize];
+    byte[] cbComp = new byte[paletteSize];
+    byte[] crComp = new byte[paletteSize];
+    int srcWidth = image.width;
+    int srcHeight = image.height;
+    for (int i = 0; i < paletteSize; i++) {
+        RGB color = rgbs[i];
+        int r = color.red;
+        int g = color.green;
+        int b = color.blue;
+        int n = RYTable[r] + GYTable[g] + BYTable[b];
+        yComp[i] = (byte)(n >> 16);
+        if ((n < 0) && ((n & 0xFFFF) !is 0)) yComp[i]--;
+        n = RCbTable[r] + GCbTable[g] + BCbTable[b];
+        cbComp[i] = (byte)(n >> 16);
+        if ((n < 0) && ((n & 0xFFFF) !is 0)) cbComp[i]--;
+        n = RCrTable[r] + GCrTable[g] + BCrTable[b];
+        crComp[i] = (byte)(n >> 16);
+        if ((n < 0) && ((n & 0xFFFF) !is 0)) crComp[i]--;
+    }
+    int bSize = srcWidth * srcHeight;
+    byte[] dataYComp = new byte[bSize];
+    byte[] dataCbComp = new byte[bSize];
+    byte[] dataCrComp = new byte[bSize];
+    byte[] origData = image.data;
+    int bytesPerLine = image.bytesPerLine;
+    int maxScanlineByte = srcWidth >> 1;
+    for (int yPos = 0; yPos < srcHeight; yPos++) {
+        for (int xPos = 0; xPos < maxScanlineByte; xPos++) {
+            int srcIndex = yPos * bytesPerLine + xPos;
+            int dstIndex = yPos * srcWidth + (xPos * 2);
+            int value2 = origData[srcIndex] & 0xFF;
+            int value1 = value2 >> 4;
+            value2 &= 0x0F;
+            dataYComp[dstIndex] = yComp[value1];
+            dataCbComp[dstIndex] = cbComp[value1];
+            dataCrComp[dstIndex] = crComp[value1];
+            dataYComp[dstIndex + 1] = yComp[value2];
+            dataCbComp[dstIndex + 1] = cbComp[value2];
+            dataCrComp[dstIndex + 1] = crComp[value2];
+        }
+    }
+    compress(image, dataYComp, dataCbComp, dataCrComp);
+}
+void convert8BitRGBToYCbCr(ImageData image) {
+    RGB[] rgbs = image.getRGBs();
+    int paletteSize = rgbs.length;
+    byte[] yComp = new byte[paletteSize];
+    byte[] cbComp = new byte[paletteSize];
+    byte[] crComp = new byte[paletteSize];
+    int srcWidth = image.width;
+    int srcHeight = image.height;
+    for (int i = 0; i < paletteSize; i++) {
+        RGB color = rgbs[i];
+        int r = color.red;
+        int g = color.green;
+        int b = color.blue;
+        int n = RYTable[r] + GYTable[g] + BYTable[b];
+        yComp[i] = (byte)(n >> 16);
+        if ((n < 0) && ((n & 0xFFFF) !is 0)) yComp[i]--;
+        n = RCbTable[r] + GCbTable[g] + BCbTable[b];
+        cbComp[i] = (byte)(n >> 16);
+        if ((n < 0) && ((n & 0xFFFF) !is 0)) cbComp[i]--;
+        n = RCrTable[r] + GCrTable[g] + BCrTable[b];
+        crComp[i] = (byte)(n >> 16);
+        if ((n < 0) && ((n & 0xFFFF) !is 0)) crComp[i]--;
+    }
+    int dstWidth = image.width;
+    int dstHeight = srcHeight;
+    int stride = ((srcWidth + 3) >> 2) << 2;
+    int bSize = dstWidth * dstHeight;
+    byte[] dataYComp = new byte[bSize];
+    byte[] dataCbComp = new byte[bSize];
+    byte[] dataCrComp = new byte[bSize];
+    byte[] origData = image.data;
+    for (int yPos = 0; yPos < srcHeight; yPos++) {
+        int srcRowIndex = yPos * stride;
+        int dstRowIndex = yPos * dstWidth;
+        for (int xPos = 0; xPos < srcWidth; xPos++) {
+            int value = origData[srcRowIndex + xPos] & 0xFF;
+            int dstIndex = dstRowIndex + xPos;
+            dataYComp[dstIndex] = yComp[value];
+            dataCbComp[dstIndex] = cbComp[value];
+            dataCrComp[dstIndex] = crComp[value];
+        }
+    }
+    compress(image, dataYComp, dataCbComp, dataCrComp);
+}
+byte[] convertCMYKToRGB() {
+    /* Unsupported CMYK format. Answer an empty byte array. */
+    return new byte[0];
+}
+void convertImageToYCbCr(ImageData image) {
+    switch (image.depth) {
+        case 4:
+            convert4BitRGBToYCbCr(image);
+            return;
+        case 8:
+            convert8BitRGBToYCbCr(image);
+            return;
+        case 16:
+        case 24:
+        case 32:
+            convertMultiRGBToYCbCr(image);
+            return;
+        default:
+            DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+    }
+    return;
+}
+void convertMultiRGBToYCbCr(ImageData image) {
+    int srcWidth = image.width;
+    int srcHeight = image.height;
+    int bSize = srcWidth * srcHeight;
+    byte[] dataYComp = new byte[bSize];
+    byte[] dataCbComp = new byte[bSize];
+    byte[] dataCrComp = new byte[bSize];
+    PaletteData palette = image.palette;
+    int[] buffer = new int[srcWidth];
+    if (palette.isDirect) {
+        int redMask = palette.redMask;
+        int greenMask = palette.greenMask;
+        int blueMask = palette.blueMask;
+        int redShift = palette.redShift;
+        int greenShift = palette.greenShift;
+        int blueShift = palette.blueShift;
+        for (int yPos = 0; yPos < srcHeight; yPos++) {
+            image.getPixels(0, yPos, srcWidth, buffer, 0);
+            int dstRowIndex = yPos * srcWidth;
+            for (int xPos = 0; xPos < srcWidth; xPos++) {
+                int pixel = buffer[xPos];
+                int dstDataIndex = dstRowIndex + xPos;
+                int r = pixel & redMask;
+                r = (redShift < 0) ? r >>> -redShift : r << redShift;
+                int g = pixel & greenMask;
+                g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+                int b = pixel & blueMask;
+                b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;                
+                dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
+                dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
+                dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
+            }
+        }
+    } else {
+        for (int yPos = 0; yPos < srcHeight; yPos++) {
+            image.getPixels(0, yPos, srcWidth, buffer, 0);
+            int dstRowIndex = yPos * srcWidth;
+            for (int xPos = 0; xPos < srcWidth; xPos++) {
+                int pixel = buffer[xPos];
+                int dstDataIndex = dstRowIndex + xPos;
+                RGB rgb = palette.getRGB(pixel);
+                int r = rgb.red;
+                int g = rgb.green;
+                int b = rgb.blue;
+                dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
+                dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
+                dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
+            }
+        }
+    }
+    compress(image, dataYComp, dataCbComp, dataCrComp);
+}
+byte[] convertYToRGB() {
+    int compWidth = frameComponents[componentIds[ID_Y]][CW];
+    int bytesPerLine = (((imageWidth * 8 + 7) / 8) + 3) / 4 * 4;
+    byte[] data = new byte[bytesPerLine * imageHeight];
+    byte[] yComp = imageComponents[ID_Y];
+    int destIndex = 0;
+    for (int i = 0; i < imageHeight; i++) {
+        int srcIndex = i * compWidth;
+        for (int j = 0; j < bytesPerLine; j++) {
+            int y = yComp[srcIndex] & 0xFF;
+            if (y < 0) {
+                y = 0;
+            } else {
+                if (y > 255) y = 255;
+            }
+            if (j >= imageWidth) {
+                y = 0;
+            }
+            data[destIndex] = (byte)y;
+            srcIndex++;
+            destIndex++;
+        }
+    }
+    return data;
+}
+byte[] convertYCbCrToRGB() {
+    /**
+     * Convert existing image components into an RGB format.
+     * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
+     * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
+     * The conversion equations to be implemented are therefore
+     *  R = Y                + 1.40200 * Cr
+     *  G = Y - 0.34414 * Cb - 0.71414 * Cr
+     *  B = Y + 1.77200 * Cb
+     * where Cb and Cr represent the incoming values less MAXJSAMPLE/2.
+     * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
+     * 
+     * To avoid floating-point arithmetic, we represent the fractional constants
+     * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
+     * the products by 2^16, with appropriate rounding, to get the correct answer.
+     * Notice that Y, being an integral input, does not contribute any fraction
+     * so it need not participate in the rounding.
+     * 
+     * For even more speed, we avoid doing any multiplications in the inner loop
+     * by precalculating the constants times Cb and Cr for all possible values.
+     * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
+     * for 12-bit samples it is still acceptable.  It's not very reasonable for
+     * 16-bit samples, but if you want lossless storage you shouldn't be changing
+     * colorspace anyway.
+     * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
+     * values for the G calculation are left scaled up, since we must add them
+     * together before rounding.
+     */
+    int bSize = imageWidth * imageHeight * nComponents;
+    byte[] rgbData = new byte[bSize];
+    int destIndex = 0;
+    expandImageComponents();
+    byte[] yComp = imageComponents[ID_Y];
+    byte[] cbComp = imageComponents[ID_CB];
+    byte[] crComp = imageComponents[ID_CR];
+    int compWidth = frameComponents[componentIds[ID_Y]][CW];
+    for (int v = 0; v < imageHeight; v++) {
+        int srcIndex = v * compWidth;
+        for (int i = 0; i < imageWidth; i++) {
+            int y = yComp[srcIndex] & 0xFF;
+            int cb = cbComp[srcIndex] & 0xFF;
+            int cr = crComp[srcIndex] & 0xFF;
+            int r = y + CrRTable[cr];
+            int g = y + ((CbGTable[cb] + CrGTable[cr]) >> 16);
+            int b = y + CbBTable[cb];
+            if (r < 0) {
+                r = 0;
+            } else {
+                if (r > 255) r = 255;
+            }
+            if (g < 0) {
+                g = 0;
+            } else {
+                if (g > 255) g = 255;
+            }
+            if (b < 0) {
+                b = 0;
+            } else {
+                if (b > 255) b = 255;
+            }
+            rgbData[destIndex] = (byte)b;
+            rgbData[destIndex + 1] = (byte)g;
+            rgbData[destIndex + 2] = (byte)r;
+            destIndex += 3;
+            srcIndex++;
+        }
+    }
+    return rgbData;
+}
+void decodeACCoefficients(int[] dataUnit, int iComp) {
+    int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+    JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+    int k = 1;
+    while (k < 64) {
+        int rs = decodeUsingTable(acTable);
+        int r = rs >> 4;
+        int s = rs & 0xF;
+        if (s is 0) {
+            if (r is 15) {
+                k += 16;
+            } else {
+                break;
+            }
+        } else {
+            k += r;
+            int bits = receive(s);
+            dataUnit[ZigZag8x8[k]] = extendBy(bits, s);
+            k++;
+        }
+    }
+}
+void decodeACFirstCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
+    if (eobrun > 0) {
+        eobrun--;
+        return;
+    }
+    int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+    JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+    int k = start;
+    while (k <= end) {
+        int rs = decodeUsingTable(acTable);
+        int r = rs >> 4;
+        int s = rs & 0xF;
+        if (s is 0) {
+            if (r is 15) {
+                k += 16;
+            } else {
+                eobrun = (1 << r) + receive(r) - 1;
+                break;
+            }
+        } else {
+            k += r;
+            int bits = receive(s);
+            dataUnit[ZigZag8x8[k]] = extendBy(bits, s) << approxBit;
+            k++;
+        }
+    }
+}
+void decodeACRefineCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
+    int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+    JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+    int k = start;
+    while (k <= end) {
+        if (eobrun > 0) {
+            while (k <= end) {
+                int zzIndex = ZigZag8x8[k];
+                if (dataUnit[zzIndex] !is 0) {
+                    dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+                }
+                k++;
+            }
+            eobrun--;
+        } else {
+            int rs = decodeUsingTable(acTable);
+            int r = rs >> 4;
+            int s = rs & 0xF;
+            if (s is 0) {
+                if (r is 15) {
+                    int zeros = 0;
+                    while (zeros < 16 && k <= end) {
+                        int zzIndex = ZigZag8x8[k];
+                        if (dataUnit[zzIndex] !is 0) {
+                            dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+                        } else {
+                            zeros++;
+                        }
+                        k++;
+                    }
+                } else {
+                    eobrun = (1 << r) + receive(r);
+                }
+            } else {
+                int bit = receive(s);
+                int zeros = 0;
+                int zzIndex = ZigZag8x8[k];
+                while ((zeros < r || dataUnit[zzIndex] !is 0) && k <= end) {
+                    if (dataUnit[zzIndex] !is 0) {
+                        dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+                    } else {
+                        zeros++;
+                    }
+                    k++;
+                    zzIndex = ZigZag8x8[k];
+                }
+                if (bit !is 0) {
+                    dataUnit[zzIndex] = 1 << approxBit;
+                } else {
+                    dataUnit[zzIndex] = -1 << approxBit;
+                }
+                k++;
+            }
+        }
+    }
+}
+int refineAC(int ac, int approxBit) {
+    if (ac > 0) {
+        int bit = nextBit();
+        if (bit !is 0) {
+            ac += 1 << approxBit;
+        }
+    } else if (ac < 0) {
+        int bit = nextBit();
+        if (bit !is 0) {
+            ac += -1 << approxBit;
+        }
+    }
+    return ac;
+}
+void decodeDCCoefficient(int[] dataUnit, int iComp, bool first, int approxBit) {
+    int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+    JPEGHuffmanTable dcTable = dcHuffmanTables[sParams[DC]];
+    int lastDC = 0;
+    if (progressive && !first) {
+        int bit = nextBit();
+        lastDC = dataUnit[0] + (bit << approxBit);
+    } else {
+        lastDC = precedingDCs[iComp];
+        int nBits = decodeUsingTable(dcTable);
+        if (nBits !is 0) {
+            int bits = receive(nBits);
+            int diff = extendBy(bits, nBits);
+            lastDC += diff;
+            precedingDCs[iComp] = lastDC;
+        }
+        if (progressive) {
+            lastDC = lastDC << approxBit;
+        }
+    }
+    dataUnit[0] = lastDC;
+}
+void dequantize(int[] dataUnit, int iComp) {
+    int[] qTable = quantizationTables[frameComponents[componentIds[iComp]][TQI]];
+    for (int i = 0; i < dataUnit.length; i++) {
+        int zzIndex = ZigZag8x8[i];
+        dataUnit[zzIndex] = dataUnit[zzIndex] * qTable[i];
+    }
+}
+byte[] decodeImageComponents() {
+    if (nComponents is 3) { // compIds 1, 2, 3
+        return convertYCbCrToRGB();
+    }
+//  if (nComponents is 3) { // compIds 1, 4, 5
+//      Unsupported CMYK format.
+//      return convertYIQToRGB();
+//  }
+    if (nComponents is 4) {
+        return convertCMYKToRGB();
+    }
+    return convertYToRGB();
+}
+void decodeMCUAtXAndY(int xmcu, int ymcu, int nComponentsInScan, bool first, int start, int end, int approxBit) {
+    for (int iComp = 0; iComp < nComponentsInScan; iComp++) {
+        int scanComponent = iComp;
+        while (scanHeader.componentParameters[componentIds[scanComponent]] is null) {
+            scanComponent++;
+        }
+        int[] frameComponent = frameComponents[componentIds[scanComponent]];
+        int hi = frameComponent[HI];
+        int vi = frameComponent[VI];
+        if (nComponentsInScan is 1) {
+            hi = 1;
+            vi = 1;
+        }
+        int compWidth = frameComponent[CW];
+        for (int ivi = 0; ivi < vi; ivi++) {
+            for (int ihi = 0; ihi < hi; ihi++) {
+                if (progressive) {
+                    // Progressive: First scan - create a new data unit.
+                    // Subsequent scans - refine the existing data unit.
+                    int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
+                    dataUnit = dataUnits[scanComponent][index];
+                    if (dataUnit is null) {
+                        dataUnit = new int[64];
+                        dataUnits[scanComponent][index] = dataUnit;
+                    }
+                } else {
+                    // Sequential: Clear and reuse the data unit buffer.
+                    for (int i = 0; i < dataUnit.length; i++) {
+                        dataUnit[i] = 0;
+                    }
+                }
+                if (!progressive || scanHeader.isDCProgressiveScan()) {
+                    decodeDCCoefficient(dataUnit, scanComponent, first, approxBit);
+                }
+                if (!progressive) {
+                    decodeACCoefficients(dataUnit, scanComponent);
+                } else {
+                    if (scanHeader.isACProgressiveScan()) {
+                        if (first) {
+                            decodeACFirstCoefficients(dataUnit, scanComponent, start, end, approxBit);
+                        } else {
+                            decodeACRefineCoefficients(dataUnit, scanComponent, start, end, approxBit);
+                        }
+                    }
+                    if (loader.hasListeners()) {
+                        // Dequantization, IDCT, up-sampling and color conversion
+                        // are done on a copy of the coefficient data in order to
+                        // display the image incrementally.
+                        int[] temp = dataUnit;
+                        dataUnit = new int[64];
+                        System.arraycopy(temp, 0, dataUnit, 0, 64);
+                    }
+                }
+                if (!progressive || (progressive && loader.hasListeners())) {
+                    dequantize(dataUnit, scanComponent);
+                    inverseDCT(dataUnit);
+                    storeData(dataUnit, scanComponent, xmcu, ymcu, hi, ihi, vi, ivi);
+                }
+            }
+        }
+    }
+}
+void decodeScan() {
+    if (progressive && !scanHeader.verifyProgressiveScan()) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    int nComponentsInScan = scanHeader.getNumberOfImageComponents();
+    int mcuRowsInScan = interleavedMcuRows;
+    int mcusPerRow = interleavedMcuCols;
+    if (nComponentsInScan is 1) {
+        // Non-interleaved.
+        int scanComponent = 0;
+        while (scanHeader.componentParameters[componentIds[scanComponent]] is null) {
+            scanComponent++;
+        }
+        int[] frameComponent = frameComponents[componentIds[scanComponent]];
+        int hi = frameComponent[HI];
+        int vi = frameComponent[VI];
+        int mcuWidth = DCTSIZE * maxH / hi;
+        int mcuHeight = DCTSIZE * maxV / vi;
+        mcusPerRow = (imageWidth + mcuWidth - 1) / mcuWidth;
+        mcuRowsInScan = (imageHeight + mcuHeight - 1) / mcuHeight;
+    }
+    bool first = scanHeader.isFirstScan();
+    int start = scanHeader.getStartOfSpectralSelection();
+    int end = scanHeader.getEndOfSpectralSelection();
+    int approxBit = scanHeader.getApproxBitPositionLow();
+    restartsToGo = restartInterval;
+    nextRestartNumber = 0;
+    for (int ymcu = 0; ymcu < mcuRowsInScan; ymcu++) {
+        for (int xmcu = 0; xmcu < mcusPerRow; xmcu++) {
+            if (restartInterval !is 0) {
+                if (restartsToGo is 0) processRestartInterval();
+                restartsToGo--;
+            }
+            decodeMCUAtXAndY(xmcu, ymcu, nComponentsInScan, first, start, end, approxBit);
+        }
+    }
+}
+int decodeUsingTable(JPEGHuffmanTable huffmanTable) {
+    int i = 0;
+    int[] maxCodes = huffmanTable.getDhMaxCodes();
+    int[] minCodes = huffmanTable.getDhMinCodes();
+    int[] valPtrs = huffmanTable.getDhValPtrs();
+    int[] huffVals = huffmanTable.getDhValues();
+    int code = nextBit();
+    while (code > maxCodes[i]) {
+        code = code * 2 + nextBit();
+        i++;
+    }
+    int j = valPtrs[i] + code - minCodes[i];
+    return huffVals[j];
+}
+void emit(int huffCode, int nBits) {
+    if (nBits is 0) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    int[] power2m1 = new int[] {
+        1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 
+        16383, 32767, 65535, 131125
+    };
+    int code = (huffCode & power2m1[nBits - 1]) << (24 - nBits - currentBitCount);
+    byte[] codeBuffer = new byte[4];
+    codeBuffer[0] = (byte)(code & 0xFF);
+    codeBuffer[1] = (byte)((code >> 8) & 0xFF);
+    codeBuffer[2] = (byte)((code >> 16) & 0xFF);
+    codeBuffer[3] = (byte)((code >> 24) & 0xFF);
+    int abs = nBits - (8 - currentBitCount);
+    if (abs < 0) abs = -abs;
+    if ((abs >> 3) > 0) {
+        currentByte += codeBuffer[2];
+        emitByte((byte)currentByte);
+        emitByte(codeBuffer[1]);
+        currentByte = codeBuffer[0];
+        currentBitCount += nBits - 16;
+    } else {
+        currentBitCount += nBits;
+        if (currentBitCount >= 8) {
+            currentByte += codeBuffer[2];
+            emitByte((byte)currentByte);
+            currentByte = codeBuffer[1];
+            currentBitCount -= 8;
+        } else {
+            currentByte += codeBuffer[2];
+        }
+    }
+}
+void emitByte(byte byteValue) {
+    if (bufferCurrentPosition >= 512) {
+        resetOutputBuffer();
+    }
+    dataBuffer[bufferCurrentPosition] = byteValue;
+    bufferCurrentPosition++;
+    if (byteValue is -1) {
+        emitByte((byte)0);
+    }
+}
+void encodeACCoefficients(int[] dataUnit, int iComp) {
+    int[] sParams = scanHeader.componentParameters[iComp];
+    JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+    int[] ehCodes = acTable.ehCodes;
+    byte[] ehSizes = acTable.ehCodeLengths;
+    int r = 0;
+    int k = 1;
+    while (k < 64) {
+        k++;
+        int acValue = dataUnit[ZigZag8x8[k - 1]];
+        if (acValue is 0) {
+            if (k is 64) {
+                emit(ehCodes[0], ehSizes[0] & 0xFF);
+            } else {
+                r++;
+            }
+        } else {
+            while (r > 15) {
+                emit(ehCodes[0xF0], ehSizes[0xF0] & 0xFF);
+                r -= 16;
+            }
+            if (acValue < 0) {
+                int absACValue = acValue;
+                if (absACValue < 0) absACValue = -absACValue;
+                int nBits = NBitsTable[absACValue];
+                int rs = r * 16 + nBits;
+                emit(ehCodes[rs], ehSizes[rs] & 0xFF);
+                emit(0xFFFFFF - absACValue, nBits);
+            } else {
+                int nBits = NBitsTable[acValue];
+                int rs = r * 16 + nBits;
+                emit(ehCodes[rs], ehSizes[rs] & 0xFF);
+                emit(acValue, nBits);
+            }
+            r = 0;
+        }
+    }
+}
+void encodeDCCoefficients(int[] dataUnit, int iComp) {
+    int[] sParams = scanHeader.componentParameters[iComp];
+    JPEGHuffmanTable dcTable = dcHuffmanTables[sParams[DC]];
+    int lastDC = precedingDCs[iComp];
+    int dcValue = dataUnit[0];
+    int diff = dcValue - lastDC;
+    precedingDCs[iComp] = dcValue;
+    if (diff < 0) {
+        int absDiff = 0 - diff;
+        int nBits = NBitsTable[absDiff];
+        emit(dcTable.ehCodes[nBits], dcTable.ehCodeLengths[nBits]);
+        emit(0xFFFFFF - absDiff, nBits);
+    } else {
+        int nBits = NBitsTable[diff];
+        emit(dcTable.ehCodes[nBits], dcTable.ehCodeLengths[nBits]);
+        if (nBits !is 0) {
+            emit(diff, nBits);
+        }
+    }
+}
+void encodeMCUAtXAndY(int xmcu, int ymcu) {
+    int nComponentsInScan = scanHeader.getNumberOfImageComponents();
+    dataUnit = new int[64];
+    for (int iComp = 0; iComp < nComponentsInScan; iComp++) {
+        int[] frameComponent = frameComponents[componentIds[iComp]];
+        int hi = frameComponent[HI];
+        int vi = frameComponent[VI];
+        for (int ivi = 0; ivi < vi; ivi++) {
+            for (int ihi = 0; ihi < hi; ihi++) {
+                extractData(dataUnit, iComp, xmcu, ymcu, ihi, ivi);
+                forwardDCT(dataUnit);
+                quantizeData(dataUnit, iComp);
+                encodeDCCoefficients(dataUnit, iComp);
+                encodeACCoefficients(dataUnit, iComp);
+            }
+        }
+    }
+}
+void encodeScan() {
+    for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
+        for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
+            encodeMCUAtXAndY(xmcu, ymcu);
+        }
+    }
+    if (currentBitCount !is 0) {
+        emitByte((byte)currentByte);
+    }
+    resetOutputBuffer();
+}
+void expandImageComponents() {
+    for (int iComp = 0; iComp < nComponents; iComp++) {
+        int[] frameComponent = frameComponents[componentIds[iComp]];
+        int hi = frameComponent[HI];
+        int vi = frameComponent[VI];
+        int upH = maxH / hi;
+        int upV = maxV / vi;
+        if ((upH * upV) > 1) {
+            byte[] component = imageComponents[iComp];
+            int compWidth = frameComponent[CW];
+            int compHeight = frameComponent[CH];
+            int upCompWidth = compWidth * upH;
+            int upCompHeight = compHeight * upV;
+            ImageData src = new ImageData(compWidth, compHeight, 8, new PaletteData(RGB16), 4, component);
+            ImageData dest = src.scaledTo(upCompWidth, upCompHeight);
+            imageComponents[iComp] = dest.data;
+        }
+    }
+}
+int extendBy(int diff, int t) {
+    if (diff < ExtendTest[t]) {
+        return diff + ExtendOffset[t];
+    } else {
+        return diff;
+    }
+}
+void extractData(int[] dataUnit, int iComp, int xmcu, int ymcu, int ihi, int ivi) {
+    byte[] compImage = imageComponents[iComp];
+    int[] frameComponent = frameComponents[componentIds[iComp]];
+    int hi = frameComponent[HI];
+    int vi = frameComponent[VI];
+    int compWidth = frameComponent[CW];
+    int srcIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
+    int destIndex = 0;
+    for (int i = 0; i < DCTSIZE; i++) {
+        for (int col = 0; col < DCTSIZE; col++) {
+            dataUnit[destIndex] = (compImage[srcIndex + col] & 0xFF) - 128;
+            destIndex++;
+        }
+        srcIndex += compWidth;
+    }
+}
+void forwardDCT(int[] dataUnit) {
+    for (int row = 0; row < 8; row++) {
+        int rIndex = row * DCTSIZE;
+        int tmp0 = dataUnit[rIndex] + dataUnit[rIndex + 7];
+        int tmp7 = dataUnit[rIndex] - dataUnit[rIndex + 7];
+        int tmp1 = dataUnit[rIndex + 1] + dataUnit[rIndex + 6];
+        int tmp6 = dataUnit[rIndex + 1] - dataUnit[rIndex + 6];
+        int tmp2 = dataUnit[rIndex + 2] + dataUnit[rIndex + 5];
+        int tmp5 = dataUnit[rIndex + 2] - dataUnit[rIndex + 5];
+        int tmp3 = dataUnit[rIndex + 3] + dataUnit[rIndex + 4];
+        int tmp4 = dataUnit[rIndex + 3] - dataUnit[rIndex + 4];
+
+        /**
+         * Even part per LL&M figure 1 --- note that published figure 
+         * is faulty; rotator 'sqrt(2)*c1' should be 'sqrt(2)*c6'.
+         */
+        int tmp10 = tmp0 + tmp3;
+        int tmp13 = tmp0 - tmp3;
+        int tmp11 = tmp1 + tmp2;
+        int tmp12 = tmp1 - tmp2;
+
+        dataUnit[rIndex] = (tmp10 + tmp11) * 4;
+        dataUnit[rIndex + 4]  = (tmp10 - tmp11) * 4;
+
+        int z1 = (tmp12 + tmp13) * FIX_0_541196100;
+        int n = z1 + (tmp13 * FIX_0_765366865) + 1024;
+        dataUnit[rIndex + 2] = n >> 11;
+        if ((n < 0) && ((n & 0x07FF) !is 0)) dataUnit[rIndex + 2]--;
+        n = z1 + (tmp12 * (0 - FIX_1_847759065)) + 1024;
+        dataUnit[rIndex + 6] = n >> 11;
+        if ((n < 0) && ((n & 0x07FF) !is 0)) dataUnit[rIndex + 6]--;
+
+        /**
+         * Odd part per figure 8 --- note paper omits factor of sqrt(2).
+         * cK represents cos(K*pi/16).
+         * i0..i3 in the paper are tmp4..tmp7 here.
+         */
+        z1 = tmp4 + tmp7;
+        int z2 = tmp5 + tmp6;
+        int z3 = tmp4 + tmp6;
+        int z4 = tmp5 + tmp7;
+        int z5 = (z3 + z4) * FIX_1_175875602;   // sqrt(2) * c3
+
+        tmp4 *= FIX_0_298631336;    // sqrt(2) * (-c1+c3+c5-c7)
+        tmp5 *= FIX_2_053119869;    // sqrt(2) * ( c1+c3-c5+c7)
+        tmp6 *= FIX_3_072711026;    // sqrt(2) * ( c1+c3+c5-c7)
+        tmp7 *= FIX_1_501321110;    // sqrt(2) * ( c1+c3-c5-c7)
+        z1 *= 0 - FIX_0_899976223;  // sqrt(2) * (c7-c3)
+        z2 *= 0 - FIX_2_562915447;  // sqrt(2) * (-c1-c3)
+        z3 *= 0 - FIX_1_961570560;  // sqrt(2) * (-c3-c5)
+        z4 *= 0 - FIX_0_390180644;  // sqrt(2) * (c5-c3)
+
+        z3 += z5;
+        z4 += z5;
+
+        n = tmp4 + z1 + z3 + 1024;
+        dataUnit[rIndex + 7] = n >> 11;
+        if ((n < 0) && ((n & 0x07FF) !is 0)) dataUnit[rIndex + 7]--;
+        n = tmp5 + z2 + z4 + 1024;
+        dataUnit[rIndex + 5] = n >> 11;
+        if ((n < 0) && ((n & 0x07FF) !is 0)) dataUnit[rIndex + 5]--;
+        n = tmp6 + z2 + z3 + 1024;
+        dataUnit[rIndex + 3] = n >> 11;
+        if ((n < 0) && ((n & 0x07FF) !is 0)) dataUnit[rIndex + 3]--;
+        n = tmp7 + z1 + z4 + 1024;
+        dataUnit[rIndex + 1] = n >> 11;
+        if ((n < 0) && ((n & 0x07FF) !is 0)) dataUnit[rIndex + 1]--;
+    }
+
+    /**
+     * Pass 2: process columns.
+     * Note that we must descale the results by a factor of 8 is 2**3,
+     * and also undo the PASS1_BITS scaling.
+     */
+    for (int col = 0; col < 8; col++) {
+        int c0 = col;
+        int c1 = col + 8;
+        int c2 = col + 16;
+        int c3 = col + 24;
+        int c4 = col + 32;
+        int c5 = col + 40;
+        int c6 = col + 48;
+        int c7 = col + 56;
+        int tmp0 = dataUnit[c0] + dataUnit[c7];
+        int tmp7 = dataUnit[c0] - dataUnit[c7];
+        int tmp1 = dataUnit[c1] + dataUnit[c6];
+        int tmp6 = dataUnit[c1] - dataUnit[c6];
+        int tmp2 = dataUnit[c2] + dataUnit[c5];
+        int tmp5 = dataUnit[c2] - dataUnit[c5];
+        int tmp3 = dataUnit[c3] + dataUnit[c4];
+        int tmp4 = dataUnit[c3] - dataUnit[c4];
+
+        /**
+         * Even part per LL&M figure 1 --- note that published figure 
+         * is faulty; rotator 'sqrt(2)*c1' should be 'sqrt(2)*c6'.
+         */
+        int tmp10 = tmp0 + tmp3;
+        int tmp13 = tmp0 - tmp3;
+        int tmp11 = tmp1 + tmp2;
+        int tmp12 = tmp1 - tmp2;
+
+        int n = tmp10 + tmp11 + 16;
+        dataUnit[c0] = n >> 5;
+        if ((n < 0) && ((n & 0x1F) !is 0)) dataUnit[c0]--;
+        n = tmp10 - tmp11 + 16;
+        dataUnit[c4] = n >> 5;
+        if ((n < 0) && ((n & 0x1F) !is 0)) dataUnit[c4]--;
+
+        int z1 = (tmp12 + tmp13) * FIX_0_541196100;
+        n = z1 + (tmp13 * FIX_0_765366865) + 131072;
+        dataUnit[c2] = n >> 18;
+        if ((n < 0) && ((n & 0x3FFFF) !is 0)) dataUnit[c2]--;
+        n = z1 + (tmp12 * (0 - FIX_1_847759065)) + 131072;
+        dataUnit[c6] = n >> 18;
+        if ((n < 0) && ((n & 0x3FFFF) !is 0)) dataUnit[c6]--;
+
+        /**
+         * Odd part per figure 8 --- note paper omits factor of sqrt(2).
+         * cK represents cos(K*pi/16).
+         * i0..i3 in the paper are tmp4..tmp7 here.
+         */
+        z1 = tmp4 + tmp7;
+        int z2 = tmp5 + tmp6;
+        int z3 = tmp4 + tmp6;
+        int z4 = tmp5 + tmp7;
+        int z5 = (z3 + z4) * FIX_1_175875602;   // sqrt(2) * c3
+
+        tmp4 *= FIX_0_298631336;    // sqrt(2) * (-c1+c3+c5-c7)
+        tmp5 *= FIX_2_053119869;    // sqrt(2) * ( c1+c3-c5+c7)
+        tmp6 *= FIX_3_072711026;    // sqrt(2) * ( c1+c3+c5-c7)
+        tmp7 *= FIX_1_501321110;    // sqrt(2) * ( c1+c3-c5-c7)
+        z1 *= 0 - FIX_0_899976223;  // sqrt(2) * (c7-c3)
+        z2 *= 0 - FIX_2_562915447;  // sqrt(2) * (-c1-c3)
+        z3 *= 0 - FIX_1_961570560;  // sqrt(2) * (-c3-c5)
+        z4 *= 0 - FIX_0_390180644;  // sqrt(2) * (c5-c3)
+
+        z3 += z5;
+        z4 += z5;
+
+        n = tmp4 + z1 + z3 + 131072;
+        dataUnit[c7] = n >> 18;
+        if ((n < 0) && ((n & 0x3FFFF) !is 0)) dataUnit[c7]--;
+        n = tmp5 + z2 + z4 + 131072;
+        dataUnit[c5] = n >> 18;
+        if ((n < 0) && ((n & 0x3FFFF) !is 0)) dataUnit[c5]--;
+        n = tmp6 + z2 + z3 + 131072;
+        dataUnit[c3] = n >> 18;
+        if ((n < 0) && ((n & 0x3FFFF) !is 0)) dataUnit[c3]--;
+        n = tmp7 + z1 + z4 + 131072;
+        dataUnit[c1] = n >> 18;
+        if ((n < 0) && ((n & 0x3FFFF) !is 0)) dataUnit[c1]--;
+    }
+}
+void getAPP0() {
+    JPEGAppn appn = new JPEGAppn(inputStream);
+    if (!appn.verify()) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+}
+void getCOM() {
+    new JPEGComment(inputStream);
+}
+void getDAC() {
+    new JPEGArithmeticConditioningTable(inputStream);
+}
+void getDHT() {
+    JPEGHuffmanTable dht = new JPEGHuffmanTable(inputStream);
+    if (!dht.verify()) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    if (acHuffmanTables is null) {
+        acHuffmanTables = new JPEGHuffmanTable[4];
+    }
+    if (dcHuffmanTables is null) {
+        dcHuffmanTables = new JPEGHuffmanTable[4];
+    }
+    JPEGHuffmanTable[] dhtTables = dht.getAllTables();
+    for (int i = 0; i < dhtTables.length; i++) {
+        JPEGHuffmanTable dhtTable = dhtTables[i];
+        if (dhtTable.getTableClass() is 0) {
+            dcHuffmanTables[dhtTable.getTableIdentifier()] = dhtTable;
+        } else {
+            acHuffmanTables[dhtTable.getTableIdentifier()] = dhtTable;
+        }
+    }
+}
+void getDNL() {
+    new JPEGRestartInterval(inputStream);
+}
+void getDQT() {
+    JPEGQuantizationTable dqt = new JPEGQuantizationTable(inputStream);
+    int[][] currentTables = quantizationTables;
+    if (currentTables is null) {
+        currentTables = new int[4][];
+    }
+    int[] dqtTablesKeys = dqt.getQuantizationTablesKeys();
+    int[][] dqtTablesValues = dqt.getQuantizationTablesValues();
+    for (int i = 0; i < dqtTablesKeys.length; i++) {
+        int index = dqtTablesKeys[i];
+        currentTables[index] = dqtTablesValues[i];
+    }
+    quantizationTables = currentTables;
+}
+void getDRI() {
+    JPEGRestartInterval dri = new JPEGRestartInterval(inputStream);
+    if (!dri.verify()) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    restartInterval = dri.getRestartInterval();
+}
+void inverseDCT(int[] dataUnit) {
+    for (int row = 0; row < 8; row++) {
+        int rIndex = row * DCTSIZE;
+        /**
+         * Due to quantization, we will usually find that many of the input
+         * coefficients are zero, especially the AC terms.  We can exploit this
+         * by short-circuiting the IDCT calculation for any row in which all
+         * the AC terms are zero.  In that case each output is equal to the
+         * DC coefficient (with scale factor as needed).
+         * With typical images and quantization tables, half or more of the
+         * row DCT calculations can be simplified this way.
+         */
+        if (isZeroInRow(dataUnit, rIndex)) {
+            int dcVal = dataUnit[rIndex] << 2;
+            for (int i = rIndex + 7; i >= rIndex; i--) {
+                dataUnit[i] = dcVal;
+            }
+        } else {
+            /**
+             * Even part: reverse the even part of the forward DCT.
+             * The rotator is sqrt(2)*c(-6).
+             */
+            int z2 = dataUnit[rIndex + 2];
+            int z3 = dataUnit[rIndex + 6];
+            int z1 = (z2 + z3) * FIX_0_541196100;
+            int tmp2 = z1 + (z3 * (0 - FIX_1_847759065));
+            int tmp3 = z1 + (z2 * FIX_0_765366865);
+            int tmp0 = (dataUnit[rIndex] + dataUnit[rIndex + 4]) << 13;
+            int tmp1 = (dataUnit[rIndex] - dataUnit[rIndex + 4]) << 13;
+            int tmp10 = tmp0 + tmp3;
+            int tmp13 = tmp0 - tmp3;
+            int tmp11 = tmp1 + tmp2;
+            int tmp12 = tmp1 - tmp2;
+            /**
+             * Odd part per figure 8; the matrix is unitary and hence its
+             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
+             */
+            tmp0 = dataUnit[rIndex + 7];
+            tmp1 = dataUnit[rIndex + 5];
+            tmp2 = dataUnit[rIndex + 3];
+            tmp3 = dataUnit[rIndex + 1];
+            z1 = tmp0 + tmp3;
+            z2 = tmp1 + tmp2;
+            z3 = tmp0 + tmp2;
+            int z4 = tmp1 + tmp3;
+            int z5 = (z3 + z4) * FIX_1_175875602; /* sqrt(2) * c3 */
+              
+            tmp0 *= FIX_0_298631336;        /* sqrt(2) * (-c1+c3+c5-c7) */
+            tmp1 *= FIX_2_053119869;        /* sqrt(2) * ( c1+c3-c5+c7) */
+            tmp2 *= FIX_3_072711026;        /* sqrt(2) * ( c1+c3+c5-c7) */
+            tmp3 *= FIX_1_501321110;        /* sqrt(2) * ( c1+c3-c5-c7) */
+            z1 *= 0 - FIX_0_899976223;  /* sqrt(2) * (c7-c3) */
+            z2 *= 0 - FIX_2_562915447;  /* sqrt(2) * (-c1-c3) */
+            z3 *= 0 - FIX_1_961570560;  /* sqrt(2) * (-c3-c5) */
+            z4 *= 0 - FIX_0_390180644;  /* sqrt(2) * (c5-c3) */
+
+            z3 += z5;
+            z4 += z5;
+            tmp0 += z1 + z3;
+            tmp1 += z2 + z4;
+            tmp2 += z2 + z3;
+            tmp3 += z1 + z4;
+
+            dataUnit[rIndex] = (tmp10 + tmp3 + 1024) >> 11;
+            dataUnit[rIndex + 7] = (tmp10 - tmp3 + 1024) >> 11;
+            dataUnit[rIndex + 1] = (tmp11 + tmp2 + 1024) >> 11;
+            dataUnit[rIndex + 6] = (tmp11 - tmp2 + 1024) >> 11;
+            dataUnit[rIndex + 2] = (tmp12 + tmp1 + 1024) >> 11;
+            dataUnit[rIndex + 5] = (tmp12 - tmp1 + 1024) >> 11;
+            dataUnit[rIndex + 3] = (tmp13 + tmp0 + 1024) >> 11;
+            dataUnit[rIndex + 4] = (tmp13 - tmp0 + 1024) >> 11;
+         }
+    }
+    /**
+     * Pass 2: process columns.
+     * Note that we must descale the results by a factor of 8 is 2**3,
+     * and also undo the PASS1_BITS scaling.
+     */
+    for (int col = 0; col < 8; col++) {
+        int c0 = col;
+        int c1 = col + 8;
+        int c2 = col + 16;
+        int c3 = col + 24;
+        int c4 = col + 32;
+        int c5 = col + 40;
+        int c6 = col + 48;
+        int c7 = col + 56;
+        if (isZeroInColumn(dataUnit, col)) {
+            int dcVal = (dataUnit[c0] + 16) >> 5;
+            dataUnit[c0] = dcVal;
+            dataUnit[c1] = dcVal;
+            dataUnit[c2] = dcVal;
+            dataUnit[c3] = dcVal;
+            dataUnit[c4] = dcVal;
+            dataUnit[c5] = dcVal;
+            dataUnit[c6] = dcVal;
+            dataUnit[c7] = dcVal;
+        } else {
+            /**
+             * Even part: reverse the even part of the forward DCT.
+             * The rotator is sqrt(2)*c(-6).
+             */
+            int z0 = dataUnit[c0];
+            int z2 = dataUnit[c2];
+            int z3 = dataUnit[c6];
+            int z4 = dataUnit[c4];
+            int z1 = (z2 + z3) * FIX_0_541196100;
+            int tmp2 = z1 + (z3 * (0 - FIX_1_847759065));
+            int tmp3 = z1 + (z2 * FIX_0_765366865);
+            int tmp0 = (z0 + z4) << 13;
+            int tmp1 = (z0 - z4) << 13;
+            int tmp10 = tmp0 + tmp3;
+            int tmp13 = tmp0 - tmp3;
+            int tmp11 = tmp1 + tmp2;
+            int tmp12 = tmp1 - tmp2;
+            /**
+             * Odd part per figure 8; the matrix is unitary and hence its
+             * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
+             */
+            tmp0 = dataUnit[c7];
+            tmp1 = dataUnit[c5];
+            tmp2 = dataUnit[c3];
+            tmp3 = dataUnit[c1];
+            z1 = tmp0 + tmp3;
+            z2 = tmp1 + tmp2;
+            z3 = tmp0 + tmp2;
+            z4 = tmp1 + tmp3;
+            z0 = (z3 + z4) * FIX_1_175875602;   /* sqrt(2) * c3 */
+            
+            tmp0 *= FIX_0_298631336;        /* sqrt(2) * (-c1+c3+c5-c7) */
+            tmp1 *= FIX_2_053119869;        /* sqrt(2) * ( c1+c3-c5+c7) */
+            tmp2 *= FIX_3_072711026;        /* sqrt(2) * ( c1+c3+c5-c7) */
+            tmp3 *= FIX_1_501321110;        /* sqrt(2) * ( c1+c3-c5-c7) */
+            z1 *= 0 - FIX_0_899976223;  /* sqrt(2) * (c7-c3) */
+            z2 *= 0 - FIX_2_562915447;  /* sqrt(2) * (-c1-c3) */
+            z3 *= 0 - FIX_1_961570560;  /* sqrt(2) * (-c3-c5) */
+            z4 *= 0 - FIX_0_390180644;  /* sqrt(2) * (c5-c3) */
+            
+            z3 += z0;
+            z4 += z0;
+            
+            tmp0 += z1 + z3;
+            tmp1 += z2 + z4;
+            tmp2 += z2 + z3;
+            tmp3 += z1 + z4;
+
+            /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
+            dataUnit[c0] = (tmp10 + tmp3 + 131072) >> 18;
+            dataUnit[c7] = (tmp10 - tmp3 + 131072) >> 18;
+            dataUnit[c1] = (tmp11 + tmp2 + 131072) >> 18;
+            dataUnit[c6] = (tmp11 - tmp2 + 131072) >> 18;
+            dataUnit[c2] = (tmp12 + tmp1 + 131072) >> 18;
+            dataUnit[c5] = (tmp12 - tmp1 + 131072) >> 18;
+            dataUnit[c3] = (tmp13 + tmp0 + 131072) >> 18;
+            dataUnit[c4] = (tmp13 - tmp0 + 131072) >> 18;
+        }
+    }
+}
+bool isFileFormat(LEDataInputStream stream) {
+    try {
+        JPEGStartOfImage soi = new JPEGStartOfImage(stream);
+        stream.unread(soi.reference);
+        return soi.verify();  // we no longer check for appN
+    } catch (Exception e) {
+        return false;
+    }
+}
+bool isZeroInColumn(int[] dataUnit, int col) {
+    return dataUnit[col + 8] is 0 && dataUnit[col + 16] is 0
+            && dataUnit[col + 24] is 0 && dataUnit[col + 32] is 0
+            && dataUnit[col + 40] is 0 && dataUnit[col + 48] is 0
+            && dataUnit[col + 56] is 0;
+}
+bool isZeroInRow(int[] dataUnit, int rIndex) {
+    return dataUnit[rIndex + 1] is 0 && dataUnit[rIndex + 2] is 0
+            && dataUnit[rIndex + 3] is 0 && dataUnit[rIndex + 4] is 0
+            && dataUnit[rIndex + 5] is 0 && dataUnit[rIndex + 6] is 0
+            && dataUnit[rIndex + 7] is 0;
+}
+ImageData[] loadFromByteStream() {
+    //TEMPORARY CODE
+    if (System.getProperty("dwt.internal.image.JPEGFileFormat_3.2") is null) {
+        return JPEGDecoder.loadFromByteStream(inputStream, loader);
+    }
+    JPEGStartOfImage soi = new JPEGStartOfImage(inputStream);
+    if (!soi.verify()) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    restartInterval = 0;
+
+    /* Process the tables preceding the frame header. */
+    processTables();
+    
+    /* Start of Frame. */
+    frameHeader = new JPEGFrameHeader(inputStream);
+    if (!frameHeader.verify()) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    imageWidth = frameHeader.getSamplesPerLine();
+    imageHeight = frameHeader.getNumberOfLines();
+    maxH = frameHeader.getMaxHFactor();
+    maxV = frameHeader.getMaxVFactor();
+    int mcuWidth = maxH * DCTSIZE;
+    int mcuHeight = maxV * DCTSIZE;
+    interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;
+    interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;
+    progressive = frameHeader.isProgressive();
+    samplePrecision = frameHeader.getSamplePrecision();
+    nComponents = frameHeader.getNumberOfImageComponents();
+    frameComponents = frameHeader.componentParameters;
+    componentIds = frameHeader.componentIdentifiers;
+    imageComponents = new byte[nComponents][];
+    if (progressive) {
+        // Progressive jpeg: need to keep all of the data units.
+        dataUnits = new int[nComponents][][];
+    } else {
+        // Sequential jpeg: only need one data unit.
+        dataUnit = new int[8 * 8];
+    }
+    for (int i = 0; i < nComponents; i++) {
+        int[] frameComponent = frameComponents[componentIds[i]];
+        int bufferSize = frameComponent[CW] * frameComponent[CH];
+        imageComponents[i] = new byte[bufferSize];
+        if (progressive) {
+            dataUnits[i] = new int[bufferSize][];
+        }
+    }
+
+    /* Process the tables preceding the scan header. */
+    processTables();
+    
+    /* Start of Scan. */
+    scanHeader = new JPEGScanHeader(inputStream);
+    if (!scanHeader.verify()) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    
+    /* Process scan(s) and further tables until EOI. */
+    int progressiveScanCount = 0;
+    bool done = false;
+    while(!done) {
+        resetInputBuffer();
+        precedingDCs = new int[4];
+        decodeScan();
+        if (progressive && loader.hasListeners()) {
+            ImageData imageData = createImageData();
+            loader.notifyListeners(new ImageLoaderEvent(loader, imageData, progressiveScanCount, false));
+            progressiveScanCount++;
+        }
+
+        /* Unread any buffered data before looking for tables again. */
+        int delta = 512 - bufferCurrentPosition - 1;
+        if (delta > 0) {
+            byte[] unreadBuffer = new byte[delta];
+            System.arraycopy(dataBuffer, bufferCurrentPosition + 1, unreadBuffer, 0, delta);
+            try {
+                inputStream.unread(unreadBuffer);
+            } catch (IOException e) {
+                DWT.error(DWT.ERROR_IO, e);
+            }
+        }
+        
+        /* Process the tables preceding the next scan header. */
+        JPEGSegment jpegSegment = processTables();
+        if (jpegSegment is null || jpegSegment.getSegmentMarker() is EOI) {
+            done = true;
+        } else {
+            scanHeader = new JPEGScanHeader(inputStream);
+            if (!scanHeader.verify()) DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+    }
+    
+    if (progressive) {
+        for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
+            for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
+                for (int iComp = 0; iComp < nComponents; iComp++) {
+                    int[] frameComponent = frameComponents[componentIds[iComp]];
+                    int hi = frameComponent[HI];
+                    int vi = frameComponent[VI];
+                    int compWidth = frameComponent[CW];
+                    for (int ivi = 0; ivi < vi; ivi++) {
+                        for (int ihi = 0; ihi < hi; ihi++) {
+                            int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
+                            dataUnit = dataUnits[iComp][index];
+                            dequantize(dataUnit, iComp);
+                            inverseDCT(dataUnit);
+                            storeData(dataUnit, iComp, xmcu, ymcu, hi, ihi, vi, ivi);
+                        }
+                    }
+                }
+            }
+        }
+        dataUnits = null; // release memory
+    }
+    ImageData imageData = createImageData();
+    if (progressive && loader.hasListeners()) {
+        loader.notifyListeners(new ImageLoaderEvent(loader, imageData, progressiveScanCount, true));
+    }
+    return new ImageData[] {imageData};
+}
+ImageData createImageData() {
+    return ImageData.internal_new(
+        imageWidth,
+        imageHeight, 
+        nComponents * samplePrecision,
+        setUpPalette(),
+        nComponents is 1 ? 4 : 1,
+        decodeImageComponents(),
+        0,
+        null,
+        null,
+        -1,
+        -1,
+        DWT.IMAGE_JPEG,
+        0,
+        0,
+        0,
+        0);
+}
+int nextBit() {
+    if (currentBitCount !is 0) {
+        currentBitCount--;
+        currentByte *= 2;
+        if (currentByte > 255) {
+            currentByte -= 256;
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+    bufferCurrentPosition++;
+    if (bufferCurrentPosition >= 512) {
+        resetInputBuffer();
+        bufferCurrentPosition = 0;
+    }
+    currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+    currentBitCount = 8;
+    byte nextByte;
+    if (bufferCurrentPosition is 511) {
+        resetInputBuffer();
+        currentBitCount = 8;
+        nextByte = dataBuffer[0];
+    } else {
+        nextByte = dataBuffer[bufferCurrentPosition + 1];
+    }
+    if (currentByte is 0xFF) {
+        if (nextByte is 0) {
+            bufferCurrentPosition ++;
+            currentBitCount--;
+            currentByte *= 2;
+            if (currentByte > 255) {
+                currentByte -= 256;
+                return 1;
+            } else {
+                return 0;
+            }
+        } else {
+            if ((nextByte & 0xFF) + 0xFF00 is DNL) {
+                getDNL();
+                return 0;
+            } else {
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+                return 0;
+            }
+        }
+    } else {
+        currentBitCount--;
+        currentByte *= 2;
+        if (currentByte > 255) {
+            currentByte -= 256;
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+}
+void processRestartInterval() {
+    do {
+        bufferCurrentPosition++;
+        if (bufferCurrentPosition > 511) {
+            resetInputBuffer();
+            bufferCurrentPosition = 0;
+        }
+        currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+    } while (currentByte !is 0xFF);
+    while (currentByte is 0xFF) {
+        bufferCurrentPosition++;
+        if (bufferCurrentPosition > 511) {
+            resetInputBuffer();
+            bufferCurrentPosition = 0;
+        }
+        currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+    }
+    if (currentByte !is ((RST0 + nextRestartNumber) & 0xFF)) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    bufferCurrentPosition++;
+    if (bufferCurrentPosition > 511) {
+        resetInputBuffer();
+        bufferCurrentPosition = 0;
+    }
+    currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+    currentBitCount = 8;
+    restartsToGo = restartInterval;
+    nextRestartNumber = (nextRestartNumber + 1) & 0x7;
+    precedingDCs = new int[4];
+    eobrun = 0;
+}
+/* Process all markers until a frame header, scan header, or EOI is found. */
+JPEGSegment processTables() {
+    while (true) {
+        JPEGSegment jpegSegment = seekUnspecifiedMarker(inputStream);
+        if (jpegSegment is null) return null;
+        JPEGFrameHeader sof = new JPEGFrameHeader(jpegSegment.reference);
+        if (sof.verify()) {
+            return jpegSegment;
+        }
+        int marker = jpegSegment.getSegmentMarker();
+        switch (marker) {
+            case SOI: // there should only be one SOI per file
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+            case EOI:
+            case SOS:
+                return jpegSegment;
+            case DQT:
+                getDQT();
+                break;
+            case DHT:
+                getDHT();
+                break;
+            case DAC:
+                getDAC();
+                break;
+            case DRI:
+                getDRI();
+                break;
+            case APP0:
+                getAPP0();
+                break;
+            case COM:
+                getCOM();
+                break;
+            default:
+                skipSegmentFrom(inputStream);
+            
+        }
+    }
+}
+void quantizeData(int[] dataUnit, int iComp) {
+    int[] qTable = quantizationTables[frameComponents[componentIds[iComp]][TQI]];
+    for (int i = 0; i < dataUnit.length; i++) {
+        int zzIndex = ZigZag8x8[i];
+        int data = dataUnit[zzIndex];
+        int absData = data < 0 ? 0 - data : data;
+        int qValue = qTable[i];
+        int q2 = qValue >> 1;
+        absData += q2;
+        if (absData < qValue) {
+            dataUnit[zzIndex] = 0;
+        } else {
+            absData /= qValue;
+            if (data >= 0) {
+                dataUnit[zzIndex] = absData;
+            } else {
+                dataUnit[zzIndex] = 0 - absData;
+            }
+        }
+    }
+}
+int receive(int nBits) {
+    int v = 0;
+    for (int i = 0; i < nBits; i++) {
+        v = v * 2 + nextBit();
+    }
+    return v;
+}
+void resetInputBuffer() {
+    if (dataBuffer is null) {
+        dataBuffer = new byte[512];
+    }
+    try {
+        inputStream.read(dataBuffer);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    currentBitCount = 0;
+    bufferCurrentPosition = -1;
+}
+void resetOutputBuffer() {
+    if (dataBuffer is null) {
+        dataBuffer = new byte[512];
+    } else {
+        try {
+            outputStream.write(dataBuffer, 0, bufferCurrentPosition);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+    bufferCurrentPosition = 0;
+}
+static JPEGSegment seekUnspecifiedMarker(LEDataInputStream byteStream) {
+    byte[] byteArray = new byte[2];
+    try {
+        while (true) {
+            if (byteStream.read(byteArray, 0, 1) !is 1) return null;
+            if (byteArray[0] is (byte) 0xFF) {
+                if (byteStream.read(byteArray, 1, 1) !is 1) return null;
+                if (byteArray[1] !is (byte) 0xFF && byteArray[1] !is 0) {
+                    byteStream.unread(byteArray);
+                    return new JPEGSegment(byteArray);
+                }
+            }
+        }
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return null;
+}
+PaletteData setUpPalette() {
+    if (nComponents is 1) {
+        RGB[] entries = new RGB[256];
+        for (int i = 0; i < 256; i++) {
+            entries[i] = new RGB(i, i, i);
+        }
+        return new PaletteData(entries);
+    }
+    return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+}
+static void skipSegmentFrom(LEDataInputStream byteStream) {
+    try {
+        byte[] byteArray = new byte[4];
+        JPEGSegment jpegSegment = new JPEGSegment(byteArray);
+    
+        if (byteStream.read(byteArray) !is byteArray.length) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+        if (!(byteArray[0] is -1 && byteArray[1] !is 0 && byteArray[1] !is -1)) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+        int delta = jpegSegment.getSegmentLength() - 2;
+        byteStream.skip(delta);
+    } catch (Exception e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+void storeData(int[] dataUnit, int iComp, int xmcu, int ymcu, int hi, int ihi, int vi, int ivi) {
+    byte[] compImage = imageComponents[iComp];
+    int[] frameComponent = frameComponents[componentIds[iComp]];
+    int compWidth = frameComponent[CW];
+    int destIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
+    int srcIndex = 0;
+    for (int i = 0; i < DCTSIZE; i++) {
+        for (int col = 0; col < DCTSIZE; col++) {
+            int x = dataUnit[srcIndex] + 128;
+            if (x < 0) {
+                x = 0;
+            } else {
+                if (x > 255) x = 255;
+            }
+            compImage[destIndex + col] = (byte)x;
+            srcIndex++;
+        }
+        destIndex += compWidth;
+    }
+}
+void unloadIntoByteStream(ImageLoader loader) {
+    ImageData image = loader.data[0];
+    if (!new JPEGStartOfImage().writeToStream(outputStream)) {
+        DWT.error(DWT.ERROR_IO);
+    }
+    JPEGAppn appn = new JPEGAppn(new byte[] {(byte)0xFF, (byte)0xE0, 0, 0x10, 0x4A, 0x46, 0x49, 0x46, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0});
+    if (!appn.writeToStream(outputStream)) {
+        DWT.error(DWT.ERROR_IO);
+    }
+    quantizationTables = new int[4][];
+    JPEGQuantizationTable chromDQT = JPEGQuantizationTable.defaultChrominanceTable();
+    chromDQT.scaleBy(encoderQFactor);
+    int[] jpegDQTKeys = chromDQT.getQuantizationTablesKeys();
+    int[][] jpegDQTValues = chromDQT.getQuantizationTablesValues();
+    for (int i = 0; i < jpegDQTKeys.length; i++) {
+        quantizationTables[jpegDQTKeys[i]] = jpegDQTValues[i];
+    }
+    JPEGQuantizationTable lumDQT = JPEGQuantizationTable.defaultLuminanceTable();
+    lumDQT.scaleBy(encoderQFactor);
+    jpegDQTKeys = lumDQT.getQuantizationTablesKeys();
+    jpegDQTValues = lumDQT.getQuantizationTablesValues();
+    for (int i = 0; i < jpegDQTKeys.length; i++) {
+        quantizationTables[jpegDQTKeys[i]] = jpegDQTValues[i];
+    }
+    if (!lumDQT.writeToStream(outputStream)) {
+        DWT.error(DWT.ERROR_IO);
+    }
+    if (!chromDQT.writeToStream(outputStream)) {
+        DWT.error(DWT.ERROR_IO);
+    }
+    int frameLength, scanLength, precision;
+    int[][] frameParams, scanParams;
+    if (image.depth is 1) {
+        frameLength = 11;
+        frameParams = new int[1][];
+        frameParams[0] = new int[] {1, 1, 1, 0, 0};
+        scanParams = new int[1][];
+        scanParams[0] = new int[] {0, 0};
+        scanLength = 8;
+        nComponents = 1;
+        precision = 1;
+    } else {
+        frameLength = 17;
+        frameParams = new int[3][];
+        frameParams[0] = new int[] {0, 2, 2, 0, 0};
+        frameParams[1] = new int[] {1, 1, 1, 0, 0};
+        frameParams[2] = new int[] {1, 1, 1, 0, 0};
+        scanParams = new int[3][];
+        scanParams[0] = new int[] {0, 0};
+        scanParams[1] = new int[] {1, 1};
+        scanParams[2] = new int[] {1, 1};
+        scanLength = 12;
+        nComponents = 3;
+        precision = 8;
+    }
+    imageWidth = image.width;
+    imageHeight = image.height;
+    frameHeader = new JPEGFrameHeader(new byte[19]);
+    frameHeader.setSegmentMarker(SOF0);
+    frameHeader.setSegmentLength(frameLength);
+    frameHeader.setSamplePrecision(precision);
+    frameHeader.setSamplesPerLine(imageWidth);
+    frameHeader.setNumberOfLines(imageHeight);
+    frameHeader.setNumberOfImageComponents(nComponents);
+    frameHeader.componentParameters = frameParams;
+    frameHeader.componentIdentifiers = new int[] {0, 1, 2};
+    frameHeader.initializeContents();
+    if (!frameHeader.writeToStream(outputStream)) {
+        DWT.error(DWT.ERROR_IO);
+    }
+    frameComponents = frameParams;
+    componentIds = frameHeader.componentIdentifiers;
+    maxH = frameHeader.getMaxHFactor();
+    maxV = frameHeader.getMaxVFactor();
+    int mcuWidth = maxH * DCTSIZE;
+    int mcuHeight = maxV * DCTSIZE;
+    interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;
+    interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;
+    acHuffmanTables = new JPEGHuffmanTable[4];
+    dcHuffmanTables = new JPEGHuffmanTable[4];
+    JPEGHuffmanTable[] dhtTables = new JPEGHuffmanTable[] {
+        JPEGHuffmanTable.getDefaultDCLuminanceTable(),
+        JPEGHuffmanTable.getDefaultDCChrominanceTable(),
+        JPEGHuffmanTable.getDefaultACLuminanceTable(),
+        JPEGHuffmanTable.getDefaultACChrominanceTable()
+    };
+    for (int i = 0; i < dhtTables.length; i++) {
+        JPEGHuffmanTable dhtTable = dhtTables[i];
+        if (!dhtTable.writeToStream(outputStream)) {
+            DWT.error(DWT.ERROR_IO);
+        }
+        JPEGHuffmanTable[] allTables = dhtTable.getAllTables();
+        for (int j = 0; j < allTables.length; j++) {
+            JPEGHuffmanTable huffmanTable = allTables[j];
+            if (huffmanTable.getTableClass() is 0) {
+                dcHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
+            } else {
+                acHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
+            }
+        }
+    }
+    precedingDCs = new int[4];
+    scanHeader = new JPEGScanHeader(new byte[14]);
+    scanHeader.setSegmentMarker(SOS);
+    scanHeader.setSegmentLength(scanLength);
+    scanHeader.setNumberOfImageComponents(nComponents);
+    scanHeader.setStartOfSpectralSelection(0);
+    scanHeader.setEndOfSpectralSelection(63);
+    scanHeader.componentParameters = scanParams;
+    scanHeader.initializeContents();
+    if (!scanHeader.writeToStream(outputStream)) {
+        DWT.error(DWT.ERROR_IO);
+    }
+    convertImageToYCbCr(image);
+    resetOutputBuffer();
+    currentByte = 0;
+    currentBitCount = 0;
+    encodeScan();
+    if (!new JPEGEndOfImage().writeToStream(outputStream)) {
+        DWT.error(DWT.ERROR_IO);
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGFixedSizeSegment.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+ 
+import dwt.DWT;
+
+abstract class JPEGFixedSizeSegment : JPEGSegment {
+
+    public JPEGFixedSizeSegment() {
+        reference = new byte[fixedSize()];
+        setSegmentMarker(signature());
+    }
+    
+    public JPEGFixedSizeSegment(byte[] reference) {
+        super(reference);
+    }
+    
+    public JPEGFixedSizeSegment(LEDataInputStream byteStream) {
+        reference = new byte[fixedSize()];
+        try {
+            byteStream.read(reference);
+        } catch (Exception e) { 
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+    
+    abstract public int fixedSize();
+
+    public int getSegmentLength() {
+        return fixedSize() - 2;
+    }
+    
+    public void setSegmentLength(int length) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGFrameHeader.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+
+final class JPEGFrameHeader : JPEGVariableSizeSegment {
+    int maxVFactor;
+    int maxHFactor;
+    public int[] componentIdentifiers;
+    public int[][] componentParameters;
+
+    public JPEGFrameHeader(byte[] reference) {
+        super(reference);
+    }
+    
+    public JPEGFrameHeader(LEDataInputStream byteStream) {
+        super(byteStream);
+        initializeComponentParameters();
+    }
+    
+    public int getSamplePrecision() {
+        return reference[4] & 0xFF;
+    }
+    
+    public int getNumberOfLines() {
+        return (reference[5] & 0xFF) << 8 | (reference[6] & 0xFF);
+    }
+    
+    public int getSamplesPerLine() {
+        return (reference[7] & 0xFF) << 8 | (reference[8] & 0xFF);
+    }
+    
+    public int getNumberOfImageComponents() {
+        return reference[9] & 0xFF;
+    }
+    
+    public void setSamplePrecision(int precision) {
+        reference[4] = (byte)(precision & 0xFF);
+    }
+    
+    public void setNumberOfLines(int anInteger) {
+        reference[5] = (byte)((anInteger & 0xFF00) >> 8);
+        reference[6] = (byte)(anInteger & 0xFF);
+    }
+    
+    public void setSamplesPerLine(int samples) {
+        reference[7] = (byte)((samples & 0xFF00) >> 8);
+        reference[8] = (byte)(samples & 0xFF);
+    }
+    
+    public void setNumberOfImageComponents(int anInteger) {
+        reference[9] = (byte)(anInteger & 0xFF);
+    }
+    
+    public int getMaxHFactor() {
+        return maxHFactor;
+    }
+    
+    public int getMaxVFactor() {
+        return maxVFactor;
+    }
+    
+    public void setMaxHFactor(int anInteger) {
+        maxHFactor = anInteger;
+    }
+    
+    public void setMaxVFactor(int anInteger) {
+        maxVFactor = anInteger;
+    }
+    
+    /* Used when decoding. */
+    void initializeComponentParameters() {
+        int nf = getNumberOfImageComponents();
+        componentIdentifiers = new int[nf];
+        int[][] compSpecParams = new int[0][];
+        int hmax = 1;
+        int vmax = 1;
+        for (int i = 0; i < nf; i++) {
+            int ofs = i * 3 + 10;
+            int ci = reference[ofs] & 0xFF;
+            componentIdentifiers[i] = ci;
+            int hi = (reference[ofs + 1] & 0xFF) >> 4;
+            int vi = reference[ofs + 1] & 0xF;
+            int tqi = reference[ofs + 2] & 0xFF;
+            if (hi > hmax) {
+                hmax = hi;
+            }
+            if (vi > vmax) {
+                vmax = vi;
+            }
+            int[] compParam = new int[5];
+            compParam[0] = tqi;
+            compParam[1] = hi;
+            compParam[2] = vi;
+            if (compSpecParams.length <= ci) {
+                int[][] newParams = new int[ci + 1][];
+                System.arraycopy(compSpecParams, 0, newParams, 0, compSpecParams.length);
+                compSpecParams = newParams;
+            }
+            compSpecParams[ci] = compParam;
+        }
+        int x = getSamplesPerLine();
+        int y = getNumberOfLines();
+        int[] multiples = new int[] { 8, 16, 24, 32 };
+        for (int i = 0; i < nf; i++) {
+            int[] compParam = compSpecParams[componentIdentifiers[i]];
+            int hi = compParam[1];
+            int vi = compParam[2];
+            int compWidth = (x * hi + hmax - 1) / hmax;
+            int compHeight = (y * vi + vmax - 1) / vmax;
+            int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
+            int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
+            compParam[3] = dsWidth;
+            compParam[4] = dsHeight;
+        }
+        setMaxHFactor(hmax);
+        setMaxVFactor(vmax);
+        componentParameters = compSpecParams;
+    }
+    
+    /* Used when encoding. */
+    public void initializeContents() {
+        int nf = getNumberOfImageComponents();
+        if (nf is 0 || nf !is componentParameters.length) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+        int hmax = 0;
+        int vmax = 0;
+        int[][] compSpecParams = componentParameters;
+        for (int i = 0; i < nf; i++) {
+            int ofs = i * 3 + 10;
+            int[] compParam = compSpecParams[componentIdentifiers[i]];
+            int hi = compParam[1];
+            int vi = compParam[2];
+            if (hi * vi > 4) {
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+            }
+            reference[ofs] = (byte)(i + 1);
+            reference[ofs + 1] = (byte)(hi * 16 + vi);
+            reference[ofs + 2] = (byte)(compParam[0]);
+            if (hi > hmax) hmax = hi;
+            if (vi > vmax) vmax = vi;
+        }
+        int x = getSamplesPerLine();
+        int y = getNumberOfLines();
+        int[] multiples = new int[] {8, 16, 24, 32};
+        for (int i = 0; i < nf; i++) {
+            int[] compParam = compSpecParams[componentIdentifiers[i]];
+            int hi = compParam[1];
+            int vi = compParam[2];
+            int compWidth = (x * hi + hmax - 1) / hmax;
+            int compHeight = (y * vi + vmax - 1) / vmax;
+            int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
+            int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
+            compParam[3] = dsWidth;
+            compParam[4] = dsHeight;
+        }
+        setMaxHFactor(hmax);
+        setMaxVFactor(vmax);
+    }
+    
+    int roundUpToMultiple(int anInteger, int mInteger) {
+        int a = anInteger + mInteger - 1;
+        return a - (a % mInteger);
+    }
+    
+    /*
+     * Verify the information contained in the receiver is correct.
+     * Answer true if the header contains a valid marker. Otherwise,
+     * answer false. Valid Start Of Frame markers are:
+     *  SOF_0  - Baseline DCT, Huffman coding
+     *  SOF_1  - Extended sequential DCT, Huffman coding
+     *  SOF_2  - Progressive DCT, Huffman coding
+     *  SOF_3  - Lossless (sequential), Huffman coding
+     *  SOF_5  - Differential sequential, Huffman coding
+     *  SOF_6  - Differential progressive, Huffman coding
+     *  SOF_7  - Differential lossless, Huffman coding
+     *  SOF_9  - Extended sequential DCT, arithmetic coding
+     *  SOF_10 - Progressive DCT, arithmetic coding
+     *  SOF_11 - Lossless (sequential), arithmetic coding
+     *  SOF_13 - Differential sequential, arithmetic coding
+     *  SOF_14 - Differential progressive, arithmetic coding
+     *  SOF_15 - Differential lossless, arithmetic coding
+     */
+    public bool verify() {
+        int marker = getSegmentMarker();
+        return (marker >= JPEGFileFormat.SOF0 && marker <= JPEGFileFormat.SOF3) ||
+            (marker >= JPEGFileFormat.SOF5 && marker <= JPEGFileFormat.SOF7) ||
+            (marker >= JPEGFileFormat.SOF9 && marker <= JPEGFileFormat.SOF11) ||
+            (marker >= JPEGFileFormat.SOF13 && marker <= JPEGFileFormat.SOF15);
+    }
+
+    public bool isProgressive() {
+        int marker = getSegmentMarker();
+        return marker is JPEGFileFormat.SOF2
+            || marker is JPEGFileFormat.SOF6
+            || marker is JPEGFileFormat.SOF10
+            || marker is JPEGFileFormat.SOF14;
+    }
+    
+    public bool isArithmeticCoding() {
+        return getSegmentMarker() >= JPEGFileFormat.SOF9;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGHuffmanTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+/**
+ * JPEGHuffmanTable class actually represents two types of object:
+ * 1) A DHT (Define Huffman Tables) segment, which may represent
+ *  as many as 4 Huffman tables. In this case, the tables are
+ *  stored in the allTables array.
+ * 2) A single Huffman table. In this case, the allTables array
+ *  will be null.
+ * The 'reference' field is stored in both types of object, but
+ * 'initialize' is only called if the object represents a DHT.
+ */
+final class JPEGHuffmanTable : JPEGVariableSizeSegment {
+    JPEGHuffmanTable[] allTables;
+    int tableClass;
+    int tableIdentifier;
+    int[] dhMaxCodes;
+    int[] dhMinCodes;
+    int[] dhValPtrs;
+    int[] dhValues;
+    int[] ehCodes;
+    byte[] ehCodeLengths;
+    static byte[] DCLuminanceTable = {
+        (byte)255, (byte)196, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
+        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+    };
+    static byte[] DCChrominanceTable = {
+        (byte)255, (byte)196, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+    };
+    static byte[] ACLuminanceTable = {
+        (byte)255, (byte)196, 0, (byte)181, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 
+        1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 
+        50, (byte)129, (byte)145, (byte)161, 8, 35, 66, (byte)177, (byte)193, 21, 82, (byte)209, (byte)240, 36, 51, 98, 
+        114, (byte)130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 
+        54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 
+        88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 
+        119, 120, 121, 122, (byte)131, (byte)132, (byte)133, (byte)134, (byte)135, (byte)136, (byte)137, (byte)138, (byte)146, (byte)147, (byte)148, 
+        (byte)149, (byte)150, (byte)151, (byte)152, (byte)153, (byte)154, (byte)162, (byte)163, (byte)164, (byte)165, (byte)166, (byte)167, (byte)168, (byte)169, (byte)170, 
+        (byte)178, (byte)179, (byte)180, (byte)181, (byte)182, (byte)183, (byte)184, (byte)185, (byte)186, (byte)194, (byte)195, (byte)196, (byte)197, (byte)198, (byte)199, 
+        (byte)200, (byte)201, (byte)202, (byte)210, (byte)211, (byte)212, (byte)213, (byte)214, (byte)215, (byte)216, (byte)217, (byte)218, (byte)225, (byte)226, (byte)227, 
+        (byte)228, (byte)229, (byte)230, (byte)231, (byte)232, (byte)233, (byte)234, (byte)241, (byte)242, (byte)243, (byte)244, (byte)245, (byte)246, (byte)247, (byte)248, 
+        (byte)249, (byte)250
+    };
+    static byte[] ACChrominanceTable = {
+        (byte)255, (byte)196, 0, (byte)181, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 
+        1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 
+        50, (byte)129, 8, 20, 66, (byte)145, (byte)161, (byte)177, (byte)193, 9, 35, 
+        51, 82, (byte)240, 21, 98, 114, (byte)209, 10, 22, 36, 52, (byte)225, 37, 
+        (byte)241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 
+        68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 
+        103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, (byte)130, 
+        (byte)131, (byte)132, (byte)133, (byte)134, (byte)135, (byte)136, (byte)137, 
+        (byte)138, (byte)146, (byte)147, (byte)148, (byte)149, (byte)150, (byte)151, 
+        (byte)152, (byte)153, (byte)154, (byte)162, (byte)163, (byte)164, (byte)165, 
+        (byte)166, (byte)167, (byte)168, (byte)169, (byte)170, (byte)178, (byte)179, 
+        (byte)180, (byte)181, (byte)182, (byte)183, (byte)184, (byte)185, (byte)186, 
+        (byte)194, (byte)195, (byte)196, (byte)197, (byte)198, (byte)199, (byte)200, 
+        (byte)201, (byte)202, (byte)210, (byte)211, (byte)212, (byte)213, (byte)214, 
+        (byte)215, (byte)216, (byte)217, (byte)218, (byte)226, (byte)227, (byte)228, 
+        (byte)229, (byte)230, (byte)231, (byte)232, (byte)233, (byte)234, (byte)242, 
+        (byte)243, (byte)244, (byte)245, (byte)246, (byte)247, (byte)248, (byte)249, 
+        (byte)250
+    };
+    
+public JPEGHuffmanTable(byte[] reference) {
+    super(reference);
+}
+
+public JPEGHuffmanTable(LEDataInputStream byteStream) {
+    super(byteStream);
+    initialize();
+}
+
+public JPEGHuffmanTable[] getAllTables() {
+    return allTables;
+}
+
+public static JPEGHuffmanTable getDefaultACChrominanceTable() {
+    JPEGHuffmanTable result = new JPEGHuffmanTable(ACChrominanceTable);
+    result.initialize();
+    return result;
+}
+
+public static JPEGHuffmanTable getDefaultACLuminanceTable() {
+    JPEGHuffmanTable result = new JPEGHuffmanTable(ACLuminanceTable);
+    result.initialize();
+    return result;
+}
+
+public static JPEGHuffmanTable getDefaultDCChrominanceTable() {
+    JPEGHuffmanTable result = new JPEGHuffmanTable(DCChrominanceTable);
+    result.initialize();
+    return result;
+}
+
+public static JPEGHuffmanTable getDefaultDCLuminanceTable() {
+    JPEGHuffmanTable result = new JPEGHuffmanTable(DCLuminanceTable);
+    result.initialize();
+    return result;
+}
+
+public int[] getDhMaxCodes() {
+    return dhMaxCodes;
+}
+
+public int[] getDhMinCodes() {
+    return dhMinCodes;
+}
+
+public int[] getDhValPtrs() {
+    return dhValPtrs;
+}
+
+public int[] getDhValues() {
+    return dhValues;
+}
+
+public int getTableClass() {
+    return tableClass;
+}
+
+public int getTableIdentifier() {
+    return tableIdentifier;
+}
+
+void initialize() {
+    int totalLength = getSegmentLength() - 2;
+    int ofs = 4;
+    int[] bits = new int[16];
+    JPEGHuffmanTable[] huffTables = new JPEGHuffmanTable[8]; // maximum is 4 AC + 4 DC
+    int huffTableCount = 0;
+    while (totalLength > 0) {
+        int tc = (reference[ofs] & 0xFF) >> 4; // table class: AC (1) or DC (0)
+        int tid = reference[ofs] & 0xF; // table id: 0-1 baseline, 0-3 prog/ext
+        ofs++;
+        
+        /* Read the 16 count bytes and add them together to get the table size. */
+        int count = 0;
+        for (int i = 0; i < bits.length; i++) {
+            int bCount = reference[ofs + i] & 0xFF;
+            bits[i] = bCount;
+            count += bCount;
+        }
+        ofs += 16;
+        totalLength -= 17;
+        
+        /* Read the table. */
+        int[] huffVals = new int[count];
+        for (int i = 0; i < count; i++) {
+            huffVals[i] = reference[ofs + i] & 0xFF;
+        }
+        ofs += count;
+        totalLength -= count;
+        
+        /* Calculate the lengths. */
+        int[] huffCodeLengths = new int[50]; // start with 50 and increment as needed
+        int huffCodeLengthsIndex = 0;
+        for (int i = 0; i < 16; i++) {
+            for (int j = 0; j < bits[i]; j++) {
+                if (huffCodeLengthsIndex >= huffCodeLengths.length) {
+                    int[] newHuffCodeLengths = new int[huffCodeLengths.length + 50];
+                    System.arraycopy(huffCodeLengths, 0, newHuffCodeLengths, 0, huffCodeLengths.length);
+                    huffCodeLengths = newHuffCodeLengths;
+                }
+                huffCodeLengths[huffCodeLengthsIndex] = i + 1;
+                huffCodeLengthsIndex++;
+            }
+        }
+        
+        /* Truncate huffCodeLengths to the correct size. */
+        if (huffCodeLengthsIndex < huffCodeLengths.length) {
+            int[] newHuffCodeLengths = new int[huffCodeLengthsIndex];
+            System.arraycopy(huffCodeLengths, 0, newHuffCodeLengths, 0, huffCodeLengthsIndex);
+            huffCodeLengths = newHuffCodeLengths;
+        }
+        
+        /* Calculate the Huffman codes. */
+        int[] huffCodes = new int[50]; // start with 50 and increment as needed
+        int huffCodesIndex = 0;
+        int k = 1;
+        int code = 0;
+        int si = huffCodeLengths[0];
+        int p = 0;
+        while (p < huffCodeLengthsIndex) {
+            while ((p < huffCodeLengthsIndex) && (huffCodeLengths[p] is si)) {
+                if (huffCodesIndex >= huffCodes.length) {
+                    int[] newHuffCodes = new int[huffCodes.length + 50];
+                    System.arraycopy(huffCodes, 0, newHuffCodes, 0, huffCodes.length);
+                    huffCodes = newHuffCodes;
+                }
+                huffCodes[huffCodesIndex] = code;
+                huffCodesIndex++;
+                code++;
+                p++;
+            }
+            code *= 2;
+            si++;
+        }
+        
+        /* Truncate huffCodes to the correct size. */
+        if (huffCodesIndex < huffCodes.length) {
+            int[] newHuffCodes = new int[huffCodesIndex];
+            System.arraycopy(huffCodes, 0, newHuffCodes, 0, huffCodesIndex);
+            huffCodes = newHuffCodes;
+        }
+        
+        /* Calculate the maximum and minimum codes */
+        k = 0;
+        int[] maxCodes = new int[16];
+        int[] minCodes = new int[16];
+        int[] valPtrs = new int[16];
+        for (int i = 0; i < 16; i++) {
+            int bSize = bits[i];
+            if (bSize is 0) {
+                maxCodes[i] = -1;
+            } else {
+                valPtrs[i] = k;
+                minCodes[i] = huffCodes[k];
+                k += bSize;
+                maxCodes[i] = huffCodes[k - 1];
+            }
+        }
+        
+        /* Calculate the eHuffman codes and lengths. */
+        int[] eHuffCodes = new int[256];
+        byte[] eHuffSize = new byte[256];
+        for (int i = 0; i < huffCodesIndex; i++) {
+            eHuffCodes[huffVals[i]] = huffCodes[i];
+            eHuffSize[huffVals[i]] = (byte)huffCodeLengths[i];
+        }
+        
+        /* Create the new JPEGHuffmanTable and add it to the allTables array. */
+        JPEGHuffmanTable dhtTable = new JPEGHuffmanTable(reference);
+        dhtTable.tableClass = tc;
+        dhtTable.tableIdentifier = tid;
+        dhtTable.dhValues = huffVals;
+        dhtTable.dhMinCodes = minCodes;
+        dhtTable.dhMaxCodes = maxCodes;
+        dhtTable.dhValPtrs = valPtrs;
+        dhtTable.ehCodes = eHuffCodes;
+        dhtTable.ehCodeLengths = eHuffSize;
+        huffTables[huffTableCount] = dhtTable;
+        huffTableCount++;
+    }
+    allTables = new JPEGHuffmanTable[huffTableCount];
+    System.arraycopy(huffTables, 0, allTables, 0, huffTableCount);
+}
+
+public int signature() {
+    return JPEGFileFormat.DHT;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGQuantizationTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class JPEGQuantizationTable : JPEGVariableSizeSegment {
+    public static byte[] DefaultLuminanceQTable = {
+        (byte)255, (byte)219, 0, 67, 0,
+        16, 11, 10, 16, 24, 40, 51, 61,
+        12, 12, 14, 19, 26, 58, 60, 55,
+        14, 13, 16, 24, 40, 57, 69, 56,
+        14, 17, 22, 29, 51, 87, 80, 62,
+        18, 22, 37, 56, 68, 109, 103, 77,
+        24, 35, 55, 64, 81, 104, 113, 92,
+        49, 64, 78, 87, 103, 121, 120, 101,
+        72, 92, 95, 98, 112, 100, 103, 99
+    };
+    public static byte[] DefaultChrominanceQTable = {
+        (byte)255, (byte)219, 0, 67, 1,
+        17, 18, 24, 47, 99, 99, 99, 99,
+        18, 21, 26, 66, 99, 99, 99, 99,
+        24, 26, 56, 99, 99, 99, 99, 99,
+        47, 66, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99,
+        99, 99, 99, 99, 99, 99, 99, 99
+    };
+    
+public JPEGQuantizationTable(byte[] reference) {
+    super(reference);
+}
+
+public JPEGQuantizationTable(LEDataInputStream byteStream) {
+    super(byteStream);
+}
+
+public static JPEGQuantizationTable defaultChrominanceTable() {
+    byte[] data = new byte[DefaultChrominanceQTable.length];
+    System.arraycopy(DefaultChrominanceQTable, 0, data, 0, data.length);
+    return new JPEGQuantizationTable(data);
+}
+
+public static JPEGQuantizationTable defaultLuminanceTable() {
+    byte[] data = new byte[DefaultLuminanceQTable.length];
+    System.arraycopy(DefaultLuminanceQTable, 0, data, 0, data.length);
+    return new JPEGQuantizationTable(data);
+}
+
+public int[] getQuantizationTablesKeys() {
+    int[] keys = new int[4];
+    int keysIndex = 0;
+    int totalLength = getSegmentLength() - 2;
+    int ofs = 4;
+    while (totalLength > 64) {
+        int tq = reference[ofs] & 0xF;
+        int pq = (reference[ofs] & 0xFF) >> 4;
+        if (pq is 0) {
+            ofs += 65;
+            totalLength -= 65;
+        } else {
+            ofs += 129;
+            totalLength -= 129;
+        }
+        if (keysIndex >= keys.length) {
+            int[] newKeys = new int[keys.length + 4];
+            System.arraycopy(keys, 0, newKeys, 0, keys.length);
+            keys = newKeys;
+        }
+        keys[keysIndex] = tq;
+        keysIndex++;
+    }
+    int[] newKeys = new int[keysIndex];
+    System.arraycopy(keys, 0, newKeys, 0, keysIndex);
+    return newKeys;
+}
+
+public int[][] getQuantizationTablesValues() {
+    int[][] values = new int[4][];
+    int valuesIndex = 0;
+    int totalLength = getSegmentLength() - 2;
+    int ofs = 4;
+    while (totalLength > 64) {
+        int[] qk = new int[64];
+        int pq = (reference[ofs] & 0xFF) >> 4;
+        if (pq is 0) {
+            for (int i = 0; i < qk.length; i++) {
+                qk[i] = reference[ofs + i + 1] & 0xFF;
+            }
+            ofs += 65;
+            totalLength -= 65;
+        } else {
+            for (int i = 0; i < qk.length; i++) {
+                int idx = (i - 1) * 2 ;
+                qk[i] = (reference[ofs + idx + 1] & 0xFF) * 256 + (reference[ofs + idx + 2] & 0xFF);
+            }
+            ofs += 129;
+            totalLength -= 129;
+        }
+        if (valuesIndex >= values.length) {
+            int[][] newValues = new int[values.length + 4][];
+            System.arraycopy(values, 0, newValues, 0, values.length);
+            values = newValues;
+        }
+        values[valuesIndex] = qk;
+        valuesIndex++;
+    }
+    int[][] newValues = new int[valuesIndex][];
+    System.arraycopy(values, 0, newValues, 0, valuesIndex);
+    return newValues;
+}
+
+public void scaleBy(int qualityFactor) {
+    int qFactor = qualityFactor;
+    if (qFactor <= 0) {
+        qFactor = 1;
+    }
+    if (qFactor > 100) {
+        qFactor = 100;
+    }
+    if (qFactor < 50) {
+        qFactor = 5000 / qFactor;
+    } else {
+        qFactor = 200 - (qFactor * 2);
+    }
+    int totalLength = getSegmentLength() - 2;
+    int ofs = 4;
+    while (totalLength > 64) {
+//      int tq = reference[ofs] & 0xFF;
+        int pq = (reference[ofs] & 0xFF) >> 4;
+        if (pq is 0) {
+            for (int i = ofs + 1; i <= ofs + 64; i++) {
+                int temp = ((reference[i] & 0xFF) * qFactor + 50) / 100;
+                if (temp <= 0) temp = 1;
+                if (temp > 255) temp = 255;
+                reference[i] = (byte)temp;
+            }
+            ofs += 65;
+            totalLength -= 65;
+        } else {
+            for (int i = ofs + 1; i <= ofs + 128; i += 2) {
+                int temp = (((reference[i] & 0xFF) * 256 + (reference[i + 1] & 0xFF)) * qFactor + 50) / 100;
+                if (temp <= 0) temp = 1;
+                if (temp > 32767) temp = 32767;
+                reference[i] = (byte)(temp >> 8);
+                reference[i + 1] = (byte)(temp & 0xFF);
+            }
+            ofs += 129;
+            totalLength -= 129;
+        }
+    }
+}
+
+public int signature() {
+    return JPEGFileFormat.DQT;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGRestartInterval.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class JPEGRestartInterval : JPEGFixedSizeSegment {
+
+    public JPEGRestartInterval(LEDataInputStream byteStream) {
+        super(byteStream);
+    }
+    
+    public int signature() {
+        return JPEGFileFormat.DRI;
+    }
+    
+    public int getRestartInterval() {
+        return ((reference[4] & 0xFF) << 8 | (reference[5] & 0xFF));
+    }
+
+    public int fixedSize() {
+        return 6;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGScanHeader.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+
+final class JPEGScanHeader : JPEGVariableSizeSegment {
+    public int[][] componentParameters;
+
+public JPEGScanHeader(byte[] reference) {
+    super(reference);
+}
+
+public JPEGScanHeader(LEDataInputStream byteStream) {
+    super(byteStream);
+    initializeComponentParameters();
+}
+
+public int getApproxBitPositionHigh() {
+    return reference[(2 * getNumberOfImageComponents()) + 7] >> 4;
+}
+
+public int getApproxBitPositionLow() {
+    return reference[(2 * getNumberOfImageComponents()) + 7] & 0xF;
+}
+
+public int getEndOfSpectralSelection() {
+    return reference[(2 * getNumberOfImageComponents()) + 6];
+}
+
+public int getNumberOfImageComponents() {
+    return reference[4];
+}
+
+public int getStartOfSpectralSelection() {
+    return reference[(2 * getNumberOfImageComponents()) + 5];
+}
+
+/* Used when decoding. */
+void initializeComponentParameters() {
+    int compCount = getNumberOfImageComponents();
+    componentParameters = new int[0][];
+    for (int i = 0; i < compCount; i++) {
+        int ofs = 5 + i * 2;
+        int cid = reference[ofs] & 0xFF;
+        int dc = (reference[ofs + 1] & 0xFF) >> 4;
+        int ac = reference[ofs + 1] & 0xF;
+        if (componentParameters.length <= cid) {
+            int[][] newParams = new int[cid + 1][];
+            System.arraycopy(componentParameters, 0, newParams, 0, componentParameters.length);
+            componentParameters = newParams;
+        }
+        componentParameters[cid] = new int[] { dc, ac };
+    }
+}
+
+/* Used when encoding. */
+public void initializeContents() {
+    int compCount = getNumberOfImageComponents();
+    int[][] compSpecParams = componentParameters;
+    if (compCount is 0 || compCount !is compSpecParams.length) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    for (int i = 0; i < compCount; i++) {
+        int ofs = i * 2 + 5;
+        int[] compParams = compSpecParams[i];
+        reference[ofs] = (byte)(i + 1);
+        reference[ofs + 1] = (byte)(compParams[0] * 16 + compParams[1]);
+    }
+}
+
+public void setEndOfSpectralSelection(int anInteger) {
+    reference[(2 * getNumberOfImageComponents()) + 6] = (byte)anInteger;
+}
+
+public void setNumberOfImageComponents(int anInteger) {
+    reference[4] = (byte)(anInteger & 0xFF);
+}
+
+public void setStartOfSpectralSelection(int anInteger) {
+    reference[(2 * getNumberOfImageComponents()) + 5] = (byte)anInteger;
+}
+
+public int signature() {
+    return JPEGFileFormat.SOS;
+}
+
+public bool verifyProgressiveScan() {
+    int start = getStartOfSpectralSelection();
+    int end = getEndOfSpectralSelection();
+    int low = getApproxBitPositionLow();
+    int high = getApproxBitPositionHigh();
+    int count = getNumberOfImageComponents();
+    if ((start is 0 && end is 00) || (start <= end && end <= 63)) {
+        if (low <= 13 && high <= 13 && (high is 0 || high is low + 1)) {
+            return start is 0 || (start > 0 && count is 1);
+        }
+    }
+    return false;
+}
+
+public bool isACProgressiveScan() {
+    return getStartOfSpectralSelection() !is 0 && getEndOfSpectralSelection() !is 0;
+}
+
+public bool isDCProgressiveScan() {
+    return getStartOfSpectralSelection() is 0 && getEndOfSpectralSelection() is 0;
+}
+
+public bool isFirstScan() {
+    return getApproxBitPositionHigh() is 0;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGSegment.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+class JPEGSegment {
+    public byte[] reference;
+
+    JPEGSegment() {
+    }
+    
+    public JPEGSegment(byte[] reference) {
+        this.reference = reference;
+    }
+    
+    public int signature() {
+        return 0;
+    }
+    
+    public bool verify() {
+        return getSegmentMarker() is signature();
+    }
+    
+    public int getSegmentMarker() {
+        return ((reference[0] & 0xFF) << 8 | (reference[1] & 0xFF));
+    }
+    
+    public void setSegmentMarker(int marker) {
+        reference[0] = (byte)((marker & 0xFF00) >> 8);
+        reference[1] = (byte)(marker & 0xFF);
+    }
+    
+    public int getSegmentLength() {
+        return ((reference[2] & 0xFF) << 8 | (reference[3] & 0xFF));
+    }
+    
+    public void setSegmentLength(int length) {
+        reference[2] = (byte)((length & 0xFF00) >> 8);
+        reference[3] = (byte)(length & 0xFF);
+    }
+    
+    public bool writeToStream(LEDataOutputStream byteStream) {
+        try {
+            byteStream.write(reference);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGStartOfImage.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class JPEGStartOfImage : JPEGFixedSizeSegment {
+
+    public JPEGStartOfImage() {
+        super();
+    }
+    
+    public JPEGStartOfImage(byte[] reference) {
+        super(reference);
+    }
+    
+    public JPEGStartOfImage(LEDataInputStream byteStream) {
+        super(byteStream);
+    }
+    
+    public int signature() {
+        return JPEGFileFormat.SOI;
+    }
+    
+    public int fixedSize() {
+        return 2;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/JPEGVariableSizeSegment.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+
+abstract class JPEGVariableSizeSegment : JPEGSegment {
+
+    public JPEGVariableSizeSegment(byte[] reference) {
+        super(reference);
+    }
+    
+    public JPEGVariableSizeSegment(LEDataInputStream byteStream) {
+        try {
+            byte[] header = new byte[4];
+            byteStream.read(header);
+            reference = header; // to use getSegmentLength()
+            byte[] contents = new byte[getSegmentLength() + 2];
+            contents[0] = header[0];
+            contents[1] = header[1];
+            contents[2] = header[2];
+            contents[3] = header[3];
+            byteStream.read(contents, 4, contents.length - 4);
+            reference = contents;
+        } catch (Exception e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/LEDataInputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+
+final class LEDataInputStream : InputStream {
+    int position;
+    InputStream in;
+
+    /**
+     * The byte array containing the bytes to read.
+     */
+    protected byte[] buf;
+    
+    /**
+     * The current position within the byte array <code>buf</code>. A value
+     * equal to buf.length indicates no bytes available.  A value of
+     * 0 indicates the buffer is full.
+     */
+    protected int pos;
+    
+
+    public LEDataInputStream(InputStream input) {
+        this(input, 512);
+    }
+    
+    public LEDataInputStream(InputStream input, int bufferSize) {
+        this.in = input;
+        if (bufferSize > 0) {
+            buf = new byte[bufferSize];
+            pos = bufferSize;
+        } 
+        else throw new IllegalArgumentException();
+    }
+    
+    public void close() throws IOException {
+        buf = null;
+        if (in !is null) {
+            in.close();
+            in = null;
+        }
+    }
+    
+    /**
+     * Answer how many bytes were read.
+     */
+    public int getPosition() {
+        return position;
+    }
+    
+    /**
+     * Answers how many bytes are available for reading without blocking
+     */
+    public int available() throws IOException {
+        if (buf is null) throw new IOException();
+        return (buf.length - pos) + in.available();
+    }
+    
+    /**
+     * Answer the next byte of the input stream.
+     */
+    public int read() throws IOException {
+        if (buf is null) throw new IOException();
+        if (pos < buf.length) {
+            position++;
+            return (buf[pos++] & 0xFF);
+        }
+        int c = in.read();
+        if (c !is -1) position++;
+        return c;
+    }
+    
+    /**
+     * Don't imitate the JDK behaviour of reading a random number
+     * of bytes when you can actually read them all.
+     */
+    public int read(byte b[], int off, int len) throws IOException {
+        int read = 0, count;
+        while (read !is len && (count = readData(b, off, len - read)) !is -1) {
+            off += count;
+            read += count;
+        }
+        position += read;
+        if (read is 0 && read !is len) return -1;
+        return read;
+    }
+    
+    /**
+     * Reads at most <code>length</code> bytes from this LEDataInputStream and 
+     * stores them in byte array <code>buffer</code> starting at <code>offset</code>.
+     * <p>
+     * Answer the number of bytes actually read or -1 if no bytes were read and 
+     * end of stream was encountered.  This implementation reads bytes from 
+     * the pushback buffer first, then the target stream if more bytes are required
+     * to satisfy <code>count</code>.
+     * </p>
+     * @param buffer the byte array in which to store the read bytes.
+     * @param offset the offset in <code>buffer</code> to store the read bytes.
+     * @param length the maximum number of bytes to store in <code>buffer</code>.
+     *
+     * @return int the number of bytes actually read or -1 if end of stream.
+     *
+     * @exception java.io.IOException if an IOException occurs.
+     */
+    private int readData(byte[] buffer, int offset, int length) throws IOException {
+        if (buf is null) throw new IOException();
+        if (offset < 0 || offset > buffer.length ||
+            length < 0 || (length > buffer.length - offset)) {
+            throw new ArrayIndexOutOfBoundsException();
+            }
+                
+        int cacheCopied = 0;
+        int newOffset = offset;
+    
+        // Are there pushback bytes available?
+        int available = buf.length - pos;
+        if (available > 0) {
+            cacheCopied = (available >= length) ? length : available;
+            System.arraycopy(buf, pos, buffer, newOffset, cacheCopied);
+            newOffset += cacheCopied;
+            pos += cacheCopied;
+        }
+    
+        // Have we copied enough?
+        if (cacheCopied is length) return length;
+
+        int inCopied = in.read(buffer, newOffset, length - cacheCopied);
+
+        if (inCopied > 0) return inCopied + cacheCopied;
+        if (cacheCopied is 0) return inCopied;
+        return cacheCopied;
+    }
+    
+    /**
+     * Answer an integer comprised of the next
+     * four bytes of the input stream.
+     */
+    public int readInt() throws IOException {
+        byte[] buf = new byte[4];
+        read(buf);
+        return ((buf[3] & 0xFF) << 24) | 
+            ((buf[2] & 0xFF) << 16) | 
+            ((buf[1] & 0xFF) << 8) | 
+            (buf[0] & 0xFF);
+    }
+    
+    /**
+     * Answer a short comprised of the next
+     * two bytes of the input stream.
+     */
+    public short readShort() throws IOException {
+        byte[] buf = new byte[2];
+        read(buf);
+        return (short)(((buf[1] & 0xFF) << 8) | (buf[0] & 0xFF));
+    }
+    
+    /**
+     * Push back the entire content of the given buffer <code>b</code>.
+     * <p>
+     * The bytes are pushed so that they would be read back b[0], b[1], etc. 
+     * If the push back buffer cannot handle the bytes copied from <code>b</code>, 
+     * an IOException will be thrown and no byte will be pushed back.
+     * </p>
+     * 
+     * @param b the byte array containing bytes to push back into the stream
+     *
+     * @exception   java.io.IOException if the pushback buffer is too small
+     */
+    public void unread(byte[] b) throws IOException {
+        int length = b.length;
+        if (length > pos) throw new IOException();
+        position -= length;
+        pos -= length;
+        System.arraycopy(b, 0, buf, pos, length);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/LEDataOutputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+final class LEDataOutputStream : OutputStream {
+    OutputStream out;
+public LEDataOutputStream(OutputStream output) {
+    this.out = output;
+}
+/**
+ * Write the specified number of bytes of the given byte array,
+ * starting at the specified offset, to the output stream.
+ */
+public void write(byte b[], int off, int len) throws IOException {
+    out.write(b, off, len);
+}
+/**
+ * Write the given byte to the output stream.
+ */
+public void write(int b) throws IOException {
+    out.write(b);
+}
+/**
+ * Write the given byte to the output stream.
+ */
+public void writeByte(byte b) throws IOException {
+    out.write(b & 0xFF);
+}
+/**
+ * Write the four bytes of the given integer
+ * to the output stream.
+ */
+public void writeInt(int theInt) throws IOException {
+    out.write(theInt & 0xFF);
+    out.write((theInt >> 8) & 0xFF);
+    out.write((theInt >> 16) & 0xFF);
+    out.write((theInt >> 24) & 0xFF);
+}
+/**
+ * Write the two bytes of the given short
+ * to the output stream.
+ */
+public void writeShort(int theShort) throws IOException {
+    out.write(theShort & 0xFF);
+    out.write((theShort >> 8) & 0xFF);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/LZWCodec.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,479 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.ImageLoaderEvent;
+
+final class LZWCodec {
+    int bitsPerPixel, blockSize, blockIndex, currentByte, bitsLeft,
+        codeSize, clearCode, endCode, newCodes, topSlot, currentSlot,
+        imageWidth, imageHeight, imageX, imageY, pass, line, codeMask;
+    byte[] block, lineArray;
+    int[] stack, suffix, prefix;
+    LZWNode[] nodeStack;
+    LEDataInputStream inputStream;
+    LEDataOutputStream outputStream;
+    ImageData image;
+    ImageLoader loader;
+    bool interlaced;
+    static final int[] MASK_TABLE = new int[] {
+        0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F,
+        0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF
+    };
+
+/**
+ * Decode the input.
+ */
+void decode() {
+    int code;
+    int oc = 0;
+    int fc = 0;
+    byte[] buf = new byte[imageWidth];
+    int stackIndex = 0;
+    int bufIndex = 0;
+    int c;
+    while ((c = nextCode()) !is endCode) {
+        if (c is clearCode) {
+            codeSize = bitsPerPixel + 1;
+            codeMask = MASK_TABLE[bitsPerPixel];
+            currentSlot = newCodes;
+            topSlot = 1 << codeSize;
+            while ((c = nextCode()) is clearCode) {}
+            if (c !is endCode) {
+                oc = fc = c;
+                buf[bufIndex] = (byte)c;
+                bufIndex++;
+                if (bufIndex is imageWidth) {
+                    nextPutPixels(buf);
+                    bufIndex = 0;
+                }
+            }
+        } else {
+            code = c;
+            if (code >= currentSlot) {
+                code = oc;
+                stack[stackIndex] = fc;
+                stackIndex++;
+            }
+            while (code >= newCodes) {
+                stack[stackIndex] = suffix[code];
+                stackIndex++;
+                code = prefix[code];
+            }
+            stack[stackIndex] = code;
+            stackIndex++;
+            if (currentSlot < topSlot) {
+                fc = code;
+                suffix[currentSlot] = fc;
+                prefix[currentSlot] = oc;
+                currentSlot++;
+                oc = c;
+            }
+            if (currentSlot >= topSlot) {
+                if (codeSize < 12) {
+                    codeMask = MASK_TABLE[codeSize];
+                    codeSize++;
+                    topSlot = topSlot + topSlot;
+                }
+            }
+            while (stackIndex > 0) {
+                stackIndex--;
+                buf[bufIndex] = (byte)stack[stackIndex];
+                bufIndex++;
+                if (bufIndex is imageWidth) {
+                    nextPutPixels(buf);
+                    bufIndex = 0;
+                }
+            }
+        }
+    }
+    if (bufIndex !is 0 && line < imageHeight) {
+        nextPutPixels(buf);
+    }
+}
+/**
+ * Decode the LZW-encoded bytes in the given byte stream
+ * into the given DeviceIndependentImage.
+ */
+public void decode(LEDataInputStream inputStream, ImageLoader loader, ImageData image, bool interlaced, int depth) {
+    this.inputStream = inputStream;
+    this.loader = loader;
+    this.image = image;
+    this.interlaced = interlaced;
+    this.bitsPerPixel = depth;
+    initializeForDecoding();
+    decode();
+}
+/**
+ * Encode the image.
+ */
+void encode() {
+    nextPutCode(clearCode);
+    int lastPrefix = encodeLoop();
+    nextPutCode(lastPrefix);
+    nextPutCode(endCode);
+
+    // Write out last partial block
+    if (bitsLeft is 8) {
+        block[0] = (byte)(blockIndex - 1); // Nothing in last byte
+    } else {
+        block[0] = (byte)(blockIndex); // Last byte has data
+    }
+    writeBlock();
+
+    // Write out empty block to indicate the end (if needed)
+    if (block[0] !is 0) {
+        block[0] = 0;
+        writeBlock();
+    }
+}
+/**
+ * Encode the bytes into the given byte stream
+ * from the given DeviceIndependentImage.
+ */
+public void encode(LEDataOutputStream byteStream, ImageData image) {
+    this.outputStream = byteStream;
+    this.image = image;
+    initializeForEncoding();
+    encode();
+}
+/**
+ * Encoding loop broken out to allow early return.
+ */
+int encodeLoop() {
+    int pixel = nextPixel();
+    bool found;
+    LZWNode node;
+    while (true) {
+        int currentPrefix = pixel;
+        node = nodeStack[currentPrefix];
+        found = true;
+        pixel = nextPixel();
+        if (pixel < 0)
+            return currentPrefix;
+        while (found && (node.children !is null)) {
+            node = node.children;
+            while (found && (node.suffix !is pixel)) {
+                if (pixel < node.suffix) {
+                    if (node.left is null) {
+                        node.left = new LZWNode();
+                        found = false;
+                    }
+                    node = node.left;
+                } else {
+                    if (node.right is null) {
+                        node.right = new LZWNode();
+                        found = false;
+                    }
+                    node = node.right;
+                }
+            }
+            if (found) {
+                currentPrefix = node.code;
+                pixel = nextPixel();
+                if (pixel < 0)
+                    return currentPrefix;
+            }
+        }
+        if (found) {
+            node.children = new LZWNode();
+            node = node.children;
+        }
+        node.children = null;
+        node.left = null;
+        node.right = null;
+        node.code = currentSlot;
+        node.prefix = currentPrefix;
+        node.suffix = pixel;
+        nextPutCode(currentPrefix);
+        currentSlot++;
+        // Off by one?
+        if (currentSlot < 4096) {
+            if (currentSlot > topSlot) {
+                codeSize++;
+                codeMask = MASK_TABLE[codeSize - 1];
+                topSlot *= 2;
+            }
+        } else {
+            nextPutCode(clearCode);
+            for (int i = 0; i < nodeStack.length; i++)
+                nodeStack[i].children = null;
+            codeSize = bitsPerPixel + 1;
+            codeMask = MASK_TABLE[codeSize - 1];
+            currentSlot = newCodes;
+            topSlot = 1 << codeSize;
+        }
+    }
+}
+/**
+ * Initialize the receiver for decoding the given
+ * byte array.
+ */
+void initializeForDecoding() {
+    pass = 1;
+    line = 0;
+    codeSize = bitsPerPixel + 1;
+    topSlot = 1 << codeSize;
+    clearCode = 1 << bitsPerPixel;
+    endCode = clearCode + 1;
+    newCodes = currentSlot = endCode + 1;
+    currentByte = -1;
+    blockSize = bitsLeft = 0;
+    blockIndex = 0;
+    codeMask = MASK_TABLE[codeSize - 1];
+    stack = new int[4096];
+    suffix = new int[4096];
+    prefix = new int[4096];
+    block = new byte[256];
+    imageWidth = image.width;
+    imageHeight = image.height;
+}
+/**
+ * Initialize the receiver for encoding the given
+ * byte array.
+ */
+void initializeForEncoding() {
+    interlaced = false;
+    bitsPerPixel = image.depth;
+    codeSize = bitsPerPixel + 1;
+    topSlot = 1 << codeSize;
+    clearCode = 1 << bitsPerPixel;
+    endCode = clearCode + 1;
+    newCodes = currentSlot = endCode + 1;
+    bitsLeft = 8;
+    currentByte = 0;
+    blockIndex = 1;
+    blockSize = 255;
+    block = new byte[blockSize];
+    block[0] = (byte)(blockSize - 1);
+    nodeStack = new LZWNode[1 << bitsPerPixel];
+    for (int i = 0; i < nodeStack.length; i++) {
+        LZWNode node = new LZWNode();
+        node.code = i + 1;
+        node.prefix = -1;
+        node.suffix = i + 1;
+        nodeStack[i] = node;
+    }
+    imageWidth = image.width;
+    imageHeight = image.height;
+    imageY = -1;
+    lineArray = new byte[imageWidth];
+    imageX = imageWidth + 1; // Force a read
+}
+/**
+ * Answer the next code from the input byte array.
+ */
+int nextCode() {
+    int code;
+    if (bitsLeft is 0) {
+        if (blockIndex >= blockSize) {
+            blockSize = readBlock();
+            blockIndex = 0;
+            if (blockSize is 0) return endCode;
+        }
+        blockIndex++;
+        currentByte = block[blockIndex] & 0xFF;
+        bitsLeft = 8;
+        code = currentByte;
+    } else {
+        int shift = bitsLeft - 8;
+        if (shift < 0)
+            code = currentByte >> (0 - shift);
+        else
+            code = currentByte << shift;
+    }
+    while (codeSize > bitsLeft) {
+        if (blockIndex >= blockSize) {
+            blockSize = readBlock();
+            blockIndex = 0;
+            if (blockSize is 0) return endCode;
+        }
+        blockIndex++;
+        currentByte = block[blockIndex] & 0xFF;
+        code += currentByte << bitsLeft;
+        bitsLeft += 8;
+    }
+    bitsLeft -= codeSize;
+    return code & codeMask;
+}
+/**
+ * Answer the next pixel to encode in the image
+ */
+int nextPixel() {
+    imageX++;
+    if (imageX > imageWidth) {
+        imageY++;
+        if (imageY >= imageHeight) {
+            return -1;
+        } else {
+            nextPixels(lineArray, imageWidth);
+        }
+        imageX = 1;
+    }
+    return this.lineArray[imageX - 1] & 0xFF;
+}
+/**
+ * Copy a row of pixel values from the image.
+ */
+void nextPixels(byte[] buf, int lineWidth) {
+    if (image.depth is 8) {
+        System.arraycopy(image.data, imageY * image.bytesPerLine, buf, 0, lineWidth);
+    } else {
+        image.getPixels(0, imageY, lineWidth, buf, 0);
+    }
+}
+/**
+ * Output aCode to the output stream.
+ */
+void nextPutCode(int aCode) {
+    int codeToDo = aCode;
+    int codeBitsToDo = codeSize;
+    // Fill in the remainder of the current byte with the
+    // *high-order* bits of the code.
+    int c = codeToDo & MASK_TABLE[bitsLeft - 1];
+    currentByte = currentByte | (c << (8 - bitsLeft));
+    block[blockIndex] = (byte)currentByte;
+    codeBitsToDo -= bitsLeft;
+    if (codeBitsToDo < 1) {
+        // The whole code fit in the first byte, so we are done.
+        bitsLeft -= codeSize;
+        if (bitsLeft is 0) {
+            // We used the whole last byte, so get ready
+            // for the next one.
+            bitsLeft = 8;
+            blockIndex++;
+            if (blockIndex >= blockSize) {
+                writeBlock();
+                blockIndex = 1;
+            }
+            currentByte = 0;
+        }
+        return;
+    }
+    codeToDo = codeToDo >> bitsLeft;
+
+    // Fill in any remaining whole bytes (i.e. not the last one!)
+    blockIndex++;
+    if (blockIndex >= blockSize) {
+        writeBlock();
+        blockIndex = 1;
+    }
+    while (codeBitsToDo >= 8) {
+        currentByte = codeToDo & 0xFF;
+        block[blockIndex] = (byte)currentByte;
+        codeToDo = codeToDo >> 8;
+        codeBitsToDo -= 8;
+        blockIndex++;
+        if (blockIndex >= blockSize) {
+            writeBlock();
+            blockIndex = 1;
+        }
+    }
+    // Fill the *low-order* bits of the last byte with the remainder
+    bitsLeft = 8 - codeBitsToDo;
+    currentByte = codeToDo;
+    block[blockIndex] = (byte)currentByte;
+}
+/**
+ * Copy a row of pixel values to the image.
+ */
+void nextPutPixels(byte[] buf) {
+    if (image.depth is 8) {
+        // Slight optimization for depth = 8.
+        int start = line * image.bytesPerLine;
+        for (int i = 0; i < imageWidth; i++)
+            image.data[start + i] = buf[i];
+    } else {
+        image.setPixels(0, line, imageWidth, buf, 0);
+    }
+    if (interlaced) {
+        if (pass is 1) {
+            copyRow(buf, 7);
+            line += 8;
+        } else if (pass is 2) {
+            copyRow(buf, 3);
+            line += 8;
+        } else if (pass is 3) {
+            copyRow(buf, 1);
+            line += 4;
+        } else if (pass is 4) {
+            line += 2;
+        } else if (pass is 5) {
+            line += 0;
+        }
+        if (line >= imageHeight) {
+            pass++;
+            if (pass is 2) line = 4;
+            else if (pass is 3) line = 2;
+            else if (pass is 4) line = 1;
+            else if (pass is 5) line = 0;
+            if (pass < 5) {
+                if (loader.hasListeners()) {
+                    ImageData imageCopy = (ImageData) image.clone();
+                    loader.notifyListeners(
+                        new ImageLoaderEvent(loader, imageCopy, pass - 2, false));
+                }
+            }
+        }
+        if (line >= imageHeight) line = 0;
+    } else {
+        line++;
+    }
+}
+/**
+ * Copy duplicate rows of pixel values to the image.
+ * This is to fill in rows if the image is interlaced.
+ */
+void copyRow(byte[] buf, int copies) {
+    for (int i = 1; i <= copies; i++) {
+        if (line + i < imageHeight) {
+            image.setPixels(0, line + i, imageWidth, buf, 0);
+        }
+    }
+}
+/**
+ * Read a block from the byte stream.
+ * Return the number of bytes read.
+ * Throw an exception if the block could not be read.
+ */
+int readBlock() {
+    int size = -1;
+    try {
+        size = inputStream.read();
+        if (size is -1) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+        block[0] = (byte)size;
+        size = inputStream.read(block, 1, size);
+        if (size is -1) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+    } catch (Exception e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return size;
+}
+/**
+ * Write a block to the byte stream.
+ * Throw an exception if the block could not be written.
+ */
+void writeBlock() {
+    try {
+        outputStream.write(block, 0, (block[0] & 0xFF) + 1);
+    } catch (Exception e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/LZWNode.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+final class LZWNode {
+    public LZWNode left, right, children;
+    public int code, prefix, suffix;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/OS2BMPFileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+
+public final class OS2BMPFileFormat : FileFormat {
+    static final int BMPFileHeaderSize = 14;
+    static final int BMPHeaderFixedSize = 12;
+    int width, height, bitCount;
+
+bool isFileFormat(LEDataInputStream stream) {
+    try {
+        byte[] header = new byte[18];
+        stream.read(header);
+        stream.unread(header);
+        int infoHeaderSize = (header[14] & 0xFF) | ((header[15] & 0xFF) << 8) | ((header[16] & 0xFF) << 16) | ((header[17] & 0xFF) << 24);
+        return header[0] is 0x42 && header[1] is 0x4D && infoHeaderSize is BMPHeaderFixedSize;
+    } catch (Exception e) {
+        return false;
+    }
+}
+byte[] loadData(byte[] infoHeader) {
+    int stride = (width * bitCount + 7) / 8;
+    stride = (stride + 3) / 4 * 4; // Round up to 4 byte multiple
+    byte[] data = loadData(infoHeader, stride);
+    flipScanLines(data, stride, height);
+    return data;
+}
+byte[] loadData(byte[] infoHeader, int stride) {
+    int dataSize = height * stride;
+    byte[] data = new byte[dataSize];
+    try {
+        if (inputStream.read(data) !is dataSize)
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return data;
+}
+int[] loadFileHeader() {
+    int[] header = new int[5];
+    try {
+        header[0] = inputStream.readShort();
+        header[1] = inputStream.readInt();
+        header[2] = inputStream.readShort();
+        header[3] = inputStream.readShort();
+        header[4] = inputStream.readInt();
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    if (header[0] !is 0x4D42)
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    return header;
+}
+ImageData[] loadFromByteStream() {
+    int[] fileHeader = loadFileHeader();
+    byte[] infoHeader = new byte[BMPHeaderFixedSize];
+    try {
+        inputStream.read(infoHeader);
+    } catch (Exception e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8);
+    height = (infoHeader[6] & 0xFF) | ((infoHeader[7] & 0xFF) << 8);
+    bitCount = (infoHeader[10] & 0xFF) | ((infoHeader[11] & 0xFF) << 8);
+    PaletteData palette = loadPalette(infoHeader);
+    if (inputStream.getPosition() < fileHeader[4]) {
+        // Seek to the specified offset
+        try {
+            inputStream.skip(fileHeader[4] - inputStream.getPosition());
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+    byte[] data = loadData(infoHeader);
+    int type = DWT.IMAGE_OS2_BMP;
+    return new ImageData[] {
+        ImageData.internal_new(
+            width,
+            height,
+            bitCount,
+            palette,
+            4,
+            data,
+            0,
+            null,
+            null,
+            -1,
+            -1,
+            type,
+            0,
+            0,
+            0,
+            0)
+    };
+}
+PaletteData loadPalette(byte[] infoHeader) {
+    if (bitCount <= 8) {
+        int numColors = 1 << bitCount;
+        byte[] buf = new byte[numColors * 3];
+        try {
+            if (inputStream.read(buf) !is buf.length)
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        return paletteFromBytes(buf, numColors);
+    }
+    if (bitCount is 16) return new PaletteData(0x7C00, 0x3E0, 0x1F);
+    if (bitCount is 24) return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+    return new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+}
+PaletteData paletteFromBytes(byte[] bytes, int numColors) {
+    int bytesOffset = 0;
+    RGB[] colors = new RGB[numColors];
+    for (int i = 0; i < numColors; i++) {
+        colors[i] = new RGB(bytes[bytesOffset + 2] & 0xFF,
+            bytes[bytesOffset + 1] & 0xFF,
+            bytes[bytesOffset] & 0xFF);
+        bytesOffset += 3;
+    }
+    return new PaletteData(colors);
+}
+/**
+ * Answer a byte array containing the BMP representation of
+ * the given device independent palette.
+ */
+static byte[] paletteToBytes(PaletteData pal) {
+    int n = pal.colors is null ? 0 : (pal.colors.length < 256 ? pal.colors.length : 256);
+    byte[] bytes = new byte[n * 3];
+    int offset = 0;
+    for (int i = 0; i < n; i++) {
+        RGB col = pal.colors[i];
+        bytes[offset] = (byte)col.blue;
+        bytes[offset + 1] = (byte)col.green;
+        bytes[offset + 2] = (byte)col.red;
+        offset += 3;
+    }
+    return bytes;
+}
+/**
+ * Unload the given image's data into the given byte stream. 
+ * Answer the number of bytes written.
+ */
+int unloadData(ImageData image, OutputStream out) {
+    int bmpBpl = 0;
+    try {
+        int bpl = (image.width * image.depth + 7) / 8;
+        bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
+        int linesPerBuf = 32678 / bmpBpl;
+        byte[] buf = new byte[linesPerBuf * bmpBpl];
+        byte[] data = image.data;
+        int imageBpl = image.bytesPerLine;
+        int dataIndex = imageBpl * (image.height - 1); // Start at last line
+        if (image.depth is 16) {
+            for (int y = 0; y < image.height; y += linesPerBuf) {
+                int count = image.height - y;
+                if (linesPerBuf < count) count = linesPerBuf;
+                int bufOffset = 0;
+                for (int i = 0; i < count; i++) {
+                    for (int wIndex = 0; wIndex < bpl; wIndex += 2) {
+                        buf[bufOffset + wIndex + 1] = data[dataIndex + wIndex + 1];
+                        buf[bufOffset + wIndex] = data[dataIndex + wIndex];
+                    }
+                    bufOffset += bmpBpl;
+                    dataIndex -= imageBpl;
+                }
+                out.write(buf, 0, bufOffset);
+            }
+        } else {
+            for (int y = 0; y < image.height; y += linesPerBuf) {
+                int tmp = image.height - y;
+                int count = tmp < linesPerBuf ? tmp : linesPerBuf;
+                int bufOffset = 0;
+                for (int i = 0; i < count; i++) {
+                    System.arraycopy(data, dataIndex, buf, bufOffset, bpl);
+                    bufOffset += bmpBpl;
+                    dataIndex -= imageBpl;
+                }
+                out.write(buf, 0, bufOffset);
+            }
+        }
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return bmpBpl * image.height;
+}
+/**
+ * Unload a DeviceIndependentImage using Windows .BMP format into the given
+ * byte stream.
+ */
+void unloadIntoByteStream(ImageLoader loader) {
+    ImageData image = loader.data[0];
+    byte[] rgbs;
+    int numCols;
+    if (!((image.depth is 1) || (image.depth is 4) || (image.depth is 8) ||
+          (image.depth is 16) || (image.depth is 24) || (image.depth is 32)))
+            DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+    PaletteData pal = image.palette;
+    if ((image.depth is 16) || (image.depth is 24) || (image.depth is 32)) {
+        if (!pal.isDirect)
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        numCols = 0;
+        rgbs = null;
+    } else {
+        if (pal.isDirect)
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        numCols = pal.colors.length;
+        rgbs = paletteToBytes(pal);
+    }
+    // Fill in file header, except for bfsize, which is done later.
+    int headersSize = BMPFileHeaderSize + BMPHeaderFixedSize;
+    int[] fileHeader = new int[5];
+    fileHeader[0] = 0x4D42; // Signature
+    fileHeader[1] = 0; // File size - filled in later
+    fileHeader[2] = 0; // Reserved 1
+    fileHeader[3] = 0; // Reserved 2
+    fileHeader[4] = headersSize; // Offset to data
+    if (rgbs !is null) {
+        fileHeader[4] += rgbs.length;
+    }
+
+    // Prepare data. This is done first so we don't have to try to rewind
+    // the stream and fill in the details later.
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    unloadData(image, out);
+    byte[] data = out.toByteArray();
+    
+    // Calculate file size
+    fileHeader[1] = fileHeader[4] + data.length;
+
+    // Write the headers
+    try {
+        outputStream.writeShort(fileHeader[0]);
+        outputStream.writeInt(fileHeader[1]);
+        outputStream.writeShort(fileHeader[2]);
+        outputStream.writeShort(fileHeader[3]);
+        outputStream.writeInt(fileHeader[4]);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    try {
+        outputStream.writeInt(BMPHeaderFixedSize);
+        outputStream.writeShort(image.width);
+        outputStream.writeShort(image.height);
+        outputStream.writeShort(1);
+        outputStream.writeShort((short)image.depth);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    
+    // Unload palette
+    if (numCols > 0) {
+        try {
+            outputStream.write(rgbs);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+
+    // Unload the data
+    try {
+        outputStream.write(data);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+void flipScanLines(byte[] data, int stride, int height) {
+    int i1 = 0;
+    int i2 = (height - 1) * stride;
+    for (int i = 0; i < height / 2; i++) {
+        for (int index = 0; index < stride; index++) {
+            byte b = data[index + i1];
+            data[index + i1] = data[index + i2];
+            data[index + i2] = b;
+        }
+        i1 += stride;
+        i2 -= stride;
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PNGFileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,579 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.ImageLoaderEvent;
+import dwt.graphics.PaletteData;
+import dwt.internal.Compatibility;
+
+public final class PNGFileFormat : FileFormat {
+    static final int SIGNATURE_LENGTH = 8;
+    static final int PRIME = 65521;
+    PngIhdrChunk headerChunk;
+    PngPlteChunk paletteChunk;
+    ImageData imageData;
+    byte[] data;
+    byte[] alphaPalette;
+    byte headerByte1;
+    byte headerByte2;
+    int adler;
+
+/**
+ * Skip over signature data. This has already been
+ * verified in isFileFormat(). 
+ */
+void readSignature() throws IOException {
+    byte[] signature = new byte[SIGNATURE_LENGTH];
+    inputStream.read(signature);
+}
+/**
+ * Load the PNG image from the byte stream.
+ */
+ImageData[] loadFromByteStream() {
+    try {
+        readSignature();
+        PngChunkReader chunkReader = new PngChunkReader(inputStream);
+        headerChunk = chunkReader.getIhdrChunk();
+        int width = headerChunk.getWidth(), height = headerChunk.getHeight();
+        if (width <= 0 || height <= 0) DWT.error(DWT.ERROR_INVALID_IMAGE);
+        int imageSize = getAlignedBytesPerRow() * height;
+        data = new byte[imageSize];     
+        imageData = ImageData.internal_new(
+            width,
+            height,
+            headerChunk.getSwtBitsPerPixel(),
+            new PaletteData(0, 0, 0),
+            4,
+            data,
+            0,
+            null,
+            null,
+            -1,
+            -1,
+            DWT.IMAGE_PNG,
+            0,
+            0,
+            0,
+            0);     
+            
+        if (headerChunk.usesDirectColor()) {
+            imageData.palette = headerChunk.getPaletteData();
+        }
+        
+        // Read and process chunks until the IEND chunk is encountered.
+        while (chunkReader.hasMoreChunks()) {
+            readNextChunk(chunkReader);
+        }
+                        
+        return new ImageData[] {imageData};
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+        return null;
+    }
+}
+/**
+ * Read and handle the next chunk of data from the 
+ * PNG file.
+ */
+void readNextChunk(PngChunkReader chunkReader) throws IOException {
+    PngChunk chunk = chunkReader.readNextChunk();
+    switch (chunk.getChunkType()) {
+        case PngChunk.CHUNK_IEND:
+            break;
+        case PngChunk.CHUNK_PLTE:
+            if (!headerChunk.usesDirectColor()) {
+                paletteChunk = (PngPlteChunk) chunk;
+                imageData.palette = paletteChunk.getPaletteData();                      
+            }           
+            break;
+        case PngChunk.CHUNK_tRNS:
+            PngTrnsChunk trnsChunk = (PngTrnsChunk) chunk;
+            if (trnsChunk.getTransparencyType(headerChunk) is 
+                PngTrnsChunk.TRANSPARENCY_TYPE_PIXEL) 
+            {
+                imageData.transparentPixel = 
+                    trnsChunk.getSwtTransparentPixel(headerChunk);
+            } else {
+                alphaPalette = trnsChunk.getAlphaValues(headerChunk, paletteChunk);
+                int transparentCount = 0, transparentPixel = -1;
+                for (int i = 0; i < alphaPalette.length; i++) {
+                    if ((alphaPalette[i] & 0xFF) !is 255) {
+                        transparentCount++;
+                        transparentPixel = i;
+                    }
+                }
+                if (transparentCount is 0) {
+                    alphaPalette = null;
+                } else if (transparentCount is 1 && alphaPalette[transparentPixel] is 0) {
+                    alphaPalette = null;
+                    imageData.transparentPixel = transparentPixel;
+                }
+            }
+            break;
+        case PngChunk.CHUNK_IDAT:
+            if (chunkReader.readPixelData()) {
+                // All IDAT chunks in an image file must be
+                // sequential. If the pixel data has already
+                // been read and another IDAT block is encountered,
+                // then this is an invalid image.
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+            } else {
+                // Read in the pixel data for the image. This should
+                // go through all the image's IDAT chunks.  
+                PngIdatChunk dataChunk = (PngIdatChunk) chunk;
+                readPixelData(dataChunk, chunkReader);              
+            }
+            break;
+        default:
+            if (chunk.isCritical()) {
+                // All critical chunks must be supported.
+                DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
+            }
+    }
+}
+void unloadIntoByteStream(ImageLoader loader) {
+    PngEncoder encoder = new PngEncoder(loader);
+    encoder.encode(outputStream);
+}
+bool isFileFormat(LEDataInputStream stream) {
+    try {
+        byte[] signature = new byte[SIGNATURE_LENGTH];
+        stream.read(signature);
+        stream.unread(signature);
+        if ((signature[0] & 0xFF) !is 137) return false; //137
+        if ((signature[1] & 0xFF) !is 80) return false; //P
+        if ((signature[2] & 0xFF) !is 78) return false; //N
+        if ((signature[3] & 0xFF) !is 71) return false; //G
+        if ((signature[4] & 0xFF) !is 13) return false; //<RETURN>
+        if ((signature[5] & 0xFF) !is 10) return false; //<LINEFEED>
+        if ((signature[6] & 0xFF) !is 26) return false; //<CTRL/Z>
+        if ((signature[7] & 0xFF) !is 10) return false; //<LINEFEED>        
+        return true;
+    } catch (Exception e) {
+        return false;
+    }
+}
+/**
+ * DWT does not support 16-bit depths. If this image uses
+ * 16-bit depths, convert the data to an 8-bit depth.
+ */
+byte[] validateBitDepth(byte[] data) {
+    if (headerChunk.getBitDepth() > 8) {
+        byte[] result = new byte[data.length / 2];
+        compress16BitDepthTo8BitDepth(data, 0, result, 0, result.length);
+        return result;
+    } else {
+        return data;
+    }
+}
+/**
+ * DWT does not support greyscale as a color type. For
+ * plain grayscale, we create a palette. For Grayscale
+ * with Alpha, however, we need to convert the pixels
+ * to use RGB values.
+ * Note: This method assumes that the bit depth of the
+ * data has already been restricted to 8 or less.
+ */
+void setPixelData(byte[] data, ImageData imageData) {
+    switch (headerChunk.getColorType()) {
+        case PngIhdrChunk.COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+        {
+            int width = imageData.width;
+            int height = imageData.height;
+            int destBytesPerLine = imageData.bytesPerLine;
+            /*
+            * If the image uses 16-bit depth, it is converted
+            * to an 8-bit depth image.
+            */
+            int srcBytesPerLine = getAlignedBytesPerRow();
+            if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
+            byte[] rgbData = new byte[destBytesPerLine * height];
+            byte[] alphaData = new byte[width * height];
+            for (int y = 0; y < height; y++) {
+                int srcIndex = srcBytesPerLine * y;
+                int destIndex = destBytesPerLine * y;
+                int destAlphaIndex = width * y;
+                for (int x = 0; x < width; x++) {
+                    byte grey = data[srcIndex];
+                    byte alpha = data[srcIndex + 1];
+                    rgbData[destIndex + 0] = grey;
+                    rgbData[destIndex + 1] = grey;
+                    rgbData[destIndex + 2] = grey;
+                    alphaData[destAlphaIndex] = alpha;
+                    srcIndex += 2;
+                    destIndex += 3;
+                    destAlphaIndex++;
+                }
+            }
+            imageData.data = rgbData;
+            imageData.alphaData = alphaData;
+            break;
+        }
+        case PngIhdrChunk.COLOR_TYPE_RGB_WITH_ALPHA:
+        {
+            int width = imageData.width;
+            int height = imageData.height;
+            int destBytesPerLine = imageData.bytesPerLine;
+            int srcBytesPerLine = getAlignedBytesPerRow();
+            /*
+            * If the image uses 16-bit depth, it is converted
+            * to an 8-bit depth image.
+            */
+            if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
+            byte[] rgbData = new byte[destBytesPerLine * height];
+            byte[] alphaData = new byte[width * height];
+            for (int y = 0; y < height; y++) {
+                int srcIndex = srcBytesPerLine * y;
+                int destIndex = destBytesPerLine * y;
+                int destAlphaIndex = width * y;
+                for (int x = 0; x < width; x++) {
+                    rgbData[destIndex + 0] = data[srcIndex + 0];
+                    rgbData[destIndex + 1] = data[srcIndex + 1];
+                    rgbData[destIndex + 2] = data[srcIndex + 2];
+                    alphaData[destAlphaIndex] = data[srcIndex + 3];
+                    srcIndex += 4;
+                    destIndex += 3;
+                    destAlphaIndex++;
+                }
+            }
+            imageData.data = rgbData;
+            imageData.alphaData = alphaData;
+            break;
+        }       
+        case PngIhdrChunk.COLOR_TYPE_RGB:
+            imageData.data = data;
+            break;
+        case PngIhdrChunk.COLOR_TYPE_PALETTE:
+            imageData.data = data;
+            if (alphaPalette !is null) {
+                int size = imageData.width * imageData.height;
+                byte[] alphaData = new byte[size];
+                byte[] pixelData = new byte[size];
+                imageData.getPixels(0, 0, size, pixelData, 0);
+                for (int i = 0; i < pixelData.length; i++) {
+                    alphaData[i] = alphaPalette[pixelData[i] & 0xFF];
+                }
+                imageData.alphaData = alphaData;
+            }
+            break;
+        default:
+            imageData.data = data;
+            break;
+    }
+}
+/**
+ * PNG supports some color types and bit depths that are 
+ * unsupported by DWT. If the image uses an unsupported
+ * color type (either of the gray scale types) or bit
+ * depth (16), convert the data to an DWT-supported
+ * format. Then assign the data into the ImageData given.
+ */
+void setImageDataValues(byte[] data, ImageData imageData) {
+    byte[] result = validateBitDepth(data);
+    setPixelData(result, imageData);
+}
+/**
+ * Read the image data from the data stream. This must handle
+ * decoding the data, filtering, and interlacing.
+ */
+void readPixelData(PngIdatChunk chunk, PngChunkReader chunkReader) throws IOException {
+    InputStream stream = new PngInputStream(chunk, chunkReader);
+    //TEMPORARY CODE
+    bool use3_2 = System.getProperty("dwt.internal.image.PNGFileFormat_3.2") !is null;
+    InputStream inflaterStream = use3_2 ? null : Compatibility.newInflaterInputStream(stream);
+    if (inflaterStream !is null) {
+        stream = inflaterStream;
+    } else {
+        stream = new PngDecodingDataStream(stream);
+    }
+    int interlaceMethod = headerChunk.getInterlaceMethod();
+    if (interlaceMethod is PngIhdrChunk.INTERLACE_METHOD_NONE) {
+        readNonInterlacedImage(stream);
+    } else {
+        readInterlacedImage(stream);
+    }
+    /*
+    * InflaterInputStream does not consume all bytes in the stream
+    * when it is closed. This may leave unread IDAT chunks. The fix
+    * is to read all available bytes before closing it.
+    */
+    while (stream.available() > 0) stream.read();
+    stream.close();
+}
+/**
+ * Answer the number of bytes in a word-aligned row of pixel data.
+ */
+int getAlignedBytesPerRow() {
+    return ((getBytesPerRow(headerChunk.getWidth()) + 3) / 4) * 4;
+}
+/**
+ * Answer the number of bytes in each row of the image
+ * data. Each PNG row is byte-aligned, so images with bit
+ * depths less than a byte may have unused bits at the
+ * end of each row. The value of these bits is undefined.
+ */
+int getBytesPerRow() {
+    return getBytesPerRow(headerChunk.getWidth());
+}
+/**
+ * Answer the number of bytes needed to represent a pixel.
+ * This value depends on the image's color type and bit
+ * depth. 
+ * Note that this method rounds up if an image's pixel size
+ * isn't byte-aligned.
+ */
+int getBytesPerPixel() {
+    int bitsPerPixel = headerChunk.getBitsPerPixel();
+    return (bitsPerPixel + 7) / 8;  
+}
+/**
+ * Answer the number of bytes in a row of the given pixel
+ * width. Each row is byte-aligned, so images with bit
+ * depths less than a byte may have unused bits at the
+ * end of each row. The value of these bits is undefined.
+ */
+int getBytesPerRow(int rowWidthInPixels) {
+    int bitsPerPixel = headerChunk.getBitsPerPixel();
+    int bitsPerRow = bitsPerPixel * rowWidthInPixels;
+    int bitsPerByte = 8;
+    return (bitsPerRow + (bitsPerByte - 1)) / bitsPerByte;
+}
+/**
+ * 1. Read one of the seven frames of interlaced data.
+ * 2. Update the imageData.
+ * 3. Notify the image loader's listeners of the frame load.
+ */
+void readInterlaceFrame(
+    InputStream inputStream,
+    int rowInterval,
+    int columnInterval,
+    int startRow,
+    int startColumn,
+    int frameCount) throws IOException 
+{
+    int width = headerChunk.getWidth();
+    int alignedBytesPerRow = getAlignedBytesPerRow();
+    int height = headerChunk.getHeight();
+    if (startRow >= height || startColumn >= width) return;
+    
+    int pixelsPerRow = (width - startColumn + columnInterval - 1) / columnInterval;
+    int bytesPerRow = getBytesPerRow(pixelsPerRow);
+    byte[] row1 = new byte[bytesPerRow];
+    byte[] row2 = new byte[bytesPerRow];
+    byte[] currentRow = row1;   
+    byte[] lastRow = row2;  
+    for (int row = startRow; row < height; row += rowInterval) {
+        byte filterType = (byte)inputStream.read();
+        int read = 0;
+        while (read !is bytesPerRow) {
+            read += inputStream.read(currentRow, read, bytesPerRow - read);
+        }
+        filterRow(currentRow, lastRow, filterType);
+        if (headerChunk.getBitDepth() >= 8) {
+            int bytesPerPixel = getBytesPerPixel();
+            int dataOffset = (row * alignedBytesPerRow) + (startColumn * bytesPerPixel);
+            for (int rowOffset = 0; rowOffset < currentRow.length; rowOffset += bytesPerPixel) {
+                for (int byteOffset = 0; byteOffset < bytesPerPixel; byteOffset++) {
+                    data[dataOffset + byteOffset] = currentRow[rowOffset + byteOffset];
+                }
+                dataOffset += (columnInterval * bytesPerPixel);
+            }
+        } else {
+            int bitsPerPixel = headerChunk.getBitDepth();
+            int pixelsPerByte = 8 / bitsPerPixel;
+            int column = startColumn;
+            int rowBase = row * alignedBytesPerRow;
+            int valueMask = 0;
+            for (int i = 0; i < bitsPerPixel; i++) {
+                valueMask <<= 1;
+                valueMask |= 1;
+            }
+            int maxShift = 8 - bitsPerPixel;
+            for (int byteOffset = 0; byteOffset < currentRow.length; byteOffset++) {
+                for (int bitOffset = maxShift; bitOffset >= 0; bitOffset -= bitsPerPixel) {
+                    if (column < width) {
+                        int dataOffset = rowBase + (column * bitsPerPixel / 8);                         
+                        int value = (currentRow[byteOffset] >> bitOffset) & valueMask;
+                        int dataShift = maxShift - (bitsPerPixel * (column % pixelsPerByte));
+                        data[dataOffset] |= value << dataShift;
+                    }
+                    column += columnInterval;
+                }
+            }
+        }
+        currentRow = (currentRow is row1) ? row2 : row1;
+        lastRow = (lastRow is row1) ? row2 : row1;
+    }
+    setImageDataValues(data, imageData);
+    fireInterlacedFrameEvent(frameCount);
+}
+/**
+ * Read the pixel data for an interlaced image from the
+ * data stream.
+ */
+void readInterlacedImage(InputStream inputStream) throws IOException {
+    readInterlaceFrame(inputStream, 8, 8, 0, 0, 0);
+    readInterlaceFrame(inputStream, 8, 8, 0, 4, 1); 
+    readInterlaceFrame(inputStream, 8, 4, 4, 0, 2); 
+    readInterlaceFrame(inputStream, 4, 4, 0, 2, 3);
+    readInterlaceFrame(inputStream, 4, 2, 2, 0, 4);
+    readInterlaceFrame(inputStream, 2, 2, 0, 1, 5); 
+    readInterlaceFrame(inputStream, 2, 1, 1, 0, 6);
+}
+/**
+ * Fire an event to let listeners know that an interlaced
+ * frame has been loaded.
+ * finalFrame should be true if the image has finished
+ * loading, false if there are more frames to come.
+ */
+void fireInterlacedFrameEvent(int frameCount) {
+    if (loader.hasListeners()) {
+        ImageData image = (ImageData) imageData.clone();
+        bool finalFrame = frameCount is 6;
+        loader.notifyListeners(new ImageLoaderEvent(loader, image, frameCount, finalFrame));
+    }
+}
+/**
+ * Read the pixel data for a non-interlaced image from the
+ * data stream.
+ * Update the imageData to reflect the new data.
+ */
+void readNonInterlacedImage(InputStream inputStream) throws IOException {
+    int dataOffset = 0;
+    int alignedBytesPerRow = getAlignedBytesPerRow();
+    int bytesPerRow = getBytesPerRow();
+    byte[] row1 = new byte[bytesPerRow];
+    byte[] row2 = new byte[bytesPerRow];
+    byte[] currentRow = row1;   
+    byte[] lastRow = row2;
+    int height = headerChunk.getHeight();
+    for (int row = 0; row < height; row++) {
+        byte filterType = (byte)inputStream.read();
+        int read = 0;
+        while (read !is bytesPerRow) {
+            read += inputStream.read(currentRow, read, bytesPerRow - read);
+        }
+        filterRow(currentRow, lastRow, filterType);
+        System.arraycopy(currentRow, 0, data, dataOffset, bytesPerRow);
+        dataOffset += alignedBytesPerRow;
+        currentRow = (currentRow is row1) ? row2 : row1;
+        lastRow = (lastRow is row1) ? row2 : row1;
+    }
+    setImageDataValues(data, imageData);
+}
+/**
+ * DWT does not support 16-bit depth color formats.
+ * Convert the 16-bit data to 8-bit data.
+ * The correct way to do this is to multiply each
+ * 16 bit value by the value:
+ * (2^8 - 1) / (2^16 - 1).
+ * The fast way to do this is just to drop the low
+ * byte of the 16-bit value.
+ */
+static void compress16BitDepthTo8BitDepth(
+    byte[] source,
+    int sourceOffset,
+    byte[] destination, 
+    int destinationOffset,
+    int numberOfValues) 
+{
+    //double multiplier = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
+    for (int i = 0; i < numberOfValues; i++) {
+        int sourceIndex = sourceOffset + (2 * i);
+        int destinationIndex = destinationOffset + i;
+        //int value = (source[sourceIndex] << 8) | source[sourceIndex + 1];
+        //byte compressedValue = (byte)(value * multiplier);
+        byte compressedValue = source[sourceIndex];
+        destination[destinationIndex] = compressedValue;
+    }
+}
+/**
+ * DWT does not support 16-bit depth color formats.
+ * Convert the 16-bit data to 8-bit data.
+ * The correct way to do this is to multiply each
+ * 16 bit value by the value:
+ * (2^8 - 1) / (2^16 - 1).
+ * The fast way to do this is just to drop the low
+ * byte of the 16-bit value.
+ */
+static int compress16BitDepthTo8BitDepth(int value) {
+    //double multiplier = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
+    //byte compressedValue = (byte)(value * multiplier);
+    return value >> 8;
+}
+/**
+ * PNG supports four filtering types. These types are applied
+ * per row of image data. This method unfilters the given row
+ * based on the filterType.
+ */
+void filterRow(byte[] row, byte[] previousRow, int filterType) {
+    int byteOffset = headerChunk.getFilterByteOffset();
+    switch (filterType) {
+        case PngIhdrChunk.FILTER_NONE:
+            break;
+        case PngIhdrChunk.FILTER_SUB:
+            for (int i = byteOffset; i < row.length; i++) {
+                int current = row[i] & 0xFF;
+                int left = row[i - byteOffset] & 0xFF;
+                row[i] = (byte)((current + left) & 0xFF);
+            }
+            break;
+        case PngIhdrChunk.FILTER_UP:
+            for (int i = 0; i < row.length; i++) {
+                int current = row[i] & 0xFF;
+                int above = previousRow[i] & 0xFF;              
+                row[i] = (byte)((current + above) & 0xFF);
+            }
+            break;
+        case PngIhdrChunk.FILTER_AVERAGE:
+            for (int i = 0; i < row.length; i++) {
+                int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
+                int above = previousRow[i] & 0xFF;
+                int current = row[i] & 0xFF;
+                row[i] = (byte)((current + ((left + above) / 2)) & 0xFF);
+            }
+            break;
+        case PngIhdrChunk.FILTER_PAETH:
+            for (int i = 0; i < row.length; i++) {
+                int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
+                int aboveLeft = (i < byteOffset) ? 0 : previousRow[i - byteOffset] & 0xFF;
+                int above = previousRow[i] & 0xFF;
+                
+                int a = Math.abs(above - aboveLeft);
+                int b = Math.abs(left - aboveLeft);
+                int c = Math.abs(left - aboveLeft + above - aboveLeft);
+                
+                int preductor = 0;
+                if (a <= b && a <= c) {
+                    preductor = left;
+                } else if (b <= c) {
+                    preductor = above;
+                } else {
+                    preductor = aboveLeft;
+                }
+                
+                int currentValue = row[i] & 0xFF;
+                row[i] = (byte) ((currentValue + preductor) & 0xFF);
+            }
+            break;
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngChunk.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,382 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+
+import dwt.DWT;
+
+class PngChunk : Object {
+    byte[] reference;
+
+    static final int LENGTH_OFFSET = 0;
+    static final int TYPE_OFFSET = 4;
+    static final int DATA_OFFSET = 8;
+
+    static final int TYPE_FIELD_LENGTH = 4;
+    static final int LENGTH_FIELD_LENGTH = 4;
+    static final int MIN_LENGTH = 12;
+
+    static final int CHUNK_UNKNOWN = -1;
+    // Critical chunks.
+    static final int CHUNK_IHDR = 0;
+    static final int CHUNK_PLTE = 1;
+    static final int CHUNK_IDAT = 2;
+    static final int CHUNK_IEND = 3;
+    // Non-critical chunks.
+    static final int CHUNK_tRNS = 5;
+    
+    static final byte[] TYPE_IHDR = {(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'};
+    static final byte[] TYPE_PLTE = {(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'};
+    static final byte[] TYPE_IDAT = {(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'};
+    static final byte[] TYPE_IEND = {(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
+    static final byte[] TYPE_tRNS = {(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
+    
+    static final int[] CRC_TABLE;
+    static {
+        CRC_TABLE = new int[256];
+        for (int i = 0; i < 256; i++) {
+            CRC_TABLE[i] = i;
+            for (int j = 0; j < 8; j++) {
+                if ((CRC_TABLE[i] & 0x1) is 0) {
+                    CRC_TABLE[i] = (CRC_TABLE[i] >> 1) & 0x7FFFFFFF;
+                } else {
+                    CRC_TABLE[i] = 0xEDB88320 ^ ((CRC_TABLE[i] >> 1) & 0x7FFFFFFF);
+                }
+            }
+        }   
+    }
+    
+    int length;
+    
+/**
+ * Construct a PngChunk using the reference bytes
+ * given.
+ */ 
+PngChunk(byte[] reference) {
+    super();
+    setReference(reference);
+    if (reference.length < LENGTH_OFFSET + LENGTH_FIELD_LENGTH) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    length = getInt32(LENGTH_OFFSET);
+}
+
+/**
+ * Construct a PngChunk with the specified number of
+ * data bytes.
+ */ 
+PngChunk(int dataLength) {
+    this(new byte[MIN_LENGTH + dataLength]);
+    setLength(dataLength);
+}
+
+/**
+ * Get the PngChunk's reference byteArray;
+ */ 
+byte[] getReference() {
+    return reference;
+}
+
+/**
+ * Set the PngChunk's reference byteArray;
+ */ 
+void setReference(byte[] reference) {
+    this.reference = reference;
+}
+
+/**
+ * Get the 16-bit integer from the reference byte
+ * array at the given offset.
+ */ 
+int getInt16(int offset) {
+    int answer = 0;
+    answer |= (reference[offset] & 0xFF) << 8;
+    answer |= (reference[offset + 1] & 0xFF);
+    return answer;  
+}
+
+/**
+ * Set the 16-bit integer in the reference byte
+ * array at the given offset.
+ */ 
+void setInt16(int offset, int value) {
+    reference[offset] = (byte) ((value >> 8) & 0xFF);
+    reference[offset + 1] = (byte) (value & 0xFF);
+}
+
+/**
+ * Get the 32-bit integer from the reference byte
+ * array at the given offset.
+ */ 
+int getInt32(int offset) {
+    int answer = 0;
+    answer |= (reference[offset] & 0xFF) << 24;
+    answer |= (reference[offset + 1] & 0xFF) << 16;
+    answer |= (reference[offset + 2] & 0xFF) << 8;
+    answer |= (reference[offset + 3] & 0xFF);
+    return answer;  
+}
+
+/**
+ * Set the 32-bit integer in the reference byte
+ * array at the given offset.
+ */ 
+void setInt32(int offset, int value) {
+    reference[offset] = (byte) ((value >> 24) & 0xFF);
+    reference[offset + 1] = (byte) ((value >> 16) & 0xFF);
+    reference[offset + 2] = (byte) ((value >> 8) & 0xFF);
+    reference[offset + 3] = (byte) (value & 0xFF);
+}
+
+/**
+ * Get the length of the data component of this chunk.
+ * This is not the length of the entire chunk.
+ */ 
+int getLength() {
+    return length;
+}
+
+/**
+ * Set the length of the data component of this chunk.
+ * This is not the length of the entire chunk.
+ */ 
+void setLength(int value) {
+    setInt32(LENGTH_OFFSET, value);
+    length = value;
+}
+
+/**
+ * Get the chunk type. This is a four byte value.
+ * Each byte should be an ASCII character.
+ * The first byte is upper case if the chunk is critical.
+ * The second byte is upper case if the chunk is publicly defined.
+ * The third byte must be upper case.
+ * The fourth byte is upper case if the chunk is unsafe to copy. 
+ * Public chunk types are defined by the PNG Development Group.
+ */ 
+byte[] getTypeBytes() {
+    byte[] type = new byte[4];
+    System.arraycopy(reference, TYPE_OFFSET, type, 0, TYPE_FIELD_LENGTH);
+    return type;
+}   
+
+/**
+ * Set the chunk type. This is a four byte value.
+ * Each byte should be an ASCII character.
+ * The first byte is upper case if the chunk is critical.
+ * The second byte is upper case if the chunk is publicly defined.
+ * The third byte must be upper case.
+ * The fourth byte is upper case if the chunk is unsafe to copy. 
+ * Public chunk types are defined by the PNG Development Group.
+ */ 
+void setType(byte[] value) {
+    if (value.length !is TYPE_FIELD_LENGTH) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    System.arraycopy(value, 0, reference, TYPE_OFFSET, TYPE_FIELD_LENGTH);
+}
+
+/**
+ * Get the chunk's data.
+ */
+byte[] getData() {
+    int dataLength = getLength();
+    if (reference.length < MIN_LENGTH + dataLength) {
+        DWT.error (DWT.ERROR_INVALID_RANGE);
+    }
+    byte[] data = new byte[dataLength];
+    System.arraycopy(reference, DATA_OFFSET, data, 0, dataLength);
+    return data;
+}
+
+/**
+ * Set the chunk's data.
+ * This method has two side-effects.
+ * 1. It will set the length field to be the length
+ *    of the data array given.
+ * 2. It will set the CRC field to the computed CRC
+ *    value of the data array given.
+ */
+void setData(byte[] data) {
+    setLength(data.length);
+    System.arraycopy(data, 0, reference, DATA_OFFSET, data.length);
+    setCRC(computeCRC());
+}
+
+/**
+ * Get the CRC value for the chunk's data.
+ * Ensure that the length field has a good
+ * value before making this call.
+ */
+int getCRC() {
+    int crcOffset = DATA_OFFSET + getLength();
+    return getInt32(crcOffset);
+}
+
+/**
+ * Set the CRC value for the chunk's data.
+ * Ensure that the length field has a good
+ * value before making this call.
+ */
+void setCRC(int value) {
+    int crcOffset = DATA_OFFSET + getLength();
+    setInt32(crcOffset, value);
+}
+
+/**
+ * Get the chunk's total size including the length, type, and crc fields.
+ */
+int getSize() {
+    return MIN_LENGTH + getLength();
+}
+
+/**
+ * Compute the CRC value for the chunk's data. Answer
+ * whether this value matches the value stored in the
+ * chunk.
+ */
+bool checkCRC() {
+    int crc = computeCRC();
+    int storedCRC = getCRC();
+    return crc is storedCRC;
+}
+
+/**
+ * Answer the CRC value of chunk's data.
+ */
+int computeCRC() {
+    int crc = 0xFFFFFFFF;
+    int start = TYPE_OFFSET;
+    int stop = DATA_OFFSET + getLength();
+    for (int i = start; i < stop; i++) {
+        int index = (crc ^ reference[i]) & 0xFF;
+        crc =  CRC_TABLE[index] ^ ((crc >> 8) & 0x00FFFFFF);
+    }
+    return ~crc;
+}
+
+bool typeMatchesArray(byte[] array) {
+    for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
+        if (reference[TYPE_OFFSET + i] !is array[i]){
+            return false;
+        }
+    }   
+    return true;
+}
+
+bool isCritical() {
+    char c = (char) getTypeBytes()[0]; 
+    return 'A' <= c && c <= 'Z';
+}
+
+int getChunkType() {
+    if (typeMatchesArray(TYPE_IHDR)) return CHUNK_IHDR;
+    if (typeMatchesArray(TYPE_PLTE)) return CHUNK_PLTE;
+    if (typeMatchesArray(TYPE_IDAT)) return CHUNK_IDAT;
+    if (typeMatchesArray(TYPE_IEND)) return CHUNK_IEND;
+    if (typeMatchesArray(TYPE_tRNS)) return CHUNK_tRNS; 
+    return CHUNK_UNKNOWN;
+}
+
+/**
+ * Read the next PNG chunk from the input stream given.
+ * If unable to read a chunk, return null.
+ */
+static PngChunk readNextFromStream(LEDataInputStream stream) {
+    try {
+        int headerLength = LENGTH_FIELD_LENGTH + TYPE_FIELD_LENGTH;
+        byte[] headerBytes = new byte[headerLength];
+        int result = stream.read(headerBytes, 0, headerLength);
+        stream.unread(headerBytes);
+        if (result !is headerLength) return null;
+        
+        PngChunk tempChunk = new PngChunk(headerBytes);
+        
+        int chunkLength = tempChunk.getSize();
+        byte[] chunk = new byte[chunkLength];
+        result = stream.read(chunk, 0, chunkLength);
+        if (result !is chunkLength) return null;
+    
+        switch (tempChunk.getChunkType()) {
+            case CHUNK_IHDR:
+                return new PngIhdrChunk(chunk);
+            case CHUNK_PLTE:
+                return new PngPlteChunk(chunk);
+            case CHUNK_IDAT:
+                return new PngIdatChunk(chunk);
+            case CHUNK_IEND:
+                return new PngIendChunk(chunk);
+            case CHUNK_tRNS:
+                return new PngTrnsChunk(chunk);
+            default:
+                return new PngChunk(chunk);
+        }       
+    } catch (IOException e) {
+        return null;
+    }
+}
+
+/**
+ * Answer whether the chunk is a valid PNG chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+    if (reference.length < MIN_LENGTH) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    
+    byte[] type = getTypeBytes();
+    
+    // The third character MUST be upper case.
+    char c = (char) type[2];
+    if (!('A' <= c && c <= 'Z')) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    
+    // All characters must be letters.
+    for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
+        c = (char) type[i];
+        if (!(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+    }
+    
+    // The stored CRC must match the data's computed CRC.
+    if (!checkCRC()) DWT.error(DWT.ERROR_INVALID_IMAGE);
+}
+
+/**
+ * Provided so that subclasses can override and add
+ * data to the toString() call.
+ */
+void contributeToString(StringBuffer buffer) {}
+
+/**
+ * Returns a String containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a String representation of the event
+ */
+public String toString() {
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("{");
+    buffer.append("\n\tLength: ");
+    buffer.append(getLength());
+    buffer.append("\n\tType: ");
+    byte[] type = getTypeBytes();
+    for(int i = 0; i < type.length; i++) {
+        buffer.append((char) type[i]);
+    }
+    
+    contributeToString(buffer);
+    
+    buffer.append("\n\tCRC: ");
+    buffer.append(Integer.toHexString(getCRC()));
+    buffer.append("\n}");
+    return buffer.toString();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngChunkReader.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+
+public class PngChunkReader {
+    LEDataInputStream inputStream;
+    PngFileReadState readState;
+    PngIhdrChunk headerChunk;
+    PngPlteChunk paletteChunk;
+    
+PngChunkReader(LEDataInputStream inputStream) {
+    this.inputStream = inputStream;
+    readState = new PngFileReadState();
+    headerChunk = null;
+}
+
+PngIhdrChunk getIhdrChunk() {
+    if (headerChunk is null) {
+        try { 
+            PngChunk chunk = PngChunk.readNextFromStream(inputStream);
+            if (chunk is null) DWT.error(DWT.ERROR_INVALID_IMAGE);
+            headerChunk = (PngIhdrChunk) chunk;
+            headerChunk.validate(readState, null);
+        } catch (ClassCastException e) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+    }
+    return headerChunk;
+}
+
+PngChunk readNextChunk() {
+    if (headerChunk is null) return getIhdrChunk();
+    
+    PngChunk chunk = PngChunk.readNextFromStream(inputStream);
+    if (chunk is null) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    switch (chunk.getChunkType()) {
+        case PngChunk.CHUNK_tRNS:
+            ((PngTrnsChunk) chunk).validate(readState, headerChunk, paletteChunk);
+            break;
+        case PngChunk.CHUNK_PLTE:
+            chunk.validate(readState, headerChunk);
+            paletteChunk = (PngPlteChunk) chunk;
+            break;
+        default:
+            chunk.validate(readState, headerChunk);
+    }
+    if (readState.readIDAT && !(chunk.getChunkType() is PngChunk.CHUNK_IDAT)) {
+        readState.readPixelData = true;
+    }
+    return chunk;
+}
+
+bool readPixelData() {
+    return readState.readPixelData;
+}
+
+bool hasMoreChunks() {
+    return !readState.readIEND;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngDecodingDataStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import dwt.DWT;
+
+public class PngDecodingDataStream : InputStream {
+    InputStream stream;
+    byte currentByte;
+    int nextBitIndex;
+    
+    PngLzBlockReader lzBlockReader;
+    int adlerValue;
+    
+    static final int PRIME = 65521;
+    static final int MAX_BIT = 7;       
+    
+PngDecodingDataStream(InputStream stream) throws IOException {
+    super();
+    this.stream = stream;
+    nextBitIndex = MAX_BIT + 1;
+    adlerValue = 1;
+    lzBlockReader = new PngLzBlockReader(this);
+    readCompressedDataHeader();
+    lzBlockReader.readNextBlockHeader();
+}
+
+/**
+ * This method should be called when the image decoder thinks
+ * that all of the compressed image data has been read. This
+ * method will ensure that the next data value is an end of 
+ * block marker. If there are more blocks after this one,
+ * the method will read them and ensure that they are empty.
+ */
+void assertImageDataAtEnd() throws IOException {
+    lzBlockReader.assertCompressedDataAtEnd();
+}
+
+public void close() throws IOException {
+    assertImageDataAtEnd();
+    checkAdler();
+}
+
+int getNextIdatBits(int length) throws IOException {
+    int value = 0;
+    for (int i = 0; i < length; i++) {
+        value |= (getNextIdatBit() << i);
+    }
+    return value;
+}
+
+int getNextIdatBit() throws IOException {
+    if (nextBitIndex > MAX_BIT) {
+        currentByte = getNextIdatByte();
+        nextBitIndex = 0;
+    }
+    return (currentByte & (1 << nextBitIndex)) >> nextBitIndex++;
+}
+
+byte getNextIdatByte() throws IOException { 
+    byte nextByte = (byte)stream.read();
+    nextBitIndex = MAX_BIT + 1;
+    return nextByte;
+}
+
+void updateAdler(byte value) {
+    int low = adlerValue & 0xFFFF;
+    int high = (adlerValue >> 16) & 0xFFFF;
+    int valueInt = value & 0xFF;
+    low = (low + valueInt) % PRIME;
+    high = (low + high) % PRIME;
+    adlerValue = (high << 16) | low;
+}
+
+public int read() throws IOException {
+    byte nextDecodedByte = lzBlockReader.getNextByte();
+    updateAdler(nextDecodedByte);
+    return nextDecodedByte & 0xFF;
+}
+
+public int read(byte[] buffer, int off, int len) throws IOException {
+    for (int i = 0; i < len; i++) {
+        int b = read();
+        if (b is -1) return i;
+        buffer[off + i] = (byte)b;
+    }
+    return len;
+}
+
+void error() {
+    DWT.error(DWT.ERROR_INVALID_IMAGE);
+}
+
+private void readCompressedDataHeader() throws IOException {
+    byte headerByte1 = getNextIdatByte();
+    byte headerByte2 = getNextIdatByte();
+    
+    int number = ((headerByte1 & 0xFF) << 8) | (headerByte2 & 0xFF);
+    if (number % 31 !is 0) error();
+    
+    int compressionMethod = headerByte1 & 0x0F;
+    if (compressionMethod !is 8) error();
+    
+    int windowSizeHint = (headerByte1 & 0xF0) >> 4;
+    if (windowSizeHint > 7) error();
+    int windowSize = (1 << (windowSizeHint + 8));
+    lzBlockReader.setWindowSize(windowSize);
+    
+    int dictionary = (headerByte2 & (1 << 5));
+    if (dictionary !is 0) error();
+    
+//  int compressionLevel = (headerByte2 & 0xC0) >> 6;
+}
+
+void checkAdler() throws IOException {
+    int storedAdler = ((getNextIdatByte() & 0xFF) << 24)
+        | ((getNextIdatByte() & 0xFF) << 16)
+        | ((getNextIdatByte() & 0xFF) << 8)
+        | (getNextIdatByte() & 0xFF);
+    if (storedAdler !is adlerValue) error();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngDeflater.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,618 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.ByteArrayOutputStream;
+
+public class PngDeflater {
+
+    static final int BASE = 65521;
+    static final int WINDOW = 32768;
+    static final int MIN_LENGTH = 3;
+    static final int MAX_MATCHES = 32;
+    static final int HASH = 8209;
+    
+    byte[] in;
+    int inLength;
+    
+    ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024);
+    
+    int adler32 = 1;
+    
+    int buffer, bitCount;
+    
+    Link[] hashtable = new Link[HASH];
+    Link[] window = new Link[WINDOW];
+    int nextWindow;
+
+static class Link {
+
+    int hash, value;
+    Link previous, next;
+    
+    Link() {
+    
+        this.hash = 0;
+        this.value = 0;
+        this.previous = null;
+        this.next = null;
+    
+    }
+
+}
+
+static class Match {
+
+    int length, distance;
+    
+    Match(int length, int distance) {
+    
+        this.length = length;
+        this.distance = distance;
+    
+    }
+
+}
+
+static final short mirrorBytes[] = {
+
+    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+    0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+    0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+    0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+    0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+    0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+    0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+    0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+    0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+    0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+    0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+    0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+    0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+    0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+    0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+    0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+    0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+    0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+    0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+    0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+    0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+    0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+    0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+    0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+    0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+    0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+    0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+    0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+    0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+    0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+    0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+    0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+
+};
+
+static class Code {
+
+    int code, extraBits, min, max;
+    
+    Code(int code, int extraBits, int min, int max) {
+    
+        this.code = code;
+        this.extraBits = extraBits;
+        this.min = min;
+        this.max = max;
+    
+    }
+
+}
+
+static final Code lengthCodes[] = {
+
+    new Code(257, 0, 3, 3),
+    new Code(258, 0, 4, 4),
+    new Code(259, 0, 5, 5),
+    new Code(260, 0, 6, 6),
+    new Code(261, 0, 7, 7),
+    new Code(262, 0, 8, 8),
+    new Code(263, 0, 9, 9),
+    new Code(264, 0, 10, 10),
+    new Code(265, 1, 11, 12),
+    new Code(266, 1, 13, 14),
+    new Code(267, 1, 15, 16),
+    new Code(268, 1, 17, 18),
+    new Code(269, 2, 19, 22),
+    new Code(270, 2, 23, 26),
+    new Code(271, 2, 27, 30),
+    new Code(272, 2, 31, 34),
+    new Code(273, 3, 35, 42),
+    new Code(274, 3, 43, 50),
+    new Code(275, 3, 51, 58),
+    new Code(276, 3, 59, 66),
+    new Code(277, 4, 67, 82),
+    new Code(278, 4, 83, 98),
+    new Code(279, 4, 99, 114),
+    new Code(280, 4, 115, 130),
+    new Code(281, 5, 131, 162),
+    new Code(282, 5, 163, 194),
+    new Code(283, 5, 195, 226),
+    new Code(284, 5, 227, 257),
+    new Code(285, 0, 258, 258)
+
+};
+
+static final Code distanceCodes[] = {
+
+    new Code(0, 0, 1, 1),
+    new Code(1, 0, 2, 2),
+    new Code(2, 0, 3, 3),
+    new Code(3, 0, 4, 4),
+    new Code(4, 1, 5, 6),
+    new Code(5, 1, 7, 8),
+    new Code(6, 2, 9, 12),
+    new Code(7, 2, 13, 16),
+    new Code(8, 3, 17, 24),
+    new Code(9, 3, 25, 32),
+    new Code(10, 4, 33, 48),
+    new Code(11, 4, 49, 64),
+    new Code(12, 5, 65, 96),
+    new Code(13, 5, 97, 128),
+    new Code(14, 6, 129, 192),
+    new Code(15, 6, 193, 256),
+    new Code(16, 7, 257, 384),
+    new Code(17, 7, 385, 512),
+    new Code(18, 8, 513, 768),
+    new Code(19, 8, 769, 1024),
+    new Code(20, 9, 1025, 1536),
+    new Code(21, 9, 1537, 2048),
+    new Code(22, 10, 2049, 3072),
+    new Code(23, 10, 3073, 4096),
+    new Code(24, 11, 4097, 6144),
+    new Code(25, 11, 6145, 8192),
+    new Code(26, 12, 8193, 12288),
+    new Code(27, 12, 12289, 16384),
+    new Code(28, 13, 16385, 24576),
+    new Code(29, 13, 24577, 32768)
+
+};
+
+void writeShortLSB(ByteArrayOutputStream baos, int theShort) {
+
+    byte byte1 = (byte) (theShort & 0xff);
+    byte byte2 = (byte) ((theShort >> 8) & 0xff);
+    byte[] temp = {byte1, byte2};
+    baos.write(temp, 0, 2);
+
+}
+
+void writeInt(ByteArrayOutputStream baos, int theInt) {
+
+    byte byte1 = (byte) ((theInt >> 24) & 0xff);
+    byte byte2 = (byte) ((theInt >> 16) & 0xff);
+    byte byte3 = (byte) ((theInt >> 8) & 0xff);
+    byte byte4 = (byte) (theInt & 0xff);
+    byte[] temp = {byte1, byte2, byte3, byte4};
+    baos.write(temp, 0, 4);
+
+}
+
+void updateAdler(byte value) {
+
+    int low = adler32 & 0xffff;
+    int high = (adler32 >> 16) & 0xffff;
+    int valueInt = value & 0xff;
+    low = (low + valueInt) % BASE;
+    high = (low + high) % BASE;
+    adler32 = (high << 16) | low;
+
+}
+
+int hash(byte[] bytes) {
+
+    int hash = ((bytes[0] & 0xff) << 24 | (bytes[1] & 0xff) << 16 | (bytes[2] & 0xff) << 8) % HASH;
+    if (hash < 0) {
+        hash = hash + HASH;
+    }
+    return hash;
+
+}
+
+void writeBits(int value, int count) {
+
+    buffer |= value << bitCount;
+    bitCount += count;
+    if (bitCount >= 16) {
+        bytes.write((byte) buffer);
+        bytes.write((byte) (buffer >>> 8));
+        buffer >>>= 16;
+        bitCount -= 16;
+    }
+
+}
+
+void alignToByte() {
+
+    if (bitCount > 0) {
+        bytes.write((byte) buffer);
+        if (bitCount > 8) bytes.write((byte) (buffer >>> 8));
+    }
+    buffer = 0;
+    bitCount = 0;
+
+}
+
+void outputLiteral(byte literal) {
+
+    int i = literal & 0xff;
+    
+    if (i <= 143) {
+        // 0 through 143 are 8 bits long starting at 00110000
+        writeBits(mirrorBytes[0x30 + i], 8);
+    }
+    else {
+        // 144 through 255 are 9 bits long starting at 110010000
+        writeBits(1 + 2 * mirrorBytes[0x90 - 144 + i], 9);
+    }
+
+}
+
+Code findCode(int value, Code[] codes) {
+
+    int i, j, k;
+    
+    i = -1;
+    j = codes.length;
+    while (true) {
+        k = (j + i) / 2;
+        if (value < codes[k].min) {
+            j = k;
+        }
+        else if (value > codes[k].max) {
+            i = k;
+        }
+        else {
+            return codes[k];
+        }
+    }
+
+}
+
+void outputMatch(int length, int distance) {
+
+    Code d, l;
+    int thisLength;
+    
+    while (length > 0) {
+
+        // we can transmit matches of lengths 3 through 258 inclusive
+        // so if length exceeds 258, we must transmit in several steps,
+        // with 258 or less in each step
+        
+        if (length > 260) {
+            thisLength = 258;
+        }
+        else if (length <= 258) {
+            thisLength = length;
+        }
+        else {
+            thisLength = length - 3;
+        }
+        
+        length = length - thisLength;
+                
+        // find length code
+        l = findCode(thisLength, lengthCodes);
+        
+        // transmit the length code
+        // 256 through 279 are 7 bits long starting at 0000000
+        // 280 through 287 are 8 bits long starting at 11000000
+        if (l.code <= 279) {
+            writeBits(mirrorBytes[(l.code - 256) * 2], 7);
+        }
+        else {
+            writeBits(mirrorBytes[0xc0 - 280 + l.code], 8);
+        }
+        
+        // transmit the extra bits
+        if (l.extraBits !is 0) {
+            writeBits(thisLength - l.min, l.extraBits);
+        }
+        
+        // find distance code
+        d = findCode(distance, distanceCodes);
+        
+        // transmit the distance code
+        // 5 bits long starting at 00000
+        writeBits(mirrorBytes[d.code * 8], 5);
+        
+        // transmit the extra bits
+        if (d.extraBits !is 0) {
+            writeBits(distance - d.min, d.extraBits);
+        }
+    
+    }
+
+}
+
+Match findLongestMatch(int position, Link firstPosition) {
+
+    Link link = firstPosition;
+    int numberOfMatches = 0;
+    Match bestMatch = new Match(-1, -1);
+    
+    while (true) {
+    
+        int matchPosition = link.value;
+        
+        if (position - matchPosition < WINDOW && matchPosition !is 0) {
+
+            int i;
+            
+            for (i = 1; position + i < inLength; i++) {
+                if (in[position + i] !is in[matchPosition + i]) {
+                    break;
+                }
+            }
+            
+            if (i >= MIN_LENGTH) {
+            
+                if (i > bestMatch.length) {
+                    bestMatch.length = i;
+                    bestMatch.distance = position - matchPosition;
+                }
+                
+                numberOfMatches = numberOfMatches + 1;
+                
+                if (numberOfMatches is MAX_MATCHES) {
+                    break;
+                }
+            
+            }
+                        
+        }
+        
+        link = link.next;
+        if (link is null) {
+            break;
+        }
+    
+    }
+    
+    if (bestMatch.length < MIN_LENGTH || bestMatch.distance < 1 || bestMatch.distance > WINDOW) {
+        return null;
+    }
+    
+    return bestMatch;   
+
+}
+
+void updateHashtable(int to, int from) {
+
+    byte[] data = new byte[3];
+    int hash;
+    Link temp;
+    
+    for (int i = to; i < from; i++) {
+        
+        if (i + MIN_LENGTH > inLength) {
+            break;
+        }
+        
+        data[0] = in[i];
+        data[1] = in[i + 1];
+        data[2] = in[i + 2];
+        
+        hash = hash(data);
+        
+        if (window[nextWindow].previous !is null) {
+            window[nextWindow].previous.next = null;
+        }
+        else if (window[nextWindow].hash !is 0) {
+            hashtable[window[nextWindow].hash].next = null;
+        }
+        
+        window[nextWindow].hash = hash;
+        window[nextWindow].value = i;
+        window[nextWindow].previous = null;
+        temp = window[nextWindow].next = hashtable[hash].next;
+        hashtable[hash].next = window[nextWindow];
+        if (temp !is null) {
+            temp.previous = window[nextWindow];
+        }
+        
+        nextWindow = nextWindow + 1;
+        if (nextWindow is WINDOW) {
+            nextWindow = 0;
+        }
+            
+    }
+
+}
+
+void compress() {
+
+    int position, newPosition;
+    byte[] data = new byte[3];
+    int hash;
+    for (int i = 0; i < HASH; i++) {
+        hashtable[i] = new Link();
+    }
+    for (int i = 0; i < WINDOW; i++) {
+        window[i] = new Link();
+    }
+    nextWindow = 0;
+    Link firstPosition;
+    Match match;
+    int deferredPosition = -1;
+    Match deferredMatch = null;
+    
+    writeBits(0x01, 1); // BFINAL = 0x01 (final block)
+    writeBits(0x01, 2); // BTYPE = 0x01 (compression with fixed Huffman codes)
+    
+    // just output first byte so we never match at zero
+    outputLiteral(in[0]);
+    position = 1;
+    
+    while (position < inLength) {
+    
+        if (inLength - position < MIN_LENGTH) {
+            outputLiteral(in[position]);
+            position = position + 1;
+            continue;
+        }
+        
+        data[0] = in[position];
+        data[1] = in[position + 1];
+        data[2] = in[position + 2];
+        
+        hash = hash(data);
+        firstPosition = hashtable[hash];
+        
+        match = findLongestMatch(position, firstPosition);
+        
+        updateHashtable(position, position + 1);
+        
+        if (match !is null) {
+        
+            if (deferredMatch !is null) {
+                if (match.length > deferredMatch.length + 1) {
+                    // output literal at deferredPosition
+                    outputLiteral(in[deferredPosition]);
+                    // defer this match
+                    deferredPosition = position;
+                    deferredMatch = match;
+                    position = position + 1;
+                }
+                else {
+                    // output deferredMatch
+                    outputMatch(deferredMatch.length, deferredMatch.distance);
+                    newPosition = deferredPosition + deferredMatch.length;
+                    deferredPosition = -1;
+                    deferredMatch = null;
+                    updateHashtable(position + 1, newPosition);
+                    position = newPosition;
+                }
+            }
+            else {
+                // defer this match
+                deferredPosition = position;
+                deferredMatch = match;
+                position = position + 1;
+            }
+        
+        }
+        
+        else {
+        
+            // no match found
+            if (deferredMatch !is null) {
+                outputMatch(deferredMatch.length, deferredMatch.distance);
+                newPosition = deferredPosition + deferredMatch.length;
+                deferredPosition = -1;
+                deferredMatch = null;
+                updateHashtable(position + 1, newPosition);
+                position = newPosition;
+            }
+            else {
+                outputLiteral(in[position]);
+                position = position + 1;
+            }
+        
+        }
+    
+    }
+    
+    writeBits(0, 7); // end of block code
+    alignToByte();
+
+}
+
+void compressHuffmanOnly() {
+
+    int position;
+    
+    writeBits(0x01, 1); // BFINAL = 0x01 (final block)
+    writeBits(0x01, 2); // BTYPE = 0x01 (compression with fixed Huffman codes)
+    
+    for (position = 0; position < inLength;) {
+    
+        outputLiteral(in[position]);
+        position = position + 1;
+    
+    }
+    
+    writeBits(0, 7); // end of block code
+    alignToByte();
+
+}
+
+void store() {
+
+    // stored blocks are limited to 0xffff bytes
+    
+    int start = 0;
+    int length = inLength;
+    int blockLength;
+    int BFINAL = 0x00; // BFINAL = 0x00 or 0x01 (if final block), BTYPE = 0x00 (no compression)
+    
+    while (length > 0) {
+    
+        if (length < 65535) {
+            blockLength = length;
+            BFINAL = 0x01;
+        }
+        else {
+            blockLength = 65535;
+            BFINAL = 0x00;
+        }
+        
+        // write data header
+        bytes.write((byte) BFINAL);
+        writeShortLSB(bytes, blockLength); // LEN
+        writeShortLSB(bytes, blockLength ^ 0xffff); // NLEN (one's complement of LEN)
+    
+        // write actual data
+        bytes.write(in, start, blockLength);
+        
+        length = length - blockLength;
+        start = start + blockLength;
+    
+    }
+
+}
+
+public byte[] deflate(byte[] input) {
+
+    in = input;
+    inLength = input.length;
+    
+    // write zlib header
+    bytes.write((byte) 0x78); // window size = 0x70 (32768), compression method = 0x08
+    bytes.write((byte) 0x9C); // compression level = 0x80 (default), check bits = 0x1C
+    
+    // compute checksum
+    for (int i = 0; i < inLength; i++) {
+        updateAdler(in[i]);
+    }
+    
+    //store();
+    
+    //compressHuffmanOnly();
+    
+    compress();
+    
+    // write checksum
+    writeInt(bytes, adler32);
+    
+    return bytes.toByteArray();
+
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngEncoder.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.RGB;
+import dwt.internal.Compatibility;
+
+final class PngEncoder : Object {
+
+    static final byte SIGNATURE[] = {(byte) '\211', (byte) 'P', (byte) 'N', (byte) 'G', (byte) '\r', (byte) '\n', (byte) '\032', (byte) '\n'};
+    static final byte TAG_IHDR[] = {(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'};
+    static final byte TAG_PLTE[] = {(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'};
+    static final byte TAG_TRNS[] = {(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
+    static final byte TAG_IDAT[] = {(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'};
+    static final byte TAG_IEND[] = {(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
+    
+    ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024);
+    PngChunk chunk;
+    
+    ImageLoader loader;
+    ImageData data;
+    int transparencyType;
+    
+    int width, height, bitDepth, colorType;
+    
+    int compressionMethod = 0;
+    int filterMethod = 0;
+    int interlaceMethod = 0;
+    
+public PngEncoder(ImageLoader loader) {
+
+    this.loader = loader;
+    this.data = loader.data[0];
+    this.transparencyType = data.getTransparencyType();
+    
+    this.width = data.width;
+    this.height = data.height;
+    
+    this.bitDepth = 8;
+    
+    this.colorType = 2;
+    
+    if (data.palette.isDirect) {
+        if (transparencyType is DWT.TRANSPARENCY_ALPHA) {
+            this.colorType = 6;
+        }
+    }
+    else {
+        this.colorType = 3;
+    }
+    
+    if (!(colorType is 2 || colorType is 3 || colorType is 6)) DWT.error(DWT.ERROR_INVALID_IMAGE);
+
+}
+
+void writeShort(ByteArrayOutputStream baos, int theShort) {
+
+    byte byte1 = (byte) ((theShort >> 8) & 0xff);
+    byte byte2 = (byte) (theShort & 0xff);
+    byte[] temp = {byte1, byte2};
+    baos.write(temp, 0, 2);
+
+}
+
+void writeInt(ByteArrayOutputStream baos, int theInt) {
+
+    byte byte1 = (byte) ((theInt >> 24) & 0xff);
+    byte byte2 = (byte) ((theInt >> 16) & 0xff);
+    byte byte3 = (byte) ((theInt >> 8) & 0xff);
+    byte byte4 = (byte) (theInt & 0xff);
+    byte[] temp = {byte1, byte2, byte3, byte4};
+    baos.write(temp, 0, 4);
+
+}
+
+void writeChunk(byte[] tag, byte[] buffer) {
+
+    int bufferLength = (buffer !is null) ? buffer.length : 0;
+    
+    chunk = new PngChunk(bufferLength);
+    
+    writeInt(bytes, bufferLength);
+    bytes.write(tag, 0, 4);
+    chunk.setType(tag);
+    if (bufferLength !is 0) {
+        bytes.write(buffer, 0, bufferLength);
+        chunk.setData(buffer);
+    }
+    else {
+        chunk.setCRC(chunk.computeCRC());
+    }
+    writeInt(bytes, chunk.getCRC());
+
+}
+
+void writeSignature() {
+
+    bytes.write(SIGNATURE, 0, 8);
+
+}
+
+void writeHeader() {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream(13);
+    
+    writeInt(baos, width);
+    writeInt(baos, height);
+    baos.write(bitDepth);
+    baos.write(colorType);
+    baos.write(compressionMethod);
+    baos.write(filterMethod);
+    baos.write(interlaceMethod);
+    
+    writeChunk(TAG_IHDR, baos.toByteArray());
+
+}
+
+void writePalette() {
+
+    RGB[] RGBs = data.palette.getRGBs();
+    
+    if (RGBs.length > 256) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    
+    ByteArrayOutputStream baos = new ByteArrayOutputStream(RGBs.length);
+    
+    for (int i = 0; i < RGBs.length; i++) {
+    
+        baos.write((byte) RGBs[i].red);
+        baos.write((byte) RGBs[i].green);
+        baos.write((byte) RGBs[i].blue);
+    
+    }
+    
+    writeChunk(TAG_PLTE, baos.toByteArray());
+
+}
+
+void writeTransparency() {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    
+    switch (transparencyType) {
+    
+        case DWT.TRANSPARENCY_ALPHA:
+            
+            int pixelValue, alphaValue;
+            
+            byte[] alphas = new byte[data.palette.getRGBs().length];
+            
+            for (int y = 0; y < height; y++) {
+            
+                for (int x = 0; x < width; x++) {
+                
+                    pixelValue = data.getPixel(x, y);
+                    alphaValue = data.getAlpha(x, y);
+                    
+                    alphas[pixelValue] = (byte) alphaValue;
+                
+                }
+            
+            }
+            
+            baos.write(alphas, 0, alphas.length);
+            
+            break;
+        
+        case DWT.TRANSPARENCY_PIXEL:
+            
+            int pixel = data.transparentPixel;
+            
+            if (colorType is 2) {
+            
+                int redMask = data.palette.redMask;
+                int redShift = data.palette.redShift;
+                int greenMask = data.palette.greenMask;
+                int greenShift = data.palette.greenShift;
+                int blueShift = data.palette.blueShift;
+                int blueMask = data.palette.blueMask;
+                
+                int r = pixel & redMask;
+                r = (redShift < 0) ? r >>> -redShift : r << redShift;
+                int g = pixel & greenMask;
+                g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+                int b = pixel & blueMask;
+                b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
+                
+                writeShort(baos, r);
+                writeShort(baos, g);
+                writeShort(baos, b);
+            
+            }
+            
+            if (colorType is 3) {
+            
+                byte[] padding = new byte[pixel + 1];
+                
+                for (int i = 0; i < pixel; i++) {
+                
+                    padding[i] = (byte) 255;
+                
+                }
+                
+                padding[pixel] = (byte) 0;
+                
+                baos.write(padding, 0, padding.length);
+            
+            }
+            
+            break;
+    
+    }
+    
+    writeChunk(TAG_TRNS, baos.toByteArray());
+
+}
+
+void writeImageData() throws IOException {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+    OutputStream os = Compatibility.newDeflaterOutputStream(baos);
+    if (os is null) os = baos;
+    
+    if (colorType is 3) {
+    
+        byte[] lineData = new byte[width];
+        
+        for (int y = 0; y < height; y++) {
+            
+            int filter = 0;
+            os.write(filter);
+            
+            data.getPixels(0, y, width, lineData, 0);
+            
+            for (int x = 0; x < lineData.length; x++) {
+            
+                os.write(lineData[x]);
+            
+            }
+        
+        }
+    
+    }
+    
+    else {
+    
+        int[] lineData = new int[width];
+        byte[] alphaData = null;
+        if (colorType is 6) {
+            alphaData = new byte[width];
+        }
+        
+        int redMask = data.palette.redMask;
+        int redShift = data.palette.redShift;
+        int greenMask = data.palette.greenMask;
+        int greenShift = data.palette.greenShift;
+        int blueShift = data.palette.blueShift;
+        int blueMask = data.palette.blueMask;
+        
+        for (int y = 0; y < height; y++) {
+        
+            int filter = 0;
+            os.write(filter);
+            
+            data.getPixels(0, y, width, lineData, 0);
+            
+            if (colorType is 6) {
+                data.getAlphas(0, y, width, alphaData, 0);
+            }
+            
+            for (int x = 0; x < lineData.length; x++) {
+            
+                int pixel = lineData[x];
+                
+                int r = pixel & redMask;
+                r = (redShift < 0) ? r >>> -redShift : r << redShift;
+                int g = pixel & greenMask;
+                g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+                int b = pixel & blueMask;
+                b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
+                
+                os.write(r);
+                os.write(g);
+                os.write(b);
+                
+                if (colorType is 6) {
+                    os.write(alphaData[x]);
+                }
+            
+            }
+        
+        }
+    
+    }
+    
+    os.flush();
+    os.close();
+    
+    byte[] compressed = baos.toByteArray();
+    if (os is baos) {
+        PngDeflater deflater = new PngDeflater();
+        compressed = deflater.deflate(compressed);
+    }
+    
+    writeChunk(TAG_IDAT, compressed);
+
+}
+
+void writeEnd() {
+
+    writeChunk(TAG_IEND, null);
+
+}
+
+public void encode(LEDataOutputStream outputStream) {
+
+    try {
+    
+        writeSignature();
+        writeHeader();
+        
+        if (colorType is 3) {
+            writePalette();
+        }
+        
+        bool transparencyAlpha = (transparencyType is DWT.TRANSPARENCY_ALPHA);
+        bool transparencyPixel = (transparencyType is DWT.TRANSPARENCY_PIXEL);
+        bool type2Transparency = (colorType is 2 && transparencyPixel);
+        bool type3Transparency = (colorType is 3 && (transparencyAlpha || transparencyPixel));
+        
+        if (type2Transparency || type3Transparency) {
+            writeTransparency();
+        }
+        
+        writeImageData();
+        writeEnd();
+        
+        outputStream.write(bytes.toByteArray());
+    
+    }
+    
+    catch (IOException e) {
+    
+        DWT.error(DWT.ERROR_IO, e);
+    
+    }
+
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngFileReadState.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+class PngFileReadState : Object {
+    bool readIHDR;
+    bool readPLTE;
+    bool readIDAT;
+    bool readIEND;
+    
+    // Non - critical chunks
+    bool readTRNS;
+    
+    // Set to true after IDATs have been read.
+    bool readPixelData;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngHuffmanTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.IOException;
+
+public class PngHuffmanTable {
+    CodeLengthInfo[] codeLengthInfo;
+    int[] codeValues;
+    
+    static final int MAX_CODE_LENGTH = 15;
+    static final int BAD_CODE = 0xFFFFFFF;
+    static final int incs[] = {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1};
+
+PngHuffmanTable (int[] lengths) {
+    super();
+    initialize(lengths);
+    generateTable(lengths);
+}
+
+private void initialize(int[] lengths) {
+    codeValues = new int[lengths.length];
+    for (int i = 0; i < codeValues.length; i++) {
+        codeValues[i] = i;
+    }
+    
+    // minCodesByLength[n] : The smallest Huffman code of length n + 1.
+    // maxCodesByLength[n] : The largest Huffman code of length n + 1.
+    // indexesByLength[n] : Index into the values array. First value with a code of length n + 1.
+    codeLengthInfo = new CodeLengthInfo[MAX_CODE_LENGTH];
+    for (int i = 0; i < MAX_CODE_LENGTH; i++) {
+        codeLengthInfo[i] = new CodeLengthInfo();
+        codeLengthInfo[i].length = i;
+        codeLengthInfo[i].baseIndex = 0;
+        codeLengthInfo[i].min = BAD_CODE;
+        codeLengthInfo[i].max = -1;
+    }
+}
+    
+private void generateTable(int[] lengths) {
+    // Sort the values using shellsort. Primary key is code size. Secondary key is value.
+    int codeValuesTemp;
+    for (int k = 0; k < 16; k++) {
+        for (int h = incs[k], i = h; i < lengths.length; i++) {
+            int v = lengths[i];
+            codeValuesTemp = codeValues[i];
+            int j = i;
+            while (j >= h && (lengths[j - h] > v || (lengths[j - h] is v && codeValues[j - h] > codeValuesTemp))) {
+                lengths[j] = lengths[j - h];
+                codeValues[j] = codeValues[j - h];
+                j -= h;
+            }
+            lengths[j] = v;
+            codeValues[j] = codeValuesTemp;
+        }
+    }
+
+    // These values in these arrays correspond to the elements of the
+    // "values" array. The Huffman code for codeValues[N] is codes[N]
+    // and the length of the code is lengths[N].
+    int[] codes = new int[lengths.length];
+    int lastLength = 0;
+    int code = 0;
+    for (int i = 0; i < lengths.length; i++) {
+        while (lastLength !is lengths[i]) {
+            lastLength++;
+            code <<= 1;
+        }
+        if (lastLength !is 0) {
+            codes[i] = code;
+            code++;
+        }
+    }
+    
+    int last = 0;
+    for (int i = 0; i < lengths.length; i++) {
+        if (last !is lengths[i]) {
+            last = lengths[i];
+            codeLengthInfo[last - 1].baseIndex = i;
+            codeLengthInfo[last - 1].min = codes[i];
+        }
+        if (last !is 0) codeLengthInfo[last - 1].max = codes[i];
+    }
+}
+
+int getNextValue(PngDecodingDataStream stream) throws IOException {
+    int code = stream.getNextIdatBit();
+    int codelength = 0;
+
+    // Here we are taking advantage of the fact that 1 bits are used as
+    // a prefix to the longer codeValues.
+    while (codelength < MAX_CODE_LENGTH && code > codeLengthInfo[codelength].max) {
+        code = ((code << 1) | stream.getNextIdatBit());
+        codelength++;
+    }
+    if (codelength >= MAX_CODE_LENGTH) stream.error();
+
+    // Now we have a Huffman code of length (codelength + 1) that
+    // is somewhere in the range
+    // minCodesByLength[codelength]..maxCodesByLength[codelength].
+    // This code is the (offset + 1)'th code of (codelength + 1);
+    int offset = code - codeLengthInfo[codelength].min;
+
+    // indexesByLength[codelength] is the first code of length (codelength + 1)
+    // so now we can look up the value for the Huffman code in the table.
+    int index = codeLengthInfo[codelength].baseIndex + offset;
+    return codeValues[index];
+}   
+    
+static class CodeLengthInfo {
+    int length;
+    int max;
+    int min;
+    int baseIndex;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngHuffmanTables.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.IOException;
+
+public class PngHuffmanTables {
+    PngHuffmanTable literalTable;
+    PngHuffmanTable distanceTable;
+    
+    static PngHuffmanTable FixedLiteralTable;
+    static PngHuffmanTable FixedDistanceTable;
+    
+    static final int LiteralTableSize = 288;
+    static final int[] FixedLiteralLengths = {
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7,
+        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
+    };
+
+    static final int DistanceTableSize = 32;
+    static final int[] FixedDistanceLengths = {
+        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+    };
+    
+    static final int LengthCodeTableSize = 19;
+    static final int[] LengthCodeOrder = {
+        16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
+        11, 4, 12, 3, 13, 2, 14, 1, 15
+    };
+    
+static PngHuffmanTables getDynamicTables(PngDecodingDataStream stream) throws IOException {
+    return new PngHuffmanTables(stream);
+}
+static PngHuffmanTables getFixedTables() {
+    return new PngHuffmanTables();
+}
+
+private PngHuffmanTable getFixedLiteralTable() {
+    if (FixedLiteralTable is null) {
+        FixedLiteralTable = new PngHuffmanTable(FixedLiteralLengths);
+    }
+    return FixedLiteralTable;
+}
+
+private PngHuffmanTable getFixedDistanceTable() {
+    if (FixedDistanceTable is null) {
+        FixedDistanceTable = new PngHuffmanTable(FixedDistanceLengths);
+    }
+    return FixedDistanceTable;
+}
+
+private PngHuffmanTables () {
+    literalTable = getFixedLiteralTable();
+    distanceTable = getFixedDistanceTable();
+}
+
+private PngHuffmanTables (PngDecodingDataStream stream) throws IOException {
+    int literals = PngLzBlockReader.FIRST_LENGTH_CODE 
+        + stream.getNextIdatBits(5);
+    int distances = PngLzBlockReader.FIRST_DISTANCE_CODE 
+        + stream.getNextIdatBits(5);
+    int codeLengthCodes = PngLzBlockReader.FIRST_CODE_LENGTH_CODE 
+        + stream.getNextIdatBits(4);
+
+    if (codeLengthCodes > PngLzBlockReader.LAST_CODE_LENGTH_CODE) {
+        stream.error();
+    }
+    
+    /* Tricky, tricky, tricky. The length codes are stored in
+     * a very odd order. (For the order, see the definition of
+     * the static field lengthCodeOrder.) Also, the data may 
+     * not contain values for all the codes. It may just contain 
+     * values for the first X number of codes. The table should
+     * be of size <LengthCodeTableSize> regardless of the number
+     * of values actually given in the table.
+     */ 
+    int[] lengthCodes = new int[LengthCodeTableSize];
+    for (int i = 0; i < codeLengthCodes; i++) {
+        lengthCodes[LengthCodeOrder[i]] = stream.getNextIdatBits(3);
+    }
+    PngHuffmanTable codeLengthsTable = new PngHuffmanTable(lengthCodes);
+    
+    int[] literalLengths = readLengths(
+        stream, literals, codeLengthsTable, LiteralTableSize);
+    int[] distanceLengths = readLengths(
+        stream, distances, codeLengthsTable, DistanceTableSize);
+    
+    literalTable = new PngHuffmanTable(literalLengths);
+    distanceTable = new PngHuffmanTable(distanceLengths);
+}
+
+private int [] readLengths (PngDecodingDataStream stream, 
+    int numLengths, 
+    PngHuffmanTable lengthsTable,
+    int tableSize) throws IOException
+{
+    int[] lengths = new int[tableSize];
+    
+    for (int index = 0; index < numLengths;) {
+        int value = lengthsTable.getNextValue(stream);
+        if (value < 16) {
+            // Literal value
+            lengths[index] = value;
+            index++;
+        } else if (value is 16) {
+            // Repeat the previous code 3-6 times.
+            int count = stream.getNextIdatBits(2) + 3;
+            for (int i = 0; i < count; i++) {
+                lengths[index] = lengths [index - 1];
+                index++;
+            }
+        } else if (value is 17) {
+            // Repeat 0 3-10 times.
+            int count = stream.getNextIdatBits(3) + 3;
+            for (int i = 0; i < count; i++) {
+                lengths[index] = 0;
+                index++;
+            }
+        } else if (value is 18) {
+            // Repeat 0 11-138 times.
+            int count = stream.getNextIdatBits(7) + 11;
+            for (int i = 0; i < count; i++) {
+                lengths[index] = 0;
+                index++;
+            }
+        } else {
+            stream.error();
+        }
+    }
+    return lengths;
+}
+
+int getNextLiteralValue(PngDecodingDataStream stream) throws IOException {
+    return literalTable.getNextValue(stream);
+}
+
+int getNextDistanceValue(PngDecodingDataStream stream) throws IOException {
+    return distanceTable.getNextValue(stream);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngIdatChunk.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+
+class PngIdatChunk : PngChunk {
+
+    static final int HEADER_BYTES_LENGTH = 2;
+    static final int ADLER_FIELD_LENGTH = 4;
+    static final int HEADER_BYTE1_DATA_OFFSET = DATA_OFFSET + 0;
+    static final int HEADER_BYTE2_DATA_OFFSET = DATA_OFFSET + 1;
+    static final int ADLER_DATA_OFFSET = DATA_OFFSET + 2; // plus variable compressed data length
+
+PngIdatChunk(byte headerByte1, byte headerByte2, byte[] data, int adler) {
+    super(data.length + HEADER_BYTES_LENGTH + ADLER_FIELD_LENGTH);
+    setType(TYPE_IDAT);
+    reference[HEADER_BYTE1_DATA_OFFSET] = headerByte1;
+    reference[HEADER_BYTE2_DATA_OFFSET] = headerByte2;
+    System.arraycopy(data, 0, reference, DATA_OFFSET, data.length);
+    setInt32(ADLER_DATA_OFFSET, adler);
+    setCRC(computeCRC());
+}
+        
+PngIdatChunk(byte[] reference) {
+    super(reference);
+}
+
+int getChunkType() {
+    return CHUNK_IDAT;
+}
+
+/**
+ * Answer whether the chunk is a valid IDAT chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+    if (!readState.readIHDR
+        || (headerChunk.getMustHavePalette() && !readState.readPLTE)
+        || readState.readIEND) 
+    {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    } else {
+        readState.readIDAT = true;
+    }
+    
+    super.validate(readState, headerChunk);
+}
+
+byte getDataByteAtOffset(int offset) {
+    return reference[DATA_OFFSET + offset];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngIendChunk.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+
+class PngIendChunk : PngChunk {
+
+PngIendChunk() {
+    super(0);
+    setType(TYPE_IEND);
+    setCRC(computeCRC());
+}
+
+PngIendChunk(byte[] reference){
+    super(reference);
+}
+
+int getChunkType() {
+    return CHUNK_IEND;
+}
+
+/**
+ * Answer whether the chunk is a valid IEND chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+    // An IEND chunk is invalid if no IHDR has been read.
+    // Or if a palette is required and has not been read.
+    // Or if no IDAT chunk has been read.
+    if (!readState.readIHDR
+        || (headerChunk.getMustHavePalette() && !readState.readPLTE)
+        || !readState.readIDAT
+        || readState.readIEND) 
+    {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    } else {
+        readState.readIEND = true;
+    }
+    
+    super.validate(readState, headerChunk);
+    
+    // IEND chunks are not allowed to have any data.
+    if (getLength() > 0) DWT.error(DWT.ERROR_INVALID_IMAGE);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngIhdrChunk.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,409 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+
+class PngIhdrChunk : PngChunk {
+    static final int IHDR_DATA_LENGTH = 13;
+    
+    static final int WIDTH_DATA_OFFSET = DATA_OFFSET + 0;
+    static final int HEIGHT_DATA_OFFSET = DATA_OFFSET + 4;
+    static final int BIT_DEPTH_OFFSET = DATA_OFFSET + 8;
+    static final int COLOR_TYPE_OFFSET = DATA_OFFSET + 9;
+    static final int COMPRESSION_METHOD_OFFSET = DATA_OFFSET + 10;
+    static final int FILTER_METHOD_OFFSET = DATA_OFFSET + 11;
+    static final int INTERLACE_METHOD_OFFSET = DATA_OFFSET + 12;
+    
+    static final byte COLOR_TYPE_GRAYSCALE = 0;
+    static final byte COLOR_TYPE_RGB = 2;
+    static final byte COLOR_TYPE_PALETTE = 3;
+    static final byte COLOR_TYPE_GRAYSCALE_WITH_ALPHA = 4;
+    static final byte COLOR_TYPE_RGB_WITH_ALPHA = 6;
+    
+    static final int INTERLACE_METHOD_NONE = 0;
+    static final int INTERLACE_METHOD_ADAM7 = 1;
+    
+    static final int FILTER_NONE = 0;
+    static final int FILTER_SUB = 1;
+    static final int FILTER_UP = 2;
+    static final int FILTER_AVERAGE = 3;
+    static final int FILTER_PAETH = 4;
+    
+    static final byte[] ValidBitDepths = {1, 2, 4, 8, 16};
+    static final byte[] ValidColorTypes = {0, 2, 3, 4, 6};
+    
+    int width, height;
+    byte bitDepth, colorType, compressionMethod, filterMethod, interlaceMethod;
+    
+PngIhdrChunk(int width, int height, byte bitDepth, byte colorType, byte compressionMethod, byte filterMethod, byte interlaceMethod) {
+    super(IHDR_DATA_LENGTH);
+    setType(TYPE_IHDR);
+    setWidth(width);
+    setHeight(height);
+    setBitDepth(bitDepth);
+    setColorType(colorType);
+    setCompressionMethod(compressionMethod);
+    setFilterMethod(filterMethod);
+    setInterlaceMethod(interlaceMethod);
+    setCRC(computeCRC());
+}
+
+/**
+ * Construct a PNGChunk using the reference bytes
+ * given.
+ */ 
+PngIhdrChunk(byte[] reference) {
+    super(reference);
+    if (reference.length <= IHDR_DATA_LENGTH) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    width = getInt32(WIDTH_DATA_OFFSET);
+    height = getInt32(HEIGHT_DATA_OFFSET);
+    bitDepth = reference[BIT_DEPTH_OFFSET];
+    colorType = reference[COLOR_TYPE_OFFSET];
+    compressionMethod = reference[COMPRESSION_METHOD_OFFSET];
+    filterMethod = reference[FILTER_METHOD_OFFSET];
+    interlaceMethod = reference[INTERLACE_METHOD_OFFSET];
+}
+
+int getChunkType() {
+    return CHUNK_IHDR;
+}
+
+/**
+ * Get the image's width in pixels.
+ */
+int getWidth() {
+    return width;
+}
+
+/**
+ * Set the image's width in pixels.
+ */
+void setWidth(int value) {
+    setInt32(WIDTH_DATA_OFFSET, value);
+    width = value;
+}
+
+/**
+ * Get the image's height in pixels.
+ */
+int getHeight() {
+    return height;
+}
+
+/**
+ * Set the image's height in pixels.
+ */
+void setHeight(int value) {
+    setInt32(HEIGHT_DATA_OFFSET, value);
+    height = value;
+}
+
+/**
+ * Get the image's bit depth.
+ * This is limited to the values 1, 2, 4, 8, or 16.
+ */
+byte getBitDepth() {
+    return bitDepth;
+}
+
+/**
+ * Set the image's bit depth.
+ * This is limited to the values 1, 2, 4, 8, or 16.
+ */
+void setBitDepth(byte value) {
+    reference[BIT_DEPTH_OFFSET] = value;
+    bitDepth = value;
+}
+
+/**
+ * Get the image's color type.
+ * This is limited to the values:
+ * 0 - Grayscale image.
+ * 2 - RGB triple.
+ * 3 - Palette.
+ * 4 - Grayscale with Alpha channel.
+ * 6 - RGB with Alpha channel.
+ */
+byte getColorType() {
+    return colorType;
+}
+
+/**
+ * Set the image's color type.
+ * This is limited to the values:
+ * 0 - Grayscale image.
+ * 2 - RGB triple.
+ * 3 - Palette.
+ * 4 - Grayscale with Alpha channel.
+ * 6 - RGB with Alpha channel.
+ */
+void setColorType(byte value) {
+    reference[COLOR_TYPE_OFFSET] = value;
+    colorType = value;
+}
+
+/**
+ * Get the image's compression method.
+ * This value must be 0.
+ */
+byte getCompressionMethod() {
+    return compressionMethod;
+}
+
+/**
+ * Set the image's compression method.
+ * This value must be 0.
+ */
+void setCompressionMethod(byte value) {
+    reference[COMPRESSION_METHOD_OFFSET] = value;
+    compressionMethod = value;
+}
+
+/**
+ * Get the image's filter method.
+ * This value must be 0.
+ */
+byte getFilterMethod() {
+    return filterMethod;
+}
+
+/**
+ * Set the image's filter method.
+ * This value must be 0.
+ */
+void setFilterMethod(byte value) {
+    reference[FILTER_METHOD_OFFSET] = value;
+    filterMethod = value;
+}
+
+/**
+ * Get the image's interlace method.
+ * This value is limited to:
+ * 0 - No interlacing used.
+ * 1 - Adam7 interlacing used.
+ */
+byte getInterlaceMethod() {
+    return interlaceMethod;
+}
+
+/**
+ * Set the image's interlace method.
+ * This value is limited to:
+ * 0 - No interlacing used.
+ * 1 - Adam7 interlacing used.
+ */
+void setInterlaceMethod(byte value) {
+    reference[INTERLACE_METHOD_OFFSET] = value;
+    interlaceMethod = value;
+}
+
+/**
+ * Answer whether the chunk is a valid IHDR chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+    // An IHDR chunk is invalid if any other chunk has
+    // been read.
+    if (readState.readIHDR 
+        || readState.readPLTE
+        || readState.readIDAT
+        || readState.readIEND) 
+    {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    } else {
+        readState.readIHDR = true;
+    }
+    
+    super.validate(readState, headerChunk);
+    
+    if (length !is IHDR_DATA_LENGTH) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    if (compressionMethod !is 0) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    if (interlaceMethod !is INTERLACE_METHOD_NONE &&
+        interlaceMethod !is INTERLACE_METHOD_ADAM7) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    
+    bool colorTypeIsValid = false;
+    for (int i = 0; i < ValidColorTypes.length; i++) {
+        if (ValidColorTypes[i] is colorType) {
+            colorTypeIsValid = true;
+            break;
+        }
+    }
+    if (!colorTypeIsValid) DWT.error(DWT.ERROR_INVALID_IMAGE);
+
+    bool bitDepthIsValid = false;
+    for (int i = 0; i < ValidBitDepths.length; i++) {
+        if (ValidBitDepths[i] is bitDepth) {
+            bitDepthIsValid = true;
+            break;
+        }
+    }
+    if (!bitDepthIsValid) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    
+    if ((colorType is COLOR_TYPE_RGB 
+        || colorType is COLOR_TYPE_RGB_WITH_ALPHA
+        || colorType is COLOR_TYPE_GRAYSCALE_WITH_ALPHA)
+        && bitDepth < 8) 
+    {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    
+    if (colorType is COLOR_TYPE_PALETTE && bitDepth > 8) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+}
+
+String getColorTypeString() {
+    switch (colorType) {
+        case COLOR_TYPE_GRAYSCALE:              return "Grayscale";
+        case COLOR_TYPE_RGB:                    return "RGB";       
+        case COLOR_TYPE_PALETTE:                return "Palette";
+        case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:   return "Grayscale with Alpha";
+        case COLOR_TYPE_RGB_WITH_ALPHA:         return "RGB with Alpha";
+        default:                                return "Unknown - " + colorType;
+    }
+}
+
+String getFilterMethodString() {
+    switch (filterMethod) {
+        case FILTER_NONE:       return "None";
+        case FILTER_SUB:        return "Sub";
+        case FILTER_UP:         return "Up";
+        case FILTER_AVERAGE:    return "Average";
+        case FILTER_PAETH:      return "Paeth";
+        default:                return "Unknown";
+    }
+}
+
+String getInterlaceMethodString() {
+    switch (interlaceMethod) {
+        case INTERLACE_METHOD_NONE:     return "Not Interlaced";
+        case INTERLACE_METHOD_ADAM7:    return "Interlaced - ADAM7";
+        default:                return "Unknown";
+    }
+}
+
+void contributeToString(StringBuffer buffer) {
+    buffer.append("\n\tWidth: ");
+    buffer.append(width);
+    buffer.append("\n\tHeight: ");
+    buffer.append(height);
+    buffer.append("\n\tBit Depth: ");
+    buffer.append(bitDepth);
+    buffer.append("\n\tColor Type: ");
+    buffer.append(getColorTypeString());
+    buffer.append("\n\tCompression Method: ");
+    buffer.append(compressionMethod);
+    buffer.append("\n\tFilter Method: ");
+    buffer.append(getFilterMethodString());
+    buffer.append("\n\tInterlace Method: ");
+    buffer.append(getInterlaceMethodString());
+}
+
+bool getMustHavePalette() {
+    return colorType is COLOR_TYPE_PALETTE;
+}
+
+bool getCanHavePalette() {
+    return colorType !is COLOR_TYPE_GRAYSCALE && 
+        colorType !is COLOR_TYPE_GRAYSCALE_WITH_ALPHA;
+}
+
+/**
+ * Answer the pixel size in bits based on the color type
+ * and bit depth.
+ */
+int getBitsPerPixel() {
+    switch (colorType) {
+        case COLOR_TYPE_RGB_WITH_ALPHA:
+            return 4 * bitDepth;
+        case COLOR_TYPE_RGB:
+            return 3 * bitDepth;
+        case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+            return 2 * bitDepth;
+        case COLOR_TYPE_GRAYSCALE:
+        case COLOR_TYPE_PALETTE:
+            return bitDepth;
+        default:
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+            return 0;
+    }
+}
+
+/**
+ * Answer the pixel size in bits based on the color type
+ * and bit depth.
+ */
+int getSwtBitsPerPixel() {
+    switch (colorType) {
+        case COLOR_TYPE_RGB_WITH_ALPHA:
+        case COLOR_TYPE_RGB:
+        case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+            return 24;
+        case COLOR_TYPE_GRAYSCALE:
+        case COLOR_TYPE_PALETTE:
+            return Math.min(bitDepth, 8);
+        default:
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+            return 0;
+    }
+}
+
+int getFilterByteOffset() {
+    if (bitDepth < 8) return 1;
+    return getBitsPerPixel() / 8;
+}
+
+bool usesDirectColor() {
+    switch (colorType) {
+        case COLOR_TYPE_GRAYSCALE:
+        case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+        case COLOR_TYPE_RGB:
+        case COLOR_TYPE_RGB_WITH_ALPHA:
+            return true;
+        default:
+            return false;
+    }
+}
+
+PaletteData createGrayscalePalette() {
+    int depth = Math.min(bitDepth, 8);
+    int max = (1 << depth) - 1;
+    int delta = 255 / max;
+    int gray = 0;
+    RGB[] rgbs = new RGB[max + 1]; 
+    for (int i = 0; i <= max; i++) {
+        rgbs[i] = new RGB(gray, gray, gray);
+        gray += delta;
+    }
+    return new PaletteData(rgbs);
+}
+
+PaletteData getPaletteData() {
+    switch (colorType) {
+        case COLOR_TYPE_GRAYSCALE:
+            return createGrayscalePalette();
+        case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+        case COLOR_TYPE_RGB:
+        case COLOR_TYPE_RGB_WITH_ALPHA:
+            return new PaletteData(0xFF0000, 0xFF00, 0xFF);
+        default:
+            return null;
+    }   
+}
+
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngInputStream.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class PngInputStream : InputStream {
+    PngChunkReader reader;
+    PngChunk chunk;
+    int offset, length;
+    
+    final static int DATA_OFFSET = 8; 
+    
+public PngInputStream(PngIdatChunk chunk, PngChunkReader reader) {
+    this.chunk = chunk;
+    this.reader = reader;
+    length = chunk.getLength();
+    offset = 0;
+}
+
+private bool checkChunk() throws IOException {
+    while (offset is length) {
+        chunk = reader.readNextChunk();
+        if (chunk is null) throw new IOException();
+        if (chunk.getChunkType() is PngChunk.CHUNK_IEND) return false;
+        if (chunk.getChunkType() !is PngChunk.CHUNK_IDAT) throw new IOException();
+        length = chunk.getLength();
+        offset = 0;
+    }
+    return true;
+}
+
+public void close() throws IOException {
+    chunk = null;
+}
+
+public int read() throws IOException {
+    if (chunk is null) throw new IOException();
+    if (offset is length && !checkChunk()) return -1;
+    int b = chunk.reference[DATA_OFFSET + offset] & 0xFF;
+    offset++;
+    return b;
+}
+
+public int read(byte[] b, int off, int len) throws IOException {
+    if (chunk is null) throw new IOException();
+    if (offset is length && !checkChunk()) return -1;
+    len = Math.min(len, length - offset);
+    System.arraycopy(chunk.reference, DATA_OFFSET + offset, b, off, len);
+    offset += len;
+    return len;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngLzBlockReader.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.IOException;
+
+public class PngLzBlockReader {
+    bool isLastBlock;
+    byte compressionType;
+    int uncompressedBytesRemaining;
+    PngDecodingDataStream stream;
+    PngHuffmanTables huffmanTables;
+    
+    byte[] window;
+    int windowIndex;
+    int copyIndex;
+    int copyBytesRemaining;
+    
+    static final int UNCOMPRESSED = 0;
+    static final int COMPRESSED_FIXED = 1;
+    static final int COMPRESSED_DYNAMIC = 2;
+
+    static final int END_OF_COMPRESSED_BLOCK = 256;
+    static final int FIRST_LENGTH_CODE = 257;
+    static final int LAST_LENGTH_CODE = 285;
+    static final int FIRST_DISTANCE_CODE = 1;
+    static final int LAST_DISTANCE_CODE = 29;
+    static final int FIRST_CODE_LENGTH_CODE = 4;
+    static final int LAST_CODE_LENGTH_CODE = 19;
+
+    static final int[] lengthBases = {
+        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 
+        31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
+    } ; 
+    static final int[] extraLengthBits = {
+        0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 
+        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0,
+    };
+    static final int[] distanceBases = {
+        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129,
+        193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097,
+        6145, 8193, 12289, 16385, 24577,
+    };
+    static final int[] extraDistanceBits = {
+        0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7,  7,
+        8,  8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
+    };  
+
+
+PngLzBlockReader(PngDecodingDataStream stream) {
+    this.stream = stream;
+    isLastBlock = false;
+}
+
+void setWindowSize(int windowSize) {
+    window = new byte[windowSize];
+}   
+
+void readNextBlockHeader() throws IOException {
+    isLastBlock = stream.getNextIdatBit() !is 0;
+    compressionType = (byte)(stream.getNextIdatBits(2) & 0xFF);
+    if (compressionType > 2) stream.error();    
+    
+    if (compressionType is UNCOMPRESSED) {
+        byte b1 = stream.getNextIdatByte();
+        byte b2 = stream.getNextIdatByte();
+        byte b3 = stream.getNextIdatByte();
+        byte b4 = stream.getNextIdatByte();
+        if (b1 !is ~b3 || b2 !is ~b4) stream.error();
+        uncompressedBytesRemaining = (b1 & 0xFF) | ((b2 & 0xFF) << 8);
+    } else if (compressionType is COMPRESSED_DYNAMIC) {
+        huffmanTables = PngHuffmanTables.getDynamicTables(stream);
+    } else {
+        huffmanTables = PngHuffmanTables.getFixedTables();
+    }
+}
+
+byte getNextByte() throws IOException {
+    if (compressionType is UNCOMPRESSED) {
+        if (uncompressedBytesRemaining is 0) {
+            readNextBlockHeader();
+            return getNextByte();
+        }
+        uncompressedBytesRemaining--;
+        return stream.getNextIdatByte();
+    } else {
+        byte value = getNextCompressedByte();
+        if (value is END_OF_COMPRESSED_BLOCK) {
+            if (isLastBlock) stream.error();
+            readNextBlockHeader();
+            return getNextByte();
+        } else {
+            return value;
+        }
+    }
+}
+
+private void assertBlockAtEnd() throws IOException {
+    if (compressionType is UNCOMPRESSED) {
+        if (uncompressedBytesRemaining > 0) stream.error();
+    } else if (copyBytesRemaining > 0 ||
+        (huffmanTables.getNextLiteralValue(stream) !is END_OF_COMPRESSED_BLOCK)) 
+    {
+        stream.error();     
+    }
+}
+void assertCompressedDataAtEnd() throws IOException {
+    assertBlockAtEnd();     
+    while (!isLastBlock) {
+        readNextBlockHeader();
+        assertBlockAtEnd();
+    }   
+}
+
+private byte getNextCompressedByte() throws IOException {
+    if (copyBytesRemaining > 0) {
+        byte value = window[copyIndex];
+        window[windowIndex] = value;
+        copyBytesRemaining--;
+        
+        copyIndex++;
+        windowIndex++;      
+        if (copyIndex is window.length) copyIndex = 0;
+        if (windowIndex is window.length) windowIndex = 0;
+
+        return value;       
+    }
+    
+    int value = huffmanTables.getNextLiteralValue(stream);
+    if (value < END_OF_COMPRESSED_BLOCK) {
+        window[windowIndex] = (byte) (value & 0xFF);
+        windowIndex++;
+        if (windowIndex >= window.length) windowIndex = 0;
+        return (byte) (value & 0xFF);       
+    } else if (value is END_OF_COMPRESSED_BLOCK) {
+        readNextBlockHeader();
+        return getNextByte();
+    } else if (value <= LAST_LENGTH_CODE) {
+        int extraBits = extraLengthBits[value - FIRST_LENGTH_CODE];
+        int length = lengthBases[value - FIRST_LENGTH_CODE];
+        if (extraBits > 0) {
+            length += stream.getNextIdatBits(extraBits);
+        }
+        
+        value = huffmanTables.getNextDistanceValue(stream);
+        if (value > LAST_DISTANCE_CODE) stream.error();
+        extraBits = extraDistanceBits[value];
+        int distance = distanceBases[value];
+        if (extraBits > 0) {
+            distance += stream.getNextIdatBits(extraBits);
+        }
+        
+        copyIndex = windowIndex - distance;
+        if (copyIndex < 0) copyIndex += window.length;
+
+        copyBytesRemaining = length;
+        return getNextCompressedByte();
+    } else {
+        stream.error();
+        return 0;
+    }
+}
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngPlteChunk.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+
+class PngPlteChunk : PngChunk {
+    
+    int paletteSize;
+
+PngPlteChunk(PaletteData palette) {
+    super(palette.getRGBs().length * 3);
+    paletteSize = length / 3;
+    setType(TYPE_PLTE);
+    setPaletteData(palette);
+    setCRC(computeCRC());
+}       
+
+PngPlteChunk(byte[] reference){
+    super(reference);
+    paletteSize = length / 3;
+}
+
+int getChunkType() {
+    return CHUNK_PLTE;
+}
+
+/**
+ * Get the number of colors in this palette.
+ */
+int getPaletteSize() {
+    return paletteSize;
+}
+
+/**
+ * Get a PaletteData object representing the colors
+ * stored in this PLTE chunk.
+ * The result should be cached as the PLTE chunk
+ * does not store the palette data created.
+ */
+PaletteData getPaletteData() {
+    RGB[] rgbs = new RGB[paletteSize];
+//  int start = DATA_OFFSET;
+//  int end = DATA_OFFSET + length;
+    for (int i = 0; i < rgbs.length; i++) {
+        int offset = DATA_OFFSET + (i * 3);
+        int red = reference[offset] & 0xFF;
+        int green = reference[offset + 1] & 0xFF;
+        int blue = reference[offset + 2] & 0xFF;
+        rgbs[i] = new RGB(red, green, blue);        
+    }
+    return new PaletteData(rgbs);
+}
+
+/**
+ * Set the data of a PLTE chunk to the colors
+ * stored in the specified PaletteData object.
+ */
+void setPaletteData(PaletteData palette) {
+    RGB[] rgbs = palette.getRGBs();
+    for (int i = 0; i < rgbs.length; i++) {
+        int offset = DATA_OFFSET + (i * 3);
+        reference[offset] = (byte) rgbs[i].red;
+        reference[offset + 1] = (byte) rgbs[i].green;
+        reference[offset + 2] = (byte) rgbs[i].blue;
+    }
+}
+
+/**
+ * Answer whether the chunk is a valid PLTE chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+    // A PLTE chunk is invalid if no IHDR has been read or if any PLTE,
+    // IDAT, or IEND chunk has been read.
+    if (!readState.readIHDR
+        || readState.readPLTE
+        || readState.readTRNS
+        || readState.readIDAT
+        || readState.readIEND) 
+    {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    } else {
+        readState.readPLTE = true;
+    }
+    
+    super.validate(readState, headerChunk);
+    
+    // Palettes cannot be included in grayscale images.
+    // 
+    // Note: just ignore the palette.
+//  if (!headerChunk.getCanHavePalette()) DWT.error(DWT.ERROR_INVALID_IMAGE);
+    
+    // Palette chunks' data fields must be event multiples
+    // of 3. Each 3-byte group represents an RGB value.
+    if (getLength() % 3 !is 0) DWT.error(DWT.ERROR_INVALID_IMAGE);  
+    
+    // Palettes cannot have more entries than 2^bitDepth
+    // where bitDepth is the bit depth of the image given
+    // in the IHDR chunk.
+    if (1 << headerChunk.getBitDepth() < paletteSize) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    
+    // Palettes cannot have more than 256 entries.
+    if (256 < paletteSize) DWT.error(DWT.ERROR_INVALID_IMAGE);
+}
+
+void contributeToString(StringBuffer buffer) {
+    buffer.append("\n\tPalette size:");
+    buffer.append(paletteSize);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/PngTrnsChunk.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import dwt.DWT;
+import dwt.graphics.RGB;
+
+public class PngTrnsChunk : PngChunk {
+    static final int TRANSPARENCY_TYPE_PIXEL = 0;
+    static final int TRANSPARENCY_TYPE_ALPHAS = 1;
+    static final int RGB_DATA_LENGTH = 6;
+    
+PngTrnsChunk(RGB rgb) {
+    super(RGB_DATA_LENGTH);
+    setType(TYPE_tRNS);
+    setInt16(DATA_OFFSET, rgb.red);
+    setInt16(DATA_OFFSET + 2, rgb.green);
+    setInt16(DATA_OFFSET + 4, rgb.blue);    
+    setCRC(computeCRC());
+}
+
+PngTrnsChunk(byte[] reference){
+    super(reference);
+}
+
+int getChunkType() {
+    return CHUNK_tRNS;
+}
+
+void validateLength(PngIhdrChunk header, PngPlteChunk paletteChunk) {
+    bool valid;
+    switch (header.getColorType()) {
+        case PngIhdrChunk.COLOR_TYPE_RGB:
+            // Three 2-byte values (RGB)
+            valid = getLength() is 6;
+            break;
+        case PngIhdrChunk.COLOR_TYPE_PALETTE:
+            // Three 2-byte values (RGB)
+            valid = getLength() <= paletteChunk.getLength();
+            break;
+        case PngIhdrChunk.COLOR_TYPE_GRAYSCALE:
+            // One 2-byte value
+            valid = getLength() is 2;
+            break;
+        // Cannot use both Alpha and tRNS
+        case PngIhdrChunk.COLOR_TYPE_RGB_WITH_ALPHA:
+        case PngIhdrChunk.COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+        default:
+            valid = false;
+    }
+    if (!valid) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+}
+
+/**
+ * Answer whether the chunk is a valid tRNS chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk, PngPlteChunk paletteChunk) {
+    if (!readState.readIHDR
+        || (headerChunk.getMustHavePalette() && !readState.readPLTE)
+        || readState.readIDAT
+        || readState.readIEND) 
+    {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    } else {
+        readState.readTRNS = true;
+    }
+    
+    validateLength(headerChunk, paletteChunk);
+    
+    super.validate(readState, headerChunk);
+}
+
+
+int getTransparencyType(PngIhdrChunk header) {
+    if (header.getColorType() is PngIhdrChunk.COLOR_TYPE_PALETTE) {
+        return TRANSPARENCY_TYPE_ALPHAS;
+    }
+    return TRANSPARENCY_TYPE_PIXEL;
+}
+
+/**
+ * Answer the transparent pixel RGB value.
+ * This is not valid for palette color types.
+ * This is not valid for alpha color types.
+ * This will convert a grayscale value into
+ * a palette index.
+ * It will compress a 6 byte RGB into a 3 byte
+ * RGB.
+ */
+int getSwtTransparentPixel(PngIhdrChunk header) {
+    switch (header.getColorType()) {
+        case PngIhdrChunk.COLOR_TYPE_GRAYSCALE:
+            int gray = ((reference[DATA_OFFSET] & 0xFF) << 8)
+                + (reference[DATA_OFFSET + 1] & 0xFF);
+            if (header.getBitDepth() > 8) {
+                return PNGFileFormat.compress16BitDepthTo8BitDepth(gray);
+            }
+            return gray & 0xFF;
+        case PngIhdrChunk.COLOR_TYPE_RGB:
+            int red = ((reference[DATA_OFFSET] & 0xFF) << 8)
+                | (reference[DATA_OFFSET + 1] & 0xFF);
+            int green = ((reference[DATA_OFFSET + 2] & 0xFF) << 8)
+                | (reference[DATA_OFFSET + 3] & 0xFF);
+            int blue = ((reference[DATA_OFFSET + 4] & 0xFF) << 8)
+                | (reference[DATA_OFFSET + 5] & 0xFF);          
+            if (header.getBitDepth() > 8) {
+                red = PNGFileFormat.compress16BitDepthTo8BitDepth(red);
+                green = PNGFileFormat.compress16BitDepthTo8BitDepth(green);
+                blue = PNGFileFormat.compress16BitDepthTo8BitDepth(blue);           
+            }
+            return (red << 16) | (green << 8) | blue;   
+        default:
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+            return -1;
+    }
+}
+
+/**
+ * Answer an array of Alpha values that correspond to the 
+ * colors in the palette.
+ * This is only valid for the COLOR_TYPE_PALETTE color type.
+ */
+byte[] getAlphaValues(PngIhdrChunk header, PngPlteChunk paletteChunk) {
+    if (header.getColorType() !is PngIhdrChunk.COLOR_TYPE_PALETTE) {
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    }
+    byte[] alphas = new byte[paletteChunk.getPaletteSize()];
+    int dataLength = getLength();
+    int i = 0;
+    for (i = 0; i < dataLength; i++) {
+        alphas[i] = reference[DATA_OFFSET + i];
+    }
+    /**
+     * Any palette entries which do not have a corresponding
+     * alpha value in the tRNS chunk are spec'd to have an 
+     * alpha of 255.
+     */
+    for (int j = i; j < alphas.length; j++) {
+        alphas[j] = (byte) 255;
+    }
+    return alphas;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/TIFFDirectory.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,630 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.ImageLoaderEvent;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+
+final class TIFFDirectory {
+
+    TIFFRandomFileAccess file;
+    bool isLittleEndian;
+    ImageLoader loader;
+    int depth;
+    
+    /* Directory fields */
+    int imageWidth;
+    int imageLength;
+    int[] bitsPerSample;
+    int compression;
+    int photometricInterpretation;
+    int[] stripOffsets;
+    int samplesPerPixel;
+    int rowsPerStrip;
+    int[] stripByteCounts;
+    int t4Options;
+    int colorMapOffset;
+    
+    /* Encoder fields */
+    ImageData image;
+    LEDataOutputStream out;
+    
+    static final int NO_VALUE = -1;
+    
+    static final short TAG_ImageWidth = 256;
+    static final short TAG_ImageLength = 257;
+    static final short TAG_BitsPerSample = 258;
+    static final short TAG_Compression = 259;
+    static final short TAG_PhotometricInterpretation = 262;
+    static final short TAG_StripOffsets = 273;
+    static final short TAG_SamplesPerPixel = 277;
+    static final short TAG_RowsPerStrip = 278;
+    static final short TAG_StripByteCounts = 279;
+    static final short TAG_XResolution = 282;
+    static final short TAG_YResolution = 283;
+    static final short TAG_T4Options = 292;
+    static final short TAG_ResolutionUnit = 296;
+    static final short TAG_ColorMap = 320;
+    
+    static final int TYPE_BYTE = 1;
+    static final int TYPE_ASCII = 2;
+    static final int TYPE_SHORT = 3;
+    static final int TYPE_LONG = 4;
+    static final int TYPE_RATIONAL = 5;
+    
+    /* Different compression schemes */
+    static final int COMPRESSION_NONE = 1;
+    static final int COMPRESSION_CCITT_3_1 = 2;
+    static final int COMPRESSION_PACKBITS = 32773;
+    
+    static final int IFD_ENTRY_SIZE = 12;
+    
+public TIFFDirectory(TIFFRandomFileAccess file, bool isLittleEndian, ImageLoader loader) {
+    this.file = file;
+    this.isLittleEndian = isLittleEndian;
+    this.loader = loader;
+}
+
+public TIFFDirectory(ImageData image) {
+    this.image = image;
+}
+
+/* PackBits decoder */
+int decodePackBits(byte[] src, byte[] dest, int offsetDest) {
+    int destIndex = offsetDest;
+    int srcIndex = 0;
+    while (srcIndex < src.length) {
+        byte n = src[srcIndex];
+        if (0 <= n && n <= 127) {
+            /* Copy next n+1 bytes literally */
+            System.arraycopy(src, ++srcIndex, dest, destIndex, n + 1);
+            srcIndex += n + 1;      
+            destIndex += n + 1; 
+        } else if (-127 <= n && n <= -1) {
+            /* Copy next byte -n+1 times */
+            byte value = src[++srcIndex];
+            for (int j = 0; j < -n + 1; j++) {
+                dest[destIndex++] = value;
+            }
+            srcIndex++;
+        } else {
+            /* Noop when n is -128 */
+            srcIndex++;
+        }
+    }
+    /* Number of bytes copied */
+    return destIndex - offsetDest;
+}
+
+int getEntryValue(int type, byte[] buffer, int index) {
+    return toInt(buffer, index + 8, type);
+}
+
+void getEntryValue(int type, byte[] buffer, int index, int[] values) throws IOException {
+    int start = index + 8;
+    int size;
+    int offset = toInt(buffer, start, TYPE_LONG);
+    switch (type) {
+        case TYPE_SHORT: size = 2; break;
+        case TYPE_LONG: size = 4; break; 
+        case TYPE_RATIONAL: size = 8; break;
+        case TYPE_ASCII:
+        case TYPE_BYTE: size = 1; break;
+        default: DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT); return;
+    }
+    if (values.length * size > 4) {
+        buffer = new byte[values.length * size]; 
+        file.seek(offset);
+        file.read(buffer);
+        start = 0;
+    }
+    for (int i = 0; i < values.length; i++) {
+        values[i] = toInt(buffer, start + i * size, type);
+    }
+}
+
+void decodePixels(ImageData image) throws IOException {
+    /* Each row is byte aligned */ 
+    byte[] imageData = new byte[(imageWidth * depth + 7) / 8 * imageLength];
+    image.data = imageData;
+    int destIndex = 0;
+    int length = stripOffsets.length;
+    for (int i = 0; i < length; i++) {
+        /* Read a strip */
+        byte[] data = new byte[stripByteCounts[i]];
+        file.seek(stripOffsets[i]);
+        file.read(data);
+        if (compression is COMPRESSION_NONE) {
+            System.arraycopy(data, 0, imageData, destIndex, data.length);
+            destIndex += data.length;
+        } else if (compression is COMPRESSION_PACKBITS) {
+            destIndex += decodePackBits(data, imageData, destIndex);
+        } else if (compression is COMPRESSION_CCITT_3_1 || compression is 3) {
+            TIFFModifiedHuffmanCodec codec = new TIFFModifiedHuffmanCodec();
+            int nRows = rowsPerStrip;
+            if (i is length -1) {
+                int n = imageLength % rowsPerStrip;
+                if (n !is 0) nRows = n;
+            }
+            destIndex += codec.decode(data, imageData, destIndex, imageWidth, nRows);
+        }
+        if (loader.hasListeners()) {
+            loader.notifyListeners(new ImageLoaderEvent(loader, image, i, i is length - 1));
+        }
+    }
+}
+
+PaletteData getColorMap() throws IOException {
+    int numColors = 1 << bitsPerSample[0];
+    /* R, G, B entries are 16 bit wide (2 bytes) */
+    int numBytes = 3 * 2 * numColors;
+    byte[] buffer = new byte[numBytes];
+    file.seek(colorMapOffset);
+    file.read(buffer);
+    RGB[] colors = new RGB[numColors];
+    /**
+     * DWT does not support 16-bit depth color formats.
+     * Convert the 16-bit data to 8-bit data.
+     * The correct way to do this is to multiply each
+     * 16 bit value by the value:
+     * (2^8 - 1) / (2^16 - 1).
+     * The fast way to do this is just to drop the low
+     * byte of the 16-bit value.
+     */
+    int offset = isLittleEndian ? 1 : 0;
+    int startG = 2 * numColors;
+    int startB = startG + 2 * numColors;
+    for (int i = 0; i < numColors; i++) {
+        int r = buffer[offset] & 0xFF;
+        int g = buffer[startG + offset] & 0xFF;
+        int b = buffer[startB + offset] & 0xFF;
+        colors[i] = new RGB(r, g, b);
+        offset += 2;
+    }
+    return new PaletteData(colors);
+}
+
+PaletteData getGrayPalette() {
+    int numColors = 1 << bitsPerSample[0];
+    RGB[] rgbs = new RGB[numColors];
+    for (int i = 0; i < numColors; i++) {
+        int value = i * 0xFF / (numColors - 1);
+        if (photometricInterpretation is 0) value = 0xFF - value;
+        rgbs[i] = new RGB(value, value, value);
+    }
+    return new PaletteData(rgbs);
+}
+
+PaletteData getRGBPalette(int bitsR, int bitsG, int bitsB) {    
+    int blueMask = 0;
+    for (int i = 0; i < bitsB; i++) {
+        blueMask |= 1 << i;
+    }
+    int greenMask = 0;
+    for (int i = bitsB; i < bitsB + bitsG; i++) {
+        greenMask |= 1 << i;
+    }
+    int redMask = 0;
+    for (int i = bitsB + bitsG; i < bitsB + bitsG + bitsR; i++) {
+        redMask |= 1 << i;
+    }   
+    return new PaletteData(redMask, greenMask, blueMask);
+}
+
+int formatStrips(int rowByteSize, int nbrRows, byte[] data, int maxStripByteSize, int offsetPostIFD, int extraBytes, int[][] strips) {
+    /* 
+    * Calculate the nbr of required strips given the following requirements: 
+    * - each strip should, if possible, not be greater than maxStripByteSize
+    * - each strip should contain 1 or more entire rows
+    * 
+    * Format the strip fields arrays so that the image data is stored in one
+    * contiguous block. This block is stored after the IFD and after any tag
+    * info described in the IFD.
+    */
+    int n, nbrRowsPerStrip;
+    if (rowByteSize > maxStripByteSize) {
+        /* Each strip contains 1 row */
+        n = data.length / rowByteSize;
+        nbrRowsPerStrip = 1;
+    } else {
+        int nbr = (data.length + maxStripByteSize - 1) / maxStripByteSize;
+        nbrRowsPerStrip = nbrRows / nbr;
+        n = (nbrRows + nbrRowsPerStrip - 1) / nbrRowsPerStrip;  
+    }
+    int stripByteSize = rowByteSize * nbrRowsPerStrip;
+
+    int[] offsets = new int[n];
+    int[] counts = new int[n];
+    /* 
+    * Nbr of bytes between the end of the IFD directory and the start of
+    * the image data. Keep space for at least the offsets and counts
+    * data, each field being TYPE_LONG (4 bytes). If other tags require
+    * space between the IFD and the image block, use the extraBytes
+    * parameter.
+    * If there is only one strip, the offsets and counts data is stored
+    * directly in the IFD and we need not reserve space for it.
+    */
+    int postIFDData = n is 1 ? 0 : n * 2 * 4;
+    int startOffset = offsetPostIFD + extraBytes + postIFDData; /* offset of image data */
+    
+    int offset = startOffset;
+    for (int i = 0; i < n; i++) {
+        /* 
+        * Store all strips sequentially to allow us
+        * to copy all pixels in one contiguous area.
+        */
+        offsets[i] = offset;
+        counts[i] = stripByteSize;
+        offset += stripByteSize;
+    }
+    /* The last strip may contain fewer rows */
+    int mod = data.length % stripByteSize;
+    if (mod !is 0) counts[counts.length - 1] = mod;
+    
+    strips[0] = offsets;
+    strips[1] = counts;
+    return nbrRowsPerStrip;
+}
+
+int[] formatColorMap(RGB[] rgbs) {
+    /* 
+    * In a TIFF ColorMap, all red come first, followed by
+    * green and blue. All values must be converted from
+    * 8 bit to 16 bit. 
+    */
+    int[] colorMap = new int[rgbs.length * 3];
+    int offsetGreen = rgbs.length;
+    int offsetBlue = rgbs.length * 2;
+    for (int i = 0; i < rgbs.length; i++) {
+        colorMap[i] = rgbs[i].red << 8 | rgbs[i].red;
+        colorMap[i + offsetGreen] = rgbs[i].green << 8 | rgbs[i].green;
+        colorMap[i + offsetBlue] = rgbs[i].blue << 8 | rgbs[i].blue;
+    }
+    return colorMap;
+}
+
+void parseEntries(byte[] buffer) throws IOException {
+    for (int offset = 0; offset < buffer.length; offset += IFD_ENTRY_SIZE) {
+        int tag = toInt(buffer, offset, TYPE_SHORT);
+        int type = toInt(buffer, offset + 2, TYPE_SHORT);
+        int count = toInt(buffer, offset + 4, TYPE_LONG);
+        switch (tag) {
+            case TAG_ImageWidth: {
+                imageWidth = getEntryValue(type, buffer, offset);
+                break;
+            }
+            case TAG_ImageLength: {
+                imageLength = getEntryValue(type, buffer, offset);
+                break;
+            }
+            case TAG_BitsPerSample: {
+                if (type !is TYPE_SHORT) DWT.error(DWT.ERROR_INVALID_IMAGE);
+                bitsPerSample = new int[count];
+                getEntryValue(type, buffer, offset, bitsPerSample);
+                break;
+            }
+            case TAG_Compression: {
+                compression = getEntryValue(type, buffer, offset);
+                break;
+            }
+            case TAG_PhotometricInterpretation: {
+                photometricInterpretation = getEntryValue(type, buffer, offset);
+                break;
+            }
+            case TAG_StripOffsets: {
+                if (type !is TYPE_LONG && type !is TYPE_SHORT) DWT.error(DWT.ERROR_INVALID_IMAGE);
+                stripOffsets = new int[count];
+                getEntryValue(type, buffer, offset, stripOffsets);
+                break;
+            }
+            case TAG_SamplesPerPixel: {
+                if (type !is TYPE_SHORT) DWT.error(DWT.ERROR_INVALID_IMAGE);
+                samplesPerPixel = getEntryValue(type, buffer, offset);
+                /* Only the basic 1 and 3 values are supported */
+                if (samplesPerPixel !is 1 && samplesPerPixel !is 3) DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+                break;
+            }
+            case TAG_RowsPerStrip: {
+                rowsPerStrip = getEntryValue(type, buffer, offset);
+                break;
+            }
+            case TAG_StripByteCounts: {
+                stripByteCounts = new int[count];
+                getEntryValue(type, buffer, offset, stripByteCounts);
+                break;
+            }
+            case TAG_XResolution: {
+                /* Ignored */
+                break;
+            }
+            case TAG_YResolution: {
+                /* Ignored */
+                break;
+            }
+            case TAG_T4Options: {
+                if (type !is TYPE_LONG) DWT.error(DWT.ERROR_INVALID_IMAGE);
+                t4Options = getEntryValue(type, buffer, offset);
+                if ((t4Options & 0x1) is 1) {
+                    /* 2-dimensional coding is not supported */
+                    DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+                }
+                break;
+            }
+            case TAG_ResolutionUnit: {
+                /* Ignored */
+                break;
+            }
+            case TAG_ColorMap: {
+                if (type !is TYPE_SHORT) DWT.error(DWT.ERROR_INVALID_IMAGE);
+                /* Get the offset of the colorMap (use TYPE_LONG) */
+                colorMapOffset = getEntryValue(TYPE_LONG, buffer, offset);
+                break;
+            }
+        }
+    }
+}
+
+public ImageData read() throws IOException {
+    /* Set TIFF default values */
+    bitsPerSample = new int[] {1};
+    colorMapOffset = NO_VALUE;
+    compression = 1;
+    imageLength = NO_VALUE;
+    imageWidth = NO_VALUE;
+    photometricInterpretation = NO_VALUE;
+    rowsPerStrip = Integer.MAX_VALUE;
+    samplesPerPixel = 1;
+    stripByteCounts = null;
+    stripOffsets = null;
+    
+    byte[] buffer = new byte[2];
+    file.read(buffer);
+    int numberEntries = toInt(buffer, 0, TYPE_SHORT);
+    buffer = new byte[IFD_ENTRY_SIZE * numberEntries];
+    file.read(buffer);
+    parseEntries(buffer);
+    
+    PaletteData palette = null;
+    depth = 0;
+    switch (photometricInterpretation) {
+        case 0:
+        case 1: {
+            /* Bilevel or Grayscale image */
+            palette = getGrayPalette();
+            depth = bitsPerSample[0];
+            break;
+        }
+        case 2: {
+            /* RGB image */
+            if (colorMapOffset !is NO_VALUE) DWT.error(DWT.ERROR_INVALID_IMAGE);
+            /* SamplesPerPixel 3 is the only value supported */
+            palette = getRGBPalette(bitsPerSample[0], bitsPerSample[1], bitsPerSample[2]);
+            depth = bitsPerSample[0] + bitsPerSample[1] + bitsPerSample[2];
+            break;      
+        }
+        case 3: {
+            /* Palette Color image */
+            if (colorMapOffset is NO_VALUE) DWT.error(DWT.ERROR_INVALID_IMAGE);
+            palette = getColorMap();
+            depth = bitsPerSample[0];
+            break;
+        }
+        default: {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        }
+    }
+
+    ImageData image = ImageData.internal_new(
+            imageWidth,
+            imageLength, 
+            depth,
+            palette,
+            1,
+            null,
+            0,
+            null,
+            null,
+            -1,
+            -1,
+            DWT.IMAGE_TIFF,
+            0,
+            0,
+            0,
+            0);
+    decodePixels(image);
+    return image;
+}
+
+int toInt(byte[] buffer, int i, int type) {
+    if (type is TYPE_LONG) {
+        return isLittleEndian ? 
+        (buffer[i] & 0xFF) | ((buffer[i + 1] & 0xFF) << 8) | ((buffer[i + 2] & 0xFF) << 16) | ((buffer[i + 3] & 0xFF) << 24) :
+        (buffer[i + 3] & 0xFF) | ((buffer[i + 2] & 0xFF) << 8) | ((buffer[i + 1] & 0xFF) << 16) | ((buffer[i] & 0xFF) << 24);
+    }
+    if (type is TYPE_SHORT) {
+        return isLittleEndian ? 
+        (buffer[i] & 0xFF) | ((buffer[i + 1] & 0xFF) << 8) :
+        (buffer[i + 1] & 0xFF) | ((buffer[i] & 0xFF) << 8);     
+    }
+    /* Invalid type */
+    DWT.error(DWT.ERROR_INVALID_IMAGE);
+    return -1;
+}
+
+void write(int photometricInterpretation) throws IOException {
+    bool isRGB = photometricInterpretation is 2;
+    bool isColorMap = photometricInterpretation is 3;
+    bool isBiLevel = photometricInterpretation is 0 || photometricInterpretation is 1;
+
+    int imageWidth = image.width;
+    int imageLength = image.height;
+    int rowByteSize = image.bytesPerLine;
+    
+    int numberEntries = isBiLevel ? 9 : 11;
+    int lengthDirectory = 2 + 12 * numberEntries + 4;
+    /* Offset following the header and the directory */
+    int nextOffset = 8 + lengthDirectory;
+
+    /* Extra space used by XResolution and YResolution values */
+    int extraBytes = 16;
+
+    int[] colorMap = null;
+    if (isColorMap) {   
+        PaletteData palette = image.palette;
+        RGB[] rgbs = palette.getRGBs();
+        colorMap = formatColorMap(rgbs);
+        /* The number of entries of the Color Map must match the bitsPerSample field */
+        if (colorMap.length !is 3 * 1 << image.depth) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+        /* Extra space used by ColorMap values */
+        extraBytes += colorMap.length * 2;
+    }
+    if (isRGB) {
+        /* Extra space used by BitsPerSample values */
+        extraBytes += 6;
+    } 
+    /* TIFF recommends storing the data in strips of no more than 8 Ko */
+    byte[] data = image.data;
+    int[][] strips = new int[2][];
+    int nbrRowsPerStrip = formatStrips(rowByteSize, imageLength, data, 8192, nextOffset, extraBytes, strips);
+    int[] stripOffsets = strips[0];
+    int[] stripByteCounts = strips[1];
+
+    int bitsPerSampleOffset = NO_VALUE;
+    if (isRGB) {
+        bitsPerSampleOffset = nextOffset;
+        nextOffset += 6;
+    }
+    int stripOffsetsOffset = NO_VALUE, stripByteCountsOffset = NO_VALUE;
+    int xResolutionOffset, yResolutionOffset, colorMapOffset = NO_VALUE;
+    int cnt = stripOffsets.length;
+    if (cnt > 1) {
+        stripOffsetsOffset = nextOffset;
+        nextOffset += 4 * cnt;
+        stripByteCountsOffset = nextOffset;
+        nextOffset += 4 * cnt;
+    }
+    xResolutionOffset = nextOffset;
+    nextOffset += 8;
+    yResolutionOffset = nextOffset;
+    nextOffset += 8;
+    if (isColorMap) {
+        colorMapOffset = nextOffset;
+        nextOffset += colorMap.length * 2;
+    }
+    /* TIFF header */
+    writeHeader();
+    
+    /* Image File Directory */
+    out.writeShort(numberEntries);  
+    writeEntry(TAG_ImageWidth, TYPE_LONG, 1, imageWidth);   
+    writeEntry(TAG_ImageLength, TYPE_LONG, 1, imageLength);
+    if (isColorMap) writeEntry(TAG_BitsPerSample, TYPE_SHORT, 1, image.depth);
+    if (isRGB) writeEntry(TAG_BitsPerSample, TYPE_SHORT, 3, bitsPerSampleOffset);
+    writeEntry(TAG_Compression, TYPE_SHORT, 1, COMPRESSION_NONE);
+    writeEntry(TAG_PhotometricInterpretation, TYPE_SHORT, 1, photometricInterpretation);
+    writeEntry(TAG_StripOffsets, TYPE_LONG, cnt, cnt > 1 ? stripOffsetsOffset : stripOffsets[0]);
+    if (isRGB) writeEntry(TAG_SamplesPerPixel, TYPE_SHORT, 1, 3);
+    writeEntry(TAG_RowsPerStrip, TYPE_LONG, 1, nbrRowsPerStrip);
+    writeEntry(TAG_StripByteCounts, TYPE_LONG, cnt, cnt > 1 ? stripByteCountsOffset : stripByteCounts[0]);
+    writeEntry(TAG_XResolution, TYPE_RATIONAL, 1, xResolutionOffset);
+    writeEntry(TAG_YResolution, TYPE_RATIONAL, 1, yResolutionOffset);
+    if (isColorMap) writeEntry(TAG_ColorMap, TYPE_SHORT, colorMap.length, colorMapOffset);
+    /* Offset of next IFD (0 for last IFD) */
+    out.writeInt(0);
+    
+    /* Values longer than 4 bytes Section */
+    
+    /* BitsPerSample 8,8,8 */
+    if (isRGB) for (int i = 0; i < 3; i++) out.writeShort(8);
+    if (cnt > 1) {
+        for (int i = 0; i < cnt; i++) out.writeInt(stripOffsets[i]);
+        for (int i = 0; i < cnt; i++) out.writeInt(stripByteCounts[i]);
+    }
+    /* XResolution and YResolution set to 300 dpi */
+    for (int i = 0; i < 2; i++) {
+        out.writeInt(300);
+        out.writeInt(1);
+    }
+    /* ColorMap */
+    if (isColorMap) for (int i = 0; i < colorMap.length; i++) out.writeShort(colorMap[i]);
+    
+    /* Image Data */
+    out.write(data);
+}
+
+void writeEntry(short tag, int type, int count, int value) throws IOException {
+    out.writeShort(tag);
+    out.writeShort(type);
+    out.writeInt(count);
+    out.writeInt(value);
+}
+
+void writeHeader() throws IOException {
+    /* little endian */
+    out.write(0x49);
+    out.write(0x49);
+
+    /* TIFF identifier */
+    out.writeShort(42);
+    /* 
+    * Offset of the first IFD is chosen to be 8.
+    * It is word aligned and immediately after this header.
+    */
+    out.writeInt(8);
+}
+
+void writeToStream(LEDataOutputStream byteStream) throws IOException {
+    out = byteStream;
+    int photometricInterpretation = -1;
+    
+    /* Scanline pad must be 1 */
+    if (image.scanlinePad !is 1) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+    switch (image.depth) {
+        case 1: {
+            /* Palette must be black and white or white and black */
+            PaletteData palette = image.palette;
+            RGB[] rgbs = palette.colors;
+            if (palette.isDirect || rgbs is null || rgbs.length !is 2) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+            RGB rgb0 = rgbs[0];
+            RGB rgb1 = rgbs[1];
+            if (!(rgb0.red is rgb0.green && rgb0.green is rgb0.blue &&
+                rgb1.red is rgb1.green && rgb1.green is rgb1.blue &&
+                ((rgb0.red is 0x0 && rgb1.red is 0xFF) || (rgb0.red is 0xFF && rgb1.red is 0x0)))) {
+                DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT); 
+            }
+            /* 0 means a color index of 0 is imaged as white */
+            photometricInterpretation = image.palette.colors[0].red is 0xFF ? 0 : 1;
+            break;
+        }
+        case 4:
+        case 8: {
+            photometricInterpretation = 3;
+            break;
+        }
+        case 24: {
+            photometricInterpretation = 2;
+            break;
+        }
+        default: {
+            DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT);
+        }
+    }
+    write(photometricInterpretation);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/TIFFFileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+
+/**
+ * Baseline TIFF decoder revision 6.0
+ * Extension T4-encoding CCITT T.4 1D
+ */
+public final class TIFFFileFormat : FileFormat {
+
+bool isFileFormat(LEDataInputStream stream) {
+    try {
+        byte[] header = new byte[4];
+        stream.read(header);
+        stream.unread(header);
+        if (header[0] !is header[1]) return false;
+        if (!(header[0] is 0x49 && header[2] is 42 && header[3] is 0) &&
+            !(header[0] is 0x4d && header[2] is 0 && header[3] is 42)) {
+            return false;
+        }   
+        return true;
+    } catch (Exception e) {
+        return false;
+    }
+}
+
+ImageData[] loadFromByteStream() {  
+    byte[] header = new byte[8];
+    bool isLittleEndian;
+    ImageData[] images = new ImageData[0];
+    TIFFRandomFileAccess file = new TIFFRandomFileAccess(inputStream);
+    try {
+        file.read(header);
+        if (header[0] !is header[1]) DWT.error(DWT.ERROR_INVALID_IMAGE);
+        if (!(header[0] is 0x49 && header[2] is 42 && header[3] is 0) &&
+            !(header[0] is 0x4d && header[2] is 0 && header[3] is 42)) {
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        } 
+        isLittleEndian = header[0] is 0x49; 
+        int offset = isLittleEndian ? 
+            (header[4] & 0xFF) | ((header[5] & 0xFF) << 8) | ((header[6] & 0xFF) << 16) | ((header[7] & 0xFF) << 24) :
+            (header[7] & 0xFF) | ((header[6] & 0xFF) << 8) | ((header[5] & 0xFF) << 16) | ((header[4] & 0xFF) << 24);
+        file.seek(offset);
+        TIFFDirectory directory = new TIFFDirectory(file, isLittleEndian, loader);
+        ImageData image = directory.read();
+        /* A baseline reader is only expected to read the first directory */
+        images = new ImageData[] {image};
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return images;
+}
+
+void unloadIntoByteStream(ImageLoader loader) {
+    /* We do not currently support writing multi-page tiff,
+     * so we use the first image data in the loader's array. */
+    ImageData image = loader.data[0];
+    TIFFDirectory directory = new TIFFDirectory(image);
+    try {
+        directory.writeToStream(outputStream);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/TIFFModifiedHuffmanCodec.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import dwt.DWT;
+
+/*
+* Decoder for 
+* - CCITT Group 3 1-Dimensional Modified Huffman run length encoding
+*   (TIFF compression type 2)
+* - CCITT T.4 bi-level encoding 1D
+*   (TIFF compression type 3 option 1D) 
+*/
+final class TIFFModifiedHuffmanCodec {
+    static final short[][][] BLACK_CODE = {
+        /* 2 bits  */
+        {{2, 3}, {3, 2}},
+        /* 3 bits  */
+        {{2, 1}, {3, 4}},
+        /* 4 bits  */
+        {{2, 6}, {3, 5}},
+        /* 5 bits  */
+        {{3, 7}},
+        /* 6 bits  */
+        {{4, 9}, {5, 8}},
+        /* 7 bits  */
+        {{4, 10}, {5, 11}, {7, 12}},
+        /* 8 bits  */
+        {{4, 13}, {7, 14}},
+        /* 9 bits  */
+        {{24, 15}},
+        /* 10 bits */
+        {{8, 18}, {15, 64}, {23, 16}, {24, 17}, {55, 0}},
+        /* 11 bits */
+        {/* EOL */{0, -1}, {8, 1792}, {23, 24}, {24, 25}, {40, 23}, {55, 22}, {103, 19},
+        {104, 20}, {108, 21}, {12, 1856}, {13, 1920}},
+        /* 12 bits */
+        {{18, 1984}, {19, 2048}, {20, 2112}, {21, 2176}, {22, 2240}, {23, 2304},
+        {28, 2368}, {29, 2432}, {30, 2496}, {31, 2560}, {36, 52}, {39, 55}, {40, 56},
+        {43, 59}, {44, 60}, {51, 320}, {52, 384}, {53, 448}, {55, 53}, {56, 54}, {82, 50},
+        {83, 51}, {84, 44}, {85, 45}, {86, 46}, {87, 47}, {88, 57}, {89, 58}, {90, 61},
+        {91, 256}, {100, 48}, {101, 49}, {102, 62}, {103, 63}, {104, 30}, {105, 31},
+        {106, 32}, {107, 33}, {108, 40}, {109, 41}, {200, 128}, {201, 192}, {202, 26},
+        {203, 27}, {204, 28}, {205, 29}, {210, 34}, {211, 35}, {212, 36}, {213, 37},
+        {214, 38}, {215, 39}, {218, 42}, {219, 43}},
+        /* 13 bits */
+        {{74, 640}, {75, 704}, {76, 768}, {77, 832}, {82, 1280}, {83, 1344}, {84, 1408},
+        {85, 1472}, {90, 1536}, {91, 1600}, {100, 1664}, {101, 1728}, {108, 512},
+        {109, 576}, {114, 896}, {115, 960}, {116, 1024}, {117, 1088}, {118, 1152},
+        {119, 1216}}
+    };
+
+    static final short[][][] WHITE_CODE = {
+        /* 4 bits */
+        {{7, 2}, {8, 3}, {11, 4}, {12, 5}, {14, 6}, {15, 7}},
+        /* 5 bits */
+        {{7, 10}, {8, 11}, {18, 128}, {19, 8}, {20, 9}, {27, 64}},
+        /* 6 bits */
+        {{3, 13}, {7, 1}, {8, 12}, {23, 192}, {24, 1664}, {42, 16}, {43, 17}, {52, 14},
+        {53, 15}},
+        /* 7 bits */
+        {{3, 22}, {4, 23}, {8, 20}, {12, 19}, {19, 26}, {23, 21}, {24, 28}, {36, 27},
+        {39, 18}, {40, 24}, {43, 25}, {55, 256}},
+        /* 8 bits */
+        {{2, 29}, {3, 30}, {4, 45}, {5, 46}, {10, 47}, {11, 48}, {18, 33}, {19, 34},
+        {20, 35}, {21, 36}, {22, 37}, {23, 38}, {26, 31}, {27, 32}, {36, 53}, {37, 54},
+        {40, 39}, {41, 40}, {42, 41}, {43, 42}, {44, 43}, {45, 44}, {50, 61}, {51, 62},
+        {52, 63}, {53, 0}, {54, 320}, {55, 384}, {74, 59}, {75, 60}, {82, 49}, {83, 50},
+        {84, 51}, {85, 52}, {88, 55}, {89, 56}, {90, 57}, {91, 58}, {100, 448},
+        {101, 512}, {103, 640}, {104, 576}},
+        /* 9 bits */
+        {{152, 1472}, {153, 1536}, {154, 1600}, {155, 1728}, {204, 704}, {205, 768},
+        {210, 832}, {211, 896}, {212, 960}, {213, 1024}, {214, 1088}, {215, 1152},
+        {216, 1216}, {217, 1280}, {218, 1344}, {219, 1408}},
+        /* 10 bits */
+        {},
+        /* 11 bits */
+        {{8, 1792}, {12, 1856}, {13, 1920}},
+        /* 12 bits */
+        {/* EOL */{1, -1}, {18, 1984}, {19, 2048}, {20, 2112}, {21, 2176}, {22, 2240}, {23, 2304},
+        {28, 2368}, {29, 2432}, {30, 2496}, {31, 2560}}
+    };
+    
+    static final int BLACK_MIN_BITS = 2;
+    static final int WHITE_MIN_BITS = 4;
+
+    bool isWhite;
+    int whiteValue = 0;
+    int blackValue = 1;
+    byte[] src;
+    byte[] dest;
+    int byteOffsetSrc = 0;
+    int bitOffsetSrc = 0;
+    int byteOffsetDest = 0;
+    int bitOffsetDest = 0;
+    int code = 0;
+    int nbrBits = 0;
+    /* nbr of bytes per row */
+    int rowSize;
+
+public int decode(byte[] src, byte[] dest, int offsetDest, int rowSize, int nRows) {
+    this.src = src;
+    this.dest = dest;
+    this.rowSize = rowSize;
+    byteOffsetSrc = 0;
+    bitOffsetSrc = 0;
+    byteOffsetDest = offsetDest;
+    bitOffsetDest = 0;
+    int cnt = 0;
+    while (cnt < nRows && decodeRow()) {
+        cnt++;
+        /* byte aligned */
+        if (bitOffsetDest > 0) {
+            byteOffsetDest++;
+            bitOffsetDest = 0; 
+        }
+    }
+    return byteOffsetDest - offsetDest;
+}
+
+bool decodeRow() {
+    isWhite = true;
+    int n = 0;
+    while (n < rowSize) {
+        int runLength = decodeRunLength();
+        if (runLength < 0) return false;
+        n += runLength;
+        setNextBits(isWhite ? whiteValue : blackValue, runLength);
+        isWhite = !isWhite;
+    }
+    return true;
+}
+
+int decodeRunLength() {
+    int runLength = 0;
+    int partialRun = 0;
+    short[][][] huffmanCode = isWhite ? WHITE_CODE : BLACK_CODE;
+    while (true) {
+        bool found = false;
+        nbrBits = isWhite ? WHITE_MIN_BITS : BLACK_MIN_BITS;
+        code = getNextBits(nbrBits);
+        for (int i = 0; i < huffmanCode.length; i++) {
+            for (int j = 0; j < huffmanCode[i].length; j++) {
+                if (huffmanCode[i][j][0] is code) {
+                    found = true;
+                    partialRun = huffmanCode[i][j][1];
+                    if (partialRun is -1) {
+                        /* Stop when reaching final EOL on last byte */
+                        if (byteOffsetSrc is src.length - 1) return -1;
+                        /* Group 3 starts each row with an EOL - ignore it */
+                    } else {
+                        runLength += partialRun;
+                        if (partialRun < 64) return runLength;
+                    }
+                    break;
+                }
+            }
+            if (found) break;
+            code = code << 1 | getNextBit();
+        }
+        if (!found) DWT.error(DWT.ERROR_INVALID_IMAGE);          
+    }
+}
+
+int getNextBit() {
+    int value = (src[byteOffsetSrc] >>> (7 - bitOffsetSrc)) & 0x1;
+    bitOffsetSrc++;
+    if (bitOffsetSrc > 7) {
+        byteOffsetSrc++;
+        bitOffsetSrc = 0;
+    }
+    return value;
+}
+
+int getNextBits(int cnt) {
+    int value = 0;
+    for (int i = 0; i < cnt; i++) {
+        value = value << 1 | getNextBit();
+    }
+    return value;
+}
+
+void setNextBits(int value, int cnt) {
+    int n = cnt;
+    while (bitOffsetDest > 0 && bitOffsetDest <= 7 && n > 0) {
+        dest[byteOffsetDest] = value is 1 ?
+            (byte)(dest[byteOffsetDest] | (1 << (7 - bitOffsetDest))) :
+            (byte)(dest[byteOffsetDest] & ~(1 << (7 - bitOffsetDest)));
+        n--;
+        bitOffsetDest++; 
+    }
+    if (bitOffsetDest is 8) {
+        byteOffsetDest++;
+        bitOffsetDest = 0;
+    }
+    while (n >= 8) {
+        dest[byteOffsetDest++] = (byte) (value is 1 ? 0xFF : 0);
+        n -= 8;
+    }
+    while (n > 0) {
+        dest[byteOffsetDest] = value is 1 ?
+            (byte)(dest[byteOffsetDest] | (1 << (7 - bitOffsetDest))) :
+            (byte)(dest[byteOffsetDest] & ~(1 << (7 - bitOffsetDest)));
+        n--;
+        bitOffsetDest++;        
+    }   
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/TIFFRandomFileAccess.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+import java.io.IOException;
+
+final class TIFFRandomFileAccess {
+
+    LEDataInputStream inputStream;
+    int start, current, next;
+    byte[][] buffers;
+
+    static final int CHUNK_SIZE = 8192;
+    static final int LIST_SIZE = 128;
+
+public TIFFRandomFileAccess(LEDataInputStream stream) {
+    inputStream = stream;
+    start = current = next = inputStream.getPosition();
+    buffers = new byte[LIST_SIZE][];
+}
+
+void seek(int pos) throws IOException {
+    if (pos is current) return;
+    if (pos < start) throw new IOException();
+    current = pos;  
+    if (current > next) {
+        int n = current - next;
+        /* store required bytes */
+        int index = next / CHUNK_SIZE;
+        int offset = next % CHUNK_SIZE;
+        while (n > 0) {
+            if (index >= buffers.length) {
+                byte[][] oldBuffers = buffers;
+                buffers = new byte[Math.max(index + 1, oldBuffers.length + LIST_SIZE)][];
+                System.arraycopy(oldBuffers, 0, buffers, 0, oldBuffers.length);
+            }
+            if (buffers[index] is null) buffers[index] = new byte[CHUNK_SIZE];
+            int cnt = inputStream.read(buffers[index], offset, Math.min(n, CHUNK_SIZE - offset));
+            n -= cnt;
+            next += cnt;
+            index++;
+            offset = 0;
+        }
+    }
+}
+
+void read(byte b[]) throws IOException {
+    int size = b.length;
+    int nCached = Math.min(size, next - current);
+    int nMissing = size - next + current;
+    int destNext = 0;
+    if (nCached > 0) {
+        /* Get cached bytes */
+        int index = current / CHUNK_SIZE;
+        int offset = current % CHUNK_SIZE;      
+        while (nCached > 0) {
+            int cnt = Math.min(nCached, CHUNK_SIZE - offset);
+            System.arraycopy(buffers[index], offset, b, destNext, cnt);
+            nCached -= cnt; 
+            destNext += cnt;
+            index++;
+            offset = 0;
+        }
+    }
+    if (nMissing > 0) {
+        /* Read required bytes */
+        int index = next / CHUNK_SIZE;
+        int offset = next % CHUNK_SIZE;
+        while (nMissing > 0) {
+            if (index >= buffers.length) {
+                byte[][] oldBuffers = buffers;
+                buffers = new byte[Math.max(index, oldBuffers.length + LIST_SIZE)][];
+                System.arraycopy(oldBuffers, 0, buffers, 0, oldBuffers.length);
+            }
+            if (buffers[index] is null) buffers[index] = new byte[CHUNK_SIZE];
+            int cnt = inputStream.read(buffers[index], offset, Math.min(nMissing, CHUNK_SIZE - offset));
+            System.arraycopy(buffers[index], offset, b, destNext, cnt);
+            nMissing -= cnt;
+            next += cnt;
+            destNext += cnt;
+            index++;
+            offset = 0;
+        }
+    }
+    current += size;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/WinBMPFileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,697 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.PaletteData;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+
+public final class WinBMPFileFormat : FileFormat {
+    static final int BMPFileHeaderSize = 14;
+    static final int BMPHeaderFixedSize = 40;
+    int importantColors;
+    Point pelsPerMeter = new Point(0, 0);
+
+/**
+ * Compress numBytes bytes of image data from src, storing in dest
+ * (starting at 0), using the technique specified by comp.
+ * If last is true, this indicates the last line of the image.
+ * Answer the size of the compressed data.
+ */
+int compress(int comp, byte[] src, int srcOffset, int numBytes, byte[] dest, bool last) {
+    if (comp is 1) { // BMP_RLE8_COMPRESSION
+        return compressRLE8Data(src, srcOffset, numBytes, dest, last);
+    }
+    if (comp is 2) { // BMP_RLE4_COMPRESSION
+        return compressRLE4Data(src, srcOffset, numBytes, dest, last);
+    }
+    DWT.error(DWT.ERROR_INVALID_IMAGE);
+    return 0;
+}
+int compressRLE4Data(byte[] src, int srcOffset, int numBytes, byte[] dest, bool last) {
+    int sp = srcOffset, end = srcOffset + numBytes, dp = 0;
+    int size = 0, left, i, n;
+    byte theByte;
+    while (sp < end) {
+        /* find two consecutive bytes that are the same in the next 128 */
+        left = end - sp - 1;
+        if (left > 127)
+            left = 127;
+        for (n = 0; n < left; n++) {
+            if (src[sp + n] is src[sp + n + 1])
+                break;
+        }
+        /* if there is only one more byte in the scan line, include it */
+        if (n < 127 && n is left)
+            n++;
+        /* store the intervening data */
+        switch (n) {
+            case 0:
+                break;
+            case 1: /* handled separately because 0,2 is a command */
+                dest[dp] = 2; dp++; /* 1 byte is 2 pixels */
+                dest[dp] = src[sp];
+                dp++; sp++;
+                size += 2;
+                break;
+            default:
+                dest[dp] = 0; dp++;
+                dest[dp] = (byte)(n + n); dp++; /* n bytes = n*2 pixels */
+                for (i = n; i > 0; i--) {
+                    dest[dp] = src[sp];
+                    dp++; sp++;
+                }
+                size += 2 + n;
+                if ((n & 1) !is 0) { /* pad to word */
+                    dest[dp] = 0;
+                    dp++;
+                    size++;
+                }
+                break;
+        }
+        /* find the length of the next run (up to 127) and store it */
+        left = end - sp;
+        if (left > 0) {
+            if (left > 127)
+                left = 127;
+            theByte = src[sp];
+            for (n = 1; n < left; n++) {
+                if (src[sp + n] !is theByte)
+                    break;
+            }
+            dest[dp] = (byte)(n + n); dp++; /* n bytes = n*2 pixels */
+            dest[dp] = theByte; dp++;
+            sp += n;
+            size += 2;
+        }
+    }
+
+    /* store the end of line or end of bitmap codes */
+    dest[dp] = 0; dp++;
+    if (last) {
+        dest[dp] = 1; dp++;
+    } else {
+        dest[dp] = 0; dp++;
+    }
+    size += 2;
+    
+    return size;
+}
+int compressRLE8Data(byte[] src, int srcOffset, int numBytes, byte[] dest, bool last) {
+    int sp = srcOffset, end = srcOffset + numBytes, dp = 0;
+    int size = 0, left, i, n;
+    byte theByte;
+    while (sp < end) {
+        /* find two consecutive bytes that are the same in the next 256 */
+        left = end - sp - 1;
+        if (left > 254)
+            left = 254;
+        for (n = 0; n < left; n++) {
+            if (src[sp + n] is src[sp + n + 1])
+                break;
+        }
+        /* if there is only one more byte in the scan line, include it */
+        if (n is left)
+            n++;
+        /* store the intervening data */
+        switch (n) {
+            case 0:
+                break;
+            case 2: /* handled separately because 0,2 is a command */
+                dest[dp] = 1; dp++;
+                dest[dp] = src[sp];
+                dp++; sp++;
+                size += 2;
+                /* don't break, fall through */
+            case 1: /* handled separately because 0,1 is a command */
+                dest[dp] = 1; dp++;
+                dest[dp] = src[sp];
+                dp++; sp++;
+                size += 2;
+                break;
+            default:
+                dest[dp] = 0; dp++;
+                dest[dp] = (byte)n; dp++;
+                for (i = n; i > 0; i--) {
+                    dest[dp] = src[sp];
+                    dp++; sp++;
+                }
+                size += 2 + n;
+                if ((n & 1) !is 0) { /* pad to word */
+                    dest[dp] = 0;
+                    dp++;
+                    size++;
+                }
+                break;
+        }
+        /* find the length of the next run (up to 255) and store it */
+        left = end - sp;
+        if (left > 0) {
+            if (left > 255)
+                left = 255;
+            theByte = src[sp];
+            for (n = 1; n < left; n++) {
+                if (src[sp + n] !is theByte)
+                    break;
+            }
+            dest[dp] = (byte)n; dp++;
+            dest[dp] = theByte; dp++;
+            sp += n;
+            size += 2;
+        }
+    }
+
+    /* store the end of line or end of bitmap codes */
+    dest[dp] = 0; dp++;
+    if (last) {
+        dest[dp] = 1; dp++;
+    } else {
+        dest[dp] = 0; dp++;
+    }
+    size += 2;
+    
+    return size;
+}
+void decompressData(byte[] src, byte[] dest, int stride, int cmp) {
+    if (cmp is 1) { // BMP_RLE8_COMPRESSION
+        if (decompressRLE8Data(src, src.length, stride, dest, dest.length) <= 0)
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        return;
+    }
+    if (cmp is 2) { // BMP_RLE4_COMPRESSION
+        if (decompressRLE4Data(src, src.length, stride, dest, dest.length) <= 0)
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        return;
+    }
+    DWT.error(DWT.ERROR_INVALID_IMAGE);
+}
+int decompressRLE4Data(byte[] src, int numBytes, int stride, byte[] dest, int destSize) {
+    int sp = 0;
+    int se = numBytes;
+    int dp = 0;
+    int de = destSize;
+    int x = 0, y = 0;
+    while (sp < se) {
+        int len = src[sp] & 0xFF;
+        sp++;
+        if (len is 0) {
+            len = src[sp] & 0xFF;
+            sp++;
+            switch (len) {
+                case 0: /* end of line */
+                    y++;
+                    x = 0;
+                    dp = y * stride;
+                    if (dp > de)
+                        return -1;
+                    break;
+                case 1: /* end of bitmap */
+                    return 1;
+                case 2: /* delta */
+                    x += src[sp] & 0xFF;
+                    sp++;
+                    y += src[sp] & 0xFF;
+                    sp++;
+                    dp = y * stride + x / 2;
+                    if (dp > de)
+                        return -1;
+                    break;
+                default: /* absolute mode run */
+                    if ((len & 1) !is 0) /* odd run lengths not currently supported */
+                        return -1;
+                    x += len;
+                    len = len / 2;
+                    if (len > (se - sp))
+                        return -1;
+                    if (len > (de - dp))
+                        return -1;
+                    for (int i = 0; i < len; i++) {
+                        dest[dp] = src[sp];
+                        dp++;
+                        sp++;
+                    }
+                    if ((sp & 1) !is 0)
+                        sp++; /* word align sp? */
+                    break;
+            }
+        } else {
+            if ((len & 1) !is 0)
+                return -1;
+            x += len;
+            len = len / 2;
+            byte theByte = src[sp];
+            sp++;
+            if (len > (de - dp))
+                return -1;
+            for (int i = 0; i < len; i++) {
+                dest[dp] = theByte;
+                dp++;
+            }
+        }
+    }
+    return 1;
+}
+int decompressRLE8Data(byte[] src, int numBytes, int stride, byte[] dest, int destSize) {
+    int sp = 0;
+    int se = numBytes;
+    int dp = 0;
+    int de = destSize;
+    int x = 0, y = 0;
+    while (sp < se) {
+        int len = src[sp] & 0xFF;
+        sp++;
+        if (len is 0) {
+            len = src[sp] & 0xFF;
+            sp++;
+            switch (len) {
+                case 0: /* end of line */
+                    y++;
+                    x = 0;
+                    dp = y * stride;
+                    if (dp > de)
+                        return -1;
+                    break;
+                case 1: /* end of bitmap */
+                    return 1;
+                case 2: /* delta */
+                    x += src[sp] & 0xFF;
+                    sp++;
+                    y += src[sp] & 0xFF;
+                    sp++;
+                    dp = y * stride + x;
+                    if (dp > de)
+                        return -1;
+                    break;
+                default: /* absolute mode run */
+                    if (len > (se - sp))
+                        return -1;
+                    if (len > (de - dp))
+                        return -1;
+                    for (int i = 0; i < len; i++) {
+                        dest[dp] = src[sp];
+                        dp++;
+                        sp++;
+                    }
+                    if ((sp & 1) !is 0)
+                        sp++; /* word align sp? */
+                    x += len;
+                    break;
+            }
+        } else {
+            byte theByte = src[sp];
+            sp++;
+            if (len > (de - dp))
+                return -1;
+            for (int i = 0; i < len; i++) {
+                dest[dp] = theByte;
+                dp++;
+            }
+            x += len;
+        }
+    }
+    return 1;
+}
+bool isFileFormat(LEDataInputStream stream) {
+    try {
+        byte[] header = new byte[18];
+        stream.read(header);
+        stream.unread(header);
+        int infoHeaderSize = (header[14] & 0xFF) | ((header[15] & 0xFF) << 8) | ((header[16] & 0xFF) << 16) | ((header[17] & 0xFF) << 24);
+        return header[0] is 0x42 && header[1] is 0x4D && infoHeaderSize >= BMPHeaderFixedSize;
+    } catch (Exception e) {
+        return false;
+    }
+}
+byte[] loadData(byte[] infoHeader) {
+    int width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+    int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+    int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+    int stride = (width * bitCount + 7) / 8;
+    stride = (stride + 3) / 4 * 4; // Round up to 4 byte multiple
+    byte[] data = loadData(infoHeader, stride);
+    flipScanLines(data, stride, height);
+    return data;
+}
+byte[] loadData(byte[] infoHeader, int stride) {
+    int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+    if (height < 0) height = -height;
+    int dataSize = height * stride;
+    byte[] data = new byte[dataSize];
+    int cmp = (infoHeader[16] & 0xFF) | ((infoHeader[17] & 0xFF) << 8) | ((infoHeader[18] & 0xFF) << 16) | ((infoHeader[19] & 0xFF) << 24);
+    if (cmp is 0 || cmp is 3) { // BMP_NO_COMPRESSION
+        try {
+            if (inputStream.read(data) !is dataSize)
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    } else {
+        int compressedSize = (infoHeader[20] & 0xFF) | ((infoHeader[21] & 0xFF) << 8) | ((infoHeader[22] & 0xFF) << 16) | ((infoHeader[23] & 0xFF) << 24);
+        byte[] compressed = new byte[compressedSize];
+        try {
+            if (inputStream.read(compressed) !is compressedSize)
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        decompressData(compressed, data, stride, cmp);
+    }
+    return data;
+}
+int[] loadFileHeader() {
+    int[] header = new int[5];
+    try {
+        header[0] = inputStream.readShort();
+        header[1] = inputStream.readInt();
+        header[2] = inputStream.readShort();
+        header[3] = inputStream.readShort();
+        header[4] = inputStream.readInt();
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    if (header[0] !is 0x4D42)
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    return header;
+}
+ImageData[] loadFromByteStream() {
+    int[] fileHeader = loadFileHeader();
+    byte[] infoHeader = new byte[BMPHeaderFixedSize];
+    try {
+        inputStream.read(infoHeader);
+    } catch (Exception e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    int width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+    int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+    if (height < 0) height = -height;
+    int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+    this.compression = (infoHeader[16] & 0xFF) | ((infoHeader[17] & 0xFF) << 8) | ((infoHeader[18] & 0xFF) << 16) | ((infoHeader[19] & 0xFF) << 24);
+    PaletteData palette = loadPalette(infoHeader);
+    if (inputStream.getPosition() < fileHeader[4]) {
+        // Seek to the specified offset
+        try {
+            inputStream.skip(fileHeader[4] - inputStream.getPosition());
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+    byte[] data = loadData(infoHeader);
+    this.importantColors = (infoHeader[36] & 0xFF) | ((infoHeader[37] & 0xFF) << 8) | ((infoHeader[38] & 0xFF) << 16) | ((infoHeader[39] & 0xFF) << 24);
+    int xPelsPerMeter = (infoHeader[24] & 0xFF) | ((infoHeader[25] & 0xFF) << 8) | ((infoHeader[26] & 0xFF) << 16) | ((infoHeader[27] & 0xFF) << 24);
+    int yPelsPerMeter = (infoHeader[28] & 0xFF) | ((infoHeader[29] & 0xFF) << 8) | ((infoHeader[30] & 0xFF) << 16) | ((infoHeader[31] & 0xFF) << 24);
+    this.pelsPerMeter = new Point(xPelsPerMeter, yPelsPerMeter);
+    int type = (this.compression is 1 /*BMP_RLE8_COMPRESSION*/) || (this.compression is 2 /*BMP_RLE4_COMPRESSION*/) ? DWT.IMAGE_BMP_RLE : DWT.IMAGE_BMP;
+    return new ImageData[] {
+        ImageData.internal_new(
+            width,
+            height,
+            bitCount,
+            palette,
+            4,
+            data,
+            0,
+            null,
+            null,
+            -1,
+            -1,
+            type,
+            0,
+            0,
+            0,
+            0)
+    };
+}
+PaletteData loadPalette(byte[] infoHeader) {
+    int depth = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+    if (depth <= 8) {
+        int numColors = (infoHeader[32] & 0xFF) | ((infoHeader[33] & 0xFF) << 8) | ((infoHeader[34] & 0xFF) << 16) | ((infoHeader[35] & 0xFF) << 24);
+        if (numColors is 0) {
+            numColors = 1 << depth;
+        } else {
+            if (numColors > 256)
+                numColors = 256;
+        }
+        byte[] buf = new byte[numColors * 4];
+        try {
+            if (inputStream.read(buf) !is buf.length)
+                DWT.error(DWT.ERROR_INVALID_IMAGE);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+        return paletteFromBytes(buf, numColors);
+    }
+    if (depth is 16) {
+        if (this.compression is 3) {
+            try {
+                return new PaletteData(inputStream.readInt(), inputStream.readInt(), inputStream.readInt());
+            } catch (IOException e) {
+                DWT.error(DWT.ERROR_IO, e);
+            }
+        }
+        return new PaletteData(0x7C00, 0x3E0, 0x1F);
+    }
+    if (depth is 24) return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+    if (this.compression is 3) {
+        try {
+            return new PaletteData(inputStream.readInt(), inputStream.readInt(), inputStream.readInt());
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+    return new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+}
+PaletteData paletteFromBytes(byte[] bytes, int numColors) {
+    int bytesOffset = 0;
+    RGB[] colors = new RGB[numColors];
+    for (int i = 0; i < numColors; i++) {
+        colors[i] = new RGB(bytes[bytesOffset + 2] & 0xFF,
+            bytes[bytesOffset + 1] & 0xFF,
+            bytes[bytesOffset] & 0xFF);
+        bytesOffset += 4;
+    }
+    return new PaletteData(colors);
+}
+/**
+ * Answer a byte array containing the BMP representation of
+ * the given device independent palette.
+ */
+static byte[] paletteToBytes(PaletteData pal) {
+    int n = pal.colors is null ? 0 : (pal.colors.length < 256 ? pal.colors.length : 256);
+    byte[] bytes = new byte[n * 4];
+    int offset = 0;
+    for (int i = 0; i < n; i++) {
+        RGB col = pal.colors[i];
+        bytes[offset] = (byte)col.blue;
+        bytes[offset + 1] = (byte)col.green;
+        bytes[offset + 2] = (byte)col.red;
+        offset += 4;
+    }
+    return bytes;
+}
+/**
+ * Unload the given image's data into the given byte stream
+ * using the given compression strategy. 
+ * Answer the number of bytes written.
+ */
+int unloadData(ImageData image, OutputStream out, int comp) {
+    int totalSize = 0;
+    try {
+        if (comp is 0)
+            return unloadDataNoCompression(image, out);
+        int bpl = (image.width * image.depth + 7) / 8;
+        int bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
+        int imageBpl = image.bytesPerLine;
+        // Compression can actually take twice as much space, in worst case
+        byte[] buf = new byte[bmpBpl * 2];
+        int srcOffset = imageBpl * (image.height - 1); // Start at last line
+        byte[] data = image.data;
+        totalSize = 0;
+        byte[] buf2 = new byte[32768];
+        int buf2Offset = 0;
+        for (int y = image.height - 1; y >= 0; y--) {
+            int lineSize = compress(comp, data, srcOffset, bpl, buf, y is 0);
+            if (buf2Offset + lineSize > buf2.length) {
+                out.write(buf2, 0, buf2Offset);
+                buf2Offset = 0;
+            }
+            System.arraycopy(buf, 0, buf2, buf2Offset, lineSize);
+            buf2Offset += lineSize;
+            totalSize += lineSize;
+            srcOffset -= imageBpl;
+        }
+        if (buf2Offset > 0)
+            out.write(buf2, 0, buf2Offset);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return totalSize;
+}
+/**
+ * Prepare the given image's data for unloading into a byte stream
+ * using no compression strategy.
+ * Answer the number of bytes written.
+ */
+int unloadDataNoCompression(ImageData image, OutputStream out) {
+    int bmpBpl = 0;
+    try {
+        int bpl = (image.width * image.depth + 7) / 8;
+        bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
+        int linesPerBuf = 32678 / bmpBpl;
+        byte[] buf = new byte[linesPerBuf * bmpBpl];
+        byte[] data = image.data;
+        int imageBpl = image.bytesPerLine;
+        int dataIndex = imageBpl * (image.height - 1); // Start at last line
+        if (image.depth is 16) {
+            for (int y = 0; y < image.height; y += linesPerBuf) {
+                int count = image.height - y;
+                if (linesPerBuf < count) count = linesPerBuf;
+                int bufOffset = 0;
+                for (int i = 0; i < count; i++) {
+                    for (int wIndex = 0; wIndex < bpl; wIndex += 2) {
+                        buf[bufOffset + wIndex + 1] = data[dataIndex + wIndex + 1];
+                        buf[bufOffset + wIndex] = data[dataIndex + wIndex];
+                    }
+                    bufOffset += bmpBpl;
+                    dataIndex -= imageBpl;
+                }
+                out.write(buf, 0, bufOffset);
+            }
+        } else {
+            for (int y = 0; y < image.height; y += linesPerBuf) {
+                int tmp = image.height - y;
+                int count = tmp < linesPerBuf ? tmp : linesPerBuf;
+                int bufOffset = 0;
+                for (int i = 0; i < count; i++) {
+                    System.arraycopy(data, dataIndex, buf, bufOffset, bpl);
+                    bufOffset += bmpBpl;
+                    dataIndex -= imageBpl;
+                }
+                out.write(buf, 0, bufOffset);
+            }
+        }
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return bmpBpl * image.height;
+}
+/**
+ * Unload a DeviceIndependentImage using Windows .BMP format into the given
+ * byte stream.
+ */
+void unloadIntoByteStream(ImageLoader loader) {
+    ImageData image = loader.data[0];
+    byte[] rgbs;
+    int numCols;
+    if (!((image.depth is 1) || (image.depth is 4) || (image.depth is 8) ||
+          (image.depth is 16) || (image.depth is 24) || (image.depth is 32)))
+            DWT.error(DWT.ERROR_UNSUPPORTED_DEPTH);
+    int comp = this.compression;
+    if (!((comp is 0) || ((comp is 1) && (image.depth is 8)) ||
+          ((comp is 2) && (image.depth is 4))))
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+    PaletteData pal = image.palette;
+    if ((image.depth is 16) || (image.depth is 24) || (image.depth is 32)) {
+        if (!pal.isDirect)
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        numCols = 0;
+        rgbs = null;
+    } else {
+        if (pal.isDirect)
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+        numCols = pal.colors.length;
+        rgbs = paletteToBytes(pal);
+    }
+    // Fill in file header, except for bfsize, which is done later.
+    int headersSize = BMPFileHeaderSize + BMPHeaderFixedSize;
+    int[] fileHeader = new int[5];
+    fileHeader[0] = 0x4D42; // Signature
+    fileHeader[1] = 0; // File size - filled in later
+    fileHeader[2] = 0; // Reserved 1
+    fileHeader[3] = 0; // Reserved 2
+    fileHeader[4] = headersSize; // Offset to data
+    if (rgbs !is null) {
+        fileHeader[4] += rgbs.length;
+    }
+
+    // Prepare data. This is done first so we don't have to try to rewind
+    // the stream and fill in the details later.
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    unloadData(image, out, comp);
+    byte[] data = out.toByteArray();
+    
+    // Calculate file size
+    fileHeader[1] = fileHeader[4] + data.length;
+
+    // Write the headers
+    try {
+        outputStream.writeShort(fileHeader[0]);
+        outputStream.writeInt(fileHeader[1]);
+        outputStream.writeShort(fileHeader[2]);
+        outputStream.writeShort(fileHeader[3]);
+        outputStream.writeInt(fileHeader[4]);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    try {
+        outputStream.writeInt(BMPHeaderFixedSize);
+        outputStream.writeInt(image.width);
+        outputStream.writeInt(image.height);
+        outputStream.writeShort(1);
+        outputStream.writeShort((short)image.depth);
+        outputStream.writeInt(comp);
+        outputStream.writeInt(data.length);
+        outputStream.writeInt(pelsPerMeter.x);
+        outputStream.writeInt(pelsPerMeter.y);
+        outputStream.writeInt(numCols);
+        outputStream.writeInt(importantColors);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    
+    // Unload palette
+    if (numCols > 0) {
+        try {
+            outputStream.write(rgbs);
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+        }
+    }
+
+    // Unload the data
+    try {
+        outputStream.write(data);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+void flipScanLines(byte[] data, int stride, int height) {
+    int i1 = 0;
+    int i2 = (height - 1) * stride;
+    for (int i = 0; i < height / 2; i++) {
+        for (int index = 0; index < stride; index++) {
+            byte b = data[index + i1];
+            data[index + i1] = data[index + i2];
+            data[index + i2] = b;
+        }
+        i1 += stride;
+        i2 -= stride;
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/image/WinICOFileFormat.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,328 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.image;
+
+
+import java.io.IOException;
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.graphics.ImageLoader;
+import dwt.graphics.PaletteData;
+
+public final class WinICOFileFormat : FileFormat {
+    
+byte[] bitInvertData(byte[] data, int startIndex, int endIndex) {
+    // Destructively bit invert data in the given byte array.
+    for (int i = startIndex; i < endIndex; i++) {
+        data[i] = (byte)(255 - data[i - startIndex]);
+    }
+    return data;
+}
+
+static final byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) {
+    if (pad is newPad) return data;
+    int stride = (width * depth + 7) / 8;
+    int bpl = (stride + (pad - 1)) / pad * pad;
+    int newBpl = (stride + (newPad - 1)) / newPad * newPad;
+    byte[] newData = new byte[height * newBpl];
+    int srcIndex = 0, destIndex = 0;
+    for (int y = 0; y < height; y++) {
+        System.arraycopy(data, srcIndex, newData, destIndex, newBpl);
+        srcIndex += bpl;
+        destIndex += newBpl;
+    }
+    return newData;
+}
+/**
+ * Answer the size in bytes of the file representation of the given
+ * icon
+ */
+int iconSize(ImageData i) {
+    int shapeDataStride = (i.width * i.depth + 31) / 32 * 4;
+    int maskDataStride = (i.width + 31) / 32 * 4;
+    int dataSize = (shapeDataStride + maskDataStride) * i.height;
+    int paletteSize = i.palette.colors !is null ? i.palette.colors.length * 4 : 0;
+    return WinBMPFileFormat.BMPHeaderFixedSize + paletteSize + dataSize;
+}
+bool isFileFormat(LEDataInputStream stream) {
+    try {
+        byte[] header = new byte[4];
+        stream.read(header);
+        stream.unread(header);
+        return header[0] is 0 && header[1] is 0 && header[2] is 1 && header[3] is 0;
+    } catch (Exception e) {
+        return false;
+    }
+}
+bool isValidIcon(ImageData i) {
+    switch (i.depth) {
+        case 1:
+        case 4:
+        case 8:
+            if (i.palette.isDirect) return false;
+            int size = i.palette.colors.length;
+            return size is 2 || size is 16 || size is 32 || size is 256;
+        case 24:
+        case 32:
+            return i.palette.isDirect;
+    }
+    return false;
+}
+int loadFileHeader(LEDataInputStream byteStream) {
+    int[] fileHeader = new int[3];
+    try {
+        fileHeader[0] = byteStream.readShort();
+        fileHeader[1] = byteStream.readShort();
+        fileHeader[2] = byteStream.readShort();
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    if ((fileHeader[0] !is 0) || (fileHeader[1] !is 1))
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    int numIcons = fileHeader[2];
+    if (numIcons <= 0)
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    return numIcons;
+}
+int loadFileHeader(LEDataInputStream byteStream, bool hasHeader) {
+    int[] fileHeader = new int[3];
+    try {
+        if (hasHeader) {
+            fileHeader[0] = byteStream.readShort();
+            fileHeader[1] = byteStream.readShort();
+        } else {
+            fileHeader[0] = 0;
+            fileHeader[1] = 1;
+        }
+        fileHeader[2] = byteStream.readShort();
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    if ((fileHeader[0] !is 0) || (fileHeader[1] !is 1))
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    int numIcons = fileHeader[2];
+    if (numIcons <= 0)
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    return numIcons;
+}
+ImageData[] loadFromByteStream() {
+    int numIcons = loadFileHeader(inputStream);
+    int[][] headers = loadIconHeaders(numIcons);
+    ImageData[] icons = new ImageData[headers.length];
+    for (int i = 0; i < icons.length; i++) {
+        icons[i] = loadIcon(headers[i]);
+    }
+    return icons;
+}
+/**
+ * Load one icon from the byte stream.
+ */
+ImageData loadIcon(int[] iconHeader) {
+    byte[] infoHeader = loadInfoHeader(iconHeader);
+    WinBMPFileFormat bmpFormat = new WinBMPFileFormat();
+    bmpFormat.inputStream = inputStream;
+    PaletteData palette = bmpFormat.loadPalette(infoHeader);
+    byte[] shapeData = bmpFormat.loadData(infoHeader);
+    int width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+    int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+    if (height < 0) height = -height;
+    int depth = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+    infoHeader[14] = 1;
+    infoHeader[15] = 0;
+    byte[] maskData = bmpFormat.loadData(infoHeader);
+    maskData = convertPad(maskData, width, height, 1, 4, 2);
+    bitInvertData(maskData, 0, maskData.length);
+    return ImageData.internal_new(
+        width,
+        height,
+        depth,
+        palette,
+        4,
+        shapeData,
+        2,
+        maskData,
+        null,
+        -1,
+        -1,
+        DWT.IMAGE_ICO,
+        0,
+        0,
+        0,
+        0);
+}
+int[][] loadIconHeaders(int numIcons) {
+    int[][] headers = new int[numIcons][7];
+    try {
+        for (int i = 0; i < numIcons; i++) {
+            headers[i][0] = inputStream.read();
+            headers[i][1] = inputStream.read();
+            headers[i][2] = inputStream.readShort();
+            headers[i][3] = inputStream.readShort();
+            headers[i][4] = inputStream.readShort();
+            headers[i][5] = inputStream.readInt();
+            headers[i][6] = inputStream.readInt();
+        }
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    return headers;
+}
+byte[] loadInfoHeader(int[] iconHeader) {
+    int width = iconHeader[0];
+    int height = iconHeader[1];
+    int numColors = iconHeader[2]; // the number of colors is in the low byte, but the high byte must be 0
+    if (numColors is 0) numColors = 256; // this is specified: '00' represents '256' (0x100) colors
+    if ((numColors !is 2) && (numColors !is 8) && (numColors !is 16) &&
+        (numColors !is 32) && (numColors !is 256))
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    if (inputStream.getPosition() < iconHeader[6]) {
+        // Seek to the specified offset
+        try {
+            inputStream.skip(iconHeader[6] - inputStream.getPosition());
+        } catch (IOException e) {
+            DWT.error(DWT.ERROR_IO, e);
+            return null;
+        }
+    }
+    byte[] infoHeader = new byte[WinBMPFileFormat.BMPHeaderFixedSize];
+    try {
+        inputStream.read(infoHeader);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    if (((infoHeader[12] & 0xFF) | ((infoHeader[13] & 0xFF) << 8)) !is 1)
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    int infoWidth = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+    int infoHeight = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+    int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+    if (height is infoHeight && bitCount is 1) height /= 2;
+    if (!((width is infoWidth) && (height * 2 is infoHeight) &&
+        (bitCount is 1 || bitCount is 4 || bitCount is 8 || bitCount is 24 || bitCount is 32)))
+            DWT.error(DWT.ERROR_INVALID_IMAGE);
+    infoHeader[8] = (byte)(height & 0xFF);
+    infoHeader[9] = (byte)((height >> 8) & 0xFF);
+    infoHeader[10] = (byte)((height >> 16) & 0xFF);
+    infoHeader[11] = (byte)((height >> 24) & 0xFF);
+    return infoHeader;
+}
+/**
+ * Unload a single icon
+ */
+void unloadIcon(ImageData icon) {
+    int sizeImage = (((icon.width * icon.depth + 31) / 32 * 4) +
+        ((icon.width + 31) / 32 * 4)) * icon.height;
+    try {
+        outputStream.writeInt(WinBMPFileFormat.BMPHeaderFixedSize);
+        outputStream.writeInt(icon.width);
+        outputStream.writeInt(icon.height * 2);
+        outputStream.writeShort(1);
+        outputStream.writeShort((short)icon.depth);
+        outputStream.writeInt(0);
+        outputStream.writeInt(sizeImage);
+        outputStream.writeInt(0);
+        outputStream.writeInt(0);
+        outputStream.writeInt(icon.palette.colors !is null ? icon.palette.colors.length : 0);
+        outputStream.writeInt(0);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    
+    byte[] rgbs = WinBMPFileFormat.paletteToBytes(icon.palette);
+    try {
+        outputStream.write(rgbs);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    unloadShapeData(icon);
+    unloadMaskData(icon);
+}
+/**
+ * Unload the icon header for the given icon, calculating the offset.
+ */
+void unloadIconHeader(ImageData i) {
+    int headerSize = 16;
+    int offset = headerSize + 6;
+    int iconSize = iconSize(i);
+    try {
+        outputStream.write(i.width);
+        outputStream.write(i.height);
+        outputStream.writeShort(i.palette.colors !is null ? i.palette.colors.length : 0);
+        outputStream.writeShort(0);
+        outputStream.writeShort(0);
+        outputStream.writeInt(iconSize);
+        outputStream.writeInt(offset);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+void unloadIntoByteStream(ImageLoader loader) {
+    /* We do not currently support writing multi-image ico,
+     * so we use the first image data in the loader's array. */
+    ImageData image = loader.data[0];
+    if (!isValidIcon(image))
+        DWT.error(DWT.ERROR_INVALID_IMAGE);
+    try {
+        outputStream.writeShort(0);
+        outputStream.writeShort(1);
+        outputStream.writeShort(1);
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+    unloadIconHeader(image);
+    unloadIcon(image);
+}
+/**
+ * Unload the mask data for an icon. The data is flipped vertically
+ * and inverted.
+ */
+void unloadMaskData(ImageData icon) {
+    ImageData mask = icon.getTransparencyMask();
+    int bpl = (icon.width + 7) / 8;
+    int pad = mask.scanlinePad;
+    int srcBpl = (bpl + pad - 1) / pad * pad;
+    int destBpl = (bpl + 3) / 4 * 4;
+    byte[] buf = new byte[destBpl];
+    int offset = (icon.height - 1) * srcBpl;
+    byte[] data = mask.data;
+    try {
+        for (int i = 0; i < icon.height; i++) {
+            System.arraycopy(data, offset, buf, 0, bpl);
+            bitInvertData(buf, 0, bpl);
+            outputStream.write(buf, 0, destBpl);
+            offset -= srcBpl;
+        }
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+/**
+ * Unload the shape data for an icon. The data is flipped vertically.
+ */
+void unloadShapeData(ImageData icon) {
+    int bpl = (icon.width * icon.depth + 7) / 8;
+    int pad = icon.scanlinePad;
+    int srcBpl = (bpl + pad - 1) / pad * pad;
+    int destBpl = (bpl + 3) / 4 * 4;
+    byte[] buf = new byte[destBpl];
+    int offset = (icon.height - 1) * srcBpl;
+    byte[] data = icon.data;
+    try {
+        for (int i = 0; i < icon.height; i++) {
+            System.arraycopy(data, offset, buf, 0, bpl);
+            outputStream.write(buf, 0, destBpl);
+            offset -= srcBpl;
+        }
+    } catch (IOException e) {
+        DWT.error(DWT.ERROR_IO, e);
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/appkit/AppKit.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,15 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.appkit.AppKit;
+
+public:
+    
+import dwt.internal.objc.appkit.NSAccessibility;
+import dwt.internal.objc.appkit.NSAttributedString;
+import dwt.internal.objc.appkit.NSGraphics;
+import dwt.internal.objc.appkit.NSScreen;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/appkit/NSAccessibility.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,18 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.appkit.NSAccessibility;
+
+import bindings = dwt.internal.objc.appkit.bindings;
+
+template NSAccessibility ()
+{
+    extern(C):
+        
+    id* NSAccessibilityPositionAttribute;
+    id* NSAccessibilitySizeAttribute;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/appkit/NSAttributedString.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,26 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.appkit.NSAttributedString;
+
+import bindings = dwt.internal.objc.appkit.bindings;
+
+template NSAttributedString ()
+{
+    extern (C):
+        
+    id* NSBackgroundColorAttributeName;
+    id* NSBaselineOffsetAttributeName;
+    id* NSFontAttributeName;
+    id* NSForegroundColorAttributeName;
+    id* NSLinkAttributeName;
+    id* NSParagraphStyleAttributeName;
+    id* NSStrikethroughColorAttributeName;
+    id* NSStrikethroughStyleAttributeName;
+    id* NSUnderlineColorAttributeName;
+    id* NSUnderlineStyleAttributeName;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/appkit/NSGraphics.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,17 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.appkit.NSGraphics;
+
+import bindings = dwt.internal.objc.appkit.bindings : NSBitsPerPixelFromDepth;
+import dwt.internal.objc.runtime;
+
+template NSGraphics ()
+{
+    extern(C) id* NSDeviceRGBColorSpace;
+    alias bindings.NSBitsPerPixelFromDepth NSBitsPerPixelFromDepth;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/appkit/NSScreen.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,15 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.appkit.NSScreen;
+
+import dwt.internal.objc.runtime;
+
+template NSScreen ()
+{
+    extern(C) id* NSDeviceResolution;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/appkit/bindings.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,29 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.appkit.bindings;
+
+extern (C):
+    
+/*void *NSDeviceRGBColorSpace();
+void *NSAccessibilityPositionAttribute ();
+void *NSAccessibilitySizeAttribute ();
+void *NSBackgroundColorAttributeName ();
+void *NSBaselineOffsetAttributeName ();
+void *NSDeviceResolution ();
+void *NSFontAttributeName ();
+void *NSForegroundColorAttributeName ();
+void *NSLinkAttributeName ();
+void *NSParagraphStyleAttributeName ();
+void *NSStrikethroughColorAttributeName ();
+void *NSStrikethroughStyleAttributeName ();
+void *NSUnderlineColorAttributeName ();
+void *NSUnderlineStyleAttributeName ();*/
+int NSBitsPerPixelFromDepth (int depth);
+
+version (build)
+    pragma(link, "objc");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/bindings.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,33 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.bindings;
+
+import dwt.internal.c.qd.QuickdrawTypes : BOOL;
+import dwt.internal.objc.runtime;
+
+extern (C):
+
+BOOL class_addIvar (Class cls, /*const*/char* name, size_t size, byte alignment, /*const*/char* types);
+BOOL class_addMethod (Class cls, SEL name, IMP imp, /*const*/char* types);
+Class objc_allocateClassPair (Class superclass, /*const*/char* name, size_t extraBytes);
+id objc_getClass (/*const*/char* name);
+id objc_lookUpClass (/*const*/char* name);
+void objc_registerClassPair (Class cls);
+/*const*/char* object_getClassName (id obj);
+Ivar object_getInstanceVariable (id obj, /*const*/char* name, void** outValue);
+Ivar object_setInstanceVariable (id obj, /*const*/char* name, void* value);
+SEL sel_registerName (/*const*/char* str);
+id objc_msgSend (id theReceiver, SEL theSelector, ...);
+void objc_msgSend_stret(void* stretAddr, id theReceiver, SEL theSelector, ...);
+id objc_msgSendSuper (objc_super* superr, SEL op, ...);
+
+version (X86)
+    double objc_msgSend_fpret(id self, SEL op, ...);
+
+version (build)
+    pragma(link, "objc");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/cocoa/Cocoa.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,13 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.cocoa.Cocoa;
+
+public:
+
+import dwt.internal.objc.foundation.Foundation;
+import dwt.internal.objc.appkit.AppKit;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/foundation/Foundation.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,13 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.foundation.Foundation;
+
+public:
+    
+import dwt.internal.objc.foundation.NSHFSFileTypes;
+import dwt.internal.objc.foundation.NSRunLoop;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/foundation/NSHFSFileTypes.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,15 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.foundation.NSHFSFileTypes;
+
+import bindings = dwt.internal.objc.foundation.bindings : NSFileTypeForHFSTypeCode;
+
+template NSHFSFileTypes ()
+{
+    alias bindings.NSFileTypeForHFSTypeCode NSFileTypeForHFSTypeCode;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/foundation/NSRunLoop.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,15 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.foundation.NSRunLoop;
+
+import dwt.internal.objc.runtime;
+
+template NSRunLoop ()
+{
+    extern(C) id* NSDefaultRunLoopMode;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/foundation/bindings.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,13 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.foundation.bindings;
+
+extern (C):
+    
+//void* NSDefaultRunLoopMode ();
+void* NSFileTypeForHFSTypeCode (int hfsFileTypeCode);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/objc/runtime.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,157 @@
+/**
+ * Copyright: Copyright (c) 2008 Jacob Carlborg. All rights reserved.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: 2008
+ * License: $(LINK2 http://opensource.org/licenses/bsd-license.php, BSD Style)
+ * 
+ */
+module dwt.internal.objc.runtime;
+
+import tango.stdc.stringz : fromStringz, toStringz;
+
+import dwt.dwthelper.utils : string;
+static import dwt.internal.objc.bindings;
+
+alias objc_ivar* Ivar;
+alias objc_method* Method;
+alias objc_object Protocol;
+
+alias char* SEL;
+alias objc_class* Class;
+alias objc_object* id;
+
+alias extern (C) id function(id, SEL, ...) IMP;
+
+struct objc_object
+{
+    Class isa;
+}
+
+struct objc_super
+{
+    id receiver;
+    Class clazz;
+}
+
+struct objc_class
+{
+    Class isa;
+    Class super_class;
+    const char* name;
+    int versionn;
+    int info;
+    int instance_size;
+    objc_ivar_list* ivars;
+    objc_method_list** methodLists;
+    objc_cache* cache;
+    objc_protocol_list* protocols;
+}
+
+struct objc_ivar
+{
+    char* ivar_name;
+    char* ivar_type;
+    int ivar_offset;
+
+    version (X86_64)
+        int space;
+}
+
+struct objc_ivar_list
+{
+    int ivar_count;
+
+    version (X86_64)
+        int space;
+
+    /* variable length structure */
+    objc_ivar ivar_list[1];
+}
+
+struct objc_method
+{
+    SEL method_name;
+    char* method_types;
+    IMP method_imp;
+}
+
+struct objc_method_list
+{
+    objc_method_list* obsolete;
+
+    int method_count;
+
+    version (X86_64)
+        int space;
+
+    /* variable length structure */
+    objc_method method_list[1];
+}
+
+struct objc_cache
+{
+    uint mask /* total = mask + 1 */;
+    uint occupied;
+    Method buckets[1];
+}
+
+struct objc_protocol_list
+{
+    objc_protocol_list* next;
+    long count;
+    Protocol* list[1];
+}
+
+template Runtime ()
+{   
+    alias dwt.internal.objc.bindings.objc_msgSendSuper objc_msgSendSuper;
+    alias dwt.internal.objc.bindings.objc_registerClassPair objc_registerClassPair;
+    alias dwt.internal.objc.bindings.objc_msgSend objc_msgSend;
+    alias dwt.internal.objc.bindings.objc_msgSend_fpret objc_msgSend_fpret;
+    alias dwt.internal.objc.bindings.objc_msgSend_stret objc_msgSend_stret;
+    
+    bool class_addIvar (Class cls, string name, size_t size, byte alignment, string types)
+    {
+        return dwt.internal.objc.bindings.class_addIvar(cls, name.toStringz(), size, alignment, types.toStringz());
+    }
+
+    bool class_addMethod (Class cls, SEL name, IMP imp, string types)
+    {
+        return dwt.internal.objc.bindings.class_addMethod(cls, name, imp, types.toStringz());
+    }
+
+    Class objc_allocateClassPair (Class superclass, string name, size_t extraBytes)
+    {
+        return dwt.internal.objc.bindings.objc_allocateClassPair(superclass, name.toStringz(), extraBytes);
+    }
+
+    id objc_getClass (string name)
+    {
+        return dwt.internal.objc.bindings.objc_getClass(name.toStringz());
+    }
+
+    id objc_lookUpClass (string name)
+    {
+        return dwt.internal.objc.bindings.objc_lookUpClass(name.toStringz());
+    }
+
+    string object_getClassName (id obj)
+    {
+        return fromStringz(dwt.internal.objc.bindings.object_getClassName(obj));
+    }
+
+    Ivar object_getInstanceVariable (id obj, string name, void** outValue)
+    {
+        return dwt.internal.objc.bindings.object_getInstanceVariable(obj, name.toStringz(), outValue);
+    }
+
+    Ivar object_setInstanceVariable (id obj, string name, void* value)
+    {
+        return dwt.internal.objc.bindings.object_setInstanceVariable(obj, name.toStringz(), value);
+    }
+
+    string sel_registerName (string str)
+    {
+        return fromStringz(dwt.internal.objc.bindings.sel_registerName(str.toStringz()));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ButtonDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ButtonDrawData : DrawData {
+    
+public ButtonDrawData() {
+    state = new int[1];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ComboDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ComboDrawData : DrawData {
+
+public ComboDrawData() {
+    state = new int[2];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/DrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+import dwt.graphics.*;
+
+public class DrawData {
+    public int style;
+    public int[] state;
+    public Rectangle clientArea;
+
+    /** Part states */
+    public static final int SELECTED = 1 << 1;
+    public static final int FOCUSED = 1 << 2;
+    public static final int PRESSED = 1 << 3;
+    public static final int ACTIVE = 1 << 4;
+    public static final int DISABLED = 1 << 5;
+    public static final int HOT = 1 << 6;
+    public static final int DEFAULTED = 1 << 7;
+    public static final int GRAYED = 1 << 8;
+    
+    /** Text and Image drawing flags */
+    public static final int DRAW_LEFT = 1 << 4;
+    public static final int DRAW_TOP = 1 << 5;
+    public static final int DRAW_RIGHT = 1 << 6;
+    public static final int DRAW_BOTTOM = 1 << 7;
+    public static final int DRAW_HCENTER = 1 << 8;
+    public static final int DRAW_VCENTER = 1 << 9;
+
+    /** Widget parts */
+    public static final int WIDGET_NOWHERE = -1;
+    public static final int WIDGET_WHOLE = 0;
+
+    /** Scrollbar parts */
+    public static final int SCROLLBAR_UP_ARROW = 1;
+    public static final int SCROLLBAR_DOWN_ARROW = 2;
+    public static final int SCROLLBAR_LEFT_ARROW = SCROLLBAR_UP_ARROW;
+    public static final int SCROLLBAR_RIGHT_ARROW = SCROLLBAR_DOWN_ARROW;
+    public static final int SCROLLBAR_UP_TRACK = 3;
+    public static final int SCROLLBAR_DOWN_TRACK = 4;
+    public static final int SCROLLBAR_LEFT_TRACK = SCROLLBAR_UP_TRACK;
+    public static final int SCROLLBAR_RIGHT_TRACK = SCROLLBAR_DOWN_TRACK;
+    public static final int SCROLLBAR_THUMB = 5;
+    
+    /** Scale parts */
+    public static final int SCALE_UP_TRACK = 1;
+    public static final int SCALE_LEFT_TRACK = SCALE_UP_TRACK;
+    public static final int SCALE_DOWN_TRACK = 2;
+    public static final int SCALE_RIGHT_TRACK = SCALE_DOWN_TRACK;
+    public static final int SCALE_THUMB = 3;
+    
+    /** ToolItem parts */
+    public static final int TOOLITEM_ARROW = 1;
+    
+    /** Combo parts */
+    public static final int COMBO_ARROW = 1;
+    
+
+public DrawData() {
+    state = new int[1];
+}
+
+Rectangle computeTrim(Theme theme, GC gc) {
+    return new Rectangle(clientArea.x, clientArea.y, clientArea.width, clientArea.height);
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {   
+}
+
+void drawImage(Theme theme, Image image, GC gc, Rectangle bounds) {
+}
+
+void drawText(Theme theme, String text, int flags, GC gc, Rectangle bounds) {
+}
+
+Rectangle getBounds(int part, Rectangle bounds) {
+    return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+    return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+Rectangle measureText(Theme theme, String text, int flags, GC gc, Rectangle bounds) {
+    return new Rectangle(0, 0, 0, 0);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ExpanderDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ExpanderDrawData : DrawData {
+    
+public ExpanderDrawData() {
+    state = new int[1];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/GroupDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+import dwt.graphics.*;
+
+public class GroupDrawData : DrawData {
+    public int headerWidth;
+    public int headerHeight;
+    public Rectangle headerArea;
+    
+public GroupDrawData() {
+    state = new int[1];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ProgressBarDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ProgressBarDrawData : RangeDrawData {
+
+public ProgressBarDrawData() {
+    state = new int[1];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/RangeDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+import dwt.graphics.*;
+
+public class RangeDrawData : DrawData {
+    public int selection;
+    public int minimum;
+    public int maximum;
+
+int getSelection(Point position, Rectangle bounds) {
+    return 0;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ScaleDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ScaleDrawData : RangeDrawData {
+    public int increment;
+    public int pageIncrement;
+    
+public ScaleDrawData() {
+    state = new int[4];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ScrollBarDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ScrollBarDrawData : RangeDrawData {
+    public int thumb;
+    public int increment;
+    public int pageIncrement;
+    
+public ScrollBarDrawData() {
+    state = new int[6];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/TabFolderDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+import dwt.*;
+import dwt.graphics.*;
+
+public class TabFolderDrawData : DrawData {
+    public int tabsWidth;
+    public int tabsHeight;
+    public Rectangle tabsArea;
+    public int selectedX;
+    public int selectedWidth;
+    public int spacing;
+    
+public TabFolderDrawData() {
+    state = new int[1];
+    if (DWT.getPlatform().opEquals("gtk")) {
+        spacing = -2;
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/TabItemDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+
+public class TabItemDrawData : DrawData {
+    
+    public TabFolderDrawData parent;
+    public int position;
+
+public TabItemDrawData() {
+    state = new int[1];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/Theme.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+import dwt.*;
+import dwt.graphics.*;
+
+public class Theme {
+    Device device;
+    
+public Theme(Device device) {
+    this.device = device;
+}
+
+void checkTheme() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+}
+
+public Rectangle computeTrim(GC gc, DrawData data) {
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    return data.computeTrim(this, gc);
+}
+
+public void dispose () {
+    device = null;
+}
+    
+public void drawBackground(GC gc, Rectangle bounds, DrawData data) {
+    checkTheme();
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    data.draw(this, gc, bounds);
+}
+
+public void drawFocus(GC gc, Rectangle bounds, DrawData data) {
+    checkTheme();
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    gc.drawFocus(bounds.x, bounds.y, bounds.width, bounds.height);
+}
+
+public void drawImage(GC gc, Rectangle bounds, DrawData data, Image image, int flags) {
+    checkTheme();
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    data.drawImage(this, image, gc, bounds);
+}
+
+public void drawText(GC gc, Rectangle bounds, DrawData data, String text, int flags) {
+    checkTheme();
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    data.drawText(this, text, flags, gc, bounds);
+}
+
+public Rectangle getBounds(int part, Rectangle bounds, DrawData data) {
+    checkTheme();
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return data.getBounds(part, bounds);
+}
+
+public int getSelection(Point offset, Rectangle bounds, RangeDrawData data) {
+    checkTheme();
+    if (offset is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return data.getSelection(offset, bounds);
+}
+
+public int hitBackground(Point position, Rectangle bounds, DrawData data) {
+    checkTheme();
+    if (position is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    return data.hit(this, position, bounds);
+}
+
+public bool isDisposed() {
+    return device is null;
+}
+
+public Rectangle measureText(GC gc, Rectangle bounds, DrawData data, String text, int flags) {
+    checkTheme();
+    if (gc is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (data is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (text is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    return data.measureText(this, text, flags, gc, bounds);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ToolBarDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ToolBarDrawData : DrawData {
+    
+public ToolBarDrawData() {
+    state = new int[1];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/theme/ToolItemDrawData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.internal.theme;
+
+public class ToolItemDrawData : DrawData {
+
+    public ToolBarDrawData parent;
+
+public ToolItemDrawData() {
+    state = new int[2];
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/FillData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -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
+ *******************************************************************************/
+module dwt.layout.FillData;
+
+import dwt.dwthelper.utils;
+
+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;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/FillLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.FillLayout;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Layout;
+import dwt.widgets.Scrollable;
+
+/**
+ * <code>FillLayout</code> is the simplest layout class. It lays out 
+ * controls in a single row or column, forcing them to be the same size. 
+ * <p>
+ * Initially, the controls will all be as tall as the tallest control, 
+ * and as wide as the widest. <code>FillLayout</code> 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 <code>Group</code>. <code>FillLayout</code> can also be used 
+ * when a <code>Composite</code> only has one child. For example, 
+ * if a <code>Shell</code> has a single <code>Group</code> child, 
+ * <code>FillLayout</code> will cause the <code>Group</code> to 
+ * completely fill the <code>Shell</code> (if margins are 0).
+ * </p>
+ * <p>
+ * Example code: first a <code>FillLayout</code> is created and
+ * its type field is set, and then the layout is set into the 
+ * <code>Composite</code>. Note that in a <code>FillLayout</code>,
+ * children are always the same size, and they fill all available space.
+ * <pre>
+ *      FillLayout fillLayout = new FillLayout();
+ *      fillLayout.type = DWT.VERTICAL;
+ *      shell.setLayout(fillLayout);
+ * </pre>
+ * </p>
+ */
+public final class FillLayout extends Layout {
+    /**
+     * type specifies how controls will be positioned 
+     * within the layout.
+     *
+     * The default value is HORIZONTAL.
+     *
+     * Possible values are: <ul>
+     *    <li>HORIZONTAL: Position the controls horizontally from left to right</li>
+     *    <li>VERTICAL: Position the controls vertically from top to bottom</li>
+     * </ul>
+     */
+    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 FillLayout () {
+}
+
+/**
+ * Constructs a new instance of this class given the type.
+ *
+ * @param type the type of fill layout
+ * 
+ * @since 2.0
+ */
+public FillLayout (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<count; i++) {
+        Control child = children [i];
+        int w = wHint, h = hHint;
+        if (count > 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 = (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 (control instanceof Scrollable) {
+            Rectangle rect = ((Scrollable) control).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) ((FillData)data).flushCache();
+    return true;
+}
+
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (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<count; i++) {
+            Control child = children [i];
+            int childWidth = cellWidth;
+            if (i is 0) {
+                childWidth += extra / 2;
+            } else {
+                if (i is count - 1) childWidth += (extra + 1) / 2;
+            }
+            child.setBounds (x, y, childWidth, height);
+            x += childWidth + spacing;
+        }
+    } else {
+        height -= (count - 1) * spacing;
+        int x = rect.x + marginWidth, cellHeight = height / count;
+        int y = rect.y + marginHeight, extra = height % count;
+        for (int i=0; i<count; i++) {
+            Control child = children [i];
+            int childHeight = cellHeight;
+            if (i is 0) {
+                childHeight += extra / 2;
+            } else {
+                if (i is count - 1) childHeight += (extra + 1) / 2;
+            }
+            child.setBounds (x, y, width, childHeight);
+            y += childHeight + spacing;
+        }
+    }
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+    String string = getName ()+" {";
+    string += "type="+((type is DWT.VERTICAL) ? "DWT.VERTICAL" : "DWT.HORIZONTAL")+" ";
+    if (marginWidth !is 0) string += "marginWidth="+marginWidth+" ";
+    if (marginHeight !is 0) string += "marginHeight="+marginHeight+" ";
+    if (spacing !is 0) string += "spacing="+spacing+" ";
+    string = string.trim();
+    string += "}";
+    return string;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/FormAttachment.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.FormAttachment;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.widgets.Control;
+
+/**
+ * Instances of this class are used to define the edges of a control
+ * within a <code>FormLayout</code>. 
+ * <p>
+ * <code>FormAttachments</code> are set into the top, bottom, left,
+ * and right fields of the <code>FormData</code> for a control.
+ * For example:
+ * <pre>
+ *      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);
+ * </pre>
+ * </p>
+ * <p>
+ * A <code>FormAttachment</code> 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:
+ * <pre>
+ *      FormAttachment attach = new FormAttachment (20, -5);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie at 20% of the parent composite, minus 5 pixels.
+ * </p>
+ * <p>
+ * Control sides can also be attached to another control.
+ * For example:
+ * <pre>
+ *      FormAttachment attach = new FormAttachment (button, 10);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie in the same position as the adjacent side of 
+ * the <code>button</code> control, plus 10 pixels. The control side can 
+ * also be attached to the opposite side of the specified control.
+ * For example:
+ * <pre>
+ *      FormData data = new FormData ();
+ *      data.left = new FormAttachment (button, 0, DWT.LEFT);
+ * </pre>
+ * specifies that the left side of the control will lie in the same position
+ * as the left side of the <code>button</code> control. The control can also 
+ * be attached in a position that will center the control on the specified 
+ * control. For example:
+ * <pre>
+ *      data.left = new FormAttachment (button, 0, DWT.CENTER);
+ * </pre>
+ * specifies that the left side of the control will be positioned so that it is
+ * centered between the left and right sides of the <code>button</code> control.
+ * If the alignment is not specified, the default is to attach to the adjacent side.
+ * </p>
+ * 
+ * @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.
+     * <p>
+     * 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.
+     * </p>
+     * 
+     * <br>Possible values are: <ul>
+     *    <li>TOP: Attach the side to the top side of the specified control.</li>
+     *    <li>BOTTOM : Attach the side to the bottom side of the specified control.</li>
+     *    <li>LEFT: Attach the side to the left side of the specified control.</li>
+     *    <li>RIGHT: Attach the side to the right side of the specified control.</li>
+     *    <li>CENTER: Attach the side at a position which will center the control on the specified control.</li>
+     *    <li>DEFAULT: Attach the side to the adjacent side of the specified control.</li>
+     * </ul>
+     */
+    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 FormAttachment () {
+}
+
+/**
+ * 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 FormAttachment (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 FormAttachment (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 FormAttachment (int numerator, int denominator, int offset) {
+    if (denominator is 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 FormAttachment (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 FormAttachment (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 FormAttachment (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 !is 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 is 0) DWT.error (DWT.ERROR_CANNOT_BE_ZERO);
+    return ((numerator * value) / denominator) + offset;
+}
+
+int solveY (int value) {
+    if (numerator is 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 String toString () {
+    String string = control !is null ? control.toString () : numerator + "/" + denominator;
+    return "{y = (" + string + (offset >= 0 ? ")x + " + offset: ")x - " + (-offset))+"}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/FormData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,345 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.FormData;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.widgets.Control;
+
+/**
+ * Instances of this class are used to define the attachments 
+ * of a control in a <code>FormLayout</code>. 
+ * <p>
+ * To set a <code>FormData</code> object into a control, you use the 
+ * <code>setLayoutData ()</code> method. To define attachments for the 
+ * <code>FormData</code>, set the fields directly, like this:
+ * <pre>
+ *      FormData data = new FormData();
+ *      data.left = new FormAttachment(0,5);
+ *      data.right = new FormAttachment(100,-5);
+ *      button.setLayoutData(formData);
+ * </pre>
+ * </p>
+ * <p>
+ * <code>FormData</code> contains the <code>FormAttachments</code> for 
+ * each edge of the control that the <code>FormLayout</code> uses to
+ * determine the size and position of the control. <code>FormData</code>
+ * objects also allow you to set the width and height of controls within
+ * a <code>FormLayout</code>. 
+ * </p>
+ * 
+ * @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 FormData () {
+}
+    
+/**
+ * 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 FormData (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 = (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 = (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;
+}
+    
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (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 = (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 = (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 String toString () {
+    String string = getName()+" {";
+    if (width !is DWT.DEFAULT) string += "width="+width+" ";
+    if (height !is DWT.DEFAULT) string += "height="+height+" ";
+    if (left !is null) string += "left="+left+" ";
+    if (right !is null) string += "right="+right+" ";
+    if (top !is null) string += "top="+top+" ";
+    if (bottom !is null) string += "bottom="+bottom+" ";
+    string = string.trim();
+    string += "}";
+    return string;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/FormLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,389 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.FormLayout;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Layout;
+import dwt.widgets.Scrollable;
+
+/**
+ * Instances of this class control the position and size of the 
+ * children of a composite control by using <code>FormAttachments</code>
+ * to optionally configure the left, top, right and bottom edges of
+ * each child.
+ * <p>
+ * The following example code creates a <code>FormLayout</code> and then sets
+ * it into a <code>Shell</code>:
+ * <pre>
+ *      Display display = new Display ();
+ *      Shell shell = new Shell(display);
+ *      FormLayout layout = new FormLayout();
+ *      layout.marginWidth = 3;
+ *      layout.marginHeight = 3;
+ *      shell.setLayout(layout);
+ * </pre>
+ * </p>
+ * <p>
+ * To use a <code>FormLayout</code>, create a <code>FormData</code> with
+ * <code>FormAttachment</code> for each child of <code>Composite</code>.
+ * The following example code attaches <code>button1</code> to the top
+ * and left edge of the composite and <code>button2</code> to the right
+ * edge of <code>button1</code> and the top and right edges of the
+ * composite:
+ * <pre>
+ *      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);
+ * </pre>
+ * </p>
+ * <p>
+ * Each side of a child control can be attached to a position in the parent 
+ * composite, or to other controls within the <code>Composite</code> by
+ * creating instances of <code>FormAttachment</code> and setting them into
+ * the top, bottom, left, and right fields of the child's <code>FormData</code>.
+ * </p>
+ * <p>
+ * 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 <code>button1</code> and <code>button2</code>
+ * but relies on default attachments:
+ * <pre>
+ *      FormData data2 = new FormData();
+ *      data2.left = new FormAttachment(button1);
+ *      data2.right = new FormAttachment(100, 0);
+ *      button2.setLayoutData(data2);
+ * </pre>
+ * </p>
+ * <p>
+ * IMPORTANT: Do not define circular attachments.  For example, do not attach
+ * the right edge of <code>button1</code> to the left edge of <code>button2</code>
+ * and then attach the left edge of <code>button2</code> to the right edge of
+ * <code>button1</code>.  This will over constrain the layout, causing undefined
+ * behavior.  The algorithm will terminate, but the results are undefined.
+ * </p>
+ * 
+ * @see FormData
+ * @see FormAttachment
+ * 
+ * @since 2.0
+ * 
+ */
+public final class FormLayout extends 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 FormLayout () {
+}
+
+/*
+ * 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) ((FormData) data).flushCache ();
+    return true;
+}
+
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (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<children.length; i++) {
+        Control child = children [i];
+        FormData data = (FormData) child.getLayoutData ();
+        if (data is null) child.setLayoutData (data = new FormData ());
+        if (flushCache) data.flushCache ();
+        data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null;
+    }
+    bool [] flush = null;
+    Rectangle [] bounds = null;
+    int w = 0, h = 0;
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        FormData data = (FormData) child.getLayoutData ();
+        if (width !is DWT.DEFAULT) {
+            data.needed = false;
+            FormAttachment left = data.getLeftAttachment (child, spacing, flushCache);
+            FormAttachment right = data.getRightAttachment (child, spacing, flushCache);
+            int x1 = left.solveX (width), x2 = right.solveX (width);
+            if (data.height is DWT.DEFAULT && !data.needed) {
+                int trim = 0;
+                //TEMPORARY CODE
+                if (child instanceof Scrollable) {
+                    Rectangle rect = ((Scrollable) child).computeTrim (0, 0, 0, 0);
+                    trim = rect.width;
+                } else {
+                    trim = child.getBorderWidth () * 2;
+                }
+                data.cacheWidth = data.cacheHeight = -1;
+                int currentWidth = Math.max (0, x2 - x1 - trim);
+                data.computeSize (child, currentWidth, data.height, flushCache);
+                if (flush is null) flush = new bool [children.length];
+                flush [i] = true;
+            }
+            w = Math.max (x2, w);
+            if (move) {
+                if (bounds is null) bounds = new Rectangle [children.length];
+                bounds [i] = new Rectangle (0, 0, 0, 0);
+                bounds [i].x = x + x1;
+                bounds [i].width = x2 - x1;
+            }
+        } else {
+            w = Math.max (computeWidth (child, data, flushCache), w);
+        }
+    }
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        FormData data = (FormData) child.getLayoutData ();
+        if (height !is DWT.DEFAULT) {
+            int y1 = data.getTopAttachment (child, spacing, flushCache).solveX (height);
+            int y2 = data.getBottomAttachment (child, spacing, flushCache).solveX (height);
+            h = Math.max (y2, h);
+            if (move) {
+                bounds [i].y = y + y1;
+                bounds [i].height = y2 - y1;
+            }
+        } else {
+            h = Math.max (computeHeight (child, data, flushCache), h);
+        }
+    }
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        FormData data = (FormData) child.getLayoutData ();
+        if (flush !is null && flush [i]) data.cacheWidth = data.cacheHeight = -1;
+        data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null;
+    }
+    if (move) {
+        for (int i=0; i<children.length; i++) {
+            children [i].setBounds (bounds [i]);
+        }
+    }
+    w += marginLeft + marginWidth * 2 + marginRight;
+    h += marginTop + marginHeight * 2 + marginBottom;
+    return new Point (w, h);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+    String string =  getName ()+" {";
+    if (marginWidth !is 0) string += "marginWidth="+marginWidth+" ";
+    if (marginHeight !is 0) string += "marginHeight="+marginHeight+" ";
+    if (marginLeft !is 0) string += "marginLeft="+marginLeft+" ";
+    if (marginRight !is 0) string += "marginRight="+marginRight+" ";
+    if (marginTop !is 0) string += "marginTop="+marginTop+" ";
+    if (marginBottom !is 0) string += "marginBottom="+marginBottom+" ";
+    if (spacing !is 0) string += "spacing="+spacing+" ";
+    string = string.trim();
+    string += "}";
+    return string;
+}   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/GridData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,563 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.GridData;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.widgets.Control;
+
+/**
+ * <code>GridData</code> is the layout data object associated with 
+ * <code>GridLayout</code>. To set a <code>GridData</code> object into a 
+ * control, you use the <code>Control.setLayoutData(Object)</code> method. 
+ * <p>
+ * There are two ways to create a <code>GridData</code> object with certain 
+ * fields set. The first is to set the fields directly, like this:
+ * <pre>
+ *      GridData gridData = new GridData();
+ *      gridData.horizontalAlignment = GridData.FILL;
+ *      gridData.grabExcessHorizontalSpace = true;
+ *      button1.setLayoutData(gridData);
+ * </pre>
+ * The second is to take advantage of convenience style bits defined 
+ * by <code>GridData</code>:
+ * <pre>
+ *      button1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
+ * </pre>
+ * </p>
+ * <p>
+ * NOTE: Do not reuse <code>GridData</code> objects. Every control in a 
+ * <code>Composite</code> that is managed by a <code>GridLayout</code>
+ * must have a unique <code>GridData</code> object. If the layout data 
+ * for a control in a <code>GridLayout</code> is null at layout time, 
+ * a unique <code>GridData</code> object is created for it.
+ * </p>
+ * 
+ * @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: <ul>
+     *    <li>DWT.BEGINNING (or DWT.TOP): Position the control at the top of the cell</li>
+     *    <li>DWT.CENTER: Position the control in the vertical center of the cell</li>
+     *    <li>DWT.END (or DWT.BOTTOM): Position the control at the bottom of the cell</li>
+     *    <li>DWT.FILL: Resize the control to fill the cell vertically</li>
+     * </ul>
+     */
+    public int verticalAlignment = CENTER;
+    
+    /**
+     * horizontalAlignment specifies how controls will be positioned 
+     * horizontally within a cell. 
+     *
+     * The default value is BEGINNING.
+     *
+     * Possible values are: <ul>
+     *    <li>DWT.BEGINNING (or DWT.LEFT): Position the control at the left of the cell</li>
+     *    <li>DWT.CENTER: Position the control in the horizontal center of the cell</li>
+     *    <li>DWT.END (or DWT.RIGHT): Position the control at the right of the cell</li>
+     *    <li>DWT.FILL: Resize the control to fill the cell horizontally</li>
+     * </ul>
+     */
+    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;
+    
+    /**
+     * <p>grabExcessHorizontalSpace specifies whether the width of the cell 
+     * changes depending on the size of the parent Composite.  If 
+     * grabExcessHorizontalSpace is <code>true</code>, the following rules
+     * apply to the width of the cell:</p>
+     * <ul>
+     * <li>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.</li>
+     * <li>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.</li>
+     * <li>If the parent is packed, the cell will be its preferred width 
+     * as specified by GridData.widthHint.</li>
+     * <li>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.</li>
+     * </ul>
+     * 
+     * <p>The default value is false.</p>
+     * 
+     * @see GridData#minimumWidth
+     * @see GridData#widthHint
+     */ 
+    public bool grabExcessHorizontalSpace = false;
+    
+    /**
+     * <p>grabExcessVerticalSpace specifies whether the height of the cell 
+     * changes depending on the size of the parent Composite.  If 
+     * grabExcessVerticalSpace is <code>true</code>, the following rules
+     * apply to the height of the cell:</p>
+     * <ul>
+     * <li>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.</li>
+     * <li>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.</li>
+     * <li>If the parent is packed, the cell will be its preferred height 
+     * as specified by GridData.heightHint.</li>
+     * <li>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.</li>
+     * </ul>
+     * 
+     * <p>The default value is false.</p>
+     * 
+     * @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 <code>true</code>,
+     * the size and position of the control will not be managed by the
+     * layout.  If this value is <code>false</code>, the size and 
+     * position of the control will be computed and assigned.
+     * 
+     * The default value is <code>false</code>.
+     * 
+     * @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 final 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 final 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 final 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 final int FILL = DWT.FILL;
+
+    /**
+     * Style bit for <code>new GridData(int)</code>.
+     * Position the control at the top of the cell.
+     * Not recommended. Use 
+     * <code>new GridData(int, DWT.BEGINNING, bool, bool)</code>
+     * instead.
+     */
+    public static final int VERTICAL_ALIGN_BEGINNING =  1 << 1;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to position the 
+     * control in the vertical center of the cell.
+     * Not recommended. Use
+     * <code>new GridData(int, DWT.CENTER, bool, bool)</code>
+     * instead.
+     */
+    public static final int VERTICAL_ALIGN_CENTER = 1 << 2;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to position the 
+     * control at the bottom of the cell.
+     * Not recommended. Use
+     * <code>new GridData(int, DWT.END, bool, bool)</code>
+     * instead.
+     */
+    public static final int VERTICAL_ALIGN_END = 1 << 3;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to resize the 
+     * control to fill the cell vertically.
+     * Not recommended. Use
+     * <code>new GridData(int, DWT.FILL, bool, bool)</code>
+     * instead
+     */
+    public static final int VERTICAL_ALIGN_FILL = 1 << 4;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to position the 
+     * control at the left of the cell.
+     * Not recommended. Use
+     * <code>new GridData(DWT.BEGINNING, int, bool, bool)</code>
+     * instead.
+     */
+    public static final int HORIZONTAL_ALIGN_BEGINNING =  1 << 5;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to position the 
+     * control in the horizontal center of the cell.
+     * Not recommended. Use
+     * <code>new GridData(DWT.CENTER, int, bool, bool)</code>
+     * instead.
+     */
+    public static final int HORIZONTAL_ALIGN_CENTER = 1 << 6;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to position the 
+     * control at the right of the cell.
+     * Not recommended. Use
+     * <code>new GridData(DWT.END, int, bool, bool)</code>
+     * instead.
+     */
+    public static final int HORIZONTAL_ALIGN_END = 1 << 7;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to resize the 
+     * control to fill the cell horizontally.
+     * Not recommended. Use
+     * <code>new GridData(DWT.FILL, int, bool, bool)</code>
+     * instead.
+     */
+    public static final int HORIZONTAL_ALIGN_FILL = 1 << 8;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to resize the 
+     * control to fit the remaining horizontal space.
+     * Not recommended. Use
+     * <code>new GridData(int, int, true, bool)</code>
+     * instead.
+     */
+    public static final int GRAB_HORIZONTAL = 1 << 9;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> to resize the 
+     * control to fit the remaining vertical space.
+     * Not recommended. Use
+     * <code>new GridData(int, int, bool, true)</code>
+     * instead.
+     */
+    public static final int GRAB_VERTICAL = 1 << 10;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> 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
+     * <code>new GridData(int, DWT.FILL, bool, true)</code>
+     * instead.
+     */ 
+    public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> 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
+     * <code>new GridData(DWT.FILL, int, true, bool)</code>
+     * instead.
+     */ 
+    public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL;
+    
+    /**
+     * Style bit for <code>new GridData(int)</code> 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
+     * <code>new GridData(DWT.FILL, DWT.FILL, true, true)</code>
+     * instead.
+     */ 
+    public static final 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 GridData () {
+    super ();
+}
+
+/**
+ * Constructs a new instance based on the GridData style.
+ * This constructor is not recommended.
+ * 
+ * @param style the GridData style
+ */
+public GridData (int style) {
+    super ();
+    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 GridData (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 GridData (int horizontalAlignment, int verticalAlignment, bool grabExcessHorizontalSpace, bool grabExcessVerticalSpace, int horizontalSpan, int verticalSpan) {
+    super ();
+    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 GridData (int width, int height) {
+    super ();
+    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;
+}
+
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (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 String toString () {
+    String 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 "+horizontalAlignment; break;
+    }
+    String 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 "+verticalAlignment; break;
+    }
+    String string = getName()+" {";
+    string += "horizontalAlignment="+hAlign+" ";
+    if (horizontalIndent !is 0) string += "horizontalIndent="+horizontalIndent+" ";
+    if (horizontalSpan !is 1) string += "horizontalSpan="+horizontalSpan+" ";
+    if (grabExcessHorizontalSpace) string += "grabExcessHorizontalSpace="+grabExcessHorizontalSpace+" ";
+    if (widthHint !is DWT.DEFAULT) string += "widthHint="+widthHint+" ";
+    if (minimumWidth !is 0) string += "minimumWidth="+minimumWidth+" ";
+    string += "verticalAlignment="+vAlign+" ";
+    if (verticalIndent !is 0) string += "verticalIndent="+verticalIndent+" ";
+    if (verticalSpan !is 1) string += "verticalSpan="+verticalSpan+" ";
+    if (grabExcessVerticalSpace) string += "grabExcessVerticalSpace="+grabExcessVerticalSpace+" ";
+    if (heightHint !is DWT.DEFAULT) string += "heightHint="+heightHint+" ";
+    if (minimumHeight !is 0) string += "minimumHeight="+minimumHeight+" ";
+    if (exclude) string += "exclude="+exclude+" ";
+    string = string.trim();
+    string += "}";
+    return string;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/GridLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,748 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.GridLayout;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Layout;
+import dwt.widgets.Scrollable;
+
+/**
+ * Instances of this class lay out the control children of a 
+ * <code>Composite</code> in a grid. 
+ * <p>
+ * <code>GridLayout</code> has a number of configuration fields, and the 
+ * controls it lays out can have an associated layout data object, called 
+ * <code>GridData</code>. The power of <code>GridLayout</code> lies in the 
+ * ability to configure <code>GridData</code> for each control in the layout. 
+ * </p>
+ * <p>
+ * The following code creates a shell managed by a <code>GridLayout</code>
+ * with 3 columns:
+ * <pre>
+ *      Display display = new Display();
+ *      Shell shell = new Shell(display);
+ *      GridLayout gridLayout = new GridLayout();
+ *      gridLayout.numColumns = 3;
+ *      shell.setLayout(gridLayout);
+ * </pre>
+ * The <code>numColumns</code> field is the most important field in a 
+ * <code>GridLayout</code>. Widgets are laid out in columns from left 
+ * to right, and a new row is created when <code>numColumns</code> + 1 
+ * controls are added to the <code>Composite<code>.
+ * </p>
+ * 
+ * @see GridData
+ */
+public final class GridLayout extends 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 GridLayout () {}
+
+/**
+ * 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 GridLayout (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) ((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 = (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<children.length; i++) {
+        Control control = children [i];
+        GridData data = (GridData) control.getLayoutData ();
+        if (data is null || !data.exclude) {
+            children [count++] = children [i];
+        } 
+    }
+    if (count is 0) {
+        return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom);
+    }
+    for (int i=0; i<count; i++) {
+        Control child = children [i];
+        GridData data = (GridData) child.getLayoutData ();
+        if (data is null) child.setLayoutData (data = new GridData ());
+        if (flushCache) data.flushCache ();
+        data.computeSize (child, data.widthHint, data.heightHint, flushCache);
+        if (data.grabExcessHorizontalSpace && data.minimumWidth > 0) {
+            if (data.cacheWidth < data.minimumWidth) {
+                int trim = 0;
+                //TEMPORARY CODE
+                if (child instanceof Scrollable) {
+                    Rectangle rect = ((Scrollable) child).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<count; i++) {   
+        Control child = children [i];
+        GridData data = (GridData) child.getLayoutData ();
+        int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+        int vSpan = Math.max (1, data.verticalSpan);
+        while (true) {
+            int lastRow = row + vSpan;
+            if (lastRow >= grid.length) {
+                Control [][] newGrid = new Control [lastRow + 4] [columnCount];
+                System.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<vSpan; j++) {
+            if (grid [row + j] is null) {
+                grid [row + j] = new Control [columnCount];
+            }
+            for (int k=0; k<hSpan; k++) {
+                grid [row + j] [column + k] = child;
+            }
+        }
+        rowCount = Math.max (rowCount, row + vSpan);
+        column += hSpan;
+    }
+
+    /* Column widths */
+    int availableWidth = width - horizontalSpacing * (columnCount - 1) - (marginLeft + marginWidth * 2 + marginRight);
+    int expandCount = 0;
+    int [] widths = new int [columnCount];
+    int [] minWidths = new int [columnCount];
+    bool [] expandColumn = new bool [columnCount];
+    for (int j=0; j<columnCount; j++) {
+        for (int i=0; i<rowCount; i++) {
+            GridData data = getData (grid, i, j, rowCount, columnCount, true);
+            if (data !is null) {
+                int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+                if (hSpan is 1) {
+                    int w = data.cacheWidth + data.horizontalIndent;
+                    widths [j] = Math.max (widths [j], w);
+                    if (data.grabExcessHorizontalSpace) {
+                        if (!expandColumn [j]) expandCount++;
+                        expandColumn [j] = true;
+                    }
+                    if (!data.grabExcessHorizontalSpace || data.minimumWidth !is 0) {
+                        w = !data.grabExcessHorizontalSpace || data.minimumWidth is DWT.DEFAULT ? data.cacheWidth : data.minimumWidth;
+                        w += data.horizontalIndent;
+                        minWidths [j] = Math.max (minWidths [j], w);
+                    }
+                }
+            }
+        }
+        for (int i=0; i<rowCount; i++) {
+            GridData data = getData (grid, i, j, rowCount, columnCount, false);
+            if (data !is null) {
+                int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+                if (hSpan > 1) {
+                    int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0;
+                    for (int k=0; k<hSpan; k++) {
+                        spanWidth += widths [j-k];
+                        spanMinWidth += minWidths [j-k];
+                        if (expandColumn [j-k]) spanExpandCount++;
+                    }
+                    if (data.grabExcessHorizontalSpace && spanExpandCount is 0) {
+                        expandCount++;
+                        expandColumn [j] = true;
+                    }
+                    int w = data.cacheWidth + data.horizontalIndent - spanWidth - (hSpan - 1) * horizontalSpacing;
+                    if (w > 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<columnCount; i++) {
+            minColumnWidth = Math.max (minColumnWidth, minWidths [i]);
+            columnWidth = Math.max (columnWidth, widths [i]);
+        }
+        columnWidth = width is DWT.DEFAULT || expandCount is 0 ? columnWidth : Math.max (minColumnWidth, availableWidth / columnCount);
+        for (int i=0; i<columnCount; i++) {
+            expandColumn [i] = expandCount > 0;
+            widths [i] = columnWidth;
+        }
+    } else {
+        if (width !is DWT.DEFAULT && expandCount > 0) {
+            int totalWidth = 0;
+            for (int i=0; i<columnCount; i++) {
+                totalWidth += widths [i];
+            }
+            int c = expandCount;
+            int delta = (availableWidth - totalWidth) / c;
+            int remainder = (availableWidth - totalWidth) % c;
+            int last = -1;
+            while (totalWidth !is availableWidth) {
+                for (int j=0; j<columnCount; j++) {
+                    if (expandColumn [j]) {
+                        if (widths [j] + delta > 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<columnCount; j++) {
+                    for (int i=0; i<rowCount; i++) {
+                        GridData data = getData (grid, i, j, rowCount, columnCount, false);
+                        if (data !is null) {
+                            int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+                            if (hSpan > 1) {
+                                if (!data.grabExcessHorizontalSpace || data.minimumWidth !is 0) {
+                                    int spanWidth = 0, spanExpandCount = 0;
+                                    for (int k=0; k<hSpan; k++) {
+                                        spanWidth += widths [j-k];
+                                        if (expandColumn [j-k]) spanExpandCount++;
+                                    }
+                                    int w = !data.grabExcessHorizontalSpace || data.minimumWidth is DWT.DEFAULT ? data.cacheWidth : data.minimumWidth;
+                                    w += data.horizontalIndent - spanWidth - (hSpan - 1) * horizontalSpacing;
+                                    if (w > 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<columnCount; i++) {
+                    totalWidth += widths [i];
+                }
+                delta = (availableWidth - totalWidth) / c;
+                remainder = (availableWidth - totalWidth) % c;
+                last = -1;
+            }
+        }
+    }
+
+    /* Wrapping */
+    GridData [] flush = null;
+    int flushLength = 0;
+    if (width !is DWT.DEFAULT) {
+        for (int j=0; j<columnCount; j++) {
+            for (int i=0; i<rowCount; i++) {
+                GridData data = getData (grid, i, j, rowCount, columnCount, false);
+                if (data !is null) {
+                    if (data.heightHint is DWT.DEFAULT) {
+                        Control child = grid [i][j];
+                        //TEMPORARY CODE
+                        int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+                        int currentWidth = 0;
+                        for (int k=0; k<hSpan; k++) {
+                            currentWidth += widths [j-k];
+                        }
+                        currentWidth += (hSpan - 1) * horizontalSpacing - data.horizontalIndent;
+                        if ((currentWidth !is data.cacheWidth && data.horizontalAlignment is DWT.FILL) || (data.cacheWidth > currentWidth)) {
+                            int trim = 0;
+                            if (child instanceof Scrollable) {
+                                Rectangle rect = ((Scrollable) child).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<rowCount; i++) {
+        for (int j=0; j<columnCount; j++) {
+            GridData data = getData (grid, i, j, rowCount, columnCount, true);
+            if (data !is null) {
+                int vSpan = Math.max (1, Math.min (data.verticalSpan, rowCount));
+                if (vSpan is 1) {
+                    int h = data.cacheHeight + data.verticalIndent;
+                    heights [i] = Math.max (heights [i], h);
+                    if (data.grabExcessVerticalSpace) {
+                        if (!expandRow [i]) expandCount++;
+                        expandRow [i] = true;
+                    }
+                    if (!data.grabExcessVerticalSpace || data.minimumHeight !is 0) {
+                        h = !data.grabExcessVerticalSpace || data.minimumHeight is DWT.DEFAULT ? data.cacheHeight : data.minimumHeight;
+                        h += data.verticalIndent;
+                        minHeights [i] = Math.max (minHeights [i], h);
+                    }
+                }
+            }
+        }
+        for (int j=0; j<columnCount; j++) {
+            GridData data = getData (grid, i, j, rowCount, columnCount, false);
+            if (data !is null) {
+                int vSpan = Math.max (1, Math.min (data.verticalSpan, rowCount));
+                if (vSpan > 1) {
+                    int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0;
+                    for (int k=0; k<vSpan; k++) {
+                        spanHeight += heights [i-k];
+                        spanMinHeight += minHeights [i-k];
+                        if (expandRow [i-k]) spanExpandCount++;
+                    }
+                    if (data.grabExcessVerticalSpace && spanExpandCount is 0) {
+                        expandCount++;
+                        expandRow [i] = true;
+                    }
+                    int h = data.cacheHeight + data.verticalIndent - spanHeight - (vSpan - 1) * verticalSpacing;
+                    if (h > 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<rowCount; i++) {
+            totalHeight += heights [i];
+        }
+        int c = expandCount;
+        int delta = (availableHeight - totalHeight) / c;
+        int remainder = (availableHeight - totalHeight) % c;
+        int last = -1;
+        while (totalHeight !is availableHeight) {
+            for (int i=0; i<rowCount; i++) {
+                if (expandRow [i]) {
+                    if (heights [i] + delta > 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<rowCount; i++) {
+                for (int j=0; j<columnCount; j++) {
+                    GridData data = getData (grid, i, j, rowCount, columnCount, false);
+                    if (data !is null) {
+                        int vSpan = Math.max (1, Math.min (data.verticalSpan, rowCount));
+                        if (vSpan > 1) {
+                            if (!data.grabExcessVerticalSpace || data.minimumHeight !is 0) {
+                                int spanHeight = 0, spanExpandCount = 0;
+                                for (int k=0; k<vSpan; k++) {
+                                    spanHeight += heights [i-k];
+                                    if (expandRow [i-k]) spanExpandCount++;
+                                }
+                                int h = !data.grabExcessVerticalSpace || data.minimumHeight is DWT.DEFAULT ? data.cacheHeight : data.minimumHeight;
+                                h += data.verticalIndent - spanHeight - (vSpan - 1) * verticalSpacing;
+                                if (h > 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<rowCount; i++) {
+                totalHeight += heights [i];
+            }
+            delta = (availableHeight - totalHeight) / c;
+            remainder = (availableHeight - totalHeight) % c;
+            last = -1;
+        }
+    }
+
+    /* Position the controls */
+    if (move) {
+        int gridY = y + marginTop + marginHeight;
+        for (int i=0; i<rowCount; i++) {
+            int gridX = x + marginLeft + marginWidth;
+            for (int j=0; j<columnCount; j++) {
+                GridData data = getData (grid, i, j, rowCount, columnCount, true);
+                if (data !is null) {
+                    int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+                    int vSpan = Math.max (1, data.verticalSpan);
+                    int cellWidth = 0, cellHeight = 0;
+                    for (int k=0; k<hSpan; k++) {
+                        cellWidth += widths [j+k];
+                    }
+                    for (int k=0; k<vSpan; k++) {
+                        cellHeight += heights [i+k];
+                    }
+                    cellWidth += horizontalSpacing * (hSpan - 1);
+                    int childX = gridX + data.horizontalIndent;
+                    int childWidth = Math.min (data.cacheWidth, cellWidth);
+                    switch (data.horizontalAlignment) {
+                        case DWT.CENTER:
+                        case GridData.CENTER:
+                            childX += Math.max (0, (cellWidth - data.horizontalIndent - childWidth) / 2);
+                            break;
+                        case DWT.RIGHT:
+                        case DWT.END:
+                        case GridData.END:
+                            childX += Math.max (0, cellWidth - data.horizontalIndent - childWidth);
+                            break;
+                        case DWT.FILL:
+                            childWidth = cellWidth - data.horizontalIndent;
+                            break;
+                    }
+                    cellHeight += verticalSpacing * (vSpan - 1);
+                    int childY = gridY + data.verticalIndent;
+                    int childHeight = Math.min (data.cacheHeight, cellHeight);
+                    switch (data.verticalAlignment) {
+                        case DWT.CENTER:
+                        case GridData.CENTER:
+                            childY += Math.max (0, (cellHeight - data.verticalIndent - childHeight) / 2);
+                            break;
+                        case DWT.BOTTOM:
+                        case DWT.END:
+                        case GridData.END:
+                            childY += Math.max (0, cellHeight - data.verticalIndent - childHeight);
+                            break;
+                        case DWT.FILL:
+                            childHeight = cellHeight - data.verticalIndent;
+                            break;
+                    }
+                    Control child = grid [i][j];
+                    if (child !is null) {
+                        child.setBounds (childX, childY, childWidth, childHeight);
+                    }
+                }
+                gridX += widths [j] + horizontalSpacing;
+            }
+            gridY += heights [i] + verticalSpacing;
+        }
+    }
+
+    // clean up cache
+    for (int i = 0; i < flushLength; i++) {
+        flush [i].cacheWidth = flush [i].cacheHeight = -1;
+    }
+
+    int totalDefaultWidth = 0;
+    int totalDefaultHeight = 0;
+    for (int i=0; i<columnCount; i++) {
+        totalDefaultWidth += widths [i];
+    }
+    for (int i=0; i<rowCount; i++) {
+        totalDefaultHeight += heights [i];
+    }
+    totalDefaultWidth += horizontalSpacing * (columnCount - 1) + marginLeft + marginWidth * 2 + marginRight;
+    totalDefaultHeight += verticalSpacing * (rowCount - 1) + marginTop + marginHeight * 2 + marginBottom;
+    return new Point (totalDefaultWidth, totalDefaultHeight);
+}
+
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+    String string = getName ()+" {";
+    if (numColumns !is 1) string += "numColumns="+numColumns+" ";
+    if (makeColumnsEqualWidth) string += "makeColumnsEqualWidth="+makeColumnsEqualWidth+" ";
+    if (marginWidth !is 0) string += "marginWidth="+marginWidth+" ";
+    if (marginHeight !is 0) string += "marginHeight="+marginHeight+" ";
+    if (marginLeft !is 0) string += "marginLeft="+marginLeft+" ";
+    if (marginRight !is 0) string += "marginRight="+marginRight+" ";
+    if (marginTop !is 0) string += "marginTop="+marginTop+" ";
+    if (marginBottom !is 0) string += "marginBottom="+marginBottom+" ";
+    if (horizontalSpacing !is 0) string += "horizontalSpacing="+horizontalSpacing+" ";
+    if (verticalSpacing !is 0) string += "verticalSpacing="+verticalSpacing+" ";
+    string = string.trim();
+    string += "}";
+    return string;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/RowData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.RowData;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+
+/**
+ * Each control controlled by a <code>RowLayout</code> can have its initial 
+ * width and height specified by setting a <code>RowData</code> object 
+ * into the control.
+ * <p>
+ * The following code uses a <code>RowData</code> object to change the initial
+ * size of a <code>Button</code> in a <code>Shell</code>:
+ * <pre>
+ *      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));
+ * </pre>
+ * </p>
+ * 
+ * @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 <code>true</code>,
+     * the size and position of the control will not be managed by the
+     * layout.  If this value is <code>false</code>, the size and 
+     * position of the control will be computed and assigned.
+     * 
+     * The default value is <code>false</code>.
+     * 
+     * @since 3.1
+     */
+    public bool exclude = false;
+    
+/**
+ * Constructs a new instance of RowData using
+ * default values.
+ */
+public RowData () {
+}
+
+/**
+ * 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 RowData (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 RowData (Point point) {
+    this (point.x, point.y);
+}
+
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (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 String toString () {
+    String string = getName ()+" {";
+    if (width !is DWT.DEFAULT) string += "width="+width+" ";
+    if (height !is DWT.DEFAULT) string += "height="+height+" ";
+    if (exclude) string += "exclude="+exclude+" ";
+    string = string.trim();
+    string += "}";
+    return string;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/layout/RowLayout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,508 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.layout.RowLayout;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.Layout;
+
+/**
+ * Instances of this class determine the size and position of the 
+ * children of a <code>Composite</code> by placing them either in 
+ * horizontal rows or vertical columns within the parent <code>Composite</code>. 
+ * <p>
+ * <code>RowLayout</code> aligns all controls in one row if the
+ * <code>type</code> 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. <code>RowLayout</code> has a number of configuration 
+ * fields. In addition, the height and width of each control in a 
+ * <code>RowLayout</code> can be specified by setting a <code>RowData</code>
+ * object into the control using <code>setLayoutData ()</code>.
+ * </p>
+ * <p>
+ * The following example code creates a <code>RowLayout</code>, sets all 
+ * of its fields to non-default values, and then sets it into a 
+ * <code>Shell</code>. 
+ * <pre>
+ *      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);
+ * </pre>
+ * If you are using the default field values, you only need one line of code:
+ * <pre>
+ *      shell.setLayout(new RowLayout());
+ * </pre>
+ * </p>
+ * 
+ * @see RowData
+ */
+public final class RowLayout extends Layout {
+    
+    /**
+     * type specifies whether the layout places controls in rows or 
+     * columns.
+     * 
+     * The default value is HORIZONTAL.
+     * 
+     * Possible values are: <ul>
+     *    <li>HORIZONTAL: Position the controls horizontally from left to right</li>
+     *    <li>VERTICAL: Position the controls vertically from top to bottom</li>
+     * </ul>
+     * 
+     * @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;
+
+    /**
+     * center specifies whether the controls in a row should be
+     * centered vertically in each cell for horizontal layouts,
+     * or centered horizontally in each cell for vertical layouts.
+     *
+     * The default value is false.
+     * 
+     * @since 3.4
+     */
+    public bool center = 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 RowLayout () {
+}
+
+/**
+ * Constructs a new instance of this class given the type.
+ *
+ * @param type the type of row layout
+ * 
+ * @since 2.0
+ */
+public RowLayout (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 = (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;
+}
+
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (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<children.length; i++) {
+        Control control = children [i];
+        RowData data = (RowData) control.getLayoutData ();
+        if (data is null || !data.exclude) {
+            children [count++] = children [i];
+        } 
+    }
+    if (count is 0) {
+        return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom);
+    }
+    int childWidth = 0, childHeight = 0, maxHeight = 0;
+    if (!pack) {
+        for (int i=0; i<count; i++) {
+            Control child = children [i];
+            Point size = computeSize (child, flushCache);
+            childWidth = Math.max (childWidth, size.x);
+            childHeight = Math.max (childHeight, size.y);
+        }
+        maxHeight = childHeight;
+    }
+    int clientX = 0, clientY = 0;
+    if (move) {
+        Rectangle rect = composite.getClientArea ();
+        clientX = rect.x;
+        clientY = rect.y;
+    }
+    int [] wraps = null;
+    bool wrapped = false;
+    Rectangle [] bounds = null;
+    if (move && (justify || fill || center)) {
+        bounds = new Rectangle [count];
+        wraps = new int [count];
+    }
+    int maxX = 0, x = marginLeft + marginWidth, y = marginTop + marginHeight;
+    for (int i=0; i<count; i++) {
+        Control child = children [i];
+        if (pack) {
+            Point size = computeSize (child, flushCache);
+            childWidth = size.x;
+            childHeight = size.y;
+        }
+        if (wrap && (i !is 0) && (x + childWidth > width)) {
+            wrapped = true;
+            if (move && (justify || fill || center)) wraps [i - 1] = maxHeight;
+            x = marginLeft + marginWidth;
+            y += spacing + maxHeight;
+            if (pack) maxHeight = 0;
+        }
+        if (pack || fill || center) {
+            maxHeight = Math.max (maxHeight, childHeight);
+        }
+        if (move) {
+            int childX = x + clientX, childY = y + clientY;
+            if (justify || fill || center) {
+                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 || center)) {
+        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 || center) {
+                int last = 0;
+                if (count > 0) wraps [count - 1] = maxHeight;
+                for (int i=0; i<count; i++) {
+                    if (wraps [i] !is 0) {
+                        int wrapCount = i - last + 1;
+                        if (justify) {
+                            int wrapX = 0;
+                            for (int j=last; j<=i; j++) {
+                                wrapX += bounds [j].width + spacing;
+                            }
+                            space = Math.max (0, (width - wrapX) / (wrapCount + 1));
+                            margin = Math.max (0, ((width - wrapX) % (wrapCount + 1)) / 2);
+                        }
+                        for (int j=last; j<=i; j++) {
+                            if (justify) bounds [j].x += (space * (j - last + 1)) + margin;
+                            if (fill) {
+                                bounds [j].height = wraps [i];
+                            } else {
+                                if (center) {
+                                    bounds [j].y += Math.max (0, (wraps [i] - bounds [j].height) / 2);
+                                }
+                            }
+                        }
+                        last = i + 1;
+                    }
+                }
+            }
+        }
+        for (int i=0; i<count; i++) {
+            if (!wrapped) {
+                if (justify) bounds [i].x += (space * (i + 1)) + margin;
+                if (fill) {
+                    bounds [i].height = maxHeight;
+                } else {
+                    if (center) {
+                        bounds [i].y += Math.max (0, (maxHeight - bounds [i].height) / 2);
+                    }
+                }
+            }
+            children [i].setBounds (bounds [i]);
+        }
+    }
+    return new Point (maxX, y + maxHeight + marginBottom + marginHeight);
+}
+
+Point layoutVertical (Composite composite, bool move, bool wrap, int height, bool flushCache) {
+    Control [] children = composite.getChildren ();
+    int count = 0;
+    for (int i=0; i<children.length; i++) {
+        Control control = children [i];
+        RowData data = (RowData) control.getLayoutData ();
+        if (data is null || !data.exclude) {
+            children [count++] = children [i];
+        } 
+    }
+    if (count is 0) {
+        return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom);
+    }
+    int childWidth = 0, childHeight = 0, maxWidth = 0;
+    if (!pack) {
+        for (int i=0; i<count; i++) {
+            Control child = children [i];
+            Point size = computeSize (child, flushCache);
+            childWidth = Math.max (childWidth, size.x);
+            childHeight = Math.max (childHeight, size.y);
+        }
+        maxWidth = childWidth;
+    }
+    int clientX = 0, clientY = 0;
+    if (move) {
+        Rectangle rect = composite.getClientArea ();
+        clientX = rect.x;
+        clientY = rect.y;
+    }
+    int [] wraps = null;
+    bool wrapped = false;
+    Rectangle [] bounds = null;
+    if (move && (justify || fill || center)) {
+        bounds = new Rectangle [count];
+        wraps = new int [count];
+    }
+    int maxY = 0, x = marginLeft + marginWidth, y = marginTop + marginHeight;
+    for (int i=0; i<count; i++) {
+        Control child = children [i];
+        if (pack) {
+            Point size = computeSize (child, flushCache);
+            childWidth = size.x;
+            childHeight = size.y;
+        }
+        if (wrap && (i !is 0) && (y + childHeight > height)) {
+            wrapped = true;
+            if (move && (justify || fill || center)) wraps [i - 1] = maxWidth;
+            x += spacing + maxWidth;
+            y = marginTop + marginHeight;
+            if (pack) maxWidth = 0;
+        }
+        if (pack || fill || center) {
+            maxWidth = Math.max (maxWidth, childWidth);
+        }
+        if (move) {
+            int childX = x + clientX, childY = y + clientY;
+            if (justify || fill || center) {
+                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 || center)) {
+        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 || center) {
+                int last = 0;
+                if (count > 0) wraps [count - 1] = maxWidth;
+                for (int i=0; i<count; i++) {
+                    if (wraps [i] !is 0) {
+                        int wrapCount = i - last + 1;
+                        if (justify) {
+                            int wrapY = 0;
+                            for (int j=last; j<=i; j++) {
+                                wrapY += bounds [j].height + spacing;
+                            }
+                            space = Math.max (0, (height - wrapY) / (wrapCount + 1));
+                            margin = Math.max (0, ((height - wrapY) % (wrapCount + 1)) / 2);
+                        }
+                        for (int j=last; j<=i; j++) {
+                            if (justify) bounds [j].y += (space * (j - last + 1)) + margin;
+                            if (fill) {
+                                bounds [j].width = wraps [i];
+                            } else {
+                                if (center) {
+                                    bounds [j].x += Math.max (0, (wraps [i] - bounds [j].width) / 2);
+                                }
+                            }
+                        }
+                        last = i + 1;
+                    }
+                }
+            }
+        }
+        for (int i=0; i<count; i++) {
+            if (!wrapped) {
+                if (justify) bounds [i].y += (space * (i + 1)) + margin;
+                if (fill) {
+                    bounds [i].width = maxWidth;
+                } else {
+                    if (center) {
+                        bounds [i].x += Math.max (0, (maxWidth - bounds [i].width) / 2);
+                    }
+                }
+
+            }
+            children [i].setBounds (bounds [i]);
+        }
+    }
+    return new Point (x + maxWidth + marginRight + marginWidth, maxY);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+    String string = getName ()+" {";
+    string += "type="+((type !is DWT.HORIZONTAL) ? "DWT.VERTICAL" : "DWT.HORIZONTAL")+" ";
+    if (marginWidth !is 0) string += "marginWidth="+marginWidth+" ";
+    if (marginHeight !is 0) string += "marginHeight="+marginHeight+" ";
+    if (marginLeft !is 0) string += "marginLeft="+marginLeft+" ";
+    if (marginTop !is 0) string += "marginTop="+marginTop+" ";
+    if (marginRight !is 0) string += "marginRight="+marginRight+" ";
+    if (marginBottom !is 0) string += "marginBottom="+marginBottom+" ";
+    if (spacing !is 0) string += "spacing="+spacing+" ";
+    string += "wrap="+wrap+" ";
+    string += "pack="+pack+" ";
+    string += "fill="+fill+" ";
+    string += "justify="+justify+" ";
+    string = string.trim();
+    string += "}";
+    return string;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/opengl/GLCanvas.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.opengl.GLCanvas;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSOpenGLContext;
+import dwt.internal.cocoa.NSOpenGLPixelFormat;
+import dwt.internal.cocoa.NSOpenGLView;
+import dwt.internal.cocoa.OS;
+import dwt.widgets.Canvas;
+import dwt.widgets.Composite;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+
+/**
+ * GLCanvas is a widget capable of displaying OpenGL content.
+ * 
+ * @since 3.2
+ */
+
+public class GLCanvas extends Canvas {
+    NSOpenGLView glView;
+    NSOpenGLPixelFormat pixelFormat;
+    static final int MAX_ATTRIBUTES = 32;
+
+/**
+ * Create a GLCanvas widget using the attributes described in the GLData
+ * object provided.
+ *
+ * @param parent a composite widget
+ * @param style the bitwise OR'ing of widget styles
+ * @param data the requested attributes of the GLCanvas
+ *
+ * @exception IllegalArgumentException
+ * <ul><li>ERROR_NULL_ARGUMENT when the data is null
+ *     <li>ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided</ul> 
+ * </ul>
+ */
+public GLCanvas (Composite parent, int style, GLData data) {
+    super (parent, style);
+    if (data is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    int attrib [] = new int [MAX_ATTRIBUTES];
+    int pos = 0;
+    //TODO this is not working
+//  attrib [pos++] = OS.AGL_RGBA;
+    if (data.doubleBuffer) attrib [pos++] = OS.NSOpenGLPFADoubleBuffer;
+    if (data.stereo) attrib [pos++] = OS.NSOpenGLPFAStereo;
+//  if (data.redSize > 0) {
+//      attrib [pos++] = OS.AGL_RED_SIZE;
+//      attrib [pos++] = data.redSize;
+//  }
+//  if (data.greenSize > 0) {
+//      attrib [pos++] = OS.AGL_GREEN_SIZE;
+//      attrib [pos++] = data.greenSize;
+//  }
+//  if (data.blueSize > 0) {
+//      attrib [pos++] = OS.AGL_BLUE_SIZE;
+//      attrib [pos++] = data.blueSize;
+//  }
+    if (data.alphaSize > 0) {
+        attrib [pos++] = OS.NSOpenGLPFAAlphaSize;
+        attrib [pos++] = data.alphaSize;
+    }
+    if (data.depthSize > 0) {
+        attrib [pos++] = OS.NSOpenGLPFADepthSize;
+        attrib [pos++] = data.depthSize;
+    }
+    if (data.stencilSize > 0) {
+        attrib [pos++] = OS.NSOpenGLPFAStencilSize;
+        attrib [pos++] = data.stencilSize;
+    }
+//  if (data.accumRedSize > 0) {
+//      attrib [pos++] = OS.AGL_ACCUM_RED_SIZE;
+//      attrib [pos++] = data.accumRedSize;
+//  }
+//  if (data.accumGreenSize > 0) {
+//      attrib [pos++] = OS.AGL_ACCUM_GREEN_SIZE;
+//      attrib [pos++] = data.accumGreenSize;
+//  }
+//  if (data.accumBlueSize > 0) {
+//      attrib [pos++] = OS.AGL_ACCUM_BLUE_SIZE;
+//      attrib [pos++] = data.accumBlueSize;
+//  }
+//  if (data.accumAlphaSize > 0) {
+//      attrib [pos++] = OS.AGL_ACCUM_ALPHA_SIZE;
+//      attrib [pos++] = data.accumAlphaSize;
+//  }
+    if (data.sampleBuffers > 0) {
+        attrib [pos++] = OS.NSOpenGLPFASampleBuffers;
+        attrib [pos++] = data.sampleBuffers;
+    }
+    if (data.samples > 0) {
+        attrib [pos++] = OS.NSOpenGLPFASamples;
+        attrib [pos++] = data.samples;
+    }
+    attrib [pos++] = 0;
+    pixelFormat = (NSOpenGLPixelFormat)new NSOpenGLPixelFormat().alloc();
+    if (pixelFormat is null) {      
+        dispose ();
+        DWT.error (DWT.ERROR_UNSUPPORTED_DEPTH);
+    }
+    pixelFormat.initWithAttributes(attrib);
+    
+    glView = (NSOpenGLView)new NSOpenGLView().alloc();
+    if (glView is null) {       
+        dispose ();
+        DWT.error (DWT.ERROR_UNSUPPORTED_DEPTH);
+    }
+    glView.initWithFrame(parent.view.frame(), pixelFormat);
+    glView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable);
+
+    Listener listener = new Listener () {
+        public void handleEvent (Event event) {
+            switch (event.type) {
+            case DWT.Dispose:
+                if (glView !is null) glView.release();
+                glView = null;
+                if (pixelFormat !is null) pixelFormat.release();
+                pixelFormat = null;
+                break;
+            }
+        }
+    };
+    addListener (DWT.Dispose, listener);
+}
+
+/**
+ * Returns a GLData object describing the created context.
+ *  
+ * @return GLData description of the OpenGL context attributes
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public GLData getGLData () {
+    checkWidget ();
+    GLData data = new GLData ();
+    int [] value = new int [1];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_DOUBLEBUFFER, value);
+//  data.doubleBuffer = value [0] !is 0;
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_STEREO, value);
+//  data.stereo = value [0] !is 0;
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_RED_SIZE, value);
+//  data.redSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_GREEN_SIZE, value);
+//  data.greenSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_BLUE_SIZE, value);
+//  data.blueSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ALPHA_SIZE, value);
+//  data.alphaSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_DEPTH_SIZE, value);
+//  data.depthSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_STENCIL_SIZE, value);
+//  data.stencilSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_RED_SIZE, value);
+//  data.accumRedSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_GREEN_SIZE, value);
+//  data.accumGreenSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_BLUE_SIZE, value);
+//  data.accumBlueSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_ALPHA_SIZE, value);
+//  data.accumAlphaSize = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_SAMPLE_BUFFERS_ARB, value);
+//  data.sampleBuffers = value [0];
+//  AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_SAMPLES_ARB, value);
+    data.samples = value [0];
+    return data;
+}
+
+/**
+ * Returns a bool indicating whether the receiver's OpenGL context
+ * is the current context.
+ *  
+ * @return true if the receiver holds the current OpenGL context,
+ * false otherwise
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool isCurrent () {
+    checkWidget ();
+    return NSOpenGLContext.currentContext().id is glView.openGLContext().id;
+}
+
+/**
+ * Sets the OpenGL context associated with this GLCanvas to be the
+ * current GL context.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCurrent () {
+    checkWidget ();
+    glView.openGLContext().makeCurrentContext();
+}
+
+/**
+ * Swaps the front and back color buffers.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void swapBuffers () {
+    checkWidget ();
+    glView.openGLContext().flushBuffer();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/opengl/GLData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 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
+ *******************************************************************************/
+module dwt.opengl.GLData;
+
+import dwt.dwthelper.utils;
+
+/**
+ * The GLData class is a device-independent description
+ * of the pixel format attributes of a GL drawable.
+ *
+ * @see GLCanvas
+ * 
+ * @since 3.2
+ */
+
+public class GLData {
+    /**
+     * Specifies a double-buffered surface.  During context
+     * creation, only double-buffered formats are considered
+     * when set to true. 
+     */
+    public bool doubleBuffer;
+
+    /**
+     * Specifies a stereo surface.  During context creation,
+     * only stereo formats are considered when set to true. 
+     */
+    public bool stereo;
+
+    /**
+     * The size in bits of the color buffer's red channel.
+     * During context creation, this specifies the minimum
+     * required red bits.
+     */
+    public int redSize;
+
+    /**
+     * The size in bits of the color buffer's green channel.
+     * During context creation, this specifies the minimum
+     * required green bits.
+     */
+    public int greenSize;
+
+    /**
+     * The size in bits of the color buffer's blue channel.
+     * During context creation, this specifies the minimum
+     * required blue bits.
+     */
+    public int blueSize;
+
+    /**
+     * The size in bits of the color buffer's alpha channel.
+     * During context creation, this specifies the minimum
+     * required alpha bits.
+     */
+    public int alphaSize;
+
+    /**
+     * The size in bits of the depth buffer.  During context
+     * creation, the smallest depth buffer of at least the
+     * specified value is preferred, or zero for no depth
+     * buffer.
+     */
+    public int depthSize;
+
+    /**
+     * The desired number of stencil bitplanes.  During
+     * context creation, the smallest stencil buffer of at
+     * least the specified value is preferred, or zero for
+     * no stencil buffer.
+     */
+    public int stencilSize;
+
+    /**
+     * The size in bits of the accumulation buffer's red
+     * channel. During context creation, this specifies the
+     * minimum required red bits.
+     */
+    public int accumRedSize;
+
+    /**
+     * The size in bits of the accumulation buffer's green
+     * channel. During context creation, this specifies the
+     * minimum required green bits.
+     */
+    public int accumGreenSize;
+
+    /**
+     * The size in bits of the accumulation buffer's blue
+     * channel. During context creation, this specifies the
+     * minimum required blue bits.
+     */
+    public int accumBlueSize;
+
+    /**
+     * The size in bits of the accumulation buffer's alpha
+     * channel. During context creation, this specifies the
+     * minimum required alpha bits.
+     */
+    public int accumAlphaSize;
+
+    /**
+     * The number of multisample buffers used by this context.
+     * During context creation, this specifies the minimum
+     * number of multisample buffers requested.
+     */
+    public int sampleBuffers;
+
+    /**
+     * The number of samples accepted in the multisample buffer.
+     * During creation, pixel formats with the smallest number of
+     * samples that meets or exceeds the specified minimum number
+     * are preferred.
+     */
+    public int samples;
+    
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the data
+ */
+public String toString() {
+    return (doubleBuffer ? "doubleBuffer," : "") +
+        (stereo ? "stereo," : "") +
+        "r:" + redSize + " g:" + greenSize + " b:" + blueSize + " a:" + alphaSize + "," +
+        "depth:" + depthSize + ",stencil:" + stencilSize +
+        ",accum r:" + accumRedSize + "g:" + accumGreenSize + "b:" + accumBlueSize + "a:" + accumAlphaSize +
+        ",sampleBuffers:" + sampleBuffers + ",samples:" + samples;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/printing/PrintDialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,341 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.printing.PrintDialog;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSPrintInfo;
+import dwt.internal.cocoa.NSPrintPanel;
+import dwt.widgets.Dialog;
+import dwt.widgets.Shell;
+import dwt.widgets.Widget;
+
+/**
+ * Instances of this class allow the user to select
+ * a printer and various print-related parameters
+ * prior to starting a print job.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class PrintDialog extends Dialog {
+    PrinterData printerData;
+    int scope = PrinterData.ALL_PAGES;
+    int startPage = 1, endPage = 1;
+    bool printToFile = false;
+
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public PrintDialog (Shell parent) {
+    this (parent, DWT.PRIMARY_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public PrintDialog (Shell parent, int style) {
+    super (parent, style);
+    checkSubclass ();
+}
+
+/**
+ * Sets the printer data that will be used when the dialog
+ * is opened.
+ * 
+ * @param data the data that will be used when the dialog is opened
+ * 
+ * @since 3.4
+ */
+public void setPrinterData(PrinterData data) {
+    this.printerData = data;
+}
+
+/**
+ * Returns the printer data that will be used when the dialog
+ * is opened.
+ * 
+ * @return the data that will be used when the dialog is opened
+ * 
+ * @since 3.4
+ */
+public PrinterData getPrinterData() {
+    return printerData;
+}
+
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return a printer data object describing the desired print job parameters
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public PrinterData open() {
+    NSPrintPanel panel = NSPrintPanel.printPanel();
+    NSPrintInfo printInfo =(NSPrintInfo)new NSPrintInfo().alloc();
+    printInfo.initWithDictionary(null);
+    panel.runModalWithPrintInfo(printInfo);
+    printInfo.release();
+//  int[] buffer = new int[1];
+//  if (OS.PMCreateSession(buffer) is OS.noErr) {
+//      int printSession = buffer[0];
+//      if (OS.PMCreatePrintSettings(buffer) is OS.noErr) {
+//          int printSettings = buffer[0];
+//          OS.PMSessionDefaultPrintSettings(printSession, printSettings);
+//          if (OS.PMCreatePageFormat(buffer) is OS.noErr) {
+//              int pageFormat = buffer[0];
+//              OS.PMSessionDefaultPageFormat(printSession, pageFormat);
+//              OS.PMSessionSetDestination(printSession, printSettings, (short) (printToFile ? OS.kPMDestinationFile : OS.kPMDestinationPrinter), 0, 0);
+//              if (scope is PrinterData.PAGE_RANGE) {
+//                  OS.PMSetFirstPage(printSettings, startPage, false);
+//                  OS.PMSetLastPage(printSettings, endPage, false);
+//                  OS.PMSetPageRange(printSettings, startPage, endPage);
+//              } else {
+//                  OS.PMSetPageRange(printSettings, 1, OS.kPMPrintAllPages);
+//              }
+//              bool[] accepted = new bool [1];
+//              OS.PMSessionPageSetupDialog(printSession, pageFormat, accepted);    
+//              if (accepted[0]) {      
+//                  OS.PMSessionPrintDialog(printSession, printSettings, pageFormat, accepted);
+//                  if (accepted[0]) {
+//                      short[] destType = new short[1];
+//                      OS.PMSessionGetDestinationType(printSession, printSettings, destType);
+//                      String name = Printer.getCurrentPrinterName(printSession);
+//                      String driver = Printer.DRIVER;
+//                      switch (destType[0]) {
+//                          case OS.kPMDestinationFax: driver = Printer.FAX_DRIVER; break;
+//                          case OS.kPMDestinationFile: driver = Printer.FILE_DRIVER; break;
+//                          case OS.kPMDestinationPreview: driver = Printer.PREVIEW_DRIVER; break;
+//                          case OS.kPMDestinationPrinter: driver = Printer.PRINTER_DRIVER; break;
+//                      }
+//                      PrinterData data = new PrinterData(driver, name);
+//                      if (destType[0] is OS.kPMDestinationFile) {
+//                          data.printToFile = true;
+//                          OS.PMSessionCopyDestinationLocation(printSession, printSettings, buffer);
+//                          int fileName = OS.CFURLCopyFileSystemPath(buffer[0],OS.kCFURLPOSIXPathStyle);
+//                          OS.CFRelease(buffer[0]);
+//                          data.fileName = Printer.getString(fileName);
+//                          OS.CFRelease(fileName);
+//                      }
+//                      OS.PMGetCopies(printSettings, buffer);
+//                      data.copyCount = buffer[0];                     
+//                      OS.PMGetFirstPage(printSettings, buffer);
+//                      data.startPage = buffer[0];
+//                      OS.PMGetLastPage(printSettings, buffer);
+//                      data.endPage = buffer[0];
+//                      OS.PMGetPageRange(printSettings, null, buffer);
+//                      if (data.startPage is 1 && data.endPage is OS.kPMPrintAllPages) {
+//                          data.scope = PrinterData.ALL_PAGES;
+//                      } else {
+//                          data.scope = PrinterData.PAGE_RANGE;
+//                      }
+//                      bool[] collate = new bool[1];
+//                      OS.PMGetCollate(printSettings, collate);
+//                      data.collate = collate[0];
+//                      
+//                      /* Serialize settings */
+//                      int[] flatSettings = new int[1];
+//                      OS.PMFlattenPrintSettings(printSettings, flatSettings);
+//                      int[] flatFormat = new int[1];
+//                      OS.PMFlattenPageFormat(pageFormat, flatFormat);
+//                      int settingsLength = OS.GetHandleSize (flatSettings[0]);
+//                      int formatLength = OS.GetHandleSize (flatFormat[0]);
+//                      byte[] otherData = data.otherData = new byte[settingsLength + formatLength + 8];
+//                      int offset = 0;
+//                      offset = Printer.packData(flatSettings[0], otherData, offset);
+//                      offset = Printer.packData(flatFormat[0], otherData, offset);
+//                      OS.DisposeHandle(flatSettings[0]);
+//                      OS.DisposeHandle(flatFormat[0]);
+//                      
+//                      scope = data.scope;
+//                      startPage = data.startPage;
+//                      endPage = data.endPage;
+//                      printToFile = data.printToFile;
+//                      return data;
+//                  }
+//              }
+//              OS.PMRelease(pageFormat);
+//          }
+//          OS.PMRelease(printSettings);
+//      }
+//      OS.PMRelease(printSession);
+//  }
+    return null;
+}
+
+/**
+ * Returns the print job scope that the user selected
+ * before pressing OK in the dialog. This will be one
+ * of the following values:
+ * <dl>
+ * <dt><code>ALL_PAGES</code></dt>
+ * <dd>Print all pages in the current document</dd>
+ * <dt><code>PAGE_RANGE</code></dt>
+ * <dd>Print the range of pages specified by startPage and endPage</dd>
+ * <dt><code>SELECTION</code></dt>
+ * <dd>Print the current selection</dd>
+ * </dl>
+ *
+ * @return the scope setting that the user selected
+ */
+public int getScope() {
+    return scope;
+}
+
+/**
+ * Sets the scope of the print job. The user will see this
+ * setting when the dialog is opened. This can have one of
+ * the following values:
+ * <dl>
+ * <dt><code>ALL_PAGES</code></dt>
+ * <dd>Print all pages in the current document</dd>
+ * <dt><code>PAGE_RANGE</code></dt>
+ * <dd>Print the range of pages specified by startPage and endPage</dd>
+ * <dt><code>SELECTION</code></dt>
+ * <dd>Print the current selection</dd>
+ * </dl>
+ *
+ * @param scope the scope setting when the dialog is opened
+ */
+public void setScope(int scope) {
+    this.scope = scope;
+}
+
+/**
+ * Returns the start page setting that the user selected
+ * before pressing OK in the dialog.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PAGE_RANGE</code>.
+ * </p>
+ *
+ * @return the start page setting that the user selected
+ */
+public int getStartPage() {
+    return startPage;
+}
+
+/**
+ * Sets the start page that the user will see when the dialog
+ * is opened.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PAGE_RANGE</code>.
+ * </p>
+ * 
+ * @param startPage the startPage setting when the dialog is opened
+ */
+public void setStartPage(int startPage) {
+    this.startPage = startPage;
+}
+
+/**
+ * Returns the end page setting that the user selected
+ * before pressing OK in the dialog.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PAGE_RANGE</code>.
+ * </p>
+ *
+ * @return the end page setting that the user selected
+ */
+public int getEndPage() {
+    return endPage;
+}
+
+/**
+ * Sets the end page that the user will see when the dialog
+ * is opened.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PAGE_RANGE</code>.
+ * </p>
+ * 
+ * @param endPage the end page setting when the dialog is opened
+ */
+public void setEndPage(int endPage) {
+    this.endPage = endPage;
+}
+
+/**
+ * Returns the 'Print to file' setting that the user selected
+ * before pressing OK in the dialog.
+ *
+ * @return the 'Print to file' setting that the user selected
+ */
+public bool getPrintToFile() {
+    return printToFile;
+}
+
+/**
+ * Sets the 'Print to file' setting that the user will see
+ * when the dialog is opened.
+ *
+ * @param printToFile the 'Print to file' setting when the dialog is opened
+ */
+public void setPrintToFile(bool printToFile) {
+    this.printToFile = printToFile;
+}
+
+protected void checkSubclass() {
+    String name = getClass().getName();
+    String validName = PrintDialog.class.getName();
+    if (!validName.equals(name)) {
+        DWT.error(DWT.ERROR_INVALID_SUBCLASS);
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/printing/Printer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,609 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.printing.Printer;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.graphics.Device;
+import dwt.graphics.DeviceData;
+import dwt.graphics.GCData;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSPrinter;
+import dwt.internal.cocoa.NSString;
+
+/**
+ * Instances of this class are used to print to a printer.
+ * Applications create a GC on a printer using <code>new GC(printer)</code>
+ * and then draw on the printer GC using the usual graphics calls.
+ * <p>
+ * A <code>Printer</code> object may be constructed by providing
+ * a <code>PrinterData</code> object which identifies the printer.
+ * A <code>PrintDialog</code> presents a print dialog to the user
+ * and returns an initialized instance of <code>PrinterData</code>.
+ * Alternatively, calling <code>new Printer()</code> will construct a
+ * printer object for the user's default printer.
+ * </p><p>
+ * Application code must explicitly invoke the <code>Printer.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see PrinterData
+ * @see PrintDialog
+ */
+public final class Printer extends Device {
+    PrinterData data;
+    NSPrinter printer;
+    bool inPage, isGCCreated;
+
+    static final String DRIVER = "Mac";
+    static final String PRINTER_DRIVER = "Printer";
+    static final String FILE_DRIVER = "File";
+    static final String PREVIEW_DRIVER = "Preview";
+    static final String FAX_DRIVER = "Fax";
+
+/**
+ * Returns an array of <code>PrinterData</code> objects
+ * representing all available printers.
+ *
+ * @return the list of available printers
+ */
+public static PrinterData[] getPrinterList() {
+    NSArray printers = NSPrinter.printerNames();
+    int count = printers.count();
+    PrinterData[] result = new PrinterData[count];
+    for (int i = 0; i < count; i++) {
+        NSString str = new NSString(printers.objectAtIndex(i));
+        char[] buffer = new char[str.length()];
+        str.getCharacters_(buffer);
+        result[i] = new PrinterData(DRIVER, new String(buffer));
+    }
+    return result;
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing
+ * the default printer or <code>null</code> if there is no 
+ * printer available on the System.
+ *
+ * @return the default printer data or null
+ * 
+ * @since 2.1
+ */
+public static PrinterData getDefaultPrinterData() {
+    //TODO - get default
+    PrinterData[] printers = getPrinterList();
+    if (printers.length > 0) return printers[0];
+    return null;
+}
+//static int packData(int handle, byte[] buffer, int offset) {
+//  int length = OS.GetHandleSize (handle);
+//  buffer[offset++] = (byte)((length & 0xFF) >> 0);
+//  buffer[offset++] = (byte)((length & 0xFF00) >> 8);
+//  buffer[offset++] = (byte)((length & 0xFF0000) >> 16);
+//  buffer[offset++] = (byte)((length & 0xFF000000) >> 24);
+//  int [] ptr = new int [1];
+//  OS.HLock(handle);
+//  OS.memmove(ptr, handle, 4);
+//  byte[] buffer1 = new byte[length];
+//  OS.memmove(buffer1, ptr [0], length);
+//  OS.HUnlock(handle);
+//  System.arraycopy(buffer1, 0, buffer, offset, length);
+//  return offset + length;
+//}
+//static int unpackData(int[] handle, byte[] buffer, int offset) {
+//  int length = 
+//      ((buffer[offset++] & 0xFF) << 0) |
+//      ((buffer[offset++] & 0xFF) << 8) |
+//      ((buffer[offset++] & 0xFF) << 16) |
+//      ((buffer[offset++] & 0xFF) << 24);
+//  handle[0] = OS.NewHandle(length);
+//  if (handle[0] is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+//  int[] ptr = new int[1];
+//  OS.HLock(handle[0]);
+//  OS.memmove(ptr, handle[0], 4);
+//  byte[] buffer1 = new byte[length];
+//  System.arraycopy(buffer, offset, buffer1, 0, length);
+//  OS.memmove(ptr[0], buffer1, length);
+//  OS.HUnlock(handle[0]);
+//  return offset + length;
+//}
+
+/**
+ * Constructs a new printer representing the default printer.
+ * <p>
+ * You must dispose the printer when it is no longer required. 
+ * </p>
+ *
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if there are no valid printers
+ * </ul>
+ *
+ * @see Device#dispose
+ */
+public Printer() {
+    this(null);
+}
+
+/**
+ * Constructs a new printer given a <code>PrinterData</code>
+ * object representing the desired printer.
+ * <p>
+ * You must dispose the printer when it is no longer required. 
+ * </p>
+ *
+ * @param data the printer data for the specified printer
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the specified printer data does not represent a valid printer
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if there are no valid printers
+ * </ul>
+ *
+ * @see Device#dispose
+ */
+public Printer(PrinterData data) {
+    super (checkNull(data));
+}
+
+/**
+ * Given a desired <em>client area</em> for the receiver
+ * (as described by the arguments), returns the bounding
+ * rectangle which would be required to produce that client
+ * area.
+ * <p>
+ * In other words, it returns a rectangle such that, if the
+ * receiver's bounds were set to that rectangle, the area
+ * of the receiver which is capable of displaying data
+ * (that is, not covered by the "trimmings") would be the
+ * rectangle described by the arguments (relative to the
+ * receiver's parent).
+ * </p><p>
+ * Note that there is no setBounds for a printer. This method
+ * is usually used by passing in the client area (the 'printable
+ * area') of the printer. It can also be useful to pass in 0, 0, 0, 0.
+ * </p>
+ * 
+ * @param x the desired x coordinate of the client area
+ * @param y the desired y coordinate of the client area
+ * @param width the desired width of the client area
+ * @param height the desired height of the client area
+ * @return the required bounds to produce the given client area
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
+ * @see #getClientArea
+ */
+public Rectangle computeTrim(int x, int y, int width, int height) {
+    checkDevice();
+//  PMRect pageRect = new PMRect();
+//  PMRect paperRect = new PMRect();
+//  OS.PMGetAdjustedPageRect(pageFormat, pageRect);
+//  OS.PMGetAdjustedPaperRect(pageFormat, paperRect);
+//  return new Rectangle(x+(int)paperRect.left, y+(int)paperRect.top, width+(int)(paperRect.right-pageRect.right), height+(int)(paperRect.bottom-pageRect.bottom));
+    return null;
+}
+
+/**  
+ * Creates the printer handle.
+ * This method is called internally by the instance creation
+ * mechanism of the <code>Device</code> class.
+ * @param deviceData the device data
+ */
+protected void create(DeviceData deviceData) {
+    data = (PrinterData)deviceData;
+    
+    printer = NSPrinter.static_printerWithName_(NSString.stringWith(data.name));
+    printer.retain();
+    
+//  int[] buffer = new int[1];
+//  if (OS.PMCreateSession(buffer) !is OS.noErr) DWT.error(DWT.ERROR_NO_HANDLES);
+//  printSession = buffer[0];
+//  if (printSession is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+//      
+//  if (data.otherData !is null) {
+//      /* Deserialize settings */
+//      int offset = 0;
+//      byte[] otherData = data.otherData;
+//      offset = unpackData(buffer, otherData, offset);
+//      int flatSettings = buffer[0];
+//      offset = unpackData(buffer, otherData, offset);
+//      int flatFormat = buffer[0];
+//      if (OS.PMUnflattenPrintSettings(flatSettings, buffer) !is OS.noErr) DWT.error(DWT.ERROR_NO_HANDLES);
+//      printSettings = buffer[0];
+//      if (printSettings is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+//      if (OS.PMUnflattenPageFormat(flatFormat, buffer) !is OS.noErr) DWT.error(DWT.ERROR_NO_HANDLES);
+//      pageFormat = buffer[0];
+//      if (pageFormat is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+//      OS.DisposeHandle(flatSettings);
+//      OS.DisposeHandle(flatFormat);
+//  } else {
+//      /* Create default settings */
+//      if (OS.PMCreatePrintSettings(buffer) !is OS.noErr) DWT.error(DWT.ERROR_NO_HANDLES);
+//      printSettings = buffer[0];
+//      if (printSettings is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+//      OS.PMSessionDefaultPrintSettings(printSession, printSettings);
+//      if (OS.PMCreatePageFormat(buffer) !is OS.noErr) DWT.error(DWT.ERROR_NO_HANDLES);
+//      pageFormat = buffer[0];
+//      if (pageFormat is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+//      OS.PMSessionDefaultPageFormat(printSession, pageFormat);
+//  }
+//  
+//  if (PREVIEW_DRIVER.equals(data.driver)) {
+//      OS.PMSessionSetDestination(printSession, printSettings, (short) OS.kPMDestinationPreview, 0, 0);
+//  }
+//  String name = data.name;
+//  char[] buffer1 = new char[name.length ()];
+//  name.getChars(0, buffer1.length, buffer1, 0);
+//  int ptr = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, buffer1, buffer1.length);
+//  if (ptr !is 0) {
+//      OS.PMSessionSetCurrentPrinter(printSession, ptr); 
+//      OS.CFRelease(ptr);
+//  }
+//  
+//  OS.PMSessionValidatePrintSettings(printSession, printSettings, null);
+//  OS.PMSessionValidatePageFormat(printSession, pageFormat, null); 
+//  
+//  int graphicsContextsArray = OS.CFArrayCreateMutable(OS.kCFAllocatorDefault, 1, 0);
+//  if (graphicsContextsArray !is 0) {
+//      OS.CFArrayAppendValue(graphicsContextsArray, OS.kPMGraphicsContextCoreGraphics());
+//      OS.PMSessionSetDocumentFormatGeneration(printSession, OS.kPMDocumentFormatPDF(), graphicsContextsArray, 0);
+//      OS.CFRelease(graphicsContextsArray);
+//  }
+}
+
+/**  
+ * Destroys the printer handle.
+ * This method is called internally by the dispose
+ * mechanism of the <code>Device</code> class.
+ */
+protected void destroy() {
+    if (printer !is null) printer.release();
+    printer = null;
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Printer</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public int internal_new_GC(GCData data) {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    setupNewPage();
+//  if (data !is null) {
+//      if (isGCCreated) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+//      data.device = this;
+//      data.background = getSystemColor(DWT.COLOR_WHITE).handle;
+//      data.foreground = getSystemColor(DWT.COLOR_BLACK).handle;
+//      data.font = getSystemFont ();
+//      PMRect paperRect= new PMRect();
+//      OS.PMGetAdjustedPaperRect(pageFormat, paperRect);
+//      Rect portRect = new Rect();
+//      portRect.left = (short)paperRect.left;
+//      portRect.right = (short)paperRect.right;
+//      portRect.top = (short)paperRect.top;
+//      portRect.bottom = (short)paperRect.bottom;
+//      data.portRect = portRect;
+//      isGCCreated = true;
+//  }
+//  return context;
+    return 0;
+}
+
+protected void init () {
+    super.init();
+}
+
+/**  
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Printer</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC(int context, GCData data) {
+    if (data !is null) isGCCreated = false;
+}
+
+/**  
+ * Releases any internal state prior to destroying this printer.
+ * This method is called internally by the dispose
+ * mechanism of the <code>Device</code> class.
+ */
+protected void release () {
+    super.release();
+}
+
+/**
+ * Starts a print job and returns true if the job started successfully
+ * and false otherwise.
+ * <p>
+ * This must be the first method called to initiate a print job,
+ * followed by any number of startPage/endPage calls, followed by
+ * endJob. Calling startPage, endPage, or endJob before startJob
+ * will result in undefined behavior.
+ * </p>
+ * 
+ * @param jobName the name of the print job to start
+ * @return true if the job started successfully and false otherwise.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #startPage
+ * @see #endPage
+ * @see #endJob
+ */
+public bool startJob(String jobName) {
+    checkDevice();
+//  if (jobName !is null && jobName.length() !is 0) {
+//      char[] buffer = new char[jobName.length ()];
+//      jobName.getChars(0, buffer.length, buffer, 0);
+//      int ptr = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, buffer, buffer.length);
+//      if (ptr !is 0) {
+//          OS.PMSetJobNameCFString(printSettings, ptr); 
+//          OS.CFRelease (ptr);
+//      }
+//  }
+//  return OS.PMSessionBeginDocumentNoDialog(printSession, printSettings, pageFormat) is OS.noErr;
+    return false;
+}
+
+/**
+ * Ends the current print job.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #startJob
+ * @see #startPage
+ * @see #endPage
+ */
+public void endJob() {
+    checkDevice();
+//  if (inPage) {
+//      OS.PMSessionEndPageNoDialog(printSession);
+//      inPage = false;
+//  }
+//  OS.PMSessionEndDocumentNoDialog(printSession);
+//  context = 0;
+}
+
+/**
+ * Cancels a print job in progress. 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void cancelJob() {
+    checkDevice();
+//  OS.PMSessionSetError(printSession, OS.kPMCancel);
+//  if (inPage) {
+//      OS.PMSessionEndPageNoDialog(printSession);
+//      inPage = false;
+//  }
+//  OS.PMSessionEndDocumentNoDialog(printSession);
+//  context = 0;
+}
+
+static DeviceData checkNull (PrinterData data) {
+    if (data is null) data = new PrinterData();
+    if (data.driver is null || data.name is null) {
+        PrinterData defaultPrinter = getDefaultPrinterData();
+        if (defaultPrinter is null) DWT.error(DWT.ERROR_NO_HANDLES);
+        data.driver = defaultPrinter.driver;
+        data.name = defaultPrinter.name;        
+    }
+    return data;
+}
+
+/**
+ * Starts a page and returns true if the page started successfully
+ * and false otherwise.
+ * <p>
+ * After calling startJob, this method may be called any number of times
+ * along with a matching endPage.
+ * </p>
+ * 
+ * @return true if the page started successfully and false otherwise.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #endPage
+ * @see #startJob
+ * @see #endJob
+ */
+public bool startPage() {
+    checkDevice();
+//  if (OS.PMSessionError(printSession) !is OS.noErr) return false;
+//  setupNewPage();
+//  return context !is 0;
+    return false;
+}
+
+/**
+ * Ends the current page.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #startPage
+ * @see #startJob
+ * @see #endJob
+ */
+public void endPage() {
+    checkDevice();
+//  if (inPage) {
+//      OS.PMSessionEndPageNoDialog(printSession);
+//      inPage = false;
+//  }
+}
+
+/**
+ * Returns a point whose x coordinate is the horizontal
+ * dots per inch of the printer, and whose y coordinate
+ * is the vertical dots per inch of the printer.
+ *
+ * @return the horizontal and vertical DPI
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point getDPI() {
+    checkDevice();
+//  PMResolution resolution = new PMResolution();
+//  OS.PMGetResolution(pageFormat, resolution);
+//  return new Point((int)resolution.hRes, (int)resolution.vRes);
+    return null;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ * For a printer, this is the size of a physical page, in pixels.
+ *
+ * @return the bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getClientArea
+ * @see #computeTrim
+ */
+public Rectangle getBounds() {
+    checkDevice();
+//  PMRect paperRect = new PMRect();
+//  OS.PMGetAdjustedPaperRect(pageFormat, paperRect);
+//  return new Rectangle(0, 0, (int)(paperRect.right-paperRect.left), (int)(paperRect.bottom-paperRect.top));
+    return null;
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * For a printer, this is the size of the printable area
+ * of a page, in pixels.
+ * 
+ * @return the client area
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
+ * @see #computeTrim
+ */
+public Rectangle getClientArea() {
+    checkDevice();
+//  PMRect pageRect = new PMRect();
+//  OS.PMGetAdjustedPageRect(pageFormat, pageRect);
+//  return new Rectangle(0, 0, (int)(pageRect.right-pageRect.left), (int)(pageRect.bottom-pageRect.top));
+    return null;
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing the
+ * target printer for this print job.
+ * 
+ * @return a PrinterData object describing the receiver
+ */
+public PrinterData getPrinterData() {
+    checkDevice();
+    return data;
+}
+
+/**
+ * On the Mac the core graphics context for printing is only valid between PMSessionBeginPage and PMSessionEndPage,
+ * so printing code has to retrieve and initializes a graphic context for every page like this:
+ * 
+ * <pre>
+ * PMSessionBeginDocument
+ *    PMSessionBeginPage
+ *       PMSessionGetGraphicsContext
+ *       // ... use context
+ *    PMSessionEndPage
+ * PMSessionEndDocument
+ * </pre>
+ * 
+ * In DWT it is OK to create a GC once between startJob / endJob and use it for all pages in between:
+ * 
+ * <pre>
+ * startJob(...);
+ *    GC gc= new GC(printer);
+ *    startPage();
+ *       // ... use gc
+ *    endPage();
+ *    gc.dispose();
+ * endJob();
+ * </pre>
+ * 
+ * The solution to resolve this difference is to rely on the fact that Mac OS X returns the same but
+ * reinitialized graphics context for every page. So we only have to account for the fact that DWT assumes
+ * that the graphics context keeps it settings across a page break when it actually does not.
+ * So we have to copy some settings that exist in the CGC before a PMSessionEndPage to the CGC after a PMSessionBeginPage.
+ * <p>
+ * In addition to this we have to cope with the situation that in DWT we can create a GC before a call to
+ * PMSessionBeginPage. For this we decouple the call to PMSessionBeginPage from
+ * DWT's method startPage as follows: if a new GC is created before a call to startPage, internal_new_GC
+ * does the PMSessionBeginPage and the next following startPage does nothing.
+ * </p>
+ */
+void setupNewPage() {
+//  if (!inPage) {
+//      inPage= true;
+//      OS.PMSessionBeginPageNoDialog(printSession, pageFormat, null);
+//      int[] buffer = new int[1];
+//      OS.PMSessionGetGraphicsContext(printSession, 0, buffer);
+//      if (context is 0) {
+//          context = buffer[0];
+//      } else {
+//          if (context !is buffer[0]) DWT.error(DWT.ERROR_UNSPECIFIED);
+//      }
+//      PMRect paperRect= new PMRect();
+//      OS.PMGetAdjustedPaperRect(pageFormat, paperRect);
+//      OS.CGContextScaleCTM(context, 1, -1);
+//      OS.CGContextTranslateCTM(context, 0, -(float)(paperRect.bottom-paperRect.top));
+//      OS.CGContextSetStrokeColorSpace(context, colorspace);
+//      OS.CGContextSetFillColorSpace(context, colorspace);
+//  }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/printing/PrinterData.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.printing.PrinterData;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.graphics.DeviceData;
+
+/**
+ * Instances of this class are descriptions of a print job
+ * in terms of the printer, and the scope and type of printing
+ * that is desired. For example, the number of pages and copies
+ * can be specified, as well as whether or not the print job
+ * should go to a file.
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Printer
+ * @see Printer#getPrinterList
+ * @see PrintDialog#open
+ */
+
+public final class PrinterData extends DeviceData {
+    
+    /**
+     * the printer driver
+     * On Windows systems, this is the name of the driver (often "winspool").
+     * On Mac OSX, this is the destination type ("Printer", "Fax", "File", or "Preview").
+     * On X/Window systems, this is the name of a display connection to the
+     * Xprt server (the default is ":1").
+     * On GTK+, this is the backend type name (eg. GtkPrintBackendCups).
+     */
+    // TODO: note that this api is not finalized for GTK+
+    public String driver;
+    
+    /**
+     * the name of the printer
+     * On Windows systems, this is the name of the 'device'.
+     * On Mac OSX, X/Window systems, and GTK+, this is the printer's 'name'.
+     */
+    public String name;
+    
+    /**
+     * the scope of the print job, expressed as one of the following values:
+     * <dl>
+     * <dt><code>ALL_PAGES</code></dt>
+     * <dd>Print all pages in the current document</dd>
+     * <dt><code>PAGE_RANGE</code></dt>
+     * <dd>Print the range of pages specified by startPage and endPage</dd>
+     * <dt><code>SELECTION</code></dt>
+     * <dd>Print the current selection</dd>
+     * </dl>
+     */
+    public int scope = ALL_PAGES;
+    
+    /**
+     * the start page of a page range, used when scope is PAGE_RANGE.
+     * This value can be from 1 to the maximum number of pages for the platform.
+     */
+    public int startPage = 0;
+
+    /**
+     * the end page of a page range, used when scope is PAGE_RANGE.
+     * This value can be from 1 to the maximum number of pages for the platform.
+     */
+    public int endPage = 0;
+    
+    /**
+     * whether or not the print job should go to a file
+     */
+    public bool printToFile = false;
+    
+    /**
+     * the name of the file to print to if printToFile is true.
+     * Note that this field is ignored if printToFile is false.
+     */
+    public String fileName;
+    
+    /**
+     * the number of copies to print.
+     * Note that this field may be controlled by the printer driver
+     * In other words, the printer itself may be capable of printing
+     * multiple copies, and if so, the value of this field will always be 1.
+     */
+    public int copyCount = 1;
+    
+    /**
+     * whether or not the printer should collate the printed paper
+     * Note that this field may be controlled by the printer driver.
+     * In other words, the printer itself may be capable of doing the
+     * collation, and if so, the value of this field will always be false.
+     */
+    public bool collate = false;
+    
+    /**
+     * <code>scope</code> field value indicating that
+     * all pages should be printed
+     */ 
+    public static final int ALL_PAGES = 0;
+    
+    /**
+     * <code>scope</code> field value indicating that
+     * the range of pages specified by startPage and endPage
+     * should be printed
+     */ 
+    public static final int PAGE_RANGE = 1;
+    
+    /**
+     * <code>scope</code> field value indicating that
+     * the current selection should be printed
+     */ 
+    public static final int SELECTION = 2;
+    
+    /**
+     * private, platform-specific data
+     * On Windows, this contains a copy of the DEVMODE struct
+     * returned from the <code>PrintDialog</code>.
+     * On GTK, this contains a copy of the print_settings and page_setup
+     * returned from the <code>PrintDialog</code>.
+     * On OS X Carbon, this contains a copy of the PrintSettings and PageFormat
+     * returned from the <code>PrintDialog</code>.
+     * This field is not currently used on the X/Window System.
+     */ 
+    byte [] otherData;
+
+    /**
+     * Constructs an instance of this class that can be
+     * used to print to the default printer.
+     * 
+     * @see Printer#getDefaultPrinterData
+     */
+    public PrinterData() {
+    }
+
+    /**
+     * Constructs an instance of this class with the given
+     * printer driver and printer name.
+     *
+     * @param driver the printer driver for the printer
+     * @param name the name of the printer
+     *
+     * @see #driver
+     * @see #name
+     */
+    public PrinterData(String driver, String name) {
+        this.driver = driver;
+        this.name = name;
+    }
+
+    /**
+     * Returns a string containing a concise, human-readable
+     * description of the receiver.
+     *
+     * @return a string representation of the receiver
+     */
+    public String toString() {
+        return "PrinterData {" + "driver = " + driver + ", name = " + name + "}";  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/program/Program.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,551 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.program.Program;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.graphics.ImageData;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.NSWorkspace;
+
+/**
+ * Instances of this class represent programs and
+ * their associated file extensions in the operating
+ * system.
+ */
+public final class Program {
+    String name;
+    byte[] fsRef;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Program () {
+}
+
+/**
+ * Finds the program that is associated with an extension.
+ * The extension may or may not begin with a '.'.  Note that
+ * a <code>Display</code> must already exist to guarantee that
+ * this method returns an appropriate result.
+ *
+ * @param extension the program extension
+ * @return the program or <code>null</code>
+ *
+ * @exception IllegalArgumentException <ul>
+ *      <li>ERROR_NULL_ARGUMENT when extension is null</li>
+ *  </ul>
+ */
+public static Program findProgram (String extension) {
+    if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    if (extension.length () is 0) return null;
+//  char[] chars;
+//  if (extension.charAt (0) !is '.') {
+//      chars = new char[extension.length()];
+//      extension.getChars(0, chars.length, chars, 0);
+//  } else {
+//      chars = new char[extension.length() - 1];
+//      extension.getChars(1, extension.length(), chars, 0);        
+//  }
+//  int ext = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, chars.length);
+//  Program program = null;
+//  if (ext !is 0) {
+//      byte[] fsRef = new byte[80];
+//      if (OS.LSGetApplicationForInfo(OS.kLSUnknownType, OS.kLSUnknownCreator, ext, OS.kLSRolesAll, fsRef, null) is OS.noErr) {
+//          program = getProgram(fsRef);
+//      }
+//      OS.CFRelease(ext);
+//  }
+//  return program;
+    return null;
+}
+
+/**
+ * Answer all program extensions in the operating system.  Note
+ * that a <code>Display</code> must already exist to guarantee
+ * that this method returns an appropriate result.
+ *
+ * @return an array of extensions
+ */
+public static String [] getExtensions () {
+    return new String [] {
+        // From System-Declared Uniform Type Identifiers
+        ".txt",
+        ".rtf",
+        ".html",
+        ".htm",
+        ".xml",
+        ".c",
+        ".m",
+        ".cp", ".cpp", ".c++", ".cc", ".cxx",
+        ".mm",
+        ".h",
+        ".hpp",
+        ".h++",
+        ".hxx",
+        ".java",
+        ".jav",
+        ".s",
+        ".r",
+        ".defs",
+        ".mig",
+        ".exp",
+        ".js",
+        ".jscript",
+        ".javascript",
+        ".sh",
+        ".command",
+        ".csh",
+        ".pl",
+        ".pm",
+        ".py",
+        ".rb",
+        ".rbw",
+        ".php",
+        ".php3",
+        ".php4",
+        ".ph3",
+        ".ph4",
+        ".phtml",
+        ".jnlp",
+        ".applescript",
+        ".scpt",
+        ".o",
+        ".exe",
+        ".dll",
+        ".class",
+        ".jar",
+        ".qtz",
+        ".gtar",
+        ".tar",
+        ".gz",
+        ".gzip",
+        ".tgz",
+        ".hqx",
+        ".bin",
+        ".vcf",
+        ".vcard",
+        ".jpg",
+        ".jpeg",
+        ".jp2",
+        ".tif",
+        ".tiff",
+        ".pic",
+        ".pct",
+        ".pict",
+        ".pntg",
+        ".png",
+        ".xbm",
+        ".qif",
+        ".qtif",
+        ".icns",
+        ".mov",
+        ".qt",
+        ".avi",
+        ".vfw",
+        ".mpg",
+        ".mpeg",
+        ".m75",
+        ".m15",
+        ".mp4",
+        ".3gp",
+        ".3gpp",
+        ".3g2",
+        ".3gp2",
+        ".mp3",
+        ".m4a",
+        ".m4p",
+        ".m4b",
+        ".au",
+        ".ulw",
+        ".snd",
+        ".aifc",
+        ".aiff",
+        ".aif",
+        ".caf",
+        ".bundle",
+        ".app",
+        ".plugin",
+        ".mdimporter",
+        ".wdgt",
+        ".cpio",
+        ".zip",
+        ".framework",
+        ".rtfd",
+        ".dfont",
+        ".otf",
+        ".ttf",
+        ".ttc",
+        ".suit",
+        ".pfb",
+        ".pfa",
+        ".icc",
+        ".icm",
+        ".pf",
+        ".pdf",
+        ".ps",
+        ".eps",
+        ".psd",
+        ".ai",
+        ".gif",
+        ".bmp",
+        ".ico",
+        ".doc",
+        ".xls",
+        ".ppt",
+        ".wav",
+        ".wave",
+        ".asf",
+        ".wm",
+        ".wmv",
+        ".wmp",
+        ".wma",
+        ".asx",
+        ".wmx",
+        ".wvx",
+        ".wax",
+        ".key",
+        ".kth",
+        ".tga",
+        ".sgi",
+        ".exr",
+        ".fpx",
+        ".jfx",
+        ".efx",
+        ".sd2",
+        ".rm",
+        ".ram",
+        ".ra",
+        ".smil",
+        ".sit",
+        ".sitx",
+        // Others
+        ".plist",
+        ".nib",
+        ".lproj",
+        // iChat
+        ".iPhoto",
+        // iChat
+        ".iChat",
+        ".chat",
+        // acrobat reader
+        ".rmf",
+        ".xfdf",
+        ".fdf",
+        // Chess
+        ".game",
+        ".pgn",
+        // iCal
+        ".ics",
+        ".vcs",
+        ".aplmodel",
+        ".icbu",
+        ".icalevent",
+        ".icaltodo",
+        // Mail
+        ".mailhold",
+        ".mbox",
+        ".imapmbox",
+        ".emlx",
+        ".mailextract",
+        // Sherlock
+        ".sherlock",
+        // Stickies
+        ".tpl",
+        // System Preferences
+        ".prefPane",
+        ".sliderSaver",
+        ".saver",
+        // Console
+        ".log",
+        // Grapher
+        ".gcx",
+    };
+}
+
+/**
+ * Answers all available programs in the operating system.  Note
+ * that a <code>Display</code> must already exist to guarantee
+ * that this method returns an appropriate result.
+ *
+ * @return an array of programs
+ */
+public static Program [] getPrograms () {
+    return new Program[0];
+//  Hashtable bundles = new Hashtable();
+//  String[] extensions = getExtensions();
+//  byte[] fsRef = new byte[80];
+//  for (int i = 0; i < extensions.length; i++) {
+//      String extension = extensions[i];
+//      char[] chars = new char[extension.length() - 1];
+//      extension.getChars(1, extension.length(), chars, 0);
+//      int ext = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, chars.length);
+//      if (ext !is 0) {
+//          if (OS.LSGetApplicationForInfo(OS.kLSUnknownType, OS.kLSUnknownCreator, ext, OS.kLSRolesAll, fsRef, null) is OS.noErr) {
+//              Program program = getProgram(fsRef);
+//              if (program !is null && bundles.get(program.getName()) is null) {
+//                  bundles.put(program.getName(), program);
+//                  fsRef = new byte[80];
+//              }
+//          }
+//          if (OS.VERSION >= 0x1040) {
+//              int utis = OS.UTTypeCreateAllIdentifiersForTag(OS.kUTTagClassFilenameExtension(), ext, 0);
+//              if (utis !is 0) {
+//                  int utiCount = OS.CFArrayGetCount(utis);
+//                  for (int j = 0; j < utiCount; j++) {
+//                      int uti = OS.CFArrayGetValueAtIndex(utis, j);
+//                      if (uti !is 0) {
+//                          int apps = OS.LSCopyAllRoleHandlersForContentType(uti, OS.kLSRolesAll);
+//                          if (apps !is 0) {
+//                              int appCount = OS.CFArrayGetCount(apps);
+//                              for (int k = 0; k < appCount; k++) {
+//                                  int app = OS.CFArrayGetValueAtIndex(apps, k);
+//                                  if (app !is 0) {;
+//                                      if (OS.LSFindApplicationForInfo(OS.kLSUnknownCreator, app, 0, fsRef, null) is OS.noErr) {
+//                                          Program program = getProgram(fsRef);
+//                                          if (program !is null && bundles.get(program.getName()) is null) {
+//                                              bundles.put(program.getName(), program);
+//                                              fsRef = new byte[80];
+//                                          }
+//                                      }
+//                                  }
+//                              }
+//                              OS.CFRelease(apps);
+//                          }
+//                      }
+//                  }
+//                  OS.CFRelease(utis);
+//              }
+//          }
+//          OS.CFRelease(ext);
+//      }
+//  }
+//  int count = 0;
+//  Program[] programs = new Program[bundles.size()];
+//  Enumeration values = bundles.elements();
+//  while (values.hasMoreElements()) {
+//      programs[count++] = (Program)values.nextElement();
+//  }
+//  return programs;
+}
+
+/**
+ * Launches the executable associated with the file in
+ * the operating system.  If the file is an executable,
+ * then the executable is launched.  Note that a <code>Display</code>
+ * must already exist to guarantee that this method returns
+ * an appropriate result.
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public static bool launch (String fileName) {
+    if (fileName is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    if (fileName.indexOf(':') is -1) fileName = "file://" + fileName;
+    NSWorkspace workspace = NSWorkspace.sharedWorkspace();
+    return workspace.openURL(NSURL.static_URLWithString_(NSString.stringWith(fileName)));
+}
+
+/**
+ * Executes the program with the file as the single argument
+ * in the operating system.  It is the responsibility of the
+ * programmer to ensure that the file contains valid data for 
+ * this program.
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public bool execute (String fileName) {
+    if (fileName is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+//  if (OS.VERSION < 0x1040) return launch(fileName);
+//  int rc = -1;
+//  int fsRefPtr = OS.NewPtr(fsRef.length);
+//  if (fsRefPtr !is 0) {
+//      OS.memmove(fsRefPtr, fsRef, fsRef.length);
+//      LSApplicationParameters params = new LSApplicationParameters();
+//      params.version = 0;
+//      params.flags = 0;
+//      params.application = fsRefPtr;
+//      if (fileName.length() is 0) {
+//          rc = OS.LSOpenApplication(params, null);
+//      } else {
+//          if (fileName.indexOf(':') is -1) fileName = "file://" + fileName;
+//          char[] chars = new char[fileName.length()];
+//          fileName.getChars(0, chars.length, chars, 0);
+//          int str = OS.CFStringCreateWithCharacters(0, chars, chars.length);
+//          if (str !is 0) {
+//              int unscapedStr = OS.CFStringCreateWithCharacters(0, new char[]{'%'}, 1);
+//              int escapedStr = OS.CFURLCreateStringByAddingPercentEscapes(OS.kCFAllocatorDefault, str, unscapedStr, 0, OS.kCFStringEncodingUTF8);
+//              if (escapedStr !is 0) {
+//                  int urls = OS.CFArrayCreateMutable(OS.kCFAllocatorDefault, 1, 0);
+//                  if (urls !is 0) {
+//                      int url = OS.CFURLCreateWithString(OS.kCFAllocatorDefault, escapedStr, 0);
+//                      if (url !is 0) {
+//                          OS.CFArrayAppendValue(urls, url);
+//                          rc = OS.LSOpenURLsWithRole(urls, OS.kLSRolesAll, 0, params, null, 0);
+//                      }
+//                      OS.CFRelease(urls);
+//                  }
+//                  OS.CFRelease(escapedStr);
+//              }
+//              if (unscapedStr !is 0) OS.CFRelease(unscapedStr);
+//              OS.CFRelease(str);
+//          }
+//      }
+//      OS.DisposePtr(fsRefPtr);
+//  }
+//  return rc is OS.noErr;
+    return false;
+}
+
+/**
+ * Returns the receiver's image data.  This is the icon
+ * that is associated with the receiver in the operating
+ * system.
+ *
+ * @return the image data for the program, may be null
+ */
+public ImageData getImageData () {
+//  int[] iconRef = new int[1];
+//  OS.GetIconRefFromFileInfo(fsRef, 0, null, 0, 0, 0, iconRef, null);
+//  int[] family = new int[1];
+//  int rc = OS.IconRefToIconFamily(iconRef[0], OS.kSelectorAlLAvailableData, family);
+//  OS.ReleaseIconRef(iconRef[0]);
+//  if (rc !is OS.noErr) return null;
+////    ImageData result = createImageFromFamily(family[0], OS.kLarge32BitData, OS.kLarge8BitMask, 32, 32);
+//  ImageData result = createImageFromFamily(family[0], OS.kSmall32BitData, OS.kSmall8BitMask, 16, 16);
+//  OS.DisposeHandle(family[0]);
+//  if (result is null) {
+//      RGB[] rgbs = new RGB[] {
+//          new RGB(0xff, 0xff, 0xff), 
+//          new RGB(0x5f, 0x5f, 0x5f),
+//          new RGB(0x80, 0x80, 0x80),
+//          new RGB(0xC0, 0xC0, 0xC0),
+//          new RGB(0xDF, 0xDF, 0xBF),
+//          new RGB(0xFF, 0xDF, 0x9F),
+//          new RGB(0x00, 0x00, 0x00),
+//      };  
+//      result = new ImageData(16, 16, 4, new PaletteData(rgbs) );
+//      result.transparentPixel = 6; // use black for transparency
+//      String[] p= {
+//          "CCCCCCCCGGG",
+//          "CFAAAAACBGG",
+//          "CAAAAAACFBG",
+//          "CAAAAAACBBB",
+//          "CAAAAAAAAEB",
+//          "CAAAAAAAAEB",
+//          "CAAAAAAAAEB",
+//          "CAAAAAAAAEB",
+//          "CAAAAAAAAEB",
+//          "CAAAAAAAAEB",
+//          "CAAAAAAAAEB",
+//          "CAAAAAAAAEB",
+//          "CDDDDDDDDDB",
+//          "CBBBBBBBBBB",
+//      };
+//      for (int y= 0; y < p.length; y++) {
+//          for (int x= 0; x < 11; x++) {
+//              result.setPixel(x+3, y+1, p[y].charAt(x)-'A');
+//          }
+//      }
+//  }
+//  return result;
+    return null;
+}
+
+/**
+ * Returns the receiver's name.  This is as short and
+ * descriptive a name as possible for the program.  If
+ * the program has no descriptive name, this string may
+ * be the executable name, path or empty.
+ *
+ * @return the name of the program
+ */
+public String getName () {
+    return name;
+}
+
+//static Program getProgram(byte[] fsRef) {
+//  String name = "";
+//  int[] namePtr = new int[1];
+//  OS.LSCopyDisplayNameForRef(fsRef, namePtr);
+//  if (namePtr[0] !is 0) {
+//      int length = OS.CFStringGetLength(namePtr[0]);
+//      if (length !is 0) {
+//          char[] buffer= new char[length];
+//          CFRange range = new CFRange();
+//          range.length = length;
+//          OS.CFStringGetCharacters(namePtr[0], range, buffer);
+//          name = new String(buffer);
+//      }
+//      OS.CFRelease(namePtr[0]);
+//  }
+//  Program program = new Program();
+//  program.fsRef = fsRef;
+//  program.name = name;
+//  return program;
+//}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param other the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public bool equals(Object other) {
+    if (this is other) return true;
+    if (other instanceof Program) {
+        final Program program = (Program) other;
+        return name.equals(program.name);
+    }
+    return false;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode() {
+    return name.hashCode();
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the program
+ */
+public String toString () {
+    return "Program {" + name + "}";
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Button.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,593 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Button;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Image;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSButton;
+import dwt.internal.cocoa.NSButtonCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSMutableParagraphStyle;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTButton;
+
+/**
+ * Instances of this class represent a selectable user interface object that
+ * issues notification when pressed and released. 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
+ * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE 
+ * may be specified.
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
+ * </p><p>
+ * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
+ * when the ARROW style is specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class Button extends Control {
+    String text = "";
+    Image image;
+    bool grayed;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#ARROW
+ * @see DWT#CHECK
+ * @see DWT#PUSH
+ * @see DWT#RADIO
+ * @see DWT#TOGGLE
+ * @see DWT#FLAT
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Button (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the control is selected by the user.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    style = checkBits (style, DWT.PUSH, DWT.ARROW, DWT.CHECK, DWT.RADIO, DWT.TOGGLE, 0);
+    if ((style & (DWT.PUSH | DWT.TOGGLE)) !is 0) {
+        return checkBits (style, DWT.CENTER, DWT.LEFT, DWT.RIGHT, 0, 0, 0);
+    }
+    if ((style & (DWT.CHECK | DWT.RADIO)) !is 0) {
+        return checkBits (style, DWT.LEFT, DWT.RIGHT, DWT.CENTER, 0, 0, 0);
+    }
+    if ((style & DWT.ARROW) !is 0) {
+        style |= DWT.NO_FOCUS;
+        return checkBits (style, DWT.UP, DWT.DOWN, DWT.LEFT, DWT.RIGHT, 0, 0);
+    }
+    return style;
+}
+
+void click () {
+    postEvent (DWT.Selection);
+}
+
+NSAttributedString createString() {
+    NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
+    if (foreground !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
+        dict.setObject(color, OS.NSForegroundColorAttributeName());
+    }
+    if (font !is null) {
+        dict.setObject(font.handle, OS.NSFontAttributeName());
+    }
+    int alignment;
+    if ((style & DWT.CENTER) !is 0) {
+        alignment = OS.NSCenterTextAlignment;
+    } else if ((style & DWT.LEFT) !is 0) {
+        alignment = OS.NSLeftTextAlignment;
+    } else {
+        alignment = OS.NSRightTextAlignment;
+    }
+    NSMutableParagraphStyle pStyle = (NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init();
+    pStyle.autorelease();
+    pStyle.setAlignment(alignment);
+    dict.setObject(pStyle, OS.NSParagraphStyleAttributeName());
+    char [] chars = new char [text.length ()];
+    text.getChars (0, chars.length, chars, 0);
+    int length = fixMnemonic (chars);
+    NSString str = NSString.stringWithCharacters(chars, length);
+    NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict);
+    attribStr.autorelease();
+    return attribStr;
+}
+
+void createHandle () {
+    NSButton widget = (NSButton)new SWTButton().alloc();
+    widget.initWithFrame(new NSRect());
+    int type = OS.NSMomentaryPushButton;
+    if ((style & DWT.PUSH) !is 0) {
+        widget.setBezelStyle(OS.NSRoundedBezelStyle);
+    } else if ((style & DWT.CHECK) !is 0) {
+        type = OS.NSSwitchButton;
+        widget.setAllowsMixedState (true);
+    } else if ((style & DWT.RADIO) !is 0) {
+        type = OS.NSRadioButton;        
+    } else if ((style & DWT.TOGGLE) !is 0) {
+        type = OS.NSPushOnPushOffButton;
+        widget.setBezelStyle(OS.NSRegularSquareBezelStyle);
+    } else if ((style & DWT.ARROW) !is 0) {
+        widget.setBezelStyle(OS.NSRoundedDisclosureBezelStyle);
+    }
+    widget.setButtonType(type);
+    widget.setTitle(NSString.stringWith(""));
+    widget.setImagePosition(OS.NSImageLeft);
+    widget.setTarget(widget);
+    widget.setAction(OS.sel_sendSelection);
+    widget.setTag(jniRef);
+    view = widget;  
+    parent.contentView().addSubview_(widget);
+    _setAlignment(style);
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in 
+ * which case, the alignment will indicate the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 
+ * <code>UP</code> or <code>DOWN</code>).
+ *
+ * @return the alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+    checkWidget ();
+    if ((style & DWT.ARROW) !is 0) {
+        if ((style & DWT.UP) !is 0) return DWT.UP;
+        if ((style & DWT.DOWN) !is 0) return DWT.DOWN;
+        if ((style & DWT.LEFT) !is 0) return DWT.LEFT;
+        if ((style & DWT.RIGHT) !is 0) return DWT.RIGHT;
+        return DWT.UP;
+    }
+    if ((style & DWT.LEFT) !is 0) return DWT.LEFT;
+    if ((style & DWT.CENTER) !is 0) return DWT.CENTER;
+    if ((style & DWT.RIGHT) !is 0) return DWT.RIGHT;
+    return DWT.LEFT;
+}
+
+public bool getGrayed() {
+    checkWidget ();
+    if ((style &DWT.CHECK) !is 0) return false;
+    return grayed;
+}
+
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+    checkWidget();
+    return image;
+}
+
+String getNameText () {
+    return getText ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed in. If the receiver is of any other type,
+ * this method returns false.
+ *
+ * @return the selection state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getSelection () {
+    checkWidget ();
+    if ((style & (DWT.CHECK | DWT.RADIO | DWT.TOGGLE)) is 0) return false;
+    if ((style & DWT.CHECK) !is 0 && grayed) return ((NSButton)view).state() is OS.NSMixedState;
+    return ((NSButton)view).state() is OS.NSOnState;
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set or if the receiver is
+ * an <code>ARROW</code> button.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget ();
+    return text;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    image = null;
+    text = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+    /*
+    * This code is intentionally commented.  When two groups
+    * of radio buttons with the same parent are separated by
+    * another control, the correct behavior should be that
+    * the two groups act independently.  This is consistent
+    * with radio tool and menu items.  The commented code
+    * implements this behavior.
+    */
+//  int index = 0;
+//  Control [] children = parent._getChildren ();
+//  while (index < children.length && children [index] !is this) index++;
+//  int i = index - 1;
+//  while (i >= 0 && children [i].setRadioSelection (false)) --i;
+//  int j = index + 1;
+//  while (j < children.length && children [j].setRadioSelection (false)) j++;
+//  setSelection (true);
+    Control [] children = parent._getChildren ();
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        if (this !is child) child.setRadioSelection (false);
+    }
+    setSelection (true);
+}
+
+void sendSelection () {
+    if ((style & DWT.RADIO) !is 0) {
+        if ((parent.getStyle () & DWT.NO_RADIO_GROUP) is 0) {
+            selectRadio ();
+        }
+    }
+    if ((style & DWT.CHECK) !is 0) {
+        if (grayed && ((NSButton)view).state() is OS.NSOnState) {
+            ((NSButton)view).setState(OS.NSOffState);
+        }
+        if (!grayed && ((NSButton)view).state() is OS.NSMixedState) {
+            ((NSButton)view).setState(OS.NSOnState);
+        }
+    }
+    postEvent (DWT.Selection);
+}
+
+
+/**
+ * Controls how text, images and arrows will be displayed
+ * in the receiver. The argument should be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in 
+ * which case, the argument indicates the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 
+ * <code>UP</code> or <code>DOWN</code>).
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+    checkWidget ();
+    _setAlignment (alignment);
+    redraw ();
+}
+
+void _setAlignment (int alignment) {
+    if ((style & DWT.ARROW) !is 0) {
+        if ((style & (DWT.UP | DWT.DOWN | DWT.LEFT | DWT.RIGHT)) is 0) return; 
+        style &= ~(DWT.UP | DWT.DOWN | DWT.LEFT | DWT.RIGHT);
+        style |= alignment & (DWT.UP | DWT.DOWN | DWT.LEFT | DWT.RIGHT);
+//      int orientation = OS.kThemeDisclosureRight;
+//      if ((style & DWT.UP) !is 0) orientation = OS.kThemeDisclosureDown;
+//      if ((style & DWT.DOWN) !is 0) orientation = OS.kThemeDisclosureDown;
+//      if ((style & DWT.LEFT) !is 0) orientation = OS.kThemeDisclosureLeft;
+//      OS.SetControl32BitValue (handle, orientation);
+        return;
+    }
+    if ((alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER)) is 0) return;
+    style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    /* text is still null when this is called from createHandle() */
+    if (text !is null) {
+        ((NSButton)view).setAttributedTitle(createString());
+    }
+//  /* Alignment not honoured when image and text is visible */
+//  bool bothVisible = text !is null && text.length () > 0 && image !is null;
+//  if (bothVisible) {
+//      if ((style & (DWT.RADIO | DWT.CHECK)) !is 0) alignment = DWT.LEFT;
+//      if ((style & (DWT.PUSH | DWT.TOGGLE)) !is 0) alignment = DWT.CENTER;
+//  }
+//  int textAlignment = 0;
+//  int graphicAlignment = 0;
+//  if ((alignment & DWT.LEFT) !is 0) {
+//      textAlignment = OS.kControlBevelButtonAlignTextFlushLeft;
+//      graphicAlignment = OS.kControlBevelButtonAlignLeft;
+//  }
+//  if ((alignment & DWT.CENTER) !is 0) {
+//      textAlignment = OS.kControlBevelButtonAlignTextCenter;
+//      graphicAlignment = OS.kControlBevelButtonAlignCenter;
+//  }
+//  if ((alignment & DWT.RIGHT) !is 0) {
+//      textAlignment = OS.kControlBevelButtonAlignTextFlushRight;
+//      graphicAlignment = OS.kControlBevelButtonAlignRight;
+//  }
+//  OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonTextAlignTag, 2, new short [] {(short)textAlignment});
+//  OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonGraphicAlignTag, 2, new short [] {(short)graphicAlignment});
+//  if (bothVisible) {
+//      OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonTextPlaceTag, 2, new short [] {(short)OS.kControlBevelButtonPlaceToRightOfGraphic});
+//  }
+}
+
+void setBackground (float [] color) {
+    NSColor nsColor;
+    if (color is null) {
+        return; // TODO set to OS default
+    } else {
+        nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    }
+    NSButtonCell cell = new NSButtonCell(((NSButton)view).cell());
+    cell.setBackgroundColor(nsColor);
+}
+
+void setDefault (bool value) {
+    if ((style & DWT.PUSH) is 0) return;
+//  int window = OS.GetControlOwner (handle);
+//  OS.SetWindowDefaultButton (window, value ? handle : 0);
+}
+
+void setForeground (float [] color) {
+    ((NSButton)view).setAttributedTitle(createString());
+}
+
+public void setGrayed(bool grayed) {
+    checkWidget ();
+    if ((style & DWT.CHECK) is 0) return;
+    bool checked = getSelection ();
+    this.grayed = grayed;
+    if (checked) {
+        if (grayed) {
+            ((NSButton) view).setState (OS.NSMixedState);
+        } else {
+            ((NSButton) view).setState (OS.NSOnState);
+        }
+    }
+}
+
+/**
+ * Sets the receiver's image to the argument, which may be
+ * <code>null</code> indicating that no image should be displayed.
+ * <p>
+ * Note that a Button can display an image and text simultaneously
+ * on Windows (starting with XP), GTK+ and OSX.  On other platforms,
+ * a Button that has an image and text set into it will display the
+ * image or text that was set most recently.
+ * </p>
+ * @param image the image to display on the receiver (may be <code>null</code>)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+    checkWidget();
+    if ((style & DWT.ARROW) !is 0) return;
+    if (image !is null && image.isDisposed ()) {
+        error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.image = image;
+    ((NSButton)view).setImage(image.handle);
+}
+
+bool setRadioSelection (bool value){
+    if ((style & DWT.RADIO) is 0) return false;
+    if (getSelection () !is value) {
+        setSelection (value);
+        postEvent (DWT.Selection);
+    }
+    return true;
+}
+
+/**
+ * Sets the selection state of the receiver, if it is of type <code>CHECK</code>, 
+ * <code>RADIO</code>, or <code>TOGGLE</code>.
+ *
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed in.
+ *
+ * @param selected the new selection state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (bool selected) {
+    checkWidget();
+    if ((style & (DWT.CHECK | DWT.RADIO | DWT.TOGGLE)) is 0) return;
+    if (grayed) {
+        ((NSButton)view).setState (selected ? OS.NSMixedState : OS.NSOffState);
+    } else {
+        ((NSButton)view).setState (selected ? OS.NSOnState : OS.NSOffState);
+    }
+}
+
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the button label.  The label may include
+ * the mnemonic character but must not contain line delimiters.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasized in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p><p>
+ * Note that a Button can display an image and text simultaneously
+ * on Windows (starting with XP), GTK+ and OSX.  On other platforms,
+ * a Button that has an image and text set into it will display the
+ * image or text that was set most recently.
+ * </p>
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if ((style & DWT.ARROW) !is 0) return;
+    text = string;
+    ((NSButton)view).setAttributedTitle(createString());
+}
+
+int traversalCode (int key, NSEvent theEvent) {
+    int code = super.traversalCode (key, theEvent);
+    if ((style & DWT.RADIO) !is 0) code |= DWT.TRAVERSE_ARROW_NEXT | DWT.TRAVERSE_ARROW_PREVIOUS;
+    return code;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Canvas.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,332 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Canvas;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class provide a surface for drawing
+ * arbitrary graphics.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are <em>not</em> constructed
+ * from aggregates of other controls. That is, they are either
+ * painted using DWT graphics calls or are handled by native
+ * methods.
+ * </p>
+ *
+ * @see Composite
+ */
+public class Canvas extends Composite {
+    Caret caret;
+    IME ime;
+
+Canvas () {
+    /* Do nothing */
+}
+
+bool becomeFirstResponder () {
+    if (caret !is null) caret.setFocus ();
+    return super.becomeFirstResponder();
+}
+
+bool resignFirstResponder () {
+    if (caret !is null) caret.killFocus ();
+    return super.resignFirstResponder();
+}
+
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Canvas (Composite parent, int style) {
+    super (parent, style);
+}
+
+/** 
+ * Fills the interior of the rectangle specified by the arguments,
+ * with the receiver's background. 
+ *
+ * @param gc the gc where the rectangle is to be filled
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled
+ * @param height the height of the rectangle to be filled
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void drawBackground (GC gc, int x, int y, int width, int height) {
+    checkWidget ();
+    if (gc is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    Control control = findBackgroundControl ();
+    if (control !is null) {
+//      control.fillBackground (handle, gc.handle, new Rectangle (x, y, width, height));
+    } else {
+        gc.fillRectangle (x, y, width, height);
+    }
+}
+
+void drawRect(int id, NSRect rect) {
+    super.drawRect(id, rect);
+    if (caret is null) return;
+    if (caret.isShowing) {
+        NSGraphicsContext context = NSGraphicsContext.currentContext();
+        
+        Image image = caret.image;
+        if (image !is null) {
+            NSRect fromRect = new NSRect ();
+            NSSize size = image.handle.size();
+            fromRect.width = size.width;
+            fromRect.height = size.height;
+            NSPoint point = new NSPoint();
+            point.x = caret.x;
+            point.y = caret.y;
+            image.handle.drawAtPoint(point, rect, OS.NSCompositeXOR, 1);
+        } else {
+            context.saveGraphicsState();
+            context.setCompositingOperation(OS.NSCompositeXOR);
+            NSRect drawRect = new NSRect();
+            drawRect.x = caret.x;
+            drawRect.y = caret.y;
+            drawRect.width = caret.width !is 0 ? caret.width : Caret.DEFAULT_WIDTH;
+            drawRect.height = caret.height;
+            context.setShouldAntialias(false);
+            NSColor color = NSColor.colorWithDeviceRed(1, 1, 1, 1);
+            color.set();
+            NSBezierPath.fillRect(drawRect);
+            context.restoreGraphicsState();
+        }
+    }
+}
+
+/**
+ * Returns the caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled.  To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ *
+ * @return the caret
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Caret getCaret () {
+    checkWidget();
+    return caret;
+}
+
+public IME getIME () {
+    checkWidget();
+    return ime;
+}
+
+//void redrawWidget (int control, bool children) {
+//  bool isFocus = OS.VERSION < 0x1040 && caret !is null && caret.isFocusCaret ();
+//  if (isFocus) caret.killFocus ();
+//  super.redrawWidget (control, children);
+//  if (isFocus) caret.setFocus ();
+//}
+//
+//void redrawWidget (int control, int x, int y, int width, int height, bool all) {
+//  bool isFocus = OS.VERSION < 0x1040 && caret !is null && caret.isFocusCaret ();
+//  if (isFocus) caret.killFocus ();
+//  super.redrawWidget (control, x, y, width, height, all);
+//  if (isFocus) caret.setFocus ();
+//}
+
+void releaseChildren (bool destroy) {
+    if (caret !is null) {
+        caret.release (false);
+        caret = null;
+    }
+    if (ime !is null) {
+        ime.release (false);
+        ime = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+/**
+ * Scrolls a rectangular area of the receiver by first copying 
+ * the source area to the destination and then causing the area
+ * of the source which is not covered by the destination to
+ * be repainted. Children that intersect the rectangle are
+ * optionally moved during the operation. In addition, outstanding
+ * paint events are flushed before the source area is copied to
+ * ensure that the contents of the canvas are drawn correctly.
+ *
+ * @param destX the x coordinate of the destination
+ * @param destY the y coordinate of the destination
+ * @param x the x coordinate of the source
+ * @param y the y coordinate of the source
+ * @param width the width of the area
+ * @param height the height of the area
+ * @param all <code>true</code>if children should be scrolled, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void scroll (int destX, int destY, int x, int y, int width, int height, bool all) {
+    checkWidget();
+    if (width <= 0 || height <= 0) return;
+    int deltaX = destX - x, deltaY = destY - y;
+    if (deltaX is 0 && deltaY is 0) return;
+//  if (!isDrawing (handle)) return;
+    bool isFocus = caret !is null && caret.isFocusCaret ();
+    if (isFocus) caret.killFocus ();
+    Rectangle clientRect = getClientArea ();
+    Rectangle sourceRect = new Rectangle (x, y, width, height);
+    if (sourceRect.intersects (clientRect)) {
+        update (all);
+    }
+    NSRect damage = new NSRect();
+    damage.x = x;
+    damage.y = y;
+    damage.width = width;
+    damage.height = height;
+    view.setNeedsDisplayInRect(damage);
+    damage.x = destX;
+    damage.y = destY;
+    view.setNeedsDisplayInRect(damage);
+//  Control control = findBackgroundControl ();
+//  if ((control !is null && control.backgroundImage !is null)) {
+//      redrawWidget (handle, x, y, width, height, false);
+//      redrawWidget (handle, destX, destY, width, height, false);
+//  } else {
+//      GC gc = new GC (this);
+//      gc.copyArea (x, y, width, height, destX, destY);
+//      gc.dispose ();
+//  }
+    if (all) {
+        Control [] children = _getChildren ();
+        for (int i=0; i<children.length; i++) {
+            Control child = children [i];
+            Rectangle rect = child.getBounds ();
+            if (Math.min(x + width, rect.x + rect.width) >= Math.max (x, rect.x) && 
+                Math.min(y + height, rect.y + rect.height) >= Math.max (y, rect.y)) {
+                    child.setLocation (rect.x + deltaX, rect.y + deltaY);
+            }
+        }
+    }
+    if (isFocus) caret.setFocus ();
+}
+
+/**
+ * Sets the receiver's caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled.  To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ * @param caret the new caret for the receiver, may be null
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCaret (Caret caret) {
+    checkWidget();
+    Caret newCaret = caret;
+    Caret oldCaret = this.caret;
+    this.caret = newCaret;
+    if (hasFocus ()) {
+        if (oldCaret !is null) oldCaret.killFocus ();
+        if (newCaret !is null) {
+            if (newCaret.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+            newCaret.setFocus ();
+        }
+    }
+}
+
+public void setFont (Font font) {
+    checkWidget ();
+    if (caret !is null) caret.setFont (font);
+    super.setFont (font);
+}
+
+public void setIME (IME ime) {
+    checkWidget ();
+    if (ime !is null && ime.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    this.ime = ime;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Caret.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,506 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Caret;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Font;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+
+/**
+ * Instances of this class provide an i-beam that is typically used
+ * as the insertion point for text.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class Caret extends Widget {
+    Canvas parent;
+    int x, y, width, height;
+    bool isVisible, isShowing;
+    int blinkRate;
+    Image image;
+    Font font;
+
+    static final int DEFAULT_WIDTH  = 1;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Caret (Canvas parent, int style) {
+    super (parent, style);
+    this.parent = parent;
+    createWidget ();
+}
+
+bool blinkCaret () {
+    if (!isVisible) return true;
+    if (!isShowing) return showCaret ();
+    if (blinkRate is 0) return true;
+    return hideCaret ();
+}
+
+void createWidget () {
+    super.createWidget ();
+    blinkRate = display.getCaretBlinkTime ();
+    isVisible = true;
+    if (parent.getCaret () is null) {
+        parent.setCaret (this);
+    }
+}
+
+bool drawCaret () {
+    if (parent is null) return false;
+    if (parent.isDisposed ()) return false;
+    int nWidth = width, nHeight = height;
+    if (nWidth <= 0) nWidth = DEFAULT_WIDTH;
+    if (image !is null) {
+        NSSize size = image.handle.size();
+        nWidth = (int)size.width;
+        nHeight = (int)size.height;
+    }
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = nWidth;
+    rect.height = nHeight;
+    parent.view.setNeedsDisplayInRect(rect);
+    return true;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+    checkWidget();
+    if (image !is null) {
+        Rectangle rect = image.getBounds ();
+        return new Rectangle (x, y, rect.width, rect.height);
+    } else {
+        if (width is 0) {
+            return new Rectangle (x, y, DEFAULT_WIDTH, height);
+        }
+    }
+    return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Font getFont () {
+    checkWidget();
+    if (font !is null) return font;
+    return parent.getFont ();
+}
+
+/**
+ * Returns the image that the receiver will use to paint the caret.
+ *
+ * @return the receiver's image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+    checkWidget();
+    return image;
+}
+
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's location
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getLocation () {
+    checkWidget();
+    return new Point (x, y);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Canvas</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Canvas getParent () {
+    checkWidget();
+    return parent;
+}
+
+/**
+ * Returns a point describing the receiver's size.
+ *
+ * @return the receiver's size
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+    checkWidget();
+    if (image !is null) {
+        Rectangle rect = image.getBounds ();
+        return new Point (rect.width, rect.height);
+    } else {
+        if (width is 0) {
+            return new Point (DEFAULT_WIDTH, height);
+        }
+    }
+    return new Point (width, height);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getVisible () {
+    checkWidget();
+    return isVisible;
+}
+
+bool hideCaret () {
+    if (!isShowing) return true;
+    isShowing = false;
+    return drawCaret ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public bool isVisible () {
+    checkWidget();
+    return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+bool isFocusCaret () {
+    return this is display.currentCaret;
+}
+
+void killFocus () {
+    if (display.currentCaret !is this) return;
+    display.setCurrentCaret (null);
+    if (isVisible) hideCaret ();
+}
+
+void releaseParent () {
+    super.releaseParent ();
+    if (this is parent.getCaret ()) parent.setCaret (null);
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    if (display.currentCaret is this) {
+        hideCaret ();
+        display.setCurrentCaret (null);
+    }
+    parent = null;
+    image = null;
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and 
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (int x, int y, int width, int height) {
+    checkWidget();
+    if (this.x is x && this.y is y && this.width is width && this.height is height) return;
+    bool isFocus = isFocusCaret ();
+    if (isFocus && isVisible) hideCaret ();
+    this.x = x;
+    this.y = y;
+    this.width = width;
+    this.height = height;
+    if (isFocus && isVisible) showCaret ();
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and 
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (Rectangle rect) {
+    checkWidget();
+    if (rect is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
+void setFocus () {
+    if (display.currentCaret is this) return;
+    display.setCurrentCaret (this);
+    if (isVisible) showCaret ();
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+    checkWidget();
+    if (font !is null && font.isDisposed ()) {
+        error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.font = font;
+}
+
+/**
+ * Sets the image that the receiver will use to paint the caret
+ * to the image specified by the argument, or to the default
+ * which is a filled rectangle if the argument is null
+ *
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed ()) {
+        error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    bool isFocus = isFocusCaret ();
+    if (isFocus && isVisible) hideCaret ();
+    this.image = image;
+    if (isFocus && isVisible) showCaret ();
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (int x, int y) {
+    checkWidget();
+    setBounds (x, y, width, height);
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the argument which is relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (Point location) {
+    checkWidget();
+    if (location is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setLocation (location.x, location.y);
+}
+
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (int width, int height) {
+    checkWidget();
+    setBounds (x, y, width, height);
+}
+
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ *
+ * @param size the new extent for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (Point size) {
+    checkWidget();
+    if (size is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setSize (size.x, size.y);
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (bool visible) {
+    checkWidget();
+    if (visible is isVisible) return;
+    isVisible = visible;
+    if (!isFocusCaret ()) return;
+    if (isVisible) {
+        showCaret ();
+    } else {
+        hideCaret ();
+    }
+}
+
+bool showCaret () {
+    if (isShowing) return true;
+    isShowing = true;
+    return drawCaret ();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ColorDialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ColorDialog;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+import dwt.internal.cocoa.NSApplication;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSColorPanel;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTPanelDelegate;
+
+/**
+ * Instances of this class allow the user to select a color
+ * from a predefined set of available colors.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class ColorDialog extends Dialog {
+    RGB rgb;
+    
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a composite control which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ColorDialog(Shell parent) {
+    this(parent, DWT.APPLICATION_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ColorDialog(Shell parent, int style) {
+    super(parent, style);
+    checkSubclass ();
+}
+
+void changeColor(int sender) {
+    //TODO
+}
+
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
+ */
+public RGB getRGB() {
+    return rgb;
+}
+
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected color, or null if the dialog was
+ *         cancelled, no color was selected, or an error
+ *         occurred
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public RGB open() { 
+    NSColorPanel panel = NSColorPanel.sharedColorPanel();
+    if (rgb !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1);
+        panel.setColor(color);
+    }
+    SWTPanelDelegate delegate = (SWTPanelDelegate)new SWTPanelDelegate().alloc().init();
+    int jniRef = OS.NewGlobalRef(this);
+    if (jniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    delegate.setTag(jniRef);
+    panel.setDelegate(delegate);
+    rgb = null;
+    panel.orderFront(null);
+    NSApplication.sharedApplication().runModalForWindow_(panel);
+    panel.setDelegate(null);
+    delegate.release();
+    OS.DeleteGlobalRef(jniRef);
+    NSColor color = panel.color();
+    if (color !is null) {
+        color = color.colorUsingColorSpaceName_(NSString.stringWith("NSCalibratedRGBColorSpace"));
+        rgb = new RGB((int)(color.redComponent() * 255), (int)(color.greenComponent() * 255), (int)(color.blueComponent() * 255));
+    }
+    return rgb;
+}
+
+/**
+ * Sets the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ *        null to let the platform select a default when
+ *        open() is called
+ * @see PaletteData#getRGBs
+ */
+public void setRGB(RGB rgb) {
+    this.rgb = rgb;
+}
+
+void windowWillClose(int sender) {
+    NSApplication.sharedApplication().stop(null);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Combo.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1387 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Combo;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ModifyListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.events.VerifyListener;
+import dwt.graphics.Color;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSComboBox;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSPopUpButton;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextField;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTComboBox;
+import dwt.internal.cocoa.SWTPopUpButton;
+
+/**
+ * Instances of this class are controls that allow the user
+ * to choose an item from a list of items, or optionally 
+ * enter a new value by typing it into an editable text
+ * field. Often, <code>Combo</code>s are used in the same place
+ * where a single selection <code>List</code> widget could
+ * be used but space is limited. A <code>Combo</code> takes
+ * less space than a <code>List</code> widget and shows
+ * similar information.
+ * <p>
+ * Note: Since <code>Combo</code>s can contain both a list
+ * and an editable text field, it is possible to confuse methods
+ * which access one versus the other (compare for example,
+ * <code>clearSelection()</code> and <code>deselectAll()</code>).
+ * The API documentation is careful to indicate either "the
+ * receiver's list" or the "the receiver's text field" to 
+ * distinguish between the two cases.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection, Verify</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see List
+ */
+public class Combo extends Composite {
+    int textLimit = LIMIT;
+
+    /**
+     * the operating system limit for the number of characters
+     * that the text field in an instance of this class can hold
+     */
+    public static final int LIMIT;
+    
+    /*
+    * These values can be different on different platforms.
+    * Therefore they are not initialized in the declaration
+    * to stop the compiler from inlining.
+    */
+    static {
+        LIMIT = 0x7FFFFFFF;
+    }
+    
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#DROP_DOWN
+ * @see DWT#READ_ONLY
+ * @see DWT#SIMPLE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Combo (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+public void add (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    NSString str = NSString.stringWith(string);
+    if ((style & DWT.READ_ONLY) !is 0) {
+        NSMenu nsMenu = ((NSPopUpButton)view).menu();
+        NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc();
+        nsItem.initWithTitle(str, 0, NSString.stringWith(""));
+        nsMenu.addItem(nsItem);
+        nsItem.release();
+    } else {
+        ((NSComboBox)view).addItemWithObjectValue(str);
+    }
+}
+
+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+public void add (String string, int index) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int count = getItemCount ();
+    if (0 > index || index > count) error (DWT.ERROR_INVALID_RANGE);
+    NSString str = NSString.stringWith(string);
+    if ((style & DWT.READ_ONLY) !is 0) {
+        NSMenu nsMenu = ((NSPopUpButton)view).menu();
+        NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc();
+        nsItem.initWithTitle(str, 0, NSString.stringWith(""));
+        nsMenu.insertItem(nsItem, index);
+        nsItem.release();
+    } else {
+        ((NSComboBox)view).insertItemWithObjectValue(str, index);
+    }
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+public void addModifyListener (ModifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Modify, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the user changes the combo's list selection.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ * 
+ * @since 3.1
+ */
+public void addVerifyListener (VerifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Verify, typedListener);
+}
+
+static int checkStyle (int style) {
+    /*
+    * Feature in Windows.  It is not possible to create
+    * a combo box that has a border using Windows style
+    * bits.  All combo boxes draw their own border and
+    * do not use the standard Windows border styles.
+    * Therefore, no matter what style bits are specified,
+    * clear the BORDER bits so that the DWT style will
+    * match the Windows widget.
+    *
+    * The Windows behavior is currently implemented on
+    * all platforms.
+    */
+    style &= ~DWT.BORDER;
+
+    /*
+    * Even though it is legal to create this widget
+    * with scroll bars, they serve no useful purpose
+    * because they do not automatically scroll the
+    * widget's client area.  The fix is to clear
+    * the DWT style.
+    */
+    style &= ~(DWT.H_SCROLL | DWT.V_SCROLL);
+    style = checkBits (style, DWT.DROP_DOWN, DWT.SIMPLE, 0, 0, 0, 0);
+    if ((style & DWT.SIMPLE) !is 0) return style & ~DWT.READ_ONLY;
+    return style;
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list, 
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #deselectAll
+ */
+public void clearSelection () {
+    checkWidget();
+    if ((style & DWT.READ_ONLY) is 0) {
+        Point selection = getSelection ();
+        selection.y = selection.x;
+        setSelection (selection);
+    }
+}
+
+void comboBoxSelectionDidChange(int notification) {
+    sendSelection();
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget ();
+    int width = 0, height = 0;
+    NSControl widget = (NSControl)view;
+    NSRect oldRect = widget.frame();
+    widget.sizeToFit();
+    NSRect newRect = widget.frame();
+    widget.setFrame (oldRect);
+    width = (int)newRect.width;
+    height = (int)newRect.height;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point (width, height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void copy () {
+    checkWidget ();
+    Point selection = getSelection ();
+    if (selection.x is selection.y) return;
+//  copyToClipboard (getText (selection.x, selection.y));
+}
+
+void createHandle () {
+    if ((style & DWT.READ_ONLY) !is 0) {
+        NSPopUpButton widget = (NSPopUpButton)new SWTPopUpButton().alloc();
+        widget.initWithFrame(new NSRect(), false);
+        widget.menu().setAutoenablesItems(false);
+        widget.setTarget(widget);
+        widget.setAction(OS.sel_sendSelection);
+        widget.setTag(jniRef);
+        view = widget;
+        parent.view.addSubview_(widget);
+    } else {
+        NSComboBox widget = (NSComboBox)new SWTComboBox().alloc();
+        widget.initWithFrame(new NSRect());
+        widget.setTag(jniRef);
+        widget.setDelegate(widget);
+        view = widget;
+        parent.contentView().addSubview_(widget);
+    }
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void cut () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) return;
+//  Point selection = getSelection ();
+//  if (selection.x is selection.y) return;
+//  int start = selection.x, end = selection.y;
+//  String text = getText ();
+//  String leftText = text.substring (0, start);
+//  String rightText = text.substring (end, text.length ());
+//  String oldText = text.substring (start, end);
+//  String newText = "";
+//  if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+//      newText = verifyText (newText, start, end, null);
+//      if (newText is null) return;
+//  }
+//  char [] buffer = new char [oldText.length ()];
+//  oldText.getChars (0, buffer.length, buffer, 0);
+//  copyToClipboard (buffer);
+//  setText (leftText + newText + rightText, false);
+//  start += newText.length ();
+//  setSelection (new Point (start, start));
+//  sendEvent (DWT.Modify);
+}
+
+Color defaultBackground () {
+    return display.getSystemColor (DWT.COLOR_LIST_BACKGROUND);
+}
+
+Color defaultForeground () {
+    return display.getSystemColor (DWT.COLOR_LIST_FOREGROUND);
+}
+
+/**
+ * Deselects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+    checkWidget ();
+    if (index is -1) return;
+    if (index is getSelectionIndex ()) {
+        if ((style & DWT.READ_ONLY) !is 0) {
+            ((NSPopUpButton)view).selectItem(null);
+            sendEvent (DWT.Modify);
+        } else {
+            ((NSComboBox)view).deselectItemAtIndex(index);
+        }
+    }
+}
+
+/**
+ * Deselects all selected items in the receiver's list.
+ * <p>
+ * Note: To clear the selection in the receiver's text field,
+ * use <code>clearSelection()</code>.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #clearSelection
+ */
+public void deselectAll () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) {
+        ((NSPopUpButton)view).selectItem(null);
+        sendEvent (DWT.Modify);
+    } else {
+        setText ("");
+    }
+}
+
+int getCharCount() {
+    NSString str;
+    if ((style & DWT.READ_ONLY) !is 0) {
+        str = ((NSPopUpButton)view).titleOfSelectedItem();
+    } else {
+        str = new NSCell(((NSComboBox)view).cell()).title();
+    }
+    return str.length();
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver's list. Throws an exception if the index is out
+ * of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getItem (int index) {
+    checkWidget ();
+    int count = getItemCount ();
+    if (0 > index || index >= count) error (DWT.ERROR_INVALID_RANGE);
+    NSString str;
+    if ((style & DWT.READ_ONLY) !is 0) {
+        str = ((NSPopUpButton)view).itemTitleAtIndex(index);
+    } else {
+        str = new NSString(((NSComboBox)view).itemObjectValueAtIndex(index));
+    }
+    if (str is null) error(DWT.ERROR_CANNOT_GET_ITEM);
+    char[] buffer = new char[str.length()];
+    str.getCharacters_(buffer);
+    return new String (buffer);
+}
+
+/**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) {
+        return ((NSPopUpButton)view).numberOfItems();
+    } else {
+        return ((NSComboBox)view).numberOfItems();
+    }
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's list.
+ *
+ * @return the height of one item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+    checkWidget ();
+    //TODO - not supported by the OS
+    return 26;
+}
+
+/**
+ * Returns a (possibly empty) array of <code>String</code>s which are
+ * the items in the receiver's list. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String [] getItems () {
+    checkWidget ();
+    int count = getItemCount ();
+    String [] result = new String [count];
+    for (int i=0; i<count; i++) result [i] = getItem (i);
+    return result;
+}
+
+int getMininumHeight () {
+    return getTextHeight ();
+}
+
+/**
+ * Returns the orientation of the receiver.
+ *
+ * @return the orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public int getOrientation () {
+    checkWidget();
+    return style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT);
+}
+
+/**
+ * Returns a <code>Point</code> whose x coordinate is the
+ * character position representing the start of the selection
+ * in the receiver's text field, and whose y coordinate is the
+ * character position representing the end of the selection.
+ * An "empty" selection is indicated by the x and y coordinates
+ * having the same value.
+ * <p>
+ * Indexing is zero based.  The range of a selection is from
+ * 0..N where N is the number of characters in the widget.
+ * </p>
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) {
+        return new Point (0, getCharCount ());
+    } else {
+//      ControlEditTextSelectionRec selection;
+//      if (this.selection !is null) {
+//          selection = this.selection;
+//      } else {
+//          selection = new ControlEditTextSelectionRec ();
+//          OS.GetControlData (handle, (short) OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, selection, null);
+//      }
+//      return new Point (selection.selStart, selection.selEnd);
+        return null;
+    }
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) {
+        return ((NSPopUpButton)view).indexOfSelectedItem();
+    } else {
+        return ((NSComboBox)view).indexOfSelectedItem();
+    }
+}
+
+/**
+ * Returns a string containing a copy of the contents of the
+ * receiver's text field, or an empty string if there are no
+ * contents.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget ();
+    return getText(0, -1);
+}
+
+String getText (int start, int end) {
+    NSString str;
+    if ((style & DWT.READ_ONLY) !is 0) {
+        str = ((NSPopUpButton)view).titleOfSelectedItem();
+    } else {
+        str = new NSCell(((NSComboBox)view).cell()).title();
+    }
+    if (str is null) return "";
+    int length = str.length();
+    char[] buffer = new char[length];
+    str.getCharacters_(buffer);
+    String string = new String(buffer);
+    if (end is -1) end = length;
+    start = Math.max(0, Math.min(start, length));
+    end = Math.max(0, Math.min(end, length));
+    return string.substring(start, end);
+}
+
+/**
+ * Returns the height of the receivers's text field.
+ *
+ * @return the text height
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTextHeight () {
+    checkWidget();
+    //TODO - not supported by the OS
+    return 26;
+}
+
+/**
+ * Returns the maximum number of characters that the receiver's
+ * text field is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Combo.LIMIT</code>.
+ * 
+ * @return the text limit
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #LIMIT
+ */
+public int getTextLimit () {
+    checkWidget();
+    return textLimit;
+}
+
+/**
+ * Gets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @return the number of items that are visible
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public int getVisibleItemCount () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) {
+        return getItemCount ();
+    } else {
+        return ((NSComboBox)view).numberOfVisibleItems();
+    }
+}
+    
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string) {
+    return indexOf (string, 0);
+}
+
+/**
+ * Searches the receiver's list starting at the given, 
+ * zero-relative index until an item is found that is equal
+ * to the argument, and returns the index of that item. If
+ * no item is found or the starting index is out of range,
+ * returns -1.
+ *
+ * @param string the search item
+ * @param start the zero-relative index at which to begin the search
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string, int start) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int count = getItemCount ();
+    if (!(0 <= start && start < count)) return -1;
+    for (int i=start; i<count; i++) {
+        if (string.equals (getItem (i))) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void paste () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) return;
+//  Point selection = getSelection ();
+//  int start = selection.x, end = selection.y;
+//  String text = getText ();
+//  String leftText = text.substring (0, start);
+//  String rightText = text.substring (end, text.length ());
+//  String newText = getClipboardText ();
+//  if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+//      newText = verifyText (newText, start, end, null);
+//      if (newText is null) return;
+//  }
+//  if (textLimit !is LIMIT) {
+//      int charCount = text.length ();
+//      if (charCount - (end - start) + newText.length() > textLimit) {
+//          newText = newText.substring(0, textLimit - charCount + (end - start));
+//      }
+//  }
+//  setText (leftText + newText + rightText, false);
+//  start += newText.length ();
+//  setSelection (new Point (start, start));
+//  sendEvent (DWT.Modify);
+}
+
+/**
+ * Removes the item from the receiver's list at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int index) {
+    checkWidget ();
+    if (index is -1) error (DWT.ERROR_INVALID_RANGE);
+    int count = getItemCount ();
+    if (0 > index || index >= count) error (DWT.ERROR_INVALID_RANGE);
+    if ((style & DWT.READ_ONLY) !is 0) {
+        ((NSPopUpButton)view).removeItemAtIndex(index);
+    } else {
+        ((NSComboBox)view).removeItemAtIndex(index);
+    }
+}
+
+/**
+ * Removes the items from the receiver's list which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+    checkWidget();
+    if (start > end) return;
+    int count = getItemCount ();
+    if (!(0 <= start && start <= end && end < count)) {
+        error (DWT.ERROR_INVALID_RANGE);
+    }
+    int newEnd = Math.min (end, count - 1);
+    for (int i=newEnd; i>=start; i--) {
+        remove(i);
+    }
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument, 
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int index = indexOf (string, 0);
+    if (index is -1) error (DWT.ERROR_INVALID_ARGUMENT);
+    remove (index);
+}
+
+/**
+ * Removes all of the items from the receiver's list and clear the
+ * contents of receiver's text field.
+ * <p>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) {
+        ((NSPopUpButton)view).removeAllItems();
+    } else {
+        setText ("", true);
+        ((NSComboBox)view).removeAllItems();
+    }
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+public void removeModifyListener (ModifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Modify, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #addVerifyListener
+ * 
+ * @since 3.1
+ */
+public void removeVerifyListener (VerifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Verify, listener);
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select (int index) {
+    checkWidget ();
+    int count = getItemCount ();
+    if (0 <= index && index < count) {
+        if ((style & DWT.READ_ONLY) !is 0) {
+            ((NSPopUpButton)view).selectItemAtIndex(index);
+            sendEvent (DWT.Modify);
+        } else {
+            ((NSComboBox)view).selectItemAtIndex(index);
+        }
+    }   
+}
+
+//bool sendKeyEvent (int type, Event event) {
+//  if (!super.sendKeyEvent (type, event)) {
+//      return false;
+//  }
+//  if (type !is DWT.KeyDown) return true;
+//  if ((style & DWT.READ_ONLY) !is 0) return true;
+//  if (event.character is 0) return true;
+//  if ((event.stateMask & DWT.COMMAND) !is 0) return true;
+//  String oldText = "", newText = "";
+//  if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+//      int charCount = getCharCount ();
+//      Point selection = getSelection ();
+//      int start = selection.x, end = selection.y;
+//      switch (event.character) {
+//          case DWT.BS:
+//              if (start is end) {
+//                  if (start is 0) return true;
+//                  start = Math.max (0, start - 1);
+//              }
+//              break;
+//          case DWT.DEL:
+//              if (start is end) {
+//                  if (start is charCount) return true;
+//                  end = Math.min (end + 1, charCount);
+//              }
+//              break;
+//          case DWT.CR:
+//              return true;
+//          default:
+//              if (event.character !is '\t' && event.character < 0x20) return true;
+//              oldText = new String (new char [] {event.character});
+//      }
+//      newText = verifyText (oldText, start, end, event);
+//      if (newText is null) return false;
+//      if (charCount - (end - start) + newText.length () > textLimit) {
+//          return false;
+//      }
+//      if (newText !is oldText) {
+//          String text = getText ();
+//          String leftText = text.substring (0, start);
+//          String rightText = text.substring (end, text.length ());
+//          setText (leftText + newText + rightText, false);
+//          start += newText.length ();
+//          setSelection (new Point (start, start));
+//      }
+//  }
+//  /*
+//  * Post the modify event so that the character will be inserted
+//  * into the widget when the modify event is delivered.  Normally,
+//  * modify events are sent but it is safe to post the event here
+//  * because this method is called from the event loop.
+//  */
+//  postEvent (DWT.Modify);
+//  return newText is oldText;
+//}
+
+void sendSelection () {
+    postEvent(DWT.Selection);
+}
+
+void setBackground (float [] color) {
+    NSColor nsColor;
+    if (color is null) {
+        return; // TODO reset to OS default
+    } else {
+        nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    }
+    ((NSTextField)view).setBackgroundColor(nsColor);
+}
+
+void setForeground (float [] color) {
+    NSColor nsColor;
+    if (color is null) {
+        return; // TODO reset to OS default
+    } else {
+        nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    }
+    ((NSTextField)view).setTextColor(nsColor);
+}
+
+/**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItem (int index, String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int count = getItemCount ();
+    if (0 > index || index >= count) error (DWT.ERROR_INVALID_RANGE);
+    NSString str = NSString.stringWith(string);
+    if ((style & DWT.READ_ONLY) !is 0) {
+        NSMenuItem nsItem = ((NSPopUpButton)view).itemAtIndex(index);
+        nsItem.setTitle(str);
+    } else {
+        NSComboBox widget = (NSComboBox)view;
+        widget.insertItemWithObjectValue(str, index);
+        widget.removeItemAtIndex(index + 1);
+    }
+}
+
+/**
+ * Sets the receiver's list to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItems (String [] items) {
+    checkWidget();
+    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<items.length; i++) {
+        if (items [i] is null) error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    removeAll();
+    if (items.length is 0) return;
+    for (int i= 0; i < items.length; i++) {
+        NSString str = NSString.stringWith(items[i]);
+        if ((style & DWT.READ_ONLY) !is 0) {
+            NSMenu nsMenu = ((NSPopUpButton)view).menu();
+            NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc();
+            nsItem.initWithTitle(str, 0, NSString.stringWith(""));
+            nsMenu.addItem(nsItem);
+            nsItem.release();
+        } else {
+            ((NSComboBox)view).addItemWithObjectValue(str);
+        }
+    }
+}
+
+/*public*/ void setListVisible (bool visible) {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) {
+        ((NSPopUpButton)view).setPullsDown(visible);
+    } else {
+    }
+}
+
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of the constants <code>DWT.LEFT_TO_RIGHT</code> or <code>DWT.RIGHT_TO_LEFT</code>.
+ * <p>
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public void setOrientation (int orientation) {
+    checkWidget();
+}
+
+/**
+ * Sets the selection in the receiver's text field to the
+ * range specified by the argument whose x coordinate is the
+ * start of the selection and whose y coordinate is the end
+ * of the selection. 
+ *
+ * @param selection a point representing the new selection start and end
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (Point selection) {
+    checkWidget ();
+    if (selection is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if ((style & DWT.READ_ONLY) is 0) {
+//      int length = getCharCount ();
+//      int start = selection.x, end = selection.y;
+//      ControlEditTextSelectionRec sel = new ControlEditTextSelectionRec ();
+//      sel.selStart = (short) Math.min (Math.max (Math.min (start, end), 0), length);
+//      sel.selEnd = (short) Math.min (Math.max (Math.max (start, end), 0), length);
+//      if (hasFocus ()) {
+//          OS.SetControlData (handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, sel);
+//      } else {
+//          this.selection = sel;
+//      }
+    }
+}
+
+/**
+ * Sets the contents of the receiver's text field to the
+ * given string.
+ * <p>
+ * Note: The text field in a <code>Combo</code> is typically
+ * only capable of displaying a single line of text. Thus,
+ * setting the text to a string containing line breaks or
+ * other special characters will probably cause it to 
+ * display incorrectly.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setText (string, true);
+}
+
+void setText (String string, bool notify) {
+    if (notify) {
+        if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+            string = verifyText (string, 0, getCharCount (), null);
+            if (string is null) return;
+        }
+    }
+    if ((style & DWT.READ_ONLY) !is 0) {
+        int index = indexOf (string);
+        if (index !is -1 && index !is getSelectionIndex ()) {
+            select (index);
+            if (notify) sendEvent (DWT.Modify);
+        }
+    } else {
+        new NSCell(((NSComboBox)view).cell()).setTitle(NSString.stringWith(string));
+        if (notify) sendEvent (DWT.Modify);
+    }
+}
+
+/**
+ * Sets the maximum number of characters that the receiver's
+ * text field is capable of holding to be the argument.
+ * <p>
+ * To reset this value to the default, use <code>setTextLimit(Combo.LIMIT)</code>.
+ * Specifying a limit value larger than <code>Combo.LIMIT</code> sets the
+ * receiver's limit to <code>Combo.LIMIT</code>.
+ * </p>
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #LIMIT
+ */
+public void setTextLimit (int limit) {
+    checkWidget ();
+    if (limit is 0) error (DWT.ERROR_CANNOT_BE_ZERO);
+    textLimit = limit;
+}
+
+/**
+ * Sets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @param count the new number of items to be visible
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setVisibleItemCount (int count) {
+    checkWidget ();
+    if (count < 0) return;
+    if ((style & DWT.READ_ONLY) !is 0) {
+        //TODO 
+    } else {
+        ((NSComboBox)view).setNumberOfVisibleItems(count);
+    }
+}
+
+String verifyText (String string, int start, int end, Event keyEvent) {
+    Event event = new Event ();
+    event.text = string;
+    event.start = start;
+    event.end = end;
+    if (keyEvent !is null) {
+        event.character = keyEvent.character;
+        event.keyCode = keyEvent.keyCode;
+        event.stateMask = keyEvent.stateMask;
+    }
+    /*
+     * It is possible (but unlikely), that application
+     * code could have disposed the widget in the verify
+     * event.  If this happens, answer null to cancel
+     * the operation.
+     */
+    sendEvent (DWT.Verify, event);
+    if (!event.doit || isDisposed ()) return null;
+    return event.text;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Composite.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,888 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Composite;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTScrollView;
+import dwt.internal.cocoa.SWTView;
+
+/**
+ * Instances of this class are controls which are capable
+ * of containing other controls.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP, EMBEDDED, DOUBLE_BUFFERED</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
+ * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
+ * They can be used with <code>Composite</code> if you are drawing your own, but their
+ * behavior is undefined if they are used with subclasses of <code>Composite</code> other
+ * than <code>Canvas</code>.
+ * </p><p>
+ * Note: The <code>CENTER</code> style, although undefined for composites, has the
+ * same value as <code>EMBEDDED</code> (which is used to embed widgets from other
+ * widget toolkits into DWT).  On some operating systems (GTK, Motif), this may cause
+ * the children of this composite to be obscured.  The <code>EMBEDDED</code> style
+ * is for use by other widget toolkits and should normally never be used.
+ * </p><p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are constructed from aggregates
+ * of other controls.
+ * </p>
+ *
+ * @see Canvas
+ */
+public class Composite extends Scrollable {
+    Layout layout;
+    Control[] tabList;
+    int scrolledVisibleRgn, siblingsVisibleRgn;
+    int layoutCount, backgroundMode;
+
+Composite () {
+    /* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT#NO_BACKGROUND
+ * @see DWT#NO_FOCUS
+ * @see DWT#NO_MERGE_PAINTS
+ * @see DWT#NO_REDRAW_RESIZE
+ * @see DWT#NO_RADIO_GROUP
+ * @see Widget#getStyle
+ */
+public Composite (Composite parent, int style) {
+    super (parent, style);
+}
+
+Control [] _getChildren () {
+    NSArray views = contentView().subviews();
+    int count = views.count();
+    Control [] children = new Control [count];
+    int j = 0;
+    for (int i=0; i<count; i++){
+        int tag = new NSView(views.objectAtIndex(i)).tag();
+        if (tag !is 0 && tag !is -1) {
+            Object widget = OS.JNIGetObject(tag);
+            if (widget !is null && widget !is this) {
+                if (widget instanceof Control) {
+                    children [j++] = (Control) widget;
+                }
+            }
+        }
+    }
+    if (j is count) return children;
+    Control [] newChildren = new Control [j];
+    System.arraycopy (children, 0, newChildren, 0, j);
+    return newChildren;
+}
+
+Control [] _getTabList () {
+    if (tabList is null) return null;
+    int count = 0;
+    for (int i=0; i<tabList.length; i++) {
+        if (!tabList [i].isDisposed ()) count++;
+    }
+    if (count is tabList.length) return tabList;
+    Control [] newList = new Control [count];
+    int index = 0;
+    for (int i=0; i<tabList.length; i++) {
+        if (!tabList [i].isDisposed ()) {
+            newList [index++] = tabList [i];
+        }
+    }
+    tabList = newList;
+    return tabList;
+}
+
+bool acceptsFirstResponder () {
+    if ((state & CANVAS) !is 0) {
+        return ((style & DWT.NO_FOCUS) is 0);
+    }
+    return super.acceptsFirstResponder ();
+}
+
+
+/**
+ * Clears any data that has been cached by a Layout for all widgets that 
+ * are in the parent hierarchy of the changed control up to and including the 
+ * receiver.  If an ancestor does not have a layout, it is skipped.
+ * 
+ * @param changed an array of controls that changed state and require a recalculation of size
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void changed (Control[] changed) {
+    checkWidget ();
+    if (changed is null) error (DWT.ERROR_INVALID_ARGUMENT);
+    for (int i=0; i<changed.length; i++) {
+        Control control = changed [i];
+        if (control is null) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+        bool ancestor = false;
+        Composite composite = control.parent;
+        while (composite !is null) {
+            ancestor = composite is this;
+            if (ancestor) break;
+            composite = composite.parent;
+        }
+        if (!ancestor) error (DWT.ERROR_INVALID_PARENT);
+    }
+    for (int i=0; i<changed.length; i++) {
+        Control child = changed [i];
+        Composite composite = child.parent;
+        while (child !is this) {
+            if (composite.layout is null || !composite.layout.flushCache (child)) {
+                composite.state |= LAYOUT_CHANGED;
+            }
+            child = composite;
+            composite = child.parent;
+        }
+    }
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    Point size;
+    if (layout !is null) {
+        if ((wHint is DWT.DEFAULT) || (hHint is DWT.DEFAULT)) {
+            changed |= (state & LAYOUT_CHANGED) !is 0;
+            size = layout.computeSize (this, wHint, hHint, changed);
+            state &= ~LAYOUT_CHANGED;
+        } else {
+            size = new Point (wHint, hHint);
+        }
+    } else {
+        size = minimumSize (wHint, hHint, changed);
+    }
+    if (size.x is 0) size.x = DEFAULT_WIDTH;
+    if (size.y is 0) size.y = DEFAULT_HEIGHT;
+    if (wHint !is DWT.DEFAULT) size.x = wHint;
+    if (hHint !is DWT.DEFAULT) size.y = hHint;
+    Rectangle trim = computeTrim (0, 0, size.x, size.y);
+    return new Point (trim.width, trim.height);
+}
+
+protected void checkSubclass () {
+    /* Do nothing - Subclassing is allowed */
+}
+
+Control [] computeTabList () {
+    Control result [] = super.computeTabList ();
+    if (result.length is 0) return result;
+    Control [] list = tabList !is null ? _getTabList () : _getChildren ();
+    for (int i=0; i<list.length; i++) {
+        Control child = list [i];
+        Control [] childList = child.computeTabList ();
+        if (childList.length !is 0) {
+            Control [] newResult = new Control [result.length + childList.length];
+            System.arraycopy (result, 0, newResult, 0, result.length);
+            System.arraycopy (childList, 0, newResult, result.length, childList.length);
+            result = newResult;
+        }
+    }
+    return result;
+}
+
+NSView contentView () {
+    return view;
+}
+
+void createHandle () {
+    createHandle (parent.contentView());
+}
+
+void createHandle (NSView parent) {
+    state |= CANVAS;
+    NSRect rect = new NSRect();
+    if ((style & (DWT.V_SCROLL | DWT.H_SCROLL)) !is 0 || hasBorder ()) {
+        SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc();
+        scrollWidget.initWithFrame (rect);
+        scrollWidget.setDrawsBackground(false);
+        if ((style & DWT.H_SCROLL) !is 0) scrollWidget.setHasHorizontalScroller(true);
+        if ((style & DWT.V_SCROLL) !is 0) scrollWidget.setHasVerticalScroller(true);
+        scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder);
+        scrollWidget.setTag(jniRef);
+        scrollView = scrollWidget;
+        rect.width = rect.height = 100000;
+    }
+    SWTView widget = (SWTView)new SWTView().alloc();
+    widget.initWithFrame (rect);
+//  widget.setFocusRingType(OS.NSFocusRingTypeExterior);
+    widget.setTag(jniRef);
+    view = widget;
+    if (scrollView !is null) {
+//      view.setAutoresizingMask (OS.NSViewWidthSizable | OS.NSViewHeightSizable);
+        scrollView.setDocumentView(view);
+        if (parent !is null) parent.addSubview_(scrollView);
+    } else {
+        if (parent !is null) parent.addSubview_(view);
+    }
+}
+
+Composite findDeferredControl () {
+    return layoutCount > 0 ? this : parent.findDeferredControl ();
+}
+
+Menu [] findMenus (Control control) {
+    if (control is this) return new Menu [0];
+    Menu result [] = super.findMenus (control);
+    Control [] children = _getChildren ();
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        Menu [] menuList = child.findMenus (control);
+        if (menuList.length !is 0) {
+            Menu [] newResult = new Menu [result.length + menuList.length];
+            System.arraycopy (result, 0, newResult, 0, result.length);
+            System.arraycopy (menuList, 0, newResult, result.length, menuList.length);
+            result = newResult;
+        }
+    }
+    return result;
+}
+
+void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+    super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+    Control [] children = _getChildren ();
+    for (int i=0; i<children.length; i++) {
+        children [i].fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+    }
+}
+
+void fixTabList (Control control) {
+    if (tabList is null) return;
+    int count = 0;
+    for (int i=0; i<tabList.length; i++) {
+        if (tabList [i] is control) count++;
+    }
+    if (count is 0) return;
+    Control [] newList = null;
+    int length = tabList.length - count;
+    if (length !is 0) {
+        newList = new Control [length];
+        int index = 0;
+        for (int i=0; i<tabList.length; i++) {
+            if (tabList [i] !is control) {
+                newList [index++] = tabList [i];
+            }
+        }
+    }
+    tabList = newList;
+}
+
+/**
+ * Returns the receiver's background drawing mode. This
+ * will be one of the following constants defined in class
+ * <code>DWT</code>:
+ * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>,
+ * <code>INHERTIT_FORCE</code>.
+ *
+ * @return the background mode
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DWT
+ * 
+ * @since 3.2
+ */
+public int getBackgroundMode () {
+    checkWidget ();
+    return backgroundMode;
+}
+
+/**
+ * Returns a (possibly empty) array containing the receiver's children.
+ * Children are returned in the order that they are drawn.  The topmost
+ * control appears at the beginning of the array.  Subsequent controls
+ * draw beneath this control and appear later in the array.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of children, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return an array of children
+ * 
+ * @see Control#moveAbove
+ * @see Control#moveBelow
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control [] getChildren () {
+    checkWidget();
+    return _getChildren ();
+}
+
+int getChildrenCount () {
+    /*
+    * NOTE:  The current implementation will count
+    * non-registered children.
+    */
+//  short [] count = new short [1];
+//  OS.CountSubControls (handle, count);
+//  return count [0];
+    return 0;
+}
+
+/**
+ * Returns layout which is associated with the receiver, or
+ * null if one has not been set.
+ *
+ * @return the receiver's layout or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Layout getLayout () {
+    checkWidget();
+    return layout;
+}
+
+/**
+ * Returns <code>true</code> if the receiver has deferred
+ * the performing of layout, and <code>false</code> otherwise.
+ *
+ * @return the receiver's deferred layout state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLayoutDeferred(bool)
+ * @see #isLayoutDeferred()
+ *
+ * @since 3.1
+ */
+public bool getLayoutDeferred () {
+    checkWidget ();
+    return layoutCount > 0 ;
+}
+
+/**
+ * Gets the (possibly empty) tabbing order for the control.
+ *
+ * @return tabList the ordered list of controls representing the tab order
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setTabList
+ */
+public Control [] getTabList () {
+    checkWidget ();
+    Control [] tabList = _getTabList ();
+    if (tabList is null) {
+        int count = 0;
+        Control [] list =_getChildren ();
+        for (int i=0; i<list.length; i++) {
+            if (list [i].isTabGroup ()) count++;
+        }
+        tabList = new Control [count];
+        int index = 0;
+        for (int i=0; i<list.length; i++) {
+            if (list [i].isTabGroup ()) {
+                tabList [index++] = list [i];
+            }
+        }
+    }
+    return tabList;
+}
+
+bool hooksKeys () {
+    return hooks (DWT.KeyDown) || hooks (DWT.KeyUp);
+}
+
+/**
+ * Returns <code>true</code> if the receiver or any ancestor 
+ * up to and including the receiver's nearest ancestor shell
+ * has deferred the performing of layouts.  Otherwise, <code>false</code>
+ * is returned.
+ *
+ * @return the receiver's deferred layout state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLayoutDeferred(bool)
+ * @see #getLayoutDeferred()
+ * 
+ * @since 3.1
+ */
+public bool isLayoutDeferred () {
+    checkWidget ();
+    return findDeferredControl () !is null;
+}
+
+bool isTabGroup () {
+    if ((state & CANVAS) !is 0) return true;
+    return super.isTabGroup ();
+}
+
+/**
+ * If the receiver has a layout, asks the layout to <em>lay out</em>
+ * (that is, set the size and location of) the receiver's children. 
+ * If the receiver does not have a layout, do nothing.
+ * <p>
+ * This is equivalent to calling <code>layout(true)</code>.
+ * </p>
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void layout () {
+    checkWidget ();
+    layout (true);
+}
+
+/**
+ * If the receiver has a layout, asks the layout to <em>lay out</em>
+ * (that is, set the size and location of) the receiver's children. 
+ * If the argument is <code>true</code> the layout must not rely
+ * on any information it has cached about the immediate children. If it
+ * is <code>false</code> the layout may (potentially) optimize the
+ * work it is doing by assuming that none of the receiver's 
+ * children has changed state since the last layout.
+ * If the receiver does not have a layout, do nothing.
+ * <p>
+ * If a child is resized as a result of a call to layout, the 
+ * resize event will invoke the layout of the child.  The layout
+ * will cascade down through all child widgets in the receiver's widget 
+ * tree until a child is encountered that does not resize.  Note that 
+ * a layout due to a resize will not flush any cached information 
+ * (same as <code>layout(false)</code>).
+ * </p>
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ *
+ * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void layout (bool changed) {
+    checkWidget ();
+    if (layout is null) return;
+    layout (changed, false);
+}
+
+/**
+ * If the receiver has a layout, asks the layout to <em>lay out</em>
+ * (that is, set the size and location of) the receiver's children. 
+ * If the changed argument is <code>true</code> the layout must not rely
+ * on any information it has cached about its children. If it
+ * is <code>false</code> the layout may (potentially) optimize the
+ * work it is doing by assuming that none of the receiver's 
+ * children has changed state since the last layout.
+ * If the all argument is <code>true</code> the layout will cascade down
+ * through all child widgets in the receiver's widget tree, regardless of
+ * whether the child has changed size.  The changed argument is applied to 
+ * all layouts.  If the all argument is <code>false</code>, the layout will
+ * <em>not</em> cascade down through all child widgets in the receiver's widget 
+ * tree.  However, if a child is resized as a result of a call to layout, the 
+ * resize event will invoke the layout of the child.  Note that 
+ * a layout due to a resize will not flush any cached information 
+ * (same as <code>layout(false)</code>).
+ * </p>
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ *
+ * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
+ * @param all <code>true</code> if all children in the receiver's widget tree should be laid out, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void layout (bool changed, bool all) {
+    checkWidget ();
+    if (layout is null && !all) return;
+    markLayout (changed, all);
+    updateLayout (all);
+}
+
+/**
+ * Forces a lay out (that is, sets the size and location) of all widgets that 
+ * are in the parent hierarchy of the changed control up to and including the 
+ * receiver.  The layouts in the hierarchy must not rely on any information 
+ * cached about the changed control or any of its ancestors.  The layout may 
+ * (potentially) optimize the work it is doing by assuming that none of the 
+ * peers of the changed control have changed state since the last layout.
+ * If an ancestor does not have a layout, skip it.
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ * 
+ * @param changed a control that has had a state change which requires a recalculation of its size
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void layout (Control [] changed) {
+    checkWidget ();
+    if (changed is null) error (DWT.ERROR_INVALID_ARGUMENT);
+    for (int i=0; i<changed.length; i++) {
+        Control control = changed [i];
+        if (control is null) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+        bool ancestor = false;
+        Composite composite = control.parent;
+        while (composite !is null) {
+            ancestor = composite is this;
+            if (ancestor) break;
+            composite = composite.parent;
+        }
+        if (!ancestor) error (DWT.ERROR_INVALID_PARENT);
+    }
+    int updateCount = 0;
+    Composite [] update = new Composite [16];
+    for (int i=0; i<changed.length; i++) {
+        Control child = changed [i];
+        Composite composite = child.parent;
+        while (child !is this) {
+            if (composite.layout !is null) {
+                composite.state |= LAYOUT_NEEDED;
+                if (!composite.layout.flushCache (child)) {
+                    composite.state |= LAYOUT_CHANGED;
+                }
+            }
+            if (updateCount is update.length) {
+                Composite [] newUpdate = new Composite [update.length + 16];
+                System.arraycopy (update, 0, newUpdate, 0, update.length);
+                update = newUpdate;
+            }
+            child = update [updateCount++] = composite;
+            composite = child.parent;
+        }
+    }
+    for (int i=updateCount-1; i>=0; i--) {
+        update [i].updateLayout (false);
+    }
+}
+
+void markLayout (bool changed, bool all) {
+    if (layout !is null) {
+        state |= LAYOUT_NEEDED;
+        if (changed) state |= LAYOUT_CHANGED;
+    }
+    if (all) {
+        Control [] children = _getChildren ();
+        for (int i=0; i<children.length; i++) {
+            children [i].markLayout (changed, all);
+        }
+    }
+}
+
+Point minimumSize (int wHint, int Hint, bool changed) {
+    Control [] children = _getChildren ();
+    int width = 0, height = 0;
+    for (int i=0; i<children.length; i++) {
+        Rectangle rect = children [i].getBounds ();
+        width = Math.max (width, rect.x + rect.width);
+        height = Math.max (height, rect.y + rect.height);
+    }
+    return new Point (width, height);
+}
+
+void releaseChildren (bool destroy) {
+    Control [] children = _getChildren ();
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        if (child !is null && !child.isDisposed ()) {
+            child.release (false);
+        }
+    }
+    super.releaseChildren (destroy);
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    layout = null;
+    tabList = null;
+}
+
+void removeControl (Control control) {
+    fixTabList (control);
+}
+
+/**
+ * Sets the background drawing mode to the argument which should
+ * be one of the following constants defined in class <code>DWT</code>:
+ * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>,
+ * <code>INHERIT_FORCE</code>.
+ *
+ * @param mode the new background mode
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DWT
+ * 
+ * @since 3.2
+ */
+public void setBackgroundMode (int mode) {
+    checkWidget ();
+    backgroundMode = mode;
+    Control [] children = _getChildren ();
+    for (int i = 0; i < children.length; i++) {
+        children [i].updateBackgroundMode ();
+    }
+}
+
+int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+    int result = super.setBounds (x, y, width, height, move, resize);
+    if (layout !is null && (result & RESIZED) !is 0) {
+        markLayout (false, false);
+        updateLayout (false);
+    }
+    return result;
+}
+
+public bool setFocus () {
+    checkWidget ();
+    Control [] children = _getChildren ();
+    for (int i= 0; i < children.length; i++) {
+        if (children [i].setFocus ()) return true;
+    }
+    return super.setFocus ();
+}
+
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+    checkWidget();
+    this.layout = layout;
+}
+
+/**
+ * If the argument is <code>true</code>, causes subsequent layout
+ * operations in the receiver or any of its children to be ignored.
+ * No layout of any kind can occur in the receiver or any of its
+ * children until the flag is set to false.
+ * Layout operations that occurred while the flag was
+ * <code>true</code> are remembered and when the flag is set to 
+ * <code>false</code>, the layout operations are performed in an
+ * optimized manner.  Nested calls to this method are stacked.
+ *
+ * @param defer the new defer state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #layout(bool)
+ * @see #layout(Control[])
+ *
+ * @since 3.1
+ */
+public void setLayoutDeferred (bool defer) {
+    if (!defer) {
+        if (--layoutCount is 0) {
+            if ((state & LAYOUT_CHILD) !is 0 || (state & LAYOUT_NEEDED) !is 0) {
+                updateLayout (true);
+            }
+        }
+    } else {
+        layoutCount++;
+    }
+}
+
+
+bool setScrollBarVisible (ScrollBar bar, bool visible) {
+    bool changed = super.setScrollBarVisible (bar, visible);
+    if (changed && layout !is null) {
+        markLayout (false, false);
+        updateLayout (false);
+    }
+    return changed;
+}
+
+bool setTabGroupFocus () {
+    if (isTabItem ()) return setTabItemFocus ();
+    bool takeFocus = (style & DWT.NO_FOCUS) is 0;
+    if ((state & CANVAS) !is 0) takeFocus = hooksKeys ();
+    if (takeFocus && setTabItemFocus ()) return true;
+    Control [] children = _getChildren ();
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        if (child.isTabItem () && child.setTabItemFocus ()) return true;
+    }
+    return false;
+}
+
+/**
+ * Sets the tabbing order for the specified controls to
+ * match the order that they occur in the argument list.
+ *
+ * @param tabList the ordered list of controls representing the tab order or null
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabList (Control [] tabList) {
+    checkWidget ();
+    if (tabList !is null) {
+        for (int i=0; i<tabList.length; i++) {
+            Control control = tabList [i];
+            if (control is null) error (DWT.ERROR_INVALID_ARGUMENT);
+            if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+            if (control.parent !is this) error (DWT.ERROR_INVALID_PARENT);
+        }
+        Control [] newList = new Control [tabList.length];
+        System.arraycopy (tabList, 0, newList, 0, tabList.length);
+        tabList = newList;
+    } 
+    this.tabList = tabList;
+}
+
+int traversalCode (int key, NSEvent theEvent) {
+    if ((state & CANVAS) !is 0) {
+        if ((style & DWT.NO_FOCUS) !is 0) return 0;
+        if (hooksKeys ()) return 0;
+    }
+    return super.traversalCode (key, theEvent);
+}
+
+void updateBackgroundMode () {
+    super.updateBackgroundMode ();
+    Control [] children = _getChildren ();
+    for (int i = 0; i < children.length; i++) {
+        children [i].updateBackgroundMode ();
+    }
+}
+
+void updateLayout (bool all) {
+    Composite parent = findDeferredControl ();
+    if (parent !is null) {
+        parent.state |= LAYOUT_CHILD;
+        return;
+    }
+    if ((state & LAYOUT_NEEDED) !is 0) {
+        bool changed = (state & LAYOUT_CHANGED) !is 0;
+        state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+        layout.layout (this, changed);
+    }
+    if (all) {
+        state &= ~LAYOUT_CHILD;
+        Control [] children = _getChildren ();
+        for (int i=0; i<children.length; i++) {
+            children [i].updateLayout (all);
+        }
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Control.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,3285 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Control;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.accessibility.Accessible;
+import dwt.events.ControlListener;
+import dwt.events.DragDetectListener;
+import dwt.events.FocusListener;
+import dwt.events.HelpListener;
+import dwt.events.KeyListener;
+import dwt.events.MenuDetectListener;
+import dwt.events.MouseEvent;
+import dwt.events.MouseListener;
+import dwt.events.MouseMoveListener;
+import dwt.events.MouseTrackListener;
+import dwt.events.MouseWheelListener;
+import dwt.events.PaintListener;
+import dwt.events.TraverseListener;
+import dwt.graphics.Color;
+import dwt.graphics.Cursor;
+import dwt.graphics.Drawable;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.GCData;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.graphics.Region;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.objc_super;
+
+/**
+ * Control is the abstract superclass of all windowed user interface classes.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER</dd>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * <dt><b>Events:</b>
+ * <dd>DragDetect, FocusIn, FocusOut, Help, KeyDown, KeyUp, MenuDetect, MouseDoubleClick, MouseDown, MouseEnter,
+ *     MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize, Traverse</dd>
+ * </dl>
+ * </p><p>
+ * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public abstract class Control extends Widget implements Drawable {
+    /**
+     * the handle to the OS resource 
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public NSView view;
+    Composite parent;
+    String toolTipText;
+    Object layoutData;
+    int drawCount;
+//  int visibleRgn;
+    Menu menu;
+    Color foreground, background;
+    Image backgroundImage;
+    Font font;
+    Cursor cursor;
+    Region region;
+//  GCData gcs[];
+    Accessible accessible;
+
+//  static final String RESET_VISIBLE_REGION = "dwt.internal.resetVisibleRegion";
+
+Control () {
+    /* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#BORDER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Control (Composite parent, int style) {
+    super (parent, style);
+    this.parent = parent;
+    createWidget ();
+}
+
+bool acceptsFirstResponder () {
+    objc_super super_struct = new objc_super();
+    super_struct.receiver = view.id;
+    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
+    return OS.objc_msgSendSuper(super_struct, OS.sel_acceptsFirstResponder) !is 0;
+}
+
+bool becomeFirstResponder () {
+//TODO - query focusControl() in DWT.FocusIn/Out is the control
+    sendEvent (DWT.FocusIn);
+    objc_super super_struct = new objc_super();
+    super_struct.receiver = view.id;
+    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
+    return OS.objc_msgSendSuper(super_struct, OS.sel_becomeFirstResponder) !is 0;
+}
+
+bool resignFirstResponder () {
+//TODO - query focusControl() in DWT.FocusIn/Out is the control
+    sendEvent (DWT.FocusOut);
+    objc_super super_struct = new objc_super();
+    super_struct.receiver = view.id;
+    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
+    return OS.objc_msgSendSuper(super_struct, OS.sel_resignFirstResponder) !is 0;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener(ControlListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Resize,typedListener);
+    addListener (DWT.Move,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag gesture occurs, by sending it
+ * one of the messages defined in the <code>DragDetectListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragDetectListener
+ * @see #removeDragDetectListener
+ * 
+ * @since 3.3
+ */
+public void addDragDetectListener (DragDetectListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.DragDetect,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control gains or loses focus, by sending
+ * it one of the messages defined in the <code>FocusListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see FocusListener
+ * @see #removeFocusListener
+ */
+public void addFocusListener(FocusListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener(DWT.FocusIn,typedListener);
+    addListener(DWT.FocusOut,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when help events are generated for the control,
+ * by sending it one of the messages defined in the
+ * <code>HelpListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
+public void addHelpListener (HelpListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Help, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard, by sending
+ * it one of the messages defined in the <code>KeyListener</code>
+ * interface.
+ * <p>
+ * 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.
+ * </p>
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #removeKeyListener
+ */
+public void addKeyListener(KeyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener(DWT.KeyUp,typedListener);
+    addListener(DWT.KeyDown,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the platform-specific context menu trigger
+ * has occurred, by sending it one of the messages defined in
+ * the <code>MenuDetectListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #removeMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void addMenuDetectListener (MenuDetectListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.MenuDetect, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when mouse buttons are pressed and released, by sending
+ * it one of the messages defined in the <code>MouseListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseListener
+ * @see #removeMouseListener
+ */
+public void addMouseListener(MouseListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener(DWT.MouseDown,typedListener);
+    addListener(DWT.MouseUp,typedListener);
+    addListener(DWT.MouseDoubleClick,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse passes or hovers over controls, by sending
+ * it one of the messages defined in the <code>MouseTrackListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseTrackListener
+ * @see #removeMouseTrackListener
+ */
+public void addMouseTrackListener (MouseTrackListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.MouseEnter,typedListener);
+    addListener (DWT.MouseExit,typedListener);
+    addListener (DWT.MouseHover,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse moves, by sending it one of the
+ * messages defined in the <code>MouseMoveListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseMoveListener
+ * @see #removeMouseMoveListener
+ */
+public void addMouseMoveListener(MouseMoveListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener(DWT.MouseMove,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse wheel is scrolled, by sending
+ * it one of the messages defined in the
+ * <code>MouseWheelListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseWheelListener
+ * @see #removeMouseWheelListener
+ *
+ * @since 3.3
+ */
+public void addMouseWheelListener (MouseWheelListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.MouseWheel, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver needs to be painted, by sending it
+ * one of the messages defined in the <code>PaintListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see PaintListener
+ * @see #removePaintListener
+ */
+public void addPaintListener(PaintListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener(DWT.Paint,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when traversal events occur, by sending it
+ * one of the messages defined in the <code>TraverseListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TraverseListener
+ * @see #removeTraverseListener
+ */
+public void addTraverseListener (TraverseListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Traverse,typedListener);
+}
+
+void checkBackground () {
+    Shell shell = getShell ();
+    if (this is shell) return;
+    state &= ~PARENT_BACKGROUND;    
+    Composite composite = parent;
+    do {
+        int mode = composite.backgroundMode;
+        if (mode !is 0) {
+            if (mode is DWT.INHERIT_DEFAULT) {
+                Control control = this;
+                do {
+                    if ((control.state & THEME_BACKGROUND) is 0) {
+                        return;
+                    }
+                    control = control.parent;
+                } while (control !is composite);
+            }
+            state |= PARENT_BACKGROUND;                 
+            return;
+        }
+        if (composite is shell) break;
+        composite = composite.parent;
+    } while (true);
+}
+
+void checkBuffered () {
+    style |= DWT.DOUBLE_BUFFERED;
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>DWT.DEFAULT</code> is passed for the hint. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>DWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>DWT.DEFAULT</code>)
+ * @return the preferred size of the control
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack(bool)
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+public Point computeSize (int wHint, int hHint) {
+    return computeSize (wHint, hHint, true);
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>DWT.DEFAULT</code> is passed for the hint. 
+ * </p><p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>DWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>DWT.DEFAULT</code>)
+ * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
+ * @return the preferred size of the control.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack(bool)
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = DEFAULT_WIDTH;
+    int height = DEFAULT_HEIGHT;
+//  if (wHint !is DWT.DEFAULT) width = wHint;
+//  if (hHint !is DWT.DEFAULT) height = hHint;
+//  int border = getBorderWidth ();
+//  width += border * 2;
+//  height += border * 2;
+//  return new Point (width, height);
+    if (topView() instanceof NSControl) {
+        NSRect oldRect = topView().frame();
+        ((NSControl)topView()).sizeToFit();
+        NSRect newRect = topView().frame();
+        topView().setFrame (oldRect);
+        return new Point ((int)newRect.width, (int)newRect.height);
+    }
+    return new Point (width, height);
+}
+
+Control computeTabGroup () {
+    if (isTabGroup()) return this;
+    return parent.computeTabGroup ();
+}
+
+Control[] computeTabList() {
+    if (isTabGroup()) {
+        if (getVisible() && getEnabled()) {
+            return new Control[] {this};
+        }
+    }
+    return new Control[0];
+}
+
+Control computeTabRoot () {
+    Control[] tabList = parent._getTabList();
+    if (tabList !is null) {
+        int index = 0;
+        while (index < tabList.length) {
+            if (tabList [index] is this) break;
+            index++;
+        }
+        if (index is tabList.length) {
+            if (isTabGroup ()) return this;
+        }
+    }
+    return parent.computeTabRoot ();
+}
+
+void createWidget () {
+    state |= DRAG_DETECT;
+    checkOrientation (parent);
+    super.createWidget ();
+    checkBackground ();
+    checkBuffered ();
+    setDefaultFont ();
+    setZOrder ();
+}
+
+Color defaultBackground () {
+    return display.getSystemColor (DWT.COLOR_WIDGET_BACKGROUND);
+}
+
+Font defaultFont () {
+    //TODO - Controls only, does this leak?
+    if (view instanceof NSControl) {
+        NSFont nsFont = ((NSControl)view).font ();
+        if (nsFont !is null) {
+            return Font.cocoa_new (display, nsFont);
+        }
+    }
+    return display.getSystemFont ();
+}
+
+Color defaultForeground () {
+    return display.getSystemColor (DWT.COLOR_WIDGET_FOREGROUND);
+}
+
+void destroyWidget () {
+    NSView view = topView ();
+    view.removeFromSuperview ();
+    releaseHandle ();
+}
+
+/**
+ * Detects a drag and drop gesture.  This method is used
+ * to detect a drag gesture when called from within a mouse
+ * down listener.
+ * 
+ * <p>By default, a drag is detected when the gesture
+ * occurs anywhere within the client area of a control.
+ * Some controls, such as tables and trees, override this
+ * behavior.  In addition to the operating system specific
+ * drag gesture, they require the mouse to be inside an
+ * item.  Custom widget writers can use <code>setDragDetect</code>
+ * to disable the default detection, listen for mouse down,
+ * and then call <code>dragDetect()</code> from within the
+ * listener to conditionally detect a drag.
+ * </p>
+ *
+ * @param event the mouse down event
+ * 
+ * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when the event is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see DragDetectListener
+ * @see #addDragDetectListener
+ * 
+ * @see #getDragDetect
+ * @see #setDragDetect
+ * 
+ * @since 3.3
+ */
+public bool dragDetect (Event event) {
+    checkWidget ();
+    if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
+    return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
+}
+
+/**
+ * Detects a drag and drop gesture.  This method is used
+ * to detect a drag gesture when called from within a mouse
+ * down listener.
+ * 
+ * <p>By default, a drag is detected when the gesture
+ * occurs anywhere within the client area of a control.
+ * Some controls, such as tables and trees, override this
+ * behavior.  In addition to the operating system specific
+ * drag gesture, they require the mouse to be inside an
+ * item.  Custom widget writers can use <code>setDragDetect</code>
+ * to disable the default detection, listen for mouse down,
+ * and then call <code>dragDetect()</code> from within the
+ * listener to conditionally detect a drag.
+ * </p>
+ *
+ * @param event the mouse down event
+ * 
+ * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when the event is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DragDetectListener
+ * @see #addDragDetectListener
+ * 
+ * @see #getDragDetect
+ * @see #setDragDetect
+ * 
+ * @since 3.3
+ */
+public bool dragDetect (MouseEvent event) {
+    checkWidget ();
+    if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
+    return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
+}
+
+bool dragDetect (int button, int count, int stateMask, int x, int y) {
+    if (button !is 1 || count !is 1) return false;
+    if (!dragDetect (x, y, false, null)) return false;
+    return sendDragEvent (button, stateMask, x, y);
+}
+
+bool dragDetect (int x, int y, bool filter, bool [] consume) {
+//  Rect rect = new Rect ();
+//  int window = OS.GetControlOwner (handle);
+//  CGPoint pt = new CGPoint ();
+//  OS.HIViewConvertPoint (pt, handle, 0);
+//  x += (int) pt.x;
+//  y += (int) pt.y;
+//  OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
+//  x += rect.left;
+//  y += rect.top;
+//  dwt.internal.carbon.Point pt1 = new dwt.internal.carbon.Point ();
+//  pt1.h = (short) x;
+//  pt1.v = (short) y;
+//  return OS.WaitMouseMoved (pt1);
+    return false;
+}
+
+bool drawGripper (int x, int y, int width, int height, bool vertical) {
+    return false;
+}
+
+void drawRect(int id, NSRect rect) {
+    super.drawRect(id, rect);
+    if (!hooks (DWT.Paint) && !filters (DWT.Paint)) return;
+
+    /* Send paint event */
+    GCData data = new GCData ();
+    data.paintRect = rect;
+    GC gc = GC.cocoa_new (this, data);
+    Event event = new Event ();
+    event.gc = gc;
+    event.x = (int)rect.x;
+    event.y = (int)rect.y;
+    event.width = (int)rect.width;
+    event.height = (int)rect.height;
+    sendEvent (DWT.Paint, event);
+    event.gc = null;
+    gc.dispose ();
+}
+
+void enableWidget (bool enabled) {
+    //TODO - other views
+    if (view instanceof NSControl) {
+        ((NSControl)view).setEnabled(enabled);
+    }
+}
+
+Cursor findCursor () {
+    if (cursor !is null) return cursor;
+    return parent.findCursor ();
+}
+
+Control findBackgroundControl () {
+    if (backgroundImage !is null || background !is null) return this;
+    return (state & PARENT_BACKGROUND) !is 0 ? parent.findBackgroundControl () : null;
+}
+
+Menu [] findMenus (Control control) {
+    if (menu !is null && this !is control) return new Menu [] {menu};
+    return new Menu [0];
+}
+
+void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+    oldShell.fixShell (newShell, this);
+    oldDecorations.fixDecorations (newDecorations, this, menus);
+}
+
+void fixFocus (Control focusControl) {
+    Shell shell = getShell ();
+    Control control = this;
+    while (control !is shell && (control = control.parent) !is null) {
+        if (control.setFocus ()) return;
+    }
+    shell.setSavedFocus (focusControl);
+//  int window = OS.GetControlOwner (handle);
+//  OS.ClearKeyboardFocus (window);
+}
+
+/**
+ * Forces the receiver to have the <em>keyboard focus</em>, causing
+ * all keyboard events to be delivered to it.
+ *
+ * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setFocus
+ */
+public bool forceFocus () {
+    checkWidget();
+//  if (display.focusEvent is DWT.FocusOut) return false;
+    Decorations shell = menuShell ();
+    shell.setSavedFocus (this);
+    if (!isEnabled () || !isVisible ()/* || !isActive ()*/) return false;
+    if (isFocusControl ()) return true;
+    shell.setSavedFocus (null);
+    shell.bringToTop (false);
+    if (isDisposed ()) return false;
+    view.window ().makeFirstResponder (view);
+    if (isDisposed ()) return false;
+    shell.setSavedFocus (this);
+    return hasFocus ();
+}
+
+/**
+ * Returns the accessible object for the receiver.
+ * If this is the first time this object is requested,
+ * then the object is created and returned.
+ *
+ * @return the accessible object
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Accessible#addAccessibleListener
+ * @see Accessible#addAccessibleControlListener
+ * 
+ * @since 2.0
+ */
+public Accessible getAccessible () {
+    checkWidget ();
+    if (accessible is null) accessible = new_Accessible (this);
+    return accessible;
+}
+    
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Color getBackground () {
+    checkWidget();
+    Control control = findBackgroundControl ();
+    if (control is null) control = this;
+    return control.getBackgroundColor ();
+}
+
+Color getBackgroundColor () {
+    return background !is null ? background : defaultBackground ();
+}
+
+/**
+ * Returns the receiver's background image.
+ *
+ * @return the background image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Image getBackgroundImage () {
+    checkWidget();
+    Control control = findBackgroundControl ();
+    if (control is null) control = this;
+    return control.backgroundImage;
+}
+
+/**
+ * Returns the receiver's border width.
+ *
+ * @return the border width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getBorderWidth () {
+    checkWidget();
+    return 0;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent (or its display if its parent is null),
+ * unless the receiver is a shell. In this case, the location is
+ * relative to the display.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+    checkWidget();
+    NSRect rect = topView().frame();
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is detecting
+ * drag gestures, and  <code>false</code> otherwise. 
+ *
+ * @return the receiver's drag detect state
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public bool getDragDetect () {
+    checkWidget ();
+    return (state & DRAG_DETECT) !is 0;
+}
+
+/**
+ * Returns the receiver's cursor, or null if it has not been set.
+ * <p>
+ * When the mouse pointer passes over a control its appearance
+ * is changed to match the control's cursor.
+ * </p>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Cursor getCursor () {
+    checkWidget();
+    return cursor;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public bool getEnabled () {
+    checkWidget();
+    return (state & DISABLED) is 0;
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Font getFont () {
+    checkWidget();
+    return font !is null ? font : defaultFont ();
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Color getForeground () {
+    checkWidget();
+    return getForegroundColor ();
+}
+
+Color getForegroundColor () {
+    return foreground !is null ? foreground: defaultForeground ();
+}
+
+/**
+ * Returns layout data which is associated with the receiver.
+ *
+ * @return the receiver's layout data
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Object getLayoutData () {
+    checkWidget();
+    return layoutData;
+}
+
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null), unless
+ * the receiver is a shell. In this case, the point is 
+ * relative to the display. 
+ *
+ * @return the receiver's location
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getLocation () {
+    checkWidget();
+    NSRect rect = topView().frame();
+    return new Point((int)rect.x, (int)rect.y);
+}
+
+/**
+ * Returns the receiver's pop up menu if it has one, or null
+ * if it does not. All controls may optionally have a pop up
+ * menu that is displayed when the user requests one for
+ * the control. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pop up
+ * menu is platform specific.
+ *
+ * @return the receiver's menu
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getMenu () {
+    checkWidget();
+    return menu;
+}
+
+int getMininumHeight () {
+    return 0;
+}
+
+/**
+ * Returns the receiver's monitor.
+ * 
+ * @return the receiver's monitor
+ * 
+ * @since 3.0
+ */
+public Monitor getMonitor () {
+    checkWidget();
+    Monitor [] monitors = display.getMonitors ();
+    if (monitors.length is 1) return monitors [0];
+    int index = -1, value = -1;
+    Rectangle bounds = getBounds ();
+    if (this !is getShell ()) {
+        bounds = display.map (this.parent, null, bounds);
+    }
+    for (int i=0; i<monitors.length; i++) {
+        Rectangle rect = bounds.intersection (monitors [i].getBounds ());
+        int area = rect.width * rect.height;
+        if (area > 0 && area > value) {
+            index = i;
+            value = area;
+        }
+    }
+    if (index >= 0) return monitors [index];
+    int centerX = bounds.x + bounds.width / 2, centerY = bounds.y + bounds.height / 2;
+    for (int i=0; i<monitors.length; i++) {
+        Rectangle rect = monitors [i].getBounds ();
+        int x = centerX < rect.x ? rect.x - centerX : centerX > rect.x + rect.width ? centerX - rect.x - rect.width : 0;
+        int y = centerY < rect.y ? rect.y - centerY : centerY > rect.y + rect.height ? centerY - rect.y - rect.height : 0;
+        int distance = x * x + y * y;
+        if (index is -1 || distance < value) {
+            index = i;
+            value = distance;
+        } 
+    }
+    return monitors [index];
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Composite</code>
+ * or null when the receiver is a shell that was created with null or
+ * a display for a parent.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Composite getParent () {
+    checkWidget();
+    return parent;
+}
+
+Control [] getPath () {
+    int count = 0;
+    Shell shell = getShell ();
+    Control control = this;
+    while (control !is shell) {
+        count++;
+        control = control.parent;
+    }
+    control = this;
+    Control [] result = new Control [count];
+    while (control !is shell) {
+        result [--count] = control;
+        control = control.parent;
+    }
+    return result;
+}
+
+public Region getRegion () {
+    checkWidget ();
+    return region;
+}
+
+/**
+ * Returns the receiver's shell. For all controls other than
+ * shells, this simply returns the control's nearest ancestor
+ * shell. Shells return themselves, even if they are children
+ * of other shells.
+ *
+ * @return the receiver's shell
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getParent
+ */
+public Shell getShell () {
+    checkWidget();
+    return parent.getShell ();
+}
+
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+    checkWidget();
+    NSRect rect = topView().frame();
+    return new Point((int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+    checkWidget();
+    return toolTipText;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getVisible () {
+    checkWidget();
+    return (state & HIDDEN) is 0;
+}
+
+bool hasBorder () {
+    return (style & DWT.BORDER) !is 0;
+}
+
+bool hasFocus () {
+    return this is display.getFocusControl ();
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Control</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public int internal_new_GC (GCData data) {
+    checkWidget();
+    int context = 0;
+    if (data !is null && data.paintRect !is null) {
+        context = NSGraphicsContext.currentContext().id;
+    } else {
+        context = NSGraphicsContext.graphicsContextWithWindow(view.window()).id;
+    }
+    if (data !is null) {
+        int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+        if ((data.style & mask) is 0) {
+            data.style |= style & (mask | DWT.MIRRORED);
+        }
+        data.device = display;
+        data.view = view;
+        data.foreground = getForegroundColor ().handle;
+        Control control = findBackgroundControl ();
+        if (control is null) control = this;
+        data.background = control.getBackgroundColor ().handle;
+        data.font = font !is null ? font : defaultFont ();       
+    }
+    return context;
+}
+
+/**  
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Control</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int context, GCData data) {
+    checkWidget (); 
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * ancestors up to and including the receiver's nearest ancestor
+ * shell are enabled.  Otherwise, <code>false</code> is returned.
+ * A disabled control is typically not selectable from the user
+ * interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public bool isEnabled () {
+    checkWidget();
+    return getEnabled () && parent.isEnabled ();
+}
+
+bool isEnabledCursor () {
+    return isEnabled ();
+}
+
+bool isFocusAncestor (Control control) {
+    while (control !is null && control !is this && !(control instanceof Shell)) {
+        control = control.parent;
+    }
+    return control is this;
+}
+
+/**
+ * Returns <code>true</code> if the receiver has the user-interface
+ * focus, and <code>false</code> otherwise.
+ *
+ * @return the receiver's focus state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool isFocusControl () {
+    checkWidget();
+//  Control focusControl = display.focusControl;
+//  if (focusControl !is null && !focusControl.isDisposed ()) {
+//      return this is focusControl;
+//  }
+    return hasFocus ();
+}
+
+/**
+ * Returns <code>true</code> if the underlying operating
+ * system supports this reparenting, otherwise <code>false</code>
+ *
+ * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool isReparentable () {
+    checkWidget();
+    return true;
+}
+
+bool isShowing () {
+    /*
+    * This is not complete.  Need to check if the
+    * widget is obscurred by a parent or sibling.
+    */
+    if (!isVisible ()) return false;
+    Control control = this;
+    while (control !is null) {
+        Point size = control.getSize ();
+        if (size.x is 0 || size.y is 0) {
+            return false;
+        }
+        control = control.parent;
+    }
+    return true;
+}
+
+bool isTabGroup () {
+    Control [] tabList = parent._getTabList ();
+    if (tabList !is null) {
+        for (int i=0; i<tabList.length; i++) {
+            if (tabList [i] is this) return true;
+        }
+    }
+    int code = traversalCode (0, null);
+    if ((code & (DWT.TRAVERSE_ARROW_PREVIOUS | DWT.TRAVERSE_ARROW_NEXT)) !is 0) return false;
+    return (code & (DWT.TRAVERSE_TAB_PREVIOUS | DWT.TRAVERSE_TAB_NEXT)) !is 0;
+}
+
+bool isTabItem () {
+    Control [] tabList = parent._getTabList ();
+    if (tabList !is null) {
+        for (int i=0; i<tabList.length; i++) {
+            if (tabList [i] is this) return false;
+        }
+    }
+    int code = traversalCode (0, null);
+    return (code & (DWT.TRAVERSE_ARROW_PREVIOUS | DWT.TRAVERSE_ARROW_NEXT)) !is 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * ancestors up to and including the receiver's nearest ancestor
+ * shell are visible. Otherwise, <code>false</code> is returned.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public bool isVisible () {
+    checkWidget();
+    return getVisible () && parent.isVisible ();
+}
+
+int menuForEvent (int nsEvent) {
+    NSPoint pt = NSEvent.mouseLocation();   
+    NSWindow window = view.window();
+    pt.y = (int) (window.screen().frame().height - pt.y);
+    int x = (int) pt.x;
+    int y = (int) pt.y;
+    Event event = new Event ();
+    event.x = x;
+    event.y = y;
+    sendEvent (DWT.MenuDetect, event);
+    if (!event.doit) return 0;
+    Menu menu = getMenu ();
+    if (menu !is null && !menu.isDisposed ()) {
+        if (x !is event.x || y !is event.y) {
+            menu.setLocation (event.x, event.y);
+        }
+        return menu.nsMenu.id;
+    }
+    objc_super super_struct = new objc_super();
+    super_struct.receiver = view.id;
+    super_struct.cls = OS.objc_msgSend(view.id, OS.sel_superclass);
+    return OS.objc_msgSendSuper(super_struct, OS.sel_menuForEvent_1, nsEvent);
+}
+
+Decorations menuShell () {
+    return parent.menuShell ();
+}
+
+bool setInputState (Event event, NSEvent nsEvent, int type) {
+    int modifierFlags = nsEvent.modifierFlags();
+    if ((modifierFlags & OS.NSAlternateKeyMask) !is 0) event.stateMask |= DWT.ALT;
+    if ((modifierFlags & OS.NSShiftKeyMask) !is 0) event.stateMask |= DWT.SHIFT;
+    if ((modifierFlags & OS.NSControlKeyMask) !is 0) event.stateMask |= DWT.CONTROL;
+    if ((modifierFlags & OS.NSCommandKeyMask) !is 0) event.stateMask |= DWT.COMMAND;
+    
+    //WRONG
+    if ((modifierFlags & OS.NSLeftMouseDownMask) !is 0) event.stateMask |= DWT.BUTTON1;
+    if ((modifierFlags & OS.NSLeftMouseDraggedMask) !is 0) event.stateMask |= DWT.BUTTON1;
+    if ((modifierFlags & OS.NSLeftMouseUpMask) !is 0) event.stateMask |= DWT.BUTTON1;
+    if ((modifierFlags & OS.NSOtherMouseDownMask) !is 0) event.stateMask |= DWT.BUTTON2;
+    if ((modifierFlags & OS.NSOtherMouseDraggedMask) !is 0) event.stateMask |= DWT.BUTTON2;
+    if ((modifierFlags & OS.NSOtherMouseUpMask) !is 0) event.stateMask |= DWT.BUTTON1;
+    if ((modifierFlags & OS.NSRightMouseDownMask) !is 0) event.stateMask |= DWT.BUTTON3;
+    if ((modifierFlags & OS.NSRightMouseDraggedMask) !is 0) event.stateMask |= DWT.BUTTON3;
+    if ((modifierFlags & OS.NSRightMouseUpMask) !is 0) event.stateMask |= DWT.BUTTON3;
+    
+//  if (OS.GetKeyState (OS.VK_XBUTTON1) < 0) event.stateMask |= DWT.BUTTON4;
+//  if (OS.GetKeyState (OS.VK_XBUTTON2) < 0) event.stateMask |= DWT.BUTTON5;
+//  switch (type) {
+//      case DWT.MouseDown:
+//      case DWT.MouseDoubleClick:
+//          if (event.button is 1) event.stateMask &= ~DWT.BUTTON1;
+//          if (event.button is 2) event.stateMask &= ~DWT.BUTTON2;
+//          if (event.button is 3) event.stateMask &= ~DWT.BUTTON3;
+//          if (event.button is 4) event.stateMask &= ~DWT.BUTTON4;
+//          if (event.button is 5) event.stateMask &= ~DWT.BUTTON5;
+//          break;
+//      case DWT.MouseUp:
+//          if (event.button is 1) event.stateMask |= DWT.BUTTON1;
+//          if (event.button is 2) event.stateMask |= DWT.BUTTON2;
+//          if (event.button is 3) event.stateMask |= DWT.BUTTON3;
+//          if (event.button is 4) event.stateMask |= DWT.BUTTON4;
+//          if (event.button is 5) event.stateMask |= DWT.BUTTON5;
+//          break;
+//      case DWT.KeyDown:
+//      case DWT.Traverse:
+//          if (event.keyCode is DWT.ALT) event.stateMask &= ~DWT.ALT;
+//          if (event.keyCode is DWT.SHIFT) event.stateMask &= ~DWT.SHIFT;
+//          if (event.keyCode is DWT.CONTROL) event.stateMask &= ~DWT.CONTROL;
+//          break;
+//      case DWT.KeyUp:
+//          if (event.keyCode is DWT.ALT) event.stateMask |= DWT.ALT;
+//          if (event.keyCode is DWT.SHIFT) event.stateMask |= DWT.SHIFT;
+//          if (event.keyCode is DWT.CONTROL) event.stateMask |= DWT.CONTROL;
+//          break;
+//  }       
+    return true;
+}
+
+void sendMouseEvent (NSEvent nsEvent, int type, int button) {
+    Event event = new Event ();
+    event.button = button;
+//  event.detail = detail;
+    event.count = nsEvent.clickCount();
+    NSPoint location = nsEvent.locationInWindow();
+    NSPoint point = view.convertPoint_fromView_(location, null);
+    event.x = (int) point.x;
+    event.y = (int) point.y;
+    setInputState (event, nsEvent, type);
+    sendEvent (type, event);
+}
+
+void mouseDown(int theEvent) {
+    NSEvent nsEvent = new NSEvent (theEvent);
+    sendMouseEvent (nsEvent, DWT.MouseDown, 1);
+}
+
+void mouseDragged(int theEvent) {
+    NSEvent nsEvent = new NSEvent (theEvent);
+    sendMouseEvent (nsEvent, DWT.MouseMove, 1);
+}
+
+void mouseUp(int theEvent) {
+    NSEvent nsEvent = new NSEvent (theEvent);
+    sendMouseEvent (nsEvent, DWT.MouseUp, 1);
+}
+
+bool sendKeyEvent (Event event) {
+    sendEvent (event);
+    return event.doit;
+}
+
+//TODO - missing modifier keys (see flagsChanged:)
+bool sendKeyEvent (NSEvent nsEvent, int type) {
+    if ((state & SAFARI_EVENTS_FIX) !is 0) return false;
+    int count = 0;
+    NSString keys = nsEvent.characters();
+    //TODO - check lowercase doesn't mangle char codes
+    NSString keyCodes = nsEvent.charactersIgnoringModifiers().lowercaseString();
+    char [] chars = new char [keys.length()];
+    for (int i=0; i<keys.length(); i++) {
+        Event event = new Event ();
+        int keyCode = Display.translateKey (keys.characterAtIndex (i) & 0xFFFF);
+        if (keyCode !is 0) {
+            event.keyCode = keyCode;
+        } else {
+            event.character = (char) keys.characterAtIndex (i);
+            //TODO - get unshifted values for Shift+1
+            event.keyCode = keyCodes.characterAtIndex (i);
+        }
+        setInputState (event, nsEvent, type);
+        if (!setKeyState(event, type, nsEvent)) return false;
+        if (sendKeyEvent (type, event)) {
+            chars [count++] = chars [i];
+        }
+    }
+//  if (count is 0) return false;
+    if (count !is keys.length () - 1) {
+//      OS.SetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, count * 2, chars);
+    }
+    return count is keys.length ();
+}
+
+void markLayout (bool changed, bool all) {
+    /* Do nothing */
+}
+
+/**
+ * Moves the receiver above the specified control in the
+ * drawing order. If the argument is null, then the receiver
+ * is moved to the top of the drawing order. The control at
+ * the top of the drawing order will not be covered by other
+ * controls even if they occupy intersecting areas.
+ *
+ * @param control the sibling control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Control#moveBelow
+ * @see Composite#getChildren
+ */
+public void moveAbove (Control control) {
+    checkWidget();
+    if (control !is null) {
+        if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (parent !is control.parent) return;
+    }
+    setZOrder (control, true);
+}
+
+/**
+ * Moves the receiver below the specified control in the
+ * drawing order. If the argument is null, then the receiver
+ * is moved to the bottom of the drawing order. The control at
+ * the bottom of the drawing order will be covered by all other
+ * controls which occupy intersecting areas.
+ *
+ * @param control the sibling control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Control#moveAbove
+ * @see Composite#getChildren
+ */
+public void moveBelow (Control control) {
+    checkWidget();
+    if (control !is null) {
+        if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (parent !is control.parent) return;
+    }
+    setZOrder (control, false);
+}
+
+Accessible new_Accessible (Control control) {
+    return Accessible.internal_new_Accessible (this);
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #computeSize(int, int, bool)
+ */
+public void pack () {
+    checkWidget();
+    pack (true);
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ * <p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained. 
+ * </p>
+ *
+ * @param changed whether or not the receiver's contents have changed
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #computeSize(int, int, bool)
+ */
+public void pack (bool changed) {
+    checkWidget();
+    setSize (computeSize (DWT.DEFAULT, DWT.DEFAULT, changed));
+}
+
+public bool print (GC gc) {
+    checkWidget ();
+    if (gc is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+//  int [] outImage = new int [1];
+//  CGRect outFrame = new CGRect ();
+//  if (OS.HIViewCreateOffscreenImage (handle, 0, outFrame, outImage) is OS.noErr) {
+//      int width = OS.CGImageGetWidth (outImage [0]);
+//      int height = OS.CGImageGetHeight (outImage [0]);
+//      CGRect rect = new CGRect();
+//      rect.width = width;
+//      rect.height = height;
+//      //TODO - does not draw the browser (cocoa widgets?)
+//      OS.HIViewDrawCGImage (gc.handle, rect, outImage [0]);
+//      OS.CGImageRelease (outImage [0]);
+//  }
+//  return true;
+    return false;
+}
+
+/**
+ * Causes the entire bounds of the receiver to be marked
+ * as needing to be redrawn. The next time a paint request
+ * is processed, the control will be completely painted,
+ * including the background.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #update()
+ * @see PaintListener
+ * @see DWT#Paint
+ * @see DWT#NO_BACKGROUND
+ * @see DWT#NO_REDRAW_RESIZE
+ * @see DWT#NO_MERGE_PAINTS
+ * @see DWT#DOUBLE_BUFFERED
+ */
+public void redraw () {
+    checkWidget();
+    view.setNeedsDisplay(true);
+}
+
+void redraw (bool children) {
+//  checkWidget();
+    
+}
+
+/**
+ * Causes the rectangular area of the receiver specified by
+ * the arguments to be marked as needing to be redrawn. 
+ * The next time a paint request is processed, that area of
+ * the receiver will be painted, including the background.
+ * If the <code>all</code> flag is <code>true</code>, any
+ * children of the receiver which intersect with the specified
+ * area will also paint their intersecting areas. If the
+ * <code>all</code> flag is <code>false</code>, the children
+ * will not be painted.
+ *
+ * @param x the x coordinate of the area to draw
+ * @param y the y coordinate of the area to draw
+ * @param width the width of the area to draw
+ * @param height the height of the area to draw
+ * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #update()
+ * @see PaintListener
+ * @see DWT#Paint
+ * @see DWT#NO_BACKGROUND
+ * @see DWT#NO_REDRAW_RESIZE
+ * @see DWT#NO_MERGE_PAINTS
+ * @see DWT#DOUBLE_BUFFERED
+ */
+public void redraw (int x, int y, int width, int height, bool all) {
+    checkWidget ();
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
+    view.setNeedsDisplayInRect(rect);
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (view !is null) {
+        OS.objc_msgSend(view.id, OS.sel_setTag_1, -1);
+        view.release();
+    }
+    view = null;
+    parent = null;
+}
+
+void releaseParent () {
+//  setVisible (topHandle (), false);
+    parent.removeControl (this);
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    if (menu !is null && !menu.isDisposed ()) {
+        menu.dispose ();
+    }
+    menu = null;
+    layoutData = null;
+    if (accessible !is null) {
+        accessible.internal_dispose_Accessible ();
+    }
+    accessible = null;
+    region = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Move, listener);
+    eventTable.unhook (DWT.Resize, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag gesture occurs.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragDetectListener
+ * @see #addDragDetectListener
+ * 
+ * @since 3.3
+ */
+public void removeDragDetectListener(DragDetectListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.DragDetect, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control gains or loses focus.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see FocusListener
+ * @see #addFocusListener
+ */
+public void removeFocusListener(FocusListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.FocusIn, listener);
+    eventTable.unhook(DWT.FocusOut, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #addHelpListener
+ */
+public void removeHelpListener (HelpListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Help, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #addKeyListener
+ */
+public void removeKeyListener(KeyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.KeyUp, listener);
+    eventTable.unhook(DWT.KeyDown, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the platform-specific context menu trigger has
+ * occurred.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #addMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void removeMenuDetectListener (MenuDetectListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.MenuDetect, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when mouse buttons are pressed and released.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseListener
+ * @see #addMouseListener
+ */
+public void removeMouseListener(MouseListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.MouseDown, listener);
+    eventTable.unhook(DWT.MouseUp, listener);
+    eventTable.unhook(DWT.MouseDoubleClick, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse moves.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseMoveListener
+ * @see #addMouseMoveListener
+ */
+public void removeMouseMoveListener(MouseMoveListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.MouseMove, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse passes or hovers over controls.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseTrackListener
+ * @see #addMouseTrackListener
+ */
+public void removeMouseTrackListener(MouseTrackListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.MouseEnter, listener);
+    eventTable.unhook (DWT.MouseExit, listener);
+    eventTable.unhook (DWT.MouseHover, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse wheel is scrolled.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseWheelListener
+ * @see #addMouseWheelListener
+ *
+ * @since 3.3
+ */
+public void removeMouseWheelListener (MouseWheelListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.MouseWheel, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver needs to be painted.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see PaintListener
+ * @see #addPaintListener
+ */
+public void removePaintListener(PaintListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Paint, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when traversal events occur.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TraverseListener
+ * @see #addTraverseListener
+ */
+public void removeTraverseListener(TraverseListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Traverse, listener);
+}
+
+bool sendDragEvent (int button, int stateMask, int x, int y) {
+    Event event = new Event ();
+    event.button = button;
+    event.x = x;
+    event.y = y;
+    event.stateMask = stateMask;
+    postEvent (DWT.DragDetect, event);
+    return event.doit;
+}
+
+bool sendDragEvent (int button, int chord, int modifiers, int x, int y) {
+    Event event = new Event ();
+    switch (button) {
+        case 1: event.button = 1; break;
+        case 2: event.button = 3; break;
+        case 3: event.button = 2; break;
+        case 4: event.button = 4; break;
+        case 5: event.button = 5; break;
+    }
+    event.x = x;
+    event.y = y;
+    setInputState (event, DWT.DragDetect, chord, modifiers);
+    postEvent (DWT.DragDetect, event);
+    return event.doit;
+}
+
+void sendFocusEvent (int type, bool post) {
+    Display display = this.display;
+    Shell shell = getShell ();
+    /*
+    * Feature in the Macintosh.  GetKeyboardFocus() returns NULL during
+    * kEventControlSetFocusPart if the focus part is not kControlFocusNoPart.
+    * The fix is to remember the focus control and return it during
+    * kEventControlSetFocusPart.
+    */
+//  display.focusControl = this;
+//  display.focusEvent = type;
+    if (post) {
+        postEvent (type);
+    } else {
+        sendEvent (type);
+    }   
+    /*
+    * It is possible that the shell may be
+    * disposed at this point.  If this happens
+    * don't send the activate and deactivate
+    * events.
+    */
+    if (!shell.isDisposed ()) {
+        switch (type) {
+            case DWT.FocusIn:
+                shell.setActiveControl (this);
+                break;
+            case DWT.FocusOut:
+                if (shell !is display.getActiveShell ()) {
+                    shell.setActiveControl (null);
+                }
+                break;
+        }
+    }
+//  display.focusEvent = DWT.None;
+//  display.focusControl = null;
+}
+
+bool sendMouseEvent (int type, short button, int count, int detail, bool send, int theEvent) {
+//  CGPoint pt = new CGPoint ();
+//  OS.GetEventParameter (theEvent, OS.kEventParamWindowMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt);
+//  OS.HIViewConvertPoint (pt, 0, handle);
+//  int x = (int) pt.x;
+//  int y = (int) pt.y;
+//  display.lastX = x;
+//  display.lastY = y;
+//  int [] chord = new int [1];
+//  OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
+//  int [] modifiers = new int [1];
+//  OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+//  return sendMouseEvent (type, button, count, detail, send, chord [0], (short) x, (short) y, modifiers [0]);
+    return false;
+}
+
+bool sendMouseEvent (int type, short button, int count, bool send, int chord, short x, short y, int modifiers) {
+    return sendMouseEvent (type, button, count, 0, send, chord, x, y, modifiers);
+}
+
+bool sendMouseEvent (int type, short button, int count, int detail, bool send, int chord, short x, short y, int modifiers) {
+    if (!hooks (type) && !filters (type)) return true;
+    Event event = new Event ();
+    switch (button) {
+        case 1: event.button = 1; break;
+        case 2: event.button = 3; break;
+        case 3: event.button = 2; break;
+        case 4: event.button = 4; break;
+        case 5: event.button = 5; break;
+    }
+    event.x = x;
+    event.y = y;
+    event.count = count;
+    event.detail = detail;
+    setInputState (event, type, chord, modifiers);
+    if (send) {
+        sendEvent (type, event);
+        if (isDisposed ()) return false;
+    } else {
+        postEvent (type, event);
+    }
+    return event.doit;
+}
+
+bool sendMouseWheel (short wheelAxis, int wheelDelta) {
+    return false;
+}
+
+void setBackground () {
+//  redrawWidget (handle, false);
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * For example, on Windows the background of a Button cannot be changed.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground (Color color) {
+    checkWidget();
+    if (color !is null) {
+        if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+//  if (equals (background, this.background)) return;
+    this.background = color;
+    setBackground (color !is null ? color.handle : null);
+    view.setNeedsDisplay(true);
+}
+
+/**
+ * Sets the receiver's background image to the image specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.  The background image is tiled to fill
+ * the available space.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * For example, on Windows the background of a Button cannot be changed.
+ * </p>
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument is not a bitmap</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setBackgroundImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (image is backgroundImage) return;
+    backgroundImage = image;
+//  redrawWidget (handle, false);
+}
+
+void setBackground (float [] color) {
+}
+
+void setBackground (int control, float [] color) {
+//  ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
+//  OS.GetControlData (control, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
+//  if (color !is null) {
+//      fontStyle.backColor_red = (short) (color [0] * 0xffff);
+//      fontStyle.backColor_green = (short) (color [1] * 0xffff);
+//      fontStyle.backColor_blue = (short) (color [2] * 0xffff);
+//      fontStyle.flags |= OS.kControlUseBackColorMask;
+//  } else {
+//      fontStyle.flags &= ~OS.kControlUseBackColorMask;
+//  }
+//  OS.SetControlFontStyle (control, fontStyle);
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and 
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null), unless 
+ * the receiver is a shell. In this case, the <code>x</code>
+ * and <code>y</code> arguments are relative to the display.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (int x, int y, int width, int height) {
+    checkWidget();
+    setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true);
+}
+
+int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+    int result = 0;
+    NSView topView = topView();
+    NSRect rect = topView.frame();
+    if (move && resize) {
+        if (rect.x !is x || rect.y !is y) result |= MOVED;
+        if (rect.width !is width || rect.height !is height) result |= RESIZED;
+        if (result !is 0) {
+            rect.x = x;
+            rect.y = y;
+            rect.width = width;
+            rect.height = height;
+            topView.setFrame (rect);
+        }
+    } else if (move) {
+        if (rect.x !is x || rect.y !is y) {
+            result |= MOVED;
+            NSPoint point = new NSPoint();
+            point.x = x;
+            point.y = y;
+            topView.setFrameOrigin(point);
+        }
+    } else if (resize) {
+        if (rect.width !is width || rect.height !is height) {
+            result |= RESIZED;
+            NSSize size = new NSSize();
+            size.width = width;
+            size.height = height;
+            topView.setFrameSize(size);
+        }
+    }
+    if ((result & MOVED) !is 0) {
+        sendEvent(DWT.Move);
+    }
+    if ((result & RESIZED) !is 0) {
+        sendEvent(DWT.Resize);
+    }
+    return result;
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and 
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (Rectangle rect) {
+    checkWidget ();
+    if (rect is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
+}
+
+/**
+ * If the argument is <code>true</code>, causes the receiver to have
+ * all mouse events delivered to it until the method is called with
+ * <code>false</code> as the argument.
+ *
+ * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCapture (bool capture) {
+    checkWidget();
+}
+
+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument, or to the default cursor for that kind of control
+ * if the argument is null.
+ * <p>
+ * When the mouse pointer passes over a control its appearance
+ * is changed to match the control's cursor.
+ * </p>
+ *
+ * @param cursor the new cursor (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor cursor) {
+    checkWidget();
+    if (cursor !is null && cursor.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    this.cursor = cursor;
+    //TODO null
+//  view.addCursorRect(view.frame(), cursor.handle);
+}
+
+void setDefaultFont () {
+//  if (display.smallFonts) setFontStyle (defaultFont ());
+}
+
+/**
+ * Sets the receiver's drag detect state. If the argument is
+ * <code>true</code>, the receiver will detect drag gestures,
+ * otherwise these gestures will be ignored.
+ *
+ * @param dragDetect the new drag detect state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void setDragDetect (bool dragDetect) {
+    checkWidget ();
+    if (dragDetect) {
+        state |= DRAG_DETECT;   
+    } else {
+        state &= ~DRAG_DETECT;
+    }
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (bool enabled) {
+    checkWidget();
+    if (((state & DISABLED) is 0) is enabled) return;
+    Control control = null;
+    bool fixFocus = false;
+    if (!enabled) {
+//      if (display.focusEvent !is DWT.FocusOut) {
+            control = display.getFocusControl ();
+            fixFocus = isFocusAncestor (control);
+//      }
+    }
+    if (enabled) {
+        state &= ~DISABLED;
+    } else {
+        state |= DISABLED;
+    }
+    enableWidget (enabled);
+    if (fixFocus) fixFocus (control);
+}
+
+/**
+ * Causes the receiver to have the <em>keyboard focus</em>, 
+ * such that all keyboard events will be delivered to it.  Focus
+ * reassignment will respect applicable platform constraints.
+ *
+ * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #forceFocus
+ */
+public bool setFocus () {
+    checkWidget();
+    if ((style & DWT.NO_FOCUS) !is 0) return false;
+    return forceFocus ();
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+    checkWidget();
+    if (font !is null) { 
+        if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.font = font;
+    setFont (font !is null ? font.handle : defaultFont().handle);
+}
+
+void setFont (NSFont font) {
+    //TODO - bad cast
+    if (view instanceof NSControl) {
+        ((NSControl)view).setFont(font);
+    }
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setForeground (Color color) {
+    checkWidget();
+    if (color !is null) {
+        if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+//  if (equals (foreground, this.foreground)) return;
+    this.foreground = color;
+    setForeground (color !is null ? color.handle : null);
+    view.setNeedsDisplay(true);
+}
+
+void setForeground (float [] color) {
+}
+
+void setForeground (int control, float [] color) {
+//  ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
+//  OS.GetControlData (control, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
+//  if (color !is null) {
+//      fontStyle.foreColor_red = (short) (color [0] * 0xffff);
+//      fontStyle.foreColor_green = (short) (color [1] * 0xffff);
+//      fontStyle.foreColor_blue = (short) (color [2] * 0xffff);
+//      fontStyle.flags |= OS.kControlUseForeColorMask;
+//  } else {
+//      fontStyle.flags &= ~OS.kControlUseForeColorMask;
+//  }
+//  OS.SetControlFontStyle (control, fontStyle);
+}
+
+/**
+ * Sets the layout data associated with the receiver to the argument.
+ * 
+ * @param layoutData the new layout data for the receiver.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayoutData (Object layoutData) {
+    checkWidget();
+    this.layoutData = layoutData;
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null), unless 
+ * the receiver is a shell. In this case, the point is 
+ * relative to the display. 
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (int x, int y) {
+    checkWidget();
+    setBounds (x, y, 0, 0, true, false);
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null), unless 
+ * the receiver is a shell. In this case, the point is 
+ * relative to the display. 
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (Point location) {
+    checkWidget();
+    if (location is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setBounds (location.x, location.y, 0, 0, true, false);
+}
+
+/**
+ * Sets the receiver's pop up menu to the argument.
+ * All controls may optionally have a pop up
+ * menu that is displayed when the user requests one for
+ * the control. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pop up
+ * menu is platform specific.
+ * <p>
+ * Note: Disposing of a control that has a pop up menu will
+ * dispose of the menu.  To avoid this behavior, set the
+ * menu to null before the control is disposed.
+ * </p>
+ *
+ * @param menu the new pop up menu
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+    checkWidget();
+    if (menu !is null) {
+        if (menu.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+        if ((menu.style & DWT.POP_UP) is 0) {
+            error (DWT.ERROR_MENU_NOT_POP_UP);
+        }
+        if (menu.parent !is menuShell ()) {
+            error (DWT.ERROR_INVALID_PARENT);
+        }
+    }
+    this.menu = menu;
+}
+
+/**
+ * Changes the parent of the widget to be the one provided if
+ * the underlying operating system supports this feature.
+ * Returns <code>true</code> if the parent is successfully changed.
+ *
+ * @param parent the new parent for the control.
+ * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is <code>null</code></li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *  </ul>
+ */
+public bool setParent (Composite parent) {
+    checkWidget();
+    if (parent is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (parent.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (this.parent is parent) return true;
+    if (!isReparentable ()) return false;
+    releaseParent ();
+    Shell newShell = parent.getShell (), oldShell = getShell ();
+    Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell ();
+    if (oldShell !is newShell || oldDecorations !is newDecorations) {
+        Menu [] menus = oldShell.findMenus (this);
+        fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+    }
+//  int topHandle = topHandle ();
+//  OS.HIViewAddSubview (parent.handle, topHandle);
+//  OS.HIViewSetVisible (topHandle, (state & HIDDEN) is 0);
+//  OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0);
+    this.parent = parent;
+    return true;
+}
+
+/**
+ * If the argument is <code>false</code>, causes subsequent drawing
+ * operations in the receiver to be ignored. No drawing of any kind
+ * can occur in the receiver until the flag is set to true.
+ * Graphics operations that occurred while the flag was
+ * <code>false</code> are lost. When the flag is set to <code>true</code>,
+ * the entire widget is marked as needing to be redrawn.  Nested calls
+ * to this method are stacked.
+ * <p>
+ * Note: This operation is a hint and may not be supported on some
+ * platforms or for some widgets.
+ * </p>
+ *
+ * @param redraw the new redraw state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #redraw(int, int, int, int, bool)
+ * @see #update()
+ */
+public void setRedraw (bool redraw) {
+    checkWidget();
+    if (redraw) {
+        if (--drawCount is 0) {
+//          OS.HIViewSetDrawingEnabled (handle, true);
+//          invalidateVisibleRegion (handle);
+//          redrawWidget (handle, true);
+        }
+    } else {
+        if (drawCount is 0) {
+//          OS.HIViewSetDrawingEnabled (handle, false);
+//          invalidateVisibleRegion (handle);
+        }
+        drawCount++;
+    }
+}
+
+public void setRegion (Region region) {
+    checkWidget ();
+    if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+    this.region = region;
+//  redrawWidget (handle, true);
+}
+
+bool setRadioSelection (bool value){
+    return false;
+}
+
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (int width, int height) {
+    checkWidget();
+    setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true);
+}
+
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause them to be
+ * set to zero instead.
+ * </p>
+ *
+ * @param size the new size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (Point size) {
+    checkWidget ();
+    if (size is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
+}
+
+bool setTabGroupFocus () {
+    return setTabItemFocus ();
+}
+
+bool setTabItemFocus () {
+    if (!isShowing ()) return false;
+    return forceFocus ();
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+    checkWidget();
+    toolTipText = string;
+    view.setToolTip(string !is null ? NSString.stringWith(string) : null);
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (bool visible) {
+    checkWidget();
+    if (visible) {
+        if ((state & HIDDEN) is 0) return;
+        state &= ~HIDDEN;
+    } else {
+        if ((state & HIDDEN) !is 0) return;
+        state |= HIDDEN;
+    }
+    if (visible) {
+        /*
+        * It is possible (but unlikely), that application
+        * code could have disposed the widget in the show
+        * event.  If this happens, just return.
+        */
+        sendEvent (DWT.Show);
+        if (isDisposed ()) return;
+    }
+    
+    /*
+    * Feature in the Macintosh.  If the receiver has focus, hiding
+    * the receiver causes no control to have focus.  Also, the focus
+    * needs to be cleared from any TXNObject so that it stops blinking
+    * the caret.  The fix is to assign focus to the first ancestor
+    * control that takes focus.  If no control will take focus, clear
+    * the focus control.
+    */
+    Control control = null;
+    bool fixFocus = false;
+    if (!visible) {
+//      if (display.focusEvent !is DWT.FocusOut) {
+            control = display.getFocusControl ();
+            fixFocus = isFocusAncestor (control);
+//      }
+    }
+    topView().setHidden(!visible);
+    if (!visible) {
+        /*
+        * It is possible (but unlikely), that application
+        * code could have disposed the widget in the show
+        * event.  If this happens, just return.
+        */
+        sendEvent (DWT.Hide);
+        if (isDisposed ()) return;
+    }
+    if (fixFocus) fixFocus (control);
+}
+
+void setZOrder () {
+//  int topHandle = topHandle ();
+//  int parentHandle = parent.handle;
+//  OS.HIViewAddSubview (parentHandle, topHandle);
+//  OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0);
+//  Rect rect = getInset ();
+//  rect.right = rect.left;
+//  rect.bottom = rect.top;
+//  OS.SetControlBounds (topHandle, rect);
+}
+
+void setZOrder (Control control, bool above) {
+    NSView otherView = control is null ? null : control.topView ();
+    view.retain();
+    view.removeFromSuperview();
+    parent.contentView().addSubview_positioned_relativeTo_(view, above ? OS.NSWindowAbove : OS.NSWindowBelow, otherView);
+    view.release();
+}
+
+void sort (int [] items) {
+    /* Shell Sort from K&R, pg 108 */
+    int length = items.length;
+    for (int gap=length/2; gap>0; gap/=2) {
+        for (int i=gap; i<length; i++) {
+            for (int j=i-gap; j>=0; j-=gap) {
+                if (items [j] <= items [j + gap]) {
+                    int swap = items [j];
+                    items [j] = items [j + gap];
+                    items [j + gap] = swap;
+                }
+            }
+        }
+    }
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in display relative coordinates,
+ * to coordinates relative to the receiver.
+ * <p>
+ * @param x the x coordinate to be translated
+ * @param y the y coordinate to be translated
+ * @return the translated coordinates
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public Point toControl (int x, int y) {
+    checkWidget();
+    return display.map (null, this, x, y);
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in display relative coordinates,
+ * to coordinates relative to the receiver.
+ * <p>
+ * @param point the point to be translated (must not be null)
+ * @return the translated coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point toControl (Point point) {
+    checkWidget();
+    if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
+    return toControl (point.x, point.y);
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in coordinates relative to
+ * the receiver, to display relative coordinates.
+ * <p>
+ * @param x the x coordinate to be translated
+ * @param y the y coordinate to be translated
+ * @return the translated coordinates
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public Point toDisplay (int x, int y) {
+    checkWidget();
+    return display.map (this, null, x, y);
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in coordinates relative to
+ * the receiver, to display relative coordinates.
+ * <p>
+ * @param point the point to be translated (must not be null)
+ * @return the translated coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point toDisplay (Point point) {
+    checkWidget();
+    if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
+    return toDisplay (point.x, point.y);
+}
+
+NSView topView () {
+    return view;
+}
+
+bool translateTraversal (int key, NSEvent theEvent, bool [] consume) {
+    int detail = DWT.TRAVERSE_NONE;
+    int code = traversalCode (key, theEvent);
+    bool all = false;
+    switch (key) {
+        case 53: /* Esc */ {
+            all = true;
+            detail = DWT.TRAVERSE_ESCAPE;
+            break;
+        }
+        case 76: /* KP Enter */
+        case 36: /* Return */ {
+            all = true;
+            detail = DWT.TRAVERSE_RETURN;
+            break;
+        }
+        case 48: /* Tab */ {
+            int modifiers = display.lastModifiers;
+            bool next = (modifiers & OS.NSShiftKeyMask) is 0;
+            detail = next ? DWT.TRAVERSE_TAB_NEXT : DWT.TRAVERSE_TAB_PREVIOUS;
+            break;
+        }
+        case 126: /* Up arrow */
+        case 123: /* Left arrow */
+        case 125: /* Down arrow */
+        case 124: /* Right arrow */ {
+            bool next = key is 125 /* Down arrow */ || key is 124 /* Right arrow */;
+            detail = next ? DWT.TRAVERSE_ARROW_NEXT : DWT.TRAVERSE_ARROW_PREVIOUS;
+            break;
+        }
+        case 116: /* Page up */
+        case 121: /* Page down */ {
+            all = true;
+//          int [] modifiers = new int [1];
+//          OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+//          if ((modifiers [0] & OS.controlKey) is 0) return false;
+//          detail = key is 121 /* Page down */ ? DWT.TRAVERSE_PAGE_NEXT : DWT.TRAVERSE_PAGE_PREVIOUS;
+            break;
+        }
+        default:
+            return false;
+    }
+    Event event = new Event ();
+    event.doit = consume [0] = (code & detail) !is 0;
+    event.detail = detail;
+    if (!setKeyState (event, DWT.Traverse, theEvent)) return false;
+    Shell shell = getShell ();
+    Control control = this;
+    do {
+        if (control.traverse (event)) return true;
+        if (!event.doit && control.hooks (DWT.Traverse)) {
+            return false;
+        }
+        if (control is shell) return false;
+        control = control.parent;
+    } while (all && control !is null);
+    return false;
+}
+
+int traversalCode (int key, NSEvent theEvent) {
+    int code = DWT.TRAVERSE_RETURN | DWT.TRAVERSE_TAB_NEXT | DWT.TRAVERSE_TAB_PREVIOUS;
+    Shell shell = getShell ();
+    if (shell.parent !is null) code |= DWT.TRAVERSE_ESCAPE;
+    return code;
+}
+
+bool traverseMnemonic (char key) {
+    return false;
+}
+
+/**
+ * Based on the argument, perform one of the expected platform
+ * traversal action. The argument should be one of the constants:
+ * <code>DWT.TRAVERSE_ESCAPE</code>, <code>DWT.TRAVERSE_RETURN</code>, 
+ * <code>DWT.TRAVERSE_TAB_NEXT</code>, <code>DWT.TRAVERSE_TAB_PREVIOUS</code>, 
+ * <code>DWT.TRAVERSE_ARROW_NEXT</code> and <code>DWT.TRAVERSE_ARROW_PREVIOUS</code>.
+ *
+ * @param traversal the type of traversal
+ * @return true if the traversal succeeded
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool traverse (int traversal) {
+    checkWidget();
+    Event event = new Event ();
+    event.doit = true;
+    event.detail = traversal;
+    return traverse (event);
+}
+
+bool traverse (Event event) {
+    sendEvent (DWT.Traverse, event);
+    if (isDisposed ()) return true;
+    if (!event.doit) return false;
+    switch (event.detail) {
+        case DWT.TRAVERSE_NONE:             return true;
+        case DWT.TRAVERSE_ESCAPE:           return traverseEscape ();
+        case DWT.TRAVERSE_RETURN:           return traverseReturn ();
+        case DWT.TRAVERSE_TAB_NEXT:         return traverseGroup (true);
+        case DWT.TRAVERSE_TAB_PREVIOUS:     return traverseGroup (false);
+        case DWT.TRAVERSE_ARROW_NEXT:       return traverseItem (true);
+        case DWT.TRAVERSE_ARROW_PREVIOUS:   return traverseItem (false);
+        case DWT.TRAVERSE_MNEMONIC:         return traverseMnemonic (event);    
+        case DWT.TRAVERSE_PAGE_NEXT:        return traversePage (true);
+        case DWT.TRAVERSE_PAGE_PREVIOUS:    return traversePage (false);
+    }
+    return false;
+}
+
+bool traverseEscape () {
+    return false;
+}
+
+bool traverseGroup (bool next) {
+    Control root = computeTabRoot ();
+    Control group = computeTabGroup ();
+    Control [] list = root.computeTabList ();
+    int length = list.length;
+    int index = 0;
+    while (index < length) {
+        if (list [index] is group) break;
+        index++;
+    }
+    /*
+    * It is possible (but unlikely), that application
+    * code could have disposed the widget in focus in
+    * or out events.  Ensure that a disposed widget is
+    * not accessed.
+    */
+    if (index is length) return false;
+    int start = index, offset = (next) ? 1 : -1;
+    while ((index = ((index + offset + length) % length)) !is start) {
+        Control control = list [index];
+        if (!control.isDisposed () && control.setTabGroupFocus ()) {
+            return true;
+        }
+    }
+    if (group.isDisposed ()) return false;
+    return group.setTabGroupFocus ();
+}
+
+bool traverseItem (bool next) {
+    Control [] children = parent._getChildren ();
+    int length = children.length;
+    int index = 0;
+    while (index < length) {
+        if (children [index] is this) break;
+        index++;
+    }
+    /*
+    * It is possible (but unlikely), that application
+    * code could have disposed the widget in focus in
+    * or out events.  Ensure that a disposed widget is
+    * not accessed.
+    */
+    if (index is length) return false;
+    int start = index, offset = (next) ? 1 : -1;
+    while ((index = (index + offset + length) % length) !is start) {
+        Control child = children [index];
+        if (!child.isDisposed () && child.isTabItem ()) {
+            if (child.setTabItemFocus ()) return true;
+        }
+    }
+    return false;
+}
+
+bool traverseReturn () {
+    return false;
+}
+
+bool traversePage (bool next) {
+    return false;
+}
+
+bool traverseMnemonic (Event event) {
+    return false;
+}
+
+/**
+ * Forces all outstanding paint requests for the widget
+ * to be processed before this method returns. If there
+ * are no outstanding paint request, this method does
+ * nothing.
+ * <p>
+ * Note: This method does not cause a redraw.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #redraw()
+ * @see #redraw(int, int, int, int, bool)
+ * @see PaintListener
+ * @see DWT#Paint
+ */
+public void update () {
+    checkWidget();
+    update (false);
+}
+
+void update (bool all) {
+//  checkWidget();
+    //TODO - not all
+//  OS.HIViewRender (handle);
+}
+
+void updateBackgroundMode () {
+    int oldState = state & PARENT_BACKGROUND;
+    checkBackground ();
+    if (oldState !is (state & PARENT_BACKGROUND)) {
+        setBackground ();
+    }
+}
+
+void updateLayout (bool all) {
+    /* Do nothing */
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/CoolBar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1191 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.CoolBar;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Color;
+import dwt.graphics.Cursor;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+
+/**
+ * Instances of this class provide an area for dynamically
+ * positioning the items they contain.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CoolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>FLAT, HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class CoolBar extends Composite {
+    CoolItem[][] items = new CoolItem[0][0];
+    CoolItem[] originalItems = new CoolItem[0];
+    Cursor hoverCursor, dragCursor, cursor;
+    CoolItem dragging = null;
+    int mouseXOffset, itemXOffset;
+    bool isLocked = false;
+    bool inDispose = false;
+    static final int ROW_SPACING = 2;
+    static final int CLICK_DISTANCE = 3;
+    static final int DEFAULT_COOLBAR_WIDTH = 0;
+    static final int DEFAULT_COOLBAR_HEIGHT = 0;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolBar (Composite parent, int style) {
+    super (parent, checkStyle(style));
+    if ((style & DWT.VERTICAL) !is 0) {
+        this.style |= DWT.VERTICAL;
+        hoverCursor = new Cursor(display, DWT.CURSOR_SIZENS);
+    } else {
+        this.style |= DWT.HORIZONTAL;
+        hoverCursor = new Cursor(display, DWT.CURSOR_SIZEWE);
+    }
+    dragCursor = new Cursor(display, DWT.CURSOR_SIZEALL);
+    Listener listener = new Listener() {
+        public void handleEvent(Event event) {
+            switch (event.type) {
+                case DWT.Dispose:           onDispose(event);           break;
+                case DWT.MouseDown:         onMouseDown(event);         break;
+                case DWT.MouseExit:         onMouseExit();              break;
+                case DWT.MouseMove:         onMouseMove(event);         break;
+                case DWT.MouseUp:           onMouseUp(event);           break;
+                case DWT.MouseDoubleClick:  onMouseDoubleClick(event);  break;
+                case DWT.Paint:             onPaint(event);             break;
+                case DWT.Resize:            onResize();                 break;
+            }
+        }
+    };
+    int[] events = new int[] { 
+        DWT.Dispose, 
+        DWT.MouseDown,
+        DWT.MouseExit, 
+        DWT.MouseMove, 
+        DWT.MouseUp, 
+        DWT.MouseDoubleClick,
+        DWT.Paint,
+        DWT.Resize
+    };
+    for (int i = 0; i < events.length; i++) {
+        addListener(events[i], listener);   
+    }
+}
+static int checkStyle (int style) {
+    style |= DWT.NO_FOCUS;
+    return (style | DWT.NO_REDRAW_RESIZE) & ~(DWT.V_SCROLL | DWT.H_SCROLL);
+}
+void _setCursor (Cursor cursor) {
+    if (this.cursor !is null) return;
+    super.setCursor (cursor);
+}
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = 0, height = 0;
+    wrapItems((style & DWT.VERTICAL) !is 0 ? hHint : wHint);
+    bool flat = (style & DWT.FLAT) !is 0;
+    for (int row = 0; row < items.length; row++) {
+        int rowWidth = 0, rowHeight = 0;
+        for (int i = 0; i < items[row].length; i++) {
+            CoolItem item = items[row][i];
+            rowWidth += item.preferredWidth;
+            rowHeight = Math.max(rowHeight, item.preferredHeight);
+        }
+        height += rowHeight;
+        if (!flat && row > 0) height += ROW_SPACING;
+        width = Math.max(width, rowWidth);
+    }
+    wrapItems(getWidth());
+    if (width is 0) width = DEFAULT_COOLBAR_WIDTH;
+    if (height is 0) height = DEFAULT_COOLBAR_HEIGHT;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    Rectangle trim = computeTrim(0, 0, width, height);
+    return fixPoint(trim.width, trim.height);
+}
+CoolItem getGrabbedItem(int x, int y) {
+    for (int row = 0; row < items.length; row++) {
+        for (int i = 0; i < items[row].length; i++) {
+            CoolItem item = items[row][i];
+            Rectangle bounds = item.internalGetBounds();
+            bounds.width = CoolItem.MINIMUM_WIDTH;
+            if (bounds.x > x) break;
+            if (bounds.y > y) return null;
+            if (bounds.contains(x, y)) {
+                return item;    
+            }   
+        }   
+    }
+    return null;
+}
+/**
+ * Returns the item that is currently displayed at the given,
+ * zero-relative index. Throws an exception if the index is
+ * out of range.
+ *
+ * @param index the visual index of the item to return
+ * @return the item at the given visual index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public CoolItem getItem (int index) {
+    checkWidget();
+    if (index < 0) error (DWT.ERROR_INVALID_RANGE);
+    for (int row = 0; row < items.length; row++) {
+        if (items[row].length > index) {
+            return items[row][index];           
+        } else {
+            index -= items[row].length;
+        }
+    }
+    error (DWT.ERROR_INVALID_RANGE);
+    return null;
+}
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget();
+    return originalItems.length;
+}
+/**
+ * Returns an array of <code>CoolItem</code>s in the order
+ * in which they are currently being displayed.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items in their current visual order
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public CoolItem [] getItems () {
+    checkWidget();
+    CoolItem [] result = new CoolItem [getItemCount()];
+    int offset = 0;
+    for (int row = 0; row < items.length; row++) {
+        System.arraycopy(items[row], 0, result, offset, items[row].length);
+        offset += items[row].length;
+    }
+    return result;
+}
+Point findItem (CoolItem item) {
+    for (int row = 0; row < items.length; row++) {
+        for (int i = 0; i < items[row].length; i++) {
+            if (items[row][i].equals(item)) return new Point(i, row);       
+        }
+    }
+    return new Point(-1, -1);
+}
+void fixEvent (Event event) {
+    if ((style & DWT.VERTICAL) !is 0) {
+        int tmp = event.x;
+        event.x = event.y;
+        event.y = tmp;
+    }
+}
+Rectangle fixRectangle (int x, int y, int width, int height) {
+    if ((style & DWT.VERTICAL) !is 0) {
+        return new Rectangle(y, x, height, width);
+    }
+    return new Rectangle(x, y, width, height);
+}
+Point fixPoint (int x, int y) {
+    if ((style & DWT.VERTICAL) !is 0) {
+        return new Point(y, x);
+    }
+    return new Point(x, y); 
+}
+/**
+ * Searches the receiver's items in the order they are currently
+ * being displayed, starting at the first item (index 0), until
+ * an item is found that is equal to the argument, and returns
+ * the index of that item. If no item is found, returns -1.
+ *
+ * @param item the search item
+ * @return the visual order index of the search item, or -1 if the item is not found
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item is disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (CoolItem item) {
+    checkWidget();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+    int answer = 0;
+    for (int row = 0; row < items.length; row++) {
+        for (int i = 0; i < items[row].length; i++) {
+            if (items[row][i].equals(item)) {
+                return answer;      
+            } else {
+                answer++;
+            }
+        }
+    }
+    return -1;
+}
+/**
+ * Insert the item into the row. Adjust the x and width values
+ * appropriately.
+ */
+void insertItemIntoRow(CoolItem item, int rowIndex, int x_root) {
+    int barWidth = getWidth();
+    int rowY = items[rowIndex][0].internalGetBounds().y;
+    int x = Math.max(0, Math.abs(x_root - toDisplay(new Point(0, 0)).x));
+    
+    /* Find the insertion index and add the item. */
+    int index;
+    for (index = 0; index < items[rowIndex].length; index++) {
+        if (x < items[rowIndex][index].internalGetBounds().x) break;
+    }
+    if (index is 0) {
+        item.wrap = true;
+        items[rowIndex][0].wrap = false;
+    }
+    int oldLength = items[rowIndex].length;
+    CoolItem[] newRow = new CoolItem[oldLength + 1];
+    System.arraycopy(items[rowIndex], 0, newRow, 0, index);
+    newRow[index] = item;
+    System.arraycopy(items[rowIndex], index, newRow, index + 1, oldLength - index);
+    items[rowIndex] = newRow;
+
+    /* Adjust the width of the item to the left. */
+    if (index > 0) {
+        CoolItem left = items[rowIndex][index - 1];
+        Rectangle leftBounds = left.internalGetBounds();
+        int newWidth = x - leftBounds.x;
+        if (newWidth < left.internalGetMinimumWidth()) {
+            x += left.internalGetMinimumWidth() - newWidth;
+            newWidth = left.internalGetMinimumWidth();
+        }
+        left.setBounds(leftBounds.x, leftBounds.y, newWidth, leftBounds.height);
+        left.requestedWidth = newWidth;
+    }
+    
+    /* Set the item's bounds. */
+    int width = 0, height = item.internalGetBounds().height;
+    if (index < items[rowIndex].length - 1) {
+        CoolItem right = items[rowIndex][index + 1];
+        width = right.internalGetBounds().x - x;
+        if (width < right.internalGetMinimumWidth()) {
+            moveRight(right, right.internalGetMinimumWidth() - width);
+            width = right.internalGetBounds().x - x;
+        }
+        item.setBounds(x, rowY, width, height);
+        if (width < item.internalGetMinimumWidth()) moveLeft(item, item.internalGetMinimumWidth() - width);
+    } else {
+        width = Math.max(item.internalGetMinimumWidth(), barWidth - x);
+        item.setBounds(x, rowY, width, height);
+        if (x + width > barWidth) moveLeft(item, x + width - barWidth); 
+    }
+    Rectangle bounds = item.internalGetBounds();
+    item.requestedWidth = bounds.width;
+    internalRedraw(bounds.x, bounds.y, item.internalGetMinimumWidth(), bounds.height);
+}
+void internalRedraw (int x, int y, int width, int height) {
+    if ((style & DWT.VERTICAL) !is 0) {
+        redraw (y, x, height, width, false);
+    } else {
+        redraw (x, y, width, height, false);
+    }
+}
+void createItem (CoolItem item, int index) {
+    int itemCount = getItemCount(), row = 0;
+    if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (items.length is 0) {
+        items = new CoolItem[1][1];
+        items[0][0] = item; 
+    } else {
+        int i = index;
+        /* find the row to insert into */
+        if (index < itemCount) {
+            while (i > items[row].length) {
+                i -= items[row].length;
+                row++;
+            }   
+        } else {
+            row = items.length - 1;
+            i = items[row].length;  
+        }
+        
+        // Set the last item in the row to the preferred size 
+        // and add the new one just to it's right
+        int lastIndex = items[row].length - 1;
+        CoolItem lastItem = items[row][lastIndex];
+        if (lastItem.ideal) {
+            Rectangle bounds = lastItem.internalGetBounds();
+            bounds.width = lastItem.preferredWidth;
+            bounds.height = lastItem.preferredHeight;
+            lastItem.requestedWidth = lastItem.preferredWidth;
+            lastItem.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);  
+        }
+        if (i is 0) {
+            item.wrap = true;
+            items[row][0].wrap = false;
+        }
+        int oldLength = items[row].length;
+        CoolItem[] newRow = new CoolItem[oldLength + 1];
+        System.arraycopy(items[row], 0, newRow, 0, i);
+        newRow[i] = item;
+        System.arraycopy(items[row], i, newRow, i + 1, oldLength - i);
+        items[row] = newRow;
+    }
+    item.requestedWidth = CoolItem.MINIMUM_WIDTH;
+    
+    int length = originalItems.length;
+    CoolItem [] newOriginals = new CoolItem [length + 1];
+    System.arraycopy (originalItems, 0, newOriginals, 0, index);
+    System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);
+    newOriginals [index] = item;
+    originalItems = newOriginals;
+    layoutItems();
+
+}
+void destroyItem(CoolItem item) {
+    if (inDispose) return;
+    int row = findItem(item).y;
+    if (row is -1) return;
+    Rectangle bounds = item.internalGetBounds();
+    removeItemFromRow(item, row, true);
+    
+    int index = 0;
+    while (index < originalItems.length) {
+        if (originalItems [index] is item) break;
+        index++;
+    }
+    int length = originalItems.length - 1;
+    CoolItem [] newOriginals = new CoolItem [length];
+    System.arraycopy (originalItems, 0, newOriginals, 0, index);
+    System.arraycopy (originalItems, index + 1, newOriginals, index, length - index);
+    originalItems = newOriginals;
+    
+    internalRedraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height);
+    relayout();
+}
+void moveDown(CoolItem item, int x_root) {
+    int oldRowIndex = findItem(item).y;
+    bool resize = false;
+    if (items[oldRowIndex].length is 1) {
+        resize = true;
+        /* If this is the only item in the bottom row, don't move it. */
+        if (oldRowIndex is items.length - 1) return;
+    }
+    int newRowIndex = (items[oldRowIndex].length is 1) ? oldRowIndex : oldRowIndex + 1;
+    removeItemFromRow(item, oldRowIndex, false);
+    Rectangle old = item.internalGetBounds();
+    internalRedraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height);
+    if (newRowIndex is items.length) {
+        /* Create a new bottom row for the item. */
+        CoolItem[][] newRows = new CoolItem[items.length + 1][];
+        System.arraycopy(items, 0, newRows, 0, items.length);
+        int row = items.length;
+        newRows[row] = new CoolItem[1];
+        newRows[row][0] = item;
+        items = newRows;
+        resize = true;
+        item.wrap = true;
+    } else {    
+        insertItemIntoRow(item, newRowIndex, x_root);
+    }
+    if (resize) {
+        relayout();
+    } else {
+        layoutItems();
+    }
+}
+void moveLeft(CoolItem item, int pixels) {
+    Point point = findItem(item);
+    int row = point.y;
+    int index = point.x;
+    if (index is 0) return; 
+    Rectangle bounds = item.internalGetBounds();
+    int minSpaceOnLeft = 0;
+    for (int i = 0; i < index; i++) {
+        minSpaceOnLeft += items[row][i].internalGetMinimumWidth();
+    }
+    int x = Math.max(minSpaceOnLeft, bounds.x - pixels);
+    CoolItem left = items[row][index - 1];
+    Rectangle leftBounds = left.internalGetBounds();
+    if (leftBounds.x + left.internalGetMinimumWidth() > x) {
+        int shift = leftBounds.x + left.internalGetMinimumWidth() - x;
+        moveLeft(left, shift);
+        leftBounds = left.internalGetBounds();
+    }
+    int leftWidth = Math.max(left.internalGetMinimumWidth(), leftBounds.width - pixels);
+    left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+    left.requestedWidth = leftWidth;
+    int width = bounds.width + (bounds.x - x);
+    item.setBounds(x, bounds.y, width, bounds.height);
+    item.requestedWidth = width;
+
+    int damagedWidth = bounds.x - x + CoolItem.MINIMUM_WIDTH;
+    if (damagedWidth > CoolItem.MINIMUM_WIDTH) {
+        internalRedraw(x, bounds.y, damagedWidth, bounds.height);
+    }
+}
+void moveRight(CoolItem item, int pixels) {
+    Point point = findItem(item);
+    int row = point.y;
+    int index = point.x;
+    if (index is 0) return; 
+    Rectangle bounds = item.internalGetBounds();
+    int minSpaceOnRight = 0;
+    for (int i = index; i < items[row].length; i++) {
+        minSpaceOnRight += items[row][i].internalGetMinimumWidth(); 
+    }
+    int max = getWidth() - minSpaceOnRight;
+    int x = Math.min(max, bounds.x + pixels);   
+    int width = 0;
+    if (index + 1 is items[row].length) {
+        width = getWidth() - x;
+    } else {
+        CoolItem right = items[row][index + 1];
+        Rectangle rightBounds = right.internalGetBounds();
+        if (x + item.internalGetMinimumWidth() > rightBounds.x) {
+            int shift = x + item.internalGetMinimumWidth() - rightBounds.x;
+            moveRight(right, shift);
+            rightBounds = right.internalGetBounds();
+        }
+        width = rightBounds.x - x;
+    }
+    item.setBounds(x, bounds.y, width, bounds.height);
+    item.requestedWidth = width;
+    CoolItem left = items[row][index - 1];
+    Rectangle leftBounds = left.internalGetBounds();
+    int leftWidth = x - leftBounds.x;
+    left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+    left.requestedWidth = leftWidth;
+    
+    int damagedWidth = x - bounds.x + CoolItem.MINIMUM_WIDTH + CoolItem.MARGIN_WIDTH;
+    if (x - bounds.x > 0) {
+        internalRedraw(bounds.x - CoolItem.MARGIN_WIDTH, bounds.y, damagedWidth, bounds.height);
+    }
+}
+void moveUp(CoolItem item, int x_root) {
+    Point point = findItem(item);
+    int oldRowIndex = point.y;
+    bool resize = false;
+    if (items[oldRowIndex].length is 1) {
+        resize = true;
+        /* If this is the only item in the top row, don't move it. */
+        if (oldRowIndex is 0) return;
+    }
+    removeItemFromRow(item, oldRowIndex, false);
+    Rectangle old = item.internalGetBounds();
+    internalRedraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height);
+    int newRowIndex = Math.max(0, oldRowIndex - 1);
+    if (oldRowIndex is 0) {
+        /* Create a new top row for the item. */
+        CoolItem[][] newRows = new CoolItem[items.length + 1][];
+        System.arraycopy(items, 0, newRows, 1, items.length);
+        newRows[0] = new CoolItem[1];
+        newRows[0][0] = item;
+        items = newRows;
+        resize = true;
+        item.wrap = true;
+    } else {
+        insertItemIntoRow(item, newRowIndex, x_root);
+    }
+    if (resize) {
+        relayout();
+    } else {
+        layoutItems();
+    }
+}
+void onDispose(Event event) {
+    /*
+     * Usually when an item is disposed, destroyItem will change the size of the items array
+     * and reset the bounds of all the remaining cool items.
+     * Since the whole cool bar is being disposed, this is not necessary.  For speed
+     * the inDispose flag is used to skip over this part of the item dispose.
+     */
+    if (inDispose) return;
+    inDispose = true;
+    notifyListeners(DWT.Dispose, event);
+    event.type = DWT.None;
+    for (int i = 0; i < items.length; i++) {
+        for (int j = 0; j < items[i].length; j++) {
+            items[i][j].dispose();
+        }
+    }
+    hoverCursor.dispose();
+    dragCursor.dispose();
+    cursor = null;
+}
+void onMouseDown(Event event) {
+    if (isLocked || event.button !is 1) return;
+    fixEvent(event);
+    dragging = getGrabbedItem(event.x, event.y);
+    if (dragging !is null) {
+        mouseXOffset = event.x;
+        itemXOffset = mouseXOffset - dragging.internalGetBounds().x;
+        _setCursor(dragCursor);
+    }
+    fixEvent(event);
+}
+void onMouseExit() {
+    if (dragging is null) _setCursor(null);
+}
+void onMouseMove(Event event) {
+    if (isLocked) return;
+    fixEvent(event);
+    CoolItem grabbed = getGrabbedItem(event.x, event.y);
+    if (dragging !is null) {
+        int left_root = toDisplay(new Point(event.x - itemXOffset, event.y)).x;
+        Rectangle bounds = dragging.internalGetBounds();
+        if (event.y < bounds.y) {
+            moveUp(dragging, left_root);
+        } else if (event.y > bounds.y + bounds.height){
+            moveDown(dragging, left_root);
+        } else if (event.x < mouseXOffset) {
+            int distance = Math.min(mouseXOffset, bounds.x + itemXOffset) - event.x;
+            if (distance > 0) moveLeft(dragging, distance);
+        } else if (event.x > mouseXOffset) {
+            int distance = event.x - Math.max(mouseXOffset, bounds.x + itemXOffset);
+            if (distance > 0) moveRight(dragging, distance);
+        }
+        mouseXOffset = event.x;     
+    } else {
+        if (grabbed !is null) {
+            _setCursor(hoverCursor);
+        } else {
+            _setCursor(null);   
+        }
+    }
+    fixEvent(event);
+}
+void onMouseUp(Event event) {
+    _setCursor(null);
+    dragging = null;
+}
+void onMouseDoubleClick(Event event) {
+    if (isLocked) return;   
+    dragging = null;
+    fixEvent(event);
+    CoolItem target = getGrabbedItem(event.x, event.y);
+    if (target is null) {
+        _setCursor(null);
+    } else {
+        Point location = findItem(target);
+        int row = location.y;
+        int index = location.x;
+        if (items[row].length > 1) {
+            Rectangle  bounds = target.internalGetBounds();
+            int maxSize = getWidth ();
+            for (int i = 0; i < items[row].length; i++) {
+                if (i !is index) {
+                    maxSize -= items[row][i].internalGetMinimumWidth(); 
+                }
+            }
+            if (bounds.width is maxSize) {
+                /* The item is at its maximum width. It should be resized to its minimum width. */
+                int distance = bounds.width - target.internalGetMinimumWidth();
+                if (index + 1 < items[row].length) {
+                    /* There is an item to the right. Maximize it. */
+                    CoolItem right = items[row][index + 1];
+                    moveLeft(right, distance);
+                } else {
+                    /* There is no item to the right. Move the item all the way right. */
+                    moveRight(target, distance);
+                }
+            } else if (bounds.width < target.preferredWidth) {
+                /* The item is less than its preferredWidth. Resize to preferredWidth. */
+                int distance = target.preferredWidth - bounds.width;
+                if (index + 1 < items[row].length) {
+                    CoolItem right = items[row][index + 1];
+                    moveRight(right, distance); 
+                    distance = target.preferredWidth - target.internalGetBounds().width;
+                }
+                if (distance > 0) {
+                    moveLeft(target, distance);
+                }
+            } else {
+                /* The item is at its minimum width. Maximize it. */
+                for (int i = 0; i < items[row].length; i++) {
+                    if (i !is index) {
+                        CoolItem item = items[row][i];
+                        item.requestedWidth = Math.max(item.internalGetMinimumWidth(), CoolItem.MINIMUM_WIDTH); 
+                    }
+                }
+                target.requestedWidth = maxSize;
+                layoutItems();
+            }
+            _setCursor(hoverCursor);
+        }
+    }
+    fixEvent(event);
+}
+void onPaint(Event event) {
+    GC gc = event.gc;
+    if (items.length is 0) return;
+    Color shadowColor = display.getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW);
+    Color highlightColor = display.getSystemColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+    bool vertical = (style & DWT.VERTICAL) !is 0;
+    bool flat = (style & DWT.FLAT) !is 0;
+    int stopX = getWidth();
+    Rectangle rect;
+    Rectangle clipping = gc.getClipping();
+    for (int row = 0; row < items.length; row++) {
+        Rectangle bounds = new Rectangle(0, 0, 0, 0);
+        for (int i = 0; i < items[row].length; i++) {
+            bounds = items[row][i].internalGetBounds();
+            rect = fixRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+            if (!clipping.intersects(rect)) continue;
+            bool nativeGripper = false;
+            
+            /* Draw gripper. */
+            if (!isLocked) {
+                rect = fixRectangle(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height);
+                if (!flat)  nativeGripper = drawGripper(rect.x, rect.y, rect.width, rect.height, vertical);
+                if (!nativeGripper) {
+                    int grabberTrim = 2; 
+                    int grabberHeight = bounds.height - (2 * grabberTrim) - 1;
+                    gc.setForeground(shadowColor);
+                    rect = fixRectangle(
+                            bounds.x + CoolItem.MARGIN_WIDTH, 
+                            bounds.y + grabberTrim, 
+                            2, 
+                            grabberHeight);
+                    gc.drawRectangle(rect);
+                    gc.setForeground(highlightColor);
+                    rect = fixRectangle(
+                            bounds.x + CoolItem.MARGIN_WIDTH, 
+                            bounds.y + grabberTrim + 1, 
+                            bounds.x + CoolItem.MARGIN_WIDTH, 
+                            bounds.y + grabberTrim + grabberHeight - 1);
+                    gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+                    rect = fixRectangle(
+                            bounds.x + CoolItem.MARGIN_WIDTH, 
+                            bounds.y + grabberTrim, 
+                            bounds.x + CoolItem.MARGIN_WIDTH + 1, 
+                            bounds.y + grabberTrim);
+                    gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+                }
+            }
+            
+            /* Draw separator. */
+            if (!flat && !nativeGripper && i !is 0) {
+                gc.setForeground(shadowColor);
+                rect = fixRectangle(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+                gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+                gc.setForeground(highlightColor);
+                rect = fixRectangle(bounds.x + 1, bounds.y, bounds.x + 1, bounds.y + bounds.height - 1);
+                gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+            }
+        }
+        if (!flat && row + 1 < items.length) {
+            /* Draw row separator. */
+            int separatorY = bounds.y + bounds.height;
+            gc.setForeground(shadowColor);
+            rect = fixRectangle(0, separatorY, stopX, separatorY);
+            gc.drawLine(rect.x, rect.y, rect.width, rect.height);   
+            gc.setForeground(highlightColor);
+            rect = fixRectangle(0, separatorY + 1, stopX, separatorY + 1);
+            gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+        }
+    }
+}
+void onResize () {
+    layoutItems ();
+}
+void removeControl (Control control) {
+    super.removeControl (control);
+    CoolItem [] items = getItems ();
+    for (int i=0; i<items.length; i++) {
+        CoolItem item = items [i];
+        if (item.control is control) item.setControl (null);
+    }
+}
+/**
+ * Remove the item from the row. Adjust the x and width values
+ * appropriately.
+ */
+void removeItemFromRow(CoolItem item, int rowIndex, bool disposed) {
+    int index = findItem(item).x;
+    int newLength = items[rowIndex].length - 1;
+    Rectangle itemBounds = item.internalGetBounds();
+    item.wrap = false;
+    if (newLength > 0) {
+        CoolItem[] newRow = new CoolItem[newLength];
+        System.arraycopy(items[rowIndex], 0, newRow, 0, index);
+        System.arraycopy(items[rowIndex], index + 1, newRow, index, newRow.length - index);
+        items[rowIndex] = newRow;
+        items[rowIndex][0].wrap = true;
+    } else {
+        CoolItem[][] newRows = new CoolItem[items.length - 1][];
+        System.arraycopy(items, 0, newRows, 0, rowIndex);
+        System.arraycopy(items, rowIndex + 1, newRows, rowIndex, newRows.length - rowIndex);
+        items = newRows;
+        return;
+    }
+    if (!disposed) {
+        if (index is 0) {
+            CoolItem first = items[rowIndex][0];
+            Rectangle bounds = first.internalGetBounds();
+            int width = bounds.x + bounds.width;
+            first.setBounds(0, bounds.y, width, bounds.height);
+            first.requestedWidth = width;
+            internalRedraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height);
+        } else {
+            CoolItem previous = items[rowIndex][index - 1];
+            Rectangle bounds = previous.internalGetBounds();
+            int width = bounds.width + itemBounds.width;
+            previous.setBounds(bounds.x, bounds.y, width, bounds.height);
+            previous.requestedWidth = width;
+        }
+    }
+}
+/**
+ * Return the height of the bar after it has
+ * been properly laid out for the given width.
+ */
+int layoutItems () {
+    int y = 0, width;
+    if ((style&DWT.VERTICAL) !is 0) {
+        width = getClientArea().height; 
+    } else {
+        width = getClientArea().width;
+    }
+    wrapItems(width);
+    int rowSpacing = (style & DWT.FLAT) !is 0 ? 0 : ROW_SPACING; 
+    for (int row = 0; row < items.length; row++) {
+        int count = items[row].length;
+        int x = 0;
+
+        /* determine the height and the available width for the row */
+        int rowHeight = 0;
+        int available = width;
+        for (int i = 0; i < count; i++) {
+            CoolItem item = items[row][i];
+            rowHeight = Math.max(rowHeight, item.internalGetBounds().height);
+            available -= item.internalGetMinimumWidth();    
+        }
+        if (row > 0) y += rowSpacing;
+    
+        /* lay the items out */
+        for (int i = 0; i < count; i++) {
+            CoolItem child = items[row][i];
+            int newWidth = available + child.internalGetMinimumWidth();
+            if (i + 1 < count) {
+                newWidth = Math.min(newWidth, child.requestedWidth);
+                available -= (newWidth - child.internalGetMinimumWidth());
+            }
+            Rectangle oldBounds = child.internalGetBounds();
+            Rectangle newBounds = new Rectangle(x, y, newWidth, rowHeight);
+            if (!oldBounds.equals(newBounds)) {
+                child.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
+                Rectangle damage = new Rectangle(0, 0, 0, 0);
+                /* Cases are in descending order from most area to redraw to least. */
+                if (oldBounds.y !is newBounds.y) {
+                    damage = newBounds;
+                    damage.add(oldBounds);
+                    /* Redraw the row separator as well. */
+                    damage.y -= rowSpacing;
+                    damage.height += 2 * rowSpacing;
+                } else if (oldBounds.height !is newBounds.height) {
+                    /* 
+                     * Draw from the bottom of the gripper to the bottom of the new area.
+                     * (Bottom of the gripper is -3 from the bottom of the item).
+                     */
+                    damage.y = newBounds.y + Math.min(oldBounds.height, newBounds.height) - 3;
+                    damage.height = newBounds.y + newBounds.height + rowSpacing;
+                    damage.x = oldBounds.x - CoolItem.MARGIN_WIDTH;
+                    damage.width = oldBounds.width + CoolItem.MARGIN_WIDTH;
+                } else if (oldBounds.x !is newBounds.x) {
+                    /* Redraw only the difference between the separators. */
+                    damage.x = Math.min(oldBounds.x, newBounds.x);
+                    damage.width = Math.abs(oldBounds.x - newBounds.x) + CoolItem.MINIMUM_WIDTH;
+                    damage.y = oldBounds.y;
+                    damage.height = oldBounds.height;
+                }
+                internalRedraw(damage.x, damage.y, damage.width, damage.height);
+            }
+            x += newWidth;
+        }
+        y += rowHeight;
+    }
+    return y;
+}
+void relayout() {
+    Point size = getSize();
+    int height = layoutItems();
+    if ((style & DWT.VERTICAL) !is 0) {
+        Rectangle trim = computeTrim (0, 0, height, 0);
+        if (height !is size.x) super.setSize(trim.width, size.y);
+    } else {
+        Rectangle trim = computeTrim (0, 0, 0, height);
+        if (height !is size.y) super.setSize(size.x, trim.height);       
+    }
+}
+/**
+ * Returns an array of zero-relative ints that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int[] getItemOrder () {
+    checkWidget ();
+    int count = getItemCount ();
+    int [] indices = new int [count];
+    count = 0;
+    for (int i = 0; i < items.length; i++) {
+        for (int j = 0; j < items[i].length; j++) {
+            CoolItem item = items[i][j];
+            int index = 0;
+            while (index<originalItems.length) {
+                if (originalItems [index] is item) break;
+                index++;    
+            }
+            if (index is originalItems.length) error (DWT.ERROR_CANNOT_GET_ITEM);
+            indices [count++] = index;
+        }
+    }
+    return indices;
+}
+void setItemOrder (int[] itemOrder) {
+    if (itemOrder is null) error(DWT.ERROR_NULL_ARGUMENT);
+    int count = originalItems.length;
+    if (itemOrder.length !is count) error(DWT.ERROR_INVALID_ARGUMENT);
+
+    /* Ensure that itemOrder does not contain any duplicates. */    
+    bool [] set = new bool [count];
+    for (int i = 0; i < set.length; i++) set [i] = false;
+    for (int i = 0; i < itemOrder.length; i++) {
+        if (itemOrder [i] < 0 || itemOrder [i] >= count) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (set [itemOrder [i]]) error (DWT.ERROR_INVALID_ARGUMENT);
+        set [itemOrder [i]] = true;
+    }
+    
+    CoolItem[] row = new CoolItem[count];
+    for (int i = 0; i < count; i++) {
+        row[i] = originalItems[itemOrder[i]];
+    }
+    items = new CoolItem[1][count];
+    items[0] = row;
+}
+/**
+ * Returns an array of points whose x and y coordinates describe
+ * the widths and heights (respectively) of the items in the receiver
+ * in the order in which they are currently being displayed.
+ *
+ * @return the receiver's item sizes in their current visual order
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point[] getItemSizes () {
+    checkWidget();
+    CoolItem[] items = getItems();
+    Point[] sizes = new Point[items.length];
+    for (int i = 0; i < items.length; i++) {
+        sizes[i] = items[i].getSize();
+    }
+    return sizes;
+}
+void setItemSizes (Point[] sizes) {
+    if (sizes is null) error(DWT.ERROR_NULL_ARGUMENT);
+    CoolItem[] items = getItems();
+    if (sizes.length !is items.length) error(DWT.ERROR_INVALID_ARGUMENT);
+    for (int i = 0; i < items.length; i++) {
+        items[i].setSize(sizes[i]);
+    }
+}
+/**
+ * Returns whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @return true if the coolbar is locked, false otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public bool getLocked () {
+    checkWidget ();
+    return isLocked;
+}
+int getWidth () {
+    if ((style & DWT.VERTICAL) !is 0) return getSize().y;
+    return getSize().x; 
+}
+/**
+ * Returns an array of ints that describe the zero-relative
+ * indices of any item(s) in the receiver that will begin on
+ * a new row. The 0th visible item always begins the first row,
+ * therefore it does not count as a wrap index.
+ *
+ * @return an array containing the receiver's wrap indices, or an empty array if all items are in one row
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int[] getWrapIndices () {
+    checkWidget();
+    if (items.length <= 1) return new int[]{};
+    int[] wrapIndices = new int[items.length - 1];
+    int i = 0, nextWrap = items[0].length;
+    for (int row = 1; row < items.length; row++) {
+        if (items[row][0].wrap) wrapIndices[i++] = nextWrap;
+        nextWrap += items[row].length;
+    }
+    if (i !is wrapIndices.length) {
+        int[] tmp = new int[i];
+        System.arraycopy(wrapIndices, 0, tmp, 0, i);
+        return tmp;
+    }
+    return wrapIndices;
+}
+/**
+ * Sets whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @param locked lock the coolbar if true, otherwise unlock the coolbar
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setLocked (bool locked) {
+    checkWidget ();
+    if (isLocked !is locked) {
+        redraw();
+    }
+    isLocked = locked;
+    
+}
+/**
+ * Sets the indices of all item(s) in the receiver that will
+ * begin on a new row. The indices are given in the order in
+ * which they are currently being displayed. The 0th item
+ * always begins the first row, therefore it does not count
+ * as a wrap index. If indices is null or empty, the items
+ * will be placed on one line.
+ *
+ * @param indices an array of wrap indices, or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWrapIndices (int[] indices) {
+    checkWidget();
+    if (indices is null) indices = new int[0];
+    int count = originalItems.length;
+    for (int i=0; i<indices.length; i++) {
+        if (indices[i] < 0 || indices[i] >= count) {
+            error (DWT.ERROR_INVALID_ARGUMENT);
+        }
+    }
+    for (int i=0; i<originalItems.length; i++) {
+        originalItems[i].wrap = false;
+    }
+    for (int i=0; i<indices.length; i++) {
+        int index = indices[i];
+        for (int row = 0; row < items.length; row++) {
+            if (items[row].length > index) {
+                items[row][index].wrap = true;
+                break;
+            } else {
+                index -= items[row].length;
+            }
+        }
+    }
+    relayout();
+}
+public void setCursor (Cursor cursor) {
+    checkWidget ();
+    super.setCursor (this.cursor = cursor);
+}
+/**
+ * Sets the receiver's item order, wrap indices, and item sizes
+ * all at once. This method is typically used to restore the
+ * displayed state of the receiver to a previously stored state.
+ * <p>
+ * The item order is the order in which the items in the receiver
+ * should be displayed, given in terms of the zero-relative ordering
+ * of when the items were added.
+ * </p><p>
+ * The wrap indices are the indices of all item(s) in the receiver
+ * that will begin on a new row. The indices are given in the order
+ * specified by the item order. The 0th item always begins the first
+ * row, therefore it does not count as a wrap index. If wrap indices
+ * is null or empty, the items will be placed on one line.
+ * </p><p>
+ * The sizes are specified in an array of points whose x and y
+ * coordinates describe the new widths and heights (respectively)
+ * of the receiver's items in the order specified by the item order.
+ * </p>
+ *
+ * @param itemOrder an array of indices that describe the new order to display the items in
+ * @param wrapIndices an array of wrap indices, or null
+ * @param sizes an array containing the new sizes for each of the receiver's items in visual order
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if item order or sizes is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items</li>
+ * </ul>
+ */
+public void setItemLayout (int[] itemOrder, int[] wrapIndices, Point[] sizes) {
+    checkWidget();
+    setItemOrder(itemOrder);
+    setWrapIndices(wrapIndices);
+    setItemSizes(sizes);    
+    relayout();
+}
+void wrapItems (int maxWidth) {
+    int itemCount = originalItems.length;
+    if (itemCount < 2) return;
+    CoolItem[] itemsVisual = new CoolItem[itemCount];
+    int start = 0;
+    for (int row = 0; row < items.length; row++) {
+        System.arraycopy(items[row], 0, itemsVisual, start, items[row].length);
+        start += items[row].length;
+    }
+    CoolItem[][] newItems = new CoolItem[itemCount][];
+    int rowCount = 0, rowWidth =  0;
+    start = 0;
+    for (int i = 0; i < itemCount; i++) {
+        CoolItem item = itemsVisual[i];
+        int itemWidth = item.internalGetMinimumWidth();
+        if ((i > 0 && item.wrap) || (maxWidth !is DWT.DEFAULT && rowWidth + itemWidth > maxWidth)) {
+            if (i is start) {
+                newItems[rowCount] = new CoolItem[1];
+                newItems[rowCount][0] = item;
+                start = i + 1;
+                rowWidth = 0;
+            } else {
+                int count = i - start;
+                newItems[rowCount] = new CoolItem[count];
+                System.arraycopy(itemsVisual, start, newItems[rowCount], 0, count);
+                start = i;
+                rowWidth = itemWidth;
+            }
+            rowCount++;         
+        } else {
+            rowWidth += itemWidth;
+        }
+    }
+    if (start < itemCount) {
+        int count = itemCount - start;
+        newItems[rowCount] = new CoolItem[count];
+        System.arraycopy(itemsVisual, start, newItems[rowCount], 0, count);
+        rowCount++;     
+    }
+    if (newItems.length !is rowCount) {
+        CoolItem[][] tmp = new CoolItem[rowCount][];
+        System.arraycopy(newItems, 0, tmp, 0, rowCount);
+        items = tmp;
+    } else {
+        items = newItems;
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/CoolItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,661 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.CoolItem;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Color;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.graphics.PaletteData;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+import dwt.graphics.Rectangle;
+ 
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent the dynamically positionable
+ * areas of a <code>CoolBar</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class CoolItem extends Item {
+    Control control;
+    CoolBar parent;
+    bool ideal;
+    int preferredWidth, preferredHeight, minimumWidth, minimumHeight, requestedWidth;
+    Rectangle itemBounds = new Rectangle(0, 0, 0, 0);
+    
+    static final int MARGIN_WIDTH = 4;
+    static final int GRABBER_WIDTH = 2;
+    static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH;
+    
+    private int CHEVRON_HORIZONTAL_TRIM = -1;           //platform dependent values
+    private int CHEVRON_VERTICAL_TRIM = -1; 
+    private static final int CHEVRON_LEFT_MARGIN = 2;
+    private static final int CHEVRON_IMAGE_WIDTH = 8;   //Width to draw the double arrow
+    
+    ToolBar chevron;
+    bool wrap;
+    Image arrowImage = null;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolItem (CoolBar parent, int style) {
+    super(parent, style);
+    this.parent = parent;
+    parent.createItem (this, parent.getItemCount());
+    calculateChevronTrim ();
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index at which to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolItem (CoolBar parent, int style, int index) {
+    super(parent, style);
+    this.parent = parent;
+    parent.createItem (this, index);
+    calculateChevronTrim ();
+}
+/**
+ * Adds the listener to the collection of listeners that will
+ * be notified when the control is selected by the user, by sending it one
+ * of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * If <code>widgetSelected</code> is called when the mouse is over
+ * the drop-down arrow (or 'chevron') portion of the cool item,
+ * the event object detail field contains the value <code>DWT.ARROW</code>,
+ * and the x and y fields in the event object represent the point at
+ * the bottom left of the chevron, where the menu should be popped up.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ * 
+ * @since 2.0
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+/* 
+ * Find the trim size of the Toolbar widget in the current platform.
+ */
+void calculateChevronTrim () {
+    ToolBar tb = new ToolBar (parent, DWT.FLAT);
+    ToolItem ti = new ToolItem (tb, DWT.PUSH);
+    Image image = new Image (display, 1, 1);
+    ti.setImage (image);
+    Point size = tb.computeSize (DWT.DEFAULT, DWT.DEFAULT);
+    size = parent.fixPoint(size.x, size.y);
+    CHEVRON_HORIZONTAL_TRIM = size.x - 1;
+    CHEVRON_VERTICAL_TRIM = size.y - 1;
+    tb.dispose ();
+    ti.dispose ();
+    image.dispose ();
+}
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a <code>CoolItem</code> is the size that
+ * it would best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask the instance questions such as "Given a particular
+ * width, how high does it need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>DWT.DEFAULT</code> is passed for the hint. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>DWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>DWT.DEFAULT</code>)
+ * @return the preferred size
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBounds
+ * @see #getSize
+ * @see Control#getBorderWidth
+ * @see Scrollable#computeTrim
+ * @see Scrollable#getClientArea
+ */
+public Point computeSize (int wHint, int hHint) {
+    checkWidget();
+    int width = wHint, height = hHint;
+    if (wHint is DWT.DEFAULT) width = 32;
+    if (hHint is DWT.DEFAULT) height = 32;
+    if ((parent.style & DWT.VERTICAL) !is 0) {
+        height += MINIMUM_WIDTH;
+    } else {
+        width += MINIMUM_WIDTH;
+    }   
+    return new Point (width, height);
+}
+public void dispose () {
+    if (isDisposed()) return;
+    
+    /*
+     * Must call parent.destroyItem() before super.dispose(), since it needs to
+     * query the bounds to properly remove the item.
+     */
+    parent.destroyItem(this);
+    super.dispose ();
+    parent = null;
+    control = null;
+    
+    /* 
+     * Although the parent for the chevron is the CoolBar (CoolItem can not be the parent)
+     * it has to be disposed with the item 
+     */
+    if (chevron !is null && !chevron.isDisposed()) chevron.dispose();
+    chevron = null;
+    if (arrowImage !is null && !arrowImage.isDisposed()) arrowImage.dispose();
+    arrowImage = null;
+}
+
+Image createArrowImage (int width, int height) {
+    Point point = parent.fixPoint(width, height);
+    width = point.x;
+    height = point.y;
+    Color foreground = parent.getForeground ();
+    Color black = display.getSystemColor (DWT.COLOR_BLACK);
+    Color background = parent.getBackground ();
+    
+    PaletteData palette = new PaletteData (new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
+    ImageData imageData = new ImageData (width, height, 4, palette);
+    imageData.transparentPixel = 1;
+    Image image = new Image (display, imageData);
+        
+    GC gc = new GC (image, parent.getStyle() & DWT.RIGHT_TO_LEFT);
+    gc.setBackground (background);
+    gc.fillRectangle (0, 0, width, height);
+    gc.setForeground (black);
+    
+    int startX = 0 ;
+    if ((parent.style & DWT.VERTICAL) !is 0) {
+        startX = width - CHEVRON_IMAGE_WIDTH;
+    }
+    int startY = height / 6; 
+    int step = 2;   
+    gc.drawLine (startX, startY, startX + step, startY + step);
+    gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+    startX++;
+    gc.drawLine (startX, startY, startX + step, startY + step);
+    gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+    startX += 3;
+    gc.drawLine (startX, startY, startX + step, startY + step);
+    gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+    startX++;
+    gc.drawLine (startX, startY, startX + step, startY + step);
+    gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+    gc.dispose ();
+    return image;
+}
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+    checkWidget();
+    return parent.fixRectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height);
+}
+Rectangle internalGetBounds () {
+    return new Rectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height);
+}
+/**
+ * Returns the control that is associated with the receiver.
+ *
+ * @return the control that is contained by the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+    checkWidget();
+    return control;
+}
+/**
+ * Returns the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ * 
+ * @return a point containing the minimum width and height of the cool item, in pixels
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Point getMinimumSize () {
+    checkWidget();
+    return parent.fixPoint(minimumWidth, minimumHeight);
+}
+/**
+ * Returns the receiver's parent, which must be a <code>CoolBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public CoolBar getParent () {
+    checkWidget();
+    return parent;
+}
+/**
+ * Returns a point describing the receiver's ideal size.
+ * The x coordinate of the result is the ideal width of the receiver.
+ * The y coordinate of the result is the ideal height of the receiver.
+ *
+ * @return the receiver's ideal size
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getPreferredSize () {
+    checkWidget();
+    return parent.fixPoint(preferredWidth, preferredHeight);
+}
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+    checkWidget();
+    return parent.fixPoint(itemBounds.width, itemBounds.height);
+}
+int internalGetMinimumWidth () {
+    int width = minimumWidth + MINIMUM_WIDTH;
+    if ((style & DWT.DROP_DOWN) !is 0 && width < preferredWidth) {
+        width += CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+    }
+    return width;
+}
+/*
+ *  Called when the chevron is selected.
+ */
+void onSelection (Event ev) {
+    Rectangle bounds = chevron.getBounds();
+    Event event = new Event();
+    event.detail = DWT.ARROW;
+    if ((parent.style & DWT.VERTICAL) !is 0) {
+        event.x = bounds.x + bounds.width;
+        event.y = bounds.y;
+    } else {
+        event.x = bounds.x;
+        event.y = bounds.y + bounds.height;
+    }
+    postEvent (DWT.Selection, event);
+}
+/**
+ * Removes the listener from the collection of listeners that
+ * will be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ * 
+ * @since 2.0
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+void setBounds (int x, int y, int width, int height) {
+    itemBounds.x = x;
+    itemBounds.y = y;
+    itemBounds.width = width;
+    itemBounds.height = height;
+    if (control !is null) {
+        int controlWidth = width - MINIMUM_WIDTH;
+        if ((style & DWT.DROP_DOWN) !is 0 && width < preferredWidth) {
+            controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+        }
+        control.setBounds (parent.fixRectangle(x + MINIMUM_WIDTH,   y, controlWidth, height));
+    }
+    updateChevron();
+}
+/**
+ * Sets the control that is associated with the receiver
+ * to the argument.
+ *
+ * @param control the new control that will be contained by the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+    checkWidget();
+    if (control !is null) {
+        if (control.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (control.parent !is parent) error (DWT.ERROR_INVALID_PARENT);
+    }
+    this.control = control;
+    if (control !is null) {
+        int controlWidth = itemBounds.width - MINIMUM_WIDTH;
+        if ((style & DWT.DROP_DOWN) !is 0 && itemBounds.width < preferredWidth) {
+            controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+        }
+        control.setBounds (parent.fixRectangle(itemBounds.x + MINIMUM_WIDTH, itemBounds.y, controlWidth, itemBounds.height));
+    }
+}
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the arguments.
+ * 
+ * @param width the minimum width of the cool item, in pixels
+ * @param height the minimum height of the cool item, in pixels
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setMinimumSize (int width, int height) {
+    checkWidget ();
+    Point point = parent.fixPoint(width, height);
+    minimumWidth = point.x;
+    minimumHeight = point.y;
+}
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the argument.
+ * 
+ * @param size a point representing the minimum width and height of the cool item, in pixels
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setMinimumSize (Point size) {
+    checkWidget ();
+    if (size is null) error(DWT.ERROR_NULL_ARGUMENT);
+    setMinimumSize(size.x, size.y);
+}
+/**
+ * Sets the receiver's ideal size to the point specified by the arguments.
+ *
+ * @param width the new ideal width for the receiver
+ * @param height the new ideal height for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPreferredSize (int width, int height) {
+    checkWidget();
+    ideal = true;
+    Point point = parent.fixPoint(width, height);
+    preferredWidth = Math.max (point.x, MINIMUM_WIDTH);
+    preferredHeight = point.y;
+}
+/**
+ * Sets the receiver's ideal size to the point specified by the argument.
+ *
+ * @param size the new ideal size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPreferredSize (Point size) {
+    checkWidget();
+    if (size is null) error(DWT.ERROR_NULL_ARGUMENT);
+    setPreferredSize(size.x, size.y);
+}
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (int width, int height) {
+    checkWidget();
+    Point point = parent.fixPoint(width, height);
+    width = Math.max(point.x, minimumWidth + MINIMUM_WIDTH);
+    height = point.y;
+    if (!ideal) {
+        preferredWidth = width;
+        preferredHeight = height;
+    }
+    itemBounds.width = requestedWidth = width;
+    itemBounds.height = height;
+    if (control !is null) {
+        int controlWidth = width - MINIMUM_WIDTH;
+        if ((style & DWT.DROP_DOWN) !is 0 && width < preferredWidth) {
+            controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+        }
+        control.setSize(parent.fixPoint(controlWidth, height));
+    }
+    parent.relayout();
+    updateChevron();
+}
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause them to be
+ * set to zero instead.
+ * </p>
+ *
+ * @param size the new size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (Point size) {
+    checkWidget();
+    if (size is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setSize (size.x, size.y);
+}
+void updateChevron() {
+    if (control !is null) {
+        int width = itemBounds.width;
+        if ((style & DWT.DROP_DOWN) !is 0 && width < preferredWidth) {
+            if (chevron is null) {
+                chevron = new ToolBar (parent, DWT.FLAT | DWT.NO_FOCUS);
+                ToolItem toolItem = new ToolItem (chevron, DWT.PUSH);
+                toolItem.addListener (DWT.Selection, new Listener() {
+                    public void handleEvent (Event event) {
+                        CoolItem.this.onSelection (event);
+                    }
+                });
+            }
+            int controlHeight, currentImageHeight = 0;
+            if ((parent.style & DWT.VERTICAL) !is 0) {
+                controlHeight = control.getSize ().x;
+                if (arrowImage !is null) currentImageHeight = arrowImage.getBounds().width;
+            } else {
+                controlHeight = control.getSize ().y;
+                if (arrowImage !is null) currentImageHeight = arrowImage.getBounds().height;
+            }           
+            int height = Math.min (controlHeight, itemBounds.height);
+            int imageHeight = Math.max(1, height - CHEVRON_VERTICAL_TRIM);          
+            if (currentImageHeight !is imageHeight) {
+                Image image = createArrowImage (CHEVRON_IMAGE_WIDTH, imageHeight);
+                chevron.getItem (0).setImage (image);
+                if (arrowImage !is null) arrowImage.dispose ();
+                arrowImage = image;
+            }
+            chevron.setBackground (parent.getBackground());
+            chevron.setBounds (parent.fixRectangle (
+                itemBounds.x + width - CHEVRON_LEFT_MARGIN - CHEVRON_IMAGE_WIDTH - CHEVRON_HORIZONTAL_TRIM,
+                itemBounds.y,
+                CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM,
+                height));
+            chevron.setVisible(true);
+        } else {
+            if (chevron !is null) {
+                chevron.setVisible(false);
+            }
+        }
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/DateTime.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,533 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.DateTime;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSCalendarDate;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDatePicker;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTDatePicker;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that allow the user to enter and modify date
+ * or time values.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DATE, TIME, CALENDAR, SHORT, MEDIUM, LONG</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles DATE, TIME, or CALENDAR may be specified,
+ * and only one of the styles SHORT, MEDIUM, or LONG may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @since 3.3
+ */
+public class DateTime extends Composite {
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#DATE
+ * @see DWT#TIME
+ * @see DWT#CALENDAR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public DateTime (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+    /*
+    * Even though it is legal to create this widget
+    * with scroll bars, they serve no useful purpose
+    * because they do not automatically scroll the
+    * widget's client area.  The fix is to clear
+    * the DWT style.
+    */
+    style &= ~(DWT.H_SCROLL | DWT.V_SCROLL);
+    style = checkBits (style, DWT.MEDIUM, DWT.SHORT, DWT.LONG, 0, 0, 0);
+    return checkBits (style, DWT.DATE, DWT.TIME, DWT.CALENDAR, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the user changes the control's value.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection, typedListener);
+    addListener (DWT.DefaultSelection, typedListener);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget ();
+    int width = 0, height = 0;
+    NSControl widget = (NSControl)view;
+    NSRect oldRect = widget.frame();
+    widget.sizeToFit();
+    NSRect newRect = widget.frame();
+    widget.setFrame (oldRect);
+    width = (int)newRect.width;
+    height = (int)newRect.height;
+    if (width is 0) width = DEFAULT_WIDTH;
+    if (height is 0) height = DEFAULT_HEIGHT;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    int border = getBorderWidth ();
+    width += border * 2; height += border * 2;
+    return new Point (width, height);
+}
+
+void createHandle () {
+    NSDatePicker widget = (NSDatePicker)new SWTDatePicker().alloc();
+    widget.initWithFrame(new NSRect());
+    int pickerStyle = OS.NSTextFieldAndStepperDatePickerStyle;
+    int elementFlags = 0;
+    if ((style & DWT.CALENDAR) !is 0) {
+        pickerStyle = OS.NSClockAndCalendarDatePickerStyle;
+        elementFlags = OS.NSYearMonthDayDatePickerElementFlag;
+    } else {
+        if ((style & DWT.TIME) !is 0) {
+            elementFlags = (style & DWT.SHORT) !is 0 ? OS.NSHourMinuteDatePickerElementFlag : OS.NSHourMinuteSecondDatePickerElementFlag;
+        }
+        if ((style & DWT.DATE) !is 0) {
+            elementFlags = (style & DWT.SHORT) !is 0 ? OS.NSYearMonthDatePickerElementFlag : OS.NSYearMonthDayDatePickerElementFlag;
+        }
+    }
+    widget.setDrawsBackground(true);
+    widget.setDatePickerStyle(pickerStyle);
+    widget.setDatePickerElements(elementFlags);
+    NSDate date = NSCalendarDate.calendarDate();
+    widget.setDateValue(date);
+    widget.setTarget(widget);
+    widget.setAction(OS.sel_sendSelection);
+    widget.setTag(jniRef);
+    view = widget;  
+    parent.contentView().addSubview_(widget);
+}
+
+/**
+ * Returns the receiver's date, or day of the month.
+ * <p>
+ * The first day of the month is 1, and the last day depends on the month and year.
+ * </p>
+ *
+ * @return a positive integer beginning with 1
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getDay () {
+    checkWidget ();
+    NSDate date = ((NSDatePicker)view).dateValue();
+    NSCalendarDate calendarDate = date.dateWithCalendarFormat(null, null);
+    return calendarDate.dayOfMonth();
+}
+
+/**
+ * Returns the receiver's hours.
+ * <p>
+ * Hours is an integer between 0 and 23.
+ * </p>
+ *
+ * @return an integer between 0 and 23
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHours () {
+    checkWidget ();
+    return new NSCalendarDate(((NSDatePicker)view).dateValue().id).hourOfDay();
+}
+
+/**
+ * Returns the receiver's minutes.
+ * <p>
+ * Minutes is an integer between 0 and 59.
+ * </p>
+ *
+ * @return an integer between 0 and 59
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinutes () {
+    checkWidget ();
+    return new NSCalendarDate(((NSDatePicker)view).dateValue().id).minuteOfHour();
+}
+
+/**
+ * Returns the receiver's month.
+ * <p>
+ * The first month of the year is 0, and the last month is 11.
+ * </p>
+ *
+ * @return an integer between 0 and 11
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMonth () {
+    checkWidget ();
+    return new NSCalendarDate(((NSDatePicker)view).dateValue().id).monthOfYear() - 1;
+}
+
+String getNameText() {
+    return (style & DWT.TIME) !is 0 ? getHours() + ":" + getMinutes() + ":" + getSeconds()
+            : (getMonth() + 1) + "/" + getDay() + "/" + getYear();
+}
+
+/**
+ * Returns the receiver's seconds.
+ * <p>
+ * Seconds is an integer between 0 and 59.
+ * </p>
+ *
+ * @return an integer between 0 and 59
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSeconds () {
+    checkWidget ();
+    return new NSCalendarDate(((NSDatePicker)view).dateValue().id).secondOfMinute();
+}
+
+/**
+ * Returns the receiver's year.
+ * <p>
+ * The first year is 1752 and the last year is 9999.
+ * </p>
+ *
+ * @return an integer between 1752 and 9999
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getYear () {
+    checkWidget ();
+    return new NSCalendarDate(((NSDatePicker)view).dateValue().id).yearOfCommonEra();
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection, listener); 
+}
+
+void sendSelection () {
+    postEvent (DWT.Selection);
+}
+
+void setBackground (float [] color) {
+    NSColor nsColor;
+    if (color is null) {
+        return; // TODO reset to OS default
+    } else {
+        nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    }
+    ((NSDatePicker)view).setBackgroundColor(nsColor);
+}
+
+/**
+ * Sets the receiver's year, month, and day in a single operation.
+ * <p>
+ * This is the recommended way to set the date, because setting the year,
+ * month, and day separately may result in invalid intermediate dates.
+ * </p>
+ *
+ * @param year an integer between 1752 and 9999
+ * @param month an integer between 0 and 11
+ * @param day a positive integer beginning with 1
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void setDate (int year, int month, int day) {
+    checkWidget ();
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(year, month + 1, day,
+            date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone());
+    if (newDate.yearOfCommonEra() is year && newDate.monthOfYear() is month + 1 && newDate.dayOfMonth() is day) {
+        ((NSDatePicker)view).setDateValue(newDate);
+    }
+}
+
+/**
+ * Sets the receiver's date, or day of the month, to the specified day.
+ * <p>
+ * The first day of the month is 1, and the last day depends on the month and year.
+ * </p>
+ *
+ * @param day a positive integer beginning with 1
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDay (int day) {
+    checkWidget ();
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), day,
+            date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone());
+    if (newDate.yearOfCommonEra() is date.yearOfCommonEra() && newDate.monthOfYear() is date.monthOfYear() && newDate.dayOfMonth() is day) {
+        ((NSDatePicker)view).setDateValue(newDate);
+    }
+}
+
+void setForeground (float [] color) {
+    NSColor nsColor;
+    if (color is null) {
+        return; // TODO reset to OS default
+    } else {
+        nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    }
+    ((NSDatePicker)view).setTextColor(nsColor);
+}
+
+/**
+ * Sets the receiver's hours.
+ * <p>
+ * Hours is an integer between 0 and 23.
+ * </p>
+ *
+ * @param hours an integer between 0 and 23
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHours (int hours) {
+    checkWidget ();
+    if (hours < 0 || hours > 23) return;
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(),
+            hours, date.minuteOfHour(), date.secondOfMinute(), date.timeZone());
+    ((NSDatePicker)view).setDateValue(newDate);
+}
+
+/**
+ * Sets the receiver's minutes.
+ * <p>
+ * Minutes is an integer between 0 and 59.
+ * </p>
+ *
+ * @param minutes an integer between 0 and 59
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinutes (int minutes) {
+    checkWidget ();
+    if (minutes < 0 || minutes > 59) return;
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(),
+            date.hourOfDay(), minutes, date.secondOfMinute(), date.timeZone());
+    ((NSDatePicker)view).setDateValue(newDate);
+}
+
+/**
+ * Sets the receiver's month.
+ * <p>
+ * The first month of the year is 0, and the last month is 11.
+ * </p>
+ *
+ * @param month an integer between 0 and 11
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMonth (int month) {
+    checkWidget ();
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), month + 1, date.dayOfMonth(),
+            date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone());
+    if (newDate.yearOfCommonEra() is date.yearOfCommonEra() && newDate.monthOfYear() is month + 1 && newDate.dayOfMonth() is date.dayOfMonth()) {
+        ((NSDatePicker)view).setDateValue(newDate);
+    }
+}
+
+/**
+ * Sets the receiver's seconds.
+ * <p>
+ * Seconds is an integer between 0 and 59.
+ * </p>
+ *
+ * @param seconds an integer between 0 and 59
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSeconds (int seconds) {
+    checkWidget ();
+    if (seconds < 0 || seconds > 59) return;
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(),
+            date.hourOfDay(), date.minuteOfHour(), seconds, date.timeZone());
+    ((NSDatePicker)view).setDateValue(newDate);
+}
+
+/**
+ * Sets the receiver's hours, minutes, and seconds in a single operation.
+ *
+ * @param hours an integer between 0 and 23
+ * @param minutes an integer between 0 and 59
+ * @param seconds an integer between 0 and 59
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void setTime (int hours, int minutes, int seconds) {
+    checkWidget ();
+    if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 59) return;
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(date.yearOfCommonEra(), date.monthOfYear(), date.dayOfMonth(),
+            hours, minutes, seconds, date.timeZone());
+    ((NSDatePicker)view).setDateValue(newDate);
+}
+
+/**
+ * Sets the receiver's year.
+ * <p>
+ * The first year is 1752 and the last year is 9999.
+ * </p>
+ *
+ * @param year an integer between 1752 and 9999
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setYear (int year) {
+    checkWidget ();
+    NSCalendarDate date = new NSCalendarDate(((NSDatePicker)view).dateValue().id);
+    NSCalendarDate newDate = NSCalendarDate.dateWithYear(year, date.monthOfYear(), date.dayOfMonth(),
+            date.hourOfDay(), date.minuteOfHour(), date.secondOfMinute(), date.timeZone());
+    if (newDate.yearOfCommonEra() is year && newDate.monthOfYear() is date.monthOfYear() && newDate.dayOfMonth() is date.dayOfMonth()) {
+        ((NSDatePicker)view).setDateValue(newDate);
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Decorations.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,684 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Decorations;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+
+/**
+ * Instances of this class provide the appearance and
+ * behavior of <code>Shells</code>, but are not top
+ * level shells or dialogs. Class <code>Shell</code>
+ * shares a significant amount of code with this class,
+ * and is a subclass.
+ * <p>
+ * IMPORTANT: This class was intended to be abstract and
+ * should <em>never</em> be referenced or instantiated.
+ * Instead, the class <code>Shell</code> should be used.
+ * </p>
+ * <p>
+ * Instances are always displayed in one of the maximized, 
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized 
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * Note: The styles supported by this class must be treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations.
+ * For example, some window managers only support resizable
+ * windows and will always assume the RESIZE style, even if
+ * it is not set.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * Class <code>DWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that 
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that 
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ *
+ * @see #getMinimized
+ * @see #getMaximized
+ * @see Shell
+ * @see DWT
+ */
+public class Decorations extends Canvas {
+    Image image;
+    Image [] images = new Image [0];
+    Menu menuBar;
+    String text = "";
+    bool minimized, maximized;
+    Control savedFocus;
+    Button defaultButton;
+    
+Decorations () {
+    /* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#BORDER
+ * @see DWT#CLOSE
+ * @see DWT#MIN
+ * @see DWT#MAX
+ * @see DWT#RESIZE
+ * @see DWT#TITLE
+ * @see DWT#NO_TRIM
+ * @see DWT#SHELL_TRIM
+ * @see DWT#DIALOG_TRIM
+ * @see DWT#ON_TOP
+ * @see DWT#TOOL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Decorations (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+    if ((style & DWT.NO_TRIM) !is 0) {
+        style &= ~(DWT.CLOSE | DWT.TITLE | DWT.MIN | DWT.MAX | DWT.RESIZE | DWT.BORDER);
+    }
+    if ((style & (DWT.MENU | DWT.MIN | DWT.MAX | DWT.CLOSE)) !is 0) {
+        style |= DWT.TITLE;
+    }
+    return style;
+}
+
+void bringToTop (bool force) {
+    moveAbove (null);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+int compare (ImageData data1, ImageData data2) {
+    if (data1.width is data2.width && data1.height is data2.height) {
+        int transparent1 = data1.getTransparencyType ();
+        int transparent2 = data2.getTransparencyType ();
+        if (transparent1 is DWT.TRANSPARENCY_ALPHA) return -1;
+        if (transparent2 is DWT.TRANSPARENCY_ALPHA) return 1;
+        if (transparent1 is DWT.TRANSPARENCY_MASK) return -1;
+        if (transparent2 is DWT.TRANSPARENCY_MASK) return 1;
+        if (transparent1 is DWT.TRANSPARENCY_PIXEL) return -1;
+        if (transparent2 is DWT.TRANSPARENCY_PIXEL) return 1;
+        return 0;
+    }
+    return data1.width > data2.width || data1.height > data2.height ? -1 : 1;
+}
+
+Control computeTabGroup () {
+    return this;
+}
+
+Control computeTabRoot () {
+    return this;
+}
+
+void fixDecorations (Decorations newDecorations, Control control, Menu [] menus) {
+    if (this is newDecorations) return;
+    if (control is savedFocus) savedFocus = null;
+    if (control is defaultButton) defaultButton = null;
+    if (menus is null) return;
+    Menu menu = control.menu;
+    if (menu !is null) {
+        int index = 0;
+        while (index < menus.length) {
+            if (menus [index] is menu) {
+                control.setMenu (null);
+                return;
+            }
+            index++;
+        }
+        menu.fixMenus (newDecorations);
+    }
+}
+
+/**
+ * Returns the receiver's default button if one had
+ * previously been set, otherwise returns null.
+ *
+ * @return the default button or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setDefaultButton(Button)
+ */
+public Button getDefaultButton () {
+    checkWidget();
+    return defaultButton;
+}
+
+/**
+ * Returns the receiver's image if it had previously been 
+ * set using <code>setImage()</code>. The image is typically
+ * displayed by the window manager when the instance is
+ * marked as iconified, and may also be displayed somewhere
+ * in the trim when the instance is in normal or maximized
+ * states.
+ * <p>
+ * Note: This method will return null if called before
+ * <code>setImage()</code> is called. It does not provide
+ * access to a window manager provided, "default" image
+ * even if one exists.
+ * </p>
+ * 
+ * @return the image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+    checkWidget();
+    return image;
+}
+
+/**
+ * Returns the receiver's images if they had previously been 
+ * set using <code>setImages()</code>. Images are typically
+ * displayed by the window manager when the instance is
+ * marked as iconified, and may also be displayed somewhere
+ * in the trim when the instance is in normal or maximized
+ * states. Depending where the icon is displayed, the platform
+ * chooses the icon with the "best" attributes.  It is expected
+ * that the array will contain the same icon rendered at different
+ * sizes, with different depth and transparency attributes.
+ * 
+ * <p>
+ * Note: This method will return an empty array if called before
+ * <code>setImages()</code> is called. It does not provide
+ * access to a window manager provided, "default" image
+ * even if one exists.
+ * </p>
+ * 
+ * @return the images
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Image [] getImages () {
+    checkWidget ();
+    if (images is null) return new Image [0];
+    Image [] result = new Image [images.length];
+    System.arraycopy (images, 0, result, 0, images.length);
+    return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is currently
+ * maximized, and false otherwise. 
+ * <p>
+ *
+ * @return the maximized state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMaximized
+ */
+public bool getMaximized () {
+    checkWidget();
+    return maximized;
+}
+
+/**
+ * Returns the receiver's menu bar if one had previously
+ * been set, otherwise returns null.
+ *
+ * @return the menu bar or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getMenuBar () {
+    checkWidget();
+    return menuBar;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is currently
+ * minimized, and false otherwise. 
+ * <p>
+ *
+ * @return the minimized state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMinimized
+ */
+public bool getMinimized () {
+    checkWidget();
+    return minimized;
+}
+
+String getNameText () {
+    return getText ();
+}
+
+/**
+ * Returns the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>. If the text has not previously been set, 
+ * returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget();
+    return text;
+}
+
+public bool isReparentable () {
+    checkWidget();
+    return false;
+}
+
+bool isTabGroup () {
+    return true;
+}
+
+bool isTabItem () {
+    return false;
+}
+
+Decorations menuShell () {
+    return this;
+}
+
+void releaseChildren (bool destroy) {
+    if (menuBar !is null) {
+        menuBar.dispose ();
+        menuBar = null;
+    } 
+    Display display = this.display;
+    super.releaseChildren (destroy);
+    //TODO
+//  Menu [] menus = display.getMenus (this);
+//  if (menus !is null) {
+//      for (int i=0; i<menus.length; i++) {
+//          Menu menu = menus [i];
+//          if (menu !is null && !menu.isDisposed ()) {
+//              menu.dispose ();
+//          }
+//      }
+//      menus = null;
+//  }
+}
+void releaseWidget () {
+    super.releaseWidget ();
+    image = null;
+    images = null;
+    savedFocus = null;
+    defaultButton = null;
+}
+
+bool restoreFocus () {
+    if (savedFocus !is null && savedFocus.isDisposed ()) savedFocus = null;
+    if (savedFocus is null) return false;
+    return savedFocus.forceFocus ();
+}
+
+void saveFocus () {
+//  int window = OS.GetControlOwner (handle);
+//  Control control = display.getFocusControl (window, false);
+//  if (control !is null && control !is this && this is control.menuShell ()) {
+//      setSavedFocus (control);
+//  }
+}
+
+/**
+ * If the argument is not null, sets the receiver's default
+ * button to the argument, and if the argument is null, sets
+ * the receiver's default button to the first button which
+ * was set as the receiver's default button (called the 
+ * <em>saved default button</em>). If no default button had
+ * previously been set, or the saved default button was
+ * disposed, the receiver's default button will be set to
+ * null.
+ * <p>
+ * The default button is the button that is selected when
+ * the receiver is active and the user presses ENTER.
+ * </p>
+ *
+ * @param button the new default button
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDefaultButton (Button button) {
+    checkWidget();
+    if (button !is null) {
+        if (button.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (button.menuShell () !is this) error (DWT.ERROR_INVALID_PARENT);
+        if ((button.style & DWT.PUSH) is 0) return;
+    }
+    if (button is defaultButton) return;
+    if (defaultButton !is null) {
+        if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);
+    }
+    defaultButton = button;
+    if (defaultButton !is null) {
+        if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);
+    }
+}
+
+/**
+ * Sets the receiver's image to the argument, which may
+ * be null. The image is typically displayed by the window
+ * manager when the instance is marked as iconified, and
+ * may also be displayed somewhere in the trim when the
+ * instance is in normal or maximized states.
+ * 
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    this.image = image;
+    if (parent !is null) return;
+//  if (display.dockImage is 0) {
+//      if (image !is null) {
+//          OS.SetApplicationDockTileImage (image.handle);
+//      } else {
+//          OS.RestoreApplicationDockTileImage ();
+//      }
+//  }
+}
+
+/**
+ * Sets the receiver's images to the argument, which may
+ * be an empty array. Images are typically displayed by the
+ * window manager when the instance is marked as iconified,
+ * and may also be displayed somewhere in the trim when the
+ * instance is in normal or maximized states. Depending where
+ * the icon is displayed, the platform chooses the icon with
+ * the "best" attributes. It is expected that the array will
+ * contain the same icon rendered at different sizes, with
+ * different depth and transparency attributes.
+ * 
+ * @param images the new image array
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the images is null or has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setImages (Image [] images) {
+    checkWidget();
+    if (images is null) error(DWT.ERROR_INVALID_ARGUMENT);
+    for (int i = 0; i < images.length; i++) {
+        if (images [i] is null || images [i].isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.images = images;
+    if (parent !is null) return;
+//  if (display.dockImage is 0) {
+//      if (images !is null && images.length > 1) {
+//          Image [] bestImages = new Image [images.length];
+//          System.arraycopy (images, 0, bestImages, 0, images.length);
+//          sort (bestImages);
+//          images = bestImages;
+//      }
+//      OS.SetApplicationDockTileImage (images [0].handle);
+//  }
+}
+
+/**
+ * Sets the maximized state of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the maximized state, and if the argument is
+ * <code>false</code> and the receiver was previously maximized,
+ * causes the receiver to switch back to either the minimized
+ * or normal states.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximized(true)</code>
+ * and <code>setMinimized(true)</code> will vary by platform. Typically,
+ * the behavior will match the platform user's expectations, but not
+ * always. This should be avoided if possible.
+ * </p>
+ *
+ * @param maximized the new maximized state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMinimized
+ */
+public void setMaximized (bool maximized) {
+    checkWidget();
+    this.maximized = maximized;
+}
+
+/**
+ * Sets the receiver's menu bar to the argument, which
+ * may be null.
+ *
+ * @param menu the new menu bar
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenuBar (Menu menu) {
+    checkWidget();
+    if (menuBar is menu) return;
+    if (menu !is null) {
+        if (menu.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+        if ((menu.style & DWT.BAR) is 0) error (DWT.ERROR_MENU_NOT_BAR);
+        if (menu.parent !is this) error (DWT.ERROR_INVALID_PARENT);
+    }
+    menuBar = menu;
+}
+
+/**
+ * Sets the minimized stated of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the minimized state, and if the argument is
+ * <code>false</code> and the receiver was previously minimized,
+ * causes the receiver to switch back to either the maximized
+ * or normal states.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximized(true)</code>
+ * and <code>setMinimized(true)</code> will vary by platform. Typically,
+ * the behavior will match the platform user's expectations, but not
+ * always. This should be avoided if possible.
+ * </p>
+ *
+ * @param minimized the new maximized state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMaximized
+ */
+public void setMinimized (bool minimized) {
+    checkWidget();
+    this.minimized = minimized;
+}
+
+void setSavedFocus (Control control) {
+    savedFocus = control;
+}
+
+/**
+ * Sets the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>, to the argument, which must not be null. 
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    text = string;
+}
+
+void sort (Image [] images) {
+    /* Shell Sort from K&R, pg 108 */
+    int length = images.length;
+    if (length <= 1) return; 
+    ImageData [] datas = new ImageData [length];
+    for (int i = 0; i < length; i++) {
+        datas [i] = images [i].getImageData ();
+    }
+    for (int gap=length/2; gap>0; gap/=2) {
+        for (int i=gap; i<length; i++) {
+            for (int j=i-gap; j>=0; j-=gap) {
+                if (compare (datas [j], datas [j + gap]) >= 0) {
+                    Image swap = images [j];
+                    images [j] = images [j + gap];
+                    images [j + gap] = swap;
+                    ImageData swapData = datas [j];
+                    datas [j] = datas [j + gap];
+                    datas [j + gap] = swapData;
+                }
+            }
+        }
+    }
+}
+
+bool traverseItem (bool next) {
+    return false;
+}
+
+bool traverseReturn () {
+    if (defaultButton is null || defaultButton.isDisposed ()) return false;
+    if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
+    defaultButton.click ();
+    return true;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Dialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Dialog;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+
+/**
+ * This class is the abstract superclass of the classes
+ * that represent the built in platform dialogs.
+ * A <code>Dialog</code> typically contains other widgets
+ * that are not accessible. A <code>Dialog</code> is not
+ * a <code>Widget</code>.
+ * <p>
+ * This class can also be used as the abstract superclass
+ * for user-designed dialogs. Such dialogs usually consist
+ * of a Shell with child widgets. The basic template for a
+ * user-defined dialog typically looks something like this:
+ * <pre><code>
+ * public class MyDialog extends Dialog {
+ *  Object result;
+ *      
+ *  public MyDialog (Shell parent, int style) {
+ *      super (parent, style);
+ *  }
+ *  public MyDialog (Shell parent) {
+ *      this (parent, 0); // your default style bits go here (not the Shell's style bits)
+ *  }
+ *  public Object open () {
+ *      Shell parent = getParent();
+ *      Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL);
+ *      shell.setText(getText());
+ *      // Your code goes here (widget creation, set result, etc).
+ *      shell.open();
+ *      Display display = parent.getDisplay();
+ *      while (!shell.isDisposed()) {
+ *          if (!display.readAndDispatch()) display.sleep();
+ *      }
+ *      return result;
+ *  }
+ * }
+ * </pre></code>
+ * <p>
+ * Note: The <em>modality</em> styles supported by this class
+ * are treated as <em>HINT</em>s, because not all are supported
+ * by every subclass on every platform. If a modality style is
+ * not supported, it is "upgraded" to a more restrictive modality
+ * style that is supported.  For example, if <code>PRIMARY_MODAL</code>
+ * is not supported by a particular dialog, it would be upgraded to 
+ * <code>APPLICATION_MODAL</code>. In addition, as is the case
+ * for shells, the window manager for the desktop on which the
+ * instance is visible has ultimate control over the appearance
+ * and behavior of the instance, including its modality.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>APPLICATION_MODAL, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, PRIMARY_MODAL,
+ * and SYSTEM_MODAL may be specified.
+ * </p>
+ * 
+ * @see Shell
+ */
+
+public abstract class Dialog {
+    int style;
+    Shell parent;
+    String title;
+
+/**
+ * Constructs a new instance of this class given only its
+ * parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+public Dialog (Shell parent) {
+    this (parent, DWT.PRIMARY_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ * 
+ * @see DWT#PRIMARY_MODAL
+ * @see DWT#APPLICATION_MODAL
+ * @see DWT#SYSTEM_MODAL
+ */
+public Dialog (Shell parent, int style) {
+    checkParent (parent);
+    this.parent = parent;
+    this.style = style;
+    title = "";
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ */
+protected void checkSubclass () {
+    if (!Display.isValidClass (getClass ())) {
+        error (DWT.ERROR_INVALID_SUBCLASS);
+    }
+}
+
+/**
+ * Throws an exception if the specified widget can not be
+ * used as a parent for the receiver.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+void checkParent (Shell parent) {
+    if (parent is null) error (DWT.ERROR_NULL_ARGUMENT);
+    parent.checkWidget ();
+}
+
+static int checkStyle (Shell parent, int style) {
+    style &= ~DWT.MIRRORED;
+    if ((style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT)) is 0) {
+        if (parent !is null) {
+            if ((parent.style & DWT.LEFT_TO_RIGHT) !is 0) style |= DWT.LEFT_TO_RIGHT;
+            if ((parent.style & DWT.RIGHT_TO_LEFT) !is 0) style |= DWT.RIGHT_TO_LEFT;
+        }
+    }
+    return Widget.checkBits (style, DWT.LEFT_TO_RIGHT, DWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+
+/**
+ * Does whatever dialog specific cleanup is required, and then
+ * uses the code in <code>DWTError.error</code> to handle the error.
+ *
+ * @param code the descriptive error code
+ *
+ * @see DWT#error(int)
+ */
+void error (int code) {
+    DWT.error(code);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Shell</code>
+ * or null.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Shell getParent () {
+    return parent;
+}
+
+/**
+ * Returns the receiver's style information.
+ * <p>
+ * Note that, the value which is returned by this method <em>may
+ * not match</em> the value which was provided to the constructor
+ * when the receiver was created. 
+ * </p>
+ *
+ * @return the style bits
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getStyle () {
+    return style;
+}
+
+/**
+ * Returns the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>. If the text has not previously been set, 
+ * returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    return title;
+}
+
+/**
+ * Sets the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>, to the argument, which must not be null. 
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    title = string;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/DirectoryDialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.DirectoryDialog;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSOpenPanel;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+
+
+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select a directory.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class DirectoryDialog extends Dialog {
+    String message = "", filterPath = "";
+
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public DirectoryDialog (Shell parent) {
+    this (parent, DWT.APPLICATION_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public DirectoryDialog (Shell parent, int style) {
+    super (parent, style);
+    checkSubclass ();
+}
+
+/**
+ * Returns the path which the dialog will use to filter
+ * the directories it shows.
+ *
+ * @return the filter path
+ * 
+ * @see #setFilterPath
+ */
+public String getFilterPath () {
+    return filterPath;
+}
+
+/**
+ * Returns the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @return the message
+ */
+public String getMessage () {
+    return message;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the selected directory,
+ *         or null if the dialog was cancelled or an error occurred
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public String open () {
+    String directoryPath = null;
+    NSOpenPanel panel = NSOpenPanel.openPanel();
+    panel.setAllowsMultipleSelection((style & DWT.MULTI) !is 0);
+    if (filterPath !is null) panel.setDirectory(NSString.stringWith(filterPath));
+    panel.setTitle(NSString.stringWith(title !is null ? title : ""));
+    panel.setCanChooseFiles(false);
+    panel.setCanChooseDirectories(true);
+    int response = panel.runModal();
+    if (response is OS.NSFileHandlingPanelOKButton) {
+        NSString filename = panel.filename();
+        char[] buffer = new char[filename.length()];
+        filename.getCharacters_(buffer);
+        directoryPath = filterPath = new String(buffer);
+    }
+//  options.optionFlags = OS.kNavSupportPackages | OS.kNavAllowOpenPackages | OS.kNavAllowInvisibleFiles;
+    return directoryPath;
+}
+
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ */
+public void setMessage (String string) {
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    message = string;
+}
+
+/**
+ * Sets the path that the dialog will use to filter
+ * the directories it shows to the argument, which may
+ * be null. If the string is null, then the operating
+ * system's default filter path will be used.
+ * <p>
+ * Note that the path string is platform dependent.
+ * For convenience, either '/' or '\' can be used
+ * as a path separator.
+ * </p>
+ *
+ * @param string the filter path
+ */
+public void setFilterPath (String string) {
+    filterPath = string;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Display.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,3293 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Display;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.graphics.Color;
+import dwt.graphics.Cursor;
+import dwt.graphics.Device;
+import dwt.graphics.DeviceData;
+import dwt.graphics.GCData;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.Callback;
+import dwt.internal.cocoa.CGPoint;
+import dwt.internal.cocoa.NSApplication;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSAutoreleasePool;
+import dwt.internal.cocoa.NSBundle;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSColorSpace;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSImage;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSResponder;
+import dwt.internal.cocoa.NSRunLoop;
+import dwt.internal.cocoa.NSScreen;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSText;
+import dwt.internal.cocoa.NSTimer;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.NSWorkspace;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTApplicationDelegate;
+import dwt.internal.cocoa.SWTWindowDelegate;
+import dwt.internal.cocoa.id;
+
+/**
+ * Instances of this class are responsible for managing the
+ * connection between DWT and the underlying operating
+ * system. Their most important function is to implement
+ * the DWT event loop in terms of the platform event model.
+ * They also provide various methods for accessing information
+ * about the operating system, and have overall control over
+ * the operating system resources which DWT allocates.
+ * <p>
+ * Applications which are built with DWT will <em>almost always</em>
+ * require only a single display. In particular, some platforms
+ * which DWT supports will not allow more than one <em>active</em>
+ * display. In other words, some platforms do not support
+ * creating a new display if one already exists that has not been
+ * sent the <code>dispose()</code> message.
+ * <p>
+ * In DWT, the thread which creates a <code>Display</code>
+ * instance is distinguished as the <em>user-interface thread</em>
+ * for that display.
+ * </p>
+ * The user-interface thread for a particular display has the
+ * following special attributes:
+ * <ul>
+ * <li>
+ * The event loop for that display must be run from the thread.
+ * </li>
+ * <li>
+ * Some DWT API methods (notably, most of the public methods in
+ * <code>Widget</code> and its subclasses), may only be called
+ * from the thread. (To support multi-threaded user-interface
+ * applications, class <code>Display</code> provides inter-thread
+ * communication methods which allow threads other than the 
+ * user-interface thread to request that it perform operations
+ * on their behalf.)
+ * </li>
+ * <li>
+ * The thread is not allowed to construct other 
+ * <code>Display</code>s until that display has been disposed.
+ * (Note that, this is in addition to the restriction mentioned
+ * above concerning platform support for multiple displays. Thus,
+ * the only way to have multiple simultaneously active displays,
+ * even on platforms which support it, is to have multiple threads.)
+ * </li>
+ * </ul>
+ * Enforcing these attributes allows DWT to be implemented directly
+ * on the underlying operating system's event model. This has 
+ * numerous benefits including smaller footprint, better use of 
+ * resources, safer memory management, clearer program logic,
+ * better performance, and fewer overall operating system threads
+ * required. The down side however, is that care must be taken
+ * (only) when constructing multi-threaded applications to use the
+ * inter-thread communication mechanisms which this class provides
+ * when required.
+ * </p><p>
+ * All DWT API methods which may only be called from the user-interface
+ * thread are distinguished in their documentation by indicating that
+ * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
+ * DWT exception.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Close, Dispose, Settings</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * @see #syncExec
+ * @see #asyncExec
+ * @see #wake
+ * @see #readAndDispatch
+ * @see #sleep
+ * @see Device#dispose
+ */
+public class Display extends Device {
+    
+    /* Windows and Events */
+    Event [] eventQueue;
+    EventTable eventTable, filterTable;
+    bool disposing;
+
+    /* Sync/Async Widget Communication */
+    Synchronizer synchronizer;
+    Thread thread;
+    bool allowTimers, runAsyncMessages;
+    
+    int lastModifiers;
+
+    Caret currentCaret;
+    
+    Menu menuBar;
+
+    NSApplication application;
+    NSAutoreleasePool pool;
+
+    NSPoint cascade = new NSPoint();
+
+    Callback applicationDelegateCallback3;
+    Callback windowDelegateCallback2, windowDelegateCallback3, windowDelegateCallback4, windowDelegateCallback5;
+    Callback windowDelegateCallback6;
+    Callback dialogCallback3;
+    
+    /* Menus */
+//  Menu menuBar;
+//  Menu [] menus, popups;
+//  static final int ID_TEMPORARY = 1000;
+//  static final int ID_START = 1001;
+    
+    /* Display Shutdown */
+    Runnable [] disposeList;
+
+    /* System Tray */
+    Tray tray;
+    
+    /* System Resources */
+    Image errorImage, infoImage, warningImage;
+    Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1];
+    
+    /* Key Mappings. */
+    static int [] [] KeyTable = {
+
+        /* Keyboard and Mouse Masks */
+//      {58,    DWT.ALT},
+//      {56,    DWT.SHIFT},
+//      {59,    DWT.CONTROL},
+//      {55,    DWT.COMMAND},
+
+        /* Non-Numeric Keypad Keys */
+        {OS.NSUpArrowFunctionKey, DWT.ARROW_UP},
+        {OS.NSDownArrowFunctionKey, DWT.ARROW_DOWN},
+        {OS.NSLeftArrowFunctionKey, DWT.ARROW_LEFT},
+        {OS.NSRightArrowFunctionKey, DWT.ARROW_RIGHT},
+        {OS.NSPageUpFunctionKey, DWT.PAGE_UP},
+        {OS.NSPageDownFunctionKey, DWT.PAGE_DOWN},
+        {OS.NSHomeFunctionKey, DWT.HOME},
+        {OS.NSEndFunctionKey, DWT.END},
+        
+//      {??,    DWT.INSERT},
+
+        /* Virtual and Ascii Keys */
+        {OS.NSDeleteCharacter, DWT.BS},
+//      {36,    DWT.CR},
+        {OS.NSDeleteFunctionKey, DWT.DEL},
+//      {53,    DWT.ESC},
+//      {76,    DWT.LF},
+//      {48,    DWT.TAB},   
+        
+        /* Functions Keys */
+        {OS.NSF1FunctionKey, DWT.F1},
+        {OS.NSF2FunctionKey, DWT.F2},
+        {OS.NSF3FunctionKey, DWT.F3},
+        {OS.NSF4FunctionKey, DWT.F4},
+        {OS.NSF5FunctionKey, DWT.F5},
+        {OS.NSF6FunctionKey, DWT.F6},
+        {OS.NSF7FunctionKey, DWT.F7},
+        {OS.NSF8FunctionKey, DWT.F8},
+        {OS.NSF9FunctionKey, DWT.F9},
+        {OS.NSF10FunctionKey, DWT.F10},
+        {OS.NSF11FunctionKey, DWT.F11},
+        {OS.NSF12FunctionKey, DWT.F12},
+        {OS.NSF13FunctionKey, DWT.F13},
+        {OS.NSF14FunctionKey, DWT.F14},
+        {OS.NSF15FunctionKey, DWT.F15},
+        
+        /* Numeric Keypad Keys */
+//      {67, DWT.KEYPAD_MULTIPLY},
+//      {69, DWT.KEYPAD_ADD},
+//      {76, DWT.KEYPAD_CR},
+//      {78, DWT.KEYPAD_SUBTRACT},
+//      {65, DWT.KEYPAD_DECIMAL},
+//      {75, DWT.KEYPAD_DIVIDE},
+//      {82, DWT.KEYPAD_0},
+//      {83, DWT.KEYPAD_1},
+//      {84, DWT.KEYPAD_2},
+//      {85, DWT.KEYPAD_3},
+//      {86, DWT.KEYPAD_4},
+//      {87, DWT.KEYPAD_5},
+//      {88, DWT.KEYPAD_6},
+//      {89, DWT.KEYPAD_7},
+//      {91, DWT.KEYPAD_8},
+//      {92, DWT.KEYPAD_9},
+//      {81, DWT.KEYPAD_EQUAL},
+
+        /* Other keys */
+//      {??,    DWT.CAPS_LOCK},
+        
+//      {71,    DWT.NUM_LOCK},
+        
+//      {??,    DWT.SCROLL_LOCK},
+//      {??,    DWT.PAUSE},
+//      {??,    DWT.BREAK},
+//      {??,    DWT.PRINT_SCREEN},
+        
+        {OS.NSHelpFunctionKey, DWT.HELP},
+        
+    };
+
+    static String APP_NAME = "DWT";
+    static final String ADD_WIDGET_KEY = "dwt.internal.addWidget";
+
+    /* Multiple Displays. */
+    static Display Default;
+    static Display [] Displays = new Display [4];
+                
+    /* Package Name */
+    static final String PACKAGE_PREFIX = "dwt.widgets.";
+            
+    /* Timer */
+    Runnable timerList [];
+    NSTimer nsTimers [];
+    SWTWindowDelegate timerDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init();
+    SWTApplicationDelegate applicationDelegate;
+    
+    /* Display Data */
+    Object data;
+    String [] keys;
+    Object [] values;
+    
+    /*
+    * TEMPORARY CODE.  Install the runnable that
+    * gets the current display. This code will
+    * be removed in the future.
+    */
+    static {
+        DeviceFinder = new Runnable () {
+            public void run () {
+                Device device = getCurrent ();
+                if (device is null) {
+                    device = getDefault ();
+                }
+                setDevice (device);
+            }
+        };
+    }
+    
+/*
+* TEMPORARY CODE.
+*/
+static void setDevice (Device device) {
+    CurrentDevice = device;
+}
+
+static byte [] ascii (String name) {
+    int length = name.length ();
+    char [] chars = new char [length];
+    name.getChars (0, length, chars, 0);
+    byte [] buffer = new byte [length + 1];
+    for (int i=0; i<length; i++) {
+        buffer [i] = (byte) chars [i];
+    }
+    return buffer;
+}
+
+static int translateKey (int key) {
+    for (int i=0; i<KeyTable.length; i++) {
+        if (KeyTable [i] [0] is key) return KeyTable [i] [1];
+    }
+    return 0;
+}
+
+static int untranslateKey (int key) {
+    for (int i=0; i<KeyTable.length; i++) {
+        if (KeyTable [i] [1] is key) return KeyTable [i] [0];
+    }
+    return 0;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an event of the given type occurs anywhere
+ * in a widget. The event type is one of the event constants
+ * defined in class <code>DWT</code>. When the event does occur,
+ * the listener is notified by sending it the <code>handleEvent()</code>
+ * message.
+ * <p>
+ * Setting the type of an event to <code>DWT.None</code> from
+ * within the <code>handleEvent()</code> method can be used to
+ * change the event type and stop subsequent Java listeners
+ * from running. Because event filters run before other listeners,
+ * event filters can both block other listeners and set arbitrary
+ * fields within an event. For this reason, event filters are both
+ * powerful and dangerous. They should generally be avoided for
+ * performance, debugging and code maintenance reasons.
+ * </p>
+ * 
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #removeFilter
+ * @see #removeListener
+ * 
+ * @since 3.0 
+ */
+public void addFilter (int eventType, Listener listener) {
+    checkDevice ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (filterTable is null) filterTable = new EventTable ();
+    filterTable.hook (eventType, listener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an event of the given type occurs. The event
+ * type is one of the event constants defined in class <code>DWT</code>.
+ * When the event does occur in the display, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #removeListener
+ * 
+ * @since 2.0 
+ */
+public void addListener (int eventType, Listener listener) {
+    checkDevice ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) eventTable = new EventTable ();
+    eventTable.hook (eventType, listener);
+}
+
+//void addMenu (Menu menu) {
+//  if (menus is null) menus = new Menu [12];
+//  for (int i=0; i<menus.length; i++) {
+//      if (menus [i] is null) {
+//          menu.id = (short)(ID_START + i);
+//          menus [i] = menu;
+//          return;
+//      }
+//  }
+//  Menu [] newMenus = new Menu [menus.length + 12];
+//  menu.id = (short)(ID_START + menus.length);
+//  newMenus [menus.length] = menu;
+//  System.arraycopy (menus, 0, newMenus, 0, menus.length);
+//  menus = newMenus;
+//}
+//
+//void addPopup (Menu menu) {
+//  if (popups is null) popups = new Menu [4];
+//  int length = popups.length;
+//  for (int i=0; i<length; i++) {
+//      if (popups [i] is menu) return;
+//  }
+//  int index = 0;
+//  while (index < length) {
+//      if (popups [index] is null) break;
+//      index++;
+//  }
+//  if (index is length) {
+//      Menu [] newPopups = new Menu [length + 4];
+//      System.arraycopy (popups, 0, newPopups, 0, length);
+//      popups = newPopups;
+//  }
+//  popups [index] = menu;
+//}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The caller of this method continues 
+ * to run in parallel, and is not notified when the
+ * runnable has completed.  Specifying <code>null</code> as the
+ * runnable simply wakes the user-interface thread when run.
+ * <p>
+ * Note that at the time the runnable is invoked, widgets 
+ * that have the receiver as their display may have been
+ * disposed. Therefore, it is necessary to check for this
+ * case inside the runnable before accessing the widget.
+ * </p>
+ *
+ * @param runnable code to run on the user-interface thread or <code>null</code>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #syncExec
+ */
+public void asyncExec (Runnable runnable) {
+    synchronized (Device.class) {
+        if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+        synchronizer.asyncExec (runnable);
+    }
+}
+
+/**
+ * Causes the system hardware to emit a short sound
+ * (if it supports this capability).
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void beep () {
+    checkDevice ();
+}
+
+protected void checkDevice () {
+    if (thread is null) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (thread !is Thread.currentThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ */
+protected void checkSubclass () {
+    if (!Display.isValidClass (getClass ())) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * Note: The resulting display is marked as the <em>current</em>
+ * display. If this is the first display which has been 
+ * constructed since the application started, it is also
+ * marked as the <em>default</em> display.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if called from a thread that already created an existing display</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see #getCurrent
+ * @see #getDefault
+ * @see Widget#checkSubclass
+ * @see Shell
+ */
+public Display () {
+    this (null);
+}
+
+/**
+ * Constructs a new instance of this class using the parameter.
+ * 
+ * @param data the device data
+ */
+public Display (DeviceData data) {
+    super (data);
+}
+
+static void checkDisplay (Thread thread, bool multiple) {
+    synchronized (Device.class) {
+        for (int i=0; i<Displays.length; i++) {
+            if (Displays [i] !is null) {
+                if (!multiple) DWT.error (DWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]");
+                if (Displays [i].thread is thread) DWT.error (DWT.ERROR_THREAD_INVALID_ACCESS);
+            }
+        }
+    }
+}
+
+static String convertToLf(String text) {
+    char Cr = '\r';
+    char Lf = '\n';
+    int length = text.length ();
+    if (length is 0) return text;
+    
+    /* Check for an LF or CR/LF.  Assume the rest of the string 
+     * is formated that way.  This will not work if the string 
+     * contains mixed delimiters. */
+    int i = text.indexOf (Lf, 0);
+    if (i is -1 || i is 0) return text;
+    if (text.charAt (i - 1) !is Cr) return text;
+
+    /* The string is formatted with CR/LF.
+     * Create a new string with the LF line delimiter. */
+    i = 0;
+    StringBuffer result = new StringBuffer ();
+    while (i < length) {
+        int j = text.indexOf (Cr, i);
+        if (j is -1) j = length;
+        String s = text.substring (i, j);
+        result.append (s);
+        i = j + 2;
+        result.append (Lf);
+    }
+    return result.toString ();
+}
+
+/**
+ * Requests that the connection between DWT and the underlying
+ * operating system be closed.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Device#dispose
+ * 
+ * @since 2.0
+ */
+public void close () {
+    checkDevice ();
+    Event event = new Event ();
+    sendEvent (DWT.Close, event);
+    if (event.doit) dispose ();
+}
+
+/**
+ * Creates the device in the operating system.  If the device
+ * does not have a handle, this method may do nothing depending
+ * on the device.
+ * <p>
+ * This method is called before <code>init</code>.
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #init
+ */
+protected void create (DeviceData data) {
+    checkSubclass ();
+    checkDisplay (thread = Thread.currentThread (), false);
+    createDisplay (data);
+    register (this);
+    synchronizer = new Synchronizer (this);
+    if (Default is null) Default = this;
+}
+
+void createDisplay (DeviceData data) {
+    if (OS.VERSION < 0x1050) {
+        System.out.println ("***WARNING: DWT requires MacOS X version " + 10 + "." + 5 + " or greater"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        System.out.println ("***WARNING: Detected: " + Integer.toHexString((OS.VERSION & 0xFF00) >> 8) + "." + Integer.toHexString((OS.VERSION & 0xF0) >> 4) + "." + Integer.toHexString(OS.VERSION & 0xF)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        error(DWT.ERROR_NOT_IMPLEMENTED);
+    }
+
+    /*
+    * Feature in the Macintosh.  On OS 10.2, it is necessary
+    * to explicitly check in with the Process Manager and set
+    * the current process to be the front process in order for
+    * windows to come to the front by default.  The fix is call
+    * both GetCurrentProcess() and SetFrontProcess().
+    * 
+    * NOTE: It is not actually necessary to use the process
+    * serial number returned by GetCurrentProcess() in the
+    * call to SetFrontProcess() (ie. kCurrentProcess can be
+    * used) but both functions must be called in order for
+    * windows to come to the front.
+    */
+    int [] psn = new int [2];
+    if (OS.GetCurrentProcess (psn) is OS.noErr) {
+//      int pid = OS.getpid ();
+//      byte [] buffer = null;
+//      int ptr = OS.getenv (ascii ("APP_NAME_" + pid));
+//      if (ptr !is 0) {
+//          buffer = new byte [OS.strlen (ptr) + 1];
+//          OS.memmove (buffer, ptr, buffer.length);
+//      } else {
+//          if (APP_NAME !is null) {
+//              char [] chars = new char [APP_NAME.length ()];
+//              APP_NAME.getChars (0, chars.length, chars, 0);
+//              int cfstring = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length);
+//              if (cfstring !is 0) {
+//                  CFRange range = new CFRange ();
+//                  range.length = chars.length;
+//                  int encoding = OS.CFStringGetSystemEncoding ();
+//                  int [] size = new int [1];
+//                  int numChars = OS.CFStringGetBytes (cfstring, range, encoding, (byte) '?', true, null, 0, size);
+//                  if (numChars !is 0) {
+//                      buffer = new byte [size [0] + 1];
+//                      numChars = OS.CFStringGetBytes (cfstring, range, encoding, (byte) '?', true, buffer, size [0], size);
+//                  }
+//                  OS.CFRelease (cfstring);
+//              }
+//          }
+//      }
+//      if (buffer !is null) OS.CPSSetProcessName (psn, buffer); 
+        OS.TransformProcessType (psn, OS.kProcessTransformToForegroundApplication);
+        OS.SetFrontProcess (psn);
+//      ptr = OS.getenv (ascii ("APP_ICON_" + pid));
+//      if (ptr !is 0) {
+//          int image = readImageRef (ptr);
+//          if (image !is 0) {
+//              dockImage = image;
+//              OS.SetApplicationDockTileImage (dockImage);
+//          }
+//      }
+    }
+    
+    pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init();
+    application = NSApplication.sharedApplication();
+}
+
+static void deregister (Display display) {
+    synchronized (Device.class) {
+        for (int i=0; i<Displays.length; i++) {
+            if (display is Displays [i]) Displays [i] = null;
+        }
+    }
+}
+
+/**
+ * Destroys the device in the operating system and releases
+ * the device's handle.  If the device does not have a handle,
+ * this method may do nothing depending on the device.
+ * <p>
+ * This method is called after <code>release</code>.
+ * </p>
+ * @see Device#dispose
+ * @see #release
+ */
+protected void destroy () {
+    if (this is Default) Default = null;
+    deregister (this);
+    destroyDisplay ();
+}
+
+void destroyDisplay () {
+    if (pool !is null) pool.release();
+    pool = null;
+    application = null;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread just before the
+ * receiver is disposed.  Specifying a <code>null</code> runnable
+ * is ignored.
+ *
+ * @param runnable code to run at dispose time.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void disposeExec (Runnable runnable) {
+    checkDevice ();
+    if (disposeList is null) disposeList = new Runnable [4];
+    for (int i=0; i<disposeList.length; i++) {
+        if (disposeList [i] is null) {
+            disposeList [i] = runnable;
+            return;
+        }
+    }
+    Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
+    System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
+    newDisposeList [disposeList.length] = runnable;
+    disposeList = newDisposeList;
+}
+
+void error (int code) {
+    DWT.error(code);
+}
+
+bool filterEvent (Event event) {
+    if (filterTable !is null) filterTable.sendEvent (event);
+    return false;
+}
+
+bool filters (int eventType) {
+    if (filterTable is null) return false;
+    return filterTable.hooks (eventType);
+}
+
+/**
+ * Given the operating system handle for a widget, returns
+ * the instance of the <code>Widget</code> subclass which
+ * represents it in the currently running application, if
+ * such exists, or null if no matching widget can be found.
+ * <p>
+ * <b>IMPORTANT:</b> This method should not be called from
+ * application code. The arguments are platform-specific.
+ * </p>
+ *
+ * @param handle the handle for the widget
+ * @return the DWT widget that the handle represents
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Widget findWidget (int handle) {
+    checkDevice ();
+    if (handle !is 0 && OS.objc_msgSend(handle, OS.sel_respondsToSelector_1, OS.sel_tag) !is 0) {
+        int tag = OS.objc_msgSend(handle, OS.sel_tag);
+        if (tag !is -1) {
+            Object object = OS.JNIGetObject(tag);
+            if (object instanceof Widget) {
+                return (Widget)object;
+            }
+        }
+    }
+    return null;
+}
+
+/**
+ * Given the operating system handle for a widget,
+ * and widget-specific id, returns the instance of
+ * the <code>Widget</code> subclass which represents
+ * the handle/id pair in the currently running application,
+ * if such exists, or null if no matching widget can be found.
+ * <p>
+ * <b>IMPORTANT:</b> This method should not be called from
+ * application code. The arguments are platform-specific.
+ * </p>
+ *
+ * @param handle the handle for the widget
+ * @param id the id for the subwidget (usually an item)
+ * @return the DWT widget that the handle/id pair represents
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Widget findWidget (int handle, int id) {
+    checkDevice ();
+    return null;
+}
+
+/**
+ * Given a widget and a widget-specific id, returns the
+ * instance of the <code>Widget</code> subclass which represents
+ * the widget/id pair in the currently running application,
+ * if such exists, or null if no matching widget can be found.
+ *
+ * @param widget the widget
+ * @param id the id for the subwidget (usually an item)
+ * @return the DWT subwidget (usually an item) that the widget/id pair represents
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Widget findWidget (Widget widget, int id) {
+    checkDevice ();
+    return null;
+}
+
+/**
+ * Returns the display which the given thread is the
+ * user-interface thread for, or null if the given thread
+ * is not a user-interface thread for any display.  Specifying
+ * <code>null</code> as the thread will return <code>null</code>
+ * for the display. 
+ *
+ * @param thread the user-interface thread
+ * @return the display for the given thread
+ */
+public static Display findDisplay (Thread thread) {
+    synchronized (Device.class) {
+        for (int i=0; i<Displays.length; i++) {
+            Display display = Displays [i];
+            if (display !is null && display.thread is thread) {
+                return display;
+            }
+        }
+        return null;
+    }
+}
+
+/**
+ * Returns the currently active <code>Shell</code>, or null
+ * if no shell belonging to the currently running application
+ * is active.
+ *
+ * @return the active shell or null
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Shell getActiveShell () {
+    checkDevice ();
+    NSWindow window = application.keyWindow();
+    if (window !is null) {
+        NSView view = window.contentView();
+        if (view !is null && view.respondsToSelector(OS.sel_tag)) {
+            int tag = OS.objc_msgSend(view.id, OS.sel_tag);
+            if (tag !is -1) {
+                Object object = OS.JNIGetObject(tag);
+                if (object instanceof Shell) {
+                    return (Shell)object;
+                }
+            }
+        }
+    }
+    return null;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ *
+ * @return the bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+    checkDevice ();
+    return super.getBounds ();
+}
+
+/**
+ * Returns the display which the currently running thread is
+ * the user-interface thread for, or null if the currently
+ * running thread is not a user-interface thread for any display.
+ *
+ * @return the current display
+ */
+public static Display getCurrent () {
+    return findDisplay (Thread.currentThread ());
+}
+
+int getCaretBlinkTime () {
+    checkDevice ();
+    return 560;
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * 
+ * @return the client area
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
+ */
+public Rectangle getClientArea () {
+    checkDevice ();
+    return super.getClientArea ();
+}
+
+/**
+ * Returns the control which the on-screen pointer is currently
+ * over top of, or null if it is not currently over one of the
+ * controls built by the currently running application.
+ *
+ * @return the control under the cursor
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Control getCursorControl () {
+    checkDevice();
+    return null;
+}
+
+/**
+ * Returns the location of the on-screen pointer relative
+ * to the top left corner of the screen.
+ *
+ * @return the cursor location
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point getCursorLocation () {
+    checkDevice ();
+    NSPoint location = NSEvent.mouseLocation();
+    //TODO bad for other screens
+    NSRect rect = NSScreen.mainScreen().frame();
+    return new Point ((int) location.x, (int) (rect.height - location.y));
+}
+
+/**
+ * Returns an array containing the recommended cursor sizes.
+ *
+ * @return the array of cursor sizes
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Point [] getCursorSizes () {
+    checkDevice ();
+    return new Point [] {new Point (16, 16)};
+}
+
+/**
+ * Returns the default display. One is created (making the
+ * thread that invokes this method its user-interface thread)
+ * if it did not already exist.
+ *
+ * @return the default display
+ */
+public static Display getDefault () {
+    synchronized (Device.class) {
+        if (Default is null) Default = new Display ();
+        return Default;
+    }
+}
+
+/**
+ * Returns the application defined property of the receiver
+ * with the specified name, or null if it has not been set.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the display is disposed
+ * of, it is the application's responsibility to provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @return the value of the property or null if it has not been set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #setData(String, Object)
+ * @see #disposeExec(Runnable)
+ */
+public Object getData (String key) {
+    checkDevice ();
+    if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (keys is null) return null;
+    for (int i=0; i<keys.length; i++) {
+        if (keys [i].equals (key)) return values [i];
+    }
+    return null;
+}
+
+/**
+ * Returns the application defined, display specific data
+ * associated with the receiver, or null if it has not been
+ * set. The <em>display specific data</em> is a single,
+ * unnamed field that is stored with every display. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the display specific data needs to
+ * be notified when the display is disposed of, it is the
+ * application's responsibility to provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @return the display specific data
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #setData(Object)
+ * @see #disposeExec(Runnable)
+ */
+public Object getData () {
+    checkDevice ();
+    return data;
+}
+
+/**
+ * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>.
+ * The button dismissal alignment is the ordering that should be used when positioning the
+ * default dismissal button for a dialog.  For example, in a dialog that contains an OK and
+ * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the
+ * button ordering should be OK/CANCEL.  When button dismissal alignment is <code>RIGHT</code>,
+ * the button ordering should be CANCEL/OK.
+ *
+ * @return the button dismissal order
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public int getDismissalAlignment () {
+    checkDevice ();
+    return DWT.RIGHT;
+}
+
+/**
+ * Returns the longest duration, in milliseconds, between
+ * two mouse button clicks that will be considered a
+ * <em>double click</em> by the underlying operating system.
+ *
+ * @return the double click time
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getDoubleClickTime () {
+    checkDevice ();
+    return 0;
+//  return OS.GetDblTime () * 1000 / 60; 
+}
+
+/**
+ * Returns the control which currently has keyboard focus,
+ * or null if keyboard events are not currently going to
+ * any of the controls built by the currently running
+ * application.
+ *
+ * @return the control under the cursor
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Control getFocusControl () {
+    checkDevice ();
+    NSWindow window = application.keyWindow();
+    if (window !is null) {
+        NSResponder view = window.firstResponder();
+        if (view !is null && view.respondsToSelector(OS.sel_tag)) {
+            int tag = OS.objc_msgSend(view.id, OS.sel_tag);
+            if (tag !is -1) {
+                Object object = OS.JNIGetObject(tag);
+                if (object instanceof Control) {
+                    //TODO go up hierarchy
+                    return (Control)object;
+                }
+            } else {
+                /*
+                * If the first responder is the shared field editor then answer its
+                * delegate as the focus control.
+                */
+                if (view.isKindOfClass(NSText.static_class())) {
+                    NSText text = new NSText(view.id);
+                    if (text.isFieldEditor()) {
+                        id delegateId = text.delegate();
+                        if (delegateId !is null) {
+                            NSObject delegate = new NSObject(delegateId.id);
+                            if (delegate.respondsToSelector(OS.sel_tag)) {
+                                tag = OS.objc_msgSend(delegate.id, OS.sel_tag);
+                                if (tag !is 0 && tag !is -1) {
+                                    Object object = OS.JNIGetObject(tag);
+                                    if (object instanceof Control) {
+                                        return (Control)object;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    return null;
+}
+
+
+/**
+ * Returns true when the high contrast mode is enabled.
+ * Otherwise, false is returned.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @return the high contrast mode
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public bool getHighContrast () {
+    checkDevice ();
+    return false;
+}
+
+/**
+ * Returns the maximum allowed depth of icons on this display, in bits per pixel.
+ * On some platforms, this may be different than the actual depth of the display.
+ *
+ * @return the maximum icon depth
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Device#getDepth
+ */
+public int getIconDepth () {
+    return getDepth ();
+}
+
+/**
+ * Returns an array containing the recommended icon sizes.
+ *
+ * @return the array of icon sizes
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Decorations#setImages(Image[])
+ * 
+ * @since 3.0
+ */
+public Point [] getIconSizes () {
+    checkDevice ();
+    return new Point [] { 
+        new Point (16, 16), new Point (32, 32), 
+        new Point (64, 64), new Point (128, 128)};  
+}
+
+int getLastEventTime () {
+    /*
+    * This code is intentionally commented.  Event time is
+    * in seconds and we need an accurate time in milliseconds.
+    */
+//  return (int) (OS.GetLastUserEventTime () * 1000.0);
+    return (int) System.currentTimeMillis ();
+}
+
+//Menu [] getMenus (Decorations shell) {
+//  if (menus is null) return new Menu [0];
+//  int count = 0;
+//  for (int i = 0; i < menus.length; i++) {
+//      Menu menu = menus[i];
+//      if (menu !is null && menu.parent is shell) count++;
+//  }
+//  int index = 0;
+//  Menu[] result = new Menu[count];
+//  for (int i = 0; i < menus.length; i++) {
+//      Menu menu = menus[i];
+//      if (menu !is null && menu.parent is shell) {
+//          result[index++] = menu;
+//      }
+//  }
+//  return result;
+//}
+//
+//Menu getMenu (int id) {
+//  if (menus is null) return null;
+//  int index = id - ID_START;
+//  if (0 <= index && index < menus.length) return menus [index];
+//  return null;
+//}
+//
+//Menu getMenuBar () {
+//  return menuBar;
+//}
+
+int getMessageCount () {
+    return synchronizer.getMessageCount ();
+}
+
+/**
+ * Returns an array of monitors attached to the device.
+ * 
+ * @return the array of monitors
+ * 
+ * @since 3.0
+ */
+public Monitor [] getMonitors () {
+    checkDevice ();
+    NSArray screens = NSScreen.screens();
+    int count = screens.count();
+    Monitor [] monitors = new Monitor [count];
+    for (int i=0; i<count; i++) {
+        Monitor monitor = new Monitor ();
+        NSScreen screen = new NSScreen(screens.objectAtIndex(i));
+        NSRect frame = screen.frame();
+        monitor.x = (int)frame.x;
+        monitor.y = (int)frame.y;
+        monitor.width = (int)frame.width;
+        monitor.height = (int)frame.height;
+        NSRect visibleFrame = screen.visibleFrame();
+        monitor.clientX = (int)visibleFrame.x;
+        monitor.clientY = (int)visibleFrame.y;
+        monitor.clientWidth = (int)visibleFrame.width;
+        monitor.clientHeight = (int)visibleFrame.height;
+        monitors [i] = monitor;
+    }
+    return monitors;
+}
+
+/**
+ * Returns the primary monitor for that device.
+ * 
+ * @return the primary monitor
+ * 
+ * @since 3.0
+ */
+public Monitor getPrimaryMonitor () {
+    checkDevice ();
+    Monitor monitor = new Monitor ();
+    NSScreen screen = NSScreen.mainScreen();
+    NSRect frame = screen.frame();
+    monitor.x = (int)frame.x;
+    monitor.y = (int)frame.y;
+    monitor.width = (int)frame.width;
+    monitor.height = (int)frame.height;
+    NSRect visibleFrame = screen.visibleFrame();
+    monitor.clientX = (int)visibleFrame.x;
+    monitor.clientY = (int)visibleFrame.y;
+    monitor.clientWidth = (int)visibleFrame.width;
+    monitor.clientHeight = (int)visibleFrame.height;
+    return monitor;
+}
+
+/**
+ * Returns a (possibly empty) array containing all shells which have
+ * not been disposed and have the receiver as their display.
+ *
+ * @return the receiver's shells
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Shell [] getShells () {
+    checkDevice ();
+    NSArray windows = application.windows();
+    int index = 0;
+    Shell [] result = new Shell [windows.count()];
+    for (int i = 0; i < result.length; i++) {
+        NSWindow window = new NSWindow(windows.objectAtIndex(i));
+        NSView view = window.contentView();
+        if (view !is null) {
+            int jniRef = OS.objc_msgSend(view.id, OS.sel_tag);
+            if (jniRef !is 0 && jniRef !is -1) {
+                Object object = OS.JNIGetObject(jniRef);
+                if (object instanceof Shell) {
+                    result[index++] = (Shell)object;
+                }
+            }
+        }
+    }
+    if (index is result.length) return result;
+    Shell [] newResult = new Shell [index];
+    System.arraycopy (result, 0, newResult, 0, index);
+    return newResult;
+}
+
+/**
+ * Gets the synchronizer used by the display.
+ *
+ * @return the receiver's synchronizer
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public Synchronizer getSynchronizer () {
+    checkDevice ();
+    return synchronizer;
+}
+
+/**
+ * Returns the thread that has invoked <code>syncExec</code>
+ * or null if no such runnable is currently being invoked by
+ * the user-interface thread.
+ * <p>
+ * Note: If a runnable invoked by asyncExec is currently
+ * running, this method will return null.
+ * </p>
+ *
+ * @return the receiver's sync-interface thread
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Thread getSyncThread () {
+    synchronized (Device.class) {
+        if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+        return synchronizer.syncThread;
+    }
+}
+
+/**
+ * Returns the matching standard color for the given
+ * constant, which should be one of the color constants
+ * specified in class <code>DWT</code>. Any value other
+ * than one of the DWT color constants which is passed
+ * in will result in the color black. This color should
+ * not be free'd because it was allocated by the system,
+ * not the application.
+ *
+ * @param id the color constant
+ * @return the matching color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see DWT
+ */
+public Color getSystemColor (int id) {
+    checkDevice ();
+    NSColor color = null;
+    switch (id) {
+        case DWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (DWT.COLOR_BLACK);
+        case DWT.COLOR_INFO_BACKGROUND: return Color.cocoa_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1});
+        case DWT.COLOR_TITLE_FOREGROUND: color = NSColor.windowFrameTextColor(); break;
+        case DWT.COLOR_TITLE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break;
+        case DWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = NSColor.windowFrameColor(); break;
+        case DWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = NSColor.disabledControlTextColor();  break;
+        case DWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = NSColor.secondarySelectedControlColor(); break;
+        case DWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = NSColor.secondarySelectedControlColor(); break;
+        case DWT.COLOR_WIDGET_DARK_SHADOW: color = NSColor.controlDarkShadowColor(); break;
+        case DWT.COLOR_WIDGET_NORMAL_SHADOW: color = NSColor.controlShadowColor(); break;
+        case DWT.COLOR_WIDGET_LIGHT_SHADOW: color = NSColor.controlHighlightColor(); break;
+        case DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: color = NSColor.controlLightHighlightColor(); break;
+        case DWT.COLOR_WIDGET_BACKGROUND: color = NSColor.controlHighlightColor(); break;
+        case DWT.COLOR_WIDGET_FOREGROUND: color = NSColor.controlTextColor(); break;
+        case DWT.COLOR_WIDGET_BORDER: return super.getSystemColor (DWT.COLOR_BLACK);
+        case DWT.COLOR_LIST_FOREGROUND: color = NSColor.textColor(); break;
+        case DWT.COLOR_LIST_BACKGROUND: color = NSColor.textBackgroundColor(); break;
+        case DWT.COLOR_LIST_SELECTION_TEXT: color = NSColor.selectedTextColor(); break;
+        case DWT.COLOR_LIST_SELECTION: color = NSColor.selectedTextBackgroundColor(); break;
+        default:
+            return super.getSystemColor (id);   
+    }
+    if (color is null) return super.getSystemColor(id);
+    color = color.colorUsingColorSpace(NSColorSpace.deviceRGBColorSpace());
+    if (color is null) return super.getSystemColor(id);
+    float[] components = new float[color.numberOfComponents()];
+    color.getComponents(components);    
+    return Color.cocoa_new (this, new float[]{components[0], components[1], components[2], components[3]});
+}
+
+/**
+ * Returns the matching standard platform cursor for the given
+ * constant, which should be one of the cursor constants
+ * specified in class <code>DWT</code>. This cursor should
+ * not be free'd because it was allocated by the system,
+ * not the application.  A value of <code>null</code> will
+ * be returned if the supplied constant is not an DWT cursor
+ * constant. 
+ *
+ * @param id the DWT cursor constant
+ * @return the corresponding cursor or <code>null</code>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see DWT#CURSOR_ARROW
+ * @see DWT#CURSOR_WAIT
+ * @see DWT#CURSOR_CROSS
+ * @see DWT#CURSOR_APPSTARTING
+ * @see DWT#CURSOR_HELP
+ * @see DWT#CURSOR_SIZEALL
+ * @see DWT#CURSOR_SIZENESW
+ * @see DWT#CURSOR_SIZENS
+ * @see DWT#CURSOR_SIZENWSE
+ * @see DWT#CURSOR_SIZEWE
+ * @see DWT#CURSOR_SIZEN
+ * @see DWT#CURSOR_SIZES
+ * @see DWT#CURSOR_SIZEE
+ * @see DWT#CURSOR_SIZEW
+ * @see DWT#CURSOR_SIZENE
+ * @see DWT#CURSOR_SIZESE
+ * @see DWT#CURSOR_SIZESW
+ * @see DWT#CURSOR_SIZENW
+ * @see DWT#CURSOR_UPARROW
+ * @see DWT#CURSOR_IBEAM
+ * @see DWT#CURSOR_NO
+ * @see DWT#CURSOR_HAND
+ * 
+ * @since 3.0
+ */
+public Cursor getSystemCursor (int id) {
+    checkDevice ();
+    if (!(0 <= id && id < cursors.length)) return null;
+    if (cursors [id] is null) {
+        cursors [id] = new Cursor (this, id);
+    }
+    return cursors [id];
+}
+
+/**
+ * Returns the matching standard platform image for the given
+ * constant, which should be one of the icon constants
+ * specified in class <code>DWT</code>. This image should
+ * not be free'd because it was allocated by the system,
+ * not the application.  A value of <code>null</code> will
+ * be returned either if the supplied constant is not an
+ * DWT icon constant or if the platform does not define an
+ * image that corresponds to the constant. 
+ *
+ * @param id the DWT icon constant
+ * @return the corresponding image or <code>null</code>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see DWT#ICON_ERROR
+ * @see DWT#ICON_INFORMATION
+ * @see DWT#ICON_QUESTION
+ * @see DWT#ICON_WARNING
+ * @see DWT#ICON_WORKING
+ * 
+ * @since 3.0
+ */
+public Image getSystemImage (int id) {
+    checkDevice ();
+    int code;
+    switch(id) {
+        case DWT.ICON_ERROR:
+            code = OS.kAlertStopIcon;
+            break;
+        case DWT.ICON_INFORMATION:
+        case DWT.ICON_WORKING:
+        case DWT.ICON_QUESTION:
+            code = OS.kAlertNoteIcon;
+            break;
+        case DWT.ICON_WARNING:
+            code = OS.kAlertCautionIcon;
+            break;
+        default:
+            return null;
+    }
+    NSImage nsImage = NSWorkspace.sharedWorkspace().iconForFileType(new NSString(OS.NSFileTypeForHFSTypeCode(code)));
+    if (nsImage is null) return null;
+    return Image.cocoa_new(this, DWT.ICON, nsImage);
+}
+
+/**
+ * Returns the single instance of the system tray or null
+ * when there is no system tray available for the platform.
+ *
+ * @return the system tray or <code>null</code>
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Tray getSystemTray () {
+    checkDevice ();
+    if (tray !is null) return tray;
+    return tray = new Tray (this, DWT.NONE);
+}
+
+/**
+ * Returns the user-interface thread for the receiver.
+ *
+ * @return the receiver's user-interface thread
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Thread getThread () {
+    synchronized (Device.class) {
+        if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+        return thread;
+    }
+}
+
+/**
+ * Initializes any internal resources needed by the
+ * device.
+ * <p>
+ * This method is called after <code>create</code>.
+ * </p>
+ * 
+ * @see #create
+ */
+protected void init () {
+    super.init ();
+    initClasses ();
+    initApplicationDelegate();  
+    application.finishLaunching();
+}
+
+void initApplicationDelegate() {
+    applicationDelegateCallback3 = new Callback(this, "applicationDelegateProc", 3);
+    int appProc3 = applicationDelegateCallback3.getAddress();
+    if (appProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+
+    String className = "SWTApplicationDelegate";
+    int cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+    OS.class_addMethod(cls, OS.sel_applicationWillFinishLaunching_1, appProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_terminate_1, appProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_orderFrontStandardAboutPanel_1, appProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_hideOtherApplications_1, appProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_hide_1, appProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_unhideAllApplications_1, appProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_applicationShouldTerminate_1, appProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_applicationWillTerminate_1, appProc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    applicationDelegate = (SWTApplicationDelegate)new SWTApplicationDelegate().alloc().init();
+    application.setDelegate(applicationDelegate);
+}
+
+void initClasses () {
+    dialogCallback3 = new Callback(this, "dialogProc", 3);
+    int dialogProc3 = dialogCallback3.getAddress();
+    if (dialogProc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    
+    windowDelegateCallback3 = new Callback(this, "windowDelegateProc", 3);
+    int proc3 = windowDelegateCallback3.getAddress();
+    if (proc3 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    windowDelegateCallback2 = new Callback(this, "windowDelegateProc", 2);
+    int proc2 = windowDelegateCallback2.getAddress();
+    if (proc2 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    windowDelegateCallback4 = new Callback(this, "windowDelegateProc", 4);
+    int proc4 = windowDelegateCallback4.getAddress();
+    if (proc4 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    windowDelegateCallback5 = new Callback(this, "windowDelegateProc", 5);
+    int proc5 = windowDelegateCallback5.getAddress();
+    if (proc5 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    windowDelegateCallback6 = new Callback(this, "windowDelegateProc", 6);
+    int proc6 = windowDelegateCallback6.getAddress();
+    if (proc6 is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    
+    int drawRectProc = OS.drawRect_CALLBACK(proc3);
+
+    String className = "SWTWindowDelegate";
+    int cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_windowDidResize_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_windowShouldClose_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_windowWillClose_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_windowWillClose_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_windowDidResignKey_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_windowDidBecomeKey_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_timerProc_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTPanelDelegate";
+    cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_windowWillClose_1, dialogProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_changeColor_1, dialogProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_changeFont_1, dialogProc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTMenu";
+    cls = OS.objc_allocateClassPair(OS.class_NSMenu, className, 0);
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+//  OS.class_addMethod(cls, OS.sel_menuWillOpen_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_menuWillClose_1, proc3, "@:@");
+//  OS.class_addMethod(cls, OS.sel_numberOfItemsInMenu_1, proc3, "@:@");    
+    OS.class_addMethod(cls, OS.sel_menu_1willHighlightItem_1, proc4, "@:@@");
+    OS.class_addMethod(cls, OS.sel_menuNeedsUpdate_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTView";
+    cls = OS.objc_allocateClassPair(OS.class_NSView, className, 0);
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
+    OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_mouseDragged_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_mouseEntered_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_mouseUp_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_resignFirstResponder, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_becomeFirstResponder, proc2, "@:");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTScrollView";
+    cls = OS.objc_allocateClassPair(OS.class_NSScrollView, className, 0);
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_sendHorizontalSelection, proc2, "@:");
+//  OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTButton";
+    cls = OS.objc_allocateClassPair(OS.class_NSButton, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+//  OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
+    OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_sendArrowSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTTableView";
+    cls = OS.objc_allocateClassPair(OS.class_NSTableView, className, 0);
+    OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_tableView_1objectValueForTableColumn_1row_1, proc5, "@:@:@:@");
+    OS.class_addMethod(cls, OS.sel_tableView_1shouldEditTableColumn_1row_1, proc5, "@:@:@:@");
+    OS.class_addMethod(cls, OS.sel_tableViewSelectionDidChange_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1, proc6, "@:@@@i");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1, proc6, "@:@@@i");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTOutlineView";
+    cls = OS.objc_allocateClassPair(OS.class_NSOutlineView, className, 0);
+    OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_outlineViewSelectionDidChange_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1shouldCollapseItem_1, proc4, "@:@@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1shouldExpandItem_1, proc4, "@:@@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1child_1ofItem_1, proc5, "@:@i@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1isItemExpandable_1, proc4, "@:@@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1numberOfChildrenOfItem_1, proc4, "@:@@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1objectValueForTableColumn_1byItem_1, proc5, "@:@@@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1, proc6, "@:@@@@");
+    OS.class_addMethod(cls, OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1, proc6, "@:@@@@");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTTreeItem";
+    cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTTabView";
+    cls = OS.objc_allocateClassPair(OS.class_NSTabView, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tabView_1willSelectTabViewItem_1, proc4, "@:@@");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTBox";
+    cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTProgressIndicator";
+    cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls); 
+
+    className = "SWTSlider";
+    cls = OS.objc_allocateClassPair(OS.class_NSSlider, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls); 
+    
+    className = "SWTPopUpButton";
+    cls = OS.objc_allocateClassPair(OS.class_NSPopUpButton, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTComboBox";
+    cls = OS.objc_allocateClassPair(OS.class_NSComboBox, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTDatePicker";
+    cls = OS.objc_allocateClassPair(OS.class_NSDatePicker, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTImageView";
+    cls = OS.objc_allocateClassPair(OS.class_NSImageView, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_drawRect_1, OS.drawRect_CALLBACK(proc3), "@:i");
+    OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_mouseUp_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_rightMouseDown_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTStepper";
+    cls = OS.objc_allocateClassPair(OS.class_NSStepper, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTScroller";
+    cls = OS.objc_allocateClassPair(OS.class_NSScroller, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTMenuItem";
+    cls = OS.objc_allocateClassPair(OS.class_NSMenuItem, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTTextView";
+    cls = OS.objc_allocateClassPair(OS.class_NSTextView, className, 0);
+//  OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
+//  OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_textView_1clickedOnLink_1atIndex_1, proc5, "@:@@i");
+    OS.objc_registerClassPair(cls);
+    
+    className = "SWTTextField";
+    cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0);
+    OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
+    OS.objc_registerClassPair(cls);
+
+    className = "SWTWindow";
+    cls = OS.objc_allocateClassPair(OS.class_NSWindow, className, 0);
+    OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+    OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
+    OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
+    OS.class_addMethod(cls, OS.sel_sendEvent_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_flagsChanged_1, proc3, "@:@");
+    OS.class_addMethod(cls, OS.sel_helpRequested_1, proc3, "@:@");
+    OS.objc_registerClassPair(cls);
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Display</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
+ * </ul>
+ */
+public int internal_new_GC (GCData data) {
+    if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
+    NSGraphicsContext context = application.context();
+//  NSAffineTransform transform = NSAffineTransform.transform();
+//  NSSize size = handle.size();
+//  transform.translateXBy(0, size.height);
+//  transform.scaleXBy(1, -1);
+//  transform.set();
+    if (data !is null) {
+        int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
+        if ((data.style & mask) is 0) {
+            data.style |= DWT.LEFT_TO_RIGHT;
+        }
+        data.device = this;
+        data.background = getSystemColor(DWT.COLOR_WHITE).handle;
+        data.foreground = getSystemColor(DWT.COLOR_BLACK).handle;
+        data.font = getSystemFont();
+    }
+    return context.id;
+}
+
+/**  
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Display</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int context, GCData data) {
+    if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
+    
+}
+
+static bool isValidClass (Class clazz) {
+    String name = clazz.getName ();
+    int index = name.lastIndexOf ('.');
+    return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
+}
+
+bool isValidThread () {
+    return thread is Thread.currentThread ();
+}
+
+/**
+ * Generate a low level system event.
+ * 
+ * <code>post</code> is used to generate low level keyboard
+ * and mouse events. The intent is to enable automated UI
+ * testing by simulating the input from the user.  Most
+ * DWT applications should never need to call this method.
+ * <p>
+ * Note that this operation can fail when the operating system
+ * fails to generate the event for any reason.  For example,
+ * this can happen when there is no such key or mouse button
+ * or when the system event queue is full.
+ * </p>
+ * <p>
+ * <b>Event Types:</b>
+ * <p>KeyDown, KeyUp
+ * <p>The following fields in the <code>Event</code> apply:
+ * <ul>
+ * <li>(in) type KeyDown or KeyUp</li>
+ * <p> Either one of:
+ * <li>(in) character a character that corresponds to a keyboard key</li>
+ * <li>(in) keyCode the key code of the key that was typed,
+ *          as defined by the key code constants in class <code>DWT</code></li>
+ * </ul>
+ * <p>MouseDown, MouseUp</p>
+ * <p>The following fields in the <code>Event</code> apply:
+ * <ul>
+ * <li>(in) type MouseDown or MouseUp
+ * <li>(in) button the button that is pressed or released
+ * </ul>
+ * <p>MouseMove</p>
+ * <p>The following fields in the <code>Event</code> apply:
+ * <ul>
+ * <li>(in) type MouseMove
+ * <li>(in) x the x coordinate to move the mouse pointer to in screen coordinates
+ * <li>(in) y the y coordinate to move the mouse pointer to in screen coordinates
+ * </ul>
+ * </dl>
+ * 
+ * @param event the event to be generated
+ * 
+ * @return true if the event was generated or false otherwise
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the event is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ * 
+ */
+public bool post(Event event) {
+    synchronized (Device.class) {
+        if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+        if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
+//      int type = event.type;
+//      switch (type) {
+//          case DWT.KeyDown:
+//          case DWT.KeyUp: {
+//              int vKey = Display.untranslateKey (event.keyCode);
+//              if (vKey !is 0) {
+//                  return OS.CGPostKeyboardEvent (0, vKey, type is DWT.KeyDown) is 0;
+//              } else {
+//                  vKey = -1;
+//                  int kchrPtr = OS.GetScriptManagerVariable ((short) OS.smKCHRCache);
+//                  int key = -1;
+//                  int [] state = new int [1];
+//                  int [] encoding = new int [1];
+//                  short keyScript = (short) OS.GetScriptManagerVariable ((short) OS.smKeyScript);
+//                  short regionCode = (short) OS.GetScriptManagerVariable ((short) OS.smRegionCode);
+//                  if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, regionCode, null, encoding) is OS.paramErr) {
+//                      if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, (short) OS.kTextRegionDontCare, null, encoding) is OS.paramErr) {
+//                          encoding [0] = OS.kTextEncodingMacRoman;
+//                      }
+//                  }
+//                  int [] encodingInfo = new int [1];
+//                  OS.CreateUnicodeToTextInfoByEncoding (encoding [0], encodingInfo);
+//                  if (encodingInfo [0] !is 0) {
+//                      char [] input = {event.character};
+//                      byte [] buffer = new byte [2];
+//                      OS.ConvertFromUnicodeToPString (encodingInfo [0], 2, input, buffer);
+//                      OS.DisposeUnicodeToTextInfo (encodingInfo);
+//                      key = buffer [1] & 0x7f;
+//                  }
+//                  if (key is -1) return false;                
+//                  for (int i = 0 ; i <= 0x7F ; i++) {
+//                      int result1 = OS.KeyTranslate (kchrPtr, (short) (i | 512), state);
+//                      int result2 = OS.KeyTranslate (kchrPtr, (short) i, state);
+//                      if ((result1 & 0x7f) is key || (result2 & 0x7f) is key) {
+//                          vKey = i;
+//                          break;
+//                      }
+//                  }
+//                  if (vKey is -1) return false;
+//                  return OS.CGPostKeyboardEvent (key, vKey, type is DWT.KeyDown) is 0;
+//              }
+//          }
+//          case DWT.MouseDown:
+//          case DWT.MouseMove: 
+//          case DWT.MouseUp: {
+//              CGPoint mouseCursorPosition = new CGPoint ();
+//              int chord = OS.GetCurrentEventButtonState ();
+//              if (type is DWT.MouseMove) {
+//                  mouseCursorPosition.x = event.x;
+//                  mouseCursorPosition.y = event.y;
+//                  return OS.CGPostMouseEvent (mouseCursorPosition, true, 5, (chord & 0x1) !is 0, (chord & 0x2) !is 0, (chord & 0x4) !is 0, (chord & 0x8) !is 0, (chord & 0x10) !is 0) is 0;
+//              } else {
+//                  int button = event.button;
+//                  if (button < 1 || button > 5) return false;
+//                  bool button1 = false, button2 = false, button3 = false, button4 = false, button5 = false;
+//                  switch (button) {
+//                      case 1: {
+//                          button1 = type is DWT.MouseDown;
+//                          button2 = (chord & 0x4) !is 0;
+//                          button3 = (chord & 0x2) !is 0;
+//                          button4 = (chord & 0x8) !is 0;
+//                          button5 = (chord & 0x10) !is 0;
+//                          break;
+//                      }
+//                      case 2: {
+//                          button1 = (chord & 0x1) !is 0;
+//                          button2 = type is DWT.MouseDown;
+//                          button3 = (chord & 0x2) !is 0;
+//                          button4 = (chord & 0x8) !is 0;
+//                          button5 = (chord & 0x10) !is 0;
+//                          break;
+//                      }
+//                      case 3: {
+//                          button1 = (chord & 0x1) !is 0;
+//                          button2 = (chord & 0x4) !is 0;
+//                          button3 = type is DWT.MouseDown;
+//                          button4 = (chord & 0x8) !is 0;
+//                          button5 = (chord & 0x10) !is 0;
+//                          break;
+//                      }
+//                      case 4: {
+//                          button1 = (chord & 0x1) !is 0;
+//                          button2 = (chord & 0x4) !is 0;
+//                          button3 = (chord & 0x2) !is 0;
+//                          button4 = type is DWT.MouseDown;
+//                          button5 = (chord & 0x10) !is 0;
+//                          break;
+//                      }
+//                      case 5: {
+//                          button1 = (chord & 0x1) !is 0;
+//                          button2 = (chord & 0x4) !is 0;
+//                          button3 = (chord & 0x2) !is 0;
+//                          button4 = (chord & 0x8) !is 0;
+//                          button5 = type is DWT.MouseDown;
+//                          break;
+//                      }
+//                  }
+//                  dwt.internal.carbon.Point pt = new dwt.internal.carbon.Point ();
+//                  OS.GetGlobalMouse (pt);
+//                  mouseCursorPosition.x = pt.h;
+//                  mouseCursorPosition.y = pt.v;
+//                  return OS.CGPostMouseEvent (mouseCursorPosition, true, 5, button1, button3, button2, button4, button5) is 0;
+//              }
+//          }
+//          case DWT.MouseWheel: {
+//              return OS.CGPostScrollWheelEvent (1, event.count) is 0;
+//          }
+//      } 
+        return false;
+    }
+}
+
+void postEvent (Event event) {
+    /*
+    * Place the event at the end of the event queue.
+    * This code is always called in the Display's
+    * thread so it must be re-enterant but does not
+    * need to be synchronized.
+    */
+    if (eventQueue is null) eventQueue = new Event [4];
+    int index = 0;
+    int length = eventQueue.length;
+    while (index < length) {
+        if (eventQueue [index] is null) break;
+        index++;
+    }
+    if (index is length) {
+        Event [] newQueue = new Event [length + 4];
+        System.arraycopy (eventQueue, 0, newQueue, 0, length);
+        eventQueue = newQueue;
+    }
+    eventQueue [index] = event;
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param point to be mapped 
+ * @return point with mapped coordinates 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Point map (Control from, Control to, Point point) {
+    checkDevice ();
+    if (point is null) error (DWT.ERROR_NULL_ARGUMENT); 
+    return map (from, to, point.x, point.y);
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param x coordinates to be mapped
+ * @param y coordinates to be mapped
+ * @return point with mapped coordinates
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Point map (Control from, Control to, int x, int y) {
+    checkDevice ();
+    if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+    Point point = new Point (x, y);
+    if (from is to) return point;
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    NSWindow fromWindow = from !is null ? from.view.window() : null;
+    NSWindow toWindow = to !is null ? to.view.window() : null;
+    if (toWindow !is null && fromWindow !is null && toWindow.id is fromWindow.id) {
+        pt = from.view.convertPoint_toView_(pt, to.view);
+    } else {
+        if (from !is null) {
+            pt = from.view.convertPoint_toView_(pt, null);
+            pt = fromWindow.convertBaseToScreen(pt);
+            pt.y = fromWindow.screen().frame().height - pt.y;
+        }
+        if (to !is null) {
+            pt.y = toWindow.screen().frame().height - pt.y;
+            pt = toWindow.convertScreenToBase(pt);
+            pt = to.view.convertPoint_fromView_(pt, null);
+        }
+    }
+    point.x = (int)pt.x;
+    point.y = (int)pt.y;
+    return point;
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param rectangle to be mapped
+ * @return rectangle with mapped coordinates
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Rectangle map (Control from, Control to, Rectangle rectangle) {
+    checkDevice ();
+    if (rectangle is null) error (DWT.ERROR_NULL_ARGUMENT); 
+    return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param x coordinates to be mapped
+ * @param y coordinates to be mapped
+ * @param width coordinates to be mapped
+ * @param height coordinates to be mapped
+ * @return rectangle with mapped coordinates
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
+    checkDevice ();
+    if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+    Rectangle rectangle = new Rectangle (x, y, width, height);
+    if (from is to) return rectangle;
+    NSPoint pt = new NSPoint();
+    pt.x = x;
+    pt.y = y;
+    NSWindow fromWindow = from !is null ? from.view.window() : null;
+    NSWindow toWindow = to !is null ? to.view.window() : null;
+    if (toWindow !is null && fromWindow !is null && toWindow.id is fromWindow.id) {
+        pt = from.view.convertPoint_toView_(pt, to.view);
+    } else {
+        if (from !is null) {
+            pt = from.view.convertPoint_toView_(pt, null);
+            pt = fromWindow.convertBaseToScreen(pt);
+            pt.y = fromWindow.screen().frame().height - pt.y;
+        }
+        if (to !is null) {
+            pt.y = toWindow.screen().frame().height - pt.y;
+            pt = toWindow.convertScreenToBase(pt);
+            pt = to.view.convertPoint_fromView_(pt, null);
+        }
+    }
+    rectangle.x = (int)pt.x;
+    rectangle.y = (int)pt.y;
+    return rectangle;
+}
+
+/**
+ * Reads an event from the operating system's event queue,
+ * dispatches it appropriately, and returns <code>true</code>
+ * if there is potentially more work to do, or <code>false</code>
+ * if the caller can sleep until another event is placed on
+ * the event queue.
+ * <p>
+ * In addition to checking the system event queue, this method also
+ * checks if any inter-thread messages (created by <code>syncExec()</code>
+ * or <code>asyncExec()</code>) are waiting to be processed, and if
+ * so handles them before returning.
+ * </p>
+ *
+ * @return <code>false</code> if the caller can sleep upon return from this method
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
+ * </ul>
+ *
+ * @see #sleep
+ * @see #wake
+ */
+public bool readAndDispatch () {
+    checkDevice ();
+    NSAutoreleasePool pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init();
+    try {
+        bool events = false;
+        events |= runTimers ();
+        NSEvent event = application.nextEventMatchingMask(0, null, OS.NSDefaultRunLoopMode, true);
+        if (event !is null) {
+            events = true;
+            application.sendEvent(event);
+        }
+        if (events) {
+            runDeferredEvents ();
+            return true;
+        }
+        return runAsyncMessages (false);
+    } finally {
+        pool.release();
+    }
+}
+
+static void register (Display display) {
+    synchronized (Device.class) {
+        for (int i=0; i<Displays.length; i++) {
+            if (Displays [i] is null) {
+                Displays [i] = display;
+                return;
+            }
+        }
+        Display [] newDisplays = new Display [Displays.length + 4];
+        System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+        newDisplays [Displays.length] = display;
+        Displays = newDisplays;
+    }
+}
+
+/**
+ * Releases any internal resources back to the operating
+ * system and clears all fields except the device handle.
+ * <p>
+ * Disposes all shells which are currently open on the display. 
+ * After this method has been invoked, all related related shells
+ * will answer <code>true</code> when sent the message
+ * <code>isDisposed()</code>.
+ * </p><p>
+ * When a device is destroyed, resources that were acquired
+ * on behalf of the programmer need to be returned to the
+ * operating system.  For example, if the device allocated a
+ * font to be used as the system font, this font would be
+ * freed in <code>release</code>.  Also,to assist the garbage
+ * collector and minimize the amount of memory that is not
+ * reclaimed when the programmer keeps a reference to a
+ * disposed device, all fields except the handle are zero'd.
+ * The handle is needed by <code>destroy</code>.
+ * </p>
+ * This method is called before <code>destroy</code>.
+ * 
+ * @see Device#dispose
+ * @see #destroy
+ */
+protected void release () {
+    disposing = true;
+    sendEvent (DWT.Dispose, new Event ());
+    Shell [] shells = getShells ();
+    for (int i=0; i<shells.length; i++) {
+        Shell shell = shells [i];
+        if (!shell.isDisposed ()) shell.dispose ();
+    }
+    if (tray !is null) tray.dispose ();
+    tray = null;
+//  while (readAndDispatch ()) {}
+    if (disposeList !is null) {
+        for (int i=0; i<disposeList.length; i++) {
+            if (disposeList [i] !is null) disposeList [i].run ();
+        }
+    }
+    disposeList = null;
+    synchronizer.releaseSynchronizer ();
+    synchronizer = null;
+    releaseDisplay ();
+    super.release ();
+}
+
+void releaseDisplay () {    
+    /* Release the System Images */
+    if (errorImage !is null) errorImage.dispose ();
+    if (infoImage !is null) infoImage.dispose ();
+    if (warningImage !is null) warningImage.dispose ();
+    errorImage = infoImage = warningImage = null;
+    
+    //TODO - stop caret
+    currentCaret = null;
+    
+    /* Release Timers */
+    if (nsTimers !is null) {
+        for (int i=0; i<nsTimers.length; i++) {
+            //TODO - check -1 as sentinal
+            if (nsTimers [i] !is null /*&& timerIds [i] !is -1*/) {
+                nsTimers [i].invalidate();
+                nsTimers [i].release();
+            }
+        }
+    }
+    nsTimers = null;
+    
+    /* Release the System Cursors */
+    for (int i = 0; i < cursors.length; i++) {
+        if (cursors [i] !is null) cursors [i].dispose ();
+    }
+    cursors = null;
+
+    if (windowDelegateCallback2 !is null) windowDelegateCallback2.dispose ();
+    if (windowDelegateCallback3 !is null) windowDelegateCallback3.dispose ();
+    if (windowDelegateCallback4 !is null) windowDelegateCallback4.dispose ();
+    if (windowDelegateCallback5 !is null) windowDelegateCallback5.dispose ();
+    if (windowDelegateCallback6 !is null) windowDelegateCallback6.dispose ();
+    if (dialogCallback3 !is null) dialogCallback3.dispose ();
+    windowDelegateCallback2 = windowDelegateCallback3 = windowDelegateCallback4 = null;
+    windowDelegateCallback6 = windowDelegateCallback5 = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs anywhere in
+ * a widget. The event type is one of the event constants defined
+ * in class <code>DWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #addFilter
+ * @see #addListener
+ * 
+ * @since 3.0
+ */
+public void removeFilter (int eventType, Listener listener) {
+    checkDevice ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (filterTable is null) return;
+    filterTable.unhook (eventType, listener);
+    if (filterTable.size () is 0) filterTable = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs. The event type
+ * is one of the event constants defined in class <code>DWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #addListener
+ * 
+ * @since 2.0 
+ */
+public void removeListener (int eventType, Listener listener) {
+    checkDevice ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (eventType, listener);
+}
+
+//void removeMenu (Menu menu) {
+//  if (menus is null) return;
+//  menus [menu.id - ID_START] = null;
+//}
+//
+//void removePopup (Menu menu) {
+//  if (popups is null) return;
+//  for (int i=0; i<popups.length; i++) {
+//      if (popups [i] is menu) {
+//          popups [i] = null;
+//          return;
+//      }
+//  }
+//}
+
+bool runAsyncMessages (bool all) {
+    return synchronizer.runAsyncMessages (all);
+}
+
+bool runDeferredEvents () {
+    /*
+    * Run deferred events.  This code is always
+    * called  in the Display's thread so it must
+    * be re-enterant need not be synchronized.
+    */
+    while (eventQueue !is null) {
+        
+        /* Take an event off the queue */
+        Event event = eventQueue [0];
+        if (event is null) break;
+        int length = eventQueue.length;
+        System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
+        eventQueue [length] = null;
+
+        /* Run the event */
+        Widget widget = event.widget;
+        if (widget !is null && !widget.isDisposed ()) {
+            Widget item = event.item;
+            if (item is null || !item.isDisposed ()) {
+                widget.notifyListeners (event.type, event);
+            }
+        }
+
+        /*
+        * At this point, the event queue could
+        * be null due to a recursive invokation
+        * when running the event.
+        */
+    }
+
+    /* Clear the queue */
+    eventQueue = null;
+    return true;
+}
+
+bool runTimers () {
+    if (timerList is null) return false;
+    bool result = false;
+    for (int i=0; i<timerList.length; i++) {
+        if (nsTimers [i] is null && timerList [i] !is null) {
+            Runnable runnable = timerList [i];
+            timerList [i] = null;
+            if (runnable !is null) {
+                result = true;
+                runnable.run ();
+            }
+        }
+    }
+    return result;
+}
+
+void sendEvent (int eventType, Event event) {
+    if (eventTable is null && filterTable is null) {
+        return;
+    }
+    if (event is null) event = new Event ();
+    event.display = this;
+    event.type = eventType;
+    if (event.time is 0) event.time = getLastEventTime ();
+    if (!filterEvent (event)) {
+        if (eventTable !is null) eventTable.sendEvent (event);
+    }
+}
+
+/**
+ * On platforms which support it, sets the application name
+ * to be the argument. On Motif, for example, this can be used
+ * to set the name used for resource lookup.  Specifying
+ * <code>null</code> for the name clears it.
+ *
+ * @param name the new app name or <code>null</code>
+ */
+public static void setAppName (String name) {
+    APP_NAME = name;
+}
+
+//TODO - use custom timer instead of timerExec
+Runnable caretTimer = new Runnable () {
+    public void run () {
+        if (currentCaret !is null) {
+            if (currentCaret is null || currentCaret.isDisposed()) return;
+            if (currentCaret.blinkCaret ()) {
+                int blinkRate = currentCaret.blinkRate;
+                if (blinkRate !is 0) timerExec (blinkRate, this);
+            } else {
+                currentCaret = null;
+            }
+        }
+        
+    }
+};
+void setCurrentCaret (Caret caret) {
+//  if (caretID !is 0) OS.RemoveEventLoopTimer (caretID);
+//  caretID = 0;
+    currentCaret = caret;
+    if (currentCaret !is null) {
+        int blinkRate = currentCaret.blinkRate;
+        timerExec (blinkRate, caretTimer);
+    }
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen.  <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param x the new x coordinate for the cursor
+ * @param y the new y coordinate for the cursor
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void setCursorLocation (int x, int y) {
+    checkDevice ();
+    CGPoint pt = new CGPoint ();
+    pt.x = x;  pt.y = y;
+    OS.CGWarpMouseCursorPosition (pt);
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen.  <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setCursorLocation (Point point) {
+    checkDevice ();
+    if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setCursorLocation (point.x, point.y);
+}
+
+/**
+ * Sets the application defined property of the receiver
+ * with the specified name to the given argument.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the display is disposed
+ * of, it is the application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @param value the new value for the property
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getData(String)
+ * @see #disposeExec(Runnable)
+ */
+public void setData (String key, Object value) {
+    checkDevice ();
+    if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
+    
+    /* Remove the key/value pair */
+    if (value is null) {
+        if (keys is null) return;
+        int index = 0;
+        while (index < keys.length && !keys [index].equals (key)) index++;
+        if (index is keys.length) return;
+        if (keys.length is 1) {
+            keys = null;
+            values = null;
+        } else {
+            String [] newKeys = new String [keys.length - 1];
+            Object [] newValues = new Object [values.length - 1];
+            System.arraycopy (keys, 0, newKeys, 0, index);
+            System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
+            System.arraycopy (values, 0, newValues, 0, index);
+            System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
+            keys = newKeys;
+            values = newValues;
+        }
+        return;
+    }
+    
+    /* Add the key/value pair */
+    if (keys is null) {
+        keys = new String [] {key};
+        values = new Object [] {value};
+        return;
+    }
+    for (int i=0; i<keys.length; i++) {
+        if (keys [i].equals (key)) {
+            values [i] = value;
+            return;
+        }
+    }
+    String [] newKeys = new String [keys.length + 1];
+    Object [] newValues = new Object [values.length + 1];
+    System.arraycopy (keys, 0, newKeys, 0, keys.length);
+    System.arraycopy (values, 0, newValues, 0, values.length);
+    newKeys [keys.length] = key;
+    newValues [values.length] = value;
+    keys = newKeys;
+    values = newValues;
+}
+
+void setMenuBar (Menu menu) {
+    /*
+    * Feature in the Macintosh.  SetRootMenu() does not
+    * accept NULL to indicate that their should be no
+    * menu bar. The fix is to create a temporary empty
+    * menu, set that to be the menu bar, clear the menu
+    * bar and then delete the temporary menu.
+    */
+    if (menu is menuBar) return;
+    menuBar = menu;
+    //remove all existing menu items except the application menu
+    NSMenu menubar = application.mainMenu();
+    int count = menubar.numberOfItems();
+    while (count > 1) {
+        menubar.removeItemAtIndex(count - 1);
+        count--;
+    }
+    //set parent of each item to NULL and add them to menubar
+    if (menu !is null) {
+        MenuItem[] items = menu.getItems();
+        for (int i = 0; i < items.length; i++) {
+            items[i].nsItem.setMenu(null);
+            menubar.addItem(items[i].nsItem);
+        }
+    }
+}
+
+/**
+ * Sets the application defined, display specific data
+ * associated with the receiver, to the argument.
+ * The <em>display specific data</em> is a single,
+ * unnamed field that is stored with every display. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the display specific data needs to
+ * be notified when the display is disposed of, it is the
+ * application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param data the new display specific data
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getData()
+ * @see #disposeExec(Runnable)
+ */
+public void setData (Object data) {
+    checkDevice ();
+    this.data = data;
+}
+
+/**
+ * Sets the synchronizer used by the display to be
+ * the argument, which can not be null.
+ *
+ * @param synchronizer the new synchronizer for the display (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
+ * </ul>
+ */
+public void setSynchronizer (Synchronizer synchronizer) {
+    checkDevice ();
+    if (synchronizer is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (synchronizer is this.synchronizer) return;
+    Synchronizer oldSynchronizer;
+    synchronized (Device.class) {
+        oldSynchronizer = this.synchronizer;
+        this.synchronizer = synchronizer;
+    }
+    if (oldSynchronizer !is null) {
+        oldSynchronizer.runAsyncMessages(true);
+    }
+}
+
+/**
+ * Causes the user-interface thread to <em>sleep</em> (that is,
+ * to be put in a state where it does not consume CPU cycles)
+ * until an event is received or it is otherwise awakened.
+ *
+ * @return <code>true</code> if an event requiring dispatching was placed on the queue.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #wake
+ */
+public bool sleep () {
+    checkDevice ();
+    if (getMessageCount () !is 0) return true;
+    NSAutoreleasePool pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init();
+    try {
+        allowTimers = runAsyncMessages = false;
+        NSRunLoop.currentRunLoop().runMode(OS.NSDefaultRunLoopMode, NSDate.distantFuture());
+        allowTimers = runAsyncMessages = true;
+        return true;
+    } finally {
+        pool.release();
+    }
+}
+
+int sourceProc (int info) {
+    return 0;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.  Specifying <code>null</code>
+ * as the runnable simply wakes the user-interface thread.
+ * <p>
+ * Note that at the time the runnable is invoked, widgets 
+ * that have the receiver as their display may have been
+ * disposed. Therefore, it is necessary to check for this
+ * case inside the runnable before accessing the widget.
+ * </p>
+ * 
+ * @param runnable code to run on the user-interface thread or <code>null</code>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+public void syncExec (Runnable runnable) {
+    Synchronizer synchronizer;
+    synchronized (Device.class) {
+        if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+        synchronizer = this.synchronizer;
+    }
+    synchronizer.syncExec (runnable);
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread after the specified
+ * number of milliseconds have elapsed. If milliseconds is less
+ * than zero, the runnable is not executed.
+ * <p>
+ * Note that at the time the runnable is invoked, widgets 
+ * that have the receiver as their display may have been
+ * disposed. Therefore, it is necessary to check for this
+ * case inside the runnable before accessing the widget.
+ * </p>
+ *
+ * @param milliseconds the delay before running the runnable
+ * @param runnable code to run on the user-interface thread
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+public void timerExec (int milliseconds, Runnable runnable) {
+    checkDevice ();
+    //TODO - remove a timer, reschedule a timer not tested
+    if (runnable is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (timerList is null) timerList = new Runnable [4];
+    if (nsTimers is null) nsTimers = new NSTimer [4];
+    int index = 0;
+    while (index < timerList.length) {
+        if (timerList [index] is runnable) break;
+        index++;
+    }
+    if (index !is timerList.length) {
+        NSTimer timer = nsTimers [index];
+        if (milliseconds < 0) {
+            timer.invalidate();
+            timerList [index] = null;
+            nsTimers [index] = null;
+        } else {
+            timer.setFireDate(NSDate.dateWithTimeIntervalSinceNow (milliseconds / 1000.0));
+        }
+        return;
+    } 
+    if (milliseconds < 0) return;
+    index = 0;
+    while (index < timerList.length) {
+        if (timerList [index] is null) break;
+        index++;
+    }
+    if (index is timerList.length) {
+        Runnable [] newTimerList = new Runnable [timerList.length + 4];
+        System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
+        timerList = newTimerList;
+        NSTimer [] newTimerIds = new NSTimer [nsTimers.length + 4];
+        System.arraycopy (nsTimers, 0, newTimerIds, 0, nsTimers.length);
+        nsTimers = newTimerIds;
+    }
+    NSNumber userInfo = NSNumber.numberWithInt(index);
+    NSTimer timer = NSTimer.static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(milliseconds / 1000.0, timerDelegate, OS.sel_timerProc_1, userInfo.id, false);
+    timer.retain();
+    if (timer !is null) {
+        nsTimers [index] = timer;
+        timerList [index] = runnable;
+    }
+}
+
+int timerProc (int id) {
+    NSTimer timer = new NSTimer (id);
+    NSNumber number = new NSNumber(timer.userInfo());
+    int index = number.intValue();
+    if (timerList is null) return 0;
+    if (0 <= index && index < timerList.length) {
+        if (allowTimers) {
+            Runnable runnable = timerList [index];
+            timerList [index] = null;
+            nsTimers [index] = null;
+            if (runnable !is null) runnable.run ();
+        } else {
+            nsTimers [index] = null;
+            wakeThread ();
+        }
+    }
+    timer.release();
+    return 0;
+}
+
+/**
+ * Forces all outstanding paint requests for the display
+ * to be processed before this method returns.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Control#update()
+ */
+public void update () {
+    checkDevice (); 
+//  Shell [] shells = getShells ();
+//  for (int i=0; i<shells.length; i++) {
+//      Shell shell = shells [i];
+//      if (!shell.isDisposed ()) shell.update (true);
+//  }
+
+}
+
+/**
+ * If the receiver's user-interface thread was <code>sleep</code>ing, 
+ * causes it to be awakened and start running again. Note that this
+ * method may be called from any thread.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #sleep
+ */
+public void wake () {
+    synchronized (Device.class) {
+        if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
+        if (thread is Thread.currentThread ()) return;
+        wakeThread ();
+    }
+}
+
+void wakeThread () {
+    NSObject object = new NSObject().alloc().init();
+    object.performSelectorOnMainThread_withObject_waitUntilDone_(OS.sel_release, null, false);
+}
+
+int applicationDelegateProc(int id, int sel, int arg0) {
+    if (sel is OS.sel_applicationWillFinishLaunching_1) {
+        id dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner"));
+        NSString nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Resources/English.lproj/DefaultApp.nib");
+        if (!NSBundle.loadNibFile(nibFile, dict, null)) {
+            nibFile = NSString.stringWith("/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Resources/English.lproj/DefaultApp.nib");
+            NSBundle.loadNibFile(nibFile, dict, null);  
+        }
+        //replace %@ with application name
+        NSMenu mainmenu = application.mainMenu();
+        NSMenuItem appitem = mainmenu.itemAtIndex(0);
+        if (appitem !is null) {
+            NSMenu sm = appitem.submenu();
+            NSArray ia = sm.itemArray();
+            for(int i = 0; i < ia.count(); i++) {
+                NSMenuItem ni = new NSMenuItem(ia.objectAtIndex(i));
+                NSString title = ni.title().stringByReplacingOccurrencesOfString_withString_(NSString.stringWith("%@"), NSString.stringWith(APP_NAME));
+                ni.setTitle(title);
+            }
+        }
+    } else if (sel is OS.sel_terminate_1) {
+        application.terminate(application);
+    } else if (sel is OS.sel_orderFrontStandardAboutPanel_1) {
+        Event event = new Event ();
+        sendEvent (DWT.ABORT, event);
+    } else if (sel is OS.sel_hideOtherApplications_1) {
+        application.hideOtherApplications(application);
+    } else if (sel is OS.sel_hide_1) {
+        application.hide(application);
+    } else if (sel is OS.sel_unhideAllApplications_1) {
+        application.unhideAllApplications(application);
+    } else if (sel is OS.sel_applicationShouldTerminate_1) {
+        if (!disposing) {
+            Event event = new Event ();
+            sendEvent (DWT.Close, event);
+            if (event.doit) {
+                return OS.NSTerminateNow;
+            }
+        }
+        return OS.NSTerminateCancel;
+    } else if (sel is OS.sel_applicationWillTerminate_1) {
+        dispose();
+    } 
+    return 0;
+}
+
+
+int dialogProc(int id, int sel, int arg0) {
+    int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return 0;
+    if (sel is OS.sel_changeColor_1) {
+        ColorDialog dialog = (ColorDialog)OS.JNIGetObject(jniRef);
+        if (dialog is null) return 0;
+        dialog.changeColor(arg0);
+    } else if (sel is OS.sel_changeFont_1) {
+        FontDialog dialog = (FontDialog)OS.JNIGetObject(jniRef);
+        if (dialog is null) return 0;
+        dialog.changeFont(arg0);
+    } else if (sel is OS.sel_windowWillClose_1) {
+        Object object = OS.JNIGetObject(jniRef);
+        if (object instanceof FontDialog) {
+            ((FontDialog)object).windowWillClose(arg0);
+        } else if (object instanceof ColorDialog) {
+            ((ColorDialog)object).windowWillClose(arg0);
+        }
+    }
+    return 0;
+}
+
+int windowDelegateProc(int delegate, int sel) {
+    if (sel is OS.sel_tag) {
+        int[] tag = new int[1];
+        OS.object_getInstanceVariable(delegate, "tag", tag);    
+        return tag[0];
+    }
+    int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return 0;
+    Widget widget = (Widget)OS.JNIGetObject(jniRef);
+    if (widget is null) return 0;
+    if (sel is OS.sel_isFlipped) {
+        return widget.isFlipped() ? 1 : 0;
+    }
+    if (sel is OS.sel_sendSelection) {
+        widget.sendSelection();
+        return 0;
+    }
+    if (sel is OS.sel_sendArrowSelection) {
+        widget.sendArrowSelection();
+        return 0;
+    }
+    if (sel is OS.sel_sendDoubleSelection) {
+        widget.sendDoubleSelection();
+        return 0;
+    }
+    if (sel is OS.sel_sendVerticalSelection) {
+        widget.sendVerticalSelection();
+        return 0;
+    }
+    if (sel is OS.sel_sendHorizontalSelection) {
+        widget.sendHorizontalSelection();
+        return 0;
+    }
+    if (sel is OS.sel_acceptsFirstResponder) {
+        return widget.acceptsFirstResponder() ? 1 : 0;
+    }
+    if (sel is OS.sel_becomeFirstResponder) {
+        return widget.becomeFirstResponder() ? 1 : 0;
+    }
+    if (sel is OS.sel_resignFirstResponder) {
+        return widget.resignFirstResponder() ? 1 : 0;
+    }
+    return 0;
+}
+
+int windowDelegateProc(int id, int sel, int arg0) {
+    if (sel is OS.sel_timerProc_1) {
+        return timerProc (arg0);
+    }
+    if (sel is OS.sel_setTag_1) {
+        OS.object_setInstanceVariable(id, "tag", arg0);
+        return 0;
+    }
+    int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return 0;
+    Widget widget = (Widget)OS.JNIGetObject(jniRef);
+    if (widget is null) return 0;
+    if (sel is OS.sel_windowWillClose_1) {
+        widget.windowWillClose(arg0);
+    } else if (sel is OS.sel_drawRect_1) {
+        NSRect rect = new NSRect();
+        OS.memmove(rect, arg0, NSRect.sizeof);
+        widget.drawRect(id, rect);
+    } else if (sel is OS.sel_windowShouldClose_1) {
+        return widget.windowShouldClose(arg0) ? 1 : 0;
+    } else if (sel is OS.sel_mouseDown_1) {
+        widget.mouseDown(arg0);
+    } else if (sel is OS.sel_rightMouseDown_1) {
+        widget.rightMouseDown(arg0);
+    } else if (sel is OS.sel_mouseDragged_1) {
+        widget.mouseDragged(arg0);
+    } else if (sel is OS.sel_mouseUp_1) {
+        widget.mouseUp(arg0);
+    } else if (sel is OS.sel_mouseEntered_1) {
+        widget.mouseEntered(arg0);
+    } else if (sel is OS.sel_flagsChanged_1) {
+        widget.flagsChanged(arg0);
+    } else if (sel is OS.sel_numberOfRowsInTableView_1) {
+        return widget.numberOfRowsInTableView(arg0);
+    } else if (sel is OS.sel_comboBoxSelectionDidChange_1) {
+        widget.comboBoxSelectionDidChange(arg0);
+    } else if (sel is OS.sel_tableViewSelectionDidChange_1) {
+        widget.tableViewSelectionDidChange(arg0);
+    } else if (sel is OS.sel_windowDidResignKey_1) {
+        widget.windowDidResignKey(arg0);
+    } else if (sel is OS.sel_windowDidBecomeKey_1) {
+        widget.windowDidBecomeKey(arg0);
+    } else if (sel is OS.sel_windowDidResize_1) {
+        widget.windowDidResize(arg0);
+    } else if (sel is OS.sel_windowDidMove_1) {
+        widget.windowDidMove(arg0);
+    } else if (sel is OS.sel_menuForEvent_1) {
+        return widget.menuForEvent(arg0);
+    } else if (sel is OS.sel_menuWillOpen_1) {
+        widget.menuWillOpen(arg0);
+    } else if (sel is OS.sel_menuWillClose_1) {
+        widget.menuWillClose(arg0);
+    } else if (sel is OS.sel_menuNeedsUpdate_1) {
+        widget.menuNeedsUpdate(arg0);
+    } else if (sel is OS.sel_outlineViewSelectionDidChange_1) {
+        widget.outlineViewSelectionDidChange(arg0);
+    } else if (sel is OS.sel_sendEvent_1) {
+        widget.windowSendEvent(id, arg0);
+    } else if (sel is OS.sel_helpRequested_1) {
+        widget.helpRequested(arg0);
+    }
+    return 0;
+}
+
+
+int windowDelegateProc(int delegate, int sel, int arg0, int arg1) {
+    int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return 0;
+    Widget widget = (Widget)OS.JNIGetObject(jniRef);
+    if (widget is null) return 0;
+    if (sel is OS.sel_tabView_1willSelectTabViewItem_1) {
+        widget.willSelectTabViewItem(arg0, arg1);
+    } else if (sel is OS.sel_outlineView_1isItemExpandable_1) {
+        return widget.outlineView_isItemExpandable(arg0, arg1) ? 1 : 0;
+    } else if (sel is OS.sel_outlineView_1numberOfChildrenOfItem_1) {
+        return widget.outlineView_numberOfChildrenOfItem(arg0, arg1);
+    } else if (sel is OS.sel_outlineView_1shouldCollapseItem_1) {
+        return widget.outlineView_shouldCollapseItem(arg0, arg1) ? 1 : 0;
+    } else if (sel is OS.sel_outlineView_1shouldExpandItem_1) {
+        return widget.outlineView_shouldExpandItem(arg0, arg1) ? 1 : 0;
+    } else if (sel is OS.sel_menu_1willHighlightItem_1) {
+        widget.menu_willHighlightItem(arg0, arg1);
+    }
+    return 0;
+}
+
+int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2) {
+    int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return 0;
+    Widget widget = (Widget)OS.JNIGetObject(jniRef);
+    if (widget is null) return 0;
+    if (sel is OS.sel_tableView_1objectValueForTableColumn_1row_1) {
+        return widget.tableView_objectValueForTableColumn_row(arg0, arg1, arg2);
+    }
+    if (sel is OS.sel_tableView_1shouldEditTableColumn_1row_1) {
+        return widget.tableView_shouldEditTableColumn_row(arg0, arg1, arg2) ? 1 : 0;
+    } else if (sel is OS.sel_textView_1clickedOnLink_1atIndex_1) {
+         return widget.clickOnLink(arg0, arg1, arg2) ? 1 : 0;
+    } else if (sel is OS.sel_outlineView_1child_1ofItem_1) {
+         return widget.outlineView_child_ofItem(arg0, arg1, arg2);
+    } else if (sel is OS.sel_outlineView_1objectValueForTableColumn_1byItem_1) {
+         return widget.outlineView_objectValueForTableColumn_byItem(arg0, arg1, arg2);
+    }
+    return 0;
+}
+
+int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2, int arg3) {
+    int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return 0;
+    Widget widget = (Widget)OS.JNIGetObject(jniRef);
+    if (widget is null) return 0;
+    if (sel is OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1) {
+        widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, arg3);
+    } else if (sel is OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1) {
+        widget.outlineView_willDisplayCell_forTableColumn_item(arg0, arg1, arg2, arg3);
+    } else  if (sel is OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1) {
+        widget.outlineView_setObjectValue_forTableColumn_byItem(arg0, arg1, arg2, arg3);
+    } else if (sel is OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1) {
+        widget.tableView_setObjectValue_forTableColumn_row(arg0, arg1, arg2, arg3);
+    }
+    return 0;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Event.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Event;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.graphics.GC;
+import dwt.graphics.Rectangle;
+
+/**
+ * Instances of this class provide a description of a particular
+ * event which occurred within DWT. The DWT <em>untyped listener</em>
+ * API uses these instances for all event dispatching.
+ * <p>
+ * Note: For a given event, only the fields which are appropriate
+ * will be filled in. The contents of the fields which are not used
+ * by the event are unspecified.
+ * </p>
+ * 
+ * @see Listener
+ * @see dwt.events.TypedEvent
+ */
+
+public class Event {
+    
+    /**
+     * the display where the event occurred
+     * 
+     * @since 2.0 
+     */ 
+    public Display display;
+        
+    /**
+     * the widget that issued the event
+     */
+    public Widget widget;
+    
+    /**
+     * the type of event, as defined by the event type constants
+     * in class <code>DWT</code>
+     *
+     * @see dwt.DWT
+     */
+    public int type;
+    
+    /**
+     * the event specific detail field, as defined by the detail constants
+     * in class <code>DWT</code>
+     * 
+     * @see dwt.DWT
+     */
+    public int detail;
+    
+    /**
+     * the item that the event occurred in (can be null)
+     */
+    public Widget item;
+    
+    /**
+     * the index of the item where the event occurred
+     * 
+     * @since 3.2
+     */
+    public int index;
+    
+    /**
+     * 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;
+    
+    /**
+     * depending on the event type, the x offset of the bounding
+     * rectangle of the region that requires painting or the
+     * widget-relative, x coordinate of the pointer at the
+     * time the mouse button was pressed or released
+     */
+    public int x;
+    
+    /**
+     * depending on the event type, the y offset of the bounding
+     * rectangle of the  region that requires painting or the
+     * widget-relative, y coordinate of the pointer at the
+     * time the mouse button was pressed or released
+     */
+    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;
+
+    /**
+     * depending on the event type, the number of following
+     * paint events which are pending which may always be zero
+     * on some platforms or the number of lines or pages to
+     * scroll using the mouse wheel
+     */
+    public int count;
+    
+    /**
+     * 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;
+    
+    /**
+     * 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;
+    
+    /**
+     * depending on the event, 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 (ASCII SOH).
+     * 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 char character;
+    
+    /**
+     * depending on the event, the key code of the key that was typed,
+     * as defined by the key code constants in class <code>DWT</code>.
+     * When the character field of the event is ambiguous, this field
+     * contains the unaffected value of the original character.  For
+     * example, typing Ctrl+M or Enter both result in the character '\r'
+     * but the keyCode field will also contain '\r' when Enter was typed
+     * and 'm' when Ctrl+M was typed.
+     * 
+     * @see dwt.DWT
+     */
+    public int keyCode;
+    
+    /**
+     * depending on the event, the state of the keyboard modifier
+     * keys and mouse masks at the time the event was generated.
+     * 
+     * @see dwt.DWT
+     */
+    public int stateMask;
+    
+    /**
+     * depending on the event, the range of text being modified.
+     * Setting these fields has no effect.
+     */
+    public int start, end;
+    
+    /**
+     * depending on the event, the new text that will be inserted.
+     * Setting this field will change the text that is about to
+     * be inserted or deleted.
+     */
+    public String text;
+
+    /**
+     * depending on the event, a flag indicating whether the operation
+     * should be allowed.  Setting this field to false will cancel the
+     * operation.
+     */
+    public bool doit = true;
+    
+    /**
+     * a field for application use
+     */
+    public Object data;
+    
+/**
+ * Gets the bounds.
+ * 
+ * @return a rectangle that is the bounds.
+ */
+public Rectangle getBounds () {
+    return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Sets the bounds.
+ * 
+ * @param rect the new rectangle
+ */
+public void setBounds (Rectangle rect) {
+    this.x = rect.x;
+    this.y = rect.y;
+    this.width = rect.width;
+    this.height = rect.height;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+    return "Event {type=" + type + " " + widget + " time=" + time + " data=" + data + " x=" + x + " y=" + y + " width=" + width + " height=" + height + " detail=" + detail + "}";  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/EventTable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.EventTable;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.internal.DWTEventListener;
+
+/**
+ * Instances of this class implement a simple
+ * look up mechanism that maps an event type
+ * to a listener.  Multiple listeners for the
+ * same event type are supported.
+ */
+
+class EventTable {
+    int [] types;
+    Listener [] listeners;
+    int level;
+    static final int GROW_SIZE = 4;
+    
+public Listener [] getListeners (int eventType) {
+    if (types is null) return new Listener [0];
+    int count = 0;
+    for (int i=0; i<types.length; i++) {
+        if (types [i] is eventType) count++;
+    }
+    if (count is 0) return new Listener [0];
+    Listener [] result = new Listener [count];
+    count = 0;
+    for (int i=0; i<types.length; i++) {
+        if (types [i] is eventType) {
+            result [count++] = listeners [i];
+        }
+    }
+    return result;
+}
+
+public void hook (int eventType, Listener listener) {
+    if (types is null) types = new int [GROW_SIZE];
+    if (listeners is null) listeners = new Listener [GROW_SIZE];
+    int length = types.length, index = length - 1;
+    while (index >= 0) {
+        if (types [index] !is 0) break;
+        --index;
+    }
+    index++;
+    if (index is length) {
+        int [] newTypes = new int [length + GROW_SIZE];
+        System.arraycopy (types, 0, newTypes, 0, length);
+        types = newTypes;
+        Listener [] newListeners = new Listener [length + GROW_SIZE];
+        System.arraycopy (listeners, 0, newListeners, 0, length);
+        listeners = newListeners;
+    }
+    types [index] = eventType;
+    listeners [index] = listener;
+}
+
+public bool hooks (int eventType) {
+    if (types is null) return false;
+    for (int i=0; i<types.length; i++) {
+        if (types [i] is eventType) return true;
+    }
+    return false;
+}
+
+public void sendEvent (Event event) {
+    if (types is null) return;
+    level += level >= 0 ? 1 : -1;
+    try {
+        for (int i=0; i<types.length; i++) {
+            if (event.type is DWT.None) return;
+            if (types [i] is event.type) {
+                Listener listener = listeners [i];
+                if (listener !is null) listener.handleEvent (event);
+            }
+        }
+    } finally {
+        bool compact = level < 0;
+        level -= level >= 0 ? 1 : -1;
+        if (compact && level is 0) {
+            int index = 0;
+            for (int i=0; i<types.length; i++) {
+                if (types [i] !is 0) {
+                    types [index] = types [i];
+                    listeners [index] = listeners [i];
+                    index++;
+                }
+            }
+            for (int i=index; i<types.length; i++) {
+                types [i] = 0;
+                listeners [i] = null;
+            }
+        }
+    }
+}
+
+public int size () {
+    if (types is null) return 0;
+    int count = 0;
+    for (int i=0; i<types.length; i++) {
+        if (types [i] !is 0) count++;
+    }
+    return count;
+}
+
+void remove (int index) {
+    if (level is 0) {
+        int end = types.length - 1;
+        System.arraycopy (types, index + 1, types, index, end - index);
+        System.arraycopy (listeners, index + 1, listeners, index, end - index);
+        index = end;
+    } else {
+        if (level > 0) level = -level;
+    }
+    types [index] = 0;
+    listeners [index] = null;
+}
+
+public void unhook (int eventType, Listener listener) {
+    if (types is null) return;
+    for (int i=0; i<types.length; i++) {
+        if (types [i] is eventType && listeners [i] is listener) {
+            remove (i);
+            return;
+        }
+    }
+}
+
+public void unhook (int eventType, DWTEventListener listener) {
+    if (types is null) return;
+    for (int i=0; i<types.length; i++) {
+        if (types [i] is eventType) {
+            if (listeners [i] instanceof TypedListener) {
+                TypedListener typedListener = (TypedListener) listeners [i];
+                if (typedListener.getEventListener () is listener) {
+                    remove (i);
+                    return;
+                }
+            }
+        }
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ExpandBar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,578 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ExpandBar;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ExpandAdapter;
+import dwt.events.ExpandEvent;
+import dwt.events.ExpandListener;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.FontMetrics;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+
+/**
+ * Instances of this class support the layout of selectable
+ * expand bar items.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>ExpandItem</code>.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>V_SCROLL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Expand, Collapse</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see ExpandItem
+ * @see ExpandEvent
+ * @see ExpandListener
+ * @see ExpandAdapter
+ * 
+ * @since 3.2
+ */
+public class ExpandBar extends Composite {  
+    ExpandItem [] items;
+    int itemCount;
+    ExpandItem focusItem;
+    int spacing;
+    int yCurrentScroll;
+    Font font;
+    Color foreground;
+    Listener listener;
+    bool inDispose;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ExpandBar (Composite parent, int style) {
+    super (parent, checkStyle (style));
+    items = new ExpandItem [4]; 
+
+    listener = new Listener () {
+        public void handleEvent (Event event) {
+            switch (event.type) {
+                case DWT.Dispose:       onDispose (event);          break;
+                case DWT.MouseDown:     onMouseDown (event);        break;
+                case DWT.MouseUp:       onMouseUp (event);          break;
+                case DWT.Paint:         onPaint (event);            break;
+                case DWT.Resize:        onResize ();                break;
+                case DWT.KeyDown:       onKeyDown (event);          break;
+                case DWT.FocusIn:       onFocus ();                 break;
+                case DWT.FocusOut:      onFocus ();                 break;
+                case DWT.Traverse:      onTraverse (event);         break;
+            }
+        }
+    };
+    addListener (DWT.Dispose, listener);
+    addListener (DWT.MouseDown, listener);
+    addListener (DWT.MouseUp, listener);
+    addListener (DWT.Paint, listener);
+    addListener (DWT.Resize, listener);
+    addListener (DWT.KeyDown, listener);
+    addListener (DWT.FocusIn, listener);
+    addListener (DWT.FocusOut, listener);
+    addListener (DWT.Traverse, listener);
+    
+    ScrollBar verticalBar = getVerticalBar ();
+    if (verticalBar !is null) {
+        verticalBar.addListener (DWT.Selection, new Listener () {
+            public void handleEvent (Event event) {
+                onScroll (event);
+            }
+        });
+    }
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>ExpandListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ExpandListener
+ * @see #removeExpandListener
+ */
+public void addExpandListener (ExpandListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Expand, typedListener);
+    addListener (DWT.Collapse, typedListener);
+}
+
+static int checkStyle (int style) {
+    return style & ~DWT.H_SCROLL;
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget ();
+    int height = 0, width = 0;
+    if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) {
+        if (itemCount > 0) {
+            height += spacing;
+            GC gc = new GC (this);
+            for (int i = 0; i < itemCount; i++) {
+                ExpandItem item = items [i];
+                height += item.getHeaderHeight ();
+                if (item.expanded) height += item.height;
+                height += spacing;
+                width = Math.max (width, item.getPreferredWidth (gc));          
+            }
+            gc.dispose ();
+        }
+    }
+    if (width is 0) width = DEFAULT_WIDTH;
+    if (height is 0) height = DEFAULT_HEIGHT;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    Rectangle trim = computeTrim (0, 0, width, height);
+    return new Point (trim.width, trim.height); 
+}
+
+void createItem (ExpandItem item, int style, int index) {
+    if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (itemCount is items.length) {
+        ExpandItem [] newItems = new ExpandItem [itemCount + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    System.arraycopy (items, index, items, index + 1, itemCount - index);
+    items [index] = item;
+    itemCount++;
+    if (focusItem is null) focusItem = item;
+    item.width = Math.max (0, getClientArea ().width - spacing * 2);
+    layoutItems (index, true);
+}
+
+void destroyItem (ExpandItem item) {
+    if (inDispose) return;
+    int index = 0;
+    while (index < itemCount) {
+        if (items [index] is item) break;
+        index++;
+    }
+    if (index is itemCount) return;
+    if (item is focusItem) {
+        int focusIndex = index > 0 ? index - 1 : 1;
+        if (focusIndex < itemCount) {
+            focusItem = items [focusIndex];
+            focusItem.redraw ();
+        } else {
+            focusItem = null;
+        }
+    }
+    System.arraycopy (items, index + 1, items, index, --itemCount - index);
+    items [itemCount] = null;
+    item.redraw ();
+    layoutItems (index, true);
+}
+
+int getBandHeight () {
+    if (font is null) return ExpandItem.CHEVRON_SIZE;
+    GC gc = new GC (this);
+    FontMetrics metrics = gc.getFontMetrics ();
+    gc.dispose ();
+    return Math.max (ExpandItem.CHEVRON_SIZE, metrics.getHeight ());
+}
+
+public Color getForeground () {
+    checkWidget ();
+    if (foreground is null) {
+        Display display = getDisplay ();
+        return display.getSystemColor (DWT.COLOR_TITLE_FOREGROUND);
+    }
+    return foreground;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ExpandItem getItem (int index) {
+    checkWidget ();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);    
+    return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    return itemCount;
+}
+
+/**
+ * Returns an array of <code>ExpandItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ExpandItem [] getItems () {
+    checkWidget ();
+    ExpandItem [] result = new ExpandItem [itemCount];
+    System.arraycopy (items, 0, result, 0, itemCount);
+    return result;
+}
+
+/**
+ * Returns the receiver's spacing.
+ *
+ * @return the spacing
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSpacing () {
+    checkWidget ();
+    return spacing;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (ExpandItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i = 0; i < itemCount; i++) {
+        if (items [i] is item) return i;
+    }
+    return -1;
+}
+
+void layoutItems (int index, bool setScrollbar) {
+    if (index < itemCount) {
+        int y = spacing - yCurrentScroll;
+        for (int i = 0; i < index; i++) {
+            ExpandItem item = items [i];
+            if (item.expanded) y += item.height;
+            y += item.getHeaderHeight() + spacing;
+        }
+        for (int i = index; i < itemCount; i++) {
+            ExpandItem item = items [i];
+            item.setBounds (spacing, y, 0, 0, true, false);
+            if (item.expanded) y += item.height;
+            y += item.getHeaderHeight() + spacing;
+        }
+    }
+    if (setScrollbar) setScrollbar ();
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ExpandListener
+ * @see #addExpandListener
+ */
+public void removeExpandListener (ExpandListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Expand, listener);
+    eventTable.unhook (DWT.Collapse, listener); 
+}
+
+public void setFont(Font font) {
+    super.setFont (font);
+    this.font = font;
+    layoutItems (0, true);
+}
+
+public void setForeground (Color color) {
+    super.setForeground (color);
+    foreground = color;
+}
+
+void setScrollbar () {
+    if (itemCount is 0) return;
+    ScrollBar verticalBar = getVerticalBar ();
+    if (verticalBar is null) return;
+    int height = getClientArea ().height;
+    ExpandItem item = items [itemCount - 1];
+    int maxHeight = item.y + getBandHeight () + spacing;
+    if (item.expanded) maxHeight += item.height;
+
+    //claim bottom free space
+    if (yCurrentScroll > 0 && height > maxHeight) {
+        yCurrentScroll = Math.max (0, yCurrentScroll + maxHeight - height);
+        layoutItems (0, false);
+    }
+    maxHeight += yCurrentScroll;
+    
+    int selection = Math.min (yCurrentScroll, maxHeight);
+    int increment = verticalBar.getIncrement ();
+    int pageIncrement = verticalBar.getPageIncrement ();
+    verticalBar.setValues(selection, 0, maxHeight, height, increment, pageIncrement);
+    verticalBar.setVisible(maxHeight > height);
+}
+
+/**
+ * Sets the receiver's spacing. Spacing specifies the number of pixels allocated around 
+ * each item.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSpacing (int spacing) {
+    checkWidget ();
+    if (spacing < 0) return;
+    if (spacing is this.spacing) return;
+    this.spacing = spacing;
+    int width = Math.max (0, getClientArea ().width - spacing * 2);
+    for (int i = 0; i < itemCount; i++) {
+        ExpandItem item = items[i];
+        if (item.width !is width) item.setBounds (0, 0, width, item.height, false, true);
+    }
+    layoutItems (0, true);
+    redraw ();
+}
+
+void showItem (ExpandItem item) {
+    Control control = item.control;
+    if (control !is null && !control.isDisposed ()) {
+        control.setVisible (item.expanded);
+    }
+    item.redraw ();
+    int index = indexOf (item);
+    layoutItems (index + 1, true);
+}
+
+void onDispose (Event event) {
+    removeListener (DWT.Dispose, listener);
+    notifyListeners (DWT.Dispose, event);
+    event.type = DWT.None;
+    /*
+     * Usually when an item is disposed, destroyItem will change the size of the items array, 
+     * reset the bounds of all the tabs and manage the widget associated with the tab.
+     * Since the whole folder is being disposed, this is not necessary.  For speed
+     * the inDispose flag is used to skip over this part of the item dispose.
+     */
+    inDispose = true;
+    
+    for (int i = 0; i < itemCount; i++) {               
+        items [i].dispose ();
+    }
+    items = null;
+    font = null;
+    foreground = null;
+    focusItem = null;
+}
+
+void onFocus () {
+    if (focusItem !is null) focusItem.redraw ();
+}
+
+void onKeyDown (Event event) {
+    if (focusItem is null) return;
+    switch (event.keyCode) {
+        case 13: /* Return */
+        case 32: /* Space */
+            Event ev = new Event ();
+            ev.item = focusItem;
+            sendEvent (focusItem.expanded ? DWT.Collapse :DWT.Expand, ev);
+            focusItem.expanded = !focusItem.expanded;
+            showItem (focusItem);
+            break;
+        case DWT.ARROW_UP: {
+            int focusIndex = indexOf (focusItem);
+            if (focusIndex > 0) {
+                focusItem.redraw ();
+                focusItem = items [focusIndex - 1];
+                focusItem.redraw ();
+            }
+            break;
+        }
+        case DWT.ARROW_DOWN: {
+            int focusIndex = indexOf (focusItem);
+            if (focusIndex < itemCount - 1) {
+                focusItem.redraw ();
+                focusItem = items [focusIndex + 1];
+                focusItem.redraw ();
+            }
+            break;
+        }
+    }
+}
+
+void onMouseDown (Event event) {
+    if (event.button !is 1) return;
+    int x = event.x;
+    int y = event.y;
+    for (int i = 0; i < itemCount; i++) {
+        ExpandItem item = items[i];
+        bool hover = item.x <= x && x < (item.x + item.width) && item.y <= y && y < (item.y + getBandHeight ()); 
+        if (hover && item !is focusItem) {
+            focusItem.redraw ();
+            focusItem = item;
+            focusItem.redraw ();
+            forceFocus ();
+            break;
+        }
+    }
+}
+
+void onMouseUp (Event event) {
+    if (event.button !is 1) return;
+    if (focusItem is null) return;
+    int x = event.x;
+    int y = event.y;
+    bool hover = focusItem.x <= x && x < (focusItem.x + focusItem.width) && focusItem.y <= y && y < (focusItem.y + getBandHeight ()); 
+    if (hover) {
+        Event ev = new Event ();
+        ev.item = focusItem;
+        notifyListeners (focusItem.expanded ? DWT.Collapse : DWT.Expand, ev);
+        focusItem.expanded = !focusItem.expanded;
+        showItem (focusItem);
+    }
+}
+
+void onPaint (Event event) {
+    bool hasFocus = isFocusControl ();
+    for (int i = 0; i < itemCount; i++) {
+        ExpandItem item = items [i];
+        item.drawItem (event.gc, hasFocus && item is focusItem);
+    }
+}
+
+void onResize () {
+    Rectangle rect = getClientArea ();  
+    int width = Math.max (0, rect.width - spacing * 2);
+    for (int i = 0; i < itemCount; i++) {
+        ExpandItem item = items[i];
+        item.setBounds (0, 0, width, item.height, false, true);
+    }
+    setScrollbar ();
+}
+
+void onScroll (Event event) {
+    ScrollBar verticalBar = getVerticalBar ();
+    if (verticalBar !is null) {
+        yCurrentScroll = verticalBar.getSelection();
+        layoutItems (0, false);
+    }
+}
+
+void onTraverse (Event event) {
+    switch (event.detail) {
+        case DWT.TRAVERSE_TAB_NEXT:
+        case DWT.TRAVERSE_TAB_PREVIOUS:
+            event.doit = true;
+            break;
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ExpandItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,395 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ExpandItem;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a expandable item in a expand bar.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see ExpandBar
+ * 
+ * @since 3.2
+ */
+public class ExpandItem extends Item {
+    ExpandBar parent;
+    Control control;
+    bool expanded;
+    int x, y, width, height;
+    int imageHeight, imageWidth;
+    static final int TEXT_INSET = 6;
+    static final int BORDER = 1;
+    static final int CHEVRON_SIZE = 24;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ExpandItem (ExpandBar parent, int style) {
+    this (parent, style, checkNull (parent).getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent, a
+ * style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ExpandItem (ExpandBar parent, int style, int index) {
+    super (parent, style);
+    this.parent = parent;
+    parent.createItem (this, style, index);
+}
+
+static ExpandBar checkNull (ExpandBar control) {
+    if (control is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    return control; 
+}
+
+public void dispose () {
+    if (isDisposed ()) return;
+    //if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    parent.destroyItem (this);
+    super.dispose();
+    parent = null;
+    control = null;
+}
+
+void drawChevron (GC gc, int x, int y) {
+    int [] polyline1, polyline2;
+    if (expanded) {
+        int px = x + 4 + 5;
+        int py = y + 4 + 7;
+        polyline1 = new int [] {
+                px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3,
+                px+3,py-2, px+4,py-2, px+4,py-1, px+5,py-1, px+5,py, px+6,py};
+        py += 4;
+        polyline2 = new int [] {
+                px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3,
+                px+3,py-2, px+4,py-2, px+4,py-1,  px+5,py-1, px+5,py, px+6,py};
+    } else {
+        int px = x + 4 + 5;
+        int py = y + 4 + 4;
+        polyline1 = new int[] {
+                px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3,
+                px+3,py+2, px+4,py+2, px+4,py+1,  px+5,py+1, px+5,py, px+6,py};
+        py += 4;
+        polyline2 = new int [] {
+                px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3,
+                px+3,py+2, px+4,py+2, px+4,py+1,  px+5,py+1, px+5,py, px+6,py};
+    }
+    gc.setForeground (display.getSystemColor (DWT.COLOR_TITLE_FOREGROUND));
+    gc.drawPolyline (polyline1);
+    gc.drawPolyline (polyline2);
+}
+
+void drawItem (GC gc, bool drawFocus) {
+    int headerHeight = parent.getBandHeight ();
+    Display display = getDisplay ();
+    gc.setForeground (display.getSystemColor (DWT.COLOR_TITLE_BACKGROUND));
+    gc.setBackground (display.getSystemColor (DWT.COLOR_TITLE_BACKGROUND_GRADIENT));
+    gc.fillGradientRectangle (x, y, width, headerHeight, true);
+    if (expanded) {
+        gc.setForeground (display.getSystemColor (DWT.COLOR_TITLE_BACKGROUND_GRADIENT));
+        gc.drawLine (x, y + headerHeight, x, y + headerHeight + height - 1);
+        gc.drawLine (x, y + headerHeight + height - 1, x + width - 1, y + headerHeight + height - 1);
+        gc.drawLine (x + width - 1, y + headerHeight + height - 1, x + width - 1, y + headerHeight);
+    }
+    int drawX = x;
+    if (image !is null) {
+        drawX += ExpandItem.TEXT_INSET;
+        if (imageHeight > headerHeight) {
+            gc.drawImage (image, drawX, y + headerHeight - imageHeight);
+        } else {
+            gc.drawImage (image, drawX, y + (headerHeight - imageHeight) / 2);
+        }
+        drawX += imageWidth;
+    }
+    if (text.length() > 0) {
+        drawX += ExpandItem.TEXT_INSET;
+        Point size = gc.stringExtent (text);
+        gc.setForeground (parent.getForeground ());
+        gc.drawString (text, drawX, y + (headerHeight - size.y) / 2, true);
+    }
+    int chevronSize = ExpandItem.CHEVRON_SIZE;
+    drawChevron (gc, x + width - chevronSize, y + (headerHeight - chevronSize) / 2);
+    if (drawFocus) {
+        gc.drawFocus (x + 1, y + 1, width - 2, headerHeight - 2);
+    }
+}
+
+/**
+ * Returns the control that is shown when the item is expanded.
+ * If no control has been set, return <code>null</code>.
+ *
+ * @return the control
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl() {
+    checkWidget ();
+    return control;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is expanded,
+ * and false otherwise.
+ *
+ * @return the expanded state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getExpanded() {
+    checkWidget ();
+    return expanded;
+}
+
+/**
+ * Returns the height of the receiver's header 
+ *
+ * @return the height of the header 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHeaderHeight () {
+    checkWidget ();
+    return Math.max (parent.getBandHeight (), imageHeight);
+}
+
+/**
+ * Gets the height of the receiver.
+ *
+ * @return the height
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHeight () {
+    checkWidget ();
+    return height;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>ExpandBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ExpandBar getParent () {
+    checkWidget ();
+    return parent;
+}
+
+int getPreferredWidth (GC gc) {
+    int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE;
+    if (image !is null) {
+        width += ExpandItem.TEXT_INSET + imageWidth;
+    }
+    if (text.length() > 0) {
+        width += gc.stringExtent (text).x;
+    }
+    return width;
+}
+
+void redraw () {
+    int headerHeight = parent.getBandHeight ();
+    if (imageHeight > headerHeight) {
+        parent.redraw (x + ExpandItem.TEXT_INSET, y + headerHeight - imageHeight, imageWidth, imageHeight, false);
+    }
+    parent.redraw (x, y, width, headerHeight + height, false);
+}
+
+void setBounds (int x, int y, int width, int height, bool move, bool size) {
+    redraw ();
+    int headerHeight = parent.getBandHeight ();
+    if (move) {
+        if (imageHeight > headerHeight) {
+            y += (imageHeight - headerHeight);
+        }
+        this.x = x;
+        this.y = y;
+        redraw ();
+    }
+    if (size) {
+        this.width = width;
+        this.height = height;
+        redraw ();
+    }
+    if (control !is null && !control.isDisposed ()) {
+        if (move) control.setLocation (x + BORDER, y + headerHeight);
+        if (size) control.setSize (Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
+    }
+}
+
+/**
+ * Sets the control that is shown when the item is expanded.
+ *
+ * @param control the new control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl(Control control) {
+    checkWidget ();
+    if (control !is null) {
+        if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (control.parent !is parent) error (DWT.ERROR_INVALID_PARENT);
+    }
+    this.control = control;
+    if (control !is null) {
+        control.setVisible (expanded);
+        int headerHeight = parent.getBandHeight ();
+        control.setBounds (x + BORDER, y + headerHeight, Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
+    }
+}
+
+/**
+ * Sets the expanded state of the receiver.
+ *
+ * @param expanded the new expanded state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpanded (bool expanded) {
+    checkWidget ();
+    this.expanded = expanded;
+    parent.showItem (this);
+}
+
+public void setImage (Image image) {
+    super.setImage (image);
+    int oldImageHeight = imageHeight;
+    if (image !is null) {
+        Rectangle bounds = image.getBounds ();
+        imageHeight = bounds.height;
+        imageWidth = bounds.width;
+    } else {
+        imageHeight = imageWidth = 0;
+    }
+    if (oldImageHeight !is imageHeight) {
+        parent.layoutItems (parent.indexOf (this), true);
+    } else {
+        redraw ();
+    }
+}
+
+/**
+ * Sets the height of the receiver. This is height of the item when it is expanded, 
+ * excluding the height of the header.
+ *
+ * @param height the new height
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHeight (int height) {
+    checkWidget ();
+    if (height < 0) return;
+    setBounds (0, 0, width, height, false, true);
+    if (expanded) parent.layoutItems (parent.indexOf (this) + 1, true);
+}
+
+public void setText (String string) {
+    super.setText (string);
+    redraw ();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/FileDialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.FileDialog;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSArray;
+import dwt.internal.cocoa.NSOpenPanel;
+import dwt.internal.cocoa.NSSavePanel;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select or enter a file name.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SAVE, OPEN, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SAVE and OPEN may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class FileDialog extends Dialog {
+    String [] filterNames = new String [0];
+    String [] filterExtensions = new String [0];
+    String [] fileNames = new String[0];    
+    String filterPath = "", fileName = "";
+    int filterIndex = -1;
+    bool overwrite = true; //TODO: if setOverwrite(false) is implemented, change default to false for consistency
+    static final char EXTENSION_SEPARATOR = ';';
+
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FileDialog (Shell parent) {
+    this (parent, DWT.APPLICATION_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FileDialog (Shell parent, int style) {
+    super (parent, style);
+    checkSubclass ();
+}
+
+/**
+ * Returns the path of the first file that was
+ * selected in the dialog relative to the filter path, or an
+ * empty string if no such file has been selected.
+ * 
+ * @return the relative path of the file
+ */
+public String getFileName () {
+    return fileName;
+}
+
+/**
+ * Returns a (possibly empty) array with the paths of all files
+ * that were selected in the dialog relative to the filter path.
+ * 
+ * @return the relative paths of the files
+ */
+public String [] getFileNames () {
+    return fileNames;
+}
+
+/**
+ * Returns the file extensions which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file extensions filter
+ */
+public String [] getFilterExtensions () {
+    return filterExtensions;
+}
+
+/**
+ * Get the 0-based index of the file extension filter
+ * which was selected by the user, or -1 if no filter
+ * was selected.
+ * <p>
+ * This is an index into the FilterExtensions array and
+ * the FilterNames array.
+ * </p>
+ *
+ * @return index the file extension filter index
+ * 
+ * @see #getFilterExtensions
+ * @see #getFilterNames
+ * 
+ * @since 3.4
+ */
+public int getFilterIndex () {
+    return filterIndex;
+}
+
+/**
+ * Returns the names that describe the filter extensions
+ * which the dialog will use to filter the files it shows.
+ *
+ * @return the list of filter names
+ */
+public String [] getFilterNames () {
+    return filterNames;
+}
+
+/**
+ * Returns the directory path that the dialog will use, or an empty
+ * string if this is not set.  File names in this path will appear
+ * in the dialog, filtered according to the filter extensions.
+ *
+ * @return the directory path string
+ * 
+ * @see #setFilterExtensions
+ */
+public String getFilterPath () {
+    return filterPath;
+}
+
+/**
+ * Returns the flag that the dialog will use to
+ * determine whether to prompt the user for file
+ * overwrite if the selected file already exists.
+ *
+ * @return true if the dialog will prompt for file overwrite, false otherwise
+ * 
+ * @since 3.4
+ */
+public bool getOverwrite () {
+    return overwrite;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the first selected file,
+ *         or null if the dialog was cancelled or an error occurred
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public String open () {
+    String fullPath = null;
+    fileNames = new String [0];
+    NSSavePanel panel;
+    if ((style & DWT.SAVE) !is 0) {
+        NSSavePanel savePanel = NSSavePanel.savePanel();
+        panel = savePanel;
+    } else {
+        NSOpenPanel openPanel = NSOpenPanel.openPanel();
+        openPanel.setAllowsMultipleSelection((style & DWT.MULTI) !is 0);
+        panel = openPanel;
+    }
+    if (filterPath !is null) panel.setDirectory(NSString.stringWith(filterPath));
+    panel.setTitle(NSString.stringWith(title !is null ? title : ""));
+    int response = panel.runModal();
+    if (response is OS.NSFileHandlingPanelOKButton) {
+        NSString filename = panel.filename();
+        char[] buffer = new char[filename.length()];
+        filename.getCharacters_(buffer);
+        fullPath = new String(buffer);
+        if ((style & DWT.SAVE) is 0) {
+            NSArray filenames = ((NSOpenPanel)panel).filenames();
+            int count = filenames.count();
+            fileNames = new String[count];
+            for (int i = 0; i < count; i++) {
+                filename = new NSString(filenames.objectAtIndex(i));
+                buffer = new char[filename.length()];
+                filename.getCharacters_(buffer);
+                fileNames[i] = new String(buffer);
+            }
+        }
+        filterIndex = -1;
+    }
+    return fullPath;    
+}
+
+/**
+ * Set the initial filename which the dialog will
+ * select by default when opened to the argument,
+ * which may be null.  The name will be prefixed with
+ * the filter path when one is supplied.
+ * 
+ * @param string the file name
+ */
+public void setFileName (String string) {
+    fileName = string;
+}
+
+/**
+ * Set the file extensions which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ * <p>
+ * The strings are platform specific. For example, on
+ * Windows, an extension filter string is typically of
+ * the form "*.extension", where "*.*" matches all files.
+ * </p>
+ *
+ * @param extensions the file extension filter
+ * 
+ * @see #setFilterNames to specify the user-friendly
+ * names corresponding to the extensions
+ */
+public void setFilterExtensions (String [] extensions) {
+    filterExtensions = extensions;
+}
+
+/**
+ * Set the 0-based index of the file extension filter
+ * which the dialog will use initially to filter the files
+ * it shows to the argument.
+ * <p>
+ * This is an index into the FilterExtensions array and
+ * the FilterNames array.
+ * </p>
+ *
+ * @param index the file extension filter index
+ * 
+ * @see #setFilterExtensions
+ * @see #setFilterNames
+ * 
+ * @since 3.4
+ */
+public void setFilterIndex (int index) {
+    filterIndex = index;
+}
+
+/**
+ * Sets the the names that describe the filter extensions
+ * which the dialog will use to filter the files it shows
+ * to the argument, which may be null.
+ * <p>
+ * Each name is a user-friendly short description shown for
+ * its corresponding filter. The <code>names</code> array must
+ * be the same length as the <code>extensions</code> array.
+ * </p>
+ *
+ * @param names the list of filter names, or null for no filter names
+ * 
+ * @see #setFilterExtensions
+ */
+public void setFilterNames (String [] names) {
+    filterNames = names;
+}
+
+/**
+ * Sets the directory path that the dialog will use
+ * to the argument, which may be null. File names in this
+ * path will appear in the dialog, filtered according
+ * to the filter extensions. If the string is null,
+ * then the operating system's default filter path
+ * will be used.
+ * <p>
+ * Note that the path string is platform dependent.
+ * For convenience, either '/' or '\' can be used
+ * as a path separator.
+ * </p>
+ *
+ * @param string the directory path
+ * 
+ * @see #setFilterExtensions
+ */
+public void setFilterPath (String string) {
+    filterPath = string;
+}
+
+/**
+ * Sets the flag that the dialog will use to
+ * determine whether to prompt the user for file
+ * overwrite if the selected file already exists.
+ *
+ * @param overwrite true if the dialog will prompt for file overwrite, false otherwise
+ * 
+ * @since 3.4
+ */
+public void setOverwrite (bool overwrite) {
+    //TODO: May be able to implement this with private NSSavePanel method (BOOL)_overwriteExistingFileCheck:(NSString *)filename
+    /* See bug 223703 */
+    //this.overwrite = overwrite;
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/FontDialog.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.FontDialog;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Font;
+import dwt.graphics.FontData;
+import dwt.graphics.PaletteData;
+import dwt.graphics.RGB;
+import dwt.internal.cocoa.NSApplication;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSFontManager;
+import dwt.internal.cocoa.NSFontPanel;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTPanelDelegate;
+
+/**
+ * Instances of this class allow the user to select a font
+ * from all available fonts in the system.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class FontDialog extends Dialog {
+    FontData fontData;
+    RGB rgb;
+    bool open;
+    int fontID, fontSize;
+
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FontDialog (Shell parent) {
+    this (parent, DWT.APPLICATION_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FontDialog (Shell parent, int style) {
+    super (parent, style);
+    checkSubclass ();
+}
+
+void changeFont(int arg0) {
+}
+
+/**
+ * Returns a FontData object describing the font that was
+ * selected in the dialog, or null if none is available.
+ * 
+ * @return the FontData for the selected font, or null
+ * @deprecated use #getFontList ()
+ */
+public FontData getFontData () {
+    return fontData;
+}
+
+/**
+ * Returns a FontData set describing the font that was
+ * selected in the dialog, or null if none is available.
+ * 
+ * @return the FontData for the selected font, or null
+ * @since 2.1.1
+ */
+public FontData [] getFontList () {
+    if (fontData is null) return null;
+    FontData [] result = new FontData [1];
+    result [0] = fontData;
+    return result;
+}
+
+/**
+ * Returns an RGB describing the color that was selected
+ * in the dialog, or null if none is available.
+ *
+ * @return the RGB value for the selected color, or null
+ *
+ * @see PaletteData#getRGBs
+ * 
+ * @since 2.1
+ */
+public RGB getRGB () {
+    return rgb;
+}
+
+//int fontProc (int nextHandler, int theEvent, int userData) {
+//  int kind = OS.GetEventKind (theEvent);
+//  switch (kind) {
+//      case OS.kEventFontPanelClosed:
+//          open = false;
+//          break;
+//      case OS.kEventFontSelection:
+//          int [] fontID = new int [1];
+//          if (OS.GetEventParameter (theEvent, OS.kEventParamATSUFontID, OS.typeUInt32, null, 4, null, fontID) is OS.noErr) {
+//              this.fontID = fontID [0];
+//          }
+//          int [] fontSize = new int [1];
+//          if (OS.GetEventParameter (theEvent, OS.kEventParamATSUFontSize, OS.typeFixed, null, 4, null, fontSize) is OS.noErr) {
+//              this.fontSize = fontSize [0];
+//          }
+//          RGBColor color = new RGBColor ();
+//          int [] actualSize = new int [1];
+//          if (OS.GetEventParameter (theEvent, OS.kEventParamFontColor, OS.typeRGBColor, null, RGBColor.sizeof, actualSize, color) is OS.noErr) {
+//              int red = (color.red >> 8) & 0xFF;
+//              int green = (color.green >> 8) & 0xFF;
+//              int blue =  (color.blue >> 8) & 0xFF;
+//              rgb = new RGB (red, green, blue);
+//          } else {
+//              int [] dict = new int [1];
+//              if (OS.GetEventParameter (theEvent, OS.kEventParamDictionary, OS.typeCFDictionaryRef, null, 4, actualSize, dict) is OS.noErr) {
+//                  int [] attrib = new int [1];
+//                  if (OS.CFDictionaryGetValueIfPresent (dict [0], OS.kFontPanelAttributesKey (), attrib)) {
+//                      int [] tags = new int [1];
+//                      int [] sizes = new int [1];
+//                      int [] values = new int [1];
+//                      if (OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeTagsKey (), tags) &&
+//                          OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeSizesKey (), sizes) &&
+//                          OS.CFDictionaryGetValueIfPresent (attrib [0], OS.kFontPanelAttributeValuesKey (), values)
+//                      ) {
+//                          int count = OS.CFDataGetLength (tags [0]) / 4;
+//                          int tagPtr = OS.CFDataGetBytePtr (tags[0]);
+//                            int sizePtr = OS.CFDataGetBytePtr (sizes [0]);
+//                            int [] tag = new int [1];
+//                            int [] size = new int [1];
+//                            int valueOffset = 0;
+//                            for (int i = 0 ; i < count ; i++) {
+//                              OS.memmove (tag, tagPtr + (i * 4), 4);
+//                              OS.memmove (size, sizePtr + (i * 4), 4);
+//                                if (tag [0] is OS.kATSUColorTag && size[0] is RGBColor.sizeof) {
+//                                    int valuePtr = OS.CFDataGetBytePtr (values [0]);
+//                                  OS.memmove (color, valuePtr + valueOffset, RGBColor.sizeof);
+//                                  int red = (color.red >> 8) & 0xFF;
+//                                  int green = (color.green >> 8) & 0xFF;
+//                                  int blue =  (color.blue >> 8) & 0xFF;
+//                                  rgb = new RGB (red, green, blue);
+//                                    break ;
+//                                }
+//                                valueOffset = size[0];
+//                            }
+//                      }
+//                  }
+//              }
+//          }
+//          break;
+//  }
+//  return OS.noErr;
+//}
+    
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a FontData object describing the font that was selected,
+ *         or null if the dialog was cancelled or an error occurred
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public FontData open () {
+    Display display = parent !is null ? parent.display : Display.getCurrent ();
+    
+    NSFontPanel panel = NSFontPanel.sharedFontPanel();
+    panel.setTitle(NSString.stringWith(title !is null ? title : ""));
+    if (fontData !is null) {
+        Font font = new Font(display, fontData);
+        NSFontManager.sharedFontManager().setSelectedFont(font.handle, false);
+        font.dispose();
+    }
+    SWTPanelDelegate delegate = (SWTPanelDelegate)new SWTPanelDelegate().alloc().init();
+    int jniRef = OS.NewGlobalRef(this);
+    if (jniRef is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    delegate.setTag(jniRef);
+    panel.setDelegate(delegate);
+    fontData = null;
+    panel.orderFront(null);
+    NSApplication.sharedApplication().runModalForWindow_(panel);
+    panel.setDelegate(null);
+    delegate.release();
+    OS.DeleteGlobalRef(jniRef);
+    NSFont font = NSFontManager.sharedFontManager().selectedFont();
+    if (font !is null) {
+        //TODO - this does work
+        fontData = Font.cocoa_new(display, font).getFontData()[0];
+    }
+    return fontData;
+}
+
+/**
+ * Sets a FontData object describing the font to be
+ * selected by default in the dialog, or null to let
+ * the platform choose one.
+ * 
+ * @param fontData the FontData to use initially, or null
+ * @deprecated use #setFontList (FontData [])
+ */
+public void setFontData (FontData fontData) {
+    this.fontData = fontData;
+}
+
+/**
+ * Sets the set of FontData objects describing the font to
+ * be selected by default in the dialog, or null to let
+ * the platform choose one.
+ * 
+ * @param fontData the set of FontData objects to use initially, or null
+ *        to let the platform select a default when open() is called
+ *
+ * @see Font#getFontData
+ * 
+ * @since 2.1.1
+ */
+public void setFontList (FontData [] fontData) {
+    if (fontData !is null && fontData.length > 0) {
+        this.fontData = fontData [0];
+    } else {
+        this.fontData = null;
+    }
+}
+
+/**
+ * Sets the RGB describing the color to be selected by default
+ * in the dialog, or null to let the platform choose one.
+ *
+ * @param rgb the RGB value to use initially, or null to let
+ *        the platform select a default when open() is called
+ *
+ * @see PaletteData#getRGBs
+ * 
+ * @since 2.1
+ */
+public void setRGB (RGB rgb) {
+    this.rgb = rgb;
+}
+
+void windowWillClose(int sender) {
+    NSApplication.sharedApplication().stop(null);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Group.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Group;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSBox;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.SWTBox;
+import dwt.internal.cocoa.SWTView;
+
+/**
+ * Instances of this class provide an etched border
+ * with an optional title.
+ * <p>
+ * Shadow styles are hints and may not be honoured
+ * by the platform.  To create a group with the
+ * default shadow style for the platform, do not
+ * specify a shadow style.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Group extends Composite {
+    SWTView contentView;
+    String text = "";
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#SHADOW_ETCHED_IN
+ * @see DWT#SHADOW_ETCHED_OUT
+ * @see DWT#SHADOW_IN
+ * @see DWT#SHADOW_OUT
+ * @see DWT#SHADOW_NONE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Group (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+    style |= DWT.NO_FOCUS;
+    /*
+    * Even though it is legal to create this widget
+    * with scroll bars, they serve no useful purpose
+    * because they do not automatically scroll the
+    * widget's client area.  The fix is to clear
+    * the DWT style.
+    */
+    return style & ~(DWT.H_SCROLL | DWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+    checkWidget ();
+    NSBox widget = (NSBox)view;
+    NSSize margins = widget.contentViewMargins();
+    NSRect frame = contentView.frame();
+    width += margins.width * 2;
+    height += margins.height * 2 + frame.y;
+    return super.computeTrim(x, y, width, height);
+}
+
+NSView contentView () {
+    return contentView;
+}
+
+void createHandle () {
+    SWTBox widget = (SWTBox)new SWTBox().alloc();
+    widget.initWithFrame(new NSRect());
+    widget.setTitle(NSString.stringWith(""));
+    widget.setTag(jniRef);
+    SWTView contentWidget = (SWTView)new SWTView().alloc();
+    contentWidget.initWithFrame(new NSRect());
+    contentWidget.setTag(jniRef);
+//  contentWidget.setDrawsBackground(false);
+    widget.setContentView(contentWidget);
+    contentView = contentWidget;
+    view = widget;  
+    parent.contentView().addSubview_(widget);
+}
+
+public Rectangle getClientArea () {
+    checkWidget();
+    NSRect rect = contentView.bounds();
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+String getNameText () {
+    return getText ();
+}
+
+/**
+ * Returns the receiver's text, which is the string that the
+ * is used as the <em>title</em>. If the text has not previously
+ * been set, returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget ();
+    return text;
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (contentView !is null) {
+        contentView.setTag(-1);
+        contentView.release();
+    }
+    contentView = null;
+}
+
+/**
+ * Sets the receiver's text, which is the string that will
+ * be displayed as the receiver's <em>title</em>, to the argument,
+ * which may not be null. The string may include the mnemonic character.
+ * </p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, focus is assigned
+ * to the first child of the group. On most platforms, the
+ * mnemonic appears underlined but may be emphasised in a
+ * platform specific manner.  The mnemonic indicator character
+ * '&amp;' can be escaped by doubling it in the string, causing
+ * a single '&amp;' to be displayed.
+ * </p>
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    text = string;
+    char [] buffer = new char [text.length ()];
+    text.getChars (0, buffer.length, buffer, 0);
+    int length = fixMnemonic (buffer);
+    ((NSBox)view).setTitle(NSString.stringWithCharacters(buffer, length));
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/IME.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+module dwt.widgets.IME;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.graphics.TextStyle;
+
+public class IME extends Widget {
+    Canvas parent;
+    int caretOffset;
+    int startOffset;
+    int commitCount;
+    String text;
+    int [] ranges;
+    TextStyle [] styles;
+    
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+IME () {
+}
+
+/**
+ * 
+ * @see DWT
+ */
+public IME (Canvas parent, int style) {
+    super (parent, style);
+    this.parent = parent;
+    createWidget ();
+}
+
+void createWidget () {
+    text = "";
+    startOffset = -1;
+    if (parent.getIME () is null) {
+        parent.setIME (this);
+    }
+}
+
+public int getCaretOffset () {
+    checkWidget ();
+    return startOffset + caretOffset;
+}
+
+public int getCommitCount () {
+    checkWidget ();
+    return commitCount;
+}
+
+public int getCompositionOffset () {
+    checkWidget ();
+    return startOffset;
+}
+
+public int [] getRanges () {
+    checkWidget ();
+    return ranges !is null ? ranges : new int [0];
+}
+
+public TextStyle [] getStyles () {
+    checkWidget ();
+    return styles !is null ? styles : new TextStyle [0];
+}
+
+public String getText () {
+    checkWidget ();
+    return text;
+}
+
+public bool getWideCaret() {
+    return false; 
+}
+
+void releaseParent () {
+    super.releaseParent ();
+    if (this is parent.getIME ()) parent.setIME (null);
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    parent = null;
+    text = null;
+    styles = null;
+    ranges = null;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Item.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Item;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Image;
+
+/**
+ * This class is the abstract superclass of all non-windowed
+ * user interface objects that occur within specific controls.
+ * For example, a tree will contain tree items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ */
+
+public abstract class Item extends Widget {
+    String text;
+    Image image;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of item to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#getStyle
+ */
+public Item (Widget parent, int style) {
+    super (parent, style);
+    text = "";
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance,
+ * and the index at which to place it in the items maintained
+ * by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of item to construct
+ * @param index the zero-relative index at which to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#getStyle
+ */
+public Item (Widget parent, int style, int index) {
+    this (parent, style);
+}
+
+protected void checkSubclass () {
+    /* Do Nothing - Subclassing is allowed */
+}
+
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+    checkWidget ();
+    return image;
+}
+
+String getNameText () {
+    return getText ();
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget();
+    return text;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    text = null;
+    image = null;
+}
+
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+    checkWidget ();
+    if (image !is null && image.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    this.image = image;
+}
+
+/**
+ * Sets the receiver's text.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    text = string;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Label.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,393 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Label;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSBox;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSImageView;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextField;
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTBox;
+import dwt.internal.cocoa.SWTImageView;
+import dwt.internal.cocoa.SWTTextField;
+
+/**
+ * Instances of this class represent a non-selectable
+ * user interface object that displays a string or image.
+ * When SEPARATOR is specified, displays a single
+ * vertical or horizontal line.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd>
+ * <dd>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of SHADOW_IN, SHADOW_OUT and SHADOW_NONE may be specified.
+ * SHADOW_NONE is a HINT. Only one of HORIZONTAL and VERTICAL may be specified.
+ * Only one of CENTER, LEFT and RIGHT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class Label extends Control {
+    String text = "";
+    Image image;
+    bool isImage;
+    NSTextField textView;
+    NSImageView imageView;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#SEPARATOR
+ * @see DWT#HORIZONTAL
+ * @see DWT#VERTICAL
+ * @see DWT#SHADOW_IN
+ * @see DWT#SHADOW_OUT
+ * @see DWT#SHADOW_NONE
+ * @see DWT#CENTER
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Label (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+    style |= DWT.NO_FOCUS;
+    if ((style & DWT.SEPARATOR) !is 0) {
+        style = checkBits (style, DWT.VERTICAL, DWT.HORIZONTAL, 0, 0, 0, 0);
+        return checkBits (style, DWT.SHADOW_OUT, DWT.SHADOW_IN, DWT.SHADOW_NONE, 0, 0, 0);
+    } 
+    return checkBits (style, DWT.LEFT, DWT.CENTER, DWT.RIGHT, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = 0, height = 0;
+    if ((style & DWT.SEPARATOR) !is 0) {
+        if ((style & DWT.HORIZONTAL) !is 0) {
+            width = DEFAULT_WIDTH;
+            height = 3;
+        } else {
+            width = 3;
+            height = DEFAULT_HEIGHT;
+        }
+    } else {
+        if (image !is null && isImage) {
+            Rectangle bounds = image.getBounds();
+            width = bounds.width;
+            height = bounds.height;
+        } else {
+            NSRect oldRect = textView.frame();
+            textView.sizeToFit();
+            NSRect newRect = textView.frame();
+            textView.setFrame (oldRect);
+            width = (int)newRect.width;
+            height = (int)newRect.height;
+        }
+    }
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point (width, height);
+}
+
+void createHandle () {
+    SWTBox widget = (SWTBox)new SWTBox().alloc();
+    widget.initWithFrame(new NSRect());
+    widget.setTag(jniRef);
+    widget.setTitle(NSString.stringWith(""));
+    if ((style & DWT.SEPARATOR) !is 0) {
+        widget.setBoxType(OS.NSBoxSeparator);
+    } else {
+        widget.setBorderType(OS.NSNoBorder);
+
+        NSImageView imageWidget = (NSImageView)new SWTImageView().alloc();
+        imageWidget.initWithFrame(new NSRect());
+        imageWidget.setTag(jniRef);
+        
+        SWTTextField textWidget = (SWTTextField)new SWTTextField().alloc();
+        textWidget.initWithFrame(new NSRect());
+        textWidget.setBordered(false);
+        textWidget.setEditable(false);
+        textWidget.setDrawsBackground(false);
+        textWidget.setTag(jniRef);
+        if ((style & DWT.WRAP) !is 0) {
+            NSTextFieldCell cell = new NSTextFieldCell(textWidget.cell());
+            cell.setWraps(true);
+        }
+        
+        widget.addSubview_(imageWidget);
+        widget.addSubview_(textWidget);
+        widget.setContentView(textWidget);
+        
+        imageView = imageWidget;
+        textView = textWidget;
+        _setAlignment();
+    }
+    view = widget;
+    parent.contentView().addSubview_(widget);
+}
+
+NSAttributedString createString() {
+    NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
+    if (foreground !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
+        dict.setObject(color, OS.NSForegroundColorAttributeName());
+    }
+    if (font !is null) {
+        dict.setObject(font.handle, OS.NSFontAttributeName());
+    }
+    char [] chars = new char [text.length ()];
+    text.getChars (0, chars.length, chars, 0);
+    int length = fixMnemonic (chars);
+
+    NSString str = NSString.stringWithCharacters(chars, length);
+    NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict);
+    attribStr.autorelease();
+    return attribStr;
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is a <code>SEPARATOR</code> label, in 
+ * which case, <code>NONE</code> is returned.
+ *
+ * @return the alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+    checkWidget();
+    if ((style & DWT.SEPARATOR) !is 0) return DWT.LEFT;
+    if ((style & DWT.CENTER) !is 0) return DWT.CENTER;
+    if ((style & DWT.RIGHT) !is 0) return DWT.RIGHT;
+    return DWT.LEFT;
+}
+
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+    checkWidget();
+    return image;
+}
+
+String getNameText () {
+    return getText ();
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set or if the receiver is
+ * a <code>SEPARATOR</code> label.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget();
+    if ((style & DWT.SEPARATOR) !is 0) return "";
+    return text;
+}
+
+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.  If the receiver is a <code>SEPARATOR</code>
+ * label, the argument is ignored and the alignment is not changed.
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+    checkWidget();
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    if ((alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER)) is 0) return;
+    style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    _setAlignment();
+}
+
+void setBackground (float [] color) {
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    textView.setDrawsBackground(color !is null);
+    if (color is null) return;
+    NSColor nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    NSTextFieldCell cell = new NSTextFieldCell(textView.cell());
+    cell.setBackgroundColor(nsColor);
+}
+
+void _setAlignment() {
+    if ((style & DWT.RIGHT) !is 0) {
+        textView.setAlignment(OS.NSRightTextAlignment);
+        imageView.setImageAlignment(OS.NSImageAlignRight);
+    }
+    if ((style & DWT.LEFT) !is 0) {
+        textView.setAlignment(OS.NSLeftTextAlignment);
+        imageView.setImageAlignment(OS.NSImageAlignLeft);
+    }
+    if ((style & DWT.CENTER) !is 0) {
+        textView.setAlignment(OS.NSCenterTextAlignment);
+        imageView.setImageAlignment(OS.NSImageAlignCenter);
+    }
+}
+
+int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+    int result = super.setBounds(x, y, width, height, move, resize);
+    if ((result & RESIZED) !is 0) {
+        if (imageView !is null || textView !is null) {
+            NSRect rect = view.bounds();
+            imageView.setFrame(rect);
+            textView.setFrame(rect);
+        }
+    }
+    return result;
+}
+
+void setForeground (float [] color) {
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    NSCell cell = new NSCell(textView.cell());
+    cell.setAttributedStringValue(createString());
+}
+
+bool setTabItemFocus () {
+    return false;
+}
+
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+    checkWidget();
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    if (image !is null && image.isDisposed ()) {
+        error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.image = image;
+    isImage = true;
+    imageView.setImage(image !is null ? image.handle : null);
+    ((NSBox)view).setContentView(imageView);
+}
+
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the widget label.  The label may include
+ * the mnemonic character and line delimiters.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, focus is assigned
+ * to the control that follows the label. On most platforms,
+ * the mnemonic appears underlined but may be emphasised in a
+ * platform specific manner.  The mnemonic indicator character
+ * '&amp;' can be escaped by doubling it in the string, causing
+ * a single '&amp;' to be displayed.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    isImage = false;
+    text = string;
+    NSCell cell = new NSCell(textView.cell());
+    cell.setAttributedStringValue(createString());
+    ((NSBox)view).setContentView(textView);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Layout.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Layout;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.graphics.Point;
+
+/**
+ * A layout controls the position and size
+ * of the children of a composite widget.
+ * This class is the abstract base class for
+ * layouts.
+ * 
+ *  @see Composite#setLayout(Layout)
+ */
+public abstract class Layout {
+
+/**
+ * Computes and returns the size of the specified
+ * composite's client area according to this layout.
+ * <p>
+ * This method computes the size that the client area 
+ * of the composite must be in order to position all 
+ * children at their preferred size inside the
+ * composite according to the layout algorithm
+ * encoded by this layout.
+ * </p>
+ * <p>
+ * When a width or height hint is supplied, it is
+ * used to constrain the result. For example, if a
+ * width hint is provided that is less than the
+ * width of the client area, the layout may choose
+ * to wrap and increase height, clip, overlap, or
+ * otherwise constrain the children.
+ * </p>
+ *
+ * @param composite a composite widget using this layout
+ * @param wHint width (<code>DWT.DEFAULT</code> for preferred size)
+ * @param hHint height (<code>DWT.DEFAULT</code> for preferred size)
+ * @param flushCache <code>true</code> means flush cached layout values
+ * @return a point containing the computed size (width, height)
+ * 
+ * @see #layout
+ * @see Control#getBorderWidth
+ * @see Control#getBounds
+ * @see Control#getSize
+ * @see Control#pack(bool)
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+protected abstract Point computeSize (Composite composite, int wHint, int hHint, bool flushCache);
+
+/**
+ * Instruct the layout to flush any cached values
+ * associated with the control specified in the argument 
+ * <code>control</code>.
+ * 
+ * @param control a control managed by this layout
+ * @return true if the Layout has flushed all cached information associated with control
+ * 
+ * @since 3.1
+ */
+protected bool flushCache (Control control) {
+    return false;
+}
+
+/**
+ * Lays out the children of the specified composite
+ * according to this layout.
+ * <p>
+ * This method positions and sizes the children of a
+ * composite using the layout algorithm encoded by this
+ * layout. Children of the composite are positioned in
+ * the client area of the composite. The position of
+ * the composite is not altered by this method.
+ * </p>
+ * <p>
+ * When the flush cache hint is true, the layout is
+ * instructed to flush any cached values associated
+ * with the children. Typically, a layout will cache
+ * the preferred sizes of the children to avoid the
+ * expense of computing these values each time the
+ * widget is laid out.
+ * </p>
+ * <p>
+ * When layout is triggered explicitly by the programmer
+ * the flush cache hint is true. When layout is triggered
+ * by a resize, either caused by the programmer or by the
+ * user, the hint is false.
+ * </p>
+ *
+ * @param composite a composite widget using this layout
+ * @param flushCache <code>true</code> means flush cached layout values
+ */
+protected abstract void layout (Composite composite, bool flushCache);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Link.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,441 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Link;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScrollView;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextStorage;
+import dwt.internal.cocoa.NSTextView;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTScrollView;
+import dwt.internal.cocoa.SWTTextView;
+
+/**
+ * Instances of this class represent a selectable
+ * user interface object that displays a text with 
+ * links.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @since 3.1
+ */
+public class Link extends Control {
+    NSScrollView scrollView;
+    String text;
+    Point [] offsets;
+    Point selection;
+    String [] ids;
+    int [] mnemonics;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Link (Composite parent, int style) {
+    super (parent, style);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the control is selected by the user.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection, typedListener);
+    addListener (DWT.DefaultSelection, typedListener);
+}
+
+bool clickOnLink(int textView, int link, int charIndex) {
+    NSString str = new NSString (link);
+    char [] buffer = new char [str.length ()];
+    str.getCharacters_ (buffer);
+    Event event = new Event ();
+    event.text = new String (buffer);
+    sendEvent (DWT.Selection, event);
+    return true;
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget ();
+    if (wHint !is DWT.DEFAULT && wHint < 0) wHint = 0;
+    if (hHint !is DWT.DEFAULT && hHint < 0) hHint = 0;
+    int width, height;
+    //TODO wrapping, wHint
+    int borderStyle = hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder;
+    NSSize borderSize = NSScrollView.frameSizeForContentSize(new NSSize(), false, false, borderStyle);
+    NSTextView widget = (NSTextView)view;
+    NSSize size = widget.textStorage().size();
+    width = (int)(size.width + borderSize.width);
+    height = (int)(size.height + borderSize.height);
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    int border = getBorderWidth ();
+    width += border * 2;
+    height += border * 2;
+    return new Point (width, height);
+}
+
+void createHandle () {
+    SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc();
+    scrollWidget.initWithFrame(new NSRect ());
+    scrollWidget.setDrawsBackground(false);
+    scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder);
+    scrollWidget.setTag(jniRef);
+
+    SWTTextView widget = (SWTTextView)new SWTTextView().alloc();
+    widget.initWithFrame(new NSRect());
+    widget.setEditable(false);
+    widget.setDrawsBackground(false);
+    widget.setDelegate(widget);
+    widget.setAutoresizingMask (OS.NSViewWidthSizable | OS.NSViewHeightSizable);
+    widget.setTag(jniRef);
+    widget.textContainer().setLineFragmentPadding(0);
+    
+    scrollView = scrollWidget;
+    view = widget;
+    scrollView.addSubview_(view);
+    scrollView.setDocumentView(view);
+    parent.contentView().addSubview_(scrollView);
+}
+
+void createWidget () {
+    super.createWidget ();
+    text = "";
+}
+
+String getNameText () {
+    return getText ();
+}
+
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget ();
+    return text;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    offsets = null;
+    ids = null;
+    mnemonics = null;
+    text = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection, listener); 
+}
+
+String parse (String string) {
+    int length = string.length ();
+    offsets = new Point [length / 4];
+    ids = new String [length / 4];
+    mnemonics = new int [length / 4 + 1];
+    StringBuffer result = new StringBuffer ();
+    char [] buffer = new char [length];
+    string.getChars (0, string.length (), buffer, 0);
+    int index = 0, state = 0, linkIndex = 0;
+    int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0;
+    while (index < length) {
+        char c = Character.toLowerCase (buffer [index]);
+        switch (state) {
+            case 0: 
+                if (c is '<') {
+                    tagStart = index;
+                    state++;
+                }
+                break;
+            case 1:
+                if (c is 'a') state++;
+                break;
+            case 2:
+                switch (c) {
+                    case 'h':
+                        state = 7;
+                        break;
+                    case '>':
+                        linkStart = index  + 1;
+                        state++;
+                        break;
+                    default:
+                        if (Character.isWhitespace(c)) break;
+                        else state = 13;
+                }
+                break;
+            case 3:
+                if (c is '<') {
+                    endtagStart = index;
+                    state++;
+                }
+                break;
+            case 4:
+                state = c is '/' ? state + 1 : 3;
+                break;
+            case 5:
+                state = c is 'a' ? state + 1 : 3;
+                break;
+            case 6:
+                if (c is '>') {
+                    mnemonics [linkIndex] = parseMnemonics (buffer, start, tagStart, result);
+                    int offset = result.length ();
+                    parseMnemonics (buffer, linkStart, endtagStart, result);
+                    offsets [linkIndex] = new Point (offset, result.length () - 1);
+                    if (ids [linkIndex] is null) {
+                        ids [linkIndex] = new String (buffer, linkStart, endtagStart - linkStart);
+                    }
+                    linkIndex++;
+                    start = tagStart = linkStart = endtagStart = refStart = index + 1;
+                    state = 0;
+                } else {
+                    state = 3;
+                }
+                break;
+            case 7:
+                state = c is 'r' ? state + 1 : 0;
+                break;
+            case 8:
+                state = c is 'e' ? state + 1 : 0;
+                break;
+            case 9:
+                state = c is 'f' ? state + 1 : 0;
+                break;
+            case 10:
+                state = c is '=' ? state + 1 : 0;
+                break;
+            case 11:
+                if (c is '"') {
+                    state++;
+                    refStart = index + 1;
+                } else {
+                    state = 0;
+                }
+                break;
+            case 12:
+                if (c is '"') {
+                    ids[linkIndex] = new String (buffer, refStart, index - refStart);
+                    state = 2;
+                }
+                break;
+            case 13:
+                if (Character.isWhitespace (c)) {
+                    state = 0;
+                } else if (c is '='){
+                    state++;
+                }
+                break;
+            case 14:
+                state = c is '"' ? state + 1 : 0;
+                break;
+            case 15:
+                if (c is '"') state = 2;
+                break;
+            default:
+                state = 0;
+                break;
+        }
+        index++;
+    }
+    if (start < length) {
+        int tmp = parseMnemonics (buffer, start, tagStart, result);
+        int mnemonic = parseMnemonics (buffer, Math.max (tagStart, linkStart), length, result);
+        if (mnemonic is -1) mnemonic = tmp;
+        mnemonics [linkIndex] = mnemonic;
+    } else {
+        mnemonics [linkIndex] = -1;
+    }
+    if (offsets.length !is linkIndex) {
+        Point [] newOffsets = new Point [linkIndex];
+        System.arraycopy (offsets, 0, newOffsets, 0, linkIndex);
+        offsets = newOffsets;
+        String [] newIDs = new String [linkIndex];
+        System.arraycopy (ids, 0, newIDs, 0, linkIndex);
+        ids = newIDs;
+        int [] newMnemonics = new int [linkIndex + 1];
+        System.arraycopy (mnemonics, 0, newMnemonics, 0, linkIndex + 1);
+        mnemonics = newMnemonics;       
+    }
+    return result.toString ();
+}
+
+int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
+    int mnemonic = -1, index = start;
+    while (index < end) {
+        if (buffer [index] is '&') {
+            if (index + 1 < end && buffer [index + 1] is '&') {
+                result.append (buffer [index]);
+                index++;
+            } else {
+                mnemonic = result.length();
+            }
+        } else {
+            result.append (buffer [index]);
+        }
+        index++;
+    }
+    return mnemonic;
+}
+
+/**
+ * Sets the receiver's text.
+ * <p>
+ * The string can contain both regular text and hyperlinks.  A hyperlink
+ * is delimited by an anchor tag, &lt;A&gt; and &lt;/A&gt;.  Within an
+ * anchor, a single HREF attribute is supported.  When a hyperlink is
+ * selected, the text field of the selection event contains either the
+ * text of the hyperlink or the value of its HREF, if one was specified.
+ * In the rare case of identical hyperlinks within the same string, the
+ * HREF tag can be used to distinguish between them.  The string may
+ * include the mnemonic character and line delimiters.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (string.equals (text)) return;
+    text = string;
+    NSTextView widget = (NSTextView)view;
+    widget.setString(NSString.stringWith(parse(string)));
+    NSTextStorage textStorage = widget.textStorage();
+    NSRange range = new NSRange();
+    for (int i = 0; i < offsets.length; i++) {
+        range.location = offsets[i].x;
+        range.length = offsets[i].y - offsets[i].x + 1;
+        textStorage.addAttribute(OS.NSLinkAttributeName(), NSString.stringWith(ids[i]), range);
+    }
+}
+
+NSView topView () {
+    return scrollView;
+}
+
+//int traversalCode (int key, int theEvent) {
+//  if (offsets.length is 0) return 0;
+//  int bits = super.traversalCode (key, theEvent);
+//  if (key is 48 /* Tab */ && theEvent !is 0) {
+//      int [] modifiers = new int [1];
+//      OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+//      bool next = (modifiers [0] & OS.shiftKey) is 0;
+//      if (next && focusIndex < offsets.length - 1) {
+//          return bits & ~ DWT.TRAVERSE_TAB_NEXT;
+//      }
+//      if (!next && focusIndex > 0) {
+//          return bits & ~ DWT.TRAVERSE_TAB_PREVIOUS;
+//      }
+//  }
+//  return bits;
+//}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/List.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1266 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.List;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Color;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSMutableIndexSet;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableColumn;
+import dwt.internal.cocoa.NSTableView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTScrollView;
+import dwt.internal.cocoa.SWTTableView;
+
+/** 
+ * Instances of this class represent a selectable user interface
+ * object that displays a list of strings and issues notification
+ * when a string is selected.  A list may be single or multi select.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class List extends Scrollable {
+    NSTableColumn column;
+    String [] items;
+    int itemCount;
+    bool ignoreSelect;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#SINGLE
+ * @see DWT#MULTI
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public List (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+public void add (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (itemCount is items.length) {
+        String [] newItems = new String [itemCount + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    items [itemCount++] = string;
+    ((NSTableView)view).reloadData();
+    //TODO adjust horizontal scrollbar
+}
+
+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+public void add (String string, int index) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (index !is itemCount) fixSelection (index, true);
+    if (itemCount is items.length) {
+        String [] newItems = new String [itemCount + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+    items [index] = string;
+    ((NSTableView)view).reloadData();
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.SINGLE, DWT.MULTI, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = 0;
+    if (wHint is DWT.DEFAULT) {
+        GC gc = new GC (this);
+        for (int i=0; i<itemCount; i++) {
+            Point extent = gc.stringExtent (items [i]);
+            width = Math.max (width, extent.x);
+        }
+        gc.dispose ();
+//      width += EXTRA_WIDTH;
+    } else {
+        width = wHint;
+    }
+    if (width <= 0) width = DEFAULT_WIDTH;
+    int height = 0;
+    if (hHint is DWT.DEFAULT) {
+        height = itemCount * getItemHeight ();
+    } else {
+        height = hHint;
+    }
+    if (height <= 0) height = DEFAULT_HEIGHT;
+    Rectangle rect = computeTrim (0, 0, width, height);
+    return new Point (rect.width, rect.height);
+}
+
+void createHandle () {
+    SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc();
+    scrollWidget.initWithFrame(new NSRect ());
+    if ((style & DWT.H_SCROLL) !is 0) scrollWidget.setHasHorizontalScroller(true);
+    if ((style & DWT.V_SCROLL) !is 0) scrollWidget.setHasVerticalScroller(true);
+    scrollWidget.setAutohidesScrollers(true);
+    scrollWidget.setBorderType((style & DWT.BORDER) !is 0 ? OS.NSBezelBorder : OS.NSNoBorder);
+    scrollWidget.setTag(jniRef);
+    
+    NSTableView widget = (NSTableView)new SWTTableView().alloc();
+    widget.initWithFrame(new NSRect());
+    widget.setAllowsMultipleSelection((style & DWT.MULTI) !is 0);
+    widget.setDataSource(widget);
+    widget.setHeaderView(null);
+    widget.setDelegate(widget);
+    widget.setDoubleAction(OS.sel_sendDoubleSelection);
+    if (!hasBorder()) widget.setFocusRingType(OS.NSFocusRingTypeNone);
+    widget.setTag(jniRef);
+    
+    column = (NSTableColumn)new NSTableColumn().alloc();
+    column.initWithIdentifier(NSString.stringWith(""));
+    widget.addTableColumn (column);
+    
+    scrollView = scrollWidget;
+    view = widget;
+    scrollView.setDocumentView(widget);
+    parent.contentView().addSubview_(scrollView);
+}
+
+void createWidget () {
+    super.createWidget ();
+    items = new String [4];
+}
+
+Color defaultBackground () {
+    return display.getSystemColor (DWT.COLOR_LIST_BACKGROUND);
+}
+
+Color defaultForeground () {
+    return display.getSystemColor (DWT.COLOR_LIST_FOREGROUND);
+}
+
+/**
+ * Deselects the item at the given zero-relative index in the receiver.
+ * If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+    checkWidget();
+    if (0 <= index && index < itemCount) {
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        widget.deselectRow (index);
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected.  The range of the
+ * indices is inclusive. Indices that are out of range are ignored.
+ *
+ * @param start the start index of the items to deselect
+ * @param end the end index of the items to deselect
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int start, int end) {
+    checkWidget();
+    if (start > end) return;
+    if (end < 0 || start >= itemCount) return;
+    start = Math.max (0, start);
+    end = Math.min (itemCount - 1, end);
+    int length = end - start + 1;
+    if (length <= 0) return;
+    if (start is 0 && end is itemCount - 1) {
+        deselectAll ();
+    } else {
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        for (int i=0; i<length; i++) {
+            widget.deselectRow (i);
+        }
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to deselect
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int [] indices) {
+    checkWidget();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    for (int i=0; i<indices.length; i++) {
+        widget.deselectRow (indices [i]);
+    }
+    ignoreSelect = false;
+}
+
+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselectAll () {
+    checkWidget ();
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.deselectAll(null);
+    ignoreSelect = false;
+}
+
+void fixSelection (int index, bool add) {
+    int [] selection = getSelectionIndices ();
+    if (selection.length is 0) return;
+    int newCount = 0;
+    bool fix = false;
+    for (int i = 0; i < selection.length; i++) {
+        if (!add && selection [i] is index) {
+            fix = true;
+        } else {
+            int newIndex = newCount++;
+            selection [newIndex] = selection [i] + 1;
+            if (selection [newIndex] - 1 >= index) {
+                selection [newIndex] += add ? 1 : -1;
+                fix = true;
+            }
+        }
+    }
+    if (fix) select (selection, newCount, true);
+}
+
+/**
+ * Returns the zero-relative index of the item which currently
+ * has the focus in the receiver, or -1 if no item has focus.
+ *
+ * @return the index of the selected item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getFocusIndex () {
+    checkWidget();
+//  int [] first = new int [1], last = new int [1];
+//  if (OS.GetDataBrowserSelectionAnchor (handle, first, last) !is OS.noErr) return -1;
+//    return first [0] - 1;
+    return -1;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getItem (int index) {
+    checkWidget();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget();
+    return itemCount;
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the list.
+ *
+ * @return the height of one item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+    checkWidget ();
+    return (int)((NSTableView)view).rowHeight();
+}
+
+/**
+ * Returns a (possibly empty) array of <code>String</code>s which
+ * are the items in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String [] getItems () {
+    checkWidget();
+    String [] result = new String [itemCount];
+    System.arraycopy (items, 0, result, 0, itemCount);
+    return result;
+}
+
+/**
+ * Returns an array of <code>String</code>s that are currently
+ * selected in the receiver.  The order of the items is unspecified.
+ * An empty array indicates that no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String [] getSelection () {
+    checkWidget ();
+    NSTableView widget = (NSTableView)view;
+    if (widget.numberOfSelectedRows() is 0) {
+        return new String [0];
+    }
+    NSIndexSet selection = widget.selectedRowIndexes();
+    int count = selection.count();
+    int [] indexBuffer = new int [count];
+    selection.getIndexes(indexBuffer, count, 0);
+    String [] result = new String  [count];
+    for (int i=0; i<count; i++) {
+        result [i] = items [indexBuffer [i]];
+    }
+    return result;
+}
+
+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+    checkWidget ();
+    return ((NSTableView)view).numberOfSelectedRows();
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item or -1
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+    checkWidget();
+    //TODO - check empty selection case
+    return ((NSTableView)view).selectedRow();
+}
+
+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver.  The order of the indices is unspecified.
+ * The array is empty if no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int [] getSelectionIndices () {
+    checkWidget ();
+    NSTableView widget = (NSTableView)view;
+    if (widget.numberOfSelectedRows() is 0) {
+        return new int [0];
+    }
+    NSIndexSet selection = widget.selectedRowIndexes();
+    int count = selection.count();
+    int [] result = new int [count];
+    selection.getIndexes(result, count, 0);
+    return result;
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex () {
+    checkWidget();
+    //TODO - partial item at the top
+    NSRect rect = scrollView.documentVisibleRect();
+    NSPoint point = new NSPoint();
+    point.x = rect.x;
+    point.y = rect.y;
+    return ((NSTableView)view).rowAtPoint(point);
+}
+
+/**
+ * Gets the index of an item.
+ * <p>
+ * The list is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned.  Indexing
+ * is zero based.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String item) {
+    checkWidget();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<itemCount; i++) {
+        if (items [i].equals (item)) return i;
+    }
+    return -1;
+}
+
+/**
+ * Searches the receiver's list starting at the given, 
+ * zero-relative index until an item is found that is equal
+ * to the argument, and returns the index of that item. If
+ * no item is found or the starting index is out of range,
+ * returns -1.
+ *
+ * @param string the search item
+ * @param start the zero-relative index at which to start the search
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string, int start) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=start; i<itemCount; i++) {
+        if (items [i].equals (string)) return i;
+    }
+    return -1;
+}
+
+/**
+ * Returns <code>true</code> if the item is selected,
+ * and <code>false</code> otherwise.  Indices out of
+ * range are ignored.
+ *
+ * @param index the index of the item
+ * @return the selection state of the item at the index
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool isSelected (int index) {
+    checkWidget();
+    //TODO - range check
+    return ((NSTableView)view).isRowSelected(index);
+}
+
+int numberOfRowsInTableView(int aTableView) {
+    return itemCount;
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (column !is null) column.release();
+    column = null;
+}
+
+void releaseWidget () { 
+    super.releaseWidget ();
+    items = null;
+}
+
+/**
+ * Removes the item from the receiver at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int index) {
+    checkWidget();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (index !is itemCount - 1) fixSelection (index, false);
+    System.arraycopy (items, index + 1, items, index, --itemCount - index);
+    items [itemCount] = null;
+    ((NSTableView)view).noteNumberOfRowsChanged();
+}
+
+/**
+ * Removes the items from the receiver which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+    checkWidget();
+    if (start > end) return;
+    if (!(0 <= start && start <= end && end < itemCount)) {
+        error (DWT.ERROR_INVALID_RANGE);
+    }
+    int length = end - start + 1;
+    for (int i=0; i<length; i++) remove (start);
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument, 
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int index = indexOf (string, 0);
+    if (index is -1) error (DWT.ERROR_INVALID_ARGUMENT);
+    remove (index);
+}
+
+/**
+ * Removes the items from the receiver at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int [] indices) {
+    checkWidget ();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (indices.length is 0) return;
+    int [] newIndices = new int [indices.length];
+    System.arraycopy (indices, 0, newIndices, 0, indices.length);
+    sort (newIndices);
+    int start = newIndices [newIndices.length - 1], end = newIndices [0];
+    int count = getItemCount ();
+    if (!(0 <= start && start <= end && end < count)) {
+        error (DWT.ERROR_INVALID_RANGE);
+    }
+    int last = -1;
+    for (int i=0; i<newIndices.length; i++) {
+        int index = newIndices [i];
+        if (index !is last) {
+            remove (index);
+            last = index;
+        }
+    }
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+    checkWidget();
+    items = new String [4];
+    itemCount = 0;
+    ((NSTableView)view).noteNumberOfRowsChanged();
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select (int index) {
+    checkWidget();
+    if (0 <= index && index < itemCount) {
+        NSIndexSet indexes = (NSIndexSet)new NSIndexSet().alloc();
+        indexes.initWithIndex(index);
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        ((NSTableView)view).selectRowIndexes(indexes, true);
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If an item in the given range is not selected, it is selected.
+ * If an item in the given range was already selected, it remains selected.
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see List#setSelection(int,int)
+ */
+public void select (int start, int end) {
+    checkWidget ();
+    if (end < 0 || start > end || ((style & DWT.SINGLE) !is 0 && start !is end)) return;
+    if (itemCount is 0 || start >= itemCount) return;
+    if (start is 0 && end is itemCount - 1) {
+        selectAll ();
+    } else {
+        start = Math.max (0, start);
+        end = Math.min (end, itemCount - 1);
+        int length = end - start + 1;
+        NSIndexSet indexes = (NSIndexSet)new NSIndexSet().alloc();
+        NSRange range = new NSRange();
+        range.location = start;
+        range.length = length;
+        indexes.initWithIndexesInRange(range);
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        widget.selectRowIndexes(indexes, true);
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If the item at a given index is not selected, it is selected.
+ * If the item at a given index was already selected, it remains selected.
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see List#setSelection(int[])
+ */
+public void select (int [] indices) {
+    checkWidget ();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int length = indices.length;
+    if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
+    int count = 0;
+    NSMutableIndexSet indexes = (NSMutableIndexSet)new NSMutableIndexSet().alloc().init();
+    for (int i=0; i<length; i++) {
+        int index = indices [length - i - 1];
+        if (index >= 0 && index < itemCount) {
+            indexes.addIndex (indices [i]);
+            count++;
+        }
+    }
+    if (count > 0) {
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        widget.selectRowIndexes(indexes, true);
+        ignoreSelect = false;
+    }
+}
+
+void select (int [] ids, int count, bool clear) {
+    NSMutableIndexSet indexes = (NSMutableIndexSet)new NSMutableIndexSet().alloc().init();
+    for (int i=0; i<count; i++) indexes.addIndex (ids [i] - 1); //WRONG -1
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.selectRowIndexes(indexes, !clear);
+    ignoreSelect = false;
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+    checkWidget ();
+    if ((style & DWT.SINGLE) !is 0) return;
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.selectAll(null);
+    ignoreSelect = false;
+}
+
+void sendDoubleSelection() {
+    postEvent (DWT.DefaultSelection);   
+}
+
+/**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItem (int index, String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    items [index] = string;
+    ((NSTableView)view).reloadData();
+}
+
+/**
+ * Sets the receiver's items to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItems (String [] items) {
+    checkWidget();
+    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<items.length; i++) {
+        if (items [i] is null) error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    this.items = new String [items.length];
+    System.arraycopy (items, 0, this.items, 0, items.length);
+    itemCount = items.length;
+    ((NSTableView)view).reloadData();
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains selected.
+ * The current selection is first cleared, then the new item is selected.
+ * Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @see List#deselectAll()
+ * @see List#select(int)
+ */
+public void setSelection (int index) {
+    checkWidget();
+    deselectAll ();
+    setSelection (index, false);
+}
+
+void setSelection (int index, bool notify) {
+//  checkWidget();
+    if (0 <= index && index < itemCount) {
+        int [] ids = new int [] {index + 1};
+        select (ids, ids.length, true);
+        showIndex (index);
+        if (notify) postEvent (DWT.Selection);
+    }
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ *
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see List#deselectAll()
+ * @see List#select(int,int)
+ */
+public void setSelection (int start, int end) {
+    checkWidget ();
+    deselectAll ();
+    if (end < 0 || start > end || ((style & DWT.SINGLE) !is 0 && start !is end)) return;
+    if (itemCount is 0 || start >= itemCount) return;
+    start = Math.max (0, start);
+    end = Math.min (end, itemCount - 1);
+    int length = end - start + 1;
+    int [] ids = new int [length];
+    for (int i=0; i<length; i++) ids [i] = end - i + 1;
+    select (ids, length, true);
+    if (ids.length > 0) showIndex (ids [0] - 1);
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ *
+ * @param indices the indices of the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see List#deselectAll()
+ * @see List#select(int[])
+ */
+public void setSelection (int [] indices) {
+    checkWidget ();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    deselectAll ();
+    int length = indices.length;
+    if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
+    int [] ids = new int [length];
+    int count = 0;
+    for (int i=0; i<length; i++) {
+        int index = indices [length - i - 1];
+        if (index >= 0 && index < itemCount) {
+            ids [count++] = index + 1;
+        }
+    }
+    if (count > 0) {
+        select (ids, count, true);
+        showIndex (ids [0] - 1);
+    }
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see List#deselectAll()
+ * @see List#select(int[])
+ * @see List#setSelection(int[])
+ */
+public void setSelection (String [] items) {
+    checkWidget ();
+    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    deselectAll ();
+    int length = items.length;
+    if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
+    int count = 0;
+    int [] ids = new int [length];
+    for (int i=0; i<length; i++) {
+        String string = items [length - i - 1];
+        if ((style & DWT.SINGLE) !is 0) {
+            int index = indexOf (string, 0);
+            if (index !is -1) {
+                count = 1;
+                ids = new int [] {index + 1};
+            }
+        } else {
+            int index = 0;
+            while ((index = indexOf (string, index)) !is -1) {
+                if (count is ids.length) {
+                    int [] newIds = new int [ids.length + 4];
+                    System.arraycopy (ids, 0, newIds, 0, ids.length);
+                    ids = newIds;
+                }
+                ids [count++] = index + 1;
+                index++;
+            }
+        }
+    }
+    if (count > 0) {
+        select (ids, count, true);
+        showIndex (ids [0] - 1);
+    }
+}
+
+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex (int index) {
+    checkWidget();
+    NSRect rect = ((NSTableView)view).rectOfRow(index);
+    ((NSTableView)view).scrollRectToVisible(rect);
+}
+
+void showIndex (int index) {
+    if (0 <= index && index < itemCount) {
+        ((NSTableView)view).scrollRowToVisible(index);
+    }
+}
+
+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void showSelection () {
+    checkWidget();
+    int index = getSelectionIndex ();
+    if (index >= 0) showIndex (index);
+}
+
+void tableViewSelectionDidChange (int aNotification) {
+    if (ignoreSelect) return;
+    postEvent (DWT.Selection);
+}
+
+bool tableView_shouldEditTableColumn_row(int aTableView, int aTableColumn, int rowIndex) {
+    return false;
+}
+
+int tableView_objectValueForTableColumn_row(int aTableView, int aTableColumn, int rowIndex) {
+    NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
+    if (foreground !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
+        dict.setObject(color, OS.NSForegroundColorAttributeName());
+    }
+    if (font !is null) {
+        dict.setObject(font.handle, OS.NSFontAttributeName());
+    }
+    if (background !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(background.handle[0], background.handle[1], background.handle[2], 1);
+        dict.setObject(color, OS.NSBackgroundColorAttributeName());
+    }
+    String text = items[rowIndex];
+    int length = text.length();
+    char[] chars = new char[length];
+    text.getChars(0, length, chars, 0);
+    NSString str = NSString.stringWithCharacters(chars, length);
+    NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict);
+    attribStr.autorelease();
+    return attribStr.id;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Listener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Listener;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * Implementers of <code>Listener</code> provide a simple 
+ * <code>handleEvent()</code> method that is used internally 
+ * by DWT to dispatch events.
+ * <p>
+ * After creating an instance of a class that implements this interface
+ * it can be added to a widget using the 
+ * <code>addListener(int eventType, Listener handler)</code> method and
+ * removed using the 
+ * <code>removeListener (int eventType, Listener handler)</code> method. 
+ * When the specified event occurs, <code>handleEvent(...)</code> will
+ * be sent to the instance.
+ * </p>
+ * <p>
+ * Classes which implement this interface are described within DWT as
+ * providing the <em>untyped listener</em> API. Typically, widgets will
+ * also provide a higher-level <em>typed listener</em> API, that is based
+ * on the standard <code>java.util.EventListener</code> pattern.
+ * </p> 
+ * <p>
+ * Note that, since all internal DWT event dispatching is based on untyped
+ * listeners, it is simple to build subsets of DWT for use on memory 
+ * constrained, small footprint devices, by removing the classes and
+ * methods which implement the typed listener API.
+ * </p>
+ *
+ * @see Widget#addListener
+ * @see java.util.EventListener
+ * @see dwt.events
+ */
+public interface Listener {
+
+/**
+ * Sent when an event that the receiver has registered for occurs.
+ *
+ * @param event the event which occurred
+ */
+void handleEvent (Event event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Menu.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,898 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Menu;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.HelpListener;
+import dwt.events.MenuListener;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTMenu;
+import dwt.internal.cocoa.SWTMenuItem;
+
+/**
+ * Instances of this class are user interface objects that contain
+ * menu items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP</dd>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Help, Hide, Show </dd>
+ * </dl>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Menu extends Widget {
+    /**
+     * the handle to the OS resource 
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    NSMenu nsMenu;
+    short id;
+    int x, y, itemCount;
+//  int width, height;
+    bool hasLocation, modified, closed;
+    MenuItem [] items;
+    MenuItem cascade, defaultItem, lastTarget;
+    Decorations parent;
+
+/**
+ * Constructs a new instance of this class given its parent,
+ * and sets the style for the instance so that the instance
+ * will be a popup menu on the given parent's shell.
+ *
+ * @param parent a control which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#POP_UP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Control parent) {
+    this (checkNull (parent).menuShell (), DWT.POP_UP);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Decorations</code>) and a style value
+ * describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a decorations control which will be the parent of the new instance (cannot be null)
+ * @param style the style of menu to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#BAR
+ * @see DWT#DROP_DOWN
+ * @see DWT#POP_UP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Decorations parent, int style) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    createWidget ();
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>) and sets the style
+ * for the instance so that the instance will be a drop-down
+ * menu on the given parent's parent.
+ *
+ * @param parentMenu a menu which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Menu parentMenu) {
+    this (checkNull (parentMenu).parent, DWT.DROP_DOWN);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>MenuItem</code>) and sets the style
+ * for the instance so that the instance will be a drop-down
+ * menu on the given parent's parent menu.
+ *
+ * @param parentItem a menu item which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (MenuItem parentItem) {
+    this (checkNull (parentItem).parent);
+}
+
+static Control checkNull (Control control) {
+    if (control is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    return control;
+}
+
+static Menu checkNull (Menu menu) {
+    if (menu is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    return menu;
+}
+
+static MenuItem checkNull (MenuItem item) {
+    if (item is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    return item;
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.POP_UP, DWT.BAR, DWT.DROP_DOWN, 0, 0, 0);
+}
+
+void _setVisible (bool visible) {
+    if ((style & (DWT.BAR | DWT.DROP_DOWN)) !is 0) return;
+    if (visible) {
+        Shell shell = getShell ();
+        NSWindow window = shell.window;
+        NSPoint location = null;
+        if (hasLocation) {
+            NSView topView = window.contentView();
+            Point shellCoord = display.map(null, shell, new Point(x,y));
+            location = new NSPoint ();
+            location.x = shellCoord.x;
+            location.y = topView.frame().height - shellCoord.y;
+        } else {
+            location = window.mouseLocationOutsideOfEventStream();
+        }
+        NSEvent nsEvent = NSEvent.otherEventWithType(OS.NSApplicationDefined, location, 0, 0.0, window.windowNumber(), window.graphicsContext(), (short)0, 0, 0);
+        NSMenu.static_popUpContextMenu_withEvent_forView_ (nsMenu, nsEvent, shell.view);
+    } else {
+        nsMenu.cancelTracking ();
+    }
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when help events are generated for the control,
+ * by sending it one of the messages defined in the
+ * <code>HelpListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
+public void addHelpListener (HelpListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Help, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when menus are hidden or shown, by sending it
+ * one of the messages defined in the <code>MenuListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuListener
+ * @see #removeMenuListener
+ */
+public void addMenuListener (MenuListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Hide,typedListener);
+    addListener (DWT.Show,typedListener);
+}
+
+void createHandle () {
+//  display.addMenu (this);
+    SWTMenu widget = (SWTMenu)new SWTMenu().alloc();
+    widget.initWithTitle(NSString.stringWith(""));
+    widget.setAutoenablesItems(false);
+    widget.setTag(jniRef);
+    widget.setDelegate(widget); 
+    nsMenu = widget;    
+}
+
+void createItem (MenuItem item, int index) {
+    checkWidget ();
+    if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    NSMenuItem nsItem = null;
+    if ((item.style & DWT.SEPARATOR) !is 0) {
+        nsItem = NSMenuItem.separatorItem();
+        nsItem.retain();
+    } else {
+        nsItem = (NSMenuItem)new SWTMenuItem().alloc();
+        nsItem.initWithTitle(NSString.stringWith(""), 0, NSString.stringWith(""));
+        nsItem.setTarget(nsItem);
+        nsItem.setAction(OS.sel_sendSelection);
+        item.createJNIRef();
+        nsItem.setTag(item.jniRef);
+    }
+    item.nsItem = nsItem;
+    nsMenu.insertItem(nsItem, index);
+    if (itemCount is items.length) {
+        MenuItem [] newItems = new MenuItem [items.length + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+    items [index] = item;
+    
+    NSMenu emptyMenu = item.createEmptyMenu ();
+    if (emptyMenu !is null) {
+        item.nsItem.setSubmenu (emptyMenu);
+    }
+}
+
+void createWidget () {
+    checkOrientation (parent);
+    super.createWidget ();
+    items = new MenuItem [4];
+}
+
+void destroyItem (MenuItem item) {
+    int index = 0;
+    while (index < itemCount) {
+        if (items [index] is item) break;
+        index++;
+    }
+    if (index is itemCount) return;
+    System.arraycopy (items, index + 1, items, index, --itemCount - index);
+    items [itemCount] = null;
+    if (itemCount is 0) items = new MenuItem [4];
+    nsMenu.removeItem (item.nsItem);
+}
+
+void destroyWidget () {
+    NSMenu nsMenu = this.nsMenu;
+    releaseHandle ();
+    if (nsMenu !is null) {
+        nsMenu.release();
+    }
+}
+
+void fixMenus (Decorations newParent) {
+    this.parent = newParent;
+}
+
+/**
+ * Returns the default menu item or null if none has
+ * been previously set.
+ *
+ * @return the default menu item.
+ *
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem getDefaultItem () {
+    checkWidget();
+    return defaultItem;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled menu is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public bool getEnabled () {
+    checkWidget();
+    return (state & DISABLED) is 0;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem getItem (int index) {
+    checkWidget ();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    return itemCount;
+}
+
+/**
+ * Returns a (possibly empty) array of <code>MenuItem</code>s which
+ * are the items in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem [] getItems () {
+    checkWidget ();
+    MenuItem [] result = new MenuItem [itemCount];
+    int index = 0;
+    if (items !is null) {
+        for (int i = 0; i < itemCount; i++) {
+            MenuItem item = items [i];
+            if (item !is null && !item.isDisposed ()) {
+                result [index++] = item;
+            }
+        }
+    }
+    if (index !is result.length) {
+        MenuItem [] newItems = new MenuItem[index];
+        System.arraycopy(result, 0, newItems, 0, index);
+        result = newItems;
+    }
+    return result;
+}
+
+String getNameText () {
+    String result = "";
+    MenuItem [] items = getItems ();
+    int length = items.length;
+    if (length > 0) {
+        for (int i=0; i<length-1; i++) {
+            result = result + items [i].getNameText() + ", ";
+        }
+        result = result + items [length-1].getNameText ();
+    }
+    return result;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Decorations</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Decorations getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>MenuItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem getParentItem () {
+    checkWidget ();
+    return cascade;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>Menu</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getParentMenu () {
+    checkWidget ();
+    if (cascade !is null) return cascade.parent;
+    return null;
+}
+
+/**
+ * Returns the receiver's shell. For all controls other than
+ * shells, this simply returns the control's nearest ancestor
+ * shell. Shells return themselves, even if they are children
+ * of other shells.
+ *
+ * @return the receiver's shell
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getParent
+ */
+public Shell getShell () {
+    checkWidget ();
+    return parent.getShell ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getVisible () {
+    checkWidget ();
+    if ((style & DWT.BAR) !is 0) {
+        return this is parent.menuShell ().menuBar;
+    }
+    if ((style & DWT.POP_UP) !is 0) {
+//      Menu [] popups = display.popups;
+//      if (popups is null) return false;
+//      for (int i=0; i<popups.length; i++) {
+//          if (popups [i] is this) return true;
+//      }
+    }
+//  MenuTrackingData outData = new MenuTrackingData ();
+//  return OS.GetMenuTrackingData (handle, outData) is OS.noErr;
+    return false;
+}
+
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (MenuItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<itemCount; i++) {
+        if (items [i] is item) return i;
+    }
+    return -1;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled menu is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public bool isEnabled () {
+    checkWidget ();
+    Menu parentMenu = getParentMenu ();
+    if (parentMenu is null) {
+        return getEnabled () && parent.isEnabled ();
+    }
+    return getEnabled () && parentMenu.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public bool isVisible () {
+    checkWidget ();
+    return getVisible ();
+}
+
+void menu_willHighlightItem(int menu, int itemID) {
+    int jniRef = OS.objc_msgSend(itemID, OS.sel_tag);
+    if (jniRef !is -1 && jniRef !is 0) {
+        Object object = OS.JNIGetObject(jniRef);
+        if (object instanceof MenuItem) {
+            MenuItem item = (MenuItem)object;
+            item.sendEvent (DWT.Arm);
+        }
+    }
+}
+
+void menuNeedsUpdate(int menu) {
+    sendEvent (DWT.Show);
+}
+
+void menuWillClose(int menu) {
+    sendEvent (DWT.Hide);
+}
+
+void menuWillOpen(int menu) {
+}
+
+int modifierIndex (String accelText) {
+    int start = accelText.length () - 1;
+    int index = start;
+    while (index >= 0) {
+        char c = accelText.charAt (index);
+        switch (c) {
+            case ' ':
+                if (index !is start) return index;
+                break;
+            case '\u2303':
+            case '\u2325':
+            case '\u21E7':
+            case '\u2318':
+                return index;
+        }
+        index--;
+    }
+    return -1;
+}
+
+int numberOfItemsInMenu(int menu) {
+    System.out.println("numver");
+    return 4;
+}
+
+void releaseChildren (bool destroy) {
+    if (items !is null) {
+        for (int i=0; i<items.length; i++) {
+            MenuItem item = items [i];
+            if (item !is null && !item.isDisposed ()) {
+                item.release (false);
+            }
+        }
+        items = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    nsMenu = null;
+}
+
+void releaseParent () {
+    super.releaseParent ();
+    if (cascade !is null) cascade.setMenu (null);
+    if ((style & DWT.BAR) !is 0 && this is parent.menuBar) {
+        parent.setMenuBar (null);
+    }
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+//  display.removeMenu (this);
+    parent = null;
+    cascade = defaultItem = lastTarget = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #addHelpListener
+ */
+public void removeHelpListener (HelpListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Help, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the menu events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuListener
+ * @see #addMenuListener
+ */
+public void removeMenuListener (MenuListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Hide, listener);
+    eventTable.unhook (DWT.Show, listener);
+}
+
+/**
+ * Sets the default menu item to the argument or removes
+ * the default emphasis when the argument is <code>null</code>.
+ * 
+ * @param item the default menu item or null
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu item has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDefaultItem (MenuItem item) {
+    checkWidget();
+    if (item !is null && item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    defaultItem = item;
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled menu is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (bool enabled) {
+    checkWidget();
+    if (enabled) {
+        state &= ~DISABLED;
+        //OS.EnableMenuItem (handle, (short)0);
+    } else {
+        state |= DISABLED;
+        //OS.DisableMenuItem (handle, (short)0);
+    }
+}
+
+/**
+ * Sets the location of the receiver, which must be a popup,
+ * to the point specified by the arguments which are relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p><p>
+ * Note that the platform window manager ultimately has control
+ * over the location of popup menus.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (int x, int y) {
+    checkWidget ();
+    this.x = x;
+    this.y = y;
+    hasLocation = true;
+}
+
+/**
+ * Sets the location of the receiver, which must be a popup,
+ * to the point specified by the argument which is relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p><p>
+ * Note that the platform window manager ultimately has control
+ * over the location of popup menus.
+ * </p>
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void setLocation (Point location) {
+    checkWidget ();
+    if (location is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setLocation (location.x, location.y);
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (bool visible) {
+    checkWidget ();
+    if ((style & (DWT.BAR | DWT.DROP_DOWN)) !is 0) return;
+    if (visible) {
+//      display.addPopup (this);
+        //TODO -WRONG
+        _setVisible (true);
+    } else {
+//      display.removePopup (this);
+        _setVisible (false);
+    }
+}
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/MenuItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,774 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.MenuItem;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ArmListener;
+import dwt.events.HelpListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Image;
+import dwt.internal.cocoa.NSMenu;
+import dwt.internal.cocoa.NSMenuItem;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTMenu;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that issues notification when pressed and released. 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Arm, Help, Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class MenuItem extends Item {
+    NSMenuItem nsItem;
+    Menu parent, menu;
+    int accelerator;
+//  int x, y, width, height;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a menu control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#CHECK
+ * @see DWT#CASCADE
+ * @see DWT#PUSH
+ * @see DWT#RADIO
+ * @see DWT#SEPARATOR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public MenuItem (Menu parent, int style) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a menu control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#CHECK
+ * @see DWT#CASCADE
+ * @see DWT#PUSH
+ * @see DWT#RADIO
+ * @see DWT#SEPARATOR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public MenuItem (Menu parent, int style, int index) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the arm events are generated for the control, by sending
+ * it one of the messages defined in the <code>ArmListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ArmListener
+ * @see #removeArmListener
+ */
+public void addArmListener (ArmListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Arm, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the help events are generated for the control, by sending
+ * it one of the messages defined in the <code>HelpListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
+public void addHelpListener (HelpListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Help, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the menu item is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the menu item is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.PUSH, DWT.CHECK, DWT.RADIO, DWT.SEPARATOR, DWT.CASCADE, 0);
+}
+
+NSMenu createEmptyMenu () {
+    if ((parent.style & DWT.BAR) !is 0) {
+        return (NSMenu) new SWTMenu ().alloc ().init ();
+    }
+    return null;
+}
+
+void destroyWidget () {
+    parent.destroyItem (this);
+    releaseHandle ();
+}
+
+/**
+ * Returns the widget accelerator.  An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>DWT.CONTROL | DWT.SHIFT | 'T', DWT.ALT | DWT.F2</code>.
+ * The default value is zero, indicating that the menu item does
+ * not have an accelerator.
+ *
+ * @return the accelerator or 0
+ *
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAccelerator () {
+    checkWidget ();
+    return accelerator;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled menu item is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public bool getEnabled () {
+    checkWidget();
+    return (state & DISABLED) is 0;
+}
+
+/**
+ * Returns the receiver's cascade menu if it has one or null
+ * if it does not. Only <code>CASCADE</code> menu items can have
+ * a pull down menu. The sequence of key strokes, button presses 
+ * and/or button releases that are used to request a pull down
+ * menu is platform specific.
+ *
+ * @return the receiver's menu
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getMenu () {
+    checkWidget ();
+    return menu;
+}
+
+String getNameText () {
+    if ((style & DWT.SEPARATOR) !is 0) return "|";
+    return super.getNameText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Menu</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @return the selection state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getSelection () {
+    checkWidget ();
+    if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return false;
+    return ((NSMenuItem)nsItem).state() is OS.NSOnState;
+}
+
+//int kEventProcessCommand (int nextHandler, int theEvent, int userData) {
+//  //TEMPORARY CODE
+//  if (!isEnabled ()) return OS.noErr;
+//
+//  if ((style & DWT.CHECK) !is 0) {
+//      setSelection (!getSelection ());
+//  } else {
+//      if ((style & DWT.RADIO) !is 0) {
+//          if ((parent.getStyle () & DWT.NO_RADIO_GROUP) !is 0) {
+//              setSelection (!getSelection ());
+//          } else {
+//              selectRadio ();
+//          }
+//      }
+//  }
+//  int [] modifiers = new int [1];
+//  OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+//  Event event = new Event ();
+//  setInputState (event, (short) 0, OS.GetCurrentEventButtonState (), modifiers [0]);
+//  postEvent (DWT.Selection, event);
+//  return OS.noErr;
+//}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled menu item is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public bool isEnabled () {
+    return getEnabled () && parent.isEnabled ();
+}
+
+//int keyGlyph (int key) {
+//  switch (key) {
+//      case DWT.BS: return OS.kMenuDeleteLeftGlyph;
+//      case DWT.CR: return OS.kMenuReturnGlyph;
+//      case DWT.DEL: return OS.kMenuDeleteRightGlyph;
+//      case DWT.ESC: return OS.kMenuEscapeGlyph;
+//      case DWT.LF: return OS.kMenuReturnGlyph;
+//      case DWT.TAB: return OS.kMenuTabRightGlyph;
+//      case ' ': return OS.kMenuBlankGlyph;
+////        case ' ': return OS.kMenuSpaceGlyph;
+//      case DWT.ALT: return OS.kMenuOptionGlyph;
+//      case DWT.SHIFT: return OS.kMenuShiftGlyph;
+//      case DWT.CONTROL: return OS.kMenuControlISOGlyph;
+//      case DWT.COMMAND: return OS.kMenuCommandGlyph;
+//      case DWT.ARROW_UP: return OS.kMenuUpArrowGlyph;
+//      case DWT.ARROW_DOWN: return OS.kMenuDownArrowGlyph;
+//      case DWT.ARROW_LEFT: return OS.kMenuLeftArrowGlyph;
+//      case DWT.ARROW_RIGHT: return OS.kMenuRightArrowGlyph;
+//      case DWT.PAGE_UP: return OS.kMenuPageUpGlyph;
+//      case DWT.PAGE_DOWN: return OS.kMenuPageDownGlyph;
+//      case DWT.F1: return OS.kMenuF1Glyph;
+//      case DWT.F2: return OS.kMenuF2Glyph;
+//      case DWT.F3: return OS.kMenuF3Glyph;
+//      case DWT.F4: return OS.kMenuF4Glyph;
+//      case DWT.F5: return OS.kMenuF5Glyph;
+//      case DWT.F6: return OS.kMenuF6Glyph;
+//      case DWT.F7: return OS.kMenuF7Glyph;
+//      case DWT.F8: return OS.kMenuF8Glyph;
+//      case DWT.F9: return OS.kMenuF9Glyph;
+//      case DWT.F10: return OS.kMenuF10Glyph;
+//      case DWT.F11: return OS.kMenuF11Glyph;
+//      case DWT.F12: return OS.kMenuF12Glyph;
+//  }
+//  return OS.kMenuNullGlyph;
+//}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (nsItem !is null) nsItem.release();
+    nsItem = null;
+    parent = null;
+}
+
+void releaseChildren (bool destroy) {
+    if (menu !is null) {
+        menu.release (false);
+        menu = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    accelerator = 0;
+    if (this is parent.defaultItem) parent.defaultItem = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the arm events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ArmListener
+ * @see #addArmListener
+ */
+public void removeArmListener (ArmListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Arm, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #addHelpListener
+ */
+public void removeHelpListener (HelpListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Help, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+void selectRadio () {
+    int index = 0;
+    MenuItem [] items = parent.getItems ();
+    while (index < items.length && items [index] !is this) index++;
+    int i = index - 1;
+    while (i >= 0 && items [i].setRadioSelection (false)) --i;
+    int j = index + 1;
+    while (j < items.length && items [j].setRadioSelection (false)) j++;
+    setSelection (true);
+}
+
+void sendSelection () {
+    if ((style & DWT.CHECK) !is 0) {
+        setSelection (!getSelection ());
+    } else {
+        if ((style & DWT.RADIO) !is 0) {
+            if ((parent.getStyle () & DWT.NO_RADIO_GROUP) !is 0) {
+                setSelection (!getSelection ());
+            } else {
+                selectRadio ();
+            }
+        }
+    }
+    Event event = new Event ();
+    //TODO state mask
+//  setInputState (event, (short) 0, OS.GetCurrentEventButtonState (), modifiers [0]);
+    postEvent (DWT.Selection, event);
+}
+
+/**
+ * Sets the widget accelerator.  An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>DWT.MOD1 | DWT.MOD2 | 'T', DWT.MOD3 | DWT.F2</code>.
+ * <code>DWT.CONTROL | DWT.SHIFT | 'T', DWT.ALT | DWT.F2</code>.
+ * The default value is zero, indicating that the menu item does
+ * not have an accelerator.
+ *
+ * @param accelerator an integer that is the bit-wise OR of masks and a key
+ *
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAccelerator (int accelerator) {
+    checkWidget ();
+    this.accelerator = accelerator;
+    int key = accelerator & DWT.KEY_MASK;
+    int virtualKey = Display.untranslateKey (key);
+    NSString string =  null;
+    if (virtualKey !is 0) {
+        string = NSString.stringWith ((char)virtualKey + "");
+    } else {
+        string = NSString.stringWith ((char)key + "").lowercaseString();
+    }
+    nsItem.setKeyEquivalent (string);
+    int mask = 0;
+    if ((accelerator & DWT.SHIFT) !is 0) mask |= OS.NSShiftKeyMask;
+    if ((accelerator & DWT.CONTROL) !is 0) mask |= OS.NSControlKeyMask;
+//  if ((accelerator & DWT.COMMAND) !is 0) mask &= ~OS.kMenuNoCommandModifier;
+    if ((accelerator & DWT.COMMAND) !is 0) mask |= OS.NSCommandKeyMask;
+    if ((accelerator & DWT.ALT) !is 0) mask |= OS.NSAlternateKeyMask;
+    nsItem.setKeyEquivalentModifierMask (mask);
+    if ((this.accelerator is 0 && accelerator !is 0) || (this.accelerator !is 0 && accelerator is 0)) {
+        updateText ();
+    }
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled menu item is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (bool enabled) {
+    checkWidget ();
+    ((NSMenuItem)nsItem).setEnabled(enabled);
+}
+
+/**
+ * Sets the image the receiver will display to the argument.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept (for example, Windows NT).
+ * </p>
+ *
+ * @param image the image to display
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+    checkWidget ();
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    super.setImage (image);
+    ((NSMenuItem)nsItem).setImage(image !is null? image.handle : null);
+}
+
+/**
+ * Sets the receiver's pull down menu to the argument.
+ * Only <code>CASCADE</code> menu items can have a
+ * pull down menu. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pull down
+ * menu is platform specific.
+ * <p>
+ * Note: Disposing of a menu item that has a pull down menu
+ * will dispose of the menu.  To avoid this behavior, set the
+ * menu to null before the menu item is disposed.
+ * </p>
+ *
+ * @param menu the new pull down menu
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_MENU_NOT_DROP_DOWN - if the menu is not a drop down menu</li>
+ *    <li>ERROR_MENUITEM_NOT_CASCADE - if the menu item is not a <code>CASCADE</code></li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+    checkWidget ();
+
+    /* Check to make sure the new menu is valid */
+    if ((style & DWT.CASCADE) is 0) {
+        error (DWT.ERROR_MENUITEM_NOT_CASCADE);
+    }
+    if (menu !is null) {
+        if (menu.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+        if ((menu.style & DWT.DROP_DOWN) is 0) {
+            error (DWT.ERROR_MENU_NOT_DROP_DOWN);
+        }
+        if (menu.parent !is parent.parent) {
+            error (DWT.ERROR_INVALID_PARENT);
+        }
+    } 
+    /* Assign the new menu */
+    Menu oldMenu = this.menu;
+    if (oldMenu is menu) return;
+    if (oldMenu !is null) oldMenu.cascade = null;
+    this.menu = menu;
+    
+    /* Update the menu in the OS */
+    NSMenu menuHandle;
+    if (menu is null) {
+        menuHandle = createEmptyMenu ();
+    } else {
+        menu.cascade = this;
+        menuHandle = menu.nsMenu;
+    }
+    nsItem.setSubmenu (menuHandle);
+    
+    /* Update menu title with parent item title */
+    updateText ();
+}
+
+bool setRadioSelection (bool value) {
+    if ((style & DWT.RADIO) is 0) return false;
+    if (getSelection () !is value) {
+        setSelection (value);
+        postEvent (DWT.Selection);
+    }
+    return true;
+}
+
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @param selected the new selection state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (bool selected) {
+    checkWidget ();
+    if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return;
+    ((NSMenuItem)nsItem).setState(selected ? OS.NSOnState : OS.NSOffState);
+}
+
+/**
+ * Sets the receiver's text. The string may include
+ * the mnemonic character and accelerator text.
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p>
+ * <p>
+ * Accelerator text is indicated by the '\t' character.
+ * On platforms that support accelerator text, the text
+ * that follows the '\t' character is displayed to the user,
+ * typically indicating the key stroke that will cause
+ * the item to become selected.  On most platforms, the
+ * accelerator text appears right aligned in the menu.
+ * Setting the accelerator text does not install the
+ * accelerator key sequence. The accelerator key sequence
+ * is installed using #setAccelerator.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setAccelerator
+ */
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    if (text.equals (string)) return;
+    super.setText (string);
+    updateText ();
+}
+    
+void updateText() {
+    char [] buffer = new char [text.length ()];
+    text.getChars (0, buffer.length, buffer, 0);
+    int i=0, j=0;
+    while (i < buffer.length) {
+        if (buffer [i] is '\t') break;
+        if ((buffer [j++] = buffer [i++]) is '&') {
+            if (i is buffer.length) {continue;}
+            if (buffer [i] is '&') {i++; continue;}
+            j--;
+        }
+    }
+    String text = new String (buffer, 0, j);
+    NSMenu submenu = nsItem.submenu ();
+    NSString label = NSString.stringWith (text);
+    if(submenu !is null && (parent.getStyle () & DWT.BAR) !is 0) {
+        submenu.setTitle (label);
+    } else {
+        nsItem.setTitle (label);
+    }
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/MessageBox.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.MessageBox;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.internal.cocoa.NSAlert;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class are used to inform or warn the user.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING</dd>
+ * <dd>OK, OK | CANCEL</dd>
+ * <dd>YES | NO, YES | NO | CANCEL</dd>
+ * <dd>RETRY | CANCEL</dd>
+ * <dd>ABORT | RETRY | IGNORE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public  class MessageBox extends Dialog {
+    String message = "";
+    
+
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public MessageBox (Shell parent) {
+    this (parent, DWT.OK | DWT.ICON_INFORMATION | DWT.APPLICATION_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public MessageBox (Shell parent, int style) {
+    super (parent, checkStyle (style));
+    checkSubclass ();
+}
+
+static int checkStyle (int style) {
+    if ((style & (DWT.PRIMARY_MODAL | DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) is 0) style |= DWT.APPLICATION_MODAL;
+    int mask = (DWT.YES | DWT.NO | DWT.OK | DWT.CANCEL | DWT.ABORT | DWT.RETRY | DWT.IGNORE);
+    int bits = style & mask;
+    if (bits is DWT.OK || bits is DWT.CANCEL || bits is (DWT.OK | DWT.CANCEL)) return style;
+    if (bits is DWT.YES || bits is DWT.NO || bits is (DWT.YES | DWT.NO) || bits is (DWT.YES | DWT.NO | DWT.CANCEL)) return style;
+    if (bits is (DWT.RETRY | DWT.CANCEL) || bits is (DWT.ABORT | DWT.RETRY | DWT.IGNORE)) return style;
+    style = (style & ~mask) | DWT.OK;
+    return style;
+}
+
+/**
+ * Returns the dialog's message, or an empty string if it does not have one.
+ * The message is a description of the purpose for which the dialog was opened.
+ * This message will be visible in the dialog while it is open.
+ *
+ * @return the message
+ */
+public String getMessage () {
+    return message;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return the ID of the button that was selected to dismiss the
+ *         message box (e.g. DWT.OK, DWT.CANCEL, etc.)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public int open () {
+    int alertType = OS.NSInformationalAlertStyle;
+    if ((style & DWT.ICON_ERROR) !is 0) alertType = OS.NSCriticalAlertStyle;
+    if ((style & DWT.ICON_INFORMATION) !is 0) alertType = OS.NSInformationalAlertStyle;
+    if ((style & DWT.ICON_QUESTION) !is 0) alertType = OS.NSInformationalAlertStyle;
+    if ((style & DWT.ICON_WARNING) !is 0) alertType = OS.NSWarningAlertStyle;
+    if ((style & DWT.ICON_WORKING) !is 0) alertType = OS.NSInformationalAlertStyle;
+    NSString defaultButton = null, alternateButton = null, otherButton = null;
+    int mask = (DWT.YES | DWT.NO | DWT.OK | DWT.CANCEL | DWT.ABORT | DWT.RETRY | DWT.IGNORE);
+    int bits = style & mask;
+    switch (bits) {
+        case DWT.OK:
+            break;
+        case DWT.CANCEL:
+            defaultButton = NSString.stringWith(DWT.getMessage("SWT_Cancel"));
+            break;
+        case DWT.OK | DWT.CANCEL:
+            alternateButton = NSString.stringWith(DWT.getMessage("SWT_Cancel"));
+            break;
+        case DWT.YES:
+            defaultButton = NSString.stringWith(DWT.getMessage("SWT_Yes"));
+            break;
+        case DWT.NO:
+            defaultButton = NSString.stringWith(DWT.getMessage("SWT_No"));
+            break;
+        case DWT.YES | DWT.NO:
+            defaultButton = NSString.stringWith(DWT.getMessage("SWT_Yes"));
+            alternateButton = NSString.stringWith(DWT.getMessage("SWT_No"));
+            break;
+        case DWT.YES | DWT.NO | DWT.CANCEL:             
+            defaultButton = NSString.stringWith(DWT.getMessage("SWT_Yes"));
+            alternateButton = NSString.stringWith(DWT.getMessage("SWT_No"));
+            otherButton = NSString.stringWith(DWT.getMessage("SWT_Cancel"));
+            break;
+        case DWT.RETRY | DWT.CANCEL:
+            defaultButton = NSString.stringWith(DWT.getMessage("SWT_Retry"));
+            alternateButton = NSString.stringWith(DWT.getMessage("SWT_Cancel"));
+            break;
+        case DWT.ABORT | DWT.RETRY | DWT.IGNORE:
+            defaultButton = NSString.stringWith(DWT.getMessage("SWT_Abort"));
+            alternateButton = NSString.stringWith(DWT.getMessage("SWT_Retry"));
+            otherButton = NSString.stringWith(DWT.getMessage("SWT_Ignore"));
+            break;
+    }
+    NSString title = NSString.stringWith(this.title !is null ? this.title : "");
+    NSString message = NSString.stringWith(this.message !is null ? this.message : "");
+    NSAlert alert = NSAlert.alertWithMessageText(title, defaultButton, alternateButton, otherButton, message);
+    alert.setAlertStyle(alertType);
+    int response = alert.runModal();
+    switch (bits) {
+        case DWT.OK:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.OK;
+            }
+            break;
+        case DWT.CANCEL:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.CANCEL;
+            }
+            break;
+        case DWT.OK | DWT.CANCEL:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.OK;
+                case OS.NSAlertAlternateReturn:
+                    return DWT.CANCEL;
+            }
+            break;
+        case DWT.YES:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.YES;
+            }
+            break;
+        case DWT.NO:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.NO;
+            }
+            break;
+        case DWT.YES | DWT.NO:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.YES;
+                case OS.NSAlertAlternateReturn:
+                    return DWT.NO;
+            }
+            break;
+        case DWT.YES | DWT.NO | DWT.CANCEL:             
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.YES;
+                case OS.NSAlertAlternateReturn:
+                    return DWT.NO;
+                case OS.NSAlertOtherReturn:
+                    return DWT.CANCEL;
+            }
+            break;
+        case DWT.RETRY | DWT.CANCEL:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.RETRY;
+                case OS.NSAlertAlternateReturn:
+                    return DWT.CANCEL;
+            }
+            break;
+        case DWT.ABORT | DWT.RETRY | DWT.IGNORE:
+            switch (response) {
+                case OS.NSAlertDefaultReturn:
+                    return DWT.ABORT;
+                case OS.NSAlertAlternateReturn:
+                    return DWT.RETRY;
+                case OS.NSAlertOtherReturn:
+                    return DWT.IGNORE;
+            }
+            break;
+    }
+    return DWT.CANCEL;
+}
+
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ */
+public void setMessage (String string) {
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    message = string;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Monitor.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Monitor;
+
+import dwt.dwthelper.utils;
+
+import dwt.graphics.Rectangle;
+
+/**
+ * Instances of this class are descriptions of monitors.
+ *
+ * @see Display
+ * 
+ * @since 3.0
+ */
+public final class Monitor {
+    int /*long*/ handle;
+    int x, y, width, height;
+    int clientX, clientY, clientWidth, clientHeight;
+    
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Monitor () {    
+}
+    
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public bool equals (Object object) {
+    if (object is this) return true;
+    if (!(object instanceof Monitor)) return false;
+    Monitor monitor = (Monitor) object;
+    return handle is monitor.handle;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its device. Note that on multi-monitor systems the
+ * origin can be negative.
+ *
+ * @return the receiver's bounding rectangle
+ */ 
+public Rectangle getBounds () {
+    return new Rectangle (x, y, width, height);
+}
+    
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * 
+ * @return the client area
+ */
+public Rectangle getClientArea () {
+    return new Rectangle (clientX, clientY, clientWidth, clientHeight);
+}
+    
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+    return (int)/*64*/handle;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ProgressBar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ProgressBar;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSProgressIndicator;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.SWTProgressIndicator;
+
+/**
+ * Instances of the receiver represent an unselectable
+ * user interface object that is used to display progress,
+ * typically in the form of a bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SMOOTH, HORIZONTAL, VERTICAL, INDETERMINATE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class ProgressBar extends Control {
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#SMOOTH
+ * @see DWT#HORIZONTAL
+ * @see DWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ProgressBar (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+    style |= DWT.NO_FOCUS;
+    return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    NSProgressIndicator widget = (NSProgressIndicator)view;
+    NSRect oldRect = widget.frame();
+    widget.sizeToFit();
+    NSRect newRect = widget.frame();
+    widget.setFrame (oldRect);
+    int size = (int)newRect.height;
+    int width = 0, height = 0;
+    if ((style & DWT.HORIZONTAL) !is 0) {
+        height = size;
+        width = height * 10;
+    } else {
+        width = size;
+        height = width * 10;
+    }
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point (width, height);
+}
+
+void createHandle () {
+    SWTProgressIndicator widget = (SWTProgressIndicator)new SWTProgressIndicator().alloc();
+    widget.initWithFrame(new NSRect());
+    widget.setUsesThreadedAnimation(false);
+    widget.setIndeterminate((style & DWT.INDETERMINATE) !is 0);
+    if ((style & DWT.INDETERMINATE) !is 0) widget.startAnimation(null);
+    widget.setTag(jniRef);
+    view = widget;
+    parent.contentView().addSubview_(widget);
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+    checkWidget();
+    return (int)((NSProgressIndicator)view).maxValue();
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+    checkWidget();
+    return (int)((NSProgressIndicator)view).minValue();
+}
+
+/**
+ * Returns the single 'selection' that is the receiver's position.
+ *
+ * @return the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+    checkWidget();
+    return (int)((NSProgressIndicator)view).doubleValue();
+}
+
+public int getState () {
+    checkWidget ();
+    return DWT.NORMAL;
+}
+
+/**
+ * Sets the maximum value that the receiver will allow.  This new
+ * value will be ignored if it is not greater than the receiver's current
+ * minimum value.  If the new maximum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    ((NSProgressIndicator)view).setMaxValue(value);
+}
+
+/**
+ * Sets the minimum value that the receiver will allow.  This new
+ * value will be ignored if it is negative or is not less than the receiver's
+ * current maximum value.  If the new minimum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new minimum, which must be nonnegative and less than the current maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    ((NSProgressIndicator)view).setMinValue(value);
+}
+
+/**
+ * Sets the single 'selection' that is the receiver's
+ * position to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+    checkWidget();
+   ((NSProgressIndicator)view).setDoubleValue(value);
+}
+
+public void setState (int state) {
+    checkWidget ();
+    //NOT IMPLEMENTED
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/RunnableLock.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.RunnableLock;
+
+import dwt.dwthelper.utils;
+
+
+/**
+ * Instances of this class are used to ensure that an
+ * application cannot interfere with the locking mechanism
+ * used to implement asynchronous and synchronous communication
+ * between widgets and background threads.
+ */
+
+class RunnableLock {
+    Runnable runnable;
+    Thread thread;
+    Throwable throwable;
+    
+RunnableLock (Runnable runnable) {
+    this.runnable = runnable;
+}
+
+bool done () {
+    return runnable is null || throwable !is null;
+}
+
+void run () {
+    if (runnable !is null) runnable.run ();
+    runnable = null;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Sash.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,327 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Sash;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Cursor;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTView;
+
+/**
+ * Instances of the receiver represent a selectable user interface object
+ * that allows the user to drag a rubber banded outline of the sash within
+ * the parent control.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL, SMOOTH</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class Sash extends Control {
+    Cursor sizeCursor;
+    bool dragging;
+    int lastX, lastY, startX, startY;
+    private final static int INCREMENT = 1;
+    private final static int PAGE_INCREMENT = 9;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#HORIZONTAL
+ * @see DWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Sash (Composite parent, int style) {
+    super (parent, checkStyle (style));
+    int cursorStyle = (style & DWT.VERTICAL) !is 0 ? DWT.CURSOR_SIZEWE : DWT.CURSOR_SIZENS;
+    sizeCursor = new Cursor (display, cursorStyle);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid.
+ * If the receiver is being dragged, the event object detail field contains the value <code>DWT.DRAG</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    /*
+    * Macintosh only supports smooth dragging.
+    */
+    style |= DWT.SMOOTH;
+    return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0);
+}
+
+bool becomeFirstResponder () {
+    bool result = super.becomeFirstResponder();
+    NSRect frame = view.frame();
+    lastX = (int)frame.x;
+    lastY = (int)frame.y;
+    return result;
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = 0, height = 0;
+    if ((style & DWT.HORIZONTAL) !is 0) {
+        width += DEFAULT_WIDTH;  height += 5;
+    } else {
+        width += 5; height += DEFAULT_HEIGHT;
+    }
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point (width, height);
+}
+
+void createHandle () {
+    SWTView widget = (SWTView)new SWTView().alloc();
+    widget.initWithFrame (new NSRect());
+    widget.setTag(jniRef);
+    view = widget;
+    parent.contentView().addSubview_(view);
+}
+
+bool sendKeyEvent(NSEvent nsEvent, int type) {
+    //TODO consumed
+    int keyCode = nsEvent.keyCode();
+    switch (keyCode) {
+        case 126: /* Up arrow */
+        case 123: /* Left arrow */
+        case 125: /* Down arrow */
+        case 124: /* Right arrow */ {
+            int xChange = 0, yChange = 0;
+            int stepSize = PAGE_INCREMENT;
+            int modifiers = nsEvent.modifierFlags();
+            if ((modifiers & OS.NSControlKeyMask) !is 0) stepSize = INCREMENT;
+            if ((style & DWT.VERTICAL) !is 0) {
+                if (keyCode is 126 || keyCode is 125) break;
+                xChange = keyCode is 123 ? -stepSize : stepSize;
+            } else {
+                if (keyCode is 123 || keyCode  is 124) break;
+                yChange = keyCode is 126 ? -stepSize : stepSize;
+            }
+            
+            Rectangle bounds = getBounds ();
+            int width = bounds.width, height = bounds.height;
+            Rectangle parentBounds = parent.getBounds ();
+            int parentWidth = parentBounds.width;
+            int parentHeight = parentBounds.height;
+            int newX = lastX, newY = lastY;
+            if ((style & DWT.VERTICAL) !is 0) {
+                newX = Math.min (Math.max (0, lastX + xChange), parentWidth - width);
+            } else {
+                newY = Math.min (Math.max (0, lastY + yChange), parentHeight - height);
+            }
+            if (newX is lastX && newY is lastY) return true;
+            Event event = new Event ();
+            event.x = newX;
+            event.y = newY;
+            event.width = width;
+            event.height = height;
+            sendEvent (DWT.Selection, event);
+            if (isDisposed ()) break;
+            if (event.doit) {
+                setBounds (event.x, event.y, width, height);
+                if (isDisposed ()) break;
+                lastX = event.x;
+                lastY = event.y;
+                if (isDisposed ()) return false;
+                int cursorX = event.x, cursorY = event.y;
+                if ((style & DWT.VERTICAL) !is 0) {
+                    cursorY += height / 2;
+                } else {
+                    cursorX += width / 2;
+                }
+                display.setCursorLocation (parent.toDisplay (cursorX, cursorY));
+            }
+            break;
+        }
+    }
+    return true;
+}
+
+void mouseDown(int theEvent) {
+    super.mouseDown(theEvent);
+    NSEvent nsEvent = new NSEvent(theEvent);
+    if (nsEvent.clickCount() !is 1) return;
+    NSPoint location = nsEvent.locationInWindow();
+    NSPoint point = view.convertPoint_fromView_(location, null);
+    startX = (int)point.x;
+    startY = (int)point.y;
+    NSRect frame = view.frame();
+    Event event = new Event ();
+    event.x = (int)frame.x;
+    event.y = (int)frame.y;
+    event.width = (int)frame.width;
+    event.height = (int)frame.height;
+    sendEvent (DWT.Selection, event);
+    if (isDisposed ()) return;
+    if (event.doit) {
+        lastX = event.x;
+        lastY = event.y;
+        dragging = true;
+        setLocation(event.x, event.y);
+    }
+}
+
+void mouseDragged(int theEvent) {
+    super.mouseDragged(theEvent);
+    if (!dragging) return;
+    NSEvent nsEvent = new NSEvent(theEvent);
+    NSPoint location = nsEvent.locationInWindow();
+    NSPoint point = view.convertPoint_fromView_(location, null);
+    NSRect frame = view.frame();
+    NSRect parentFrame = parent.topView().frame();
+    int newX = lastX, newY = lastY;
+    if ((style & DWT.VERTICAL) !is 0) {
+        newX = Math.min (Math.max (0, (int)(point.x + frame.x - startX)), (int)(parentFrame.width - frame.width));
+    } else {
+        newY = Math.min (Math.max (0, (int)(point.y + frame.y - startY)), (int)(parentFrame.height - frame.height));
+    }
+    if (newX is lastX && newY is lastY) return;
+    Event event = new Event ();
+    event.x = newX;
+    event.y = newY;
+    event.width = (int)frame.width;
+    event.height = (int)frame.height;
+    sendEvent (DWT.Selection, event);
+    if (isDisposed ()) return;
+    if (event.doit) {
+        lastX = event.x;
+        lastY = event.y;
+        setBounds (event.x, event.y, (int)frame.width, (int)frame.height);
+    }
+}
+
+void mouseEntered(int theEvent) {
+    //TODO need to add tracking area
+    super.mouseEntered(theEvent);
+    sizeCursor.handle.set();
+}
+
+void mouseUp(int theEvent) {
+    super.mouseUp(theEvent);
+    if (!dragging) return;
+    dragging = false;
+    NSRect frame = view.frame();
+    Event event = new Event ();
+    event.x = lastX;
+    event.y = lastY;
+    event.width = (int)frame.width;
+    event.height = (int)frame.height;
+    sendEvent (DWT.Selection, event);
+    if (isDisposed ()) return;
+    if (event.doit) {
+        setBounds (event.x, event.y, (int)frame.width, (int)frame.height);
+    }
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    if (sizeCursor !is null) sizeCursor.dispose ();
+    sizeCursor = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);
+}
+
+int traversalCode (int key, NSEvent theEvent) {
+    return 0;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Scale.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,351 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Scale;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionListener;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSlider;
+import dwt.internal.cocoa.SWTSlider;
+
+/**
+ * Instances of the receiver represent a selectable user
+ * interface object that present a range of continuous
+ * numeric values.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public class Scale extends Control {
+    int increment = 1;
+    int pageIncrement = 10;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#HORIZONTAL
+ * @see DWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Scale (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's value, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the user changes the receiver's value.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    NSSlider widget = (NSSlider)view;
+    NSRect oldRect = widget.frame();
+    widget.sizeToFit();
+    NSRect newRect = widget.frame();
+    widget.setFrame (oldRect);
+    int width = 0, height = 0;
+    if ((style & DWT.HORIZONTAL) !is 0) {        
+        height = (int)newRect.width;
+        width = height * 10;
+    } else {
+        width = (int)newRect.width;
+        height = width * 10;
+    }
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point (width, height);
+}
+
+void createHandle () {
+    NSSlider widget = (NSSlider)new SWTSlider().alloc();
+    NSRect rect = new NSRect();
+    if ((style & DWT.HORIZONTAL) !is 0) {
+        rect.width = 1;
+    } else {
+        rect.height = 1;
+    }
+    widget.initWithFrame(rect);
+    widget.setMaxValue(100);
+    widget.setTag(jniRef);
+    view = widget;
+    parent.contentView().addSubview_(widget);
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+    checkWidget();
+    return increment;
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+    checkWidget();
+    return (int)((NSSlider)view).maxValue();
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+    checkWidget();
+    return (int)((NSSlider)view).minValue();
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+    checkWidget();
+    return pageIncrement;
+}
+
+/**
+ * Returns the 'selection', which is the receiver's position.
+ *
+ * @return the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+    checkWidget();
+//  int value = OS.GetControl32BitValue (handle);
+//  if ((style & DWT.VERTICAL) !is 0) {
+//      int minimum = OS.GetControl32BitMinimum (handle);
+//      int maximum = OS.GetControl32BitMaximum (handle);
+//      value = maximum - value + minimum;
+//  }
+    return (int)((NSSlider)view).doubleValue();
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's value.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param increment the new increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+    checkWidget();
+    if (value < 1) return;
+    increment = value;
+}
+
+/**
+ * Sets the maximum value that the receiver will allow.  This new
+ * value will be ignored if it is not greater than the receiver's current
+ * minimum value.  If the new maximum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    ((NSSlider)view).setMaxValue(value);
+}
+
+/**
+ * Sets the minimum value that the receiver will allow.  This new
+ * value will be ignored if it is negative or is not less than the receiver's
+ * current maximum value.  If the new minimum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new minimum, which must be nonnegative and less than the current maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    ((NSSlider)view).setMinValue(value);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @param pageIncrement the page increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+    checkWidget();
+    if (value < 1) return;
+    pageIncrement = value;
+}
+
+/**
+ * Sets the 'selection', which is the receiver's value,
+ * to the argument which must be greater than or equal to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+    checkWidget();
+    ((NSSlider)view).setDoubleValue(value);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ScrollBar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,664 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ScrollBar;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSScroller;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.id;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent a range of positive, numeric values. 
+ * <p>
+ * At any given moment, a given scroll bar will have a 
+ * single 'selection' that is considered to be its
+ * value, which is constrained to be within the range of
+ * values the scroll bar represents (that is, between its
+ * <em>minimum</em> and <em>maximum</em> values).
+ * </p><p>
+ * Typically, scroll bars will be made up of five areas:
+ * <ol>
+ * <li>an arrow button for decrementing the value</li>
+ * <li>a page decrement area for decrementing the value by a larger amount</li>
+ * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
+ * <li>a page increment area for incrementing the value by a larger amount</li>
+ * <li>an arrow button for incrementing the value</li>
+ * </ol>
+ * Based on their style, scroll bars are either <code>HORIZONTAL</code>
+ * (which have a left facing button for decrementing the value and a
+ * right facing button for incrementing it) or <code>VERTICAL</code>
+ * (which have an upward facing button for decrementing the value
+ * and a downward facing buttons for incrementing it).
+ * </p><p>
+ * On some platforms, the size of the scroll bar's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. DWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the scroll bar will not change.
+ * </p><p>
+ * Scroll bars are created by specifying either <code>H_SCROLL</code>,
+ * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.
+ * They are accessed from the <code>Scrollable</code> using
+ * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.
+ * </p><p>
+ * Note: Scroll bars are not Controls.  On some platforms, scroll bars
+ * that appear as part of some standard controls such as a text or list
+ * have no operating system resources and are not children of the control.
+ * For this reason, scroll bars are treated specially.  To create a control
+ * that looks like a scroll bar but has operating system resources, use
+ * <code>Slider</code>. 
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see Slider
+ * @see Scrollable
+ * @see Scrollable#getHorizontalBar
+ * @see Scrollable#getVerticalBar
+ */
+public class ScrollBar extends Widget {
+    NSScroller view;
+    Scrollable parent;
+    int minimum, maximum, thumb;
+    int increment = 1;
+    int pageIncrement = 10;
+    id target;
+    int actionSelector;;
+
+ScrollBar () {
+    /* Do nothing */
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's value, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>DWT.NONE</code> - for the end of a drag.
+ * <code>DWT.DRAG</code>.
+ * <code>DWT.HOME</code>.
+ * <code>DWT.END</code>.
+ * <code>DWT.ARROW_DOWN</code>.
+ * <code>DWT.ARROW_UP</code>.
+ * <code>DWT.PAGE_DOWN</code>.
+ * <code>DWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's value
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0);
+}
+
+void createWidget () {
+    maximum = 100;
+    thumb = 10;
+    super.createWidget();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public bool getEnabled () {
+    checkWidget();
+    return (state & DISABLED) is 0;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+    checkWidget();
+    return increment;
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+    checkWidget();
+    return maximum;
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+    checkWidget();
+    return minimum;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+    checkWidget();
+    return pageIncrement;
+}
+
+/**
+ * Returns the receiver's parent, which must be a Scrollable.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Scrollable getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Returns the single 'selection' that is the receiver's value.
+ *
+ * @return the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+    checkWidget();
+    NSScroller widget = (NSScroller)view;
+    float value = widget.floatValue();
+    return (int)((maximum - thumb - minimum) * value + minimum);
+}
+
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+    checkWidget();
+//  return getControlSize (handle);
+    return new Point(0, 0);
+}
+
+/**
+ * Returns the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ScrollBar
+ */
+public int getThumb () {
+    checkWidget();
+    return thumb;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getVisible () {
+    checkWidget();
+    return (state & HIDDEN) is 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public bool isEnabled () {
+    checkWidget();
+    return getEnabled () && parent.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public bool isVisible () {
+    checkWidget();
+    return getVisible () && parent.isVisible ();
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's value.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    view = null;
+}
+
+void releaseParent () {
+    super.releaseParent ();
+    if (parent.horizontalBar is this) parent.horizontalBar = null;
+    if (parent.verticalBar is this) parent.verticalBar = null;
+    parent.resizeClientArea ();
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    parent = null;
+}
+
+void sendSelection () {
+    int value = 0;
+    if (target !is null) {
+        view.sendAction(actionSelector, target);
+    } else {
+        value = getSelection ();
+    }
+    Event event = new Event();
+    int hitPart = ((NSScroller)view).hitPart();
+    switch (hitPart) {
+        case OS.NSScrollerDecrementLine:
+            value -= increment;
+            event.detail = DWT.ARROW_UP;
+            break;
+        case OS.NSScrollerDecrementPage:
+            value -= pageIncrement;
+            event.detail = DWT.PAGE_UP;
+            break;
+        case OS.NSScrollerIncrementLine:
+            value += increment;
+            event.detail = DWT.PAGE_DOWN;
+            break;
+        case OS.NSScrollerIncrementPage:
+            value += pageIncrement;
+            event.detail = DWT.ARROW_DOWN;
+            break;
+        case OS.NSScrollerKnob:
+            event.detail = DWT.DRAG;
+            break;
+    }
+    if (target is null) {
+        if (event.detail !is DWT.DRAG) {
+            setSelection(value);
+        }
+    }
+    sendEvent(DWT.Selection, event);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+    checkWidget();
+    if (value < 1) return;
+    increment = value;
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (bool enabled) {
+    checkWidget();
+//  if (enabled) {
+//      if ((state & DISABLED) is 0) return;
+//      state &= ~DISABLED;
+//      OS.EnableControl (handle);
+//  } else {
+//      if ((state & DISABLED) !is 0) return;
+//      state |= DISABLED;
+//      OS.DisableControl (handle);
+//  }
+}
+
+/**
+ * Sets the maximum. If this value is negative or less than or
+ * equal to the minimum, the value is ignored. If necessary, first
+ * the thumb and then the selection are adjusted to fit within the
+ * new range.
+ *
+ * @param value the new maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    if (value <= minimum) return;
+    if (value - minimum < thumb) {
+        thumb = value - minimum;
+    }
+    int selection = Math.max(minimum, Math.min (getSelection (), value - thumb));
+    this.maximum = value;
+    updateBar(selection, minimum, value, thumb);
+}
+
+/**
+ * Sets the minimum value. If this value is negative or greater
+ * than or equal to the maximum, the value is ignored. If necessary,
+ * first the thumb and then the selection are adjusted to fit within
+ * the new range.
+ *
+ * @param value the new minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    if (value >= maximum) return;
+    if (maximum - value < thumb) {
+        thumb = maximum - value;
+    }
+    int selection = Math.min(maximum - thumb, Math.max (getSelection (), value));
+    this.minimum = value;
+    updateBar(selection, value, maximum, thumb);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @param value the page increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+    checkWidget();
+    if (value < 1) return;
+    pageIncrement = value;
+}
+
+/**
+ * Sets the single <em>selection</em> that is the receiver's
+ * value to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param selection the new selection (must be zero or greater)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+    checkWidget();
+    updateBar(value, minimum, maximum, thumb);
+}
+
+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.  This new
+ * value will be ignored if it is less than one, and will be
+ * clamped if it exceeds the receiver's current range.
+ *
+ * @param value the new thumb value, which must be at least one and not
+ * larger than the size of the current range
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setThumb (int value) {
+    checkWidget();
+    if (value < 1) return;
+    value = Math.min (value, maximum - minimum);
+    this.thumb = value;
+    updateBar(getSelection(), minimum, maximum, value);
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is similar to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param thumb the new thumb value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+    checkWidget();
+    if (minimum < 0) return;
+    if (maximum < 0) return;
+    if (thumb < 1) return;
+    if (increment < 1) return;
+    if (pageIncrement < 1) return;
+    thumb = Math.min (thumb, maximum - minimum);
+    this.increment = increment;
+    this.pageIncrement = pageIncrement;
+    updateBar(selection, minimum, maximum, thumb);
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (bool visible) {
+    checkWidget();
+    //TODO visibility
+    parent.setScrollBarVisible (this, visible);
+}
+
+void updateBar(int selection, int minimum, int maximum, int thumb) {
+    NSScroller widget = (NSScroller)view;
+    selection = Math.max(minimum, Math.min(maximum - thumb, selection));
+    int range = maximum - thumb - minimum;
+    float fraction = range < 0 ? 1 : (float)(selection - minimum) / range;
+    float knob = minimum is maximum ? 1 : (float)(thumb - minimum) / maximum - minimum;
+    widget.setFloatValue(fraction, knob);
+    widget.setEnabled(range > 0); 
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Scrollable.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Scrollable;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScrollView;
+import dwt.internal.cocoa.NSScroller;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTScrollView;
+
+/**
+ * This class is the abstract superclass of all classes which
+ * represent controls that have standard scroll bars.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>H_SCROLL, V_SCROLL</dd>
+ * <dt><b>Events:</b>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ */
+public abstract class Scrollable extends Control {
+    SWTScrollView scrollView;
+    ScrollBar horizontalBar, verticalBar;
+    
+Scrollable () {
+    /* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#H_SCROLL
+ * @see DWT#V_SCROLL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Scrollable (Composite parent, int style) {
+    super (parent, style);
+}
+
+/**
+ * Given a desired <em>client area</em> for the receiver
+ * (as described by the arguments), returns the bounding
+ * rectangle which would be required to produce that client
+ * area.
+ * <p>
+ * In other words, it returns a rectangle such that, if the
+ * receiver's bounds were set to that rectangle, the area
+ * of the receiver which is capable of displaying data
+ * (that is, not covered by the "trimmings") would be the
+ * rectangle described by the arguments (relative to the
+ * receiver's parent).
+ * </p>
+ * 
+ * @param x the desired x coordinate of the client area
+ * @param y the desired y coordinate of the client area
+ * @param width the desired width of the client area
+ * @param height the desired height of the client area
+ * @return the required bounds to produce the given client area
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getClientArea
+ */
+public Rectangle computeTrim (int x, int y, int width, int height) {
+    checkWidget();
+    if (scrollView !is null) {
+        NSSize size = new NSSize();
+        size.width = width;
+        size.height = height;
+        int border = hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder;
+        size = NSScrollView.frameSizeForContentSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, border);
+        width = (int)size.width;
+        height = (int)size.height;
+        NSRect frame = scrollView.contentView().frame();
+        x -= frame.x;
+        y -= frame.y;
+    }
+    return new Rectangle (x, y, width, height);
+}
+
+ScrollBar createScrollBar (int style) {
+    if (scrollView is null) return null;
+    ScrollBar bar = new ScrollBar ();
+    bar.parent = this;
+    bar.style = style;
+    bar.display = display;
+    NSScroller scroller;
+    int actionSelector;
+    if ((style & DWT.H_SCROLL) !is 0) {
+        scroller = scrollView.horizontalScroller();
+        actionSelector = OS.sel_sendHorizontalSelection;
+    } else {
+        scroller = scrollView.verticalScroller();
+        actionSelector = OS.sel_sendVerticalSelection;
+    }
+    bar.view = scroller;
+    bar.createJNIRef();
+    scroller.setTag(bar.jniRef);
+    if ((state & CANVAS) is 0) {
+        bar.target = scroller.target();
+        bar.actionSelector = scroller.action();
+    }
+    scroller.setTarget(scrollView);
+    scroller.setAction(actionSelector);
+    return bar;
+}
+
+void createWidget () {
+    super.createWidget ();
+    if ((style & DWT.H_SCROLL) !is 0) horizontalBar = createScrollBar (DWT.H_SCROLL);
+    if ((style & DWT.V_SCROLL) !is 0) verticalBar = createScrollBar (DWT.V_SCROLL);
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data (that is,
+ * not covered by the "trimmings").
+ * 
+ * @return the client area
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #computeTrim
+ */
+public Rectangle getClientArea () {
+    checkWidget();
+    if (scrollView !is null) {
+        NSSize size = scrollView.contentSize();
+        return new Rectangle(0, 0, (int)size.width, (int)size.height);
+    } else {
+        NSRect rect = view.bounds();
+        return new Rectangle(0, 0, (int)rect.width, (int)rect.height);
+    }
+}
+
+/**
+ * Returns the receiver's horizontal scroll bar if it has
+ * one, and null if it does not.
+ *
+ * @return the horizontal scroll bar (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ScrollBar getHorizontalBar () {
+    checkWidget();
+    return horizontalBar;
+}
+
+/**
+ * Returns the receiver's vertical scroll bar if it has
+ * one, and null if it does not.
+ *
+ * @return the vertical scroll bar (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ScrollBar getVerticalBar () {
+    checkWidget();
+    return verticalBar;
+}
+
+bool hooksKeys () {
+    return hooks (DWT.KeyDown) || hooks (DWT.KeyUp) || hooks (DWT.Traverse);
+}
+
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (scrollView !is null)  {
+        scrollView.setTag(-1);
+        scrollView.release();
+    }
+    scrollView = null;
+}
+
+void releaseChildren (bool destroy) {
+    if (horizontalBar !is null) {
+        horizontalBar.release (false);
+        horizontalBar = null;
+    }
+    if (verticalBar !is null) {
+        verticalBar.release (false);
+        verticalBar = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void resizeClientArea () {
+//  if (scrolledHandle is 0) return;
+//  if ((state & CANVAS) is 0) return;
+//  int vWidth = 0, hHeight = 0;
+//  int [] outMetric = new int [1];
+//  OS.GetThemeMetric (OS.kThemeMetricScrollBarWidth, outMetric);
+//  bool isVisibleHBar = horizontalBar !is null && horizontalBar.getVisible ();
+//  bool isVisibleVBar = verticalBar !is null && verticalBar.getVisible ();
+//  if (isVisibleHBar) hHeight = outMetric [0];
+//  if (isVisibleVBar) vWidth = outMetric [0];
+//  int width, height;
+//  CGRect rect = new CGRect (); 
+//  OS.HIViewGetBounds (scrolledHandle, rect);
+//  width = (int) rect.width;
+//  height = (int) rect.height;
+//  Rect inset = inset ();
+//  width = Math.max (0, width - vWidth - inset.left - inset.right);
+//  height = Math.max (0, height - hHeight - inset.top - inset.bottom);
+//  setBounds (handle, inset.left, inset.top, width, height, true, true, false);
+//  if (isVisibleHBar) {
+//      setBounds (horizontalBar.handle, inset.left, inset.top + height, width, hHeight, true, true, false);
+//  }
+//  if (isVisibleVBar) {
+//      setBounds (verticalBar.handle, inset.left + width, inset.top, vWidth, height, true, true, false);
+//  }
+}
+
+void sendHorizontalSelection () {
+    horizontalBar.sendSelection ();
+}
+
+bool sendMouseWheel (short wheelAxis, int wheelDelta) {
+//  if ((state & CANVAS) !is 0) {
+//      ScrollBar bar = wheelAxis is OS.kEventMouseWheelAxisX ? horizontalBar : verticalBar;
+//      if (bar !is null && bar.getEnabled ()) {
+//          bar.setSelection (Math.max (0, bar.getSelection () - bar.getIncrement () * wheelDelta));
+//          Event event = new Event ();
+//          event.detail = wheelDelta > 0 ? DWT.PAGE_UP : DWT.PAGE_DOWN;    
+//          bar.sendEvent (DWT.Selection, event);
+//          return true;
+//      }
+//  }
+    return false;
+}
+
+void sendVerticalSelection () {
+    verticalBar.sendSelection ();
+}
+
+bool setScrollBarVisible (ScrollBar bar, bool visible) {
+    if (scrollView is null) return false;
+    if ((state & CANVAS) is 0) return false;
+    if (visible) {
+        if ((bar.state & HIDDEN) is 0) return false;
+        bar.state &= ~HIDDEN;
+    } else {
+        if ((bar.state & HIDDEN) !is 0) return false;
+        bar.state |= HIDDEN;
+    }
+    resizeClientArea ();
+//  setVisible (bar.handle, visible);
+    bar.sendEvent (visible ? DWT.Show : DWT.Hide);
+    sendEvent (DWT.Resize);
+    return true;
+}
+
+NSView topView () {
+    if (scrollView !is null) return scrollView;
+    return super.topView ();
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Shell.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1378 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Shell;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ShellListener;
+import dwt.graphics.Cursor;
+import dwt.graphics.GC;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.graphics.Region;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScrollView;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTWindow;
+import dwt.internal.cocoa.SWTWindowDelegate;
+
+/**
+ * Instances of this class represent the "windows"
+ * which the desktop or "window manager" is managing.
+ * Instances that do not have a parent (that is, they
+ * are built using the constructor, which takes a 
+ * <code>Display</code> as the argument) are described
+ * as <em>top level</em> shells. Instances that do have
+ * a parent are described as <em>secondary</em> or
+ * <em>dialog</em> shells.
+ * <p>
+ * Instances are always displayed in one of the maximized, 
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized 
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p><p>
+ * The <em>modality</em> of an instance may be specified using
+ * style bits. The modality style bits are used to determine
+ * whether input is blocked for other shells on the display.
+ * The <code>PRIMARY_MODAL</code> style allows an instance to block
+ * input to its parent. The <code>APPLICATION_MODAL</code> style
+ * allows an instance to block input to every other shell in the
+ * display. The <code>SYSTEM_MODAL</code> style allows an instance
+ * to block input to all shells, including shells belonging to
+ * different applications.
+ * </p><p>
+ * Note: The styles supported by this class are treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations
+ * and modality. For example, some window managers only
+ * support resizable windows and will always assume the
+ * RESIZE style, even if it is not set. In addition, if a
+ * modality style is not supported, it is "upgraded" to a
+ * more restrictive modality style that is supported. For
+ * example, if <code>PRIMARY_MODAL</code> is not supported,
+ * it would be upgraded to <code>APPLICATION_MODAL</code>.
+ * A modality style may also be "downgraded" to a less
+ * restrictive style. For example, most operating systems
+ * no longer support <code>SYSTEM_MODAL</code> because
+ * it can freeze up the desktop, so this is typically
+ * downgraded to <code>APPLICATION_MODAL</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
+ * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
+ * </dl>
+ * Class <code>DWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that 
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that 
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * </p>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS, 
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see DWT
+ */
+public class Shell extends Decorations {
+    NSWindow window;
+    SWTWindowDelegate windowDelegate;
+    bool opened, moved, resized, fullScreen;
+//  bool resized, moved, drawing, reshape, update, deferDispose, active, disposed, opened, fullScreen;
+    Control lastActive;
+    Region region;
+    Rectangle normalBounds;
+
+    static int DEFAULT_CLIENT_WIDTH = -1;
+    static int DEFAULT_CLIENT_HEIGHT = -1;
+
+/**
+ * Constructs a new instance of this class. This is equivalent
+ * to calling <code>Shell((Display) null)</code>.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell () {
+    this ((Display) null);
+}
+
+/**
+ * Constructs a new instance of this class given only the style
+ * value describing its behavior and appearance. This is equivalent
+ * to calling <code>Shell((Display) null, style)</code>.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param style the style of control to construct
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see DWT#BORDER
+ * @see DWT#CLOSE
+ * @see DWT#MIN
+ * @see DWT#MAX
+ * @see DWT#RESIZE
+ * @see DWT#TITLE
+ * @see DWT#NO_TRIM
+ * @see DWT#SHELL_TRIM
+ * @see DWT#DIALOG_TRIM
+ * @see DWT#MODELESS
+ * @see DWT#PRIMARY_MODAL
+ * @see DWT#APPLICATION_MODAL
+ * @see DWT#SYSTEM_MODAL
+ */
+public Shell (int style) {
+    this ((Display) null, style);
+}
+
+/**
+ * Constructs a new instance of this class given only the display
+ * to create it on. It is created with style <code>DWT.SHELL_TRIM</code>.
+ * <p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of DWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell (Display display) {
+    this (display, DWT.SHELL_TRIM);
+}
+
+/**
+ * Constructs a new instance of this class given the display
+ * to create it on and a style value describing its behavior
+ * and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of DWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ * @param style the style of control to construct
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see DWT#BORDER
+ * @see DWT#CLOSE
+ * @see DWT#MIN
+ * @see DWT#MAX
+ * @see DWT#RESIZE
+ * @see DWT#TITLE
+ * @see DWT#NO_TRIM
+ * @see DWT#SHELL_TRIM
+ * @see DWT#DIALOG_TRIM
+ * @see DWT#MODELESS
+ * @see DWT#PRIMARY_MODAL
+ * @see DWT#APPLICATION_MODAL
+ * @see DWT#SYSTEM_MODAL
+ */
+public Shell (Display display, int style) {
+    this (display, null, style, 0, false);
+}
+
+Shell (Display display, Shell parent, int style, int handle, bool embedded) {
+    super ();
+    checkSubclass ();
+    if (display is null) display = Display.getCurrent ();
+    if (display is null) display = Display.getDefault ();
+    if (!display.isValidThread ()) {
+        error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    }
+    if (parent !is null && parent.isDisposed ()) {
+        error (DWT.ERROR_INVALID_ARGUMENT); 
+    }
+    this.style = checkStyle (style);
+    this.parent = parent;
+    this.display = display;
+    if (handle !is 0) {
+        if (embedded) {
+            view = new NSView(handle);
+        } else {
+            window = new NSWindow(handle);
+            state |= FOREIGN_HANDLE;
+        }
+    }
+    createWidget ();
+}
+
+/**
+ * Constructs a new instance of this class given only its
+ * parent. It is created with style <code>DWT.DIALOG_TRIM</code>.
+ * <p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of DWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell (Shell parent) {
+    this (parent, DWT.DIALOG_TRIM);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of DWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see DWT#BORDER
+ * @see DWT#CLOSE
+ * @see DWT#MIN
+ * @see DWT#MAX
+ * @see DWT#RESIZE
+ * @see DWT#TITLE
+ * @see DWT#NO_TRIM
+ * @see DWT#SHELL_TRIM
+ * @see DWT#DIALOG_TRIM
+ * @see DWT#ON_TOP
+ * @see DWT#TOOL
+ * @see DWT#MODELESS
+ * @see DWT#PRIMARY_MODAL
+ * @see DWT#APPLICATION_MODAL
+ * @see DWT#SYSTEM_MODAL
+ */
+public Shell (Shell parent, int style) {
+    this (parent !is null ? parent.display : null, parent, style, 0, false);
+}
+
+public static Shell internal_new (Display display, int handle) {
+    return new Shell (display, null, DWT.NO_TRIM, handle, false);
+}
+
+static int checkStyle (int style) {
+    style = Decorations.checkStyle (style);
+    style &= ~DWT.TRANSPARENT;
+    int mask = DWT.SYSTEM_MODAL | DWT.APPLICATION_MODAL | DWT.PRIMARY_MODAL;
+    int bits = style & ~mask;
+    if ((style & DWT.SYSTEM_MODAL) !is 0) return bits | DWT.SYSTEM_MODAL;
+    if ((style & DWT.APPLICATION_MODAL) !is 0) return bits | DWT.APPLICATION_MODAL;
+    if ((style & DWT.PRIMARY_MODAL) !is 0) return bits | DWT.PRIMARY_MODAL;
+    return bits;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when operations are performed on the receiver,
+ * by sending the listener one of the messages defined in the
+ * <code>ShellListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ShellListener
+ * @see #removeShellListener
+ */
+public void addShellListener(ShellListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener(DWT.Activate,typedListener);
+    addListener(DWT.Close,typedListener);
+    addListener(DWT.Deactivate,typedListener);
+    addListener(DWT.Iconify,typedListener);
+    addListener(DWT.Deiconify,typedListener);
+}
+
+void bringToTop (bool force) {
+    if (getMinimized ()) return;
+    if (force) {
+        forceActive ();
+    } else {
+        setActive ();
+    }
+}
+
+void checkOpen () {
+    if (!opened) resized = false;
+}
+
+/**
+ * Requests that the window manager close the receiver in
+ * the same way it would be closed when the user clicks on
+ * the "close box" or performs some other platform specific
+ * key or mouse combination that indicates the window
+ * should be removed.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DWT#Close
+ * @see #dispose
+ */
+public void close () {
+    checkWidget();
+    closeWidget ();
+}
+
+void closeWidget () {
+    Event event = new Event ();
+    sendEvent (DWT.Close, event);
+    if (event.doit && !isDisposed ()) dispose ();
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+    checkWidget();
+    Rectangle trim = super.computeTrim(x, y, width, height);
+    NSRect rect = new NSRect ();
+    rect.x = trim.x;
+    rect.y = trim.y;
+    rect.width = trim.width;
+    rect.height = trim.height;
+    rect = NSWindow.static_frameRectForContentRect_styleMask_(rect, window.styleMask());
+    return new Rectangle ((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+void createHandle () {
+    state |= CANVAS;// | GRAB | HIDDEN;
+    if (window !is null) {
+        view = window.contentView();
+        return;
+    } else {
+        SWTWindow swtWindow = (SWTWindow) new SWTWindow ().alloc ();
+        swtWindow.setTag(jniRef);
+        window = (NSWindow)swtWindow;
+        NSRect rect = new NSRect();
+        Monitor monitor = getMonitor ();
+        Rectangle clientArea = monitor.getClientArea ();
+        rect.width = clientArea.width * 5 / 8;
+        rect.height = clientArea.height * 5 / 8;
+        int styleMask = OS.NSBorderlessWindowMask;
+        if ((style & DWT.NO_TRIM) is 0) {
+            styleMask = OS.NSTitledWindowMask;
+            if ((style & DWT.CLOSE) !is 0) styleMask |= OS.NSClosableWindowMask;
+            if ((style & DWT.MIN) !is 0) styleMask |= OS.NSMiniaturizableWindowMask;
+            if ((style & DWT.MAX) !is 0) styleMask |= OS.NSResizableWindowMask;
+            if ((style & DWT.RESIZE) !is 0) styleMask |= OS.NSResizableWindowMask;
+        }
+        window = window.initWithContentRect_styleMask_backing_defer_(rect, styleMask, OS.NSBackingStoreBuffered, false);
+        display.cascade = window.cascadeTopLeftFromPoint(display.cascade);
+        if ((style & DWT.ON_TOP) !is 0) {
+            window.setLevel(OS.NSFloatingWindowLevel);
+        }
+    }
+    
+    createHandle (null);
+    
+    window.setContentView (topView());
+    windowDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init();
+    windowDelegate.setTag(jniRef);
+    window.setDelegate(windowDelegate);
+}
+
+void destroyWidget () {
+    NSWindow window = this.window;
+    releaseHandle ();
+    if (window !is null) window.close();
+}
+
+Control findBackgroundControl () {
+    return background !is null || backgroundImage !is null ? this : null;
+}
+
+Composite findDeferredControl () {
+    return layoutCount > 0 ? this : null;
+}
+
+Cursor findCursor () {
+    return cursor;
+}
+
+void fixShell (Shell newShell, Control control) {
+    if (this is newShell) return;
+//  if (control is lastActive) setActiveControl (null);
+}
+
+void flagsChanged(int theEvent) {
+    Display display = this.display;
+    NSEvent nsEvent = new NSEvent(theEvent);
+    int modifiers = nsEvent.modifierFlags();
+    int lastModifiers = display.lastModifiers;
+//  int chord = OS.GetCurrentEventButtonState ();
+    int type = DWT.KeyUp;   
+    if ((modifiers & OS.NSAlphaShiftKeyMask) !is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) is 0) type = DWT.KeyDown;
+    if ((modifiers & OS.NSAlternateKeyMask) !is 0 && (lastModifiers & OS.NSAlternateKeyMask) is 0) type = DWT.KeyDown;
+    if ((modifiers & OS.NSShiftKeyMask) !is 0 && (lastModifiers & OS.NSShiftKeyMask) is 0) type = DWT.KeyDown;
+    if ((modifiers & OS.NSControlKeyMask) !is 0 && (lastModifiers & OS.NSControlKeyMask) is 0) type = DWT.KeyDown;
+    if ((modifiers & OS.NSCommandKeyMask) !is 0 && (lastModifiers & OS.NSCommandKeyMask) is 0) type = DWT.KeyDown;
+    Control target = display.getFocusControl();
+    if (type is DWT.KeyUp && (modifiers & OS.NSAlphaShiftKeyMask) is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) !is 0) {
+        if (target !is null) {
+            Event event = new Event ();
+            event.keyCode = DWT.CAPS_LOCK;
+    //      setInputState (event, DWT.KeyDown, chord, modifiers);
+            target.sendKeyEvent (DWT.KeyDown, event);
+        }
+    }
+    Event event = new Event ();
+//  setInputState (event, type, chord, modifiers);
+    if (event.keyCode is 0 && event.character is 0) return;
+    bool result = sendKeyEvent (type, event);
+    if (type is DWT.KeyDown && (modifiers & OS.NSAlphaShiftKeyMask) !is 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) is 0) {
+        if (target !is null) {
+            event = new Event ();
+            event.keyCode = DWT.CAPS_LOCK;
+    //      setInputState (event, DWT.KeyUp, chord, modifiers);
+            target.sendKeyEvent (DWT.KeyUp, event);
+        }
+    }
+    display.lastModifiers = modifiers;
+}
+
+/**
+ * If the receiver is visible, moves it to the top of the 
+ * drawing order for the display on which it was created 
+ * (so that all other shells on that display, which are not 
+ * the receiver's children will be drawn behind it) and forces 
+ * the window manager to make the shell active.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton(Button)
+ * @see Shell#open
+ * @see Shell#setActive
+ */
+public void forceActive () {
+    checkWidget ();
+    if (!isVisible ()) return;
+//  OS.SelectWindow (shellHandle);
+//  OS.SetFrontProcessWithOptions (new int [] {0, OS.kCurrentProcess}, OS.kSetFrontProcessFrontWindowOnly);
+}
+
+public int getAlpha () {
+    checkWidget ();
+    return (int)(window.alphaValue() * 255);
+}
+
+public Rectangle getBounds () {
+    checkWidget();
+    NSRect frame = window.frame ();
+    return new Rectangle ((int)frame.x, (int) frame.y, (int) frame.width, (int) frame.height);
+}
+
+public Rectangle getClientArea () {
+    checkWidget();
+    //TODO why super implementation fails
+    NSRect rect = window.contentRectForFrameRect_(window.frame());
+    int width = (int)rect.width, height = (int)rect.height;
+    if (scrollView !is null) {
+        NSSize size = new NSSize();
+        size.width = width;
+        size.height = height;
+        size = NSScrollView.contentSizeForFrameSize(size, (style & DWT.H_SCROLL) !is 0, (style & DWT.V_SCROLL) !is 0, OS.NSNoBorder);
+        width = (int)size.width;
+        height = (int)size.height;
+    }
+    return new Rectangle (0, 0, width, height);
+}
+
+int getDrawCount (int control) {
+    if (!isTrimHandle (control)) return drawCount;
+    return 0;
+}
+
+public bool getFullScreen () {
+    checkWidget();
+    return fullScreen;
+}
+
+/**
+ * Returns the receiver's input method editor mode. This
+ * will be the result of bitwise OR'ing together one or
+ * more of the following constants defined in class
+ * <code>DWT</code>:
+ * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 
+ * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
+ *
+ * @return the IME mode
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DWT
+ */
+public int getImeInputMode () {
+    checkWidget();
+    return DWT.NONE;
+}
+
+public Point getLocation () {
+    checkWidget();
+    NSRect frame = window.frame ();
+    return new Point ((int) frame.x, (int) frame.y);
+}
+
+public bool getMaximized () {
+    checkWidget();
+    //NOT DONE
+    return !fullScreen && super.getMaximized ();
+}
+
+public bool getMinimized () {
+    checkWidget();
+    if (!getVisible ()) return super.getMinimized ();
+//  return OS.IsWindowCollapsed (shellHandle);
+    return false;
+}
+
+/**
+ * Returns a point describing the minimum receiver's size. The
+ * x coordinate of the result is the minimum width of the receiver.
+ * The y coordinate of the result is the minimum height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Point getMinimumSize () {
+    checkWidget();
+//  Rect rect = new Rect ();
+//  OS.GetWindowStructureWidths (shellHandle, rect);
+//  CGPoint inMinLimits = new CGPoint (), inMaxLimits = new CGPoint ();
+//  OS.GetWindowResizeLimits (shellHandle, inMinLimits, inMaxLimits);
+//  int width = Math.max (1, (int) inMinLimits.x + (rect.left + rect.right));
+//  int height = Math.max (1, (int) inMinLimits.y + (rect.top + rect.bottom));
+//  return new Point (width, height);
+    return null;
+}
+
+float [] getParentBackground () {
+    return null;
+}
+
+/** 
+ * Returns the region that defines the shape of the shell,
+ * or null if the shell has the default shape.
+ *
+ * @return the region that defines the shape of the shell (or null)
+ *  
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ *
+ */
+public Region getRegion () {
+    /* This method is needed for the @since 3.0 Javadoc */
+    checkWidget ();
+    return region;
+}
+
+public Shell getShell () {
+    checkWidget();
+    return this;
+}
+
+/**
+ * Returns an array containing all shells which are 
+ * descendants of the receiver.
+ * <p>
+ * @return the dialog shells
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Shell [] getShells () {
+    checkWidget();
+    int count = 0;
+    Shell [] shells = display.getShells ();
+    for (int i=0; i<shells.length; i++) {
+        Control shell = shells [i];
+        do {
+            shell = shell.parent;
+        } while (shell !is null && shell !is this);
+        if (shell is this) count++;
+    }
+    int index = 0;
+    Shell [] result = new Shell [count];
+    for (int i=0; i<shells.length; i++) {
+        Control shell = shells [i];
+        do {
+            shell = shell.parent;
+        } while (shell !is null && shell !is this);
+        if (shell is this) {
+            result [index++] = shells [i];
+        }
+    }
+    return result;
+}
+
+public Point getSize () {
+    checkWidget();
+    NSRect frame = window.frame ();
+    return new Point ((int) frame.width, (int) frame.height);
+}
+
+bool hasBorder () {
+    return false;
+}
+
+void helpRequested(int theEvent) {
+    Control control = display.getFocusControl();
+    while (control !is null) {
+        if (control.hooks (DWT.Help)) {
+            control.postEvent (DWT.Help);
+            break;
+        }
+        control = control.parent;
+    }
+}
+
+public bool isEnabled () {
+    checkWidget();
+    return getEnabled ();
+}
+
+bool isEnabledCursor () {
+    return true;
+}
+
+public bool isVisible () {
+    checkWidget();
+    return getVisible ();
+}
+
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it), marks it visible,
+ * sets the focus and asks the window manager to make the
+ * shell active.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton(Button)
+ * @see Shell#setActive
+ * @see Shell#forceActive
+ */
+public void open () {
+    checkWidget();
+    setWindowVisible (true, true);
+    if (isDisposed ()) return;
+//  if (active) {
+        if (!restoreFocus () && !traverseGroup (true)) setFocus ();
+//  }
+}
+
+public bool print (GC gc) {
+    checkWidget ();
+    if (gc is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+//  int [] outImage = new int [1];
+//  CGRect outFrame = new CGRect ();
+//  if (OS.HIViewCreateOffscreenImage (handle, 0, outFrame, outImage) is OS.noErr) {
+//      int width = OS.CGImageGetWidth (outImage [0]);
+//      int height = OS.CGImageGetHeight (outImage [0]);
+//      CGRect rect = new CGRect();
+//      rect.width = width;
+//      rect.height = height;
+//      //TODO - does not draw the browser (cocoa widgets?)
+//      OS.HIViewDrawCGImage (gc.handle, rect, outImage [0]);
+//      OS.CGImageRelease (outImage [0]);
+//  }
+//  return true;
+    return false;
+}
+
+void releaseChildren (bool destroy) {
+    Shell [] shells = getShells ();
+    for (int i=0; i<shells.length; i++) {
+        Shell shell = shells [i];
+        if (shell !is null && !shell.isDisposed ()) {
+            shell.dispose ();
+        }
+    }
+    super.releaseChildren (destroy);
+}
+
+void releaseHandle () {
+    window.setDelegate(null);
+    if (windowDelegate !is null) windowDelegate.release();
+    windowDelegate = null;
+    super.releaseHandle ();
+    window = null;
+}
+
+void releaseParent () {
+    /* Do nothing */
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+//  disposed = true;
+    lastActive = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when operations are performed on the receiver.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ShellListener
+ * @see #addShellListener
+ */
+public void removeShellListener(ShellListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Activate, listener);
+    eventTable.unhook(DWT.Close, listener);
+    eventTable.unhook(DWT.Deactivate, listener);
+    eventTable.unhook(DWT.Iconify,listener);
+    eventTable.unhook(DWT.Deiconify,listener);
+}
+
+/**
+ * If the receiver is visible, moves it to the top of the 
+ * drawing order for the display on which it was created 
+ * (so that all other shells on that display, which are not 
+ * the receiver's children will be drawn behind it) and asks 
+ * the window manager to make the shell active 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton(Button)
+ * @see Shell#open
+ * @see Shell#setActive
+ */
+public void setActive () {
+    checkWidget ();
+    if (!isVisible ()) return;
+//  OS.SelectWindow (shellHandle);
+}
+
+void setActiveControl (Control control) {
+    if (control !is null && control.isDisposed ()) control = null;
+    if (lastActive !is null && lastActive.isDisposed ()) lastActive = null;
+    if (lastActive is control) return;
+    
+    /*
+    * Compute the list of controls to be activated and
+    * deactivated by finding the first common parent
+    * control.
+    */
+    Control [] activate = (control is null) ? new Control[0] : control.getPath ();
+    Control [] deactivate = (lastActive is null) ? new Control[0] : lastActive.getPath ();
+    lastActive = control;
+    int index = 0, length = Math.min (activate.length, deactivate.length);
+    while (index < length) {
+        if (activate [index] !is deactivate [index]) break;
+        index++;
+    }
+    
+    /*
+    * It is possible (but unlikely), that application
+    * code could have destroyed some of the widgets. If
+    * this happens, keep processing those widgets that
+    * are not disposed.
+    */
+    for (int i=deactivate.length-1; i>=index; --i) {
+        if (!deactivate [i].isDisposed ()) {
+            deactivate [i].sendEvent (DWT.Deactivate);
+        }
+    }
+    for (int i=activate.length-1; i>=index; --i) {
+        if (!activate [i].isDisposed ()) {
+            activate [i].sendEvent (DWT.Activate);
+        }
+    }
+}
+
+public void setAlpha (int alpha) {
+    checkWidget ();
+    alpha &= 0xFF;
+    window.setAlphaValue (alpha / 255f);
+}
+
+int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+//  if (fullScreen) setFullScreen (false);
+    if (move && resize) {
+        NSRect rect = new NSRect ();
+        rect.x = x;
+        //TODO - get the screen for the point
+        int screenHeight = (int) window.screen().frame().height;
+        rect.y = screenHeight - y;
+        rect.width = width;
+        rect.height = height;
+        window.setFrame_display_(rect, false);
+    } else {
+        if (move) {
+            NSPoint point = new NSPoint();
+            point.x = x;
+            //TODO - get the screen for the point
+            int screenHeight = (int) window.screen().frame().height;
+            point.y = screenHeight - y;
+            window.setFrameTopLeftPoint (point);
+        } else {
+            if (resize) {
+                NSRect rect = window.frame();
+                rect.width = width;
+                rect.height = height;
+                window.setFrame_display_(rect, false);
+            }
+        }
+    }
+    return 0;
+}
+
+public void setEnabled (bool enabled) {
+    checkWidget();
+    if (((state & DISABLED) is 0) is enabled) return;
+    super.setEnabled (enabled);
+//  if (enabled && OS.IsWindowActive (shellHandle)) {
+//      if (!restoreFocus ()) traverseGroup (false);
+//  }
+}
+
+public void setFullScreen (bool fullScreen) {
+    checkWidget ();
+    this.fullScreen = fullScreen; 
+//  if (fullScreen) {
+//      normalBounds = getBounds ();
+//      OS.ChangeWindowAttributes (shellHandle, OS.kWindowNoTitleBarAttribute, OS.kWindowResizableAttribute | OS.kWindowLiveResizeAttribute);
+//      updateSystemUIMode ();
+//      Rectangle screen = getMonitor ().getBounds ();
+//      if (menuBar !is null && getMonitor ().equals(display.getPrimaryMonitor ())) {
+//          Rect rect = new Rect ();
+//          int gdevice = OS.GetMainDevice ();
+//          OS.GetAvailableWindowPositioningBounds (gdevice, rect);
+//          screen.height -= rect.top;
+//          screen.y += rect.top;
+//      }
+//      Rect rect = new Rect ();
+//      OS.SetRect (rect, (short) screen.x, (short) screen.y, (short) (screen.x + screen.width), (short) (screen.y + screen.height));
+//      OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect);
+//  } else {
+//      int attributes = 0;
+//      if ((style & DWT.RESIZE) !is 0) {
+//          attributes |= OS.kWindowResizableAttribute;
+//          /*
+//          * Bug in the Macintosh.  For some reason, a window has no title bar
+//          * and the kWindowResizableAttribute, no rubber banding feedback is
+//          * given while the window is resizing.  The fix is to create the window 
+//          * with kWindowLiveResizeAttribute in this case.  This is inconsistent
+//          * with other windows, but the user will get feedback when resizing.
+//          */
+//          if ((style & DWT.TITLE) is 0) attributes |= OS.kWindowLiveResizeAttribute;
+//          if (!OS.__BIG_ENDIAN__()) attributes |= OS.kWindowLiveResizeAttribute;
+//      }
+//      OS.ChangeWindowAttributes (shellHandle, attributes, OS.kWindowNoTitleBarAttribute);
+//      OS.SetSystemUIMode (OS.kUIModeNormal, 0);
+//      if (maximized) {
+//          setMaximized (true);
+//      } else {
+//          Rect rect = new Rect ();
+//          if (normalBounds !is null) OS.SetRect (rect, (short) normalBounds.x, (short) normalBounds.y, (short) (normalBounds.x + normalBounds.width), (short) (normalBounds.y + normalBounds.height));
+//          OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect);
+//      }
+//      normalBounds = null;
+//  }
+}
+
+public void setMenuBar (Menu menu) {
+    checkWidget();
+    super.setMenuBar (menu);
+    if (display.getActiveShell () is this) {
+        display.setMenuBar (menuBar);
+    }
+}
+
+/**
+ * Sets the input method editor mode to the argument which 
+ * should be the result of bitwise OR'ing together one or more
+ * of the following constants defined in class <code>DWT</code>:
+ * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 
+ * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
+ *
+ * @param mode the new IME mode
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DWT
+ */
+public void setImeInputMode (int mode) {
+    checkWidget();
+}
+
+public void setMaximized (bool maximized) {
+    checkWidget();
+    super.setMaximized (maximized);
+//  dwt.internal.carbon.Point pt = new dwt.internal.carbon.Point ();
+//  if (maximized) {
+//      Rect rect = new Rect ();
+//      int gdevice = OS.GetMainDevice ();
+//      OS.GetAvailableWindowPositioningBounds (gdevice, rect);
+//      pt.h = (short) (rect.right - rect.left);
+//      pt.v = (short) (rect.bottom - rect.top);
+//  }
+//  short inPartCode = (short) (maximized ? OS.inZoomOut : OS.inZoomIn);
+//  OS.ZoomWindowIdeal (shellHandle, inPartCode, pt);
+}
+
+public void setMinimized (bool minimized) {
+    checkWidget();
+    if (this.minimized is minimized) return;
+    super.setMinimized (minimized);
+//  if (!minimized && OS.IsWindowCollapsed (shellHandle)) {
+//      OS.SelectWindow (shellHandle);
+//  }
+//  OS.CollapseWindow (shellHandle, minimized);
+}
+
+/**
+ * Sets the receiver's minimum size to the size specified by the arguments.
+ * If the new minimum size is larger than the current size of the receiver,
+ * the receiver is resized to the new minimum size.
+ *
+ * @param width the new minimum width for the receiver
+ * @param height the new minimum height for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setMinimumSize (int width, int height) {
+    checkWidget();
+//  int clientWidth = 0, clientHeight = 0;
+//  int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX;
+//  if ((style & DWT.NO_TRIM) is 0 && (style & trim) !is 0) {
+//      clientWidth = DEFAULT_CLIENT_WIDTH;
+//      clientHeight = DEFAULT_CLIENT_HEIGHT;
+//  }
+//  Rect rect = new Rect ();
+//  OS.GetWindowStructureWidths (shellHandle, rect);
+//  CGPoint inMinLimits = new CGPoint (), inMaxLimits = new CGPoint ();
+//  OS.GetWindowResizeLimits (shellHandle, inMinLimits, inMaxLimits);
+//  width = Math.max (width, clientWidth + rect.left + rect.right);
+//  height = Math.max (height, clientHeight + rect.top + rect.bottom);
+//  inMinLimits.x = width - (rect.left + rect.right);
+//  inMinLimits.y = height - (rect.top + rect.bottom);
+//  OS.SetWindowResizeLimits (shellHandle, inMinLimits, inMaxLimits);
+//  Point size = getSize ();
+//  int newWidth = Math.max (size.x, width), newHeight = Math.max (size.y, height);
+//  if (newWidth !is size.x || newHeight !is size.y) setSize (newWidth, newHeight);
+}
+
+/**
+ * Sets the receiver's minimum size to the size specified by the argument.
+ * If the new minimum size is larger than the current size of the receiver,
+ * the receiver is resized to the new minimum size.
+ *
+ * @param size the new minimum size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setMinimumSize (Point size) {
+    checkWidget();
+    if (size is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setMinimumSize (size.x, size.y);
+}
+
+/**
+ * Sets the shape of the shell to the region specified
+ * by the argument.  When the argument is null, the
+ * default shape of the shell is restored.  The shell
+ * must be created with the style DWT.NO_TRIM in order
+ * to specify a region.
+ *
+ * @param region the region that defines the shape of the shell (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
+ * </ul>  
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ *
+ */
+public void setRegion (Region region) {
+    checkWidget ();
+    if ((style & DWT.NO_TRIM) is 0) return;
+    if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+//  if (region is null) {
+//      rgnRect = null;
+//  } else {
+//      if (rgnRect is null) {
+//          rgnRect = new Rect ();
+//          OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rgnRect);
+//          OS.SetRect (rgnRect, (short) 0, (short) 0, (short) (rgnRect.right - rgnRect.left), (short) (rgnRect.bottom - rgnRect.top)); 
+//      }
+//  }
+//  this.region = region;
+//  /*
+//  * Bug in the Macintosh.  Calling ReshapeCustomWindow() from a
+//  * kEventWindowDrawContent handler originating from ShowWindow()
+//  * will deadlock.  The fix is to detected this case and only call
+//  * ReshapeCustomWindow() after the default handler is done.
+//  */
+//  if (drawing) {
+//      reshape = true;
+//  } else {
+//      OS.ReshapeCustomWindow (shellHandle);
+//      redrawWidget (handle, true);
+//  }
+}
+
+public void setText (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    super.setText (string);
+    NSString str = NSString.stringWith(string);
+    window.setTitle(str);
+//  str.release();
+}
+
+public void setVisible (bool visible) {
+    checkWidget();
+    setWindowVisible (visible, false);
+}
+
+void setWindowVisible (bool visible, bool key) {
+    if (window.isVisible() is visible) return;
+    if (visible) {
+        sendEvent (DWT.Show);
+        if (isDisposed ()) return;
+        if (key) {
+            window.makeKeyAndOrderFront (null);
+        } else {
+            window.orderFront (null);
+        }
+        opened = true;
+        if (!moved) {
+            moved = true;
+            sendEvent (DWT.Move);
+            if (isDisposed ()) return;
+        }
+        if (!resized) {
+            resized = true;
+            sendEvent (DWT.Resize);
+            if (isDisposed ()) return;
+            if (layout !is null) {
+                markLayout (false, false);
+                updateLayout (false);
+            }
+        }
+    } else {
+        window.orderOut (null);
+        sendEvent (DWT.Hide);
+    }
+}
+
+void setZOrder () {
+//  if (scrolledHandle !is 0) OS.HIViewAddSubview (scrolledHandle, handle);
+}
+
+void setZOrder (Control control, bool above) {
+//  if (above) {
+//      //NOT DONE - move one window above another
+//      OS.BringToFront (shellHandle);
+//   } else {
+//      int window = control is null ? 0 : OS.GetControlOwner (control.handle);
+//      OS.SendBehind (shellHandle, window);
+//  }
+}
+
+bool traverseEscape () {
+    if (parent is null) return false;
+    if (!isVisible () || !isEnabled ()) return false;
+    close ();
+    return true;
+}
+
+void updateSystemUIMode () {
+    if (!getMonitor ().equals (display.getPrimaryMonitor ())) return;
+    bool isActive = false;
+    Shell activeShell = display.getActiveShell ();
+    Shell current = this;
+    while (current !is null) {
+        if (current.equals (activeShell)) {
+            isActive = true;
+            break;
+        }
+        current = (Shell) current.parent;
+    }
+    if (!isActive) return;
+//  if (fullScreen) {
+//      int mode = OS.kUIModeAllHidden;
+//      if (menuBar !is null) {
+//          mode = OS.kUIModeContentHidden;
+//      }
+//      OS.SetSystemUIMode (mode, 0);
+//  } else {
+//      OS.SetSystemUIMode (OS.kUIModeNormal, 0);
+//  }
+}
+
+void windowDidBecomeKey(int notification) {
+    super.windowDidBecomeKey(notification);
+    Display display = this.display;
+    display.setMenuBar (menuBar);
+    sendEvent (DWT.Activate);
+//  if (!isDisposed ()) {
+//      if (!restoreFocus () && !traverseGroup (true)) setFocus ();
+//  }
+}
+
+void windowDidMove(int notification) {
+    moved = true;
+    sendEvent(DWT.Move);
+}
+
+void windowDidResize(int notification) {
+    resized = true;
+    sendEvent (DWT.Resize);
+    if (isDisposed ()) return;
+    if (layout !is null) {
+        markLayout (false, false);
+        updateLayout (false);
+    }
+}
+
+void windowDidResignKey(int notification) {
+    super.windowDidResignKey(notification);
+    Display display = this.display;
+    sendEvent (DWT.Deactivate);
+    if (isDisposed ()) return;
+//  saveFocus ();
+//  if (savedFocus !is null) {
+//      /*
+//      * Bug in the Macintosh.  When ClearKeyboardFocus() is called,
+//      * the control that has focus gets two kEventControlSetFocus
+//      * events indicating that focus was lost.  The fix is to ignore
+//      * both of these and send the focus lost event explicitly.
+//      */
+//      display.ignoreFocus = true;
+//      OS.ClearKeyboardFocus (shellHandle);
+//      display.ignoreFocus = false;
+//      if (!savedFocus.isDisposed ()) savedFocus.sendFocusEvent (DWT.FocusOut, false);
+//  }
+    display.setMenuBar (null);
+}
+
+bool windowShouldClose(int window) {
+    closeWidget ();
+    return false;
+}
+
+void windowWillClose(int notification) {
+}
+
+void windowSendEvent(int id, int event) {
+    NSEvent nsEvent = new NSEvent(event);
+    int type = nsEvent.type();
+    if (type is OS.NSKeyDown || type is OS.NSKeyUp) {
+        Control eventTarget = display.getFocusControl();
+        if (eventTarget !is null) {
+            if (type is OS.NSKeyDown) {
+                bool[] consume = new bool[1];
+                int key = nsEvent.keyCode();
+                if (eventTarget.translateTraversal(key, nsEvent, consume)) return;
+                if (consume[0]) return;
+                if (eventTarget.isDisposed()) return;
+            }
+            if (!eventTarget.sendKeyEvent(nsEvent, type is OS.NSKeyDown ? DWT.KeyDown : DWT.KeyUp)) return;
+        }
+    }
+    super.windowSendEvent(id, event);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Slider.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,518 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Slider;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScroller;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTScroller;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent a range of positive, numeric values. 
+ * <p>
+ * At any given moment, a given slider will have a 
+ * single 'selection' that is considered to be its
+ * value, which is constrained to be within the range of
+ * values the slider represents (that is, between its
+ * <em>minimum</em> and <em>maximum</em> values).
+ * </p><p>
+ * Typically, sliders will be made up of five areas:
+ * <ol>
+ * <li>an arrow button for decrementing the value</li>
+ * <li>a page decrement area for decrementing the value by a larger amount</li>
+ * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
+ * <li>a page increment area for incrementing the value by a larger amount</li>
+ * <li>an arrow button for incrementing the value</li>
+ * </ol>
+ * Based on their style, sliders are either <code>HORIZONTAL</code>
+ * (which have a left facing button for decrementing the value and a
+ * right facing button for incrementing it) or <code>VERTICAL</code>
+ * (which have an upward facing button for decrementing the value
+ * and a downward facing buttons for incrementing it).
+ * </p><p>
+ * On some platforms, the size of the slider's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. DWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the slider will not change.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see ScrollBar
+ */
+public class Slider extends Control {
+    bool dragging;
+    int minimum, maximum, thumb;
+    int increment = 1;
+    int pageIncrement = 10;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#HORIZONTAL
+ * @see DWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Slider (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's value, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>DWT.NONE</code> - for the end of a drag.
+ * <code>DWT.DRAG</code>.
+ * <code>DWT.HOME</code>.
+ * <code>DWT.END</code>.
+ * <code>DWT.ARROW_DOWN</code>.
+ * <code>DWT.ARROW_UP</code>.
+ * <code>DWT.PAGE_DOWN</code>.
+ * <code>DWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's value
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = 0, height = 0;
+    if ((style & DWT.HORIZONTAL) !is 0) {
+        height = (int)NSScroller.scrollerWidth();
+        width = height * 10;
+    } else {
+        width = (int)NSScroller.scrollerWidth();
+        height = width * 10;
+    }
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    return new Point (width, height);
+}
+
+void createHandle () {
+    NSScroller widget = (NSScroller)new SWTScroller().alloc();
+    NSRect rect = new NSRect();
+    if ((style & DWT.HORIZONTAL) !is 0) {
+        rect.width = 1;
+    } else {
+        rect.height = 1;
+    }
+    widget.initWithFrame(rect);
+    widget.setEnabled(true);
+    widget.setTarget(widget);
+    widget.setAction(OS.sel_sendSelection);
+    widget.setTag(jniRef);
+    view = widget;
+    parent.contentView().addSubview_(widget);
+    updateBar(0, minimum, maximum, thumb);
+}
+
+void createWidget () {
+    maximum = 100;
+    thumb = 10;
+    super.createWidget();
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+    checkWidget();
+    return increment;
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+    checkWidget();
+    return maximum; 
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+    checkWidget();
+    return minimum;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+    checkWidget();
+    return pageIncrement;
+}
+
+/**
+ * Returns the 'selection', which is the receiver's value.
+ *
+ * @return the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+    checkWidget();
+    NSScroller widget = (NSScroller)view;
+    float value = widget.floatValue();
+    return (int)((maximum - thumb - minimum) * value + minimum);
+}
+
+/**
+ * Returns the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getThumb () {
+    checkWidget();
+    return thumb;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's value.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);
+}
+
+void sendSelection () {
+    Event event = new Event();
+    int hitPart = ((NSScroller)view).hitPart();
+    int value = getSelection ();
+    switch (hitPart) {
+        case OS.NSScrollerDecrementLine:
+            event.detail = DWT.ARROW_UP;
+            value -= increment;
+            break;
+        case OS.NSScrollerDecrementPage:
+            value -= pageIncrement;
+            event.detail = DWT.PAGE_UP;
+            break;
+        case OS.NSScrollerIncrementLine:
+            value += increment;
+            event.detail = DWT.PAGE_DOWN;
+            break;
+        case OS.NSScrollerIncrementPage:
+            value += pageIncrement;
+            event.detail = DWT.ARROW_DOWN;
+            break;
+        case OS.NSScrollerKnob:
+            event.detail = DWT.DRAG;
+            break;
+    }
+    if (event.detail !is DWT.DRAG) {
+        setSelection(value);
+    }
+    sendEvent(DWT.Selection, event);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+    checkWidget();
+    if (value < 1) return;
+    increment = value;
+}
+
+/**
+ * Sets the maximum. If this value is negative or less than or
+ * equal to the minimum, the value is ignored. If necessary, first
+ * the thumb and then the selection are adjusted to fit within the
+ * new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    if (value <= minimum) return;
+    if (value - minimum < thumb) {
+        thumb = value - minimum;
+    }
+    int selection = Math.max(minimum, Math.min (getSelection (), value - thumb));
+    this.maximum = value;
+    updateBar(selection, minimum, value, thumb);
+}
+
+/**
+ * Sets the minimum value. If this value is negative or greater
+ * than or equal to the maximum, the value is ignored. If necessary,
+ * first the thumb and then the selection are adjusted to fit within
+ * the new range.
+ *
+ * @param value the new minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+    checkWidget();
+    if (value < 0) return;
+    if (value >= maximum) return;
+    if (maximum - value < thumb) {
+        thumb = maximum - value;
+    }
+    int selection = Math.min(maximum - thumb, Math.max (getSelection (), value));
+    this.minimum = value;
+    updateBar(selection, value, maximum, thumb);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @param value the page increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+    checkWidget();
+    if (value < 1) return;
+    pageIncrement = value;
+}
+
+/**
+ * Sets the 'selection', which is the receiver's
+ * value, to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+    checkWidget();
+    updateBar(value, minimum, maximum, thumb);
+}
+
+void updateBar(int selection, int minimum, int maximum, int thumb) {
+    NSScroller widget = (NSScroller)view;
+    selection = Math.max(minimum, Math.min(maximum - thumb, selection));
+    float fraction = minimum is maximum ? 1 : (float)(selection - minimum) / (maximum - thumb - minimum);
+    float knob = minimum is maximum ? 1 : (float)(thumb - minimum) / (maximum - minimum);
+    widget.setFloatValue(fraction, knob);
+}
+
+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.  This new
+ * value will be ignored if it is less than one, and will be
+ * clamped if it exceeds the receiver's current range.
+ *
+ * @param value the new thumb value, which must be at least one and not
+ * larger than the size of the current range
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setThumb (int value) {
+    checkWidget();
+    if (value < 1) return;
+    value = Math.min (value, maximum - minimum);
+    this.thumb = value;
+    updateBar(getSelection(), minimum, maximum, value);
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is similar to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param thumb the new thumb value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+    checkWidget();
+    if (minimum < 0) return;
+    if (maximum < 0) return;
+    if (thumb < 1) return;
+    if (increment < 1) return;
+    if (pageIncrement < 1) return;
+    thumb = Math.min (thumb, maximum - minimum);
+    this.increment = increment;
+    this.pageIncrement = pageIncrement;
+    updateBar(selection, minimum, maximum, thumb);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Spinner.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,778 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Spinner;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ModifyListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.events.VerifyListener;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSStepper;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextField;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTStepper;
+import dwt.internal.cocoa.SWTTextField;
+import dwt.internal.cocoa.SWTView;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that allow the user to enter and modify numeric
+ * values.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>READ_ONLY, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, Modify, Verify</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @since 3.1
+ */
+public class Spinner extends Composite {
+    NSTextField textView;
+    NSStepper buttonView;
+    int pageIncrement = 10;
+    int digits = 0;
+    
+    static int GAP = 0;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#READ_ONLY
+ * @see DWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Spinner (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+public void addModifyListener (ModifyListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Modify, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is not called for texts.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ */
+void addVerifyListener (VerifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Verify, typedListener);
+}
+
+static int checkStyle (int style) {
+    /*
+    * Even though it is legal to create this widget
+    * with scroll bars, they serve no useful purpose
+    * because they do not automatically scroll the
+    * widget's client area.  The fix is to clear
+    * the DWT style.
+    */
+    return style & ~(DWT.H_SCROLL | DWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget ();
+    float width = 0, height = 0;
+    String string = Double.toString (buttonView.maxValue ());
+    NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity (1);
+    dict.setObject(textView.font (), OS.NSFontAttributeName ());
+    int length = string.length ();
+    char [] chars = new char [length];
+    string.getChars (0, length, chars, 0);
+    NSString nsString = NSString.stringWithCharacters (chars, length);
+    NSAttributedString str = ((NSAttributedString) new NSAttributedString ().alloc ()).initWithString_attributes_ (nsString, dict);
+    NSSize size = str.size ();
+    str.release ();
+    width = size.width;
+    height = size.height;
+    NSRect frameRect = textView.frame();
+    NSCell cell = new NSCell (textView.cell ());
+    NSRect cellRect = cell.drawingRectForBounds(frameRect);
+    width += frameRect.width - cellRect.width;
+    height += frameRect.height - cellRect.height;
+    width += GAP;
+    NSRect oldRect = buttonView.frame ();
+    buttonView.sizeToFit();
+    NSRect newRect = buttonView.frame ();
+    buttonView.setFrame (oldRect);
+    width += newRect.width;
+    height = Math.max (height, newRect.height);
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    Rectangle trim = computeTrim (0, 0, (int) width, (int) height);
+    return new Point (trim.width, trim.height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void copy () {
+    checkWidget ();
+//  short [] selection = new short [2];
+//  if (OS.GetControlData (textHandle, (short)OS.kControlEntireControl, OS.kControlEditTextSelectionTag, 4, selection, null) !is OS.noErr) return;
+//  if (selection [0] is selection [1]) return;
+//  int [] actualSize = new int [1];
+//  int [] ptr = new int [1];
+//  if (OS.GetControlData (textHandle, (short)OS.kControlEntireControl, OS.kControlEditTextCFStringTag, 4, ptr, actualSize) !is OS.noErr) return;
+//  CFRange range = new CFRange ();
+//  range.location = selection [0];
+//  range.length = selection [1] - selection [0];
+//  char [] buffer= new char [range.length];
+//  OS.CFStringGetCharacters (ptr [0], range, buffer);
+//  OS.CFRelease (ptr [0]);
+//  copyToClipboard (buffer);
+}
+
+void createHandle () {
+    SWTView widget = (SWTView)new SWTView().alloc();
+    widget.initWithFrame(new NSRect());
+//  widget.setDrawsBackground(false);
+    widget.setTag(jniRef);
+    NSStepper buttonWidget = (NSStepper)new SWTStepper().alloc();
+    buttonWidget.initWithFrame(new NSRect());
+    buttonWidget.setValueWraps((style & DWT.WRAP) !is 0);
+    buttonWidget.setTarget(buttonWidget);
+    buttonWidget.setAction(OS.sel_sendSelection);
+    buttonWidget.setTag(jniRef);
+    NSTextField textWidget = (NSTextField)new SWTTextField().alloc();
+    textWidget.initWithFrame(new NSRect());
+//  textWidget.setTarget(widget);
+    textWidget.setTag(jniRef);
+    textWidget.setEditable((style & DWT.READ_ONLY) is 0);
+    widget.addSubview_(textWidget);
+    widget.addSubview_(buttonWidget);
+    buttonView = buttonWidget;
+    textView = textWidget;
+    view = widget;  
+    parent.contentView().addSubview_(widget);
+    setSelection (0, false, true, false);
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void cut () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) return;
+//  short [] selection = new short [2];
+//  if (OS.GetControlData (textHandle, (short)OS.kControlEntireControl, OS.kControlEditTextSelectionTag, 4, selection, null) !is OS.noErr) return;
+//  if (selection [0] is selection [1]) return;
+//  char [] buffer = setText ("", selection [0], selection [1], true);
+//  if (buffer !is null) {
+//      copyToClipboard (buffer);
+//  }
+}
+
+void enableWidget (bool enabled) {
+    buttonView.setEnabled(enabled);
+    textView.setEnabled(enabled);
+}
+
+/**
+ * Returns the number of decimal places used by the receiver.
+ *
+ * @return the digits
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getDigits () {
+    checkWidget ();
+    return digits;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down arrows are pressed.
+ *
+ * @return the increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+    checkWidget ();
+    return (int)buttonView.increment();
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+    checkWidget ();
+    return (int)buttonView.maxValue();
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+    checkWidget ();
+    return (int)buttonView.minValue();
+}
+
+/**
+ * Returns the amount that the receiver's position will be
+ * modified by when the page up/down keys are pressed.
+ *
+ * @return the page increment
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+    checkWidget ();
+    return pageIncrement;
+}
+
+/**
+ * Returns the <em>selection</em>, which is the receiver's position.
+ *
+ * @return the selection 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+    checkWidget ();
+    return (int)((NSStepper)buttonView).doubleValue();
+}
+
+int getSelectionText () {
+    return -1;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void paste () {
+    checkWidget ();
+    if ((style & DWT.READ_ONLY) !is 0) return;
+//  String text = getClipboardText ();
+//  short [] selection = new short [2];
+//  if (OS.GetControlData (textHandle, (short)OS.kControlEntireControl, OS.kControlEditTextSelectionTag, 4, selection, null) !is OS.noErr) return;
+//  setText (text, selection [0], selection [1], true);
+}
+
+void releaseHandle () {
+    super.releaseHandle();
+    if (buttonView !is null) {
+        buttonView.setTag(-1);
+        buttonView.release();
+    }
+    if (textView !is null) {
+        textView.setTag(-1);
+        textView.release();
+    }
+    buttonView = null;
+    textView = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+public void removeModifyListener (ModifyListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Modify, listener);   
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #addVerifyListener
+ */
+void removeVerifyListener (VerifyListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Verify, listener);   
+}
+
+void sendSelection () { 
+    setSelection (getSelection(), false, true, true);
+}
+
+int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+    int result = super.setBounds(x, y, width, height, move, resize);
+    if ((result & RESIZED) !is 0) {
+        buttonView.sizeToFit();
+        NSRect buttonFrame = buttonView.bounds();
+        NSRect frame = view.frame();
+        buttonFrame.x = frame.width - buttonFrame.width;
+        buttonFrame.y = 0;
+        frame.x = 0;
+        frame.y = 0;
+        frame.width -= buttonFrame.width + GAP;
+        textView.setFrame(frame);
+        buttonView.setFrame(buttonFrame);
+    }
+    return result;
+}
+
+/**
+ * Sets the number of decimal places used by the receiver.
+ * <p>
+ * The digit setting is used to allow for floating point values in the receiver.
+ * For example, to set the selection to a floating point value of 1.37 call setDigits() with 
+ * a value of 2 and setSelection() with a value of 137. Similarly, if getDigits() has a value
+ * of 2 and getSelection() returns 137 this should be interpreted as 1.37. This applies to all
+ * numeric APIs. 
+ * </p>
+ * 
+ * @param value the new digits (must be greater than or equal to zero)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the value is less than zero</li>
+ * </ul> 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDigits (int value) {
+    checkWidget ();
+    if (value < 0) error (DWT.ERROR_INVALID_ARGUMENT);
+//  if (value is digits) return;
+//  digits = value;
+//  int pos = OS.GetControl32BitValue (buttonHandle);   
+//  setSelection (pos, false, true, false);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down arrows are pressed to
+ * the argument, which must be at least one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+    checkWidget ();
+    if (value < 1) return;
+    buttonView.setIncrement(value);
+}
+
+/**
+ * Sets the maximum value that the receiver will allow.  This new
+ * value will be ignored if it is not greater than the receiver's current
+ * minimum value.  If the new maximum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+    checkWidget ();
+    if (value < 0) return;
+    int min = getMinimum ();
+    if (value <= min) return;
+    int pos = getSelection();
+    buttonView.setMaxValue(value);
+    if (pos > value) setSelection (value, true, true, false);   
+}
+
+/**
+ * Sets the minimum value that the receiver will allow.  This new
+ * value will be ignored if it is negative or is not less than the receiver's
+ * current maximum value.  If the new minimum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new minimum, which must be nonnegative and less than the current maximum
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+    checkWidget ();
+    if (value < 0) return;
+    int max = getMaximum();
+    if (value >= max) return;
+    int pos = getSelection();
+    buttonView.setMinValue(value);
+    if (pos < value) setSelection (value, true, true, false);
+}
+
+/**
+ * Sets the amount that the receiver's position will be
+ * modified by when the page up/down keys are pressed
+ * to the argument, which must be at least one.
+ *
+ * @param value the page increment (must be greater than zero)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+    checkWidget ();
+    if (value < 1) return;
+    pageIncrement = value;
+}
+
+/**
+ * Sets the <em>selection</em>, which is the receiver's
+ * position, to the argument. If the argument is not within
+ * the range specified by minimum and maximum, it will be
+ * adjusted to fall within this range.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+    checkWidget ();
+    int min = getMinimum();
+    int max = getMaximum();
+    value = Math.min (Math.max (min, value), max);
+    setSelection (value, true, true, false);
+}
+
+void setSelection (int value, bool setPos, bool setText, bool notify) {
+    if (setPos) {
+        ((NSStepper)buttonView).setDoubleValue(value);
+    }
+    if (setText) {
+        String string = String.valueOf (value);
+        if (digits > 0) {
+            String decimalSeparator = ".";//getDecimalSeparator ();
+            int index = string.length () - digits;
+            StringBuffer buffer = new StringBuffer ();
+            if (index > 0) {
+                buffer.append (string.substring (0, index));
+                buffer.append (decimalSeparator);
+                buffer.append (string.substring (index));
+            } else {
+                buffer.append ("0");
+                buffer.append (decimalSeparator);
+                while (index++ < 0) buffer.append ("0");
+                buffer.append (string);
+            }
+            string = buffer.toString ();
+        }
+        NSCell cell = new NSCell(textView.cell());
+        if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+            int length = cell.title().length();
+            string = verifyText (string, 0, length, null);
+            if (string is null) return;
+        }
+        cell.setTitle(NSString.stringWith(string));
+//      short [] selection = new short [] {0, (short)string.length ()};
+//      OS.SetControlData (textHandle, (short)OS.kControlEntireControl, OS.kControlEditTextSelectionTag, 4, selection);
+        sendEvent (DWT.Modify);
+    }
+    if (notify) postEvent (DWT.Selection);
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, digits, increment and page increment all at once.
+ * <p>
+ * Note: This is similar to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param digits the new digits value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setValues (int selection, int minimum, int maximum, int digits, int increment, int pageIncrement) {
+    checkWidget ();
+    if (minimum < 0) return;
+    if (maximum <= minimum) return;
+    if (digits < 0) return;
+    if (increment < 1) return;
+    if (pageIncrement < 1) return;
+    selection = Math.min (Math.max (minimum, selection), maximum);
+    this.pageIncrement = pageIncrement;
+    this.digits = digits;
+    buttonView.setIncrement(increment);
+    buttonView.setMaxValue(maximum);
+    buttonView.setMinValue(minimum);
+    setSelection (selection, true, true, false);
+}
+
+String verifyText (String string, int start, int end, Event keyEvent) {
+    Event event = new Event ();
+    event.text = string;
+    event.start = start;
+    event.end = end;
+    if (keyEvent !is null) {
+        event.character = keyEvent.character;
+        event.keyCode = keyEvent.keyCode;
+        event.stateMask = keyEvent.stateMask;
+    }
+    int index = 0;
+    if (digits > 0) {
+        String decimalSeparator = ".";//getDecimalSeparator ();
+        index = string.indexOf (decimalSeparator);
+        if (index !is -1) {
+            string = string.substring (0, index) + string.substring (index + 1);
+        }
+        index = 0;
+    }
+    while (index < string.length ()) {
+        if (!Character.isDigit (string.charAt (index))) break;
+        index++;
+    }
+    event.doit = index is string.length (); 
+    /*
+     * It is possible (but unlikely), that application
+     * code could have disposed the widget in the verify
+     * event.  If this happens, answer null to cancel
+     * the operation.
+     */
+    sendEvent (DWT.Verify, event);
+    if (!event.doit || isDisposed ()) return null;
+    return event.text;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Synchronizer.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Synchronizer;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Device;
+import dwt.internal.Compatibility;
+ 
+/**
+ * Instances of this class provide synchronization support
+ * for displays. A default instance is created automatically
+ * for each display, and this instance is sufficient for almost
+ * all applications.
+ * <p>
+ * <b>IMPORTANT:</b> Typical application code <em>never</em>
+ * needs to deal with this class. It is provided only to
+ * allow applications which require non-standard
+ * synchronization behavior to plug in the support they
+ * require. <em>Subclasses which override the methods in 
+ * this class must ensure that the superclass methods are
+ * invoked in their implementations</em>
+ * </p>
+ *
+ * @see Display#setSynchronizer
+ */
+public class Synchronizer {
+    Display display;
+    int messageCount;
+    RunnableLock [] messages;
+    Object messageLock = new Object ();
+    Thread syncThread;
+    static final int GROW_SIZE = 4;
+    static final int MESSAGE_LIMIT = 64;
+
+    //TEMPORARY CODE
+    static final bool IS_CARBON = "carbon".equals (DWT.getPlatform ());
+
+/**
+ * Constructs a new instance of this class.
+ * 
+ * @param display the display to create the synchronizer on
+ */
+public Synchronizer (Display display) {
+    this.display = display;
+}
+    
+void addLast (RunnableLock lock) {
+    bool wake = false;
+    synchronized (messageLock) {
+        if (messages is null) messages = new RunnableLock [GROW_SIZE];
+        if (messageCount is messages.length) {
+            RunnableLock[] newMessages = new RunnableLock [messageCount + GROW_SIZE];
+            System.arraycopy (messages, 0, newMessages, 0, messageCount);
+            messages = newMessages;
+        }
+        messages [messageCount++] = lock;
+        wake = messageCount is 1;
+    }   
+    if (wake) display.wakeThread ();
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The caller of this method continues 
+ * to run in parallel, and is not notified when the
+ * runnable has completed.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @see #syncExec
+ */
+protected void asyncExec (Runnable runnable) {
+    if (runnable is null) {
+        //TEMPORARY CODE
+        if (!IS_CARBON) {
+            display.wake ();
+            return;
+        }
+    }
+    addLast (new RunnableLock (runnable));
+}
+
+int getMessageCount () {
+    synchronized (messageLock) {
+        return messageCount;
+    }
+}
+
+void releaseSynchronizer () {
+    display = null;
+    messages = null;
+    messageLock = null;
+    syncThread = null;
+}
+
+RunnableLock removeFirst () {
+    synchronized (messageLock) {
+        if (messageCount is 0) return null;
+        RunnableLock lock = messages [0];
+        System.arraycopy (messages, 1, messages, 0, --messageCount);
+        messages [messageCount] = null;
+        if (messageCount is 0) {
+            if (messages.length > MESSAGE_LIMIT) messages = null;
+        }
+        return lock;
+    }
+}
+
+bool runAsyncMessages () {
+    return runAsyncMessages (false);
+}
+
+bool runAsyncMessages (bool all) {
+    bool run = false;
+    do {
+        RunnableLock lock = removeFirst ();
+        if (lock is null) return run;
+        run = true;
+        synchronized (lock) {
+            syncThread = lock.thread;
+            try {
+                lock.run ();
+            } catch (Throwable t) {
+                lock.throwable = t;
+                DWT.error (DWT.ERROR_FAILED_EXEC, t);
+            } finally {
+                syncThread = null;
+                lock.notifyAll ();
+            }
+        }
+    } while (all);
+    return run;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+protected void syncExec (Runnable runnable) {
+    RunnableLock lock = null;
+    synchronized (Device.class) {
+        if (display is null || display.isDisposed ()) DWT.error (DWT.ERROR_DEVICE_DISPOSED);
+        if (!display.isValidThread ()) {
+            if (runnable is null) {
+                display.wake ();
+                return;
+            }
+            lock = new RunnableLock (runnable);
+            /*
+             * Only remember the syncThread for syncExec.
+             */
+            lock.thread = Thread.currentThread();
+            addLast (lock);
+        }
+    }
+    if (lock is null) {
+        if (runnable !is null) runnable.run ();
+        return;
+    }
+    synchronized (lock) {
+        bool interrupted = false;
+        while (!lock.done ()) {
+            try {
+                lock.wait ();
+            } catch (InterruptedException e) {
+                interrupted = true;
+            }
+        }
+        if (interrupted) {
+            Compatibility.interrupt();
+        }
+        if (lock.throwable !is null) {
+            DWT.error (DWT.ERROR_FAILED_EXEC, lock.throwable);
+        }
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TabFolder.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,624 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TabFolder;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSFont;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSTabView;
+import dwt.internal.cocoa.NSTabViewItem;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTTabView;
+
+/**
+ * Instances of this class implement the notebook user interface
+ * metaphor.  It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>TabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>TOP, BOTTOM</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles TOP and BOTTOM may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TabFolder extends Composite {
+    TabItem [] items;
+    int itemCount;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabFolder (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    style = checkBits (style, DWT.TOP, DWT.BOTTOM, 0, 0, 0, 0);
+    /*
+    * Even though it is legal to create this widget
+    * with scroll bars, they serve no useful purpose
+    * because they do not automatically scroll the
+    * widget's client area.  The fix is to clear
+    * the DWT style.
+    */
+    return style & ~(DWT.H_SCROLL | DWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    Point size = super.computeSize (wHint, hHint, changed);
+    if (wHint is DWT.DEFAULT && items.length > 0) {
+        NSSize mimSize = ((NSTabView)view).minimumSize();
+        Rectangle trim = computeTrim (0, 0, (int)mimSize.width, 0);
+        size.x = Math.max (trim.width, size.x);
+    }
+    return size;
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+    checkWidget ();
+//  CGRect oldBounds = new CGRect (), bounds = oldBounds;
+//  OS.HIViewGetFrame (handle, oldBounds);
+//  int MIN_SIZE = 100;
+//  if (oldBounds.width < MIN_SIZE || oldBounds.height < MIN_SIZE) {
+//      OS.HIViewSetDrawingEnabled (handle, false);
+//      bounds = new CGRect ();
+//      bounds.width = bounds.height = 100;
+//      OS.HIViewSetFrame (handle, bounds);
+//  }
+//  Rect client = new Rect ();
+//  OS.GetTabContentRect (handle, client);
+//  if (oldBounds.width < MIN_SIZE || oldBounds.height < MIN_SIZE) {
+//      OS.HIViewSetFrame (handle, oldBounds);
+//      OS.HIViewSetDrawingEnabled (handle, drawCount is 0);
+//  }
+//  x -= client.left;
+//  y -= client.top;
+//  width += (int) bounds.width - (client.right - client.left);
+//  height += (int) bounds.height - (client.bottom - client.top);
+//  Rect inset = getInset ();
+//  x -= inset.left;
+//  y -= inset.top;
+//  width += inset.left + inset.right;
+//  height += inset.top + inset.bottom;
+//  return new Rectangle (-client.left, -client.top, width, height);
+    return super.computeTrim(x, y, width, height);
+}
+
+void createHandle () {
+    SWTTabView widget = (SWTTabView)new SWTTabView().alloc();
+    widget.initWithFrame (new NSRect());
+    widget.setTag(jniRef);
+    widget.setDelegate(widget);
+    if ((style & DWT.BOTTOM) !is 0) {
+        widget.setTabViewType(OS.NSBottomTabsBezelBorder);
+    }
+    view = widget;
+    parent.contentView().addSubview_(view);
+}
+
+void createItem (TabItem item, int index) {
+    int count = itemCount;
+    if (!(0 <= index && index <= count)) error (DWT.ERROR_INVALID_RANGE);
+    if (count is items.length) {
+        TabItem [] newItems = new TabItem [items.length + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    System.arraycopy (items, index, items, index + 1, count - index);
+    items [index] = item;
+    itemCount++;
+    NSTabViewItem nsItem = (NSTabViewItem)new NSTabViewItem().alloc().init();
+    item.nsItem = nsItem;
+    ((NSTabView)view).insertTabViewItem(nsItem, index);
+}
+
+void createWidget () {
+    super.createWidget ();
+    items = new TabItem [4];
+}
+
+void destroyItem (TabItem item) {
+    int count = itemCount;
+    int index = 0;
+    while (index < count) {
+        if (items [index] is item) break;
+        index++;
+    }
+    if (index is count) return;
+    --count;
+    System.arraycopy (items, index + 1, items, index, count - index);
+    items [count] = null;
+    if (count is 0) {
+        items = new TabItem [4];
+    }
+    itemCount = count;
+    ((NSTabView)view).removeTabViewItem(item.nsItem);
+}
+
+public Rectangle getClientArea () {
+    checkWidget ();
+    NSRect rect = ((NSTabView)view).contentRect();
+    int x = Math.max (0, (int)rect.x);
+    int y = Math.max (0, (int)rect.y);
+    int width = Math.max (0, (int)rect.width);
+    int height = Math.max (0, (int)rect.height);
+    return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem getItem (int index) {
+    checkWidget ();
+    int count = itemCount;
+    if (!(0 <= index && index < count)) error (DWT.ERROR_INVALID_RANGE);
+    return items [index];
+}
+
+public TabItem getItem (Point point) {
+    checkWidget ();
+    if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
+    NSPoint nsPoint = new NSPoint ();
+    nsPoint.x = point.x;
+    nsPoint.y = point.y;
+    NSTabView tabView = (NSTabView) view;
+    NSTabViewItem tabViewItem = tabView.tabViewItemAtPoint (nsPoint);
+    for (int i = 0; i < itemCount; i++) {
+        NSTabViewItem item = items[i].nsItem;
+        if (item.isEqual (tabViewItem)) {
+            return items [i];
+        }
+    }
+    return null;
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    return itemCount;
+}
+
+/**
+ * Returns an array of <code>TabItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem [] getItems () {
+    checkWidget ();
+    int count = itemCount;
+    TabItem [] result = new TabItem [count];
+    System.arraycopy (items, 0, result, 0, count);
+    return result;
+}
+
+/**
+ * Returns an array of <code>TabItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem [] getSelection () {
+    checkWidget ();
+    int index = getSelectionIndex ();
+    if (index is -1) return new TabItem [0];
+    return new TabItem [] {items [index]};
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+    checkWidget ();
+    NSTabViewItem selected =  ((NSTabView)view).selectedTabViewItem();
+    if (selected is null) return -1;
+    for (int i = 0; i < itemCount; i++) {
+        if (items[i].nsItem.id is selected.id) return i;
+    }
+    return -1;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (TabItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int count = itemCount;
+    for (int i=0; i<count; i++) {
+        if (items [i] is item) return i;
+    }
+    return -1;
+}
+
+Point minimumSize (int wHint, int hHint, bool flushCache) {
+    Control [] children = _getChildren ();
+    int width = 0, height = 0;
+    for (int i=0; i<children.length; i++) {
+        Control child = children [i];
+        int index = 0;
+        int count = itemCount;
+        while (index < count) {
+            if (items [index].control is child) break;
+            index++;
+        }
+        if (index is count) {
+            Rectangle rect = child.getBounds ();
+            width = Math.max (width, rect.x + rect.width);
+            height = Math.max (height, rect.y + rect.height);
+        } else {
+            Point size = child.computeSize (wHint, hHint, flushCache);
+            width = Math.max (width, size.x);
+            height = Math.max (height, size.y);
+        }
+    }
+    return new Point (width, height);
+}
+
+void releaseChildren (bool destroy) {
+    if (items !is null) {
+        for (int i=0; i<items.length; i++) {
+            TabItem item = items [i];
+            if (item !is null && !item.isDisposed ()) {
+                item.release (false);
+            }
+        }
+        items = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void removeControl (Control control) {
+    super.removeControl (control);
+    int count = itemCount;
+    for (int i=0; i<count; i++) {
+        TabItem item = items [i];
+        if (item.control is control) item.setControl (null);
+    }
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+    int result = super.setBounds(x, y, width, height, move, resize);
+    if ((result & RESIZED) !is 0) {
+        int index = getSelectionIndex ();
+        if (index !is -1) {
+            TabItem item = items [index];
+            Control control = item.control;
+            if (control !is null && !control.isDisposed ()) {
+                control.setBounds (getClientArea ());
+            }
+        }
+    }
+    return result;
+}
+
+void setFont (NSFont font) {
+    ((NSTabView)view).setFont(font);
+}
+
+/**
+ * Sets the receiver's selection to the given item.
+ * The current selected is first cleared, then the new item is
+ * selected.
+ *
+ * @param item the item to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSelection (TabItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setSelection (new TabItem [] {item});
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (TabItem [] items) {
+    checkWidget ();
+    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (items.length is 0) {
+        setSelection (-1, false, false);
+    } else {
+        for (int i=items.length - 1; i>=0; --i) {
+            int index = indexOf (items [i]);
+            if (index !is -1) setSelection (index, false, false);
+        }
+    }
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains selected.
+ * The current selection is first cleared, then the new items are
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int index) {
+    checkWidget ();
+    int count = itemCount;
+    if (!(0 <= index && index < count)) return;
+    setSelection (index, false, false);
+}
+
+void setSelection (int index, bool notify, bool force) {
+    if (index >= itemCount) return;
+    int currentIndex = getSelectionIndex ();
+    if (!force && currentIndex is index) return;
+    if (currentIndex !is -1) {
+        TabItem item = items [currentIndex];
+        if (item !is null) {
+            Control control = item.control;
+            if (control !is null && !control.isDisposed ()) {
+                control.setVisible (false);
+            }
+        }
+    }
+    ((NSTabView)view).selectTabViewItemAtIndex(index);
+    index = getSelectionIndex();
+    if (index !is -1) {
+        TabItem item = items [index];
+        if (item !is null) {
+            Control control = item.control;
+            if (control !is null && !control.isDisposed ()) {
+                control.setBounds (getClientArea ());
+                control.setVisible (true);
+            }
+            if (notify) {
+                Event event = new Event ();
+                event.item = item;
+                sendEvent (DWT.Selection, event);
+            }
+        }
+    }
+}
+
+bool traversePage (bool next) {
+    int count = getItemCount ();
+    if (count is 0) return false;
+    int index = getSelectionIndex ();
+    if (index is -1) {
+        index = 0;
+    } else {
+        int offset = (next) ? 1 : -1;
+        index = (index + offset + count) % count;
+    }
+    setSelection (index, true, false);
+    return index is getSelectionIndex ();
+}
+
+void willSelectTabViewItem(int tabView, int tabViewItem) {
+    if (tabViewItem is 0) return;
+    for (int i = 0; i < itemCount; i++) {
+        TabItem item = items [i];
+        if (item.nsItem.id is tabViewItem) {
+            int currentIndex = getSelectionIndex ();
+            if (currentIndex !is -1) {
+                TabItem selected = items [currentIndex];
+                if (selected !is null) {
+                    Control control = selected.control;
+                    if (control !is null && !control.isDisposed ()) {
+                        control.setVisible (false);
+                    }
+                }
+            }
+            Control control = item.control;
+            if (control !is null && !control.isDisposed ()) {
+                control.setBounds (getClientArea ());
+                control.setVisible (true);
+            }
+            Event event = new Event ();
+            event.item = item;
+            sendEvent (DWT.Selection, event);
+        }
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TabItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,340 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TabItem;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Image;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTabViewItem;
+import dwt.internal.cocoa.NSValue;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * corresponding to a tab for a page in a tab folder.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TabItem extends Item {
+    TabFolder parent;
+    Control control;
+    String toolTipText;
+    NSTabViewItem nsItem;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabItem (TabFolder parent, int style) {
+    super (parent, style);
+    this.parent = parent;
+    parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabItem (TabFolder parent, int style, int index) {
+    super (parent, style);
+    this.parent = parent;
+    parent.createItem (this, index);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+void destroyWidget () {
+    parent.destroyItem (this);
+    releaseHandle ();
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public Rectangle getBounds() {
+    checkWidget();
+    Rectangle result = new Rectangle (0, 0, 0, 0);
+    if (nsItem.respondsToSelector (OS.sel_accessibilityAttributeValue_1)) {
+        int posValue = OS.objc_msgSend (nsItem.id, OS.sel_accessibilityAttributeValue_1, OS.NSAccessibilityPositionAttribute ());
+        int sizeValue = OS.objc_msgSend (nsItem.id, OS.sel_accessibilityAttributeValue_1, OS.NSAccessibilitySizeAttribute ());      
+        NSValue val = new NSValue (posValue);
+        NSPoint pt = val.pointValue ();
+        NSWindow window = parent.view.window ();
+        pt.y = window.screen ().frame ().height - pt.y;
+        pt = parent.view.convertPoint_fromView_ (pt, null);
+        pt = window.convertScreenToBase (pt);
+        result.x = (int) pt.x;
+        result.y = (int) pt.y;
+        val = new NSValue (sizeValue);
+        NSSize size = val.sizeValue ();
+        result.width = (int) size.width;
+        result.height = (int) size.height;
+    }
+    return result;
+}
+
+/**
+ * Returns the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.  If no
+ * control has been set, return <code>null</code>.
+ * <p>
+ * @return the control
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+    checkWidget ();
+    return control;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>TabFolder</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabFolder getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+    checkWidget ();
+    return toolTipText;
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (nsItem !is null) nsItem.release();
+    nsItem = null;
+    parent = null;
+}
+
+void releaseParent () {
+    super.releaseParent ();
+    int index = parent.indexOf (this);
+    if (index is parent.getSelectionIndex ()) {
+        if (control !is null) control.setVisible (false);
+    }
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    control = null;
+}
+
+/**
+ * Sets the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.
+ * <p>
+ * @param control the new control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+    checkWidget ();
+    if (control !is null) {
+        if (control.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (control.parent !is parent) error (DWT.ERROR_INVALID_PARENT);
+    }
+    if (this.control !is null && this.control.isDisposed ()) {
+        this.control = null;
+    }
+    Control oldControl = this.control, newControl = control;
+    this.control = control;
+    int index = parent.indexOf (this);
+    if (index !is parent.getSelectionIndex ()) {
+        if (newControl !is null) newControl.setVisible (false);
+        return;
+    }
+    if (newControl !is null) {
+//      nsItem.setView(control.topView ());
+        newControl.setBounds (parent.getClientArea ());
+        newControl.setVisible (true);
+    }
+    if (oldControl !is null) oldControl.setVisible (false);
+}
+
+public void setImage (Image image) {
+    checkWidget ();
+    int index = parent.indexOf (this);
+    if (index is -1) return;
+    super.setImage (image);
+}
+
+/**
+ * Sets the receiver's text.  The string may include
+ * the mnemonic character.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ */
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int index = parent.indexOf (this);
+    if (index is -1) return;
+    super.setText (string);
+    char [] chars = new char [string.length ()];
+    string.getChars (0, chars.length, chars, 0);
+    int length = fixMnemonic (chars);
+    NSString str = NSString.stringWithCharacters (chars, length);
+    nsItem.setLabel (str);
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+    checkWidget();
+    toolTipText = string;
+}
+
+void update () {
+    setText (text);
+    setImage (image);
+    setToolTipText (toolTipText);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Table.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,2390 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Table;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSBrowserCell;
+import dwt.internal.cocoa.NSButtonCell;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSMutableIndexSet;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableColumn;
+import dwt.internal.cocoa.NSTableHeaderView;
+import dwt.internal.cocoa.NSTableView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTScrollView;
+import dwt.internal.cocoa.SWTTableView;
+
+/** 
+ * Instances of this class implement a selectable user interface
+ * object that displays a list of images and strings and issues
+ * notification when selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableItem</code>.
+ * </p><p>
+ * Style <code>VIRTUAL</code> is used to create a <code>Table</code> whose
+ * <code>TableItem</code>s are to be populated by the client on an on-demand basis
+ * instead of up-front.  This can provide significant performance improvements for
+ * tables that are very large or for which <code>TableItem</code> population is
+ * expensive (for example, retrieving values from an external source).
+ * </p><p>
+ * Here is an example of using a <code>Table</code> with style <code>VIRTUAL</code>:
+ * <code><pre>
+ *  final Table table = new Table (parent, DWT.VIRTUAL | DWT.BORDER);
+ *  table.setItemCount (1000000);
+ *  table.addListener (DWT.SetData, new Listener () {
+ *      public void handleEvent (Event event) {
+ *          TableItem item = (TableItem) event.item;
+ *          int index = table.indexOf (item);
+ *          item.setText ("Item " + index);
+ *          System.out.println (item.getText ());
+ *      }
+ *  }); 
+ * </pre></code>
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION, VIRTUAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, SetData, MeasureItem, EraseItem, PaintItem</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Table extends Composite {
+    TableItem [] items;
+    TableColumn [] columns;
+    TableColumn sortColumn;
+    TableItem currentItem;
+    NSTableHeaderView headerView;
+    NSTableColumn firstColumn, checkColumn;
+    int columnCount, itemCount, lastIndexOf, sortDirection;
+    bool ignoreSelect;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#SINGLE
+ * @see DWT#MULTI
+ * @see DWT#CHECK
+ * @see DWT#FULL_SELECTION
+ * @see DWT#HIDE_SELECTION
+ * @see DWT#VIRTUAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Table (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has the <code>DWT.CHECK</code> style and the check selection changes,
+ * the event object detail field contains the value <code>DWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection, typedListener);
+    addListener (DWT.DefaultSelection, typedListener);
+}
+
+TableItem _getItem (int index) {
+    if ((style & DWT.VIRTUAL) is 0) return items [index];
+    if (items [index] !is null) return items [index];
+    return items [index] = new TableItem (this, DWT.NULL, -1, false);
+}
+
+bool checkData (TableItem item, bool redraw) {
+    if (item.cached) return true;
+    if ((style & DWT.VIRTUAL) !is 0) {
+        item.cached = true;
+        Event event = new Event ();
+        event.item = item;
+        event.index = indexOf (item);
+        currentItem = item;
+        sendEvent (DWT.SetData, event);
+        //widget could be disposed at this point
+        currentItem = null;
+        if (isDisposed () || item.isDisposed ()) return false;
+        if (redraw) {
+//          if (!setScrollWidth (item)) item.redraw (OS.kDataBrowserNoItem);
+        }
+    }
+    return true;
+}
+
+static int checkStyle (int style) {
+    /*
+    * Feature in Windows.  Even when WS_HSCROLL or
+    * WS_VSCROLL is not specified, Windows creates
+    * trees and tables with scroll bars.  The fix
+    * is to set H_SCROLL and V_SCROLL.
+    * 
+    * NOTE: This code appears on all platforms so that
+    * applications have consistent scroll bar behavior.
+    */
+    if ((style & DWT.NO_SCROLL) is 0) {
+        style |= DWT.H_SCROLL | DWT.V_SCROLL;
+    }
+    return checkBits (style, DWT.SINGLE, DWT.MULTI, 0, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Clears the item at the given zero-relative index in the receiver.
+ * The text, icon and other attributes of the item are set to the default
+ * value.  If the table was created with the <code>DWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param index the index of the item to clear
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clear (int index) {
+    checkWidget();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    TableItem item = items [index];
+    if (item !is null) {
+        if (currentItem !is item) item.clear ();
+        if (currentItem is null && drawCount is 0) {
+            int [] id = new int [] {index + 1};
+//          OS.UpdateDataBrowserItems (handle, 0, id.length, id, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem);
+        }
+//      setScrollWidth (item);
+    }
+}
+
+/**
+ * Removes the items from the receiver which are between the given
+ * zero-relative start and end indices (inclusive).  The text, icon
+ * and other attributes of the items are set to their default values.
+ * If the table was created with the <code>DWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param start the start index of the item to clear
+ * @param end the end index of the item to clear
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clear (int start, int end) {
+    checkWidget();
+    if (start > end) return;
+    if (!(0 <= start && start <= end && end < itemCount)) {
+        error (DWT.ERROR_INVALID_RANGE);
+    }
+    if (start is 0 && end is itemCount - 1) {
+        clearAll ();
+    } else {
+        for (int i=start; i<=end; i++) {
+            clear (i);
+        }
+    }
+}
+
+/**
+ * Clears the items at the given zero-relative indices in the receiver.
+ * The text, icon and other attributes of the items are set to their default
+ * values.  If the table was created with the <code>DWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clear (int [] indices) {
+    checkWidget();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (indices.length is 0) return;
+    for (int i=0; i<indices.length; i++) {
+        if (!(0 <= indices [i] && indices [i] < itemCount)) {
+            error (DWT.ERROR_INVALID_RANGE);
+        }
+    }
+    for (int i=0; i<indices.length; i++) {
+        clear (indices [i]);
+    }
+}
+
+/**
+ * Clears all the items in the receiver. The text, icon and other
+ * attributes of the items are set to their default values. If the
+ * table was created with the <code>DWT.VIRTUAL</code> style, these
+ * attributes are requested again as needed.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clearAll () {
+    checkWidget();
+    for (int i=0; i<itemCount; i++) {
+        TableItem item = items [i];
+        if (item !is null) item.clear ();
+    }
+    if (currentItem is null && drawCount is 0) {
+//      OS.UpdateDataBrowserItems (handle, 0, 0, null, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem);
+    }
+//  setScrollWidth (items, true);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = 0;
+    if (wHint is DWT.DEFAULT) {
+        if (columnCount !is 0) {
+            for (int i=0; i<columnCount; i++) {
+                width += columns [i].getWidth ();
+            }
+        } else {
+            int columnWidth = 0;
+            GC gc = new GC (this);
+            for (int i=0; i<itemCount; i++) {
+                TableItem item = items [i];
+                if (item !is null) {
+                    columnWidth = Math.max (columnWidth, item.calculateWidth (0, gc));
+                }
+            }
+            gc.dispose ();
+            width += columnWidth + getInsetWidth ();
+        }
+        if ((style & DWT.CHECK) !is 0) width += getCheckColumnWidth ();
+    } else {
+        width = wHint;
+    }
+    if (width <= 0) width = DEFAULT_WIDTH;
+    int height = 0;
+    if (hHint is DWT.DEFAULT) {
+        height = itemCount * getItemHeight () + getHeaderHeight();
+    } else {
+        height = hHint;
+    }
+    if (height <= 0) height = DEFAULT_HEIGHT;
+    Rectangle rect = computeTrim (0, 0, width, height);
+    return new Point (rect.width, rect.height);
+}
+
+void createHandle () {
+    //TODO - DWT.CHECK  
+    SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc();
+    scrollWidget.initWithFrame(new NSRect ());
+    scrollWidget.setHasHorizontalScroller(true);
+    scrollWidget.setHasVerticalScroller(true);
+    scrollWidget.setAutohidesScrollers(true);
+    scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder);
+    scrollWidget.setTag(jniRef);
+    
+    NSTableView widget = (NSTableView)new SWTTableView().alloc();
+    widget.initWithFrame(new NSRect());
+    widget.setAllowsMultipleSelection((style & DWT.MULTI) !is 0);
+    widget.setDataSource(widget);
+    widget.setDelegate(widget);
+    widget.setDoubleAction(OS.sel_sendDoubleSelection);
+    if (!hasBorder()) widget.setFocusRingType(OS.NSFocusRingTypeNone);
+    widget.setTag(jniRef);
+    
+    headerView = widget.headerView();
+    headerView.retain();
+    widget.setHeaderView(null);
+    
+    NSString str = NSString.stringWith("");
+    if ((style & DWT.CHECK) !is 0) {
+        checkColumn = (NSTableColumn)new NSTableColumn().alloc();
+        checkColumn.initWithIdentifier(str);
+        checkColumn.headerCell().setTitle(str);
+        widget.addTableColumn (checkColumn);
+        NSButtonCell cell = (NSButtonCell)new NSButtonCell().alloc().init();
+        checkColumn.setDataCell(cell);
+        cell.setButtonType(OS.NSSwitchButton);
+        cell.setImagePosition(OS.NSImageOnly);
+        cell.setAllowsMixedState(true);
+        cell.release();
+        checkColumn.setWidth(getCheckColumnWidth());
+        checkColumn.setResizingMask(OS.NSTableColumnNoResizing);
+        checkColumn.setEditable(false);
+    }
+
+    firstColumn = (NSTableColumn)new NSTableColumn().alloc();
+    firstColumn.initWithIdentifier(str);
+    //column.setResizingMask(OS.NSTableColumnAutoresizingMask);
+    NSCell cell = (NSBrowserCell)new NSBrowserCell().alloc().init();
+    firstColumn.setDataCell(cell);
+    cell.release();
+    widget.addTableColumn (firstColumn);
+
+    scrollView = scrollWidget;
+    view = widget;
+    scrollView.setDocumentView(widget);
+    parent.contentView().addSubview_(scrollView);
+}
+
+void createItem (TableColumn column, int index) {
+    if (!(0 <= index && index <= columnCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (columnCount is columns.length) {
+        TableColumn [] newColumns = new TableColumn [columnCount + 4];
+        System.arraycopy (columns, 0, newColumns, 0, columns.length);
+        columns = newColumns;
+    }
+    NSTableColumn nsColumn;
+    if (columnCount is 0) {
+        //TODO - clear attributes, alignment etc.
+        nsColumn = firstColumn;
+        firstColumn = null;
+    } else {
+        //TODO - set attributes, alignment etc.
+        nsColumn = (NSTableColumn)new NSTableColumn().alloc();
+        nsColumn.initWithIdentifier(NSString.stringWith(""));
+        ((NSTableView)view).addTableColumn (nsColumn);
+        int checkColumn = (style & DWT.CHECK) !is 0 ? 1 : 0;
+        ((NSTableView)view).moveColumn (columnCount + checkColumn, index + checkColumn);
+        NSCell cell = (NSBrowserCell)new NSBrowserCell().alloc().init();
+        nsColumn.setDataCell(cell);
+        cell.release();
+    }
+    column.nsColumn = nsColumn;
+    nsColumn.headerCell().setTitle(NSString.stringWith(""));
+    nsColumn.setWidth(0);
+    System.arraycopy (columns, index, columns, index + 1, columnCount++ - index);
+    columns [index] = column;
+    if (columnCount > 1) {
+        for (int i=0; i<itemCount; i++) {
+            TableItem item = items [i];
+            if (item !is null) {
+                String [] strings = item.strings;
+                if (strings !is null) {
+                    String [] temp = new String [columnCount];
+                    System.arraycopy (strings, 0, temp, 0, index);
+                    System.arraycopy (strings, index, temp, index+1, columnCount-index-1);
+                    temp [index] = "";
+                    item.strings = temp;
+                }
+                if (index is 0) item.text = "";
+                Image [] images = item.images;
+                if (images !is null) {
+                    Image [] temp = new Image [columnCount];
+                    System.arraycopy (images, 0, temp, 0, index);
+                    System.arraycopy (images, index, temp, index+1, columnCount-index-1);
+                    item.images = temp;
+                }
+                if (index is 0) item.image = null;
+                Color [] cellBackground = item.cellBackground;
+                if (cellBackground !is null) {
+                    Color [] temp = new Color [columnCount];
+                    System.arraycopy (cellBackground, 0, temp, 0, index);
+                    System.arraycopy (cellBackground, index, temp, index+1, columnCount-index-1);
+                    item.cellBackground = temp;
+                }
+                Color [] cellForeground = item.cellForeground;
+                if (cellForeground !is null) {
+                    Color [] temp = new Color [columnCount];
+                    System.arraycopy (cellForeground, 0, temp, 0, index);
+                    System.arraycopy (cellForeground, index, temp, index+1, columnCount-index-1);
+                    item.cellForeground = temp;
+                }
+                Font [] cellFont = item.cellFont;
+                if (cellFont !is null) {
+                    Font [] temp = new Font [columnCount];
+                    System.arraycopy (cellFont, 0, temp, 0, index);
+                    System.arraycopy (cellFont, index, temp, index+1, columnCount-index-1);
+                    item.cellFont = temp;
+                }
+            }
+        }
+    }
+}
+
+void createItem (TableItem item, int index) {
+    if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (itemCount is items.length) {
+        /* Grow the array faster when redraw is off */
+        int length = drawCount is 0 ? items.length + 4 : Math.max (4, items.length * 3 / 2);
+        TableItem [] newItems = new TableItem [length];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+    items [index] = item;
+    //TODO - use noteNumberOfRowsChanged?
+    ((NSTableView)view).reloadData();
+}
+
+void createWidget () {
+    super.createWidget ();
+    items = new TableItem [4];
+    columns = new TableColumn [4];
+}
+
+Color defaultBackground () {
+    return display.getSystemColor (DWT.COLOR_LIST_BACKGROUND);
+}
+
+Color defaultForeground () {
+    return display.getSystemColor (DWT.COLOR_LIST_FOREGROUND);
+}
+
+/**
+ * Deselects the item at the given zero-relative index in the receiver.
+ * If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+    checkWidget();
+    if (0 <= index && index < itemCount) {
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        widget.deselectRow (index);
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected.  The range of the
+ * indices is inclusive. Indices that are out of range are ignored.
+ *
+ * @param start the start index of the items to deselect
+ * @param end the end index of the items to deselect
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int start, int end) {
+    checkWidget();
+    //TODO - check range
+    if (start is 0 && end is itemCount - 1) {
+        deselectAll ();
+    } else {
+        int length = end - start + 1;
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        for (int i=0; i<length; i++) {
+            widget.deselectRow (i);
+        }
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to deselect
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int [] indices) {
+    checkWidget();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    for (int i=0; i<indices.length; i++) {
+        widget.deselectRow (indices [i]);
+    }
+    ignoreSelect = false;
+}
+
+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselectAll () {
+    checkWidget ();
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.deselectAll(null);
+    ignoreSelect = false;
+}
+
+void destroyItem (TableColumn column) {
+    int index = 0;
+    while (index < columnCount) {
+        if (columns [index] is column) break;
+        index++;
+    }
+    for (int i=0; i<itemCount; i++) {
+        TableItem item = items [i];
+        if (item !is null) {
+            if (columnCount <= 1) {
+                item.strings = null;
+                item.images = null;
+                item.cellBackground = null;
+                item.cellForeground = null;
+                item.cellFont = null;
+            } else {
+                if (item.strings !is null) {
+                    String [] strings = item.strings;
+                    if (index is 0) {
+                        item.text = strings [1] !is null ? strings [1] : "";
+                    }
+                    String [] temp = new String [columnCount - 1];
+                    System.arraycopy (strings, 0, temp, 0, index);
+                    System.arraycopy (strings, index + 1, temp, index, columnCount - 1 - index);
+                    item.strings = temp;
+                } else {
+                    if (index is 0) item.text = "";
+                }
+                if (item.images !is null) {
+                    Image [] images = item.images;
+                    if (index is 0) item.image = images [1];
+                    Image [] temp = new Image [columnCount - 1];
+                    System.arraycopy (images, 0, temp, 0, index);
+                    System.arraycopy (images, index + 1, temp, index, columnCount - 1 - index);
+                    item.images = temp;
+                } else {
+                    if (index is 0) item.image = null;
+                }
+                if (item.cellBackground !is null) {
+                    Color [] cellBackground = item.cellBackground;
+                    Color [] temp = new Color [columnCount - 1];
+                    System.arraycopy (cellBackground, 0, temp, 0, index);
+                    System.arraycopy (cellBackground, index + 1, temp, index, columnCount - 1 - index);
+                    item.cellBackground = temp;
+                }
+                if (item.cellForeground !is null) {
+                    Color [] cellForeground = item.cellForeground;
+                    Color [] temp = new Color [columnCount - 1];
+                    System.arraycopy (cellForeground, 0, temp, 0, index);
+                    System.arraycopy (cellForeground, index + 1, temp, index, columnCount - 1 - index);
+                    item.cellForeground = temp;
+                }
+                if (item.cellFont !is null) {
+                    Font [] cellFont = item.cellFont;
+                    Font [] temp = new Font [columnCount - 1];
+                    System.arraycopy (cellFont, 0, temp, 0, index);
+                    System.arraycopy (cellFont, index + 1, temp, index, columnCount - 1 - index);
+                    item.cellFont = temp;
+                }
+            }
+        }
+    }
+    if (columnCount is 1) {
+        //TODO - reset attributes
+        firstColumn = column.nsColumn;
+        firstColumn.setWidth (0);
+    } else {
+        ((NSTableView)view).removeTableColumn(column.nsColumn);
+    }
+    System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
+    columns [columnCount] = null;
+    for (int i=index; i<columnCount; i++) {
+        columns [i].sendEvent (DWT.Move);
+    }
+}
+
+void destroyItem (TableItem item) {
+    int index = 0;
+    while (index < itemCount) {
+        if (items [index] is item) break;
+        index++;
+    }
+    if (index !is itemCount - 1) fixSelection (index, false); 
+    System.arraycopy (items, index + 1, items, index, --itemCount - index);
+    items [itemCount] = null;
+    ((NSTableView)view).noteNumberOfRowsChanged();
+    if (itemCount is 0) {
+        setTableEmpty ();
+    } else {
+//      fixScrollBar ();
+    }
+}
+
+void fixSelection (int index, bool add) {
+    int [] selection = getSelectionIndices ();
+    if (selection.length is 0) return;
+    int newCount = 0;
+    bool fix = false;
+    for (int i = 0; i < selection.length; i++) {
+        if (!add && selection [i] is index) {
+            fix = true;
+        } else {
+            int newIndex = newCount++;
+            selection [newIndex] = selection [i] + 1;
+            if (selection [newIndex] - 1 >= index) {
+                selection [newIndex] += add ? 1 : -1;
+                fix = true;
+            }
+        }
+    }
+    if (fix) select (selection, newCount, true);
+}
+
+int getCheckColumnWidth () {
+    return 20; //TODO - compute width
+}
+
+/**
+ * Returns the column at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ * Columns are returned in the order that they were created.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this method will throw <code>ERROR_INVALID_RANGE</code> despite
+ * the fact that a single column of data may be visible in the table.
+ * This occurs when the programmer uses the table like a list, adding
+ * items but never creating a column.
+ *
+ * @param index the index of the column to return
+ * @return the column at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(bool)
+ * @see DWT#Move
+ */
+public TableColumn getColumn (int index) {
+    checkWidget ();
+    if (!(0 <=index && index < columnCount)) error (DWT.ERROR_INVALID_RANGE);
+    return columns [index];
+}
+
+/**
+ * Returns the number of columns contained in the receiver.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this value is zero, despite the fact that visually, one column
+ * of items may be visible. This occurs when the programmer uses
+ * the table like a list, adding items but never creating a column.
+ *
+ * @return the number of columns
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getColumnCount () {
+    checkWidget ();
+    return columnCount;
+}
+
+/**
+ * Returns an array of zero-relative integers that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.1
+ */
+public int [] getColumnOrder () {
+    checkWidget ();
+    int [] order = new int [columnCount];
+    int [] position = new int [1];
+    for (int i=0; i<columnCount; i++) {
+        TableColumn column = columns [i];
+//      OS.GetDataBrowserTableViewColumnPosition (handle, column.id, position);
+//      if ((style & DWT.CHECK) !is 0) position [0] -= 1;
+        order [position [0]] = i;
+    }
+    return order;
+}
+
+/**
+ * Returns an array of <code>TableColumn</code>s which are the
+ * columns in the receiver.  Columns are returned in the order
+ * that they were created.  If no <code>TableColumn</code>s were
+ * created by the programmer, the array is empty, despite the fact
+ * that visually, one column of items may be visible. This occurs
+ * when the programmer uses the table like a list, adding items but
+ * never creating a column.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(bool)
+ * @see DWT#Move
+ */
+public TableColumn [] getColumns () {
+    checkWidget ();
+    TableColumn [] result = new TableColumn [columnCount];
+    System.arraycopy (columns, 0, result, 0, columnCount);
+    return result;
+}
+
+/**
+ * Returns the width in pixels of a grid line.
+ *
+ * @return the width of a grid line in pixels
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getGridLineWidth () {
+    checkWidget ();
+    return 0;
+}
+
+/**
+ * Returns the height of the receiver's header 
+ *
+ * @return the height of the header or zero if the header is not visible
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0 
+ */
+public int getHeaderHeight () {
+    checkWidget ();
+    NSTableHeaderView headerView = ((NSTableView)view).headerView();
+    if (headerView is null) return 0;
+    return (int)headerView.bounds().height;
+}
+
+/**
+ * Returns <code>true</code> if the receiver's header is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's header's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getHeaderVisible () {
+    checkWidget ();
+    return ((NSTableView)view).headerView() !is null;
+}
+
+int getInsetWidth () {
+    //TODO - wrong
+    return 20;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getItem (int index) {
+    checkWidget ();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    return _getItem (index);
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ * <p>
+ * The item that is returned represents an item that could be selected by the user.
+ * For example, if selection only occurs in items in the first column, then null is 
+ * returned if the point is outside of the item. 
+ * Note that the DWT.FULL_SELECTION style hint, which specifies the selection policy,
+ * determines the extent of the selection.
+ * </p>
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point, or null if the point is not in a selectable item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getItem (Point point) {
+    checkWidget ();
+//  checkItems (true);
+//  if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
+//  Rect rect = new Rect ();
+//  dwt.internal.carbon.Point pt = new dwt.internal.carbon.Point ();
+//  OS.SetPt (pt, (short) point.x, (short) point.y);
+//  if (0 < lastHittest && lastHittest <= itemCount && lastHittestColumn !is 0) {
+//      if (OS.GetDataBrowserItemPartBounds (handle, lastHittest, lastHittestColumn, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//          if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//              if ((style & DWT.FULL_SELECTION) !is 0) {
+//                  return _getItem (lastHittest - 1);
+//              } else {
+//                  return OS.PtInRect (pt, rect) ? _getItem (lastHittest - 1) : null;
+//              }
+//          }
+//      }
+//          
+//  }
+//  int [] top = new int [1], left = new int [1];
+//    OS.GetDataBrowserScrollPosition(handle, top, left);
+//  short [] height = new short [1];
+//  OS.GetDataBrowserTableViewRowHeight (handle, height);
+//  short [] header = new short [1];
+//  OS.GetDataBrowserListViewHeaderBtnHeight (handle, header);
+//  int [] offsets = new int [] {0, 1, -1};
+//  for (int i = 0; i < offsets.length; i++) {
+//      int index = (top[0] - header [0] + point.y) / height [0] + offsets [i];
+//      if (0 <= index && index < itemCount) {
+//          if (columnCount is 0) {
+//              if (OS.GetDataBrowserItemPartBounds (handle, index + 1, column_id, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//                  if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//                      if ((style & DWT.FULL_SELECTION) !is 0) {
+//                          return _getItem (index);
+//                      } else {
+//                          return OS.PtInRect (pt, rect) ? _getItem (index) : null;
+//                      }
+//                  }
+//              }
+//          } else {
+//              for (int j = 0; j < columnCount; j++) {
+//                  if (OS.GetDataBrowserItemPartBounds (handle, index + 1, columns [j].id, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//                      if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//                          if ((style & DWT.FULL_SELECTION) !is 0) {
+//                              return _getItem (index);
+//                          } else {
+//                              return OS.PtInRect (pt, rect) ? _getItem (index) : null;
+//                          }
+//                      }
+//                  }
+//              }
+//          }
+//      }
+//  }
+//  //TODO - optimize
+//  for (int i=0; i<itemCount; i++) {
+//      if (columnCount is 0) {
+//          if (OS.GetDataBrowserItemPartBounds (handle, i + 1, column_id, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//              if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//                  if ((style & DWT.FULL_SELECTION) !is 0) {
+//                      return _getItem (i);
+//                  } else {
+//                      return OS.PtInRect (pt, rect) ? _getItem (i) : null;
+//                  }
+//              }
+//          }
+//      } else {
+//          for (int j = 0; j < columnCount; j++) {
+//              if (OS.GetDataBrowserItemPartBounds (handle, i + 1, columns [j].id, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//                  if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//                      if ((style & DWT.FULL_SELECTION) !is 0) {
+//                          return _getItem (i);
+//                      } else {
+//                          return OS.PtInRect (pt, rect) ? _getItem (i) : null;
+//                      }
+//                  }
+//              }
+//          }
+//      }
+//  }
+    return null;
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    return itemCount;
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's.
+ *
+ * @return the height of one item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+    checkWidget ();
+    return (int)((NSTableView)view).rowHeight();
+}
+
+/**
+ * Returns a (possibly empty) array of <code>TableItem</code>s which
+ * are the items in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getItems () {
+    checkWidget ();
+    TableItem [] result = new TableItem [itemCount];
+    if ((style & DWT.VIRTUAL) !is 0) {
+        for (int i=0; i<itemCount; i++) {
+            result [i] = _getItem (i);
+        }
+    } else {
+        System.arraycopy (items, 0, result, 0, itemCount);
+    }
+    return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver's lines are visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the visibility state of the lines
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getLinesVisible () {
+    checkWidget ();
+//  if (OS.VERSION >= 0x1040) {
+//      int [] attrib = new int [1];
+//      OS.DataBrowserGetAttributes (handle, attrib);
+//      return (attrib [0] & (OS.kDataBrowserAttributeListViewAlternatingRowColors | OS.kDataBrowserAttributeListViewDrawColumnDividers)) !is 0;
+//  }
+    return false;
+}
+
+/**
+ * Returns an array of <code>TableItem</code>s that are currently
+ * selected in the receiver. The order of the items is unspecified.
+ * An empty array indicates that no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getSelection () {
+    checkWidget ();
+    NSTableView widget = (NSTableView)view;
+    if (widget.numberOfSelectedRows() is 0) {
+        return new TableItem [0];
+    }
+    NSIndexSet selection = widget.selectedRowIndexes();
+    int count = selection.count();
+    int [] indexBuffer = new int [count];
+    selection.getIndexes(indexBuffer, count, 0);
+    TableItem [] result = new TableItem  [count];
+    for (int i=0; i<count; i++) {
+        result [i] = _getItem (indexBuffer [i]);
+    }
+    return result;
+}
+
+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+    checkWidget ();
+    return ((NSTableView)view).numberOfSelectedRows();
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+    checkWidget();
+    //TODO - check empty selection case
+    return ((NSTableView)view).selectedRow();
+}
+
+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver. The order of the indices is unspecified.
+ * The array is empty if no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int [] getSelectionIndices () {
+    checkWidget ();
+    NSTableView widget = (NSTableView)view;
+    if (widget.numberOfSelectedRows() is 0) {
+        return new int [0];
+    }
+    NSIndexSet selection = widget.selectedRowIndexes();
+    int count = selection.count();
+    int [] result = new int [count];
+    selection.getIndexes(result, count, 0);
+    return result;
+}
+
+/**
+ * Returns the column which shows the sort indicator for
+ * the receiver. The value may be null if no column shows
+ * the sort indicator.
+ *
+ * @return the sort indicator 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortColumn(TableColumn)
+ * 
+ * @since 3.2
+ */
+public TableColumn getSortColumn () {
+    checkWidget ();
+    return sortColumn;
+}
+
+/**
+ * Returns the direction of the sort indicator for the receiver. 
+ * The value will be one of <code>UP</code>, <code>DOWN</code> 
+ * or <code>NONE</code>.
+ *
+ * @return the sort direction
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortDirection(int)
+ * 
+ * @since 3.2
+ */
+public int getSortDirection () {
+    checkWidget ();
+    return sortDirection;
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex () {
+    checkWidget();
+    //TODO - partial item at the top
+    NSRect rect = scrollView.documentVisibleRect();
+    NSPoint point = new NSPoint();
+    point.x = rect.x;
+    point.y = rect.y;
+    return ((NSTableView)view).rowAtPoint(point);
+}
+
+
+/**
+ * Searches the receiver's list starting at the first column
+ * (index 0) until a column is found that is equal to the 
+ * argument, and returns the index of that column. If no column
+ * is found, returns -1.
+ *
+ * @param column the search column
+ * @return the index of the column
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the column is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (TableColumn column) {
+    checkWidget ();
+    if (column is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<columnCount; i++) {
+        if (columns [i] is column) return i;
+    }
+    return -1;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (TableItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (1 <= lastIndexOf && lastIndexOf < itemCount - 1) {
+        if (items [lastIndexOf] is item) return lastIndexOf;
+        if (items [lastIndexOf + 1] is item) return ++lastIndexOf;
+        if (items [lastIndexOf - 1] is item) return --lastIndexOf;
+    }
+    if (lastIndexOf < itemCount / 2) {
+        for (int i=0; i<itemCount; i++) {
+            if (items [i] is item) return lastIndexOf = i;
+        }
+    } else {
+        for (int i=itemCount - 1; i>=0; --i) {
+            if (items [i] is item) return lastIndexOf = i;
+        }
+    }
+    return -1;
+}
+
+/**
+ * Returns <code>true</code> if the item is selected,
+ * and <code>false</code> otherwise.  Indices out of
+ * range are ignored.
+ *
+ * @param index the index of the item
+ * @return the selection state of the item at the index
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool isSelected (int index) {
+    checkWidget();
+    //TODO - range check
+    return ((NSTableView)view).isRowSelected(index);
+}
+
+int numberOfRowsInTableView(int aTableView) {
+    return itemCount;
+}
+
+void releaseChildren (bool destroy) {
+    if (items !is null) {
+        for (int i=0; i<itemCount; i++) {
+            TableItem item = items [i];
+            if (item !is null && !item.isDisposed ()) {
+                item.release (false);
+            }
+        }
+        items = null;
+    }
+    if (columns !is null) {
+        for (int i=0; i<columnCount; i++) {
+            TableColumn column = columns [i];
+            if (column !is null && !column.isDisposed ()) {
+                column.release (false);
+            }
+        }
+        columns = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (headerView !is null) headerView.release();
+    headerView = null;
+    if (firstColumn !is null) firstColumn.release();
+    firstColumn = null;
+    if (checkColumn !is null) checkColumn.release();
+    checkColumn = null;
+}
+
+void releaseWidget () { 
+    super.releaseWidget ();
+    currentItem = null;
+    sortColumn = null;
+}
+
+/**
+ * Removes the item from the receiver at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int index) {
+    checkWidget();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    TableItem item = items [index];
+    if (item !is null) item.release (false);
+    if (index !is itemCount - 1) fixSelection (index, false);
+    System.arraycopy (items, index + 1, items, index, --itemCount - index);
+    items [itemCount] = null;
+    ((NSTableView)view).noteNumberOfRowsChanged();
+    if (itemCount is 0) {
+        setTableEmpty ();
+    } else {
+//      fixScrollBar ();
+    }
+}
+
+/**
+ * Removes the items from the receiver which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+    checkWidget();
+    if (start > end) return;
+    if (!(0 <= start && start <= end && end < itemCount)) {
+        error (DWT.ERROR_INVALID_RANGE);
+    }
+    if (start is 0 && end is itemCount - 1) {
+        removeAll ();
+    } else {
+        int length = end - start + 1;
+        for (int i=0; i<length; i++) remove (start);
+    }
+}
+
+/**
+ * Removes the items from the receiver's list at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int [] indices) {
+    checkWidget ();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (indices.length is 0) return;
+    int [] newIndices = new int [indices.length];
+    System.arraycopy (indices, 0, newIndices, 0, indices.length);
+    sort (newIndices);
+    int start = newIndices [newIndices.length - 1], end = newIndices [0];
+    if (!(0 <= start && start <= end && end < itemCount)) {
+        error (DWT.ERROR_INVALID_RANGE);
+    }
+    int last = -1;
+    for (int i=0; i<newIndices.length; i++) {
+        int index = newIndices [i];
+        if (index !is last) {
+            remove (index);
+            last = index;
+        }
+    }
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+    checkWidget();
+    for (int i=0; i<itemCount; i++) {
+        TableItem item = items [i];
+        if (item !is null && !item.isDisposed ()) item.release (false);
+    }
+    setTableEmpty ();
+    ((NSTableView)view).noteNumberOfRowsChanged();
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener(SelectionListener)
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select (int index) {
+    checkWidget();
+    if (0 <= index && index < itemCount) {
+        NSIndexSet indexes = (NSIndexSet)new NSIndexSet().alloc();
+        indexes.initWithIndex(index);
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        ((NSTableView)view).selectRowIndexes(indexes, true);
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If an item in the given range is not selected, it is selected.
+ * If an item in the given range was already selected, it remains selected.
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setSelection(int,int)
+ */
+public void select (int start, int end) {
+    checkWidget ();
+    if (end < 0 || start > end || ((style & DWT.SINGLE) !is 0 && start !is end)) return;
+    if (itemCount is 0 || start >= itemCount) return;
+    if (start is 0 && end is itemCount - 1) {
+        selectAll ();
+    } else {
+        start = Math.max (0, start);
+        end = Math.min (end, itemCount - 1);
+        int length = end - start + 1;
+        NSIndexSet indexes = (NSIndexSet)new NSIndexSet().alloc();
+        NSRange range = new NSRange();
+        range.location = start;
+        range.length = length;
+        indexes.initWithIndexesInRange(range);
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        widget.selectRowIndexes(indexes, true);
+        ignoreSelect = false;
+    }
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If the item at a given index is not selected, it is selected.
+ * If the item at a given index was already selected, it remains selected.
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ * </p>
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setSelection(int[])
+ */
+public void select (int [] indices) {
+    checkWidget ();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int length = indices.length;
+    if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
+    int count = 0;
+    NSMutableIndexSet indexes = (NSMutableIndexSet)new NSMutableIndexSet().alloc().init();
+    for (int i=0; i<length; i++) {
+        int index = indices [length - i - 1];
+        if (index >= 0 && index < itemCount) {
+            indexes.addIndex (indices [i]);
+            count++;
+        }
+    }
+    if (count > 0) {
+        NSTableView widget = (NSTableView)view;
+        ignoreSelect = true;
+        widget.selectRowIndexes(indexes, true);
+        ignoreSelect = false;
+    }
+}
+
+void select (int [] ids, int count, bool clear) {
+    NSMutableIndexSet indexes = (NSMutableIndexSet)new NSMutableIndexSet().alloc().init();
+    for (int i=0; i<count; i++) indexes.addIndex (ids [i] - 1); //WRONG -1
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.selectRowIndexes(indexes, !clear);
+    ignoreSelect = false;
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+    checkWidget ();
+    if ((style & DWT.SINGLE) !is 0) return;
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.selectAll(null);
+    ignoreSelect = false;
+}
+
+/**
+ * Sets the order that the items in the receiver should 
+ * be displayed in to the given argument which is described
+ * in terms of the zero-relative ordering of when the items
+ * were added.
+ *
+ * @param order the new order to display the items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item order is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.1
+ */
+public void setColumnOrder (int [] order) {
+    checkWidget ();
+    if (order is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (columnCount is 0) {
+        if (order.length !is 0) error (DWT.ERROR_INVALID_ARGUMENT);
+        return;
+    }
+    if (order.length !is columnCount) error (DWT.ERROR_INVALID_ARGUMENT);
+    int [] oldOrder = getColumnOrder ();
+    bool reorder = false;
+    bool [] seen = new bool [columnCount];
+    for (int i=0; i<order.length; i++) {
+        int index = order [i];
+        if (index < 0 || index >= columnCount) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (seen [index]) error (DWT.ERROR_INVALID_ARGUMENT);
+        seen [index] = true;
+        if (order [i] !is oldOrder [i]) reorder = true;
+    }
+    if (reorder) {
+        int x = 0;
+        short [] width = new short [1];
+        int [] oldX = new int [oldOrder.length];
+        for (int i=0; i<oldOrder.length; i++) {
+            int index = oldOrder [i];
+            TableColumn column = columns [index];
+            oldX [index] =  x;
+//          OS.GetDataBrowserTableViewNamedColumnWidth(handle, column.id, width);
+            x += width [0];
+        }
+        x = 0;
+        int [] newX = new int [order.length];
+        for (int i=0; i<order.length; i++) {
+            int index = order [i];
+            TableColumn column = columns [index];
+            int position = (style & DWT.CHECK) !is 0 ? i + 1 : i;
+//          OS.SetDataBrowserTableViewColumnPosition(handle, column.id, position);
+//          column.lastPosition = position;
+            newX [index] =  x;
+//          OS.GetDataBrowserTableViewNamedColumnWidth(handle, column.id, width);
+            x += width [0];
+        }
+        TableColumn[] newColumns = new TableColumn [columnCount];
+        System.arraycopy (columns, 0, newColumns, 0, columnCount);
+        for (int i=0; i<columnCount; i++) {
+            TableColumn column = newColumns [i];
+            if (!column.isDisposed ()) {
+                if (newX [i] !is oldX [i]) {
+                    column.sendEvent (DWT.Move);
+                }
+            }
+        }
+    }
+}
+
+/**
+ * Marks the receiver's header as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHeaderVisible (bool show) {
+    checkWidget ();
+    ((NSTableView)view).setHeaderView (show ? headerView : null);
+}
+
+/**
+ * Sets the number of items contained in the receiver.
+ *
+ * @param count the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void setItemCount (int count) {
+    checkWidget ();
+//  checkItems (true);
+//  count = Math.max (0, count);
+//  if (count is itemCount) return;
+//  setRedraw (false);
+//    int[] top = new int [1], left = new int [1];
+//    OS.GetDataBrowserScrollPosition (handle, top, left);
+//    DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+//  OS.GetDataBrowserCallbacks (handle, callbacks);
+//  callbacks.v1_itemNotificationCallback = 0;
+//  callbacks.v1_itemCompareCallback = 0;
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+//  if (count < itemCount) {
+//      int index = count;
+//      int[] id = new int [itemCount - count];
+//      while (index < itemCount) {
+//          TableItem item = items [index];
+//          if (item !is null) item.release (false);
+//          id [index-count] = index + 1;
+//          index++;
+//      }
+//      OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, id.length, id, 0);
+//      int [] newItemCount = new int [1];
+//      if (OS.GetDataBrowserItemCount (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemAnyState, newItemCount) !is OS.noErr) {
+//          error (DWT.ERROR_CANNOT_GET_COUNT);
+//      }
+//      if (count !is newItemCount[0]) error (DWT.ERROR_ITEM_NOT_REMOVED);
+//  }
+//  int length = Math.max (4, (count + 3) / 4 * 4);
+//  TableItem [] newItems = new TableItem [length];
+//  System.arraycopy (items, 0, newItems, 0, Math.min (count, itemCount));
+//  items = newItems;
+//  if ((style & DWT.VIRTUAL) is 0) {
+//      for (int i=itemCount; i<count; i++) {
+//          items [i] = new TableItem (this, DWT.NONE, i, false);
+//      }
+//  }
+//  itemCount = count;
+//  OS.AddDataBrowserItems (handle, 0, itemCount, null, OS.kDataBrowserItemNoProperty);
+//  callbacks.v1_itemNotificationCallback = display.itemNotificationProc;
+//  callbacks.v1_itemCompareCallback = itemCompareProc ();
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+//  fixScrollBar ();
+//  setRedraw (true);
+}
+
+/*public*/ void setItemHeight (int itemHeight) {
+    checkWidget ();
+    if (itemHeight < -1) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (itemHeight is -1) {
+        //TODO - reset item height, ensure other API's such as setFont don't do this
+    } else {
+//      OS.SetDataBrowserTableViewRowHeight (handle, (short) itemHeight);
+    }
+}
+
+/**
+ * Marks the receiver's lines as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLinesVisible (bool show) {
+    checkWidget ();
+    ((NSTableView)view).setUsesAlternatingRowBackgroundColors(show);
+}
+
+bool setScrollWidth (TableItem item) {
+    if (columnCount !is 0) return false;
+    if (currentItem !is null) {
+//      if (currentItem !is item) fixScrollWidth = true;
+        return false;
+    }
+    if (drawCount !is 0) return false;
+    GC gc = new GC (this);
+    int newWidth = item.calculateWidth (0, gc);
+    gc.dispose ();
+    newWidth += getInsetWidth ();
+//  short [] width = new short [1];
+//  OS.GetDataBrowserTableViewNamedColumnWidth (handle, column_id, width);
+//  if (width [0] < newWidth) {
+//      OS.SetDataBrowserTableViewNamedColumnWidth (handle, column_id, (short) newWidth);
+//      return true;
+//  }
+    if (firstColumn.width() < newWidth) {
+        firstColumn.setWidth (newWidth);
+    }
+    return false;
+}
+
+bool setScrollWidth (TableItem [] items, bool set) {
+    if (columnCount !is 0) return false;
+    if (currentItem !is null) {
+//      fixScrollWidth = true;
+        return false;
+    }
+    if (drawCount !is 0) return false;
+    GC gc = new GC (this);
+    int newWidth = 0;
+    for (int i = 0; i < items.length; i++) {
+        TableItem item = items [i];
+        if (item !is null) {
+            newWidth = Math.max (newWidth, item.calculateWidth (0, gc));
+        }
+    }
+    gc.dispose ();
+    newWidth += getInsetWidth ();
+//  if (!set) {
+//      short [] width = new short [1];
+//      OS.GetDataBrowserTableViewNamedColumnWidth (handle, column_id, width);
+//      if (width [0] >= newWidth) return false;
+//  }
+//  OS.SetDataBrowserTableViewNamedColumnWidth (handle, column_id, (short) newWidth);
+    if (!set) {
+        if (firstColumn.width() > newWidth) return false;
+    }
+    firstColumn.setWidth (newWidth);
+    return true;
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * The current selection is first cleared, then the new item is selected.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int)
+ */
+public void setSelection (int index) {
+    checkWidget();
+    //TODO - optimize to use expand flag
+    deselectAll ();
+    setSelection (index, false);
+}
+
+void setSelection (int index, bool notify) {
+//  checkWidget();
+    if (0 <= index && index < itemCount) {
+        select (index);
+        showIndex (index);
+        if (notify) {
+            Event event = new Event ();
+            event.item = _getItem (index);
+            postEvent (DWT.Selection, event);
+        }
+    }
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ * </p>
+ * 
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int,int)
+ */
+public void setSelection (int start, int end) {
+    checkWidget ();
+    //TODO - optimize to use expand flag
+    deselectAll ();
+    if (end < 0 || start > end || ((style & DWT.SINGLE) !is 0 && start !is end)) return;
+    if (itemCount is 0 || start >= itemCount) return;
+    start = Math.max (0, start);
+    end = Math.min (end, itemCount - 1);
+    select (start, end);
+    showIndex (start);
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ * </p>
+ *
+ * @param indices the indices of the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int[])
+ */
+public void setSelection (int [] indices) {
+    checkWidget ();
+    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    //TODO - optimize to use expand flag
+    deselectAll ();
+    int length = indices.length;
+    if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
+    select (indices);
+    showIndex (indices [0]);
+}
+
+/**
+ * Sets the receiver's selection to the given item.
+ * The current selection is cleared before the new item is selected.
+ * <p>
+ * If the item is not in the receiver, then it is ignored.
+ * </p>
+ *
+ * @param item the item to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSelection (TableItem  item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setSelection (new TableItem [] {item});
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ * </p>
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the items has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int[])
+ * @see Table#setSelection(int[])
+ */
+public void setSelection (TableItem [] items) {
+    checkWidget ();
+    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    //TODO - optimize to use expand flag
+    deselectAll ();
+    int length = items.length;
+    if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
+    int [] indices = new int [length];
+    int count = 0;
+    for (int i=0; i<length; i++) {
+        int index = indexOf (items [length - i - 1]);
+        if (index !is -1) {
+            indices [count++] = index;
+        }
+    }
+    if (count > 0) {
+        select (indices);
+        showIndex (indices [0] - 1);
+    }
+}
+
+/**
+ * Sets the column used by the sort indicator for the receiver. A null
+ * value will clear the sort indicator.  The current sort column is cleared 
+ * before the new column is set.
+ *
+ * @param column the column used by the sort indicator or <code>null</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the column is disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortColumn (TableColumn column) {
+    checkWidget ();
+    if (column !is null && column.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (column is sortColumn) return;
+//  DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+//  OS.GetDataBrowserCallbacks (handle, callbacks);
+//  callbacks.v1_itemCompareCallback = display.itemCompareProc;
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+//  if (column is null) {
+//      if (sortColumn !is null  && !sortColumn.isDisposed ()  && sortDirection !is DWT.NONE) {
+//          OS.SetDataBrowserSortOrder (handle, (short) OS.kDataBrowserOrderIncreasing);
+//          sortColumn = null; 
+//          OS.SetDataBrowserSortProperty (handle, 0);
+//      }
+//  }
+//  sortColumn = column;
+//  if (sortColumn !is null  && !sortColumn.isDisposed () && sortDirection !is DWT.NONE) {
+//      OS.SetDataBrowserSortProperty (handle, sortColumn.id);
+//      int order = sortDirection is DWT.DOWN ? OS.kDataBrowserOrderDecreasing : OS.kDataBrowserOrderIncreasing;
+//      OS.SetDataBrowserSortOrder (handle, (short) order);
+//  }
+//  callbacks.v1_itemCompareCallback = itemCompareProc ();
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+}
+
+/**
+ * Sets the direction of the sort indicator for the receiver. The value 
+ * can be one of <code>UP</code>, <code>DOWN</code> or <code>NONE</code>.
+ *
+ * @param direction the direction of the sort indicator 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortDirection  (int direction) {
+    checkWidget ();
+    if (direction !is DWT.UP && direction !is DWT.DOWN && direction !is DWT.NONE) return;
+    if (direction is sortDirection) return;
+    sortDirection = direction;
+//  DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+//  OS.GetDataBrowserCallbacks (handle, callbacks);
+//  callbacks.v1_itemCompareCallback = display.itemCompareProc;
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+//  if (sortColumn !is null && !sortColumn.isDisposed ()) {
+//      if (sortDirection is DWT.NONE) {
+//          OS.SetDataBrowserSortOrder (handle, (short) OS.kDataBrowserOrderIncreasing);
+//          TableColumn column = sortColumn;
+//          sortColumn = null; 
+//          OS.SetDataBrowserSortProperty (handle, 0);
+//          sortColumn = column;
+//      } else {
+//          OS.SetDataBrowserSortProperty (handle, 0);
+//          OS.SetDataBrowserSortProperty (handle, sortColumn.id);
+//          int order = sortDirection is DWT.DOWN ? OS.kDataBrowserOrderDecreasing : OS.kDataBrowserOrderIncreasing;
+//          OS.SetDataBrowserSortOrder (handle, (short) order);
+//      }
+//  }
+//  callbacks.v1_itemCompareCallback = itemCompareProc ();
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+}
+
+void setTableEmpty () {
+    itemCount = 0;
+    items = new TableItem [4];
+}
+
+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex (int index) {
+    checkWidget();
+    NSRect rect = ((NSTableView)view).rectOfRow(index);
+    ((NSTableView)view).scrollRectToVisible(rect);
+}
+
+/**
+ * Shows the column.  If the column is already showing in the receiver,
+ * this method simply returns.  Otherwise, the columns are scrolled until
+ * the column is visible.
+ *
+ * @param column the column to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the column is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the column has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void showColumn (TableColumn column) {
+    checkWidget ();
+    if (column is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (column.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    if (column.parent !is this) return;
+    int index = indexOf (column);
+    if (columnCount <= 1 || !(0 <= index && index < columnCount)) return;
+    ((NSTableView)view).scrollColumnToVisible(index + ((style & DWT.CHECK) !is 0 ? 1 : 0));
+}
+
+void showIndex (int index) {
+    if (0 <= index && index < itemCount) {
+        ((NSTableView)view).scrollRowToVisible(index);
+    }
+}
+
+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#showSelection()
+ */
+public void showItem (TableItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    int index = indexOf (item);
+    if (index !is -1) showIndex (index);
+}
+
+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#showItem(TableItem)
+ */
+public void showSelection () {
+    checkWidget();
+    int index = getSelectionIndex ();
+    if (index >= 0) showIndex (index);
+}
+
+void sendDoubleSelection() {
+    postEvent (DWT.DefaultSelection);
+}
+
+void tableViewSelectionDidChange (int aNotification) {
+    if (ignoreSelect) return;
+    NSTableView widget = (NSTableView)view;
+    int row = widget.selectedRow();
+    if(row is -1)
+        postEvent(DWT.Selection);
+    else {
+        TableItem item = _getItem(row);
+        Event event = new Event();
+        event.item = item;
+        event.index = row;
+        postEvent(DWT.Selection, event);
+    }
+}
+
+int tableView_objectValueForTableColumn_row(int aTableView, int aTableColumn, int rowIndex) {
+    TableItem item = items [rowIndex];
+    if (checkColumn !is null && aTableColumn is checkColumn.id) {
+        NSNumber value;
+        if (item.checked && item.grayed) {
+            value = NSNumber.numberWithInt(OS.NSMixedState);
+        } else {
+            value = NSNumber.numberWithInt(item.checked ? OS.NSOnState : OS.NSOffState);
+        }
+        return value.id;
+    }
+    for (int i=0; i<columnCount; i++) {
+        if (columns [i].nsColumn.id is aTableColumn) {
+            return item.createString(i).id;
+        }
+    }
+    return item.createString(0).id;
+}
+
+void tableView_setObjectValue_forTableColumn_row(int aTableView, int anObject, int aTableColumn, int rowIndex) {
+    TableItem item = items [rowIndex];
+    if (checkColumn !is null && aTableColumn is checkColumn.id)  {
+        item.checked = !item.checked;
+        Event event = new Event();
+        event.detail = DWT.CHECK;
+        event.item = item;
+        event.index = rowIndex;
+        postEvent(DWT.Selection, event);
+    }
+}
+
+bool tableView_shouldEditTableColumn_row(int aTableView, int aTableColumn, int rowIndex) {
+    return false;
+}
+
+void tableView_willDisplayCell_forTableColumn_row(int aTableView, int aCell, int aTableColumn, int rowIndex) {
+    if (checkColumn !is null && aTableColumn is checkColumn.id) return;
+    TableItem item = items [rowIndex];
+    Image image = item.image;
+    for (int i=0; i<columnCount; i++) {
+        if (columns [i].nsColumn.id is aTableColumn) {
+            image = item.getImage(i);
+        }
+    }
+    NSBrowserCell cell = new NSBrowserCell(aCell);
+    cell.setImage(image !is null ? image.handle : null);
+    cell.setLeaf(true);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TableColumn.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,542 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TableColumn;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ControlListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableColumn;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class represent a column in a table widget.
+ * <p><dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd> Move, Resize, Selection</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TableColumn extends Item {
+    Table parent;
+    NSTableColumn nsColumn;
+    String toolTipText;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableColumn (Table parent, int style) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, parent.getColumnCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableColumn (Table parent, int style, int index) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener(ControlListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Resize,typedListener);
+    addListener (DWT.Move,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the column header is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.LEFT, DWT.CENTER, DWT.RIGHT, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+void destroyWidget () {
+    parent.destroyItem (this);
+    releaseHandle ();
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>.
+ *
+ * @return the alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+    checkWidget ();
+    if ((style & DWT.LEFT) !is 0) return DWT.LEFT;
+    if ((style & DWT.CENTER) !is 0) return DWT.CENTER;
+    if ((style & DWT.RIGHT) !is 0) return DWT.RIGHT;
+    return DWT.LEFT;
+}
+
+String getNameText () {
+    return getText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Table</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Table getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Gets the moveable attribute. A column that is
+ * not moveable cannot be reordered by the user 
+ * by dragging the header but may be reordered 
+ * by the programmer.
+ *
+ * @return the moveable attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.1
+ */
+public bool getMoveable () {
+    checkWidget ();
+//  int [] flags = new int [1];
+//  OS.GetDataBrowserPropertyFlags (parent.handle, id, flags);
+//  return (flags [0] & OS.kDataBrowserListViewMovableColumn) !is 0;
+    return false;
+}
+
+/**
+ * Gets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @return the resizable attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getResizable () {
+    checkWidget ();
+    return nsColumn.resizingMask() !is OS.NSTableColumnNoResizing;
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public String getToolTipText () {
+    checkWidget ();
+    return toolTipText;
+}
+
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getWidth () {
+    checkWidget ();
+    return (int)nsColumn.width();
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void pack () {
+    checkWidget ();
+    GC gc = new GC (parent);
+    int width = gc.stringExtent (text).x;
+    //TODO header extra
+    int index = parent.indexOf (this);
+    for (int i=0; i<parent.itemCount; i++) {
+        TableItem item = parent.items [i];
+        if (item !is null && item.cached) {
+            width = Math.max (width, item.calculateWidth (index, gc));
+        }
+    }
+    gc.dispose ();
+    setWidth (width + parent.getInsetWidth ());
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (nsColumn !is null) nsColumn.release();
+    nsColumn = null;
+    parent = null;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    if (parent.sortColumn is this) {
+        parent.sortColumn = null;
+    }
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Move, listener);
+    eventTable.unhook (DWT.Resize, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+    checkWidget ();
+    if ((alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER)) is 0) return;
+    int index = parent.indexOf (this);
+    if (index is -1 || index is 0) return;
+    style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    //NOT DONE
+}
+
+public void setImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed ()) {
+        error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+//  int index = parent.indexOf (this);
+//  if (index is -1) return;
+//  if (iconRef !is 0) {
+//      OS.ReleaseIconRef (iconRef);
+//      iconRef = 0;
+//  }
+//  super.setImage (image);
+//  if (image !is null) {
+//      if (OS.VERSION < 0x1040) {
+//          iconRef = createIconRef (image);
+//      }
+//  }
+//  updateHeader ();
+}
+
+/**
+ * Sets the moveable attribute.  A column that is
+ * moveable can be reordered by the user by dragging
+ * the header. A column that is not moveable cannot be 
+ * dragged by the user but may be reordered 
+ * by the programmer.
+ *
+ * @param moveable the moveable attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setColumnOrder(int[])
+ * @see Table#getColumnOrder()
+ * @see TableColumn#getMoveable()
+ * @see DWT#Move
+ * 
+ * @since 3.1
+ */
+public void setMoveable (bool moveable) {
+    checkWidget ();
+//  int [] flags = new int [1];
+//  OS.GetDataBrowserPropertyFlags (parent.handle, id, flags);
+//  if (moveable) {
+//      flags [0] |= OS.kDataBrowserListViewMovableColumn;
+//  } else {
+//      flags [0] &= ~OS.kDataBrowserListViewMovableColumn;
+//  }
+//  OS.SetDataBrowserPropertyFlags (parent.handle, id, flags [0]);
+}
+
+/**
+ * Sets the resizable attribute.  A column that is
+ * resizable can be resized by the user dragging the
+ * edge of the header.  A column that is not resizable 
+ * cannot be dragged by the user but may be resized 
+ * by the programmer.
+ *
+ * @param resizable the resize attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setResizable (bool resizable) {
+    checkWidget ();
+    nsColumn.setResizingMask (resizable ? OS.NSTableColumnUserResizingMask : OS.NSTableColumnNoResizing);
+}
+
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    super.setText (string);
+    char [] buffer = new char [text.length ()];
+    text.getChars (0, buffer.length, buffer, 0);
+    int length = fixMnemonic (buffer);
+    nsColumn.headerCell ().setTitle (NSString.stringWithCharacters (buffer, length));
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setToolTipText (String string) {
+    checkWidget();
+    toolTipText = string;
+}
+
+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWidth (int width) {
+    checkWidget ();
+    if (width < 0) return;
+    nsColumn.setWidth (width);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TableItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1059 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TableItem;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableView;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents an item in a table.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TableItem extends Item {
+    Table parent;
+    String [] strings;
+    Image [] images;
+    bool checked, grayed, cached;
+    Color foreground, background;
+    Color[] cellForeground, cellBackground;
+    Font font;
+    Font[] cellFont;
+    int width = -1;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableItem (Table parent, int style) {
+    this (parent, style, checkNull (parent).getItemCount (), true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableItem (Table parent, int style, int index) {
+    this (parent, style, index, true);
+}
+
+TableItem (Table parent, int style, int index, bool create) {
+    super (parent, style);
+    this.parent = parent;
+    if (create) parent.createItem (this, index);
+}
+
+static Table checkNull (Table control) {
+    if (control is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    return control;
+}
+
+int calculateWidth (int index, GC gc) {
+    if (index is 0 && width !is -1) return width;
+    int width = 0;
+    Image image = getImage (index);
+    String text = getText (index);
+    gc.setFont (getFont (index));
+//  if (image !is null) width += image.getBounds ().width + parent.getGap ();
+    if (text !is null && text.length () > 0) width += gc.stringExtent (text).x;
+//  if (parent.hooks (DWT.MeasureItem)) {
+//      Event event = new Event ();
+//      event.item = this;
+//      event.index = index;
+//      event.gc = gc;
+//      short [] height = new short [1];
+//      OS.GetDataBrowserTableViewRowHeight (parent.handle, height);
+//      event.width = width;
+//      event.height = height[0];
+//      parent.sendEvent (DWT.MeasureItem, event);
+//      if (parent.itemHeight < event.height) {
+//          parent.itemHeight = event.height;
+//          OS.SetDataBrowserTableViewRowHeight (parent.handle, (short) event.height);
+//      }
+//      width = event.width;
+//  }
+    if (index is 0) this.width = width;
+    return width;
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+void clear () {
+    text = "";
+    image = null;
+    strings = null;
+    images = null;
+    checked = grayed = cached = false;
+    foreground = background = null;
+    cellForeground = cellBackground = null;
+    font = null;
+    cellFont = null;
+    width = -1;
+}
+
+NSAttributedString createString(int index) {
+    NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
+    Color foreground = cellForeground !is null ? cellForeground [index] : null;
+    if (foreground is null) foreground = this.foreground;
+    if (foreground is null) foreground = parent.foreground;
+    if (foreground !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
+        dict.setObject(color, OS.NSForegroundColorAttributeName());
+    }
+    Font font = cellFont !is null ? cellFont [index] : null;
+    if (font is null) font = this.font;
+//  if (font is null) font = parent.font;
+    if (font !is null) {
+        dict.setObject(font.handle, OS.NSFontAttributeName());
+    }
+    Color background = cellBackground !is null ? cellBackground [index] : null;
+    if (background is null) background = this.background;
+    if (background !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(background.handle[0], background.handle[1], background.handle[2], 1);
+        dict.setObject(color, OS.NSBackgroundColorAttributeName());
+    }
+    String text = getText (index);
+    int length = text.length();
+    char[] chars = new char[length];
+    text.getChars(0, length, chars, 0);
+    NSString str = NSString.stringWithCharacters(chars, length);
+    NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict);
+    attribStr.autorelease();
+    return attribStr;
+}
+
+void destroyWidget () {
+    parent.destroyItem (this);
+    releaseHandle ();
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Color getBackground () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return background !is null ? background : parent.getBackground ();
+}
+
+/**
+ * Returns the background color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the background color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Color getBackground (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count -1) return getBackground ();
+    if (cellBackground is null || cellBackground [index] is null) return getBackground ();
+    return cellBackground [index];
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Rectangle getBounds () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    NSTableView tableView = (NSTableView) parent.view;
+    NSRect rect = tableView.rectOfRow (parent.indexOf (this));
+    rect = tableView.convertRect_toView_ (rect, parent.scrollView);
+    Rectangle result = new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
+    return result;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent at a column in the table.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding column rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    NSTableView tableView = (NSTableView) parent.view;
+    if ((parent.style & DWT.CHECK) !is 0) index ++;
+    NSRect rect = tableView.frameOfCellAtColumn (index, parent.indexOf (this));
+    rect = tableView.convertRect_toView_ (rect, parent.scrollView);
+    Rectangle result = new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
+    return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the checked state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getChecked () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if ((parent.style & DWT.CHECK) is 0) return false;
+    return checked;
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information for this item.
+ *
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return font !is null ? font : parent.getFont ();
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information
+ * for the specified cell in this item.
+ *
+ * @param index the column index
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count -1) return getFont ();
+    if (cellFont is null || cellFont [index] is null) return getFont ();
+    return cellFont [index];
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Color getForeground () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return foreground !is null ? foreground : parent.getForeground ();
+}
+
+/**
+ * 
+ * Returns the foreground color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the foreground color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Color getForeground (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count -1) return getForeground ();
+    if (cellForeground is null || cellForeground [index] is null) return getForeground ();
+    return cellForeground [index];
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getGrayed () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if ((parent.style & DWT.CHECK) is 0) return false;
+    return grayed;
+}
+
+public Image getImage () {
+    checkWidget();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return super.getImage ();
+}
+
+/**
+ * Returns the image stored at the given column index in the receiver,
+ * or null if the image has not been set or if the column does not exist.
+ *
+ * @param index the column index
+ * @return the image stored at the given column index in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage (int index) {
+    checkWidget();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (index is 0) return getImage ();
+    if (images !is null) {
+        if (0 <= index && index < images.length) return images [index];
+    }
+    return null;
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of an image at a column in the
+ * table.  An empty rectangle is returned if index exceeds
+ * the index of the table's last column.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding image rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getImageBounds (int index) {
+    checkWidget();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+//  parent.checkItems (true);
+//  if (index !is 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
+//  Rect rect = new Rect();
+//  int itemIndex = parent.indexOf (this);
+//  int id = itemIndex + 1;
+//  int columnId = parent.columnCount is 0 ? parent.column_id : parent.columns [index].id;
+//  if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect) !is OS.noErr) {
+//      return new Rectangle (0, 0, 0, 0);
+//  }
+//  int x = rect.left, y = rect.top;
+//  int width = 0;
+//  if (index is 0 && image !is null) {
+//      Rectangle bounds = image.getBounds ();
+//      width += bounds.width;
+//  }
+//  if (index !is 0 && images !is null && images[index] !is null) {
+//      Rectangle bounds = images [index].getBounds ();
+//      width += bounds.width;
+//  }
+//  int height = rect.bottom - rect.top + 1;
+//  return new Rectangle (x, y, width, height);
+    return null;
+}
+
+/**
+ * Gets the image indent.
+ *
+ * @return the indent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getImageIndent () {
+    checkWidget();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return 0;
+}
+
+String getNameText () {
+    if ((parent.style & DWT.VIRTUAL) !is 0) {
+        if (!cached) return "*virtual*"; //$NON-NLS-1$
+    }
+    return super.getNameText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Table</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Table getParent () {
+    checkWidget ();
+    return parent;
+}
+
+public String getText () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return super.getText ();
+}
+
+/**
+ * Returns the text stored at the given column index in the receiver,
+ * or empty string if the text has not been set.
+ *
+ * @param index the column index
+ * @return the text stored at the given column index in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (index is 0) return getText ();
+    if (strings !is null) {
+        if (0 <= index && index < strings.length) {
+            String string = strings [index];
+            return string !is null ? string : "";
+        }
+    }
+    return "";
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of the text at a column in the
+ * table.  An empty rectangle is returned if index exceeds
+ * the index of the table's last column.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding text rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Rectangle getTextBounds (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+//  parent.checkItems (true);
+//  if (index !is 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
+//  Rect rect = new Rect();
+//  int itemIndex = parent.indexOf (this);
+//  int id = itemIndex + 1;
+//  int columnId = parent.columnCount is 0 ? parent.column_id : parent.columns [index].id;
+//  if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) !is OS.noErr) {
+//      return new Rectangle (0, 0, 0, 0);
+//  }
+//  int imageWidth = 0;
+//  int margin = parent.getInsetWidth () / 2;
+//  Image image = getImage (index);
+//  if (image !is null) {
+//      Rectangle bounds = image.getBounds ();
+//      imageWidth = bounds.width + parent.getGap ();
+//  }
+//  int x, y, width, height;
+//  if (OS.VERSION >= 0x1040) {
+//      if (parent.getLinesVisible ()) {
+//          rect.left += Table.GRID_WIDTH;
+//          rect.top += Table.GRID_WIDTH;
+//      }
+//      x = rect.left + imageWidth + margin;
+//      y = rect.top;
+//      width = Math.max (0, rect.right - rect.left - imageWidth - margin * 2);
+//      height = rect.bottom - rect.top;
+//  } else {
+//      Rect rect2 = new Rect();
+//      if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect2) !is OS.noErr) {
+//          return new Rectangle (0, 0, 0, 0);
+//      }
+//      x = rect2.left + imageWidth + margin;
+//      y = rect2.top;
+//      width = Math.max (0, rect.right - rect2.left + 1 - imageWidth - margin * 2);
+//      height = rect2.bottom - rect2.top + 1;
+//  }
+//  return new Rectangle (x, y, width, height);
+    return null;
+}
+
+void redraw () {
+//  0[aTableView setNeedsDisplayInRect:[aTableView rectOfRow:row]];
+    ((NSTableView)parent.view).reloadData();
+    ((NSTableView)parent.view).tile();
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    parent = null;
+}
+
+void releaseParent () {
+    super.releaseParent ();
+//  parent.checkItems (true);
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    strings = null;
+    images = null;
+    background = foreground = null;
+    font = null;
+    cellBackground = cellForeground = null;
+    cellFont = null;
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setBackground (Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    Color oldColor = background;
+    if (oldColor is color) return;
+    background = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.rectOfRow(parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the background color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setBackground (int index, Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count - 1) return;
+    if (cellBackground is null) {
+        if (color is null) return;
+        cellBackground = new Color [count];
+    }
+    Color oldColor = cellBackground [index];
+    if (oldColor is color) return;
+    cellBackground [index] = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the checked state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the DWT.CHECK style.
+ *
+ * @param checked the new checked state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (bool checked) {
+    checkWidget ();
+    if ((parent.style & DWT.CHECK) is 0) return;
+    if (this.checked is checked) return;
+    this.checked = checked;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.rectOfRow(parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (Font font) {
+    checkWidget ();
+    if (font !is null && font.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    Font oldFont = this.font;
+    if (oldFont is font) return;
+    this.font = font;
+    if (oldFont !is null && oldFont.equals (font)) return;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.rectOfRow(parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for the specified cell in this item to the font specified by the 
+ * argument, or to the default font for that kind of control if the 
+ * argument is null.
+ *
+ * @param index the column index
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (int index, Font font) {
+    checkWidget ();
+    if (font !is null && font.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count - 1) return;
+    if (cellFont is null) {
+        if (font is null) return;
+        cellFont = new Font [count];
+    }
+    Font oldFont = cellFont [index];
+    if (oldFont is font) return;
+    cellFont [index] = font;
+    if (oldFont !is null && oldFont.equals (font)) return;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setForeground (Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    Color oldColor = foreground;
+    if (oldColor is color) return;
+    foreground = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.rectOfRow(parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the foreground color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setForeground (int index, Color color){
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count - 1) return;
+    if (cellForeground is null) {
+        if (color is null) return;
+        cellForeground = new Color [count];
+    }
+    Color oldColor = cellForeground [index];
+    if (oldColor is color) return;
+    cellForeground [index] = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the DWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox; 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setGrayed (bool grayed) {
+    checkWidget ();
+    if ((parent.style & DWT.CHECK) is 0) return;
+    if (this.grayed is grayed) return;
+    this.grayed = grayed;
+    cached = true;
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.rectOfRow(parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+/**
+ * Sets the image for multiple columns in the table. 
+ * 
+ * @param images the array of new images
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image [] images) {
+    checkWidget();
+    if (images is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<images.length; i++) {
+        setImage (i, images [i]);
+    }
+}
+
+/**
+ * Sets the receiver's image at a column.
+ *
+ * @param index the column index
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (int index, Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed ()) {
+        error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    int itemIndex = parent.indexOf (this);
+    if (itemIndex is -1) return;
+//  if (parent.imageBounds is null && image !is null) {
+//      parent.setItemHeight (image);
+//  }
+    if (index is 0)  {
+        if (image !is null && image.type is DWT.ICON) {
+            if (image.equals (this.image)) return;
+        }
+        width = -1;
+        super.setImage (image);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 <= index && index < count) {
+        if (images is null) images = new Image [count];
+        if (image !is null && image.type is DWT.ICON) {
+            if (image.equals (images [index])) return;
+        }
+        images [index] = image; 
+    }
+//  cached = true;
+//  if (index is 0) parent.setScrollWidth (this);
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+public void setImage (Image image) {
+    checkWidget ();
+    setImage (0, image);
+}
+
+/**
+ * Sets the indent of the first column's image, expressed in terms of the image's width.
+ *
+ * @param indent the new indent
+ *
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated this functionality is not supported on most platforms
+ */
+public void setImageIndent (int indent) {
+    checkWidget();
+    if (indent < 0) return;
+    cached = true;
+    /* Image indent is not supported on the Macintosh */
+}
+
+/**
+ * Sets the text for multiple columns in the table. 
+ * 
+ * @param strings the array of new strings
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String [] strings) {
+    checkWidget();
+    if (strings is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<strings.length; i++) {
+        String string = strings [i];
+        if (string !is null) setText (i, string);
+    }
+}
+
+/**
+ * Sets the receiver's text at a column
+ *
+ * @param index the column index
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (int index, String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (index is 0) {
+        if (string.equals (text)) return;
+        width = -1;
+        super.setText (string);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 <= index && index < count) {
+        if (strings is null) strings = new String [count];
+        if (string.equals (strings [index])) return;
+        strings [index] = string;
+    }
+    cached = true;
+    if (index is 0) parent.setScrollWidth (this);
+    NSTableView view = (NSTableView)parent.view;
+    NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this));
+    view.setNeedsDisplayInRect(rect);
+}
+
+public void setText (String string) {
+    checkWidget();
+    setText (0, string);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Text.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1678 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Text;
+
+import dwt.dwthelper.utils;
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ModifyListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.events.VerifyListener;
+import dwt.graphics.Color;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSCell;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSControl;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSMutableString;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSearchField;
+import dwt.internal.cocoa.NSSecureTextField;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTextField;
+import dwt.internal.cocoa.NSTextFieldCell;
+import dwt.internal.cocoa.NSTextView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTScrollView;
+import dwt.internal.cocoa.SWTTextField;
+import dwt.internal.cocoa.SWTTextView;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that allow the user to enter and modify text.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CANCEL, CENTER, LEFT, MULTI, PASSWORD, SEARCH, SINGLE, RIGHT, READ_ONLY, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Verify</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified,
+ * and only one of the styles LEFT, CENTER, and RIGHT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Text extends Scrollable {
+    int textLimit = LIMIT, tabs = 8;
+    char echoCharacter;
+    bool doubleClick;
+    String hiddenText, message;
+    
+    /**
+    * The maximum number of characters that can be entered
+    * into a text widget.
+    * <p>
+    * Note that this value is platform dependent, based upon
+    * the native widget implementation.
+    * </p>
+    */
+    public static final int LIMIT;
+    
+    /**
+    * The delimiter used by multi-line text widgets.  When text
+    * is queried and from the widget, it will be delimited using
+    * this delimiter.
+    */
+    public static final String DELIMITER;
+    static final char PASSWORD = '\u2022';
+
+    /*
+    * These values can be different on different platforms.
+    * Therefore they are not initialized in the declaration
+    * to stop the compiler from inlining.
+    */
+    static {
+        LIMIT = 0x7FFFFFFF;
+        DELIMITER = "\r";
+    }
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#SINGLE
+ * @see DWT#MULTI
+ * @see DWT#READ_ONLY
+ * @see DWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Text (Composite parent, int style) {
+    super (parent, checkStyle (style));
+    if ((style & DWT.SEARCH) !is 0) {
+//      int inAttributesToSet = (style & DWT.CANCEL) !is 0 ? OS.kHISearchFieldAttributesCancel : 0;
+//      OS.HISearchFieldChangeAttributes (handle, inAttributesToSet, 0);
+        /*
+        * Ensure that DWT.CANCEL is set.
+        * NOTE: CANCEL has the same value as H_SCROLL so it is
+        * necessary to first clear these bits to avoid a scroll
+        * bar and then reset the bit using the original style
+        * supplied by the programmer.
+        */
+        if ((style & DWT.CANCEL) !is 0) this.style |= DWT.CANCEL;
+    }
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+public void addModifyListener (ModifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Modify, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is not called for texts.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text,
+ * or when ENTER is pressed in a search text. If the receiver has the <code>DWT.SEARCH | DWT.CANCEL</code> style
+ * and the user cancels the search, the event object detail field contains the value <code>DWT.CANCEL</code>.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ */
+public void addVerifyListener (VerifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Verify, typedListener);
+}
+
+/**
+ * Appends a string.
+ * <p>
+ * The new text is appended to the text at
+ * the end of the widget.
+ * </p>
+ *
+ * @param string the string to be appended
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void append (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+        int charCount = getCharCount ();
+        string = verifyText (string, charCount, charCount, null);
+        if (string is null) return;
+    }
+    NSString str = NSString.stringWith(string);
+    if ((style & DWT.SINGLE) !is 0) {
+//      new NSTextFieldCell(((NSTextField)view).cell()).title().
+    } else {
+        NSTextView widget = (NSTextView)view;
+        NSMutableString mutableString = widget.textStorage().mutableString();
+        mutableString.appendString(str);
+        NSRange range = new NSRange();
+        range.location = mutableString.length();
+        widget.scrollRangeToVisible(range);
+    }
+    if (string.length () !is 0) sendEvent (DWT.Modify);
+}
+
+static int checkStyle (int style) {
+    if ((style & DWT.SEARCH) !is 0) {
+        style |= DWT.SINGLE | DWT.BORDER;
+        style &= ~DWT.PASSWORD;
+    }
+    if ((style & DWT.SINGLE) !is 0 && (style & DWT.MULTI) !is 0) {
+        style &= ~DWT.MULTI;
+    }
+    style = checkBits (style, DWT.LEFT, DWT.CENTER, DWT.RIGHT, 0, 0, 0);
+    if ((style & DWT.SINGLE) !is 0) style &= ~(DWT.H_SCROLL | DWT.V_SCROLL | DWT.WRAP);
+    if ((style & DWT.WRAP) !is 0) {
+        style |= DWT.MULTI;
+        style &= ~DWT.H_SCROLL;
+    }
+    if ((style & DWT.MULTI) !is 0) style &= ~DWT.PASSWORD;
+    if ((style & (DWT.SINGLE | DWT.MULTI)) !is 0) return style;
+    if ((style & (DWT.H_SCROLL | DWT.V_SCROLL)) !is 0) return style | DWT.MULTI;
+    return style | DWT.SINGLE;
+}
+
+/**
+ * Clears the selection.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void clearSelection () {
+    checkWidget();
+    Point selection = getSelection ();
+    setSelection (selection.x); 
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = 0, height = 0;
+    if ((style & DWT.SINGLE) !is 0) {
+        NSTextField widget = (NSTextField)view;
+        NSRect oldRect = widget.frame();
+        widget.sizeToFit();
+        NSRect newRect = widget.frame();
+        widget.setFrame (oldRect);
+        width = (int)newRect.width;
+        height = (int)newRect.height;
+    } else {
+        NSTextView widget = (NSTextView)view;
+        NSRect oldRect = widget.frame();
+        widget.sizeToFit();
+        NSRect newRect = widget.frame();
+        widget.setFrame (oldRect);
+        width = (int)newRect.width;
+        height = (int)newRect.height;
+    }
+    if (width <= 0) width = DEFAULT_WIDTH;
+    if (height <= 0) height = DEFAULT_HEIGHT;
+    if (wHint !is DWT.DEFAULT) width = wHint;
+    if (hHint !is DWT.DEFAULT) height = hHint;
+    Rectangle trim = computeTrim (0, 0, width, height);
+    width = trim.width;
+    height = trim.height;
+    return new Point (width, height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void copy () {
+    checkWidget ();
+    if ((style & DWT.SINGLE) !is 0) {
+        
+    } else {
+        ((NSTextView)view).copy();
+    }
+}
+
+void createHandle () {
+    if ((style & DWT.SINGLE) !is 0) {
+        NSTextField widget;
+        if ((style & DWT.PASSWORD) !is 0) {
+            widget = (NSTextField)new NSSecureTextField().alloc();
+        } else if ((style & DWT.SEARCH) !is 0) {
+            widget = (NSTextField)new NSSearchField().alloc();
+        } else {
+            widget = (NSTextField)new SWTTextField().alloc();
+        }
+        widget.initWithFrame(new NSRect());
+        widget.setSelectable(true);
+        widget.setEditable((style & DWT.READ_ONLY) is 0);
+        if ((style & DWT.BORDER) is 0) widget.setBordered(false);
+        int align = OS.NSLeftTextAlignment;
+        if ((style & DWT.CENTER) !is 0) align = OS.NSCenterTextAlignment;
+        if ((style & DWT.RIGHT) !is 0) align = OS.NSRightTextAlignment;
+        widget.setAlignment(align);
+//      widget.setTarget(widget);
+//      widget.setAction(OS.sel_sendSelection);
+        widget.setTag(jniRef);
+        view = widget;
+        parent.contentView().addSubview_(widget);
+    } else {
+        SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc();
+        scrollWidget.initWithFrame(new NSRect());
+        scrollWidget.setHasVerticalScroller((style & DWT.VERTICAL) !is 0);
+        scrollWidget.setHasHorizontalScroller((style & DWT.HORIZONTAL) !is 0);
+        scrollWidget.setAutoresizesSubviews(true);
+        scrollWidget.setTag(jniRef);
+        
+        SWTTextView widget = (SWTTextView)new SWTTextView().alloc();
+        widget.initWithFrame(new NSRect());
+        widget.setEditable((style & DWT.READ_ONLY) is 0);
+        if ((style & DWT.BORDER) is 0) widget.setFocusRingType(OS.NSFocusRingTypeNone);
+        
+        NSSize size = new NSSize();
+        size.width = size.height = Float.MAX_VALUE;
+        widget.setMaxSize(size);
+        widget.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable);
+
+        if ((style & DWT.WRAP) is 0) {
+            widget.setHorizontallyResizable(true);
+            NSSize csize = new NSSize();
+            csize.width = csize.height = Float.MAX_VALUE;
+            widget.textContainer().setWidthTracksTextView(false);
+            widget.textContainer().setContainerSize(csize);
+        }
+
+        int align = OS.NSLeftTextAlignment;
+        if ((style & DWT.CENTER) !is 0) align = OS.NSCenterTextAlignment;
+        if ((style & DWT.RIGHT) !is 0) align = OS.NSRightTextAlignment;
+        widget.setAlignment(align);
+
+//      widget.setTarget(widget);
+//      widget.setAction(OS.sel_sendSelection);
+        widget.setTag(jniRef);
+        widget.setRichText(false);
+        
+        view = widget;
+        scrollView = scrollWidget;
+        scrollView.setDocumentView(widget);
+        parent.contentView().addSubview_(scrollView);
+    }
+}
+
+void createWidget () {
+    super.createWidget ();
+    doubleClick = true;
+    message = "";
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void cut () {
+    checkWidget();
+    if ((style & DWT.READ_ONLY) !is 0) return;
+    if ((style & DWT.SINGLE) !is 0) {
+        
+    } else {
+        ((NSTextView)view).cut(null);
+    }
+//  bool cut = true;
+//  char [] oldText = null;
+//  Point oldSelection = getSelection ();
+//  if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+//      if (oldSelection.x !is oldSelection.y) {
+//          oldText = getEditText (oldSelection.x, oldSelection.y - 1);
+//          String newText = verifyText ("", oldSelection.x, oldSelection.y, null);
+//          if (newText is null) return;
+//          if (newText.length () !is 0) {
+//              copyToClipboard (oldText);
+//              if (txnObject is 0) {
+//                  insertEditText (newText);
+//              } else {
+//                  setTXNText (OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection, newText);
+//                  OS.TXNShowSelection (txnObject, false);
+//              }
+//              cut = false;
+//          }
+//      }
+//  }
+//  if (cut) {
+//      if (txnObject is 0) {
+//          if (oldText is null) oldText = getEditText (oldSelection.x, oldSelection.y - 1);
+//          copyToClipboard (oldText);
+//          insertEditText ("");
+//      } else {
+//          OS.TXNCut (txnObject);
+//  
+//          /*
+//          * Feature in the Macintosh.  When an empty string is set in the TXNObject,
+//          * the font attributes are cleared.  The fix is to reset them.
+//          */
+//          if (OS.TXNDataSize (txnObject) / 2 is 0) setFontStyle (font);
+//      }
+//  }
+//  Point newSelection = getSelection ();
+//  if (!cut || !oldSelection.equals (newSelection)) sendEvent (DWT.Modify);
+}
+
+Color defaultBackground () {
+    return display.getSystemColor (DWT.COLOR_LIST_BACKGROUND);
+}
+
+Color defaultForeground () {
+    return display.getSystemColor (DWT.COLOR_LIST_FOREGROUND);
+}
+
+bool dragDetect (int x, int y, bool filter, bool [] consume) {
+    if (filter) {
+        Point selection = getSelection ();
+        if (selection.x !is selection.y) {
+            int position = getPosition (x, y);
+            if (selection.x <= position && position < selection.y) {
+                if (super.dragDetect (x, y, filter, consume)) {
+                    if (consume !is null) consume [0] = true;
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    return super.dragDetect (x, y, filter, consume);
+}
+
+/**
+ * Returns the line number of the caret.
+ * <p>
+ * The line number of the caret is returned.
+ * </p>
+ *
+ * @return the line number
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretLineNumber () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) return 0;
+    return (getTopPixel () + getCaretLocation ().y) / getLineHeight ();
+}
+
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ * <p>
+ * The location of the caret is returned.
+ * </p>
+ *
+ * @return a point, the location of the caret
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getCaretLocation () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) {
+        //TODO - caret location for unicode text
+        return new Point (0, 0);
+    }
+//  NSText
+    NSRange range = ((NSTextView)view).selectedRange();
+    System.out.println(range.location + " " + range.length);
+    return null;
+}
+
+/**
+ * Returns the character position of the caret.
+ * <p>
+ * Indexing is zero based.
+ * </p>
+ *
+ * @return the position of the caret
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretPosition () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) {
+        //TODO
+        return 0;
+    } else {
+        NSRange range = ((NSTextView)view).selectedRange();
+        return range.location;
+    }
+}
+
+/**
+ * Returns the number of characters.
+ *
+ * @return number of characters in the widget
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCharCount () {
+    checkWidget ();
+    if ((style & DWT.SINGLE) !is 0) {
+        return new NSCell(((NSControl)view).cell()).title().length();
+    } else {
+        //TODO
+        return 0;
+    }
+}
+
+/**
+ * Returns the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p>
+ * 
+ * @return whether or not double click is enabled
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getDoubleClickEnabled () {
+    checkWidget();
+    return doubleClick;
+}
+
+/**
+ * Returns the echo character.
+ * <p>
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer.
+ * </p>
+ * 
+ * @return the echo character
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setEchoChar
+ */
+public char getEchoChar () {
+    checkWidget();
+    return echoCharacter;
+}
+
+/**
+ * Returns the editable state.
+ *
+ * @return whether or not the receiver is editable
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getEditable () {
+    checkWidget();
+    return (style & DWT.READ_ONLY) is 0;
+}
+
+/**
+ * Returns the number of lines.
+ *
+ * @return the number of lines in the widget
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineCount () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) return 1;
+    return ((NSTextView)view).textStorage().paragraphs().count();
+}
+
+/**
+ * Returns the line delimiter.
+ *
+ * @return a string that is the line delimiter
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #DELIMITER
+ */
+public String getLineDelimiter () {
+    checkWidget();
+    return DELIMITER;
+}
+
+/**
+ * Returns the height of a line.
+ *
+ * @return the height of a row of text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineHeight () {
+    checkWidget();
+    //TODO
+    return 16;
+}
+
+/**
+ * Returns the orientation of the receiver, which will be one of the
+ * constants <code>DWT.LEFT_TO_RIGHT</code> or <code>DWT.RIGHT_TO_LEFT</code>.
+ *
+ * @return the orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public int getOrientation () {
+    checkWidget();
+    return style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT);
+}
+
+/**
+ * Returns the widget message. When the widget is created
+ * with the style <code>DWT.SEARCH</code>, the message text
+ * is displayed as a hint for the user, indicating the
+ * purpose of the field.
+ * <p>
+ * Note: This operation is a <em>HINT</em> and is not
+ * supported on platforms that do not have this concept.
+ * </p>
+ * 
+ * @return the widget message
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public String getMessage () {
+    checkWidget ();
+    return message;
+}
+
+int getPosition (int x, int y) {
+//  checkWidget ();
+    //TODO 
+    return 0;
+}
+
+public int getPosition (Point point) {
+    checkWidget ();
+    if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
+    return getPosition (point.x, point.y);
+}
+
+/**
+ * Returns a <code>Point</code> whose x coordinate is the
+ * character position representing the start of the selected
+ * text, and whose y coordinate is the character position
+ * representing the end of the selection. An "empty" selection
+ * is indicated by the x and y coordinates having the same value.
+ * <p>
+ * Indexing is zero based.  The range of a selection is from
+ * 0..N where N is the number of characters in the widget.
+ * </p>
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) {
+//      new NSTextFieldCell(((NSTextField)view).cell()).title().
+        return new Point(0, 0);
+    } else {
+        NSTextView widget = (NSTextView)view;
+        NSRange range = widget.selectedRange();
+        return new Point(range.location, range.location + range.length);
+    }
+}
+
+/**
+ * Returns the number of selected characters.
+ *
+ * @return the number of selected characters.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) {
+//      new NSTextFieldCell(((NSTextField)view).cell()).title().
+        return -1;
+    } else {
+        NSTextView widget = (NSTextView)view;
+        NSRange range = widget.selectedRange();
+        return range.length;
+    }
+}
+
+/**
+ * Gets the selected text, or an empty string if there is no current selection.
+ *
+ * @return the selected text
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getSelectionText () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) {
+        //TODO
+        return "";
+    } else {
+        NSTextView widget = (NSTextView)view;
+        NSRange range = widget.selectedRange();
+        NSString str = widget.textStorage().string();
+        char[] buffer = new char[range.length];
+        str.getCharacters_range_(buffer, range);
+        return new String(buffer);
+    }
+}
+
+/**
+ * Returns the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character.  The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @return the number of tab characters
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTabs () {
+    checkWidget();
+    return tabs;
+}
+
+/**
+ * Returns the widget text.
+ * <p>
+ * The text for a text widget is the characters in the widget, or
+ * an empty string if this has never been set.
+ * </p>
+ *
+ * @return the widget text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget();
+    NSString str;
+    if ((style & DWT.SINGLE) !is 0) {
+        str = new NSTextFieldCell(((NSTextField)view).cell()).title();
+    } else {
+        str = ((NSTextView)view).textStorage().string();
+    }
+    if (str is null) return "";
+    char[] buffer = new char[str.length()];
+    str.getCharacters_(buffer);
+    return new String(buffer);
+}
+
+/**
+ * Returns a range of text.  Returns an empty string if the
+ * start of the range is greater than the end.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N-1 where N is
+ * the number of characters in the widget.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ * @return the range of text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText (int start, int end) {
+    checkWidget ();
+    NSString str;
+    if ((style & DWT.SINGLE) !is 0) {
+        str = new NSTextFieldCell(((NSTextField)view).cell()).title();
+         
+    } else {
+        str = null;
+//      return getTXNText (OS.kTXNStartOffset, OS.kTXNEndOffset);
+    }
+    if (str is null) return "";
+    char[] buffer = new char[str.length()];
+    str.getCharacters_(buffer);
+    return new String(buffer, start, end - start);
+}
+
+/**
+ * Returns the maximum number of characters that the receiver is capable of holding. 
+ * <p>
+ * If this has not been changed by <code>setTextLimit()</code>,
+ * it will be the constant <code>Text.LIMIT</code>.
+ * </p>
+ * 
+ * @return the text limit
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #LIMIT
+ */
+public int getTextLimit () {
+    checkWidget();
+    return textLimit;
+}
+
+/**
+ * Returns the zero-relative index of the line which is currently
+ * at the top of the receiver.
+ * <p>
+ * This index can change when lines are scrolled or new lines are added or removed.
+ * </p>
+ *
+ * @return the index of the top line
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) return 0;
+    return getTopPixel () / getLineHeight ();
+}
+
+/**
+ * Returns the top pixel.
+ * <p>
+ * The top pixel is the pixel position of the line
+ * that is currently at the top of the widget.  On
+ * some platforms, a text widget can be scrolled by
+ * pixels instead of lines so that a partial line
+ * is displayed at the top of the widget.
+ * </p><p>
+ * The top pixel changes when the widget is scrolled.
+ * The top pixel does not include the widget trimming.
+ * </p>
+ *
+ * @return the pixel position of the top line
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopPixel () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) return 0;
+    //TODO
+    return 0;
+}
+
+/**
+ * Inserts a string.
+ * <p>
+ * The old selection is replaced with the new text.
+ * </p>
+ *
+ * @param string the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is <code>null</code></li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void insert (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+        Point selection = getSelection ();
+        string = verifyText (string, selection.x, selection.y, null);
+        if (string is null) return;
+    }
+    if ((style & DWT.SINGLE) !is 0) {
+//      new NSTextFieldCell(((NSTextField)view).cell()).title().
+    } else {
+        //
+        NSString str = NSString.stringWith(string);
+        NSTextView widget = (NSTextView)view;
+        NSRange range = widget.selectedRange();
+        widget.textStorage().replaceCharactersInRange_withString_(range, str);
+    }
+    if (string.length () !is 0) sendEvent (DWT.Modify);
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void paste () {
+    checkWidget();
+    if ((style & DWT.READ_ONLY) !is 0) return;
+//  bool paste = true;
+//  String oldText = null;
+//  if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+//      oldText = getClipboardText ();
+//      if (oldText !is null) {
+//          Point selection = getSelection ();
+//          String newText = verifyText (oldText, selection.x, selection.y, null);
+//          if (newText is null) return;
+//          if (!newText.equals (oldText)) {
+//              if (txnObject is 0) {
+//                  insertEditText (newText);
+//              } else {
+//                  setTXNText (OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection, newText);
+//                  OS.TXNShowSelection (txnObject, false);
+//              }
+//              paste = false;
+//          }
+//      }
+//  }
+//  if (paste) {
+//      if (txnObject is 0) {
+//          if (oldText is null) oldText = getClipboardText ();
+//          insertEditText (oldText);
+//      } else {
+//          if (textLimit !is LIMIT) {
+//              if (oldText is null) oldText = getClipboardText ();
+//              setTXNText (OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection, oldText);
+//              OS.TXNShowSelection (txnObject, false);
+//          } else {
+//              OS.TXNPaste (txnObject);
+//          }
+//      }
+//  }
+//  sendEvent (DWT.Modify);
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    hiddenText = message = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+public void removeModifyListener (ModifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Modify, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #addVerifyListener
+ */
+public void removeVerifyListener (VerifyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Verify, listener);
+}
+
+/**
+ * Selects all the text in the receiver.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) {
+        setSelection (0, getCharCount ());
+    } else {
+        ((NSTextView)view).selectAll(null);
+    }
+}
+
+bool sendKeyEvent (int type, Event event) {
+    if (!super.sendKeyEvent (type, event)) {
+        return false;
+    }
+    if (type !is DWT.KeyDown) return true;
+    if ((style & DWT.READ_ONLY) !is 0) return true;
+    if (event.character is 0) return true;
+    if ((event.stateMask & DWT.COMMAND) !is 0) return true;
+    String oldText = "";
+    int charCount = getCharCount ();
+    Point selection = getSelection ();
+    int start = selection.x, end = selection.y;
+    switch (event.character) {
+        case DWT.BS:
+            if (start is end) {
+                if (start is 0) return true;
+                start = Math.max (0, start - 1);
+            }
+            break;
+        case DWT.DEL:
+            if (start is end) {
+                if (start is charCount) return true;
+                end = Math.min (end + 1, charCount);
+            }
+            break;
+        case DWT.CR:
+            if ((style & DWT.SINGLE) !is 0) return true;
+            oldText = DELIMITER;
+            break;
+        default:
+            if (event.character !is '\t' && event.character < 0x20) return true;
+            oldText = new String (new char [] {event.character});
+    }
+    String newText = verifyText (oldText, start, end, event);
+    if (newText is null) return false;
+    if (charCount - (end - start) + newText.length () > textLimit) {
+        return false;
+    }
+    bool result = newText is oldText;
+    if (newText !is oldText || hiddenText !is null) {
+//      if (txnObject is 0) {
+//          String text = new String (getEditText (0, -1));
+//          String leftText = text.substring (0, start);
+//          String rightText = text.substring (end, text.length ());
+//          setEditText (leftText + newText + rightText);
+//          start += newText.length ();
+//          setSelection (new Point (start, start));
+//          result = false;
+//      } else {
+//          setTXNText (start, end, newText);
+//      }
+    }
+    /*
+    * Post the modify event so that the character will be inserted
+    * into the widget when the modify event is delivered.  Normally,
+    * modify events are sent but it is safe to post the event here
+    * because this method is called from the event loop.
+    */
+    postEvent (DWT.Modify);
+    return result;
+}
+
+void setBackground (float [] color) {
+    NSColor nsColor;
+    if (color is null) {
+        return; // TODO reset to OS default
+    } else {
+        nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    }
+    if ((style & DWT.SINGLE) !is 0) {
+        ((NSTextField)view).setBackgroundColor(nsColor);
+    } else {
+        ((NSTextView)view).setBackgroundColor(nsColor);
+    }
+}
+
+/**
+ * Sets the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p><p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ * 
+ * @param doubleClick the new double click flag
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDoubleClickEnabled (bool doubleClick) {
+    checkWidget();
+    this.doubleClick = doubleClick;
+}
+
+/**
+ * Sets the echo character.
+ * <p>
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer. Setting
+ * the echo character to '\0' clears the echo
+ * character and redraws the original text.
+ * If for any reason the echo character is invalid,
+ * or if the platform does not allow modification
+ * of the echo character, the default echo character
+ * for the platform is used.
+ * </p>
+ *
+ * @param echo the new echo character
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEchoChar (char echo) {
+    checkWidget();
+    if ((style & DWT.MULTI) !is 0) return;
+//  if (txnObject is 0) {
+//      if ((style & DWT.PASSWORD) is 0) {
+//          Point selection = getSelection ();
+//          String text = getText ();
+//          echoCharacter = echo;
+//          setEditText (text);
+//          setSelection (selection);
+//      }
+//  } else {
+//      OS.TXNEchoMode (txnObject, echo, OS.kTextEncodingMacUnicode, echo !is '\0');
+//  }
+    echoCharacter = echo;
+}
+
+/**
+ * Sets the editable state.
+ *
+ * @param editable the new editable state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEditable (bool editable) {
+    checkWidget();
+    if (editable) {
+        style &= ~DWT.READ_ONLY;
+    } else {
+        style |= DWT.READ_ONLY;
+    }
+    if ((style & DWT.SINGLE) !is 0) {
+        ((NSTextField)view).setEditable(editable);
+    } else {
+        ((NSTextView)view).setEditable(editable);
+    }
+}
+
+void setForeground (float [] color) {
+    NSColor nsColor;
+    if (color is null) {
+        return; // TODO reset to OS default
+    } else {
+        nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+    }
+    if ((style & DWT.SINGLE) !is 0) {
+        ((NSTextField)view).setTextColor(nsColor);
+    } else {
+        ((NSTextView)view).setTextColor_(nsColor);
+    }
+}
+
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of the constants <code>DWT.LEFT_TO_RIGHT</code> or <code>DWT.RIGHT_TO_LEFT</code>.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public void setOrientation (int orientation) {
+    checkWidget();
+}
+
+/**
+ * Sets the widget message. When the widget is created
+ * with the style <code>DWT.SEARCH</code>, the message text
+ * is displayed as a hint for the user, indicating the
+ * purpose of the field.
+ * <p>
+ * Note: This operation is a <em>HINT</em> and is not
+ * supported on platforms that do not have this concept.
+ * </p>
+ * 
+ * @param message the new message
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the message is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void setMessage (String message) {
+    checkWidget ();
+    if (message is null) error (DWT.ERROR_NULL_ARGUMENT);
+    this.message = message;
+//  if ((style & DWT.SEARCH) !is 0) {
+//      char [] buffer = new char [message.length ()];
+//      message.getChars (0, buffer.length, buffer, 0);
+//      int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length);
+//      if (ptr is 0) error (DWT.ERROR_CANNOT_SET_TEXT);
+//      OS.HISearchFieldSetDescriptiveText (handle, ptr);
+//      OS.CFRelease (ptr);
+//  }
+}
+
+/**
+ * Sets the selection.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * regular array indexing rules.
+ * </p>
+ *
+ * @param start new caret position
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int start) {
+    checkWidget();
+    setSelection (start, start);
+}
+
+/**
+ * Sets the selection to the range specified
+ * by the given start and end indices.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int start, int end) {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) {
+//      int length = getCharCount ();
+//      ControlEditTextSelectionRec selection = new ControlEditTextSelectionRec ();
+//      selection.selStart = (short) Math.min (Math.max (Math.min (start, end), 0), length);
+//      selection.selEnd = (short) Math.min (Math.max (Math.max (start, end), 0), length);
+//      if (hasFocus ()) {
+//          OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlEditTextSelectionTag, 4, selection);
+//      } else {
+//          this.selection = selection;
+//      }
+    } else {
+        //TODO - range test
+        NSRange range = new NSRange ();
+        range.location = start;
+        range.length = end - start + 1;
+        ((NSTextView)view).setSelectedRange (range);
+    }
+}
+
+/**
+ * Sets the selection to the range specified
+ * by the given point, where the x coordinate
+ * represents the start index and the y coordinate
+ * represents the end index.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param selection the point
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (Point selection) {
+    checkWidget();
+    if (selection is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setSelection (selection.x, selection.y);
+}
+
+/**
+ * Sets the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character.  The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @param tabs the number of tabs
+ *
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabs (int tabs) {
+    checkWidget();
+    if (this.tabs is tabs) return;
+//  if (txnObject is 0) return;
+//  this.tabs = tabs;
+//  TXNTab tab = new TXNTab ();
+//  tab.value = (short) (textExtent (new char[]{' '}, 0).x * tabs);
+//  int [] tags = new int [] {OS.kTXNTabSettingsTag};
+//  int [] datas = new int [1];
+//  OS.memmove (datas, tab, TXNTab.sizeof);
+//  OS.TXNSetTXNObjectControls (txnObject, false, tags.length, tags, datas);
+}
+
+/**
+ * Sets the contents of the receiver to the given string. If the receiver has style
+ * SINGLE and the argument contains multiple lines of text, the result of this
+ * operation is undefined and may vary from platform to platform.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (hooks (DWT.Verify) || filters (DWT.Verify)) {
+        string = verifyText (string, 0, getCharCount (), null);
+        if (string is null) return;
+    }
+    NSString str = NSString.stringWith(string);
+    if ((style & DWT.SINGLE) !is 0) {
+        new NSCell(((NSTextField)view).cell()).setTitle(str);
+    } else {
+        ((NSTextView)view).setString(str);
+    }
+    sendEvent (DWT.Modify);
+}
+
+/**
+ * Sets the maximum number of characters that the receiver
+ * is capable of holding to be the argument.
+ * <p>
+ * Instead of trying to set the text limit to zero, consider
+ * creating a read-only text widget.
+ * </p><p>
+ * To reset this value to the default, use <code>setTextLimit(Text.LIMIT)</code>.
+ * Specifying a limit value larger than <code>Text.LIMIT</code> sets the
+ * receiver's limit to <code>Text.LIMIT</code>.
+ * </p>
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #LIMIT
+ */
+public void setTextLimit (int limit) {
+    checkWidget();
+    if (limit is 0) error (DWT.ERROR_CANNOT_BE_ZERO);
+    textLimit = limit;
+}
+
+/**
+ * Sets the zero-relative index of the line which is currently
+ * at the top of the receiver. This index can change when lines
+ * are scrolled or new lines are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex (int index) {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0) return;
+    //TODO no working
+    NSTextView widget = (NSTextView)view;
+    NSRange range = new NSRange();
+    NSRect rect = widget.firstRectForCharacterRange(range);
+    view.scrollRectToVisible(rect);
+}
+
+/**
+ * Shows the selection.
+ * <p>
+ * If the selection is already showing
+ * in the receiver, this method simply returns.  Otherwise,
+ * lines are scrolled until the selection is visible.
+ * </p>
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void showSelection () {
+    checkWidget();
+    if ((style & DWT.SINGLE) !is 0)  {
+        setSelection (getSelection());
+    } else {
+        NSTextView widget = (NSTextView)view;
+        widget.scrollRangeToVisible(widget.selectedRange());
+    }
+}
+
+int traversalCode (int key, NSEvent theEvent) {
+    int bits = super.traversalCode (key, theEvent);
+    if ((style & DWT.READ_ONLY) !is 0) return bits;
+    if ((style & DWT.MULTI) !is 0) {
+        bits &= ~DWT.TRAVERSE_RETURN;
+//      if (key is 48 /* Tab */ && theEvent !is 0) {
+//          int [] modifiers = new int [1];
+//          OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+//          bool next = (modifiers [0] & OS.shiftKey) is 0;
+//          if (next && (modifiers [0] & OS.controlKey) is 0) {
+//              bits &= ~(DWT.TRAVERSE_TAB_NEXT | DWT.TRAVERSE_TAB_PREVIOUS);
+//          }
+//      }
+    }
+    return bits;
+}
+
+String verifyText (String string, int start, int end, Event keyEvent) {
+    Event event = new Event ();
+    event.text = string;
+    event.start = start;
+    event.end = end;
+    if (keyEvent !is null) {
+        event.character = keyEvent.character;
+        event.keyCode = keyEvent.keyCode;
+        event.stateMask = keyEvent.stateMask;
+    }
+    /*
+     * It is possible (but unlikely), that application
+     * code could have disposed the widget in the verify
+     * event.  If this happens, answer null to cancel
+     * the operation.
+     */
+    sendEvent (DWT.Verify, event);
+    if (!event.doit || isDisposed ()) return null;
+    return event.text;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ToolBar.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,444 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ToolBar;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.SWTView;
+
+/**
+ * Instances of this class support the layout of selectable
+ * tool bar items.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>ToolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>FLAT, WRAP, RIGHT, HORIZONTAL, VERTICAL, SHADOW_OUT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class ToolBar extends Composite {
+    int itemCount;
+    ToolItem [] items;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#FLAT
+ * @see DWT#WRAP
+ * @see DWT#RIGHT
+ * @see DWT#HORIZONTAL
+ * @see DWT#SHADOW_OUT
+ * @see DWT#VERTICAL
+ * @see Widget#checkSubclass()
+ * @see Widget#getStyle()
+ */
+public ToolBar (Composite parent, int style) {
+    super (parent, checkStyle (style));
+    
+    /*
+    * Ensure that either of HORIZONTAL or VERTICAL is set.
+    * NOTE: HORIZONTAL and VERTICAL have the same values
+    * as H_SCROLL and V_SCROLL so it is necessary to first
+    * clear these bits to avoid scroll bars and then reset
+    * the bits using the original style supplied by the
+    * programmer.
+    */
+    if ((style & DWT.VERTICAL) !is 0) {
+        this.style |= DWT.VERTICAL;
+    } else {
+        this.style |= DWT.HORIZONTAL;
+    }
+}
+
+static int checkStyle (int style) {
+    /*
+    * Even though it is legal to create this widget
+    * with scroll bars, they serve no useful purpose
+    * because they do not automatically scroll the
+    * widget's client area.  The fix is to clear
+    * the DWT style.
+    */
+    return style & ~(DWT.H_SCROLL | DWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget();
+    int width = wHint, height = hHint;
+    if (wHint is DWT.DEFAULT) width = 0x7FFFFFFF;
+    if (hHint is DWT.DEFAULT) height = 0x7FFFFFFF;
+    int [] result = layout (width, height, false);
+    Point extent = new Point (result [1], result [2]);
+    if (wHint !is DWT.DEFAULT) extent.x = wHint;
+    if (hHint !is DWT.DEFAULT) extent.y = hHint;
+    return extent;
+}
+
+void createHandle () {
+    SWTView widget = (SWTView)new SWTView().alloc();
+    widget.initWithFrame(new NSRect());
+//  widget.setDrawsBackground(false);
+    widget.setTag(jniRef);
+    view = widget;
+    parent.contentView().addSubview_(widget);
+}
+
+void createItem (ToolItem item, int index) {
+    if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (itemCount is items.length) {
+        ToolItem [] newItems = new ToolItem [itemCount + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    item.createWidget();
+    view.addSubview_(item.view);
+    System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+    items [index] = item;
+    relayout ();
+}
+
+void createWidget () {
+    super.createWidget ();
+    items = new ToolItem [4];
+    itemCount = 0;
+}
+
+void destroyItem (ToolItem item) {
+    int index = 0;
+    while (index < itemCount) {
+        if (items [index] is item) break;
+        index++;
+    }
+    if (index is itemCount) return;
+    System.arraycopy (items, index + 1, items, index, --itemCount - index);
+    items [itemCount] = null;
+    NSView nsItem = item.view;
+    nsItem.removeFromSuperview();
+    item.view = null;
+    relayout ();
+}
+
+void enableWidget(bool enabled) {
+    super.enableWidget(enabled);
+    for (int i = 0; i < itemCount; i++) {
+        ToolItem item = items[i];
+        if (item !is null) {
+            item.enableWidget(enabled);
+        }
+    }
+}
+
+public Rectangle getClientArea () {
+    checkWidget();
+    NSRect rect = view.bounds();
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolItem getItem (int index) {
+    checkWidget();
+    if (0 <= index && index < itemCount) return items [index];
+    error (DWT.ERROR_INVALID_RANGE);
+    return null;
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolItem getItem (Point pt) {
+    checkWidget();
+    if (pt is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<itemCount; i++) {
+        Rectangle rect = items [i].getBounds ();
+        if (rect.contains (pt)) return items [i];
+    }
+    return null;
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget();
+    return itemCount;
+}
+
+/**
+ * Returns an array of <code>ToolItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolItem [] getItems () {
+    checkWidget();
+    ToolItem [] result = new ToolItem [itemCount];
+    System.arraycopy (items, 0, result, 0, itemCount);
+    return result;
+}
+
+/**
+ * Returns the number of rows in the receiver. When
+ * the receiver has the <code>WRAP</code> style, the
+ * number of rows can be greater than one.  Otherwise,
+ * the number of rows is always one.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getRowCount () {
+    checkWidget();
+    Rectangle rect = getClientArea ();
+    return layout (rect.width, rect.height, false) [0];
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the tool item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (ToolItem item) {
+    checkWidget();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    for (int i=0; i<itemCount; i++) {
+        if (items [i] is item) return i;
+    }
+    return -1;
+}
+
+int [] layoutHorizontal (int width, int height, bool resize) {
+    int xSpacing = 0, ySpacing = 2;
+    int marginWidth = 0, marginHeight = 0;
+    int x = marginWidth, y = marginHeight;
+    int maxX = 0, rows = 1;
+    bool wrap = (style & DWT.WRAP) !is 0;
+    int itemHeight = 0;
+    Point [] sizes = new Point [itemCount];
+    for (int i=0; i<itemCount; i++) {
+        Point size = sizes [i] = items [i].computeSize ();
+        itemHeight = Math.max (itemHeight, size.y);
+    }
+    for (int i=0; i<itemCount; i++) {
+        ToolItem item = items [i];
+        Point size = sizes [i];
+        if (wrap && i !is 0 && x + size.x > width) {
+            rows++;
+            x = marginWidth;
+            y += ySpacing + itemHeight;
+        }
+        if (resize) {
+            item.setBounds (x, y, size.x, itemHeight);
+            bool visible = x + size.x <= width && y + itemHeight <= height;
+            item.setVisible (visible);
+            Control control = item.control;
+            if (control !is null) {
+                int controlY = y + (itemHeight - size.y) / 2;
+                control.setBounds (x, controlY, size.x, itemHeight - (controlY - y));
+            }
+        }
+        x += xSpacing + size.x;
+        maxX = Math.max (maxX, x);
+    }
+    
+    return new int [] {rows, maxX, y + itemHeight};
+}
+
+int [] layoutVertical (int width, int height, bool resize) {
+    int xSpacing = 2, ySpacing = 0;
+    int marginWidth = 0, marginHeight = 0;
+    int x = marginWidth, y = marginHeight;
+    int maxY = 0, cols = 1;
+    bool wrap = (style & DWT.WRAP) !is 0;
+    int itemWidth = 0;
+    Point [] sizes = new Point [itemCount];
+    for (int i=0; i<itemCount; i++) {
+        Point size = sizes [i] = items [i].computeSize ();
+        itemWidth = Math.max (itemWidth, size.x);
+    }
+    for (int i=0; i<itemCount; i++) {
+        ToolItem item = items [i];
+        Point size = sizes [i];
+        if (wrap && i !is 0 && y + size.y > height) {
+            cols++;
+            x += xSpacing + itemWidth;
+            y = marginHeight;
+        }
+        if (resize) {
+            item.setBounds (x, y, itemWidth, size.y);
+            bool visible = x + itemWidth <= width && y + size.y <= height;
+            item.setVisible (visible);
+            Control control = item.control;
+            if (control !is null) {
+                int controlX = x + (itemWidth - size.x) / 2;
+                control.setBounds (controlX, y, itemWidth - (controlX - x), size.y);
+            }
+        }
+        y += ySpacing + size.y;
+        maxY = Math.max (maxY, y);
+    }
+    
+    return new int [] {cols, x + itemWidth, maxY};
+}
+
+int [] layout (int nWidth, int nHeight, bool resize) {
+    if ((style & DWT.VERTICAL) !is 0) {
+        return layoutVertical (nWidth, nHeight, resize);
+    } else {
+        return layoutHorizontal (nWidth, nHeight, resize);
+    }
+}
+
+void relayout () {
+    if (drawCount !is 0) return;
+    Rectangle rect = getClientArea ();
+    layout (rect.width, rect.height, true);
+}
+
+void releaseChildren (bool destroy) {
+    if (items !is null) {
+        for (int i=0; i<itemCount; i++) {
+            ToolItem item = items [i];
+            if (item !is null && !item.isDisposed ()) {
+                item.release (false);
+            }
+        }
+        itemCount = 0;
+        items = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void removeControl (Control control) {
+    super.removeControl (control);
+    for (int i=0; i<itemCount; i++) {
+        ToolItem item = items [i];
+        if (item.control is control) item.setControl (null);
+    }
+}
+
+int setBounds (int x, int y, int width, int height, bool move, bool resize) {
+    int result = super.setBounds (x, y, width, height, move, resize);
+    if ((result & RESIZED) !is 0) relayout ();
+    return result;
+}
+
+public void setRedraw (bool redraw) {
+    checkWidget();
+    super.setRedraw (redraw);
+    if (redraw && drawCount is 0) relayout();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ToolItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,852 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ToolItem;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSButton;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTBox;
+import dwt.internal.cocoa.SWTButton;
+import dwt.internal.cocoa.SWTView;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a button in a tool bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN 
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class ToolItem extends Item {
+    NSView view;
+    NSButton button, arrow;
+    int width = DEFAULT_SEPARATOR_WIDTH;
+    ToolBar parent;
+    Image hotImage, disabledImage;
+    String toolTipText;
+    Control control;
+    bool selection;
+
+    static final int DEFAULT_WIDTH = 24;
+    static final int DEFAULT_HEIGHT = 22;
+    static final int DEFAULT_SEPARATOR_WIDTH = 6;
+    static final int INSET = 5;
+    static final int ARROW_WIDTH = 5;
+    static final int ARROW_INSET = 2;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>ToolBar</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#PUSH
+ * @see DWT#CHECK
+ * @see DWT#RADIO
+ * @see DWT#SEPARATOR
+ * @see DWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolItem (ToolBar parent, int style) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>ToolBar</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#PUSH
+ * @see DWT#CHECK
+ * @see DWT#RADIO
+ * @see DWT#SEPARATOR
+ * @see DWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolItem (ToolBar parent, int style, int index) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called when the mouse is over the arrow portion of a drop-down tool,
+ * the event object detail field contains the value <code>DWT.ARROW</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user,
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener(listener);
+    addListener(DWT.Selection,typedListener);
+    addListener(DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.PUSH, DWT.CHECK, DWT.RADIO, DWT.SEPARATOR, DWT.DROP_DOWN, 0);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+Point computeSize () {
+    checkWidget();
+    int width = 0, height = 0;
+    if ((style & DWT.SEPARATOR) !is 0) {
+        if ((parent.style & DWT.HORIZONTAL) !is 0) {
+            width = getWidth ();
+            height = DEFAULT_HEIGHT;
+        } else {
+            width = DEFAULT_WIDTH;
+            height = getWidth ();
+        }
+        if (control !is null) {
+            height = Math.max (height, control.getMininumHeight ());
+        }
+    } else {
+        ((NSButton)button).sizeToFit ();
+        NSRect frame = button.frame();
+        width = (int)frame.width + INSET;
+        height = (int)frame.height;
+        if (arrow !is null) {
+            width += ARROW_INSET + ARROW_WIDTH;
+        }
+        view.setNeedsDisplay(true);
+    }
+    return new Point (width, height);
+}
+
+void createWidget() {
+    createJNIRef ();
+    if ((style & DWT.SEPARATOR) !is 0) {
+        SWTBox widget = (SWTBox)new SWTBox().alloc();
+        widget.initWithFrame(new NSRect());
+        widget.setBoxType(OS.NSBoxSeparator);
+        widget.setTag(jniRef);
+        view = widget;
+    } else {
+        SWTView widget = (SWTView)new SWTView().alloc();
+        widget.initWithFrame(new NSRect());
+        widget.setTag(parent.jniRef);
+        parent.contentView().addSubview_(widget);
+        button = (NSButton)new SWTButton().alloc();
+        button.initWithFrame(new NSRect());
+        button.setBordered(false);
+        button.setAction(OS.sel_sendSelection);
+        button.setTarget(button);
+        button.setTag(jniRef);
+        button.setImagePosition(OS.NSImageOverlaps);
+        button.setTitle(NSString.stringWith(""));
+        button.setEnabled(parent.getEnabled());
+        widget.addSubview_(button);
+        if ((style & DWT.DROP_DOWN) !is 0) {
+            arrow = (NSButton)new SWTButton().alloc();
+            arrow.initWithFrame(new NSRect());
+            arrow.setBordered(false);
+            arrow.setAction(OS.sel_sendArrowSelection);
+            arrow.setTarget(arrow);
+            arrow.setTag(jniRef);
+            arrow.setEnabled(parent.getEnabled());
+            widget.addSubview_(arrow);
+        }
+        view = widget;
+    }
+}
+void destroyWidget() {
+    parent.destroyItem(this);
+    super.destroyWidget();
+}
+
+void drawRect(int id, NSRect rect) {
+    super.drawRect(id, rect);
+    if (getSelection ()) {
+        NSRect bounds = view.bounds();
+        NSGraphicsContext context = NSGraphicsContext.currentContext();
+        context.saveGraphicsState();
+        NSColor.colorWithDeviceRed(0.1f, 0.1f, 0.1f, 0.1f).setFill();
+        NSColor.colorWithDeviceRed(0.2f, 0.2f, 0.2f, 0.2f).setStroke();
+        NSBezierPath.fillRect(bounds);
+        bounds.x += 0.5f;
+        bounds.y += 0.5f;
+        bounds.width -= 1;
+        bounds.height -= 1;
+        NSBezierPath.strokeRect(bounds);
+        context.restoreGraphicsState();
+    }
+    if (arrow !is null && id is arrow.id) {
+        NSRect frame = arrow.frame();
+        NSGraphicsContext context = NSGraphicsContext.currentContext();
+        context.saveGraphicsState();
+        NSPoint p1 = new NSPoint();
+        p1.y = (float)Math.ceil(frame.height / 2 - frame.width / 2);
+        NSPoint p2 = new NSPoint();
+        p2.x = frame.width;
+        p2.y = p1.y;
+        NSPoint p3 = new NSPoint();
+        p3.x = frame.width / 2;
+        p3.y = (float)(p2.y + Math.sqrt(Math.pow(frame.width, 2) - Math.pow(frame.width / 2, 2)));
+        NSBezierPath path = NSBezierPath.bezierPath();
+        path.moveToPoint(p1);
+        path.lineToPoint(p2);
+        path.lineToPoint(p3);
+        path.closePath();
+        NSColor color = isEnabled() ? NSColor.blackColor() : NSColor.disabledControlTextColor();
+        color.set();
+        path.fill();
+        context.restoreGraphicsState();
+    }
+}
+
+void enableWidget(bool enabled) {
+    if ((style & DWT.SEPARATOR) is 0) {
+        ((NSButton)button).setEnabled(enabled);
+        if (arrow !is null) {
+            ((NSButton)arrow).setEnabled(enabled);
+        }
+    }
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+    checkWidget();
+    NSRect rect = view.frame();
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns the control that is used to fill the bounds of
+ * the item when the item is a <code>SEPARATOR</code>.
+ *
+ * @return the control
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+    checkWidget();
+    return control;
+}
+
+/**
+ * Returns the receiver's disabled image if it has one, or null
+ * if it does not.
+ * <p>
+ * The disabled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @return the receiver's disabled image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getDisabledImage () {
+    checkWidget();
+    return disabledImage;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public bool getEnabled () {
+    checkWidget();
+    return (state & DISABLED) is 0;
+}
+
+/**
+ * Returns the receiver's hot image if it has one, or null
+ * if it does not.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @return the receiver's hot image
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getHotImage () {
+    checkWidget();
+    return hotImage;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>ToolBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolBar getParent () {
+    checkWidget();
+    return parent;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked (which some platforms draw as a
+ * pushed in button). If the receiver is of any other type, this method
+ * returns false.
+ * </p>
+ *
+ * @return the selection state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getSelection () {
+    checkWidget();
+    if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return false;
+    return selection;
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+    checkWidget();
+    return toolTipText;
+}
+
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getWidth () {
+    checkWidget();
+    return width;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public bool isEnabled () {
+    checkWidget();
+    return getEnabled () && parent.isEnabled ();
+}
+
+void releaseParent () {
+    super.releaseParent ();
+    setVisible (false);
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (view !is null) {
+        OS.objc_msgSend(view.id, OS.sel_setTag_1, -1);
+        view.release();
+    }
+    if (button !is null) {
+        OS.objc_msgSend(button.id, OS.sel_setTag_1, -1);
+        button.release();
+    }
+    if (arrow !is null) {
+        OS.objc_msgSend(arrow.id, OS.sel_setTag_1, -1);
+        arrow.release();
+    }
+    view = button = arrow = null;
+    parent = null;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    control = null;
+    toolTipText = null;
+    image = disabledImage = hotImage = null; 
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.Selection, listener);
+    eventTable.unhook(DWT.DefaultSelection,listener);   
+}
+
+void selectRadio () {
+    int index = 0;
+    ToolItem [] items = parent.getItems ();
+    while (index < items.length && items [index] !is this) index++;
+    int i = index - 1;
+    while (i >= 0 && items [i].setRadioSelection (false)) --i;
+    int j = index + 1;
+    while (j < items.length && items [j].setRadioSelection (false)) j++;
+    setSelection (true);
+}
+
+void sendArrowSelection () {
+    NSRect frame = view.frame();
+    Event event = new Event ();
+    event.detail = DWT.ARROW;
+    event.x = (int)frame.x;
+    event.y = (int)(frame.y + arrow.frame().height);
+    postEvent (DWT.Selection, event);
+}
+
+void sendSelection () {
+    if ((style & DWT.RADIO) !is 0) {
+        if ((parent.getStyle () & DWT.NO_RADIO_GROUP) is 0) {
+            selectRadio ();
+        }
+    }
+    if ((style & DWT.CHECK) !is 0) setSelection (!getSelection ());
+    postEvent (DWT.Selection);
+}
+
+void setBounds (int x, int y, int width, int height) {
+    NSRect rect = new NSRect();
+    rect.x = x;
+    rect.y = y;
+    rect.width = width;
+    rect.height = height;
+    view.setFrame(rect);
+    if (arrow !is null) {
+        rect = button.frame();
+        NSRect arrowRect = new NSRect();
+        arrowRect.x = rect.width + ARROW_INSET;
+        arrowRect.width = ARROW_WIDTH;
+        arrowRect.height = rect.height;
+        arrow.setFrame(arrowRect);
+    }
+}
+
+/**
+ * Sets the control that is used to fill the bounds of
+ * the item when the item is a <code>SEPARATOR</code>.
+ *
+ * @param control the new control
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+    checkWidget();
+    if (control !is null) {
+        if (control.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (control.parent !is parent) error (DWT.ERROR_INVALID_PARENT);
+    }
+    if ((style & DWT.SEPARATOR) is 0) return;
+    if (this.control is control) return;
+    this.control = control;
+    view.setHidden(control !is null);
+    if (control !is null && !control.isDisposed ()) {
+        control.moveAbove (null);
+    }
+    parent.relayout ();
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise.
+ * <p>
+ * A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ * </p>
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (bool enabled) {
+    checkWidget();
+    if ((state & DISABLED) is 0 && enabled) return;
+    if (enabled) {
+        state &= ~DISABLED;     
+    } else {
+        state |= DISABLED;
+    }
+    enableWidget(enabled);
+}
+
+/**
+ * Sets the receiver's disabled image to the argument, which may be
+ * null indicating that no disabled image should be displayed.
+ * <p>
+ * The disabled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @param image the disabled image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDisabledImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    disabledImage = image;
+    updateImage (true);
+}
+
+/**
+ * Sets the receiver's hot image to the argument, which may be
+ * null indicating that no hot image should be displayed.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @param image the hot image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHotImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    hotImage = image;
+    updateImage (true);
+}
+
+public void setImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    super.setImage (image);
+    updateImage (true);
+}
+
+bool setRadioSelection (bool value) {
+    if ((style & DWT.RADIO) is 0) return false;
+    if (getSelection () !is value) {
+        setSelection (value);
+        postEvent (DWT.Selection);
+    }
+    return true;
+}
+
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked (which some platforms draw as a
+ * pushed in button).
+ * </p>
+ *
+ * @param selected the new selection state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (bool selected) {
+    checkWidget();
+    if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return;
+    this.selection = selected;
+    view.setNeedsDisplay(true);
+}
+
+/**
+ * Sets the receiver's text. The string may include
+ * the mnemonic character.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    super.setText (string);
+    NSString str = NSString.stringWith(string);
+    ((NSButton)button).setTitle(str);
+    parent.relayout ();
+    if (text.length() !is 0 && image !is null) {
+        if ((parent.style & DWT.RIGHT) !is 0) {
+            ((NSButton)button).setImagePosition(OS.NSImageLeft);
+        } else {
+            ((NSButton)button).setImagePosition(OS.NSImageAbove);       
+        }
+    } else {
+        ((NSButton)button).setImagePosition(OS.NSImageOverlaps);            
+    }
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+    checkWidget();
+    toolTipText = string;
+    view.setToolTip(NSString.stringWith(string));
+}
+
+void setVisible (bool visible) {
+    if (visible) {
+        if ((state & HIDDEN) is 0) return;
+        state &= ~HIDDEN;
+    } else {
+        if ((state & HIDDEN) !is 0) return;
+        state |= HIDDEN;
+    }
+    view.setHidden(!visible);
+}
+
+/**
+ * Sets the width of the receiver, for <code>SEPARATOR</code> ToolItems.
+ *
+ * @param width the new width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWidth (int width) {
+    checkWidget();
+    if ((style & DWT.SEPARATOR) is 0) return;
+    if (width < 0 || this.width is width) return;
+    this.width = width;
+    parent.relayout();
+}
+
+void updateImage (bool layout) {
+    if ((style & DWT.SEPARATOR) !is 0) return;
+    Image image = null;
+    if (hotImage !is null) {
+        image = hotImage;
+    } else {
+        if (this.image !is null) {
+            image = this.image;
+        } else {
+            image = disabledImage;
+        }
+    }
+    ((NSButton)button).setImage(image !is null ? image.handle : null);
+    if (text.length() !is 0 && image !is null) {
+        if ((parent.style & DWT.RIGHT) !is 0) {
+            ((NSButton)button).setImagePosition(OS.NSImageLeft);
+        } else {
+            ((NSButton)button).setImagePosition(OS.NSImageAbove);       
+        }
+    } else {
+        ((NSButton)button).setImagePosition(OS.NSImageOverlaps);            
+    }
+    parent.relayout();
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/ToolTip.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,637 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.ToolTip;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.FontData;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.graphics.Region;
+import dwt.graphics.TextLayout;
+import dwt.graphics.TextStyle;
+
+/**
+ * Instances of this class represent popup windows that are used
+ * to inform or warn the user.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BALLOON, ICON_ERROR, ICON_INFORMATION, ICON_WARNING</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION,
+ * and ICON_WARNING may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation.
+ * </p>
+ * 
+ * @since 3.2
+ */
+public class ToolTip extends Widget {
+    Shell parent, tip;
+    TrayItem item;
+    int x, y;
+    int [] borderPolygon;
+    bool spikeAbove, autohide;
+    Listener listener;
+    TextLayout layoutText, layoutMessage;
+    Region region;
+    Font boldFont;
+    Runnable runnable;
+    
+    static final int BORDER = 5;
+    static final int PADDING = 5;
+    static final int INSET = 4;
+    static final int TIP_HEIGHT = 20;
+    static final int IMAGE_SIZE = 16;
+    static final int DELAY = 10000;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#ICON_ERROR
+ * @see DWT#ICON_INFORMATION
+ * @see DWT#ICON_WARNING
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolTip (Shell parent, int style) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    this.autohide = true;
+    x = y = -1; 
+    Display display = getDisplay ();
+    tip = new Shell (parent, DWT.ON_TOP | DWT.NO_TRIM);
+    Color background = display.getSystemColor (DWT.COLOR_INFO_BACKGROUND);
+    tip.setBackground (background);
+    listener = new Listener () {
+        public void handleEvent (Event event) {
+            switch (event.type) {
+                case DWT.Dispose: onDispose (event); break;
+                case DWT.Paint: onPaint (event); break;
+                case DWT.MouseDown: onMouseDown (event); break;
+            }
+        }
+    };
+    addListener (DWT.Dispose, listener);
+    tip.addListener (DWT.Paint, listener);
+    tip.addListener (DWT.MouseDown, listener);
+}
+
+static int checkStyle (int style) {
+    int mask = DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING;
+    if ((style & mask) is 0) return style;
+    return checkBits (style, DWT.ICON_INFORMATION, DWT.ICON_WARNING, DWT.ICON_ERROR, 0, 0, 0);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the receiver is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the receiver is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+void configure () {
+    Display display = parent.getDisplay ();
+    int x = this.x;
+    int y = this.y;
+    if (x is -1 || y is -1) {
+        Point point = display.getCursorLocation ();
+        x = point.x;
+        y = point.y;
+    }
+    Monitor monitor = parent.getMonitor ();
+    Rectangle dest = monitor.getBounds ();
+    Point size = getSize (dest.width / 4);
+    int w = size.x;
+    int h = size.y;
+    int t = (style & DWT.BALLOON) !is 0 ? TIP_HEIGHT : 0;
+    int i = (style & DWT.BALLOON) !is 0 ? 16 : 0;
+    tip.setSize (w, h + t);
+    int [] polyline;
+    spikeAbove = dest.height >= y + size.y + t;
+    if (dest.width >= x + size.x) {
+        if (dest.height >= y + size.y + t) {
+            polyline = new int [] {
+                0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t, 5, 1+t, 5, t, 
+                16, t, 16, 0, 35, t,
+                w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
+                w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
+                5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t, 
+                0, 5+t};
+            borderPolygon = new int[] {
+                    0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t,  4, 1+t, 5, t, 
+                    16, t, 16, 1, 35, t,
+                    w-6, 0+t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
+                    w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
+                    5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t, 
+                    0, 5+t};
+            tip.setLocation (Math.max (0, x - i), y);
+        } else {
+            polyline = new int [] {
+                0, 5, 1, 5, 1, 3, 3, 1, 5, 1, 5, 0, 
+                w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
+                w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
+                35, h, 16, h+t, 16, h,
+                5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5, 
+                0, 5};
+            borderPolygon = new int[] {
+                    0, 5, 1, 4, 1, 3, 3, 1,  4, 1, 5, 0, 
+                    w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
+                    w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
+                    36, h-1, 16, h+t-1, 16, h-1,
+                    5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6, 
+                    0, 5};
+            tip.setLocation (Math.max (0, x - i), y - size.y - t);
+        }
+    } else {
+        if (dest.height >= y + size.y + t) {
+            polyline = new int [] {
+                0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t, 5, 1+t, 5, t, 
+                w-35, t, w-16, 0, w-16, t,
+                w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
+                w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
+                5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t, 
+                0, 5+t};
+            borderPolygon = new int[] {
+                    0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t,  4, 1+t, 5, t, 
+                    w-35, t, w-17, 2, w-17, t,
+                    w-6, t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
+                    w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
+                    5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t, 
+                    0, 5+t};
+            tip.setLocation (Math.min (dest.width - size.x, x - size.x + i), y);
+        } else {
+            polyline = new int [] {
+                0, 5, 1, 5, 1, 3, 3, 1, 5, 1, 5, 0, 
+                w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
+                w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
+                w-16, h, w-16, h+t, w-35, h,
+                5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5, 
+                0, 5};
+            borderPolygon = new int[] {
+                    0, 5, 1, 4, 1, 3, 3, 1,  4, 1, 5, 0, 
+                    w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
+                    w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
+                    w-17, h-1, w-17, h+t-2, w-36, h-1,
+                    5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6, 
+                    0, 5};
+            tip.setLocation (Math.min (dest.width - size.x, x - size.x + i), y - size.y - t);
+        }
+    }   
+    if ((style & DWT.BALLOON) !is 0) {
+        if (region !is null) region.dispose ();
+        region = new Region (display);
+        region.add (polyline);
+        tip.setRegion (region);
+    }
+}
+
+/**
+ * Returns <code>true</code> if the receiver is automatically
+ * hidden by the platform, and <code>false</code> otherwise.
+ *
+ * @return the receiver's auto hide state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ */
+public bool getAutoHide () {
+    checkWidget ();
+    return autohide;
+}
+
+Point getSize (int maxWidth) {
+    int textWidth = 0, messageWidth = 0;
+    if (layoutText !is null) {
+        layoutText.setWidth (-1);
+        textWidth = layoutText.getBounds ().width;
+    }
+    if (layoutMessage !is null) {
+        layoutMessage.setWidth (-1);
+        messageWidth = layoutMessage.getBounds ().width;
+    }
+    int messageTrim = 2 * INSET + 2 * BORDER + 2 * PADDING;
+    bool hasImage =  layoutText !is null && (style & DWT.BALLOON) !is 0 && (style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING)) !is 0;
+    int textTrim = messageTrim + (hasImage ? IMAGE_SIZE : 0);
+    int width = Math.min (maxWidth, Math.max (textWidth + textTrim, messageWidth + messageTrim));
+    int textHeight = 0, messageHeight = 0;
+    if (layoutText !is null) {
+        layoutText.setWidth (maxWidth - textTrim);  
+        textHeight = layoutText.getBounds ().height;
+    }
+    if (layoutMessage !is null) {
+        layoutMessage.setWidth (maxWidth - messageTrim);
+        messageHeight = layoutMessage.getBounds ().height;
+    }
+    int height = 2 * BORDER + 2 * PADDING + messageHeight;
+    if (layoutText !is null) height += Math.max (IMAGE_SIZE, textHeight) + 2 * PADDING;
+    return new Point (width, height);
+}
+
+/**
+ * Returns the receiver's message, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's message
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getMessage () {
+    checkWidget ();
+    return layoutMessage !is null ? layoutMessage.getText() : "";
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Shell</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Shell getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+    checkWidget ();
+    return layoutText !is null ? layoutText.getText() : "";
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getVisible () {
+    checkWidget ();
+    return tip.getVisible ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public bool isVisible () {
+    checkWidget ();
+    return getVisible ();
+}
+
+void onDispose (Event event) {
+    removeListener (DWT.Dispose, listener);
+    notifyListeners (DWT.Dispose, event);
+    event.type = DWT.None;
+
+    if (runnable !is null) {
+        Display display = getDisplay ();
+        display.timerExec (-1, runnable);
+    }
+    runnable = null;
+    tip.dispose ();
+    tip = null;
+    if (region !is null) region.dispose ();
+    region = null;
+    if (layoutText !is null) layoutText.dispose ();
+    layoutText = null;
+    if (layoutMessage !is null) layoutMessage.dispose ();
+    layoutMessage = null;
+    if (boldFont !is null) boldFont.dispose ();
+    boldFont = null;
+    borderPolygon = null;
+}
+
+void onMouseDown (Event event) {
+    notifyListeners (DWT.Selection, new Event ());
+    setVisible (false);
+}
+
+void onPaint (Event event) {
+    GC gc = event.gc;
+    int x = BORDER + PADDING;
+    int y = BORDER + PADDING;
+    if ((style & DWT.BALLOON) !is 0) {
+        if (spikeAbove) y += TIP_HEIGHT;
+        gc.drawPolygon (borderPolygon);
+    } else {
+        Rectangle rect = tip.getClientArea ();
+        gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height -1);
+    } 
+    if (layoutText !is null) {
+        int id = style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING);
+        if ((style & DWT.BALLOON) !is 0 && id !is 0) {
+            Display display = getDisplay ();
+            Image image = display.getSystemImage (id);
+            Rectangle rect = image.getBounds ();
+            gc.drawImage (image, 0, 0, rect.width, rect.height, x, y, IMAGE_SIZE, IMAGE_SIZE);
+            x += IMAGE_SIZE;
+        }
+        x += INSET;
+        layoutText.draw (gc, x, y);
+        y += 2 * PADDING + Math.max (IMAGE_SIZE, layoutText.getBounds ().height);
+    }
+    if (layoutMessage !is null) {
+        x = BORDER + PADDING + INSET;
+        layoutMessage.draw (gc, x, y);
+    }
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+/**
+ * Makes the receiver hide automatically when <code>true</code>,
+ * and remain visible when <code>false</code>.
+ *
+ * @param autoHide the auto hide state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getVisible
+ * @see #setVisible
+ */
+public void setAutoHide (bool autohide) {
+    checkWidget ();
+    this.autohide = autohide;
+    //TODO - update when visible
+}
+
+/**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the arguments which are relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (int x, int y) {
+    checkWidget ();
+    if (this.x is x && this.y is y) return;
+    this.x = x;
+    this.y = y;
+    if (tip.getVisible ()) configure ();
+}
+
+/**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the argument which is relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p><p>
+ * Note that the platform window manager ultimately has control
+ * over the location of tooltips.
+ * </p>
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (Point location) {
+    checkWidget ();
+    if (location is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    setLocation (location.x, location.y);
+}
+
+/**
+ * Sets the receiver's message.
+ *
+ * @param string the new message
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMessage (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (layoutMessage !is null) layoutMessage.dispose();
+    layoutMessage = null;
+    if (string.length () !is 0) {
+        Display display = getDisplay (); 
+        layoutMessage = new TextLayout (display);
+        layoutMessage.setText (string);
+    }
+    if (tip.getVisible ()) configure ();
+}
+
+/**
+ * Sets the receiver's text.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (layoutText !is null) layoutText.dispose ();
+    layoutText = null;
+    if (boldFont !is null) boldFont.dispose ();
+    boldFont = null;
+    if (string.length () !is 0) {
+        Display display = getDisplay ();
+        layoutText = new TextLayout (display);
+        layoutText.setText (string);
+        Font font = display.getSystemFont ();
+        FontData data = font.getFontData () [0];
+        boldFont = new Font (display, data.getName (), data.getHeight (), DWT.BOLD);
+        TextStyle style = new TextStyle (boldFont, null, null);
+        layoutText.setStyle (style, 0, string.length ());
+    }
+    if (tip.getVisible ()) configure ();
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (bool visible) {
+    if (visible) configure ();
+    tip.setVisible (visible);
+    Display display = getDisplay ();
+    if (runnable !is null) display.timerExec (-1, runnable);
+    runnable = null;
+    if (autohide && visible) {
+        runnable = new Runnable () {
+            public void run () {
+                if (!isDisposed ()) setVisible (false);
+            }
+        };
+        display.timerExec(DELAY, runnable);
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Tracker.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1078 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Tracker;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ControlListener;
+import dwt.events.KeyListener;
+import dwt.graphics.Cursor;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSAffineTransform;
+import dwt.internal.cocoa.NSApplication;
+import dwt.internal.cocoa.NSAutoreleasePool;
+import dwt.internal.cocoa.NSBezierPath;
+import dwt.internal.cocoa.NSDate;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSGraphicsContext;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSScreen;
+import dwt.internal.cocoa.NSWindow;
+import dwt.internal.cocoa.OS;
+
+/**
+ *  Instances of this class implement rubber banding rectangles that are
+ *  drawn onto a parent <code>Composite</code> or <code>Display</code>.
+ *  These rectangles can be specified to respond to mouse and key events
+ *  by either moving or resizing themselves accordingly.  Trackers are
+ *  typically used to represent window geometries in a lightweight manner.
+ *  
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move, Resize</dd>
+ * </dl>
+ * <p>
+ * Note: Rectangle move behavior is assumed unless RESIZE is specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tracker extends Widget {
+    Control parent;
+    bool tracking, cancelled, stippled;
+    Cursor clientCursor, resizeCursor;
+    Rectangle [] rectangles = new Rectangle [0], proportions = rectangles;
+    Rectangle bounds;
+    int cursorOrientation = DWT.NONE;
+    bool inEvent = false;
+    NSWindow window;
+    int oldX, oldY;
+        
+    /*
+    * The following values mirror step sizes on Windows
+    */
+    final static int STEPSIZE_SMALL = 1;
+    final static int STEPSIZE_LARGE = 9;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#UP
+ * @see DWT#DOWN
+ * @see DWT#RESIZE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Tracker (Composite parent, int style) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+}
+
+/**
+ * Constructs a new instance of this class given the display
+ * to create it on and a style value describing its behavior
+ * and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the tracker on the currently active
+ * display if there is one. If there is no current display, the 
+ * tracker is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of DWT.</b>
+ * </p>
+ *
+ * @param display the display to create the tracker on
+ * @param style the style of control to construct
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#UP
+ * @see DWT#DOWN
+ */
+public Tracker (Display display, int style) {
+    if (display is null) display = Display.getCurrent ();
+    if (display is null) display = Display.getDefault ();
+    if (!display.isValidThread ()) {
+        error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    }
+    this.style = checkStyle (style);
+    this.display = display;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener (ControlListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Resize, typedListener);
+    addListener (DWT.Move, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard, by sending
+ * it one of the messages defined in the <code>KeyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #removeKeyListener
+ */
+public void addKeyListener(KeyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener(DWT.KeyUp,typedListener);
+    addListener(DWT.KeyDown,typedListener);
+}
+
+Point adjustMoveCursor () {
+    if (bounds is null) return null;
+    int newX = bounds.x + bounds.width / 2;
+    int newY = bounds.y;
+    /*
+     * Convert to screen coordinates if needed
+     */
+    if (parent !is null) {
+        Point pt = parent.toDisplay (newX, newY);
+        newX = pt.x;
+        newY = pt.y;
+    }
+    display.setCursorLocation(newX, newY);
+    return new Point (newX, newY);
+}
+
+Point adjustResizeCursor (bool movePointer) {
+    if (bounds is null) return null;
+    int newX, newY;
+
+    if ((cursorOrientation & DWT.LEFT) !is 0) {
+        newX = bounds.x;
+    } else if ((cursorOrientation & DWT.RIGHT) !is 0) {
+        newX = bounds.x + bounds.width;
+    } else {
+        newX = bounds.x + bounds.width / 2;
+    }
+
+    if ((cursorOrientation & DWT.UP) !is 0) {
+        newY = bounds.y;
+    } else if ((cursorOrientation & DWT.DOWN) !is 0) {
+        newY = bounds.y + bounds.height;
+    } else {
+        newY = bounds.y + bounds.height / 2;
+    }
+
+    /*
+     * Convert to screen coordinates if needed
+     */
+    if (parent !is null) {
+        Point pt = parent.toDisplay (newX, newY);
+        newX = pt.x;
+        newY = pt.y; 
+    }
+    if (movePointer) {
+        display.setCursorLocation(newX, newY);
+    }
+
+    /*
+    * If the client has not provided a custom cursor then determine
+    * the appropriate resize cursor.
+    */
+    if (clientCursor is null) {
+        Cursor newCursor = null;
+        switch (cursorOrientation) {
+            case DWT.UP:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZENS);
+                break;
+            case DWT.DOWN:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZENS);
+                break;
+            case DWT.LEFT:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZEWE);
+                break;
+            case DWT.RIGHT:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZEWE);
+                break;
+            case DWT.LEFT | DWT.UP:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZENWSE);
+                break;
+            case DWT.RIGHT | DWT.DOWN:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZENWSE);
+                break;
+            case DWT.LEFT | DWT.DOWN:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZENESW);
+                break;
+            case DWT.RIGHT | DWT.UP:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZENESW);
+                break;
+            default:
+                newCursor = new Cursor(display, DWT.CURSOR_SIZEALL);
+                break;
+        }
+        newCursor.handle.set();
+        if (resizeCursor !is null) {
+            resizeCursor.dispose ();
+        }
+        resizeCursor = newCursor;
+    }
+        
+    return new Point (newX, newY);
+}
+
+static int checkStyle (int style) {
+    if ((style & (DWT.LEFT | DWT.RIGHT | DWT.UP | DWT.DOWN)) is 0) {
+        style |= DWT.LEFT | DWT.RIGHT | DWT.UP | DWT.DOWN;
+    }
+    return style;
+}
+
+/**
+ * Stops displaying the tracker rectangles.  Note that this is not considered
+ * to be a cancelation by the user.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void close () {
+    checkWidget ();
+    tracking = false;
+}
+Rectangle computeBounds () {
+    if (rectangles.length is 0) return null;
+    int xMin = rectangles [0].x;
+    int yMin = rectangles [0].y;
+    int xMax = rectangles [0].x + rectangles [0].width;
+    int yMax = rectangles [0].y + rectangles [0].height;
+    
+    for (int i = 1; i < rectangles.length; i++) {
+        if (rectangles [i].x < xMin) xMin = rectangles [i].x;
+        if (rectangles [i].y < yMin) yMin = rectangles [i].y;
+        int rectRight = rectangles [i].x + rectangles [i].width;
+        if (rectRight > xMax) xMax = rectRight;     
+        int rectBottom = rectangles [i].y + rectangles [i].height;
+        if (rectBottom > yMax) yMax = rectBottom;
+    }
+    
+    return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
+}
+
+Rectangle [] computeProportions (Rectangle [] rects) {
+    Rectangle [] result = new Rectangle [rects.length];
+    bounds = computeBounds ();
+    if (bounds !is null) {
+        for (int i = 0; i < rects.length; i++) {
+            int x = 0, y = 0, width = 0, height = 0;
+            if (bounds.width !is 0) {
+                x = (rects [i].x - bounds.x) * 100 / bounds.width;
+                width = rects [i].width * 100 / bounds.width;
+            } else {
+                width = 100;
+            }
+            if (bounds.height !is 0) {
+                y = (rects [i].y - bounds.y) * 100 / bounds.height;
+                height = rects [i].height * 100 / bounds.height;
+            } else {
+                height = 100;
+            }
+            result [i] = new Rectangle (x, y, width, height);           
+        }
+    }
+    return result;
+}
+
+void drawRectangles (NSWindow window, Rectangle [] rects, bool erase) {
+    NSRect frame = window.frame();
+    NSGraphicsContext context = window.graphicsContext();
+    NSGraphicsContext.setCurrentContext(context);
+    NSAffineTransform transform = NSAffineTransform.transform();
+    context.saveGraphicsState();
+    transform.scaleXBy(1, -1);
+    transform.translateXBy(0, -frame.height);
+    transform.concat();
+    Point parentOrigin;
+    if (parent !is null) {
+        parentOrigin = display.map (parent, null, 0, 0);
+    } else {
+        parentOrigin = new Point (0, 0);    
+    }
+    context.setCompositingOperation(erase ? OS.NSCompositeClear : OS.NSCompositeSourceOver);
+    for (int i=0; i<rects.length; i++) {
+        Rectangle rect = rects [i];
+        frame.x = rect.x + parentOrigin.x;
+        frame.y = rect.y + parentOrigin.y;
+        frame.width = rect.width;
+        frame.height = rect.height;
+        if (erase) {
+            frame.width++;
+            frame.height++;
+            NSBezierPath.fillRect(frame);
+        } else {
+            frame.x += 0.5f;
+            frame.y += 0.5f;
+            NSBezierPath.strokeRect(frame);
+        }
+    }
+    context.flushGraphics();
+    context.restoreGraphicsState();
+}
+
+/**
+ * Returns the bounds that are being drawn, expressed relative to the parent
+ * widget.  If the parent is a <code>Display</code> then these are screen
+ * coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle [] getRectangles () {
+    checkWidget();
+    Rectangle [] result = new Rectangle [rectangles.length];
+    for (int i = 0; i < rectangles.length; i++) {
+        Rectangle current = rectangles [i];
+        result [i] = new Rectangle (current.x, current.y, current.width, current.height);
+    }
+    return result;
+}
+
+/**
+ * Returns <code>true</code> if the rectangles are drawn with a stippled line, <code>false</code> otherwise.
+ *
+ * @return the stippled effect of the rectangles
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getStippled () {
+    checkWidget ();
+    return stippled;
+}
+
+void mouse (NSEvent nsEvent) {
+    NSPoint location = nsEvent.locationInWindow();
+    if (parent !is null) {
+        location = parent.view.convertPoint_toView_(location, parent.view);
+    } else {
+        NSWindow eventWindow = nsEvent.window();
+        location = eventWindow.convertBaseToScreen(location);
+        location.y = eventWindow.screen().frame().height - location.y;
+    }
+    int newX = (int)location.x, newY = (int)location.y;
+    if (newX !is oldX || newY !is oldY) {
+        Rectangle [] oldRectangles = rectangles;
+        Rectangle [] rectsToErase = new Rectangle [rectangles.length];
+        for (int i = 0; i < rectangles.length; i++) {
+            Rectangle current = rectangles [i];
+            rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
+        }
+        Event event = new Event ();
+        event.x = newX;
+        event.y = newY;
+        if ((style & DWT.RESIZE) !is 0) {
+            bool orientationInit = resizeRectangles (newX - oldX, newY - oldY);
+            inEvent = true;
+            sendEvent (DWT.Resize, event);
+            inEvent = false;
+            /*
+            * It is possible (but unlikely), that application
+            * code could have disposed the widget in the move
+            * event.  If this happens, return false to indicate
+            * that the tracking has failed.
+            */
+            if (isDisposed ()) {
+                cancelled = true;
+                return;
+            }
+            bool draw = false;
+            /*
+             * It is possible that application code could have
+             * changed the rectangles in the resize event.  If this
+             * happens then only redraw the tracker if the rectangle
+             * values have changed.
+             */
+            if (rectangles !is oldRectangles) {
+                int length = rectangles.length;
+                if (length !is rectsToErase.length) {
+                    draw = true;
+                } else {
+                    for (int i = 0; i < length; i++) {
+                        if (!rectangles [i].equals (rectsToErase [i])) {
+                            draw = true;
+                            break;
+                        }
+                    }
+                }
+            }
+            else {
+                draw = true;
+            }
+            if (draw) {
+                drawRectangles (window, rectsToErase, true);
+                drawRectangles (window, rectangles, false);
+            }
+            Point cursorPos = adjustResizeCursor (orientationInit);
+            if (cursorPos !is null) {
+                newX = cursorPos.x;
+                newY = cursorPos.y;
+            }
+        } else {
+            moveRectangles (newX - oldX, newY - oldY);
+            inEvent = true;
+            sendEvent (DWT.Move, event);
+            inEvent = false;
+            /*
+            * It is possible (but unlikely), that application
+            * code could have disposed the widget in the move
+            * event.  If this happens, return false to indicate
+            * that the tracking has failed.
+            */
+            if (isDisposed ()) {
+                cancelled = true;
+                return;
+            }
+            bool draw = false;
+            /*
+             * It is possible that application code could have
+             * changed the rectangles in the move event.  If this
+             * happens then only redraw the tracker if the rectangle
+             * values have changed.
+             */
+            if (rectangles !is oldRectangles) {
+                int length = rectangles.length;
+                if (length !is rectsToErase.length) {
+                    draw = true;
+                } else {
+                    for (int i = 0; i < length; i++) {
+                        if (!rectangles [i].equals (rectsToErase [i])) {
+                            draw = true;
+                            break;
+                        }
+                    }
+                }
+            } else {
+                draw = true;
+            }
+            if (draw) {
+                drawRectangles (window, rectsToErase, true);
+                drawRectangles (window, rectangles, false);
+            }
+        }
+        oldX = newX;  oldY = newY;
+    }
+    switch (nsEvent.type()) {
+        case OS.NSLeftMouseUp:
+        case OS.NSRightMouseUp:
+        case OS.NSOtherMouseUp:
+            tracking = false;
+    }
+}
+
+void key (NSEvent nsEvent) {
+    //TODO send event
+//  if (!sendKeyEvent (DWT.KeyDown, theEvent)) return OS.noErr;
+    int modifierFlags = nsEvent.modifierFlags();
+    int stepSize = (modifierFlags & OS.NSControlKeyMask) !is 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
+    int xChange = 0, yChange = 0;
+    switch (nsEvent.keyCode()) {
+        case 53: /* Esc */
+            cancelled = true;
+            tracking = false;
+            break;
+        case 76: /* KP Enter */
+        case 36: /* Return */
+            tracking = false;
+            break;
+        case 123: /* Left arrow */
+            xChange = -stepSize;
+            break;
+        case 124: /* Right arrow */
+            xChange = stepSize;
+            break;
+        case 126: /* Up arrow */
+            yChange = -stepSize;
+            break;
+        case 125: /* Down arrow */
+            yChange = stepSize;
+            break;
+    }
+    if (xChange !is 0 || yChange !is 0) {
+        Rectangle [] oldRectangles = rectangles;
+        Rectangle [] rectsToErase = new Rectangle [rectangles.length];
+        for (int i = 0; i < rectangles.length; i++) {
+            Rectangle current = rectangles [i];
+            rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
+        }
+        Event event = new Event ();
+        int newX = oldX + xChange;
+        int newY = oldY + yChange;
+        event.x = newX;
+        event.y = newY;
+        Point cursorPos;
+        if ((style & DWT.RESIZE) !is 0) {
+            resizeRectangles (xChange, yChange);
+            inEvent = true;
+            sendEvent (DWT.Resize, event);
+            inEvent = false;
+            /*
+            * It is possible (but unlikely) that application
+            * code could have disposed the widget in the move
+            * event.  If this happens return false to indicate
+            * that the tracking has failed.
+            */
+            if (isDisposed ()) {
+                cancelled = true;
+                return;
+            }
+            bool draw = false;
+            /*
+             * It is possible that application code could have
+             * changed the rectangles in the resize event.  If this
+             * happens then only redraw the tracker if the rectangle
+             * values have changed.
+             */
+            if (rectangles !is oldRectangles) {
+                int length = rectangles.length;
+                if (length !is rectsToErase.length) {
+                    draw = true;
+                } else {
+                    for (int i = 0; i < length; i++) {
+                        if (!rectangles [i].equals (rectsToErase [i])) {
+                            draw = true;
+                            break;
+                        }
+                    }
+                }
+            } else {
+                draw = true;
+            }
+            if (draw) {
+                drawRectangles (window, rectsToErase, true);
+                drawRectangles (window, rectangles, false);
+            }
+            cursorPos = adjustResizeCursor (true);
+        } else {
+            moveRectangles (xChange, yChange);
+            inEvent = true;
+            sendEvent (DWT.Move, event);
+            inEvent = false;
+            /*
+            * It is possible (but unlikely) that application
+            * code could have disposed the widget in the move
+            * event.  If this happens return false to indicate
+            * that the tracking has failed.
+            */
+            if (isDisposed ()) {
+                cancelled = true;
+                return;
+            }
+            bool draw = false;
+            /*
+             * It is possible that application code could have
+             * changed the rectangles in the move event.  If this
+             * happens then only redraw the tracker if the rectangle
+             * values have changed.
+             */
+            if (rectangles !is oldRectangles) {
+                int length = rectangles.length;
+                if (length !is rectsToErase.length) {
+                    draw = true;
+                } else {
+                    for (int i = 0; i < length; i++) {
+                        if (!rectangles [i].equals (rectsToErase [i])) {
+                            draw = true;
+                            break;
+                        }
+                    }
+                }
+            } else {
+                draw = true;
+            }
+            if (draw) {
+                drawRectangles (window, rectsToErase, true);
+                drawRectangles (window, rectangles, false);
+            }
+            cursorPos = adjustMoveCursor ();
+        }
+        if (cursorPos !is null) {
+            oldX = cursorPos.x;
+            oldY = cursorPos.y;
+        }
+    }
+}
+
+void moveRectangles (int xChange, int yChange) {
+    if (bounds is null) return;
+    if (xChange < 0 && ((style & DWT.LEFT) is 0)) xChange = 0;
+    if (xChange > 0 && ((style & DWT.RIGHT) is 0)) xChange = 0;
+    if (yChange < 0 && ((style & DWT.UP) is 0)) yChange = 0;
+    if (yChange > 0 && ((style & DWT.DOWN) is 0)) yChange = 0;
+    if (xChange is 0 && yChange is 0) return;
+    bounds.x += xChange; bounds.y += yChange;
+    for (int i = 0; i < rectangles.length; i++) {
+        rectangles [i].x += xChange;
+        rectangles [i].y += yChange;
+    }
+}
+
+/**
+ * Displays the Tracker rectangles for manipulation by the user.  Returns when
+ * the user has either finished manipulating the rectangles or has cancelled the
+ * Tracker.
+ * 
+ * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool open () {
+    checkWidget ();
+    cancelled = false;
+    tracking = true;
+    window = (NSWindow)new NSWindow().alloc();
+    NSRect frame = NSScreen.mainScreen().frame();
+    window = window.initWithContentRect_styleMask_backing_defer_(frame, OS.NSBorderlessWindowMask, OS.NSBackingStoreBuffered, false);
+    window.setOpaque(false);
+    window.setContentView(null);
+    NSGraphicsContext context = window.graphicsContext();
+    NSGraphicsContext.setCurrentContext(context);
+    context.setCompositingOperation(OS.NSCompositeClear);
+    NSBezierPath.fillRect(frame);
+    window.orderFrontRegardless();
+
+    drawRectangles (window, rectangles, false);
+    
+    /*
+    * If exactly one of UP/DOWN is specified as a style then set the cursor
+    * orientation accordingly (the same is done for LEFT/RIGHT styles below).
+    */
+    int vStyle = style & (DWT.UP | DWT.DOWN);
+    if (vStyle is DWT.UP || vStyle is DWT.DOWN) {
+        cursorOrientation |= vStyle;
+    }
+    int hStyle = style & (DWT.LEFT | DWT.RIGHT);
+    if (hStyle is DWT.LEFT || hStyle is DWT.RIGHT) {
+        cursorOrientation |= hStyle;
+    }
+    
+    Point cursorPos;
+    bool down = false;
+    NSApplication application = NSApplication.sharedApplication();
+    NSEvent currentEvent = application.currentEvent();
+    switch (currentEvent.type()) {
+        case OS.NSLeftMouseDown:
+        case OS.NSRightMouseDown:
+        case OS.NSOtherMouseDown:
+            down = true;
+    }
+    if (down) {
+        cursorPos = display.getCursorLocation();
+    } else {
+        if ((style & DWT.RESIZE) !is 0) {
+            cursorPos = adjustResizeCursor (true);
+        } else {
+            cursorPos = adjustMoveCursor ();
+        }
+    }
+    if (cursorPos !is null) {
+        oldX = cursorPos.x;
+        oldY = cursorPos.y;
+    }
+
+    /* Tracker behaves like a Dialog with its own OS event loop. */
+    while (tracking && !cancelled) {
+        NSAutoreleasePool pool = (NSAutoreleasePool)new NSAutoreleasePool().alloc().init();
+        NSEvent event = application.nextEventMatchingMask(0, NSDate.distantFuture(), OS.NSDefaultRunLoopMode, true);
+        if (event is null) continue;
+        int type = event.type();
+        switch (type) {
+            case OS.NSLeftMouseUp:
+            case OS.NSRightMouseUp:
+            case OS.NSOtherMouseUp:
+            case OS.NSMouseMoved:
+            case OS.NSLeftMouseDragged:
+            case OS.NSRightMouseDragged:
+            case OS.NSOtherMouseDragged:
+                mouse(event);
+                break;
+            case OS.NSKeyDown:
+//          case OS.NSKeyUp:
+            case OS.NSFlagsChanged:
+                key(event);
+                break;
+        }
+        /*
+        * Don't dispatch mouse and key events in general, EXCEPT once this
+        * tracker has finished its work.
+        */
+        bool dispatch = true;
+        if (!(tracking && !cancelled)) {
+            switch (type) {
+                case OS.NSLeftMouseDown:
+                case OS.NSLeftMouseUp:
+                case OS.NSRightMouseDown:
+                case OS.NSRightMouseUp:
+                case OS.NSOtherMouseDown:
+                case OS.NSOtherMouseUp:
+                case OS.NSMouseMoved:
+                case OS.NSLeftMouseDragged:
+                case OS.NSRightMouseDragged:
+                case OS.NSOtherMouseDragged:
+                case OS.NSMouseEntered:
+                case OS.NSMouseExited:
+                case OS.NSKeyDown:
+                case OS.NSKeyUp:
+                case OS.NSFlagsChanged:
+                    dispatch = false;
+            }
+        }
+        if (dispatch) application.sendEvent(event);
+        if (clientCursor !is null && resizeCursor is null) {
+            clientCursor.handle.set();
+        }
+        pool.release();
+    }
+    if (!isDisposed()) {
+        drawRectangles (window, rectangles, true);
+    }
+    if (window !is null) window.close();
+    tracking = false;
+    window = null;
+    return !cancelled;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    parent = null;
+    rectangles = proportions = null;
+    bounds = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Resize, listener);
+    eventTable.unhook (DWT.Move, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #addKeyListener
+ */
+public void removeKeyListener(KeyListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook(DWT.KeyUp, listener);
+    eventTable.unhook(DWT.KeyDown, listener);
+}
+
+/*
+ * Returns true if the pointer's orientation was initialized in some dimension,
+ * and false otherwise.
+ */
+bool resizeRectangles (int xChange, int yChange) {
+    if (bounds is null) return false;
+    bool orientationInit = false;
+    /*
+    * If the cursor orientation has not been set in the orientation of
+    * this change then try to set it here.
+    */
+    if (xChange < 0 && ((style & DWT.LEFT) !is 0) && ((cursorOrientation & DWT.RIGHT) is 0)) {
+        if ((cursorOrientation & DWT.LEFT) is 0) {
+            cursorOrientation |= DWT.LEFT;
+            orientationInit = true;
+        }
+    }
+    if (xChange > 0 && ((style & DWT.RIGHT) !is 0) && ((cursorOrientation & DWT.LEFT) is 0)) {
+        if ((cursorOrientation & DWT.RIGHT) is 0) {
+            cursorOrientation |= DWT.RIGHT;
+            orientationInit = true;
+        }
+    } 
+    if (yChange < 0 && ((style & DWT.UP) !is 0) && ((cursorOrientation & DWT.DOWN) is 0)) {
+        if ((cursorOrientation & DWT.UP) is 0) {
+            cursorOrientation |= DWT.UP;
+            orientationInit = true;
+        }
+    } 
+    if (yChange > 0 && ((style & DWT.DOWN) !is 0) && ((cursorOrientation & DWT.UP) is 0)) {
+        if ((cursorOrientation & DWT.DOWN) is 0) {
+            cursorOrientation |= DWT.DOWN;
+            orientationInit = true;
+        }
+    }
+    
+    /*
+     * If the bounds will flip about the x or y axis then apply the adjustment
+     * up to the axis (ie.- where bounds width/height becomes 0), change the
+     * cursor's orientation accordingly, and flip each Rectangle's origin (only
+     * necessary for > 1 Rectangles) 
+     */
+    if ((cursorOrientation & DWT.LEFT) !is 0) {
+        if (xChange > bounds.width) {
+            if ((style & DWT.RIGHT) is 0) return orientationInit;
+            cursorOrientation |= DWT.RIGHT;
+            cursorOrientation &= ~DWT.LEFT;
+            bounds.x += bounds.width;
+            xChange -= bounds.width;
+            bounds.width = 0;
+            if (proportions.length > 1) {
+                for (int i = 0; i < proportions.length; i++) {
+                    Rectangle proportion = proportions [i];
+                    proportion.x = 100 - proportion.x - proportion.width;
+                }
+            }
+        }
+    } else if ((cursorOrientation & DWT.RIGHT) !is 0) {
+        if (bounds.width < -xChange) {
+            if ((style & DWT.LEFT) is 0) return orientationInit;
+            cursorOrientation |= DWT.LEFT;
+            cursorOrientation &= ~DWT.RIGHT;
+            xChange += bounds.width;
+            bounds.width = 0;
+            if (proportions.length > 1) {
+                for (int i = 0; i < proportions.length; i++) {
+                    Rectangle proportion = proportions [i];
+                    proportion.x = 100 - proportion.x - proportion.width;
+                }
+            }
+        }
+    }
+    if ((cursorOrientation & DWT.UP) !is 0) {
+        if (yChange > bounds.height) {
+            if ((style & DWT.DOWN) is 0) return orientationInit;
+            cursorOrientation |= DWT.DOWN;
+            cursorOrientation &= ~DWT.UP;
+            bounds.y += bounds.height;
+            yChange -= bounds.height;
+            bounds.height = 0;
+            if (proportions.length > 1) {
+                for (int i = 0; i < proportions.length; i++) {
+                    Rectangle proportion = proportions [i];
+                    proportion.y = 100 - proportion.y - proportion.height;
+                }
+            }
+        }
+    } else if ((cursorOrientation & DWT.DOWN) !is 0) {
+        if (bounds.height < -yChange) {
+            if ((style & DWT.UP) is 0) return orientationInit;
+            cursorOrientation |= DWT.UP;
+            cursorOrientation &= ~DWT.DOWN;
+            yChange += bounds.height;
+            bounds.height = 0;
+            if (proportions.length > 1) {
+                for (int i = 0; i < proportions.length; i++) {
+                    Rectangle proportion = proportions [i];
+                    proportion.y = 100 - proportion.y - proportion.height;
+                }
+            }
+        }
+    }
+    
+    // apply the bounds adjustment
+    if ((cursorOrientation & DWT.LEFT) !is 0) {
+        bounds.x += xChange;
+        bounds.width -= xChange;
+    } else if ((cursorOrientation & DWT.RIGHT) !is 0) {
+        bounds.width += xChange;
+    }
+    if ((cursorOrientation & DWT.UP) !is 0) {
+        bounds.y += yChange;
+        bounds.height -= yChange;
+    } else if ((cursorOrientation & DWT.DOWN) !is 0) {
+        bounds.height += yChange;
+    }
+    
+    Rectangle [] newRects = new Rectangle [rectangles.length];
+    for (int i = 0; i < rectangles.length; i++) {
+        Rectangle proportion = proportions[i];
+        newRects[i] = new Rectangle (
+            proportion.x * bounds.width / 100 + bounds.x,
+            proportion.y * bounds.height / 100 + bounds.y,
+            proportion.width * bounds.width / 100,
+            proportion.height * bounds.height / 100);
+    }
+    rectangles = newRects;
+    return orientationInit;
+}
+
+/**
+ * Sets the <code>Cursor</code> of the Tracker.  If this cursor is <code>null</code>
+ * then the cursor reverts to the default.
+ *
+ * @param newCursor the new <code>Cursor</code> to display
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor newCursor) {
+    checkWidget ();
+    clientCursor = newCursor;
+    if (newCursor !is null) {
+        if (inEvent) newCursor.handle.set();
+    }
+}
+
+/**
+ * Specifies the rectangles that should be drawn, expressed relative to the parent
+ * widget.  If the parent is a Display then these are screen coordinates.
+ *
+ * @param rectangles the bounds of the rectangles to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the set of rectangles is null or contains a null rectangle</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setRectangles (Rectangle [] rectangles) {
+    checkWidget ();
+    if (rectangles is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int length = rectangles.length;
+    this.rectangles = new Rectangle [length];
+    for (int i = 0; i < length; i++) {
+        Rectangle current = rectangles [i];
+        if (current is null) error (DWT.ERROR_NULL_ARGUMENT);
+        this.rectangles [i] = new Rectangle (current.x, current.y, current.width, current.height);
+    }
+    proportions = computeProportions (rectangles);
+}
+
+/**
+ * Changes the appearance of the line used to draw the rectangles.
+ *
+ * @param stippled <code>true</code> if rectangle should appear stippled
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setStippled (bool stippled) {
+    checkWidget ();
+    this.stippled = stippled;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Tray.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Tray;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+
+/**
+ * Instances of this class represent the system tray that is part
+ * of the task bar status area on some operating systems.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see Display#getSystemTray
+ * 
+ * @since 3.0
+ */
+public class Tray extends Widget {
+    int itemCount;
+    TrayItem [] items = new TrayItem [4];
+
+Tray (Display display, int style) {
+    if (display is null) display = Display.getCurrent ();
+    if (display is null) display = Display.getDefault ();
+    if (!display.isValidThread ()) {
+        error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    }
+    this.display = display;
+}
+    
+void createItem (TrayItem item, int index) {
+    if (!(0 <= index && index <= itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (itemCount is items.length) {
+        TrayItem [] newItems = new TrayItem [items.length + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+    }
+    System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+    items [index] = item;
+}
+
+void destroyItem (TrayItem item) {
+    int index = 0;
+    while (index < itemCount) {
+        if (items [index] is item) break;
+        index++;
+    }
+    if (index is itemCount) return;
+    System.arraycopy (items, index + 1, items, index, --itemCount - index);
+    items [itemCount] = null;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TrayItem getItem (int index) {
+    checkWidget ();
+    if (!(0 <= index && index < itemCount)) error (DWT.ERROR_INVALID_RANGE);
+    return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    return itemCount;
+}
+
+/**
+ * Returns an array of <code>TrayItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TrayItem [] getItems () {
+    checkWidget ();
+    TrayItem [] result = new TrayItem [itemCount];
+    System.arraycopy (items, 0, result, 0, result.length);
+    return result;
+}
+
+void releaseChildren (bool destroy) {
+    if (items !is null) {
+        for (int i=0; i<items.length; i++) {
+            TrayItem item = items [i];
+            if (item !is null && !item.isDisposed ()) {
+                item.release (false);
+            }
+        }
+        items = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void releaseParent () {
+    super.releaseParent ();
+    if (display.tray is this) display.tray = null;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TrayItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,453 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TrayItem;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.MenuDetectListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSImageView;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSStatusBar;
+import dwt.internal.cocoa.NSStatusItem;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTImageView;
+
+/**
+ * Instances of this class represent icons that can be placed on the
+ * system tray or task bar status area.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, MenuDetect, Selection</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @since 3.0
+ */
+public class TrayItem extends Item {
+    Tray parent;
+    ToolTip toolTip;
+    String toolTipText;
+    bool visible = true, highlight;
+    NSStatusItem item;
+    NSImageView view;
+    
+    static final float BORDER = 8f;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tray</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TrayItem (Tray parent, int style) {
+    super (parent, style);
+    this.parent = parent;
+    parent.createItem (this, parent.getItemCount ());
+    createWidget ();
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the platform-specific context menu trigger
+ * has occurred, by sending it one of the messages defined in
+ * the <code>MenuDetectListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #removeMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void addMenuDetectListener (MenuDetectListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.MenuDetect, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the receiver is selected
+ * <code>widgetDefaultSelected</code> is called when the receiver is double-clicked
+ * </p>
+ *
+ * @param listener the listener which should be notified when the receiver is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createWidget () {
+    NSStatusBar statusBar = NSStatusBar.systemStatusBar();
+    item = statusBar.statusItemWithLength(0);
+    if (item is null) error (DWT.ERROR_NO_HANDLES);
+    item.retain();
+    item.setHighlightMode(true);    
+    NSRect rect = new NSRect();
+    view = (NSImageView)new SWTImageView().alloc();
+    if (view is null) error (DWT.ERROR_NO_HANDLES);
+    view.initWithFrame(rect);
+    item.setView(view);
+    createJNIRef();
+    view.setTag(jniRef);
+}
+
+void destroyWidget () {
+    parent.destroyItem (this);
+    releaseHandle ();
+}
+
+Point getLocation () {
+    NSRect rect = view.frame();
+    NSRect windowRect = view.window().frame();
+    NSPoint pt = new NSPoint();
+    pt.x = rect.width / 2;
+    pt.y = rect.height;
+    pt = view.convertPoint_fromView_(pt, null);
+    pt.x += windowRect.x;
+    return new Point ((int)pt.x, (int)pt.y);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Tray</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Tray getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Returns the receiver's tool tip, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public ToolTip getToolTip () {
+    checkWidget ();
+    return toolTip;
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+    checkWidget ();
+    return toolTipText;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and 
+ * <code>false</code> otherwise.
+ *
+ * @return the receiver's visibility
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getVisible () {
+    checkWidget ();
+    return visible;
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    parent = null;
+    if (item !is null) item.release();
+    if (view !is null) {
+        view.setTag(-1);
+        view.release();
+    }
+    item = null;
+    view = null;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    NSStatusBar statusBar = NSStatusBar.systemStatusBar();
+    statusBar.removeStatusItem(item);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the platform-specific context menu trigger has
+ * occurred.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #addMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void removeMenuDetectListener (MenuDetectListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.MenuDetect, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+/**
+ * Sets the receiver's image.
+ *
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+    checkWidget ();
+    if (image !is null && image.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    super.setImage (image);
+    view.setImage(image !is null ? image.handle : null);
+    float width = image !is null && visible ? image.handle.size().width + BORDER : 0;
+    item.setLength(width);
+}
+
+/**
+ * Sets the receiver's tool tip to the argument, which
+ * may be null indicating that no tool tip should be shown.
+ *
+ * @param toolTip the new tool tip (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setToolTip (ToolTip toolTip) {
+    checkWidget ();
+    ToolTip oldTip = this.toolTip, newTip = toolTip;
+    if (oldTip !is null) oldTip.item = null;
+    this.toolTip = newTip;
+    if (newTip !is null) newTip.item = this;
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param value the new tool tip text (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+    checkWidget ();
+    toolTipText = string;
+    _setToolTipText (string);
+}
+
+void _setToolTipText (String string) {
+    NSString str = null;
+    if (string !is null) str = NSString.stringWith(string);
+    view.setToolTip(str);
+}
+
+/**
+ * Makes the receiver visible if the argument is <code>true</code>,
+ * and makes it invisible otherwise. 
+ *
+ * @param visible the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (bool visible) {
+    checkWidget ();
+    if (this.visible is visible) return;
+    if (visible) {
+        sendEvent (DWT.Show);
+        if (isDisposed ()) return;
+    }
+    this.visible = visible;
+    float width = image !is null && visible ? image.handle.size().width + BORDER : 0;
+    item.setLength(width);
+    if (!visible) sendEvent (DWT.Hide);
+}
+
+void showMenu () {
+    _setToolTipText (null);
+    sendEvent (DWT.MenuDetect);
+    if (isDisposed ()) return;
+//  display.runPopups ();
+    if (isDisposed ()) return;
+    _setToolTipText (toolTipText);
+}
+
+void mouseDown(int event) {
+    NSEvent nsEvent = new NSEvent(event);
+    int mask = nsEvent.modifierFlags() & OS.NSDeviceIndependentModifierFlagsMask;
+    if (mask is OS.NSControlKeyMask) {
+        showMenu();
+    } else {
+        highlight = true;
+        view.setNeedsDisplay(true);
+        int clickCount = nsEvent.clickCount();
+        postEvent(clickCount is 2 ? DWT.DefaultSelection : DWT.Selection);
+    }
+}
+
+void mouseUp(int event) {
+    highlight = false;
+    view.setNeedsDisplay(true);
+}
+
+void rightMouseDown(int event) {
+    showMenu();
+}
+
+void drawRect(int id, NSRect rect) {
+    item.drawStatusBarBackgroundInRect(rect, highlight);
+    super.drawRect(id, rect);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Tree.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,2326 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Tree;
+
+import dwt.dwthelper.utils;
+
+ 
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.events.TreeListener;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSBrowserCell;
+import dwt.internal.cocoa.NSButtonCell;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSNumber;
+import dwt.internal.cocoa.NSOutlineView;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableColumn;
+import dwt.internal.cocoa.NSTableHeaderView;
+import dwt.internal.cocoa.NSTableView;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTOutlineView;
+import dwt.internal.cocoa.SWTScrollView;
+import dwt.internal.cocoa.SWTTreeItem;
+import dwt.internal.cocoa.id;
+
+/**
+ * Instances of this class provide a selectable user interface object
+ * that displays a hierarchy of items and issues notification when an
+ * item in the hierarchy is selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TreeItem</code>.
+ * </p><p>
+ * Style <code>VIRTUAL</code> is used to create a <code>Tree</code> whose
+ * <code>TreeItem</code>s are to be populated by the client on an on-demand basis
+ * instead of up-front.  This can provide significant performance improvements for
+ * trees that are very large or for which <code>TreeItem</code> population is
+ * expensive (for example, retrieving values from an external source).
+ * </p><p>
+ * Here is an example of using a <code>Tree</code> with style <code>VIRTUAL</code>:
+ * <code><pre>
+ *  final Tree tree = new Tree(parent, DWT.VIRTUAL | DWT.BORDER);
+ *  tree.setItemCount(20);
+ *  tree.addListener(DWT.SetData, new Listener() {
+ *      public void handleEvent(Event event) {
+ *          TreeItem item = (TreeItem)event.item;
+ *          TreeItem parentItem = item.getParentItem();
+ *          String text = null;
+ *          if (parentItem is null) {
+ *              text = "node " + tree.indexOf(item);
+ *          } else {
+ *              text = parentItem.getText() + " - " + parentItem.indexOf(item);
+ *          }
+ *          item.setText(text);
+ *          System.out.println(text);
+ *          item.setItemCount(10);
+ *      }
+ *  });
+ * </pre></code>
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, VIRTUAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, Collapse, Expand, SetData, MeasureItem, EraseItem, PaintItem</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tree extends Composite {
+    NSTableColumn firstColumn, checkColumn;
+    NSTableHeaderView headerView;
+    TreeItem [] items;
+    int itemCount;
+    TreeColumn [] columns;
+    TreeColumn sortColumn;
+    int columnCount;
+    int sortDirection;
+    bool ignoreExpand, ignoreSelect;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#SINGLE
+ * @see DWT#MULTI
+ * @see DWT#CHECK
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Tree (Composite parent, int style) {
+    super (parent, checkStyle (style));
+}
+
+void _addListener (int eventType, Listener listener) {
+    super._addListener (eventType, listener);
+    for (int i = 0; i < items.length; i++) {
+        if (items [i] !is null) items [i].width = -1;        
+    }
+}
+
+TreeItem _getItem (TreeItem parentItem, int index) {
+    int count;
+    TreeItem[] items;
+    if (parentItem !is null) {
+        count = parentItem.itemCount;
+        items = parentItem.items;
+    } else {
+        count = this.itemCount;
+        items = this.items;
+    }
+    if (index < 0 || index >= count) return null;
+    TreeItem item = items [index]; 
+    if (item !is null || (style & DWT.VIRTUAL) is 0) return item;
+    item = new TreeItem (this, parentItem, DWT.NONE, index, false);
+    items [index] = item;
+    return item;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has the <code>DWT.CHECK</code> style and the check selection changes,
+ * the event object detail field contains the value <code>DWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection, typedListener);
+    addListener (DWT.DefaultSelection, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>TreeListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #removeTreeListener
+ */
+public void addTreeListener(TreeListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Expand, typedListener);
+    addListener (DWT.Collapse, typedListener);
+}
+
+bool checkData (TreeItem item, bool redraw) {
+    if (item.cached) return true;
+    if ((style & DWT.VIRTUAL) !is 0) {
+        item.cached = true;
+        Event event = new Event ();
+        TreeItem parentItem = item.getParentItem ();
+        event.item = item;
+        event.index = parentItem is null ? indexOf (item) : parentItem.indexOf (item);
+//      ignoreRedraw = true;
+        sendEvent (DWT.SetData, event);
+        //widget could be disposed at this point
+//      ignoreRedraw = false;
+        if (isDisposed () || item.isDisposed ()) return false;
+        if (redraw) {
+//          if (!setScrollWidth (item)) item.redraw (OS.kDataBrowserNoItem);
+        }
+    }
+    return true;
+}
+
+static int checkStyle (int style) {
+    /*
+    * Feature in Windows.  Even when WS_HSCROLL or
+    * WS_VSCROLL is not specified, Windows creates
+    * trees and tables with scroll bars.  The fix
+    * is to set H_SCROLL and V_SCROLL.
+    * 
+    * NOTE: This code appears on all platforms so that
+    * applications have consistent scroll bar behavior.
+    */
+    if ((style & DWT.NO_SCROLL) is 0) {
+        style |= DWT.H_SCROLL | DWT.V_SCROLL;
+    }
+    return checkBits (style, DWT.SINGLE, DWT.MULTI, 0, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+void clear (TreeItem parentItem, int index, bool all) {
+//  int [] ids = parentItem is null ? childIds : parentItem.childIds;
+//  TreeItem item = _getItem (ids [index], false);
+//  if (item !is null) {
+//      item.clear();
+//      if (all) {
+//          clearAll (item, true);
+//      } else {
+//          int container = parentItem is null ? OS.kDataBrowserNoItem : parentItem.id;
+//          OS.UpdateDataBrowserItems (handle, container, 1, new int[] {item.id}, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem);
+//      }
+//  }
+}
+
+void clearAll (TreeItem parentItem, bool all) {
+//  bool update = !inClearAll;
+//  int count = getItemCount (parentItem);
+//  if (count is 0) return;
+//  inClearAll = true;
+//  int [] ids = parentItem is null ? childIds : parentItem.childIds;
+//  for (int i=0; i<count; i++) {
+//      TreeItem item = _getItem (ids [i], false);
+//      if (item !is null) {
+//          item.clear ();
+//          if (all) clearAll (item, true);
+//      }
+//  }
+//  if (update) {
+//      OS.UpdateDataBrowserItems (handle, 0, 0, null, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem);
+//      inClearAll = false;
+//  }
+}
+
+/**
+ * Clears the item at the given zero-relative index in the receiver.
+ * The text, icon and other attributes of the item are set to the default
+ * value.  If the tree was created with the <code>DWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param index the index of the item to clear
+ * @param all <code>true</code> if all child items of the indexed item should be
+ * cleared recursively, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clear (int index, bool all) {
+    checkWidget ();
+    int count = getItemCount ();
+    if (index < 0 || index >= count) error (DWT.ERROR_INVALID_RANGE);
+    clear (null, index, all);
+}
+
+/**
+ * Clears all the items in the receiver. The text, icon and other
+ * attributes of the items are set to their default values. If the
+ * tree was created with the <code>DWT.VIRTUAL</code> style, these
+ * attributes are requested again as needed.
+ * 
+ * @param all <code>true</code> if all child items should be cleared
+ * recursively, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clearAll (bool all) {
+    checkWidget ();
+    clearAll (null, all);
+}
+
+public Point computeSize (int wHint, int hHint, bool changed) {
+    checkWidget ();
+    int width = 0, height = 0;
+    if (wHint is DWT.DEFAULT) {
+        if (columnCount !is 0) {
+            for (int i=0; i<columnCount; i++) {
+                width += columns [i].getWidth ();
+            }
+        } else {
+//          int levelIndent = DISCLOSURE_COLUMN_LEVEL_INDENT;
+//          if (OS.VERSION >= 0x1040) {
+//              float [] metric = new float [1];
+//              OS.DataBrowserGetMetric (handle, OS.kDataBrowserMetricDisclosureColumnPerDepthGap, null, metric);
+//              levelIndent = (int) metric [0];
+//          }
+//          GC gc = new GC (this);
+//          width = calculateWidth (childIds, gc, true, 0, levelIndent);
+//          gc.dispose ();
+//          width += getInsetWidth (column_id, true);
+        }
+        if ((style & DWT.CHECK) !is 0) width += getCheckColumnWidth ();
+    } else {
+        width = wHint;
+    }
+    if (hHint is DWT.DEFAULT) {
+        height = ((NSTableView)view).numberOfRows() * getItemHeight () + getHeaderHeight();
+    } else {
+        height = hHint;
+    }
+    if (width <= 0) width = DEFAULT_WIDTH;
+    if (height <= 0) height = DEFAULT_HEIGHT;
+    Rectangle rect = computeTrim (0, 0, width, height);
+    return new Point (rect.width, rect.height);
+}
+
+void createHandle () {
+    SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc();
+    scrollWidget.initWithFrame(new NSRect ());
+    scrollWidget.setHasHorizontalScroller(true);
+    scrollWidget.setHasVerticalScroller(true);
+    scrollWidget.setAutohidesScrollers(true);
+    scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder);
+    scrollWidget.setTag(jniRef);
+    
+    NSOutlineView widget = (NSOutlineView)new SWTOutlineView().alloc();
+    widget.initWithFrame(new NSRect());
+    widget.setAllowsMultipleSelection((style & DWT.MULTI) !is 0);
+    widget.setAutoresizesOutlineColumn(false);
+    widget.setAutosaveExpandedItems(true);
+    widget.setDataSource(widget);
+    widget.setDelegate(widget);
+    widget.setDoubleAction(OS.sel_sendDoubleSelection);
+    if (!hasBorder()) widget.setFocusRingType(OS.NSFocusRingTypeNone);
+    widget.setTag(jniRef);
+    
+    headerView = widget.headerView();
+    headerView.retain();
+    widget.setHeaderView(null);
+    
+    NSString str = NSString.stringWith("");
+    if ((style & DWT.CHECK) !is 0) {
+        checkColumn = (NSTableColumn)new NSTableColumn().alloc();
+        checkColumn.initWithIdentifier(str);
+        checkColumn.headerCell().setTitle(str);
+        widget.addTableColumn (checkColumn);
+        widget.setOutlineTableColumn(checkColumn);
+        NSButtonCell cell = (NSButtonCell)new NSButtonCell().alloc().init();
+        checkColumn.setDataCell(cell);
+        cell.setButtonType(OS.NSSwitchButton);
+        cell.setImagePosition(OS.NSImageOnly);
+        cell.setAllowsMixedState(true);
+        checkColumn.setWidth(getCheckColumnWidth());
+        checkColumn.setResizingMask(OS.NSTableColumnNoResizing);
+        checkColumn.setEditable(false);
+        cell.release();
+    }
+    
+    firstColumn = (NSTableColumn)new NSTableColumn().alloc();
+    firstColumn.initWithIdentifier(str);
+    firstColumn.headerCell().setTitle(str);
+    widget.addTableColumn (firstColumn);
+    widget.setOutlineTableColumn(firstColumn);
+    NSBrowserCell cell = (NSBrowserCell)new NSBrowserCell().alloc().init();
+    cell.setLeaf(true);
+    firstColumn.setDataCell(cell);
+    cell.release();
+    
+    scrollView = scrollWidget;
+    view = widget;
+    scrollView.setDocumentView(widget);
+    parent.contentView().addSubview_(scrollView);
+}
+
+void createItem (TreeColumn column, int index) {
+    if (!(0 <= index && index <= columnCount)) error (DWT.ERROR_INVALID_RANGE);
+    if (index is 0) {
+        // first column must be left aligned
+        column.style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+        column.style |= DWT.LEFT;
+    }
+    if (columnCount is columns.length) {
+        TreeColumn [] newColumns = new TreeColumn [columnCount + 4];
+        System.arraycopy (columns, 0, newColumns, 0, columns.length);
+        columns = newColumns;
+    }
+    NSTableColumn nsColumn;
+    if (columnCount is 0) {
+        //TODO - clear attributes, alignment etc.
+        nsColumn = firstColumn;
+        firstColumn = null;
+    } else {
+        //TODO - set attributes, alignment etc.
+        NSString str = NSString.stringWith("");
+        nsColumn = (NSTableColumn)new NSTableColumn().alloc();
+        nsColumn.initWithIdentifier(str);
+        nsColumn.headerCell().setTitle(str);
+        ((NSTableView)view).addTableColumn (nsColumn);
+        int checkColumn = (style & DWT.CHECK) !is 0 ? 1 : 0;
+        ((NSTableView)view).moveColumn (columnCount + checkColumn, index + checkColumn);
+        NSBrowserCell cell = (NSBrowserCell)new NSBrowserCell().alloc().init();
+        cell.setLeaf(true);
+        nsColumn.setDataCell(cell);
+        cell.release();
+    }
+    column.nsColumn = nsColumn;
+    nsColumn.headerCell().setTitle(NSString.stringWith(""));
+    nsColumn.setWidth(0);
+    System.arraycopy (columns, index, columns, index + 1, columnCount++ - index);
+    columns [index] = column;
+    if (columnCount > 1) {
+        for (int i=0; i<items.length; i++) {
+            TreeItem item = items [i];
+            if (item !is null) {
+                String [] strings = item.strings;
+                if (strings !is null) {
+                    String [] temp = new String [columnCount];
+                    System.arraycopy (strings, 0, temp, 0, index);
+                    System.arraycopy (strings, index, temp, index+1, columnCount-index-1);
+                    temp [index] = "";
+                    item.strings = temp;
+                }
+                if (index is 0) item.text = "";
+                Image [] images = item.images;
+                if (images !is null) {
+                    Image [] temp = new Image [columnCount];
+                    System.arraycopy (images, 0, temp, 0, index);
+                    System.arraycopy (images, index, temp, index+1, columnCount-index-1);
+                    item.images = temp;
+                }
+                if (index is 0) item.image = null;
+                Color [] cellBackground = item.cellBackground;
+                if (cellBackground !is null) {
+                    Color [] temp = new Color [columnCount];
+                    System.arraycopy (cellBackground, 0, temp, 0, index);
+                    System.arraycopy (cellBackground, index, temp, index+1, columnCount-index-1);
+                    item.cellBackground = temp;
+                }
+                Color [] cellForeground = item.cellForeground;
+                if (cellForeground !is null) {
+                    Color [] temp = new Color [columnCount];
+                    System.arraycopy (cellForeground, 0, temp, 0, index);
+                    System.arraycopy (cellForeground, index, temp, index+1, columnCount-index-1);
+                    item.cellForeground = temp;
+                }
+                Font [] cellFont = item.cellFont;
+                if (cellFont !is null) {
+                    Font [] temp = new Font [columnCount];
+                    System.arraycopy (cellFont, 0, temp, 0, index);
+                    System.arraycopy (cellFont, index, temp, index+1, columnCount-index-1);
+                    item.cellFont = temp;
+                }
+            }
+        }
+    }
+}
+
+void createItem (TreeItem item, TreeItem parentItem, int index) {
+    int count;
+    TreeItem[] items;
+    if (parentItem !is null) {
+        count = parentItem.itemCount;
+        items = parentItem.items;
+    } else {
+        count = this.itemCount;
+        items = this.items;
+    }
+    if (index is -1) index = count;
+    if (!(0 <= index && index <= count)) error (DWT.ERROR_INVALID_RANGE);
+    if (count is items.length) {
+        TreeItem [] newItems = new TreeItem [items.length + 4];
+        System.arraycopy (items, 0, newItems, 0, items.length);
+        items = newItems;
+        if (parentItem !is null) {
+            parentItem.items = items;
+        } else {
+            this.items = items;
+        }
+    }
+    System.arraycopy (items, index, items, index + 1, count++ - index);
+    items [index] = item;
+    item.items = new TreeItem[4];
+    item.createJNIRef();
+    SWTTreeItem handle = (SWTTreeItem)new SWTTreeItem().alloc().init();
+    handle.setTag(item.jniRef);
+    item.handle = handle;
+    if (parentItem !is null) {
+        parentItem.itemCount = count;
+    } else {
+        this.itemCount = count;
+    }
+    //TODO ?
+    ((NSTableView)view).reloadData();
+}
+
+void createWidget () {
+    super.createWidget ();
+    items = new TreeItem [4];
+    columns = new TreeColumn [4];
+}
+
+Color defaultBackground () {
+    return display.getSystemColor (DWT.COLOR_LIST_BACKGROUND);
+}
+
+Color defaultForeground () {
+    return display.getSystemColor (DWT.COLOR_LIST_FOREGROUND);
+}
+
+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselectAll () {
+    checkWidget ();
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.deselectAll(null);
+    ignoreSelect = false;
+}
+
+public void deselect (TreeItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+//  ignoreSelect = true;
+//  /*
+//  * Bug in the Macintosh.  When the DataBroswer selection flags includes
+//  * both kDataBrowserNeverEmptySelectionSet and kDataBrowserSelectOnlyOne,
+//  * two items are selected when SetDataBrowserSelectedItems() is called
+//  * with kDataBrowserItemsAssign to assign a new seletion despite the fact
+//  * that kDataBrowserSelectOnlyOne was specified.  The fix is to save and
+//  * restore kDataBrowserNeverEmptySelectionSet around each call to
+//  * SetDataBrowserSelectedItems().
+//  */
+//  int [] selectionFlags = null;
+//  if ((style & DWT.SINGLE) !is 0) {
+//      selectionFlags = new int [1];
+//      OS.GetDataBrowserSelectionFlags (handle, selectionFlags);
+//      OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0] & ~OS.kDataBrowserNeverEmptySelectionSet);
+//  }
+//  OS.SetDataBrowserSelectedItems (handle, 1, new int [] {item.id}, OS.kDataBrowserItemsRemove);
+//  if ((style & DWT.SINGLE) !is 0) {
+//      OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0]);
+//  }
+//  ignoreSelect = false;
+}
+
+
+void destroyItem (TreeColumn column) {
+    int index = 0;
+    while (index < columnCount) {
+        if (columns [index] is column) break;
+        index++;
+    }
+    for (int i=0; i<items.length; i++) {
+        TreeItem item = items [i];
+        if (item !is null) {
+            if (columnCount <= 1) {
+                item.strings = null;
+                item.images = null;
+                item.cellBackground = null;
+                item.cellForeground = null;
+                item.cellFont = null;
+            } else {
+                if (item.strings !is null) {
+                    String [] strings = item.strings;
+                    if (index is 0) {
+                        item.text = strings [1] !is null ? strings [1] : "";
+                    }
+                    String [] temp = new String [columnCount - 1];
+                    System.arraycopy (strings, 0, temp, 0, index);
+                    System.arraycopy (strings, index + 1, temp, index, columnCount - 1 - index);
+                    item.strings = temp;
+                } else {
+                    if (index is 0) item.text = "";
+                }
+                if (item.images !is null) {
+                    Image [] images = item.images;
+                    if (index is 0) item.image = images [1];
+                    Image [] temp = new Image [columnCount - 1];
+                    System.arraycopy (images, 0, temp, 0, index);
+                    System.arraycopy (images, index + 1, temp, index, columnCount - 1 - index);
+                    item.images = temp;
+                } else {
+                    if (index is 0) item.image = null;
+                }
+                if (item.cellBackground !is null) {
+                    Color [] cellBackground = item.cellBackground;
+                    Color [] temp = new Color [columnCount - 1];
+                    System.arraycopy (cellBackground, 0, temp, 0, index);
+                    System.arraycopy (cellBackground, index + 1, temp, index, columnCount - 1 - index);
+                    item.cellBackground = temp;
+                }
+                if (item.cellForeground !is null) {
+                    Color [] cellForeground = item.cellForeground;
+                    Color [] temp = new Color [columnCount - 1];
+                    System.arraycopy (cellForeground, 0, temp, 0, index);
+                    System.arraycopy (cellForeground, index + 1, temp, index, columnCount - 1 - index);
+                    item.cellForeground = temp;
+                }
+                if (item.cellFont !is null) {
+                    Font [] cellFont = item.cellFont;
+                    Font [] temp = new Font [columnCount - 1];
+                    System.arraycopy (cellFont, 0, temp, 0, index);
+                    System.arraycopy (cellFont, index + 1, temp, index, columnCount - 1 - index);
+                    item.cellFont = temp;
+                }
+            }
+        }
+    }
+//  if (columnCount is 1) {
+//      column_id = column.id; idCount = 0;
+//      DataBrowserListViewHeaderDesc desc = new DataBrowserListViewHeaderDesc ();
+//      desc.version = OS.kDataBrowserListViewLatestHeaderDesc;
+//      short [] width = new short [1];
+//      OS.GetDataBrowserTableViewNamedColumnWidth (handle, column_id, width);
+//      desc.minimumWidth = desc.maximumWidth = width [0];
+//      int str = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, null, 0);
+//      desc.titleString = str;
+//      OS.SetDataBrowserListViewHeaderDesc (handle, column_id, desc);
+//      OS.CFRelease (str);
+//  } else {
+//      int [] disclosure = new int [1];
+//      bool [] expandableRows = new bool [1];
+//      OS.GetDataBrowserListViewDisclosureColumn (handle, disclosure, expandableRows);
+//      if (disclosure [0] is column.id) {
+//          TreeColumn firstColumn = columns [1];
+//          firstColumn.style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+//          firstColumn.style |= DWT.LEFT;
+//          firstColumn.updateHeader();
+//          OS.SetDataBrowserListViewDisclosureColumn (handle, firstColumn.id, expandableRows [0]);
+//      }
+//      if (OS.RemoveDataBrowserTableViewColumn (handle, column.id) !is OS.noErr) {
+//          error (DWT.ERROR_ITEM_NOT_REMOVED);
+//      }
+//  }
+    System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
+    columns [columnCount] = null;
+    for (int i=index; i<columnCount; i++) {
+        columns [i].sendEvent (DWT.Move);
+    }
+}
+
+void destroyItem (TreeItem item) {
+    int count;
+    TreeItem[] items;
+    TreeItem parentItem = item.parentItem;
+    if (parentItem !is null) {
+        count = parentItem.itemCount;
+        items = parentItem.items;
+    } else {
+        count = this.itemCount;
+        items = this.items;
+    }
+    int index = 0;
+    while (index < count) {
+        if (items [index] is item) break;
+        index++;
+    }
+//  if (index !is itemCount - 1) fixSelection (index, false); 
+    System.arraycopy (items, index + 1, items, index, --count - index);
+    items [count] = null;
+    if (parentItem !is null) {
+        parentItem.itemCount = count;
+        ((NSOutlineView)view).reloadItem_reloadChildren_(parentItem.handle, true);
+    } else {
+        this.itemCount = count;
+        ((NSOutlineView)view).reloadItem_(null);
+    }
+    
+    //noteNumberOfRowsChanged was causing crashes whenever
+    //a TreeItem was disposed. 
+    //Using reloadItem avoids the crashes.
+    //Not sure that this NSTableView function 
+    //makes sense in an NSOutlineView.
+    
+    //((NSTableView)view).noteNumberOfRowsChanged();
+    
+//  setScrollWidth (true);
+//  fixScrollBar ();
+}
+
+
+void fixScrollBar () {
+    /*
+    * Bug in the Macintosh. For some reason, the data browser does not update
+    * the vertical scrollbar when it is scrolled to the bottom and items are
+    * removed.  The fix is to check if the scrollbar value is bigger the
+    * maximum number of visible items and clamp it when needed.
+    */
+//  int [] top = new int [1], left = new int [1];
+//  OS.GetDataBrowserScrollPosition (handle, top, left);
+//  int maximum = Math.max (0, getItemHeight () * visibleCount - getClientArea ().height);
+//  if (top [0] > maximum) {
+//      OS.SetDataBrowserScrollPosition (handle, maximum, left [0]);
+//  }
+}
+
+int getCheckColumnWidth () {
+    return 20; //TODO - compute width
+}
+
+/**
+ * Returns the column at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ * Columns are returned in the order that they were created.
+ * If no <code>TreeColumn</code>s were created by the programmer,
+ * this method will throw <code>ERROR_INVALID_RANGE</code> despite
+ * the fact that a single column of data may be visible in the tree.
+ * This occurs when the programmer uses the tree like a list, adding
+ * items but never creating a column.
+ *
+ * @param index the index of the column to return
+ * @return the column at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.1
+ */
+public TreeColumn getColumn (int index) {
+    checkWidget ();
+    if (!(0 <=index && index < columnCount)) error (DWT.ERROR_INVALID_RANGE);
+    return columns [index];
+}
+
+/**
+ * Returns the number of columns contained in the receiver.
+ * If no <code>TreeColumn</code>s were created by the programmer,
+ * this value is zero, despite the fact that visually, one column
+ * of items may be visible. This occurs when the programmer uses
+ * the tree like a list, adding items but never creating a column.
+ *
+ * @return the number of columns
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getColumnCount () {
+    checkWidget ();
+    return columnCount;
+}
+
+/**
+ * Returns an array of zero-relative integers that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.2
+ */
+public int [] getColumnOrder () {
+    checkWidget ();
+    int [] order = new int [columnCount];
+    int [] position = new int [1];
+    for (int i=0; i<columnCount; i++) {
+        TreeColumn column = columns [i];
+//      OS.GetDataBrowserTableViewColumnPosition (handle, column.id, position);
+//      if ((style & DWT.CHECK) !is 0) position [0] -= 1;
+        order [position [0]] = i;
+    }
+    return order;
+}
+
+/**
+ * Returns an array of <code>TreeColumn</code>s which are the
+ * columns in the receiver. Columns are returned in the order
+ * that they were created.  If no <code>TreeColumn</code>s were
+ * created by the programmer, the array is empty, despite the fact
+ * that visually, one column of items may be visible. This occurs
+ * when the programmer uses the tree like a list, adding items but
+ * never creating a column.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.1
+ */
+public TreeColumn [] getColumns () {
+    checkWidget ();
+    TreeColumn [] result = new TreeColumn [columnCount];
+    System.arraycopy (columns, 0, result, 0, columnCount);
+    return result;
+}
+
+/**
+ * Returns the width in pixels of a grid line.
+ *
+ * @return the width of a grid line in pixels
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getGridLineWidth () {
+    checkWidget ();
+    return 0;
+}
+
+/**
+ * Returns the height of the receiver's header 
+ *
+ * @return the height of the header or zero if the header is not visible
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int getHeaderHeight () {
+    checkWidget ();
+    NSTableHeaderView headerView = ((NSTableView)view).headerView();
+    if (headerView is null) return 0;
+    return (int)headerView.bounds().height;
+}
+
+/**
+ * Returns <code>true</code> if the receiver's header is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's header's visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public bool getHeaderVisible () {
+    checkWidget ();
+    return ((NSTableView)view).headerView() !is null;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TreeItem getItem (int index) {
+    checkWidget ();
+    int count = getItemCount ();
+    if (index < 0 || index >= count) error (DWT.ERROR_INVALID_RANGE);
+    return _getItem (null, index);
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ * <p>
+ * The item that is returned represents an item that could be selected by the user.
+ * For example, if selection only occurs in items in the first column, then null is 
+ * returned if the point is outside of the item. 
+ * Note that the DWT.FULL_SELECTION style hint, which specifies the selection policy,
+ * determines the extent of the selection.
+ * </p>
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point, or null if the point is not in a selectable item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem getItem (Point point) {
+    checkWidget ();
+    if (point is null) error (DWT.ERROR_NULL_ARGUMENT);
+//  Rect rect = new Rect ();
+//  dwt.internal.carbon.Point pt = new dwt.internal.carbon.Point ();
+//  OS.SetPt (pt, (short) point.x, (short) point.y);
+//  if (0 < lastHittest && lastHittest <= items.length && lastHittestColumn !is 0) {
+//      TreeItem item = _getItem (lastHittest, false);
+//      if (item !is null) {
+//          if (OS.GetDataBrowserItemPartBounds (handle, item.id, lastHittestColumn, OS.kDataBrowserPropertyDisclosurePart, rect) is OS.noErr) {
+//              if (OS.PtInRect (pt, rect)) return null;
+//          }
+//          if (OS.GetDataBrowserItemPartBounds (handle, item.id, lastHittestColumn, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//              if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//                  if ((style & DWT.FULL_SELECTION) !is 0) {
+//                      return item;
+//                  } else {
+//                      return OS.PtInRect (pt, rect) ? item : null;
+//                  }
+//              }
+//          }
+//      }
+//  }
+//  //TODO - optimize
+//  for (int i=0; i<items.length; i++) {
+//      TreeItem item = items [i];
+//      if (item !is null) {
+//          if (OS.GetDataBrowserItemPartBounds (handle, item.id, column_id, OS.kDataBrowserPropertyDisclosurePart, rect) is OS.noErr) {
+//              if (OS.PtInRect (pt, rect)) return null;
+//          }
+//          if (columnCount is 0) {
+//              if (OS.GetDataBrowserItemPartBounds (handle, item.id, column_id, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//                  if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//                      if ((style & DWT.FULL_SELECTION) !is 0) {
+//                          return item;
+//                      } else {
+//                          return OS.PtInRect (pt, rect) ? item : null;
+//                      }
+//                  }
+//              }
+//          } else {
+//              for (int j = 0; j < columnCount; j++) {
+//                  if (OS.GetDataBrowserItemPartBounds (handle, item.id, columns [j].id, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//                      if (rect.top <= pt.v && pt.v <= rect.bottom) {
+//                          if ((style & DWT.FULL_SELECTION) !is 0) {
+//                              return item;
+//                          } else {
+//                              return OS.PtInRect (pt, rect) ? item : null;
+//                          }
+//                      }
+//                  }
+//              }
+//          }
+//      }
+//  }
+    return null;
+}
+
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.  The
+ * number that is returned is the number of roots in the
+ * tree.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    return itemCount;
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the tree.
+ *
+ * @return the height of one item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+    checkWidget ();
+    return (int)((NSTableView)view).rowHeight();
+}
+
+/**
+ * Returns a (possibly empty) array of items contained in the
+ * receiver that are direct item children of the receiver.  These
+ * are the roots of the tree.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getItems () {
+    checkWidget ();
+    TreeItem [] result = new TreeItem [itemCount];
+    for (int i=0; i<itemCount; i++) {
+        result [i] = _getItem (null, i);
+    }
+    return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver's lines are visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the visibility state of the lines
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public bool getLinesVisible () {
+    checkWidget ();
+//  if (OS.VERSION >= 0x1040) {
+//      int [] attrib = new int [1];
+//      OS.DataBrowserGetAttributes (handle, attrib);
+//      return (attrib [0] & (OS.kDataBrowserAttributeListViewAlternatingRowColors | OS.kDataBrowserAttributeListViewDrawColumnDividers)) !is 0;
+//  }
+    return false;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem getParentItem () {
+    checkWidget ();
+    return null;
+}
+
+/**
+ * Returns an array of <code>TreeItem</code>s that are currently
+ * selected in the receiver. The order of the items is unspecified.
+ * An empty array indicates that no items are selected. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getSelection () {
+    checkWidget ();
+    NSOutlineView widget = (NSOutlineView)view;
+    if (widget.numberOfSelectedRows() is 0) {
+        return new TreeItem [0];
+    }
+    NSIndexSet selection = widget.selectedRowIndexes();
+    int count = selection.count();
+    int [] indexBuffer = new int [count];
+    selection.getIndexes(indexBuffer, count, 0);
+    TreeItem [] result = new TreeItem  [count];
+    for (int i=0; i<count; i++) {
+        id item = widget.itemAtRow(indexBuffer [i]);
+        int jniRef = OS.objc_msgSend(item.id, OS.sel_tag);
+        if (jniRef !is -1 && jniRef !is 0) {
+            //TODO virtual
+            result[i] = (TreeItem)OS.JNIGetObject(jniRef);
+        }
+    }
+    return result;
+}
+
+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+    checkWidget ();
+    return ((NSTableView)view).numberOfSelectedRows();
+}
+
+/**
+ * Returns the column which shows the sort indicator for
+ * the receiver. The value may be null if no column shows
+ * the sort indicator.
+ *
+ * @return the sort indicator 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortColumn(TreeColumn)
+ * 
+ * @since 3.2
+ */
+public TreeColumn getSortColumn () {
+    checkWidget ();
+    return sortColumn;
+}
+
+/**
+ * Returns the direction of the sort indicator for the receiver. 
+ * The value will be one of <code>UP</code>, <code>DOWN</code> 
+ * or <code>NONE</code>.
+ *
+ * @return the sort direction
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortDirection(int)
+ * 
+ * @since 3.2
+ */
+public int getSortDirection () {
+    checkWidget ();
+    return sortDirection;
+}
+
+/**
+ * Returns the item which is currently at the top of the receiver.
+ * This item can change when items are expanded, collapsed, scrolled
+ * or new items are added or removed.
+ *
+ * @return the item at the top of the receiver 
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public TreeItem getTopItem () {
+    checkWidget();
+//  //TODO - optimize
+//  Rect rect = new Rect ();
+//  int y = getBorder () + getHeaderHeight ();
+//  for (int i=0; i<items.length; i++) {
+//      TreeItem item = items [i];
+//      if (item !is null) {
+//          int columnId = (columnCount is 0) ? column_id : columns [0].id;
+//          if (OS.GetDataBrowserItemPartBounds (handle, item.id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//              if (rect.top <= y && y <= rect.bottom) return item;
+//          }
+//      }
+//  }
+    return null;
+}
+
+/**
+ * Searches the receiver's list starting at the first column
+ * (index 0) until a column is found that is equal to the 
+ * argument, and returns the index of that column. If no column
+ * is found, returns -1.
+ *
+ * @param column the search column
+ * @return the index of the column
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the column is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int indexOf (TreeColumn column) {
+    checkWidget ();
+    if (column is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (column.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    for (int i=0; i<columnCount; i++) {
+        if (columns [i] is column) return i;
+    }
+    return -1;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int indexOf (TreeItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (item.parentItem !is null) return -1;
+    for (int i = 0; i < itemCount; i++) {
+        if (item is items[i]) return i;
+    }
+    return -1;
+}
+
+int outlineView_child_ofItem(int outlineView, int index, int ref) {
+    TreeItem parent = null;
+    if (ref !is 0) parent = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+    TreeItem item = _getItem(parent, index);
+    return item.handle.id;
+}
+
+int outlineView_objectValueForTableColumn_byItem(int outlineView, int tableColumn, int ref) {
+    TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+    if (checkColumn !is null && tableColumn is checkColumn.id) {
+        NSNumber value;
+        if (item.checked && item.grayed) {
+            value = NSNumber.numberWithInt(OS.NSMixedState);
+        } else {
+            value = NSNumber.numberWithInt(item.checked ? OS.NSOnState : OS.NSOffState);
+        }
+        return value.id;
+    }
+    for (int i=0; i<columnCount; i++) {
+        if (columns [i].nsColumn.id is tableColumn) {
+            return item.createString(i).id;
+        }
+    }
+    return item.createString(0).id;
+}
+
+bool outlineView_isItemExpandable(int outlineView, int ref) {
+    if (ref is 0) return true;
+    return ((TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag))).itemCount !is 0;
+}
+
+int outlineView_numberOfChildrenOfItem(int outlineView, int ref) {
+    if (ref is 0) return itemCount;
+    return ((TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag))).itemCount;
+}
+
+void outlineView_willDisplayCell_forTableColumn_item(int outlineView, int cell, int tableColumn, int ref) {
+    if (checkColumn !is null && tableColumn is checkColumn.id) return;
+    TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+    Image image = item.image;
+    for (int i=0; i<columnCount; i++) {
+        if (columns [i].nsColumn.id is tableColumn) {
+            image = item.getImage(i);
+        }
+    }
+    NSBrowserCell browserCell = new NSBrowserCell(cell);
+    browserCell.setImage(image !is null ? image.handle : null);
+}
+
+void outlineViewSelectionDidChange(int notification) {
+    if (ignoreSelect) return;
+    NSOutlineView widget = (NSOutlineView)view;
+    int row = widget.selectedRow();
+    if(row is -1)
+        postEvent(DWT.Selection);
+    else {
+        id _id = widget.itemAtRow(row);
+        TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(_id.id, OS.sel_tag));
+        Event event = new Event();
+        event.item = item;
+        event.index = row;
+        postEvent(DWT.Selection, event);
+    }
+}
+
+bool outlineView_shouldCollapseItem(int outlineView, int ref) {
+    if (!ignoreExpand) {
+        TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+        Event event = new Event();
+        event.item = item;
+        sendEvent(DWT.Collapse, event);
+        item.expanded = false;
+    }
+    return true;
+}
+
+bool outlineView_shouldExpandItem(int outlineView, int ref) {
+    if (!ignoreExpand) {
+        TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+        Event event = new Event();
+        event.item = item;
+        sendEvent(DWT.Expand, event);
+        item.expanded = true;
+    }
+    return true;
+}
+
+void outlineView_setObjectValue_forTableColumn_byItem(int outlineView, int object, int tableColumn, int ref) {
+    TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+    if (checkColumn !is null && tableColumn is checkColumn.id)  {
+        item.checked = !item.checked;
+        Event event = new Event();
+        event.detail = DWT.CHECK;
+        event.item = item;
+        postEvent(DWT.Selection, event);
+    }
+}
+
+void releaseChildren (bool destroy) {
+    for (int i=0; i<items.length; i++) {
+        TreeItem item = items [i];
+        if (item !is null && !item.isDisposed ()) {
+            item.release (false);
+        }
+    }
+    items = null;
+    if (columns !is null) {
+        for (int i=0; i<columnCount; i++) {
+            TreeColumn column = columns [i];
+            if (column !is null && !column.isDisposed ()) {
+                column.release (false);
+            }
+        }
+        columns = null;
+    }
+    super.releaseChildren (destroy);
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (headerView !is null) headerView.release();
+    headerView = null;
+    if (firstColumn !is null) firstColumn.release();
+    firstColumn = null;
+    if (checkColumn !is null) checkColumn.release();
+    checkColumn = null;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    //release handle
+    sortColumn = null;
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+    checkWidget ();
+    for (int i=0; i<items.length; i++) {
+        TreeItem item = items [i];
+        if (item !is null && !item.isDisposed ()) item.release (false);
+    }
+    items = new TreeItem [4];
+    itemCount = 0;
+    ((NSOutlineView)view).reloadItem_(null);
+    //((NSTableView)view).noteNumberOfRowsChanged();
+//  setScrollWidth (true);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection, listener); 
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #addTreeListener
+ */
+public void removeTreeListener(TreeListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Expand, listener);
+    eventTable.unhook (DWT.Collapse, listener);
+}
+
+/**
+ * Display a mark indicating the point at which an item will be inserted.
+ * The drop insert item has a visual hint to show where a dragged item 
+ * will be inserted when dropped on the tree.
+ * 
+ * @param item the insert item.  Null will clear the insertion mark.
+ * @param before true places the insert mark above 'item'. false places 
+ *  the insert mark below 'item'.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark (TreeItem item, bool before) {
+    checkWidget ();
+    if (item !is null) {
+        if (item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+    checkWidget ();
+    if ((style & DWT.SINGLE) !is 0) return;
+    NSTableView widget = (NSTableView)view;
+    ignoreSelect = true;
+    widget.selectAll(null);
+    ignoreSelect = false;
+}
+
+public void select (TreeItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+//  showItem (item, false);
+//  ignoreSelect = true;
+//  /*
+//  * Bug in the Macintosh.  When the DataBroswer selection flags includes
+//  * both kDataBrowserNeverEmptySelectionSet and kDataBrowserSelectOnlyOne,
+//    * two items are selected when SetDataBrowserSelectedItems() is called
+//    * with kDataBrowserItemsAssign to assign a new seletion despite the fact
+//  * that kDataBrowserSelectOnlyOne was specified.  The fix is to save and
+//  * restore kDataBrowserNeverEmptySelectionSet around each call to
+//  * SetDataBrowserSelectedItems().
+//  */
+//  int [] selectionFlags = null;
+//  if ((style & DWT.SINGLE) !is 0) {
+//      selectionFlags = new int [1];
+//      OS.GetDataBrowserSelectionFlags (handle, selectionFlags);
+//      OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0] & ~OS.kDataBrowserNeverEmptySelectionSet);
+//  }
+//  OS.SetDataBrowserSelectedItems (handle, 1, new int [] {item.id}, OS.kDataBrowserItemsAssign);
+//  if ((style & DWT.SINGLE) !is 0) {
+//      OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0]);
+//  }
+//  ignoreSelect = false;
+}
+
+void sendDoubleSelection() {
+    postEvent (DWT.DefaultSelection);
+}
+
+/**
+ * Sets the order that the items in the receiver should 
+ * be displayed in to the given argument which is described
+ * in terms of the zero-relative ordering of when the items
+ * were added.
+ *
+ * @param order the new order to display the items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item order is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.2
+ */
+public void setColumnOrder (int [] order) {
+    checkWidget ();
+    if (order is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (columnCount is 0) {
+        if (order.length !is 0) error (DWT.ERROR_INVALID_ARGUMENT);
+        return;
+    }
+    if (order.length !is columnCount) error (DWT.ERROR_INVALID_ARGUMENT);
+    int [] oldOrder = getColumnOrder ();
+    bool reorder = false;
+    bool [] seen = new bool [columnCount];
+    for (int i=0; i<order.length; i++) {
+        int index = order [i];
+        if (index < 0 || index >= columnCount) error (DWT.ERROR_INVALID_ARGUMENT);
+        if (seen [index]) error (DWT.ERROR_INVALID_ARGUMENT);
+        seen [index] = true;
+        if (order [i] !is oldOrder [i]) reorder = true;
+    }
+    if (reorder) {
+        int [] disclosure = new int [1];
+        bool [] expandableRows = new bool [1];
+//      OS.GetDataBrowserListViewDisclosureColumn (handle, disclosure, expandableRows);
+        TreeColumn firstColumn = columns [order [0]];
+//      if (disclosure [0] !is firstColumn.id) {
+//          OS.SetDataBrowserListViewDisclosureColumn (handle, firstColumn.id, expandableRows [0]);
+//      }
+        int x = 0;
+        short [] width = new short [1];
+        int [] oldX = new int [oldOrder.length];
+        for (int i=0; i<oldOrder.length; i++) {
+            int index = oldOrder [i];
+            TreeColumn column = columns [index];
+            oldX [index] =  x;
+//          OS.GetDataBrowserTableViewNamedColumnWidth(handle, column.id, width);
+            x += width [0];
+        }
+        x = 0;
+        int [] newX = new int [order.length];
+        for (int i=0; i<order.length; i++) {
+            int index = order [i];
+            TreeColumn column = columns [index];
+            int position = (style & DWT.CHECK) !is 0 ? i + 1 : i;
+//          OS.SetDataBrowserTableViewColumnPosition(handle, column.id, position);
+//          column.lastPosition = position;
+            newX [index] =  x;
+//          OS.GetDataBrowserTableViewNamedColumnWidth(handle, column.id, width);
+            x += width [0];
+        }
+        TreeColumn[] newColumns = new TreeColumn [columnCount];
+        System.arraycopy (columns, 0, newColumns, 0, columnCount);
+        for (int i=0; i<columnCount; i++) {
+            TreeColumn column = newColumns [i];
+            if (!column.isDisposed ()) {
+                if (newX [i] !is oldX [i]) {
+                    column.sendEvent (DWT.Move);
+                }
+            }
+        }
+    }
+}
+
+/**
+ * Marks the receiver's header as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setHeaderVisible (bool show) {
+    checkWidget ();
+    ((NSTableView)view).setHeaderView (show ? headerView : null);
+}
+
+/**
+ * Sets the number of root-level items contained in the receiver.
+ *
+ * @param count the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.2
+ */
+public void setItemCount (int count) {
+    checkWidget ();
+    count = Math.max (0, count);
+    setItemCount (null, count);
+}
+
+void setItemCount (TreeItem parentItem, int count) {
+//  int itemCount = getItemCount (parentItem);
+//  if (count is itemCount) return;
+//  setRedraw (false);
+//  int [] top = new int [1], left = new int [1];
+//    OS.GetDataBrowserScrollPosition (handle, top, left);
+//    DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
+//  OS.GetDataBrowserCallbacks (handle, callbacks);
+//  callbacks.v1_itemNotificationCallback = 0;
+//  callbacks.v1_itemCompareCallback = 0;
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+//  int[] ids = parentItem is null ? childIds : parentItem.childIds;
+//  if (count < itemCount) {
+//      for (int index = ids.length - 1; index >= count; index--) {
+//          int id = ids [index];
+//          if (id !is 0) {
+//              TreeItem item = _getItem (id, false);
+//              if (item !is null && !item.isDisposed ()) {
+//                  item.dispose ();
+//              } else {
+//                  if (parentItem is null || parentItem.getExpanded ()) {
+//                      if (OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, 1, new int [] {id}, 0) !is OS.noErr) {
+//                          error (DWT.ERROR_ITEM_NOT_REMOVED);
+//                          break;
+//                      }
+//                      visibleCount--;
+//                  }
+//              }
+//          }
+//      }
+//      //TODO - move shrink to paint event
+//      // shrink items array
+//      int lastIndex = items.length;
+//      for (int i=items.length; i>0; i--) {
+//          if (items [i-1] !is null) {
+//              lastIndex = i;
+//              break;
+//          }
+//      }
+//      if (lastIndex < items.length - 4) {
+//          int length = Math.max (4, (lastIndex + 3) / 4 * 4);
+//          TreeItem [] newItems = new TreeItem [length];
+//          System.arraycopy(items, 0, newItems, 0, Math.min(items.length, lastIndex));
+//      }
+//  }
+//  
+//  if (parentItem !is null) parentItem.itemCount = count;
+//  int length = Math.max (4, (count + 3) / 4 * 4);
+//  int [] newIds = new int [length];
+//  if (ids !is null) {
+//      System.arraycopy (ids, 0, newIds, 0, Math.min (count, itemCount));
+//  }
+//  ids = newIds;
+//  if (parentItem is null) {
+//      childIds = newIds;
+//  } else {
+//      parentItem.childIds = newIds;
+//  }
+//  
+//  if (count > itemCount) {
+//      if ((getStyle() & DWT.VIRTUAL) is 0) {
+//          int delta = Math.max (4, (count - itemCount + 3) / 4 * 4);
+//          TreeItem [] newItems = new TreeItem [items.length + delta];
+//          System.arraycopy (items, 0, newItems, 0, items.length);
+//          items = newItems;
+//          for (int i=itemCount; i<count; i++) {
+//              items [i] = new TreeItem (this, parentItem, DWT.NONE, i, true);
+//          }
+//      } else {
+//          if (parentItem is null || parentItem.getExpanded ()) {
+//              int parentID = parentItem is null ? OS.kDataBrowserNoItem : parentItem.id;
+//              int [] addIds = _getIds (count - itemCount);
+//              if (OS.AddDataBrowserItems (handle, parentID, addIds.length, addIds, OS.kDataBrowserItemNoProperty) !is OS.noErr) {
+//                  error (DWT.ERROR_ITEM_NOT_ADDED);
+//              }
+//              visibleCount += (count - itemCount);
+//              System.arraycopy (addIds, 0, ids, itemCount, addIds.length);
+//          }
+//      }
+//  }
+//  
+//  callbacks.v1_itemNotificationCallback = display.itemNotificationProc;
+//  callbacks.v1_itemCompareCallback = display.itemCompareProc;
+//  OS.SetDataBrowserCallbacks (handle, callbacks);
+//  setRedraw (true);
+//  if (itemCount is 0 && parentItem !is null) parentItem.redraw (OS.kDataBrowserNoItem);
+}
+
+/*public*/ void setItemHeight (int itemHeight) {
+    checkWidget ();
+    if (itemHeight < -1) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (itemHeight is -1) {
+        //TODO - reset item height, ensure other API's such as setFont don't do this
+    } else {
+//      OS.SetDataBrowserTableViewRowHeight (handle, (short) itemHeight);
+    }
+}
+
+void setItemHeight (Image image) {
+//  Rectangle bounds = image !is null ? image.getBounds () : imageBounds;
+//  if (bounds is null) return;
+//  imageBounds = bounds;
+//  short [] height = new short [1];
+//  if (OS.GetDataBrowserTableViewRowHeight (handle, height) is OS.noErr) {
+//      if (height [0] < bounds.height) {
+//          OS.SetDataBrowserTableViewRowHeight (handle, (short) bounds.height);
+//      }
+//  }
+}
+
+/**
+ * Marks the receiver's lines as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setLinesVisible (bool show) {
+    checkWidget ();
+    ((NSTableView)view).setUsesAlternatingRowBackgroundColors(show);
+}
+
+public void setRedraw (bool redraw) {
+    checkWidget();
+    super.setRedraw (redraw);
+    if (redraw && drawCount is 0) {
+        setScrollWidth (true);
+    }
+}
+
+bool setScrollWidth (TreeItem item) {
+//  if (ignoreRedraw || drawCount !is 0) return false;
+    if (columnCount !is 0) return false;
+//  TreeItem parentItem = item.parentItem;
+//  if (parentItem !is null && !parentItem._getExpanded ()) return false;
+//  GC gc = new GC (this);
+//  int newWidth = item.calculateWidth (0, gc);
+//  gc.dispose ();
+//  newWidth += getInsetWidth (column_id, false);
+//  short [] width = new short [1];
+//  OS.GetDataBrowserTableViewNamedColumnWidth (handle, column_id, width);
+//  if (width [0] < newWidth) {
+//      OS.SetDataBrowserTableViewNamedColumnWidth (handle, column_id, (short) newWidth);
+//      return true;
+//  }
+//  firstColumn.setWidth(400);
+    return false;
+}
+
+bool setScrollWidth (bool set) {
+//  return setScrollWidth(set, childIds, true);
+    return false;
+}
+
+bool setScrollWidth (bool set, int[] childIds, bool recurse) {
+//  if (ignoreRedraw || drawCount !is 0) return false;
+//  if (columnCount !is 0 || childIds is null) return false;
+//  GC gc = new GC (this);
+//  int newWidth = calculateWidth (childIds, gc, recurse, 0, 0);
+//  gc.dispose ();
+//  newWidth += getInsetWidth (column_id, false);
+//  if (!set) {
+//      short [] width = new short [1];
+//      OS.GetDataBrowserTableViewNamedColumnWidth (handle, column_id, width);
+//      if (width [0] >= newWidth) return false;
+//  }
+//  OS.SetDataBrowserTableViewNamedColumnWidth (handle, column_id, (short) newWidth);
+    return true;
+}
+
+/**
+ * Sets the receiver's selection to the given item.
+ * The current selection is cleared before the new item is selected.
+ * <p>
+ * If the item is not in the receiver, then it is ignored.
+ * </p>
+ *
+ * @param item the item to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSelection (TreeItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    setSelection (new TreeItem [] {item});
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ * </p>
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the items has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#deselectAll()
+ */
+public void setSelection (TreeItem [] items) {
+    checkWidget ();
+    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    deselectAll ();
+//  int length = items.length;
+//  if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
+//  int count = 0;
+//  int[] ids = new int [length];
+//  for (int i=0; i<length; i++) {
+//      if (items [i] !is null) {
+//          if (items [i].isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+//          ids [count++] = items [i].id;
+//          showItem (items [i], false);
+//      }
+//  }
+//  ignoreSelect = true;
+//  /*
+//  * Bug in the Macintosh.  When the DataBroswer selection flags includes
+//  * both kDataBrowserNeverEmptySelectionSet and kDataBrowserSelectOnlyOne,
+//    * two items are selected when SetDataBrowserSelectedItems() is called
+//    * with kDataBrowserItemsAssign to assign a new seletion despite the fact
+//  * that kDataBrowserSelectOnlyOne was specified.  The fix is to save and
+//  * restore kDataBrowserNeverEmptySelectionSet around each call to
+//  * SetDataBrowserSelectedItems().
+//  */
+//  int [] selectionFlags = null;
+//  if ((style & DWT.SINGLE) !is 0) {
+//      selectionFlags = new int [1];
+//      OS.GetDataBrowserSelectionFlags (handle, selectionFlags);
+//      OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0] & ~OS.kDataBrowserNeverEmptySelectionSet);
+//  }
+//  OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign);
+//  if ((style & DWT.SINGLE) !is 0) {
+//      OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0]);
+//  }
+//  ignoreSelect = false;
+//  if (length > 0) {
+//      int index = -1;
+//      for (int i=0; i<items.length; i++) {
+//          if (items [i] !is null) {
+//              index = i;
+//              break;
+//          }
+//      }
+//      if (index !is -1) showItem (items [index], true);
+//  }
+}
+
+/**
+ * Sets the column used by the sort indicator for the receiver. A null
+ * value will clear the sort indicator.  The current sort column is cleared 
+ * before the new column is set.
+ *
+ * @param column the column used by the sort indicator or <code>null</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the column is disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortColumn (TreeColumn column) {
+    checkWidget ();
+    if (column !is null && column.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (column is sortColumn) return;
+//  if (column is null) {
+//      if (sortColumn !is null  && !sortColumn.isDisposed ()  && sortDirection !is DWT.NONE) {
+//          OS.SetDataBrowserSortOrder (handle, (short) OS.kDataBrowserOrderIncreasing);
+//          sortColumn = null; 
+//          OS.SetDataBrowserSortProperty (handle, 0);
+//      }
+//  }
+//  sortColumn = column;
+//  if (sortColumn !is null  && !sortColumn.isDisposed () && sortDirection !is DWT.NONE) {
+//      OS.SetDataBrowserSortProperty (handle, sortColumn.id);
+//      int order = sortDirection is DWT.DOWN ? OS.kDataBrowserOrderDecreasing : OS.kDataBrowserOrderIncreasing;
+//      OS.SetDataBrowserSortOrder (handle, (short) order);
+//  }
+}
+
+/**
+ * Sets the direction of the sort indicator for the receiver. The value 
+ * can be one of <code>UP</code>, <code>DOWN</code> or <code>NONE</code>.
+ *
+ * @param direction the direction of the sort indicator 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortDirection  (int direction) {
+    checkWidget ();
+    if (direction !is DWT.UP && direction !is DWT.DOWN && direction !is DWT.NONE) return;
+//  if (direction is sortDirection) return;
+//  sortDirection = direction;
+//  if (sortColumn !is null && !sortColumn.isDisposed ()) {
+//      if (sortDirection is DWT.NONE) {
+//          OS.SetDataBrowserSortOrder (handle, (short) OS.kDataBrowserOrderIncreasing);
+//          TreeColumn column = sortColumn;
+//          sortColumn = null; 
+//          OS.SetDataBrowserSortProperty (handle, 0);
+//          sortColumn = column;
+//      } else {
+//          OS.SetDataBrowserSortProperty (handle, 0);
+//          OS.SetDataBrowserSortProperty (handle, sortColumn.id);
+//          int order = sortDirection is DWT.DOWN ? OS.kDataBrowserOrderDecreasing : OS.kDataBrowserOrderIncreasing;
+//          OS.SetDataBrowserSortOrder (handle, (short) order);
+//      }
+//  }
+}
+
+/**
+ * Sets the item which is currently at the top of the receiver.
+ * This item can change when items are expanded, collapsed, scrolled
+ * or new items are added or removed.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#getTopItem()
+ * 
+ * @since 2.1
+ */
+public void setTopItem (TreeItem item) {
+    checkWidget();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+//  showItem (item, false);
+//  int columnId = (columnCount is 0) ? column_id : columns [0].id;
+//  OS.RevealDataBrowserItem (handle, item.id, columnId, (byte) OS.kDataBrowserRevealWithoutSelecting);
+//  Rect rect = new Rect ();
+//  if (OS.GetDataBrowserItemPartBounds (handle, item.id, column_id, OS.kDataBrowserPropertyEnclosingPart, rect) is OS.noErr) {
+//      int border = getBorder ();
+//      int [] top = new int [1], left = new int [1];
+//      OS.GetDataBrowserScrollPosition (handle, top, left);
+//      OS.SetDataBrowserScrollPosition (handle, Math.max (0, top [0] + rect.top - border - getHeaderHeight ()), left [0]);
+//  }
+}
+
+/**
+ * Shows the column.  If the column is already showing in the receiver,
+ * this method simply returns.  Otherwise, the columns are scrolled until
+ * the column is visible.
+ *
+ * @param column the column to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void showColumn (TreeColumn column) {
+    checkWidget ();
+    if (column is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (column.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
+    if (column.parent !is this) return;
+    int index = indexOf (column);
+    if (columnCount <= 1 || !(0 <= index && index < columnCount)) return;
+    ((NSTableView)view).scrollColumnToVisible(index + ((style & DWT.CHECK) !is 0 ? 1 : 0));
+}
+
+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#showSelection()
+ */
+public void showItem (TreeItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    showItem (item, true);
+}
+
+void showItem (TreeItem item, bool scroll) {
+    int count = 0;
+//  TreeItem parentItem = item.parentItem;
+//  while (parentItem !is null && !parentItem._getExpanded ()) {
+//      count++;
+//      parentItem = parentItem.parentItem;
+//  }
+//  int index = 0;
+//  parentItem = item.parentItem;
+//  TreeItem [] path = new TreeItem [count];
+//  while (parentItem !is null && !parentItem._getExpanded ()) {
+//      path [index++] = parentItem;
+//      parentItem = parentItem.parentItem;
+//  }
+//  for (int i=path.length-1; i>=0; --i) {
+//      path [i].setExpanded (true);
+//  }
+//  if (scroll) {
+//      /*
+//      * Bug in the Macintosh.  When there is not room to show a
+//      * single item in the data browser, RevealDataBrowserItem()
+//      * scrolls the item such that it is above the top of the data
+//      * browser.  The fix is to remember the index and scroll when
+//      * the data browser is resized.
+//      * 
+//      * Bug in the Macintosh.  When items are added to the data
+//      * browser after is has been hidden, RevealDataBrowserItem()
+//      * when called before the controls behind the data browser
+//      * are repainted causes a redraw.  This redraw happens right
+//      * away causing pixel corruption.  The fix is to remember the
+//      * index and scroll when the data browser is shown.
+//      */
+//      Rectangle rect = getClientArea ();
+//      if (rect.height < getItemHeight () || !OS.IsControlVisible (handle)) {
+//          showItem = item;
+//          return;
+//      }
+//      showItem = null;
+//      Rectangle itemRect = item.getBounds ();
+//      if (!itemRect.isEmpty()) {
+//          if (rect.contains (itemRect.x, itemRect.y)
+//              && rect.contains (itemRect.x, itemRect.y + itemRect.height)) return;
+//      }
+//      int [] top = new int [1], left = new int [1];
+//      OS.GetDataBrowserScrollPosition (handle, top, left);
+//      int columnId = (columnCount is 0) ? column_id : columns [0].id;
+//      int options = OS.kDataBrowserRevealWithoutSelecting;
+//      /*
+//      * This code is intentionally commented, since kDataBrowserRevealAndCenterInView
+//      * does not scroll the item to the center always (it seems to scroll to the
+//      * end in some cases).
+//      */
+//      //options |= OS.kDataBrowserRevealAndCenterInView;
+//      OS.RevealDataBrowserItem (handle, item.id, columnId, (byte) options);
+//      int [] newTop = new int [1], newLeft = new int [1];
+//      if (columnCount is 0) {
+//          bool fixScroll = false;
+//          Rect content = new Rect ();
+//          if (OS.GetDataBrowserItemPartBounds (handle, item.id, columnId, OS.kDataBrowserPropertyContentPart, content) is OS.noErr) {
+//              fixScroll = content.left < rect.x || content.left >= rect.x + rect.width;
+//              if (!fixScroll) {
+//                  GC gc = new GC (this);
+//                  int contentWidth = calculateWidth (new int[]{item.id}, gc, false, 0, 0);
+//                  gc.dispose ();
+//                  fixScroll =  content.left + contentWidth > rect.x + rect.width;
+//              }
+//          }
+//          if (fixScroll) {
+//              int leftScroll = getLeftDisclosureInset (columnId);
+//              int levelIndent = DISCLOSURE_COLUMN_LEVEL_INDENT;
+//              if (OS.VERSION >= 0x1040) {
+//                  float [] metric = new float [1];
+//                  OS.DataBrowserGetMetric (handle, OS.kDataBrowserMetricDisclosureColumnPerDepthGap, null, metric);
+//                  levelIndent = (int) metric [0];
+//              }
+//              TreeItem temp = item;
+//              while (temp.parentItem !is null) {
+//                  leftScroll += levelIndent;
+//                  temp = temp.parentItem;
+//              }
+//              OS.GetDataBrowserScrollPosition (handle, newTop, newLeft);
+//              OS.SetDataBrowserScrollPosition (handle, newTop [0], leftScroll);
+//          }
+//      }
+//
+//      /*
+//      * Bug in the Macintosh.  For some reason, when the DataBrowser is scrolled
+//      * by RevealDataBrowserItem(), the scrollbars are not redrawn.  The fix is to
+//      * force a redraw.
+//      */
+//      OS.GetDataBrowserScrollPosition (handle, newTop, newLeft);
+//      if (horizontalBar !is null && newLeft [0] !is left [0]) horizontalBar.redraw ();
+//      if (verticalBar !is null && newTop [0] !is top [0]) verticalBar.redraw ();
+//  }
+}
+
+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#showItem(TreeItem)
+ */
+public void showSelection () {
+    checkWidget ();
+    //checkItems (false);
+    //TODO - optimize
+    TreeItem [] selection = getSelection ();
+    if (selection.length > 0) showItem (selection [0], true);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TreeColumn.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,538 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TreeColumn;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.ControlListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.graphics.Image;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSTableColumn;
+import dwt.internal.cocoa.OS;
+
+/**
+ * Instances of this class represent a column in a tree widget.
+ * <p><dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd> Move, Resize, Selection</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @since 3.1
+ */
+public class TreeColumn extends Item {
+    NSTableColumn nsColumn;
+    Tree parent;
+    String toolTipText;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeColumn (Tree parent, int style) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, parent.getColumnCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT#LEFT
+ * @see DWT#RIGHT
+ * @see DWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeColumn (Tree parent, int style, int index) {
+    super (parent, checkStyle (style));
+    this.parent = parent;
+    parent.createItem (this, index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener(ControlListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Resize,typedListener);
+    addListener (DWT.Move,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the column header is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Selection,typedListener);
+    addListener (DWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+    return checkBits (style, DWT.LEFT, DWT.CENTER, DWT.RIGHT, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+void destroyWidget () {
+    parent.destroyItem (this);
+    releaseHandle ();
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>.
+ *
+ * @return the alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+    checkWidget ();
+    if ((style & DWT.LEFT) !is 0) return DWT.LEFT;
+    if ((style & DWT.CENTER) !is 0) return DWT.CENTER;
+    if ((style & DWT.RIGHT) !is 0) return DWT.RIGHT;
+    return DWT.LEFT;
+}
+
+String getNameText () {
+    return getText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Tree</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Tree getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Gets the moveable attribute. A column that is
+ * not moveable cannot be reordered by the user 
+ * by dragging the header but may be reordered 
+ * by the programmer.
+ *
+ * @return the moveable attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#setMoveable(bool)
+ * @see DWT#Move
+ * 
+ * @since 3.2
+ */
+public bool getMoveable () {
+    checkWidget ();
+//  int [] flags = new int [1];
+//  OS.GetDataBrowserPropertyFlags (parent.handle, id, flags);
+//  return (flags [0] & OS.kDataBrowserListViewMovableColumn) !is 0;
+    return false;
+}
+
+/**
+ * Gets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @return the resizable attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getResizable () {
+    checkWidget ();
+    return nsColumn.resizingMask() !is OS.NSTableColumnNoResizing;
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public String getToolTipText () {
+    checkWidget ();
+    return toolTipText;
+}
+
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getWidth () {
+    checkWidget ();
+    return (int)nsColumn.width();
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void pack () {
+    checkWidget ();
+//  GC gc = new GC (parent);
+//  int width = gc.stringExtent (text).x;
+    //TODO extra header
+//  int index = parent.indexOf (this);
+//  width = Math.max (width, calculateWidth (parent.childIds, index, gc, width));
+//
+//  gc.dispose ();
+//  setWidth (width + parent.getInsetWidth (id, true));
+    //TODO this only takes care of the header
+    nsColumn.sizeToFit();
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (nsColumn !is null) nsColumn.release();
+    nsColumn = null;
+    parent = null;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    if (parent.sortColumn is this) {
+        parent.sortColumn = null;
+    }
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Move, listener);
+    eventTable.unhook (DWT.Resize, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+    checkWidget ();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Selection, listener);
+    eventTable.unhook (DWT.DefaultSelection,listener);  
+}
+
+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+    checkWidget ();
+    if ((alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER)) is 0) return;
+    int index = parent.indexOf (this);
+    if (index is -1 || index is 0) return;
+    style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER);
+    //TODO
+}
+
+public void setImage (Image image) {
+    checkWidget();
+    if (image !is null && image.isDisposed ()) {
+        error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+//  int index = parent.indexOf (this);
+//  if (index is -1) return;
+//  if (iconRef !is 0) {
+//      OS.ReleaseIconRef (iconRef);
+//      iconRef = 0;
+//  }
+//  super.setImage (image);
+//  if (image !is null) {
+//      if (OS.VERSION < 0x1040) {
+//          iconRef = createIconRef (image);
+//      }
+//  }
+//  updateHeader ();
+}
+
+/**
+ * Sets the moveable attribute.  A column that is
+ * moveable can be reordered by the user by dragging
+ * the header. A column that is not moveable cannot be 
+ * dragged by the user but may be reordered 
+ * by the programmer.
+ *
+ * @param moveable the moveable attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#setColumnOrder(int[])
+ * @see Tree#getColumnOrder()
+ * @see TreeColumn#getMoveable()
+ * @see DWT#Move
+ * 
+ * @since 3.2
+ */
+public void setMoveable (bool moveable) {
+    checkWidget ();
+//  int [] flags = new int [1];
+//  OS.GetDataBrowserPropertyFlags (parent.handle, id, flags);
+//  if (moveable) {
+//      flags [0] |= OS.kDataBrowserListViewMovableColumn;
+//  } else {
+//      flags [0] &= ~OS.kDataBrowserListViewMovableColumn;
+//  }
+//  OS.SetDataBrowserPropertyFlags (parent.handle, id, flags [0]);
+}
+
+/**
+ * Sets the resizable attribute.  A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @param resizable the resize attribute
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setResizable (bool resizable) {
+    checkWidget ();
+    nsColumn.setResizingMask(resizable ? OS.NSTableColumnUserResizingMask : OS.NSTableColumnNoResizing);
+}
+
+public void setText (String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    super.setText (string);
+    char [] buffer = new char [text.length ()];
+    text.getChars (0, buffer.length, buffer, 0);
+    int length = fixMnemonic (buffer);
+    nsColumn.headerCell().setTitle(NSString.stringWithCharacters(buffer, length));
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setToolTipText (String string) {
+    checkWidget();
+    toolTipText = string;
+}
+
+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWidth (int width) {
+    checkWidget ();
+    if (width < 0) return;
+    nsColumn.setWidth (width);
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TreeItem.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1369 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TreeItem;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.graphics.Color;
+import dwt.graphics.Font;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSAttributedString;
+import dwt.internal.cocoa.NSColor;
+import dwt.internal.cocoa.NSMutableDictionary;
+import dwt.internal.cocoa.NSOutlineView;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.SWTTreeItem;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a hierarchy of tree items in a tree widget.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class TreeItem extends Item {
+    Tree parent;
+    TreeItem parentItem;
+    TreeItem[] items;
+    int itemCount;
+    String [] strings;
+    Image [] images;
+    bool checked, grayed, cached, expanded;
+    Color foreground, background;
+    Color[] cellForeground, cellBackground;
+    Font font;
+    Font[] cellFont;
+    int width = -1;
+    //
+    SWTTreeItem handle;
+    
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (Tree parent, int style) {
+    this (checkNull (parent), null, style, -1, true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (Tree parent, int style, int index) {
+    this (checkNull (parent), null, style, checkIndex (index), true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (TreeItem parentItem, int style) {
+    this (checkNull (parentItem).parent, parentItem, style, -1, true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (TreeItem parentItem, int style, int index) {
+    this (checkNull (parentItem).parent, parentItem, style, checkIndex (index), true);
+}
+
+TreeItem (Tree parent, TreeItem parentItem, int style, int index, bool create) {
+    super (parent, style);
+    this.parent = parent;
+    this.parentItem = parentItem;
+    if (create) parent.createItem (this, parentItem, index);
+}
+
+static TreeItem checkNull (TreeItem item) {
+    if (item is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    return item;
+}
+
+static Tree checkNull (Tree parent) {
+    if (parent is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
+    return parent;
+}
+
+static int checkIndex (int index) {
+    if (index < 0) DWT.error (DWT.ERROR_INVALID_RANGE);
+    return index;
+}
+
+int calculateWidth (int index, GC gc) {
+    if (index is 0 && width !is -1) return width;
+    int width = 0;
+    Image image = getImage (index);
+    String text = getText (index);
+    gc.setFont (getFont (index));
+//  if (image !is null) width += image.getBounds ().width + parent.getGap ();
+    if (text !is null && text.length () > 0) width += gc.stringExtent (text).x;
+//  if (parent.hooks (DWT.MeasureItem)) {
+//      Event event = new Event ();
+//      event.item = this;
+//      event.index = index;
+//      event.gc = gc;
+//      short [] height = new short [1];
+//      OS.GetDataBrowserTableViewRowHeight (parent.handle, height);
+//      event.width = width;
+//      event.height = height [0];
+//      parent.sendEvent (DWT.MeasureItem, event);
+//      if (parent.itemHeight < event.height) {
+//          parent.itemHeight = event.height;
+//          OS.SetDataBrowserTableViewRowHeight (parent.handle, (short) event.height);
+//      }
+//      width = event.width;
+//  }
+    if (index is 0) this.width = width;
+    return width;
+}
+
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+void clear () {
+    cached = false;
+    text = "";
+    image = null;
+    strings = null;
+    images = null;
+    checked = grayed = false;
+    foreground = background = null;
+    cellForeground = cellBackground = null;
+    font = null;
+    cellFont = null;
+}
+
+/**
+ * Clears the item at the given zero-relative index in the receiver.
+ * The text, icon and other attributes of the item are set to the default
+ * value.  If the tree was created with the <code>DWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param index the index of the item to clear
+ * @param all <code>true</code> if all child items of the indexed item should be
+ * cleared recursively, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clear (int index, bool all) {
+    checkWidget ();
+    int count = getItemCount ();
+    if (index < 0 || index >= count) DWT.error (DWT.ERROR_INVALID_RANGE);
+    parent.clear (this, index, all);
+}
+
+
+/**
+ * Clears all the items in the receiver. The text, icon and other
+ * attributes of the items are set to their default values. If the
+ * tree was created with the <code>DWT.VIRTUAL</code> style, these
+ * attributes are requested again as needed.
+ * 
+ * @param all <code>true</code> if all child items should be cleared
+ * recursively, and <code>false</code> otherwise
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT#VIRTUAL
+ * @see DWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clearAll (bool all) {
+    checkWidget ();
+    parent.clearAll (this, all);
+}
+
+NSAttributedString createString(int index) {
+    NSMutableDictionary dict = NSMutableDictionary.dictionaryWithCapacity(4);
+    Color foreground = cellForeground !is null ? cellForeground [index] : null;
+    if (foreground is null) foreground = this.foreground;
+    if (foreground is null) foreground = parent.foreground;
+    if (foreground !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(foreground.handle[0], foreground.handle[1], foreground.handle[2], 1);
+        dict.setObject(color, OS.NSForegroundColorAttributeName());
+    }
+    Font font = cellFont !is null ? cellFont [index] : null;
+    if (font is null) font = this.font;
+//  if (font is null) font = parent.font;
+    if (font !is null) {
+        dict.setObject(font.handle, OS.NSFontAttributeName());
+    }
+    Color background = cellBackground !is null ? cellBackground [index] : null;
+    if (background is null) background = this.background;
+    if (background !is null) {
+        NSColor color = NSColor.colorWithDeviceRed(background.handle[0], background.handle[1], background.handle[2], 1);
+        dict.setObject(color, OS.NSBackgroundColorAttributeName());
+    }
+    String text = getText (index);
+    int length = text.length();
+    char[] chars = new char[length];
+    text.getChars(0, length, chars, 0);
+    NSString str = NSString.stringWithCharacters(chars, length);
+    NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict);
+    attribStr.autorelease();
+    return attribStr;
+}
+
+void destroyWidget () {
+    parent.destroyItem (this);
+    releaseHandle ();
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ * 
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getBackground () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return background !is null ? background : parent.getBackground ();
+}
+
+/**
+ * Returns the background color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the background color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Color getBackground (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count -1) return getBackground ();
+    if (cellBackground is null || cellBackground [index] is null) return getBackground ();
+    return cellBackground [index];
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    NSOutlineView outlineView = (NSOutlineView) parent.view;
+    int row = outlineView.rowForItem(handle);
+    NSRect rect = outlineView.rectOfRow (row);
+    rect = outlineView.convertRect_toView_ (rect, parent.scrollView);
+    Rectangle result = new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
+    return result;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent at a column in the tree.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding column rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Rectangle getBounds (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (index !is 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
+    NSOutlineView outlineView = (NSOutlineView) parent.view;
+    int row = outlineView.rowForItem(handle);
+    if ((parent.style & DWT.CHECK) !is 0) index ++;
+    NSRect rect = outlineView.frameOfCellAtColumn(index, row);
+    rect = outlineView.convertRect_toView_ (rect, parent.scrollView);
+    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @return the checked state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getChecked () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if ((parent.style & DWT.CHECK) is 0) return false;
+    return checked;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is expanded,
+ * and false otherwise.
+ * <p>
+ *
+ * @return the expanded state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getExpanded () {
+    checkWidget ();
+    return expanded;
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information for this item.
+ *
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return font !is null ? font : parent.getFont ();
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information
+ * for the specified cell in this item.
+ *
+ * @param index the column index
+ * @return the receiver's font
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public Font getFont (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count -1) return getFont ();
+    if (cellFont is null || cellFont [index] is null) return getFont ();
+    return cellFont [index];
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getForeground () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return foreground !is null ? foreground : parent.getForeground ();
+}
+
+/**
+ * 
+ * Returns the foreground color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the foreground color
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Color getForeground (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count -1) return getForeground ();
+    if (cellForeground is null || cellForeground [index] is null) return getForeground ();
+    return cellForeground [index];
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public bool getGrayed () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if ((parent.style & DWT.CHECK) is 0) return false;
+    return grayed;
+}
+
+public Image getImage () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return super.getImage ();
+}
+
+/**
+ * Returns the image stored at the given column index in the receiver,
+ * or null if the image has not been set or if the column does not exist.
+ *
+ * @param index the column index
+ * @return the image stored at the given column index in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Image getImage (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (index is 0) return getImage ();
+    if (images !is null) {
+        if (0 <= index && index < images.length) return images [index];
+    }
+    return null;
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of an image at a column in the
+ * tree.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding image rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Rectangle getImageBounds (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+//  if (index !is 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
+//  Rect rect = new Rect();
+//  int columnId = parent.columnCount is 0 ? parent.column_id : parent.columns [index].id;
+//  if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect) !is OS.noErr) {
+//      return new Rectangle (0, 0, 0, 0);
+//  }
+//  int x = rect.left, y = rect.top;
+//  int width = 0;
+//  if (index is 0 && image !is null) {
+//      Rectangle bounds = image.getBounds ();
+//      width += bounds.width;
+//  }
+//  if (index !is 0 && images !is null && images[index] !is null) {
+//      Rectangle bounds = images [index].getBounds ();
+//      width += bounds.width;
+//  }
+//  int height = rect.bottom - rect.top + 1;
+//  return new Rectangle (x, y, width, height);
+    return null;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TreeItem getItem (int index) {
+    checkWidget ();
+    if (index < 0) error (DWT.ERROR_INVALID_RANGE);
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (index >= itemCount) error (DWT.ERROR_INVALID_RANGE);
+    return parent._getItem (this, index);
+}
+
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return itemCount;
+}
+
+/**
+ * Returns a (possibly empty) array of <code>TreeItem</code>s which
+ * are the direct item children of the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getItems () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    TreeItem [] result = new TreeItem [itemCount];
+    for (int i=0; i<itemCount; i++) {
+        result [i] = parent._getItem (this, i);
+    }
+    return result;
+}
+
+String getNameText () {
+    if ((parent.style & DWT.VIRTUAL) !is 0) {
+        if (!cached) return "*virtual*"; //$NON-NLS-1$
+    }
+    return super.getNameText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Tree</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Tree getParent () {
+    checkWidget ();
+    return parent;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem getParentItem () {
+    checkWidget ();
+    return parentItem;
+}
+
+public String getText () {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    return super.getText ();
+}
+
+/**
+ * Returns the text stored at the given column index in the receiver,
+ * or empty string if the text has not been set.
+ *
+ * @param index the column index
+ * @return the text stored at the given column index in the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public String getText (int index) {
+    checkWidget ();
+    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (index is 0) return getText ();
+    if (strings !is null) {
+        if (0 <= index && index < strings.length) {
+            String string = strings [index];
+            return string !is null ? string : "";
+        }
+    }
+    return "";
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of the text at a column in the
+ * tree.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding text rectangle
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Rectangle getTextBounds (int index) {
+    checkWidget ();
+//  if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
+//  if (index !is 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
+//  Rect rect = new Rect();
+//  int columnId = parent.columnCount is 0 ? parent.column_id : parent.columns [index].id;
+//  if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) !is OS.noErr) {
+//      return new Rectangle (0, 0, 0, 0);
+//  }
+//  int[] disclosure = new int [1];
+//  OS.GetDataBrowserListViewDisclosureColumn (parent.handle, disclosure, new bool [1]);
+//  int imageWidth = 0;
+//  int margin = index is 0 ? 0 : parent.getInsetWidth (columnId, false) / 2;
+//  Image image = getImage (index);
+//  if (image !is null) {
+//      Rectangle bounds = image.getBounds ();
+//      imageWidth = bounds.width + parent.getGap ();
+//  }
+//  int x, y, width, height;
+//  if (OS.VERSION >= 0x1040 && disclosure [0] !is columnId) {
+//      if (parent.getLinesVisible ()) {
+//          rect.left += Tree.GRID_WIDTH;
+//          rect.top += Tree.GRID_WIDTH;
+//      }
+//      x = rect.left + imageWidth + margin;
+//      y = rect.top;
+//      width = Math.max (0, rect.right - rect.left - imageWidth - margin * 2);;
+//      height = rect.bottom - rect.top;
+//  } else {
+//      Rect rect2 = new Rect();
+//      if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect2) !is OS.noErr) {
+//          return new Rectangle (0, 0, 0, 0);
+//      }
+//      x = rect2.left + imageWidth + margin;
+//      y = rect2.top;
+//      width = Math.max (0, rect.right - rect2.left + 1 - imageWidth - margin * 2);
+//      height = rect2.bottom - rect2.top + 1;
+//  }
+//  return new Rectangle (x, y, width, height);
+    return null;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int indexOf (TreeItem item) {
+    checkWidget ();
+    if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (item.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    if (item.parentItem !is this) return -1;
+    for (int i = 0; i < itemCount; i++) {
+        if (item is items[i]) return i;
+    }
+    return -1;
+}
+
+void releaseChildren (bool destroy) {
+    for (int i=0; i<items.length; i++) {
+        TreeItem item = items [i];
+        if (item !is null && !item.isDisposed ()) {
+            item.release (false);
+        }
+    }
+    items = null;
+    itemCount = 0;
+    super.releaseChildren (destroy);
+}
+
+void releaseHandle () {
+    super.releaseHandle ();
+    if (handle !is null) handle.release();
+    handle = null;
+    parentItem = null;
+    parent = null;
+}
+
+void releaseWidget () {
+    super.releaseWidget ();
+    strings = null;
+    images = null;
+    background = foreground = null;
+    font = null;
+    cellBackground = cellForeground = null;
+    cellFont = null;
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void removeAll () {
+    checkWidget ();
+//  for (int i=itemCount - 1; i >= 0; i--) {
+//      TreeItem item = parent._getItem (childIds [i], false);
+//      if (item !is null && !item.isDisposed ()) {
+//          item.dispose ();
+//      }
+//  }
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setBackground (Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    Color oldColor = background;
+    if (oldColor is color) return;
+    background = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true;
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the background color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ * 
+ */
+public void setBackground (int index, Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count - 1) return;
+    if (cellBackground is null) {
+        if (color is null) return;
+        cellBackground = new Color [count];
+    }
+    Color oldColor = cellBackground [index];
+    if (oldColor is color) return;
+    cellBackground [index] = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true; 
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the checked state of the receiver.
+ * <p>
+ *
+ * @param checked the new checked state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (bool checked) {
+    checkWidget ();
+    if ((parent.style & DWT.CHECK) is 0) return;
+    if (this.checked is checked) return;
+    this.checked = checked;
+    cached = true;
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the expanded state of the receiver.
+ * <p>
+ *
+ * @param expanded the new expanded state
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpanded (bool expanded) {
+    checkWidget ();
+    if (expanded is getExpanded ()) return;
+    parent.ignoreExpand = true;
+    if (expanded) {
+        ((NSOutlineView)parent.view).expandItem_(handle);
+    } else {
+        ((NSOutlineView)parent.view).collapseItem_(handle);
+    }
+    parent.ignoreExpand = false;
+    cached = true;
+//  if (expanded) {
+//      parent.setScrollWidth (false, childIds, false);
+//  } else {
+//      parent.setScrollWidth (true);
+//      parent.fixScrollBar ();
+//  }
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (Font font) {
+    checkWidget ();
+    if (font !is null && font.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    Font oldFont = this.font;
+    if (oldFont is font) return;
+    this.font = font;
+    if (oldFont !is null && oldFont.equals (font)) return;
+    cached = true;
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for the specified cell in this item to the font specified by the 
+ * argument, or to the default font for that kind of control if the 
+ * argument is null.
+ *
+ * @param index the column index
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setFont (int index, Font font) {
+    checkWidget ();
+    if (font !is null && font.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count - 1) return;
+    if (cellFont is null) {
+        if (font is null) return;
+        cellFont = new Font [count];
+    }
+    Font oldFont = this.font;
+    if (oldFont is font) return;
+    cellFont [index] = font;
+    if (oldFont !is null && oldFont.equals (font)) return;
+    cached = true;
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setForeground (Color color) {
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    Color oldColor = foreground;
+    if (oldColor is color) return;
+    foreground = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true;
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the foreground color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ * 
+ */
+public void setForeground (int index, Color color){
+    checkWidget ();
+    if (color !is null && color.isDisposed ()) {
+        DWT.error (DWT.ERROR_INVALID_ARGUMENT);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 > index || index > count - 1) return;
+    if (cellForeground is null) {
+        if (color is null) return;
+        cellForeground = new Color [count];
+    }
+    Color oldColor = cellForeground [index];
+    if (oldColor is color) return;
+    cellForeground [index] = color;
+    if (oldColor !is null && oldColor.equals (color)) return;
+    cached = true;
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item.  This state change 
+ * only applies if the Tree was created with the DWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setGrayed (bool grayed) {
+    checkWidget ();
+    if ((parent.style & DWT.CHECK) is 0) return;
+    if (this.grayed is grayed) return;
+    this.grayed = grayed;
+    cached = true;
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+/**
+ * Sets the image for multiple columns in the tree. 
+ * 
+ * @param images the array of new images
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setImage (Image [] images) {
+    checkWidget ();
+    if (images is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<images.length; i++) {
+        setImage (i, images [i]);
+    }
+}
+
+/**
+ * Sets the receiver's image at a column.
+ *
+ * @param index the column index
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setImage (int index, Image image) {
+    checkWidget ();
+    if (image !is null && image.isDisposed ()) {
+        error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+//  if (parent.imageBounds is null && image !is null) {
+//      parent.setItemHeight (image);
+//  }
+    if (index is 0)  {
+        if (image !is null && image.type is DWT.ICON) {
+            if (image.equals (this.image)) return;
+        }
+        width = -1;
+        super.setImage (image);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 <= index && index < count) {
+        if (images is null) images = new Image [count];
+        if (image !is null && image.type is DWT.ICON) {
+            if (image.equals (images [index])) return;
+        }
+        images [index] = image; 
+    }
+//  cached = true;
+//  if (index is 0) parent.setScrollWidth (this);
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+public void setImage (Image image) {
+    checkWidget ();
+    setImage (0, image);
+}
+
+/**
+ * Sets the number of child items contained in the receiver.
+ *
+ * @param count the number of items
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.2
+ */
+public void setItemCount (int count) {
+    checkWidget ();
+    count = Math.max (0, count);
+    parent.setItemCount (this, count);
+}
+
+/**
+ * Sets the text for multiple columns in the tree. 
+ * 
+ * @param strings the array of new strings
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setText (String [] strings) {
+    checkWidget ();
+    if (strings is null) error (DWT.ERROR_NULL_ARGUMENT);
+    for (int i=0; i<strings.length; i++) {
+        String string = strings [i];
+        if (string !is null) setText (i, string);
+    }
+}
+
+/**
+ * Sets the receiver's text at a column
+ *
+ * @param index the column index
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setText (int index, String string) {
+    checkWidget ();
+    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (index is 0) {
+        if (string.equals (text)) return;
+        width = -1;
+        super.setText (string);
+    }
+    int count = Math.max (1, parent.columnCount);
+    if (0 <= index && index < count) {
+        if (strings is null) strings = new String [count];
+        if (string.equals (strings [index])) return;
+        strings [index] = string;
+    }
+    cached = true;
+    if (index is 0) parent.setScrollWidth (this);
+    ((NSOutlineView)parent.view).reloadItem_(handle);
+}
+
+public void setText (String string) {
+    checkWidget ();
+    setText (0, string);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/TypedListener.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.TypedListener;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.events.ArmEvent;
+import dwt.events.ArmListener;
+import dwt.events.ControlEvent;
+import dwt.events.ControlListener;
+import dwt.events.DisposeEvent;
+import dwt.events.DisposeListener;
+import dwt.events.DragDetectEvent;
+import dwt.events.DragDetectListener;
+import dwt.events.ExpandEvent;
+import dwt.events.ExpandListener;
+import dwt.events.FocusEvent;
+import dwt.events.FocusListener;
+import dwt.events.HelpEvent;
+import dwt.events.HelpListener;
+import dwt.events.KeyEvent;
+import dwt.events.KeyListener;
+import dwt.events.MenuDetectEvent;
+import dwt.events.MenuDetectListener;
+import dwt.events.MenuEvent;
+import dwt.events.MenuListener;
+import dwt.events.ModifyEvent;
+import dwt.events.ModifyListener;
+import dwt.events.MouseEvent;
+import dwt.events.MouseListener;
+import dwt.events.MouseMoveListener;
+import dwt.events.MouseTrackListener;
+import dwt.events.MouseWheelListener;
+import dwt.events.PaintEvent;
+import dwt.events.PaintListener;
+import dwt.events.SelectionEvent;
+import dwt.events.SelectionListener;
+import dwt.events.ShellEvent;
+import dwt.events.ShellListener;
+import dwt.events.TraverseEvent;
+import dwt.events.TraverseListener;
+import dwt.events.TreeEvent;
+import dwt.events.TreeListener;
+import dwt.events.VerifyEvent;
+import dwt.events.VerifyListener;
+import dwt.internal.DWTEventListener;
+
+/**  
+ * Instances of this class are <em>internal DWT implementation</em>
+ * objects which provide a mapping between the typed and untyped 
+ * listener mechanisms that DWT supports.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the DWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by DWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @see Listener
+ */
+public class TypedListener implements Listener {
+    
+    /**
+     * The receiver's event listener
+     */
+    protected DWTEventListener eventListener;
+
+/**
+ * Constructs a new instance of this class for the given event listener.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the DWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by DWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @param listener the event listener to store in the receiver
+ */
+public TypedListener (DWTEventListener listener) {
+    eventListener = listener;
+}
+
+/**
+ * Returns the receiver's event listener.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the DWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by DWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @return the receiver's event listener
+ */
+public DWTEventListener getEventListener () {
+    return eventListener;
+}
+
+/**
+ * Handles the given event.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the DWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by DWT. It should never be
+ * referenced from application code.
+ * </p>
+ * @param e the event to handle
+ */
+public void handleEvent (Event e) {
+    switch (e.type) {
+        case DWT.Activate: {
+            ((ShellListener) eventListener).shellActivated(new ShellEvent(e));
+            break;
+        }
+        case DWT.Arm: {
+            ((ArmListener) eventListener).widgetArmed (new ArmEvent (e));
+            break;
+        }
+        case DWT.Close: {
+            /* Fields set by Decorations */
+            ShellEvent event = new ShellEvent (e);
+            ((ShellListener) eventListener).shellClosed(event);
+            e.doit = event.doit;
+            break;
+        }
+        case DWT.Collapse: {
+            if (eventListener instanceof TreeListener) {
+                ((TreeListener) eventListener).treeCollapsed(new TreeEvent(e));
+            } else {
+                ((ExpandListener) eventListener).itemCollapsed(new ExpandEvent(e)); 
+            }
+            break;
+        }
+        case DWT.Deactivate: {
+            ((ShellListener) eventListener).shellDeactivated(new ShellEvent(e));
+            break;
+        }
+        case DWT.Deiconify: {
+            ((ShellListener) eventListener).shellDeiconified(new ShellEvent(e));
+            break;
+        }
+        case DWT.DefaultSelection: {
+            ((SelectionListener)eventListener).widgetDefaultSelected(new SelectionEvent(e));
+            break;
+        }
+        case DWT.Dispose: {
+            ((DisposeListener) eventListener).widgetDisposed(new DisposeEvent(e));
+            break;
+        }
+        case DWT.DragDetect: {
+            ((DragDetectListener) eventListener).dragDetected(new DragDetectEvent(e));
+            break;
+        }
+        case DWT.Expand: {
+            if (eventListener instanceof TreeListener) {
+                ((TreeListener) eventListener).treeExpanded(new TreeEvent(e));
+            } else {
+                ((ExpandListener) eventListener).itemExpanded(new ExpandEvent(e));  
+            }
+            break;
+        }
+        case DWT.FocusIn: {
+            ((FocusListener) eventListener).focusGained(new FocusEvent(e));
+            break;
+        }
+        case DWT.FocusOut: {
+            ((FocusListener) eventListener).focusLost(new FocusEvent(e));
+            break;
+        }
+        case DWT.Help: {
+            ((HelpListener) eventListener).helpRequested (new HelpEvent (e));
+            break;
+        }
+        case DWT.Hide: {
+            ((MenuListener) eventListener).menuHidden(new MenuEvent(e));
+            break;
+        }
+        case DWT.Iconify: {
+            ((ShellListener) eventListener).shellIconified(new ShellEvent(e));
+            break;
+        }
+        case DWT.KeyDown: {
+            /* Fields set by Control */
+            KeyEvent event = new KeyEvent(e);
+            ((KeyListener) eventListener).keyPressed(event);
+            e.doit = event.doit;
+            break;
+        }
+        case DWT.KeyUp: {
+            /* Fields set by Control */
+            KeyEvent event = new KeyEvent(e);
+            ((KeyListener) eventListener).keyReleased(event);
+            e.doit = event.doit;
+            break;
+        }
+        case DWT.Modify: {
+            ((ModifyListener) eventListener).modifyText(new ModifyEvent(e));
+            break;
+        }
+        case DWT.MenuDetect: {
+            MenuDetectEvent event = new MenuDetectEvent(e);
+            ((MenuDetectListener) eventListener).menuDetected(event);
+            e.x = event.x;
+            e.y = event.y;
+            e.doit = event.doit;
+            break;
+        }
+        case DWT.MouseDown: {
+            ((MouseListener) eventListener).mouseDown(new MouseEvent(e));
+            break;
+        }
+        case DWT.MouseDoubleClick: {
+            ((MouseListener) eventListener).mouseDoubleClick(new MouseEvent(e));
+            break;
+        }
+        case DWT.MouseEnter: {
+            ((MouseTrackListener) eventListener).mouseEnter (new MouseEvent (e));
+            break;
+        }
+        case DWT.MouseExit: {
+            ((MouseTrackListener) eventListener).mouseExit (new MouseEvent (e));
+            break;
+        }
+        case DWT.MouseHover: {
+            ((MouseTrackListener) eventListener).mouseHover (new MouseEvent (e));
+            break;
+        }
+        case DWT.MouseMove: {
+            ((MouseMoveListener) eventListener).mouseMove(new MouseEvent(e));
+            return;
+        }
+        case DWT.MouseWheel: {
+            ((MouseWheelListener) eventListener).mouseScrolled(new MouseEvent(e));
+            return;
+        }
+        case DWT.MouseUp: {
+            ((MouseListener) eventListener).mouseUp(new MouseEvent(e));
+            break;
+        }
+        case DWT.Move: {
+            ((ControlListener) eventListener).controlMoved(new ControlEvent(e));
+            break;
+        }
+        case DWT.Paint: {
+            /* Fields set by Control */
+            PaintEvent event = new PaintEvent (e);
+            ((PaintListener) eventListener).paintControl (event);
+            e.gc = event.gc;
+            break;
+        }
+        case DWT.Resize: {
+            ((ControlListener) eventListener).controlResized(new ControlEvent(e));
+            break;
+        }
+        case DWT.Selection: {
+            /* Fields set by Sash */
+            SelectionEvent event = new SelectionEvent (e);
+            ((SelectionListener) eventListener).widgetSelected (event);         
+            e.x = event.x;
+            e.y = event.y;
+            e.doit = event.doit;
+            break;
+        }
+        case DWT.Show: {
+            ((MenuListener) eventListener).menuShown(new MenuEvent(e));
+            break;
+        }
+        case DWT.Traverse: {
+            /* Fields set by Control */
+            TraverseEvent event = new TraverseEvent (e);
+            ((TraverseListener) eventListener).keyTraversed (event);
+            e.detail = event.detail;
+            e.doit = event.doit;
+            break;
+        }
+        case DWT.Verify: {
+            /* Fields set by Text, RichText */
+            VerifyEvent event = new VerifyEvent (e);
+            ((VerifyListener) eventListener).verifyText (event);
+            e.text = event.text;
+            e.doit = event.doit;
+            break;
+        }
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/widgets/Widget.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,1270 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+module dwt.widgets.Widget;
+
+import dwt.dwthelper.utils;
+
+
+import dwt.DWT;
+import dwt.DWTException;
+import dwt.events.DisposeListener;
+import dwt.internal.DWTEventListener;
+import dwt.internal.cocoa.NSEvent;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.OS;
+import dwt.internal.cocoa.objc_super;
+
+
+/**
+ * This class is the abstract superclass of all user interface objects.  
+ * Widgets are created, disposed and issue notification to listeners
+ * when events occur which affect them.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Dispose</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the DWT implementation. However, it has not been marked
+ * final to allow those outside of the DWT development team to implement
+ * patched versions of the class in order to get around specific
+ * limitations in advance of when those limitations can be addressed
+ * by the team.  Any class built using subclassing to access the internals
+ * of this class will likely fail to compile or run between releases and
+ * may be strongly platform specific. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the workings of the
+ * hierarchy. No support is provided for user-written classes which are
+ * implemented as subclasses of this class.
+ * </p>
+ *
+ * @see #checkSubclass
+ */
+public abstract class Widget {
+    int style, state;
+    Display display;
+    EventTable eventTable;
+    Object data;
+
+    int jniRef;
+
+    /* Global state flags */
+    static final int DISPOSED         = 1 << 0;
+    static final int CANVAS           = 1 << 1;
+    static final int KEYED_DATA       = 1 << 2;
+    static final int DISABLED         = 1 << 3;
+    static final int HIDDEN           = 1 << 4;
+    static final int GRAB                = 1 << 5;
+    static final int MOVED            = 1 << 6;
+    static final int RESIZED          = 1 << 7;
+    static final int EXPANDING        = 1 << 8;
+    static final int IGNORE_WHEEL     = 1 << 9;
+    static final int PARENT_BACKGROUND = 1 << 10;
+    static final int THEME_BACKGROUND = 1 << 11;
+    
+    /* A layout was requested on this widget */
+    static final int LAYOUT_NEEDED  = 1<<12;
+    
+    /* The preferred size of a child has changed */
+    static final int LAYOUT_CHANGED = 1<<13;
+    
+    /* A layout was requested in this widget hierachy */
+    static final int LAYOUT_CHILD = 1<<14;
+
+    /* More global state flags */
+    static final int RELEASED = 1<<15;
+    static final int DISPOSE_SENT = 1<<16;  
+    static final int FOREIGN_HANDLE = 1<<17;
+    static final int DRAG_DETECT = 1<<18;
+
+    /* Safari fixes */
+    static final int SAFARI_EVENTS_FIX = 1<<19;
+    static final String SAFARI_EVENTS_FIX_KEY = "dwt.internal.safariEventsFix"; //$NON-NLS-1$
+
+    /* Default size for widgets */
+    static final int DEFAULT_WIDTH  = 64;
+    static final int DEFAULT_HEIGHT = 64;
+
+Widget () {
+    /* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>DWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DWT
+ * @see #checkSubclass
+ * @see #getStyle
+ */
+public Widget (Widget parent, int style) {
+    checkSubclass ();
+    checkParent (parent);
+    this.style = style;
+    display = parent.display;
+}
+
+void callSuper(int id, int selector, int arg0) {
+    objc_super super_struct = new objc_super();
+    super_struct.receiver = id;
+    super_struct.cls = OS.objc_msgSend(id, OS.sel_superclass);
+    OS.objc_msgSendSuper(super_struct, selector, arg0);
+}
+
+bool acceptsFirstResponder () {
+    return false;
+}
+
+bool becomeFirstResponder () {
+    return true;
+}
+
+bool resignFirstResponder () {
+    return true;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an event of the given type occurs. When the
+ * event does occur in the widget, the listener is notified by
+ * sending it the <code>handleEvent()</code> message. The event
+ * type is one of the event constants defined in class <code>DWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #removeListener(int, Listener)
+ * @see #notifyListeners
+ */
+public void addListener (int eventType, Listener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    _addListener (eventType, listener);
+}
+
+void _addListener (int eventType, Listener listener) {
+    if (eventTable is null) eventTable = new EventTable ();
+    eventTable.hook (eventType, listener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the widget is disposed. When the widget is
+ * disposed, the listener is notified by sending it the
+ * <code>widgetDisposed()</code> message.
+ *
+ * @param listener the listener which should be notified when the receiver is disposed
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DisposeListener
+ * @see #removeDisposeListener
+ */
+public void addDisposeListener (DisposeListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    TypedListener typedListener = new TypedListener (listener);
+    addListener (DWT.Dispose, typedListener);
+}
+
+static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
+    int mask = int0 | int1 | int2 | int3 | int4 | int5;
+    if ((style & mask) is 0) style |= int0;
+    if ((style & int0) !is 0) style = (style & ~mask) | int0;
+    if ((style & int1) !is 0) style = (style & ~mask) | int1;
+    if ((style & int2) !is 0) style = (style & ~mask) | int2;
+    if ((style & int3) !is 0) style = (style & ~mask) | int3;
+    if ((style & int4) !is 0) style = (style & ~mask) | int4;
+    if ((style & int5) !is 0) style = (style & ~mask) | int5;
+    return style;
+}
+
+void checkOpen () {
+    /* Do nothing */
+}
+
+void checkOrientation (Widget parent) {
+    style &= ~DWT.MIRRORED;
+    if ((style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT)) is 0) {
+        if (parent !is null) {
+            if ((parent.style & DWT.LEFT_TO_RIGHT) !is 0) style |= DWT.LEFT_TO_RIGHT;
+            if ((parent.style & DWT.RIGHT_TO_LEFT) !is 0) style |= DWT.RIGHT_TO_LEFT;
+        }
+    }
+    style = checkBits (style, DWT.LEFT_TO_RIGHT, DWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+
+void checkParent (Widget parent) {
+    if (parent is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (parent.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
+    parent.checkWidget ();
+    parent.checkOpen ();
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The DWT class library is intended to be subclassed 
+ * only at specific, controlled points (most notably, 
+ * <code>Composite</code> and <code>Canvas</code> when
+ * implementing new widgets). This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not 
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between DWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed DWT classes
+ * is intended purely to enable those not on the DWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+    if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Throws an <code>DWTException</code> if the receiver can not
+ * be accessed by the caller. This may include both checks on
+ * the state of the receiver and more generally on the entire
+ * execution context. This method <em>should</em> be called by
+ * widget implementors to enforce the standard DWT invariants.
+ * <p>
+ * Currently, it is an error to invoke any method (other than
+ * <code>isDisposed()</code>) on a widget that has had its 
+ * <code>dispose()</code> method called. It is also an error
+ * to call widget methods from any thread that is different
+ * from the thread that created the widget.
+ * </p><p>
+ * In future releases of DWT, there may be more or fewer error
+ * checks and exceptions may be thrown for different reasons.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+protected void checkWidget () {
+    Display display = this.display;
+    if (display is null) error (DWT.ERROR_WIDGET_DISPOSED);
+    if (display.thread !is Thread.currentThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    if ((state & DISPOSED) !is 0) error (DWT.ERROR_WIDGET_DISPOSED);
+}
+
+bool clickOnLink(int textView, int link, int charIndex) {
+    return true;
+}
+
+void comboBoxSelectionDidChange(int notification) {
+}
+
+void createHandle () {
+}
+
+void createJNIRef () {
+    jniRef = OS.NewGlobalRef(this);
+    if (jniRef is 0) error (DWT.ERROR_NO_HANDLES);
+}
+
+void createWidget () {
+    createJNIRef ();
+    createHandle ();
+}
+
+void destroyWidget () {
+    releaseHandle ();
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the receiver and all its descendants. After this method has
+ * been invoked, the receiver and all descendants will answer
+ * <code>true</code> when sent the message <code>isDisposed()</code>.
+ * Any internal connections between the widgets in the tree will
+ * have been removed to facilitate garbage collection.
+ * <p>
+ * NOTE: This method is not called recursively on the descendants
+ * of the receiver. This means that, widget implementers can not
+ * detect when a widget is being disposed of by re-implementing
+ * this method, but should instead listen for the <code>Dispose</code>
+ * event.
+ * </p>
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #addDisposeListener
+ * @see #removeDisposeListener
+ * @see #checkWidget
+ */
+public void dispose () {
+    /*
+    * Note:  It is valid to attempt to dispose a widget
+    * more than once.  If this happens, fail silently.
+    */
+    if (isDisposed ()) return;
+    if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    release (true);
+}
+
+void drawBackground (int control, int context) {
+    /* Do nothing */
+}
+
+void drawRect(int id, NSRect rect) {
+    objc_super super_struct = new objc_super();
+    super_struct.receiver = id;
+    super_struct.cls = OS.objc_msgSend(id, OS.sel_superclass);
+    OS.objc_msgSendSuper(super_struct, OS.sel_drawRect_1, rect);
+}
+
+void drawWidget (int control, int context, int damageRgn, int visibleRgn, int theEvent) {
+}
+
+void error (int code) {
+    DWT.error(code);
+}
+
+bool filters (int eventType) {
+    return display.filters (eventType);
+}
+
+int fixMnemonic (char [] buffer) {
+    int i=0, j=0;
+    while (i < buffer.length) {
+        if ((buffer [j++] = buffer [i++]) is '&') {
+            if (i is buffer.length) {continue;}
+            if (buffer [i] is '&') {i++; continue;}
+            j--;
+        }
+    }
+    return j;
+}
+
+/**
+ * Returns the application defined widget data associated
+ * with the receiver, or null if it has not been set. The
+ * <em>widget data</em> is a single, unnamed field that is
+ * stored with every widget. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the widget data needs to be notified
+ * when the widget is disposed of, it is the application's
+ * responsibility to hook the Dispose event on the widget and
+ * do so.
+ * </p>
+ *
+ * @return the widget data
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ *
+ * @see #setData(Object)
+ */
+public Object getData () {
+    checkWidget();
+    return (state & KEYED_DATA) !is 0 ? ((Object []) data) [0] : data;
+}
+
+/**
+ * Returns the application defined property of the receiver
+ * with the specified name, or null if it has not been set.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the widget is disposed
+ * of, it is the application's responsibility to hook the
+ * Dispose event on the widget and do so.
+ * </p>
+ *
+ * @param   key the name of the property
+ * @return the value of the property or null if it has not been set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setData(String, Object)
+ */
+public Object getData (String key) {
+    checkWidget();
+    if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if ((state & KEYED_DATA) !is 0) {
+        Object [] table = (Object []) data;
+        for (int i=1; i<table.length; i+=2) {
+            if (key.equals (table [i])) return table [i+1];
+        }
+    }
+    return null;
+}
+
+/**
+ * Returns the <code>Display</code> that is associated with
+ * the receiver.
+ * <p>
+ * A widget's display is either provided when it is created
+ * (for example, top level <code>Shell</code>s) or is the
+ * same as its parent's display.
+ * </p>
+ *
+ * @return the receiver's display
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Display getDisplay () {
+    Display display = this.display;
+    if (display is null) error (DWT.ERROR_WIDGET_DISPOSED);
+    return display;
+}
+
+/**
+ * Returns an array of listeners who will be notified when an event 
+ * of the given type occurs. The event type is one of the event constants 
+ * defined in class <code>DWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @return an array of listeners that will be notified when the event occurs
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #addListener(int, Listener)
+ * @see #removeListener(int, Listener)
+ * @see #notifyListeners
+ * 
+ * @since 3.4
+ */
+public Listener[] getListeners (int eventType) {
+    checkWidget();
+    if (eventTable is null) return new Listener[0];
+    return eventTable.getListeners(eventType);
+}
+
+String getName () {
+    String string = getClass ().getName ();
+    int index = string.lastIndexOf ('.');
+    if (index is -1) return string;
+    return string.substring (index + 1, string.length ());
+}
+
+String getNameText () {
+    return "";
+}
+
+/**
+ * Returns the receiver's style information.
+ * <p>
+ * Note that the value which is returned by this method <em>may
+ * not match</em> the value which was provided to the constructor
+ * when the receiver was created. This can occur when the underlying
+ * operating system does not support a particular combination of
+ * requested styles. For example, if the platform widget used to
+ * implement a particular DWT widget always has scroll bars, the
+ * result of calling this method would always have the
+ * <code>DWT.H_SCROLL</code> and <code>DWT.V_SCROLL</code> bits set.
+ * </p>
+ *
+ * @return the style bits
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getStyle () {
+    checkWidget();
+    return style;
+}
+
+void helpRequested(int theEvent) {
+}
+
+bool hooks (int eventType) {
+    if (eventTable is null) return false;
+    return eventTable.hooks (eventType);
+}
+
+/**
+ * Returns <code>true</code> if the widget has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the widget.
+ * When a widget has been disposed, it is an error to
+ * invoke any other method using the widget.
+ * </p>
+ *
+ * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed () {
+    return (state & DISPOSED) !is 0;
+}
+
+bool isFlipped () {
+    return true;
+}
+
+/**
+ * Returns <code>true</code> if there are any listeners
+ * for the specified event type associated with the receiver,
+ * and <code>false</code> otherwise. The event type is one of
+ * the event constants defined in class <code>DWT</code>.
+ *
+ * @param eventType the type of event
+ * @return true if the event is hooked
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DWT
+ */
+public bool isListening (int eventType) {
+    checkWidget();
+    return hooks (eventType);
+}
+
+bool isTrimHandle (int trimHandle) {
+    return false;
+}
+
+bool isValidSubclass () {
+    return Display.isValidClass (getClass ());
+}
+
+bool isValidThread () {
+    return getDisplay ().isValidThread ();
+}
+
+void flagsChanged(int event) {
+}
+
+void mouseDragged(int event) {
+}
+
+void mouseDown(int event) {
+}
+
+void rightMouseDown(int event) {
+}
+
+void mouseEntered(int event) {
+}
+
+void mouseUp(int event) {
+}
+
+int menuForEvent (int event) {
+    return 0;
+}
+
+void menuNeedsUpdate(int menu) {
+}
+
+void menu_willHighlightItem(int menu, int item) {
+}
+
+void menuWillClose(int menu) {
+}
+
+void menuWillOpen(int menu) {
+}
+
+int numberOfRowsInTableView(int aTableView) {
+    return 0;
+}
+
+int outlineView_child_ofItem(int outlineView, int index, int item) {
+    return 0;
+}
+
+int outlineView_objectValueForTableColumn_byItem(int outlineView, int tableColumn, int item) {
+    return 0;
+}
+
+bool outlineView_isItemExpandable(int outlineView, int item) {
+    return false;
+}
+
+int outlineView_numberOfChildrenOfItem(int outlineView, int item) {
+    return 0;
+}
+
+void outlineView_willDisplayCell_forTableColumn_item(int outlineView, int cell, int tableColumn, int item) {
+}
+
+bool outlineView_shouldCollapseItem(int outlineView, int item) {
+    return false;
+}
+
+bool outlineView_shouldExpandItem(int outlineView, int item) {
+    return false;
+}
+
+void outlineViewSelectionDidChange(int notification) {
+}
+
+void outlineView_setObjectValue_forTableColumn_byItem(int outlineView, int object, int tableColumn, int item) {
+}
+
+/**
+ * Notifies all of the receiver's listeners for events
+ * of the given type that one such event has occurred by
+ * invoking their <code>handleEvent()</code> method.  The
+ * event type is one of the event constants defined in class
+ * <code>DWT</code>.
+ *
+ * @param eventType the type of event which has occurred
+ * @param event the event data
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DWT
+ * @see #addListener
+ * @see #removeListener(int, Listener)
+ */
+public void notifyListeners (int eventType, Event event) {
+    checkWidget();
+    if (event is null) event = new Event ();
+    sendEvent (eventType, event);
+}
+
+void postEvent (int eventType) {
+    sendEvent (eventType, null, false);
+}
+
+void postEvent (int eventType, Event event) {
+    sendEvent (eventType, event, false);
+}
+
+void release (bool destroy) {
+    if ((state & DISPOSE_SENT) is 0) {
+        state |= DISPOSE_SENT;
+        sendEvent (DWT.Dispose);
+    }
+    if ((state & DISPOSED) is 0) {
+        releaseChildren (destroy);
+    }
+    if ((state & RELEASED) is 0) {
+        state |= RELEASED;
+        if (destroy) {
+            releaseParent ();
+            releaseWidget ();
+            destroyWidget ();
+        } else {
+            releaseWidget ();
+            releaseHandle ();
+        }
+    }
+}
+
+void releaseChildren (bool destroy) {
+}
+
+void releaseHandle () {
+    state |= DISPOSED;
+    display = null;
+    if (jniRef !is 0) OS.DeleteGlobalRef(jniRef);
+    jniRef = 0;
+}
+
+void releaseParent () {
+    /* Do nothing */
+}
+
+void releaseWidget () {
+    eventTable = null;
+    data = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs. The event
+ * type is one of the event constants defined in class <code>DWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see DWT
+ * @see #addListener
+ * @see #notifyListeners
+ */
+public void removeListener (int eventType, Listener handler) {
+    checkWidget();
+    if (handler is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (eventType, handler);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the DWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by DWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ */
+protected void removeListener (int eventType, DWTEventListener handler) {
+    checkWidget();
+    if (handler is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (eventType, handler);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the widget is disposed.
+ *
+ * @param listener the listener which should no longer be notified when the receiver is disposed
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DisposeListener
+ * @see #addDisposeListener
+ */
+public void removeDisposeListener (DisposeListener listener) {
+    checkWidget();
+    if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (eventTable is null) return;
+    eventTable.unhook (DWT.Dispose, listener);
+}
+
+void sendArrowSelection () {
+}
+
+void sendEvent (Event event) {
+    Display display = event.display;
+    if (!display.filterEvent (event)) {
+        if (eventTable !is null) eventTable.sendEvent (event);
+    }
+}
+
+void sendEvent (int eventType) {
+    sendEvent (eventType, null, true);
+}
+
+void sendEvent (int eventType, Event event) {
+    sendEvent (eventType, event, true);
+}
+
+void sendEvent (int eventType, Event event, bool send) {
+    if (eventTable is null && !display.filters (eventType)) {
+        return;
+    }
+    if (event is null) event = new Event ();
+    event.type = eventType;
+    event.display = display;
+    event.widget = this;
+    if (event.time is 0) {
+        event.time = display.getLastEventTime ();
+    }
+    if (send) {
+        sendEvent (event);
+    } else {
+        display.postEvent (event);
+    }
+}
+
+bool sendKeyEvent (int type, int theEvent) {
+//  int [] length = new int [1];
+//  int status = OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, 4, length, (char[])null);
+//  if (status is OS.noErr && length [0] > 2) {
+//      int count = 0;
+//      int [] chord = new int [1];
+//      OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
+//      int [] modifiers = new int [1];
+//      OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+//      char [] chars = new char [length [0] / 2];
+//      OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, chars.length * 2, null, chars);
+//      for (int i=0; i<chars.length; i++) {
+//          Event event = new Event ();
+//          event.character = chars [i];
+//          setInputState (event, type, chord [0], modifiers [0]);
+//          if (sendKeyEvent (type, event)) chars [count++] = chars [i];
+//      }
+//      if (count is 0) return false;
+//      if (count !is chars.length - 1) {
+//          OS.SetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, count * 2, chars);
+//      }
+//      return true;
+//  } else {
+//      Event event = new Event ();
+//      if (!setKeyState (event, type, theEvent)) return true;
+//      return sendKeyEvent (type, event);
+//  }
+    return false;
+}
+
+bool sendKeyEvent (int type, Event event) {
+    sendEvent (type, event);
+    // widget could be disposed at this point
+    
+    /*
+    * It is possible (but unlikely), that application
+    * code could have disposed the widget in the key
+    * events.  If this happens, end the processing of
+    * the key by returning false.
+    */
+    if (isDisposed ()) return false;
+    return event.doit;
+}
+
+void sendDoubleSelection() {
+}
+
+void sendHorizontalSelection () {
+}
+
+void sendSelection () {
+}
+
+void sendVerticalSelection () {
+}
+
+/**
+ * Sets the application defined widget data associated
+ * with the receiver to be the argument. The <em>widget
+ * data</em> is a single, unnamed field that is stored
+ * with every widget. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the widget data needs to be notified
+ * when the widget is disposed of, it is the application's
+ * responsibility to hook the Dispose event on the widget and
+ * do so.
+ * </p>
+ *
+ * @param data the widget data
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ * 
+ * @see #getData()
+ */
+public void setData (Object data) {
+    checkWidget();
+    if (SAFARI_EVENTS_FIX_KEY.equals (data)) {
+        state |= SAFARI_EVENTS_FIX;
+        return;
+    }
+    if ((state & KEYED_DATA) !is 0) {
+        ((Object []) this.data) [0] = data;
+    } else {
+        this.data = data;
+    }
+}
+
+/**
+ * Sets the application defined property of the receiver
+ * with the specified name to the given value.
+ * <p>
+ * Applications may associate arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the widget is disposed
+ * of, it is the application's responsibility to hook the
+ * Dispose event on the widget and do so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @param value the new value for the property
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception DWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getData(String)
+ */
+public void setData (String key, Object value) {
+    checkWidget();
+    if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
+    int index = 1;
+    Object [] table = null;
+    if ((state & KEYED_DATA) !is 0) {
+        table = (Object []) data;
+        while (index < table.length) {
+            if (key.equals (table [index])) break;
+            index += 2;
+        }
+    }
+    if (value !is null) {
+        if ((state & KEYED_DATA) !is 0) {
+            if (index is table.length) {
+                Object [] newTable = new Object [table.length + 2];
+                System.arraycopy (table, 0, newTable, 0, table.length);
+                data = table = newTable;
+            }
+        } else {
+            table = new Object [3];
+            table [0] = data;
+            data = table;
+            state |= KEYED_DATA;
+        }
+        table [index] = key;
+        table [index + 1] = value;
+    } else {
+        if ((state & KEYED_DATA) !is 0) {
+            if (index !is table.length) {
+                int length = table.length - 2;
+                if (length is 1) {
+                    data = table [0];
+                    state &= ~KEYED_DATA;
+                } else {
+                    Object [] newTable = new Object [length];
+                    System.arraycopy (table, 0, newTable, 0, index);
+                    System.arraycopy (table, index + 2, newTable, index, length - index);
+                    data = newTable;
+                }
+            }
+        }
+    }
+}
+
+bool setInputState (Event event, int type, int chord, int modifiers) {
+//  if ((chord & 0x01) !is 0) event.stateMask |= DWT.BUTTON1;
+//  if ((chord & 0x02) !is 0) event.stateMask |= DWT.BUTTON3;
+//  if ((chord & 0x04) !is 0) event.stateMask |= DWT.BUTTON2;
+//  if ((chord & 0x08) !is 0) event.stateMask |= DWT.BUTTON4;
+//  if ((chord & 0x10) !is 0) event.stateMask |= DWT.BUTTON5;
+//  
+//  if ((modifiers & OS.optionKey) !is 0) event.stateMask |= DWT.ALT;
+//  if ((modifiers & OS.shiftKey) !is 0) event.stateMask |= DWT.SHIFT;
+//  if ((modifiers & OS.controlKey) !is 0) event.stateMask |= DWT.CONTROL;
+//  if ((modifiers & OS.cmdKey) !is 0) event.stateMask |= DWT.COMMAND;
+//  switch (type) {
+//      case DWT.MouseDown:
+//      case DWT.MouseDoubleClick:
+//          if (event.button is 1) event.stateMask &= ~DWT.BUTTON1;
+//          if (event.button is 2) event.stateMask &= ~DWT.BUTTON2;
+//          if (event.button is 3)  event.stateMask &= ~DWT.BUTTON3;
+//          if (event.button is 4)  event.stateMask &= ~DWT.BUTTON4;
+//          if (event.button is 5)  event.stateMask &= ~DWT.BUTTON5;
+//          break;
+//      case DWT.MouseUp:
+//          if (event.button is 1) event.stateMask |= DWT.BUTTON1;
+//          if (event.button is 2) event.stateMask |= DWT.BUTTON2;
+//          if (event.button is 3) event.stateMask |= DWT.BUTTON3;
+//          if (event.button is 4) event.stateMask |= DWT.BUTTON4;
+//          if (event.button is 5) event.stateMask |= DWT.BUTTON5;
+//          break;
+//      case DWT.KeyDown:
+//      case DWT.Traverse: {
+//          if (event.keyCode !is 0 || event.character !is 0) return true;
+//          int lastModifiers = display.lastModifiers;
+//          if ((modifiers & OS.alphaLock) !is 0 && (lastModifiers & OS.alphaLock) is 0) {
+//              event.keyCode = DWT.CAPS_LOCK;
+//              return true;
+//          }
+//          if ((modifiers & OS.shiftKey) !is 0 && (lastModifiers & OS.shiftKey) is 0) {
+//              event.stateMask &= ~DWT.SHIFT;
+//              event.keyCode = DWT.SHIFT;
+//              return true;
+//          }
+//          if ((modifiers & OS.controlKey) !is 0 && (lastModifiers & OS.controlKey) is 0) {
+//              event.stateMask &= ~DWT.CONTROL;
+//              event.keyCode = DWT.CONTROL;
+//              return true;
+//          }
+//          if ((modifiers & OS.cmdKey) !is 0 && (lastModifiers & OS.cmdKey) is 0) {
+//              event.stateMask &= ~DWT.COMMAND;
+//              event.keyCode = DWT.COMMAND;
+//              return true;
+//          }   
+//          if ((modifiers & OS.optionKey) !is 0 && (lastModifiers & OS.optionKey) is 0) {
+//              event.stateMask &= ~DWT.ALT;
+//              event.keyCode = DWT.ALT;
+//              return true;
+//          }
+//          break;
+//      }
+//      case DWT.KeyUp: {
+//          if (event.keyCode !is 0 || event.character !is 0) return true;
+//          int lastModifiers = display.lastModifiers;
+//          if ((modifiers & OS.alphaLock) is 0 && (lastModifiers & OS.alphaLock) !is 0) {
+//              event.keyCode = DWT.CAPS_LOCK;
+//              return true;
+//          }
+//          if ((modifiers & OS.shiftKey) is 0 && (lastModifiers & OS.shiftKey) !is 0) {
+//              event.stateMask |= DWT.SHIFT;
+//              event.keyCode = DWT.SHIFT;
+//              return true;
+//          }
+//          if ((modifiers & OS.controlKey) is 0 && (lastModifiers & OS.controlKey) !is 0) {
+//              event.stateMask |= DWT.CONTROL;
+//              event.keyCode = DWT.CONTROL;
+//              return true;
+//          }
+//          if ((modifiers & OS.cmdKey) is 0 && (lastModifiers & OS.cmdKey) !is 0) {
+//              event.stateMask |= DWT.COMMAND;
+//              event.keyCode = DWT.COMMAND;
+//              return true;
+//          }
+//          if ((modifiers & OS.optionKey) is 0 && (lastModifiers & OS.optionKey) !is 0) {
+//              event.stateMask |= DWT.ALT;
+//              event.keyCode = DWT.ALT;
+//              return true;
+//          }
+//          break;
+//      }
+//  }
+    return true; 
+}
+
+bool setKeyState (Event event, int type, NSEvent nsEvent) {
+//  bool isNull = false;
+//  int [] keyCode = new int [1];
+//  OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode);
+//  event.keyCode = Display.translateKey (keyCode [0]);
+    switch (event.keyCode) {
+//      case DWT.LF: {
+//          /*
+//          * Feature in the Macintosh.  When the numeric key pad
+//          * Enter key is pressed, it generates '\n'.  This is the
+//          * correct platform behavior but is not portable.  The
+//          * fix is to convert the '\n' into '\r'.
+//          */
+//          event.keyCode = DWT.KEYPAD_CR;
+//          event.character = '\r';
+//          break;
+//      }
+        case DWT.BS: event.character = '\b'; break;
+//      case DWT.CR: event.character = '\r'; break;
+        case DWT.DEL: event.character = 0x7F; break;
+//      case DWT.ESC: event.character = 0x1B; break;
+//      case DWT.TAB: event.character = '\t'; break;
+//      default: {
+//          if (event.keyCode is 0 || (DWT.KEYPAD_MULTIPLY <= event.keyCode && event.keyCode <= DWT.KEYPAD_CR)) {
+//              int [] length = new int [1];
+//              int status = OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, 4, length, (char[])null);
+//              if (status is OS.noErr && length [0] !is 0) {
+//                  char [] chars = new char [1];
+//                  OS.GetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, null, 2, null, chars);
+//                  event.character = chars [0];
+//              }
+//              /*
+//              * Bug in the Mactonish.  For some reason, Ctrl+Shift+'2' and Ctrl+Shift+'6'
+//              * fail to give 0x0 (^@ or ASCII NUL) and 0x1e (^^).  Other control character
+//              * key sequences such as ^A or even Ctrl+Shift+'-' (^_ or 0x1f) are correctly
+//              * translated to control characters.  Since it is not possible to know which
+//              * key combination gives '@' on an international keyboard, there is no way to
+//              * test for either character and convert it to a control character (Shift+'2'
+//              * gives '@' only on an English keyboard) to work around the problem.
+//              *
+//              * There is no fix at this time.
+//              */
+//          }
+//          if (event.keyCode is 0) {
+//              int kchrPtr = OS.GetScriptManagerVariable ((short) OS.smKCHRCache);
+//              if (display.kchrPtr !is kchrPtr) {
+//                  display.kchrPtr = kchrPtr;
+//                  display.kchrState [0] = 0;
+//              }
+//              int result = OS.KeyTranslate (display.kchrPtr, (short)keyCode [0], display.kchrState);
+//              if (result <= 0x7f) {
+//                  event.keyCode = result & 0x7f;
+//              } else {
+//                  int [] encoding = new int [1];
+//                  short keyScript = (short) OS.GetScriptManagerVariable ((short) OS.smKeyScript);
+//                  short regionCode = (short) OS.GetScriptManagerVariable ((short) OS.smRegionCode);
+//                  if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, regionCode, null, encoding) is OS.paramErr) {
+//                      if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, (short) OS.kTextRegionDontCare, null, encoding) is OS.paramErr) {
+//                          encoding [0] = OS.kTextEncodingMacRoman;
+//                      }
+//                  }
+//                  int [] encodingInfo = new int [1];
+//                  OS.CreateTextToUnicodeInfoByEncoding (encoding [0], encodingInfo);
+//                  if (encodingInfo [0] !is 0) {
+//                      char [] chars = new char [1];
+//                      int [] nchars = new int [1];
+//                      byte [] buffer = new byte [2];
+//                      buffer [0] = 1;
+//                      buffer [1] = (byte) (result & 0xFF);
+//                      OS.ConvertFromPStringToUnicode (encodingInfo [0], buffer, chars.length * 2, nchars, chars);
+//                      OS.DisposeTextToUnicodeInfo (encodingInfo);
+//                      event.keyCode = chars [0];
+//                  }
+//              }
+//          }
+//          break;
+//      }
+    }
+//  if (event.keyCode is 0 && event.character is 0) {
+//      if (!isNull) return false;
+//  }
+//  int [] chord = new int [1];
+//  OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
+//  int [] modifiers = new int [1];
+//  OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+//  return setInputState (event, type, chord [0], modifiers [0]);
+    return true;
+}
+
+void tableViewSelectionDidChange (int aNotification) {
+}
+
+int tableView_objectValueForTableColumn_row(int aTableView, int aTableColumn, int rowIndex) {
+    return 0;
+}
+
+void tableView_setObjectValue_forTableColumn_row(int aTableView, int anObject, int aTableColumn, int rowIndex) {    
+}
+
+bool tableView_shouldEditTableColumn_row(int aTableView, int aTableColumn, int rowIndex) {
+    return true;
+}
+
+void tableView_willDisplayCell_forTableColumn_row(int aTableView, int aCell, int aTableColumn, int rowIndex) {
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+    String string = "*Disposed*";
+    if (!isDisposed ()) {
+        string = "*Wrong Thread*";
+        if (isValidThread ()) string = getNameText ();
+    }
+    return getName () + " {" + string + "}";
+}
+
+void willSelectTabViewItem(int tabView, int tabViewItem) {
+}
+
+void windowDidMove(int notification) {
+}
+
+void windowDidResize(int notification) {
+}
+
+void windowDidResignKey(int notification) {
+}
+
+void windowDidBecomeKey(int notification) {
+}
+
+void windowSendEvent(int id, int event) {
+    callSuper(id, OS.sel_sendEvent_1, event);
+}
+
+bool windowShouldClose(int window) {
+    return false;
+}
+
+void windowWillClose(int notification) {
+}
+
+}